1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
90 ## @defgroup l1_measurements Measurements
95 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
168 # MirrorType enumeration
169 POINT = SMESH_MeshEditor.POINT
170 AXIS = SMESH_MeshEditor.AXIS
171 PLANE = SMESH_MeshEditor.PLANE
173 # Smooth_Method enumeration
174 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
175 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
177 # Fineness enumeration (for NETGEN)
185 # Optimization level of GHS3D
187 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
188 # V4.1 (partialy redefines V3.1). Issue 0020574
189 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
191 # Topology treatment way of BLSURF
192 FromCAD, PreProcess, PreProcessPlus = 0,1,2
194 # Element size flag of BLSURF
195 DefaultSize, DefaultGeom, Custom = 0,0,1
197 PrecisionConfusion = 1e-07
199 # TopAbs_State enumeration
200 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 # Methods of splitting a hexahedron into tetrahedra
203 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 ## Converts an angle from degrees to radians
206 def DegreesToRadians(AngleInDegrees):
208 return AngleInDegrees * pi / 180.0
210 # Salome notebook variable separator
213 # Parametrized substitute for PointStruct
214 class PointStructStr:
223 def __init__(self, xStr, yStr, zStr):
227 if isinstance(xStr, str) and notebook.isVariable(xStr):
228 self.x = notebook.get(xStr)
231 if isinstance(yStr, str) and notebook.isVariable(yStr):
232 self.y = notebook.get(yStr)
235 if isinstance(zStr, str) and notebook.isVariable(zStr):
236 self.z = notebook.get(zStr)
240 # Parametrized substitute for PointStruct (with 6 parameters)
241 class PointStructStr6:
256 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
263 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
264 self.x1 = notebook.get(x1Str)
267 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
268 self.x2 = notebook.get(x2Str)
271 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
272 self.y1 = notebook.get(y1Str)
275 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
276 self.y2 = notebook.get(y2Str)
279 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
280 self.z1 = notebook.get(z1Str)
283 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
284 self.z2 = notebook.get(z2Str)
288 # Parametrized substitute for AxisStruct
304 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
311 if isinstance(xStr, str) and notebook.isVariable(xStr):
312 self.x = notebook.get(xStr)
315 if isinstance(yStr, str) and notebook.isVariable(yStr):
316 self.y = notebook.get(yStr)
319 if isinstance(zStr, str) and notebook.isVariable(zStr):
320 self.z = notebook.get(zStr)
323 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
324 self.dx = notebook.get(dxStr)
327 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
328 self.dy = notebook.get(dyStr)
331 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
332 self.dz = notebook.get(dzStr)
336 # Parametrized substitute for DirStruct
339 def __init__(self, pointStruct):
340 self.pointStruct = pointStruct
342 # Returns list of variable values from salome notebook
343 def ParsePointStruct(Point):
344 Parameters = 2*var_separator
345 if isinstance(Point, PointStructStr):
346 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
347 Point = PointStruct(Point.x, Point.y, Point.z)
348 return Point, Parameters
350 # Returns list of variable values from salome notebook
351 def ParseDirStruct(Dir):
352 Parameters = 2*var_separator
353 if isinstance(Dir, DirStructStr):
354 pntStr = Dir.pointStruct
355 if isinstance(pntStr, PointStructStr6):
356 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
357 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
358 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
359 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
361 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
362 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
363 Dir = DirStruct(Point)
364 return Dir, Parameters
366 # Returns list of variable values from salome notebook
367 def ParseAxisStruct(Axis):
368 Parameters = 5*var_separator
369 if isinstance(Axis, AxisStructStr):
370 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
371 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
372 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
373 return Axis, Parameters
375 ## Return list of variable values from salome notebook
376 def ParseAngles(list):
379 for parameter in list:
380 if isinstance(parameter,str) and notebook.isVariable(parameter):
381 Result.append(DegreesToRadians(notebook.get(parameter)))
384 Result.append(parameter)
387 Parameters = Parameters + str(parameter)
388 Parameters = Parameters + var_separator
390 Parameters = Parameters[:len(Parameters)-1]
391 return Result, Parameters
393 def IsEqual(val1, val2, tol=PrecisionConfusion):
394 if abs(val1 - val2) < tol:
404 if isinstance(obj, SALOMEDS._objref_SObject):
407 ior = salome.orb.object_to_string(obj)
410 studies = salome.myStudyManager.GetOpenStudies()
411 for sname in studies:
412 s = salome.myStudyManager.GetStudyByName(sname)
414 sobj = s.FindObjectIOR(ior)
415 if not sobj: continue
416 return sobj.GetName()
417 if hasattr(obj, "GetName"):
418 # unknown CORBA object, having GetName() method
421 # unknown CORBA object, no GetName() method
424 if hasattr(obj, "GetName"):
425 # unknown non-CORBA object, having GetName() method
428 raise RuntimeError, "Null or invalid object"
430 ## Prints error message if a hypothesis was not assigned.
431 def TreatHypoStatus(status, hypName, geomName, isAlgo):
433 hypType = "algorithm"
435 hypType = "hypothesis"
437 if status == HYP_UNKNOWN_FATAL :
438 reason = "for unknown reason"
439 elif status == HYP_INCOMPATIBLE :
440 reason = "this hypothesis mismatches the algorithm"
441 elif status == HYP_NOTCONFORM :
442 reason = "a non-conform mesh would be built"
443 elif status == HYP_ALREADY_EXIST :
444 if isAlgo: return # it does not influence anything
445 reason = hypType + " of the same dimension is already assigned to this shape"
446 elif status == HYP_BAD_DIM :
447 reason = hypType + " mismatches the shape"
448 elif status == HYP_CONCURENT :
449 reason = "there are concurrent hypotheses on sub-shapes"
450 elif status == HYP_BAD_SUBSHAPE :
451 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
452 elif status == HYP_BAD_GEOMETRY:
453 reason = "geometry mismatches the expectation of the algorithm"
454 elif status == HYP_HIDDEN_ALGO:
455 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
456 elif status == HYP_HIDING_ALGO:
457 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
458 elif status == HYP_NEED_SHAPE:
459 reason = "Algorithm can't work without shape"
462 hypName = '"' + hypName + '"'
463 geomName= '"' + geomName+ '"'
464 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
465 print hypName, "was assigned to", geomName,"but", reason
466 elif not geomName == '""':
467 print hypName, "was not assigned to",geomName,":", reason
469 print hypName, "was not assigned:", reason
472 ## Check meshing plugin availability
473 def CheckPlugin(plugin):
474 if plugin == NETGEN and noNETGENPlugin:
475 print "Warning: NETGENPlugin module unavailable"
477 elif plugin == GHS3D and noGHS3DPlugin:
478 print "Warning: GHS3DPlugin module unavailable"
480 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
481 print "Warning: GHS3DPRLPlugin module unavailable"
483 elif plugin == Hexotic and noHexoticPlugin:
484 print "Warning: HexoticPlugin module unavailable"
486 elif plugin == BLSURF and noBLSURFPlugin:
487 print "Warning: BLSURFPlugin module unavailable"
491 # end of l1_auxiliary
494 # All methods of this class are accessible directly from the smesh.py package.
495 class smeshDC(SMESH._objref_SMESH_Gen):
497 ## Sets the current study and Geometry component
498 # @ingroup l1_auxiliary
499 def init_smesh(self,theStudy,geompyD):
500 self.SetCurrentStudy(theStudy,geompyD)
502 ## Creates an empty Mesh. This mesh can have an underlying geometry.
503 # @param obj the Geometrical object on which the mesh is built. If not defined,
504 # the mesh will have no underlying geometry.
505 # @param name the name for the new mesh.
506 # @return an instance of Mesh class.
507 # @ingroup l2_construct
508 def Mesh(self, obj=0, name=0):
509 if isinstance(obj,str):
511 return Mesh(self,self.geompyD,obj,name)
513 ## Returns a long value from enumeration
514 # Should be used for SMESH.FunctorType enumeration
515 # @ingroup l1_controls
516 def EnumToLong(self,theItem):
519 ## Returns a string representation of the color.
520 # To be used with filters.
521 # @param c color value (SALOMEDS.Color)
522 # @ingroup l1_controls
523 def ColorToString(self,c):
525 if isinstance(c, SALOMEDS.Color):
526 val = "%s;%s;%s" % (c.R, c.G, c.B)
527 elif isinstance(c, str):
530 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
533 ## Gets PointStruct from vertex
534 # @param theVertex a GEOM object(vertex)
535 # @return SMESH.PointStruct
536 # @ingroup l1_auxiliary
537 def GetPointStruct(self,theVertex):
538 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
539 return PointStruct(x,y,z)
541 ## Gets DirStruct from vector
542 # @param theVector a GEOM object(vector)
543 # @return SMESH.DirStruct
544 # @ingroup l1_auxiliary
545 def GetDirStruct(self,theVector):
546 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
547 if(len(vertices) != 2):
548 print "Error: vector object is incorrect."
550 p1 = self.geompyD.PointCoordinates(vertices[0])
551 p2 = self.geompyD.PointCoordinates(vertices[1])
552 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
553 dirst = DirStruct(pnt)
556 ## Makes DirStruct from a triplet
557 # @param x,y,z vector components
558 # @return SMESH.DirStruct
559 # @ingroup l1_auxiliary
560 def MakeDirStruct(self,x,y,z):
561 pnt = PointStruct(x,y,z)
562 return DirStruct(pnt)
564 ## Get AxisStruct from object
565 # @param theObj a GEOM object (line or plane)
566 # @return SMESH.AxisStruct
567 # @ingroup l1_auxiliary
568 def GetAxisStruct(self,theObj):
569 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
571 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
572 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
573 vertex1 = self.geompyD.PointCoordinates(vertex1)
574 vertex2 = self.geompyD.PointCoordinates(vertex2)
575 vertex3 = self.geompyD.PointCoordinates(vertex3)
576 vertex4 = self.geompyD.PointCoordinates(vertex4)
577 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
578 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
579 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
580 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
582 elif len(edges) == 1:
583 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
584 p1 = self.geompyD.PointCoordinates( vertex1 )
585 p2 = self.geompyD.PointCoordinates( vertex2 )
586 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
590 # From SMESH_Gen interface:
591 # ------------------------
593 ## Sets the given name to the object
594 # @param obj the object to rename
595 # @param name a new object name
596 # @ingroup l1_auxiliary
597 def SetName(self, obj, name):
598 if isinstance( obj, Mesh ):
600 elif isinstance( obj, Mesh_Algorithm ):
601 obj = obj.GetAlgorithm()
602 ior = salome.orb.object_to_string(obj)
603 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
605 ## Sets the current mode
606 # @ingroup l1_auxiliary
607 def SetEmbeddedMode( self,theMode ):
608 #self.SetEmbeddedMode(theMode)
609 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
611 ## Gets the current mode
612 # @ingroup l1_auxiliary
613 def IsEmbeddedMode(self):
614 #return self.IsEmbeddedMode()
615 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
617 ## Sets the current study
618 # @ingroup l1_auxiliary
619 def SetCurrentStudy( self, theStudy, geompyD = None ):
620 #self.SetCurrentStudy(theStudy)
623 geompyD = geompy.geom
626 self.SetGeomEngine(geompyD)
627 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
629 ## Gets the current study
630 # @ingroup l1_auxiliary
631 def GetCurrentStudy(self):
632 #return self.GetCurrentStudy()
633 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
635 ## Creates a Mesh object importing data from the given UNV file
636 # @return an instance of Mesh class
638 def CreateMeshesFromUNV( self,theFileName ):
639 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
640 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
643 ## Creates a Mesh object(s) importing data from the given MED file
644 # @return a list of Mesh class instances
646 def CreateMeshesFromMED( self,theFileName ):
647 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
649 for iMesh in range(len(aSmeshMeshes)) :
650 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
651 aMeshes.append(aMesh)
652 return aMeshes, aStatus
654 ## Creates a Mesh object importing data from the given STL file
655 # @return an instance of Mesh class
657 def CreateMeshesFromSTL( self, theFileName ):
658 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
659 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
662 ## From SMESH_Gen interface
663 # @return the list of integer values
664 # @ingroup l1_auxiliary
665 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
666 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
668 ## From SMESH_Gen interface. Creates a pattern
669 # @return an instance of SMESH_Pattern
671 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
672 # @ingroup l2_modif_patterns
673 def GetPattern(self):
674 return SMESH._objref_SMESH_Gen.GetPattern(self)
676 ## Sets number of segments per diagonal of boundary box of geometry by which
677 # default segment length of appropriate 1D hypotheses is defined.
678 # Default value is 10
679 # @ingroup l1_auxiliary
680 def SetBoundaryBoxSegmentation(self, nbSegments):
681 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
683 ## Concatenate the given meshes into one mesh.
684 # @return an instance of Mesh class
685 # @param meshes the meshes to combine into one mesh
686 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
687 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
688 # @param mergeTolerance tolerance for merging nodes
689 # @param allGroups forces creation of groups of all elements
690 def Concatenate( self, meshes, uniteIdenticalGroups,
691 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
692 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
693 for i,m in enumerate(meshes):
694 if isinstance(m, Mesh):
695 meshes[i] = m.GetMesh()
697 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
698 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
700 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
701 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
702 aSmeshMesh.SetParameters(Parameters)
703 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
706 # Filtering. Auxiliary functions:
707 # ------------------------------
709 ## Creates an empty criterion
710 # @return SMESH.Filter.Criterion
711 # @ingroup l1_controls
712 def GetEmptyCriterion(self):
713 Type = self.EnumToLong(FT_Undefined)
714 Compare = self.EnumToLong(FT_Undefined)
718 UnaryOp = self.EnumToLong(FT_Undefined)
719 BinaryOp = self.EnumToLong(FT_Undefined)
722 Precision = -1 ##@1e-07
723 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
724 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
726 ## Creates a criterion by the given parameters
727 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
728 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
729 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
730 # @param Treshold the threshold value (range of ids as string, shape, numeric)
731 # @param UnaryOp FT_LogicalNOT or FT_Undefined
732 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
733 # FT_Undefined (must be for the last criterion of all criteria)
734 # @return SMESH.Filter.Criterion
735 # @ingroup l1_controls
736 def GetCriterion(self,elementType,
738 Compare = FT_EqualTo,
740 UnaryOp=FT_Undefined,
741 BinaryOp=FT_Undefined):
742 aCriterion = self.GetEmptyCriterion()
743 aCriterion.TypeOfElement = elementType
744 aCriterion.Type = self.EnumToLong(CritType)
748 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
749 aCriterion.Compare = self.EnumToLong(Compare)
750 elif Compare == "=" or Compare == "==":
751 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
753 aCriterion.Compare = self.EnumToLong(FT_LessThan)
755 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
757 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
760 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
761 FT_BelongToCylinder, FT_LyingOnGeom]:
762 # Checks the treshold
763 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
764 aCriterion.ThresholdStr = GetName(aTreshold)
765 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
767 print "Error: The treshold should be a shape."
769 elif CritType == FT_RangeOfIds:
770 # Checks the treshold
771 if isinstance(aTreshold, str):
772 aCriterion.ThresholdStr = aTreshold
774 print "Error: The treshold should be a string."
776 elif CritType == FT_ElemGeomType:
777 # Checks the treshold
779 aCriterion.Threshold = self.EnumToLong(aTreshold)
781 if isinstance(aTreshold, int):
782 aCriterion.Threshold = aTreshold
784 print "Error: The treshold should be an integer or SMESH.GeometryType."
788 elif CritType == FT_GroupColor:
789 # Checks the treshold
791 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
793 print "Error: The threshold value should be of SALOMEDS.Color type"
796 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
797 FT_FreeFaces, FT_LinearOrQuadratic]:
798 # At this point the treshold is unnecessary
799 if aTreshold == FT_LogicalNOT:
800 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
801 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
802 aCriterion.BinaryOp = aTreshold
806 aTreshold = float(aTreshold)
807 aCriterion.Threshold = aTreshold
809 print "Error: The treshold should be a number."
812 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
813 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
815 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
816 aCriterion.BinaryOp = self.EnumToLong(Treshold)
818 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
819 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
821 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
822 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
826 ## Creates a filter with the given parameters
827 # @param elementType the type of elements in the group
828 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
829 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
830 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
831 # @param UnaryOp FT_LogicalNOT or FT_Undefined
832 # @return SMESH_Filter
833 # @ingroup l1_controls
834 def GetFilter(self,elementType,
835 CritType=FT_Undefined,
838 UnaryOp=FT_Undefined):
839 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
840 aFilterMgr = self.CreateFilterManager()
841 aFilter = aFilterMgr.CreateFilter()
843 aCriteria.append(aCriterion)
844 aFilter.SetCriteria(aCriteria)
848 ## Creates a numerical functor by its type
849 # @param theCriterion FT_...; functor type
850 # @return SMESH_NumericalFunctor
851 # @ingroup l1_controls
852 def GetFunctor(self,theCriterion):
853 aFilterMgr = self.CreateFilterManager()
854 if theCriterion == FT_AspectRatio:
855 return aFilterMgr.CreateAspectRatio()
856 elif theCriterion == FT_AspectRatio3D:
857 return aFilterMgr.CreateAspectRatio3D()
858 elif theCriterion == FT_Warping:
859 return aFilterMgr.CreateWarping()
860 elif theCriterion == FT_MinimumAngle:
861 return aFilterMgr.CreateMinimumAngle()
862 elif theCriterion == FT_Taper:
863 return aFilterMgr.CreateTaper()
864 elif theCriterion == FT_Skew:
865 return aFilterMgr.CreateSkew()
866 elif theCriterion == FT_Area:
867 return aFilterMgr.CreateArea()
868 elif theCriterion == FT_Volume3D:
869 return aFilterMgr.CreateVolume3D()
870 elif theCriterion == FT_MaxElementLength2D:
871 return aFilterMgr.CreateMaxElementLength2D()
872 elif theCriterion == FT_MaxElementLength3D:
873 return aFilterMgr.CreateMaxElementLength3D()
874 elif theCriterion == FT_MultiConnection:
875 return aFilterMgr.CreateMultiConnection()
876 elif theCriterion == FT_MultiConnection2D:
877 return aFilterMgr.CreateMultiConnection2D()
878 elif theCriterion == FT_Length:
879 return aFilterMgr.CreateLength()
880 elif theCriterion == FT_Length2D:
881 return aFilterMgr.CreateLength2D()
883 print "Error: given parameter is not numerucal functor type."
885 ## Creates hypothesis
886 # @param theHType mesh hypothesis type (string)
887 # @param theLibName mesh plug-in library name
888 # @return created hypothesis instance
889 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
890 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
892 ## Gets the mesh stattistic
893 # @return dictionary type element - count of elements
894 # @ingroup l1_meshinfo
895 def GetMeshInfo(self, obj):
896 if isinstance( obj, Mesh ):
899 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
900 values = obj.GetMeshInfo()
901 for i in range(SMESH.Entity_Last._v):
902 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
906 ## Get minimum distance between two objects
908 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
909 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
911 # @param src1 first source object
912 # @param src2 second source object
913 # @param id1 node/element id from the first source
914 # @param id2 node/element id from the second (or first) source
915 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
916 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
917 # @return minimum distance value
918 # @sa GetMinDistance()
919 # @ingroup l1_measurements
920 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
921 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
925 result = result.value
928 ## Get measure structure specifying minimum distance data between two objects
930 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
931 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
933 # @param src1 first source object
934 # @param src2 second source object
935 # @param id1 node/element id from the first source
936 # @param id2 node/element id from the second (or first) source
937 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
938 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
939 # @return Measure structure or None if input data is invalid
941 # @ingroup l1_measurements
942 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
943 if isinstance(src1, Mesh): src1 = src1.mesh
944 if isinstance(src2, Mesh): src2 = src2.mesh
945 if src2 is None and id2 != 0: src2 = src1
946 if not hasattr(src1, "_narrow"): return None
947 src1 = src1._narrow(SMESH.SMESH_IDSource)
948 if not src1: return None
951 e = m.GetMeshEditor()
953 src1 = e.MakeIDSource([id1], SMESH.FACE)
955 src1 = e.MakeIDSource([id1], SMESH.NODE)
957 if hasattr(src2, "_narrow"):
958 src2 = src2._narrow(SMESH.SMESH_IDSource)
959 if src2 and id2 != 0:
961 e = m.GetMeshEditor()
963 src2 = e.MakeIDSource([id2], SMESH.FACE)
965 src2 = e.MakeIDSource([id2], SMESH.NODE)
968 aMeasurements = self.CreateMeasurements()
969 result = aMeasurements.MinDistance(src1, src2)
970 aMeasurements.Destroy()
973 ## Get bounding box of the specified object(s)
974 # @param objects single source object or list of source objects
975 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
976 # @sa GetBoundingBox()
977 # @ingroup l1_measurements
978 def BoundingBox(self, objects):
979 result = self.GetBoundingBox(objects)
983 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
986 ## Get measure structure specifying bounding box data of the specified object(s)
987 # @param objects single source object or list of source objects
988 # @return Measure structure
990 # @ingroup l1_measurements
991 def GetBoundingBox(self, objects):
992 if isinstance(objects, tuple):
993 objects = list(objects)
994 if not isinstance(objects, list):
998 if isinstance(o, Mesh):
999 srclist.append(o.mesh)
1000 elif hasattr(o, "_narrow"):
1001 src = o._narrow(SMESH.SMESH_IDSource)
1002 if src: srclist.append(src)
1005 aMeasurements = self.CreateMeasurements()
1006 result = aMeasurements.BoundingBox(srclist)
1007 aMeasurements.Destroy()
1011 #Registering the new proxy for SMESH_Gen
1012 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1015 # Public class: Mesh
1016 # ==================
1018 ## This class allows defining and managing a mesh.
1019 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1020 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1021 # new nodes and elements and by changing the existing entities), to get information
1022 # about a mesh and to export a mesh into different formats.
1031 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1032 # sets the GUI name of this mesh to \a name.
1033 # @param smeshpyD an instance of smeshDC class
1034 # @param geompyD an instance of geompyDC class
1035 # @param obj Shape to be meshed or SMESH_Mesh object
1036 # @param name Study name of the mesh
1037 # @ingroup l2_construct
1038 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1039 self.smeshpyD=smeshpyD
1040 self.geompyD=geompyD
1044 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1046 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1047 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1050 self.mesh = self.smeshpyD.CreateEmptyMesh()
1052 self.smeshpyD.SetName(self.mesh, name)
1054 self.smeshpyD.SetName(self.mesh, GetName(obj))
1057 self.geom = self.mesh.GetShapeToMesh()
1059 self.editor = self.mesh.GetMeshEditor()
1061 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1062 # @param theMesh a SMESH_Mesh object
1063 # @ingroup l2_construct
1064 def SetMesh(self, theMesh):
1066 self.geom = self.mesh.GetShapeToMesh()
1068 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1069 # @return a SMESH_Mesh object
1070 # @ingroup l2_construct
1074 ## Gets the name of the mesh
1075 # @return the name of the mesh as a string
1076 # @ingroup l2_construct
1078 name = GetName(self.GetMesh())
1081 ## Sets a name to the mesh
1082 # @param name a new name of the mesh
1083 # @ingroup l2_construct
1084 def SetName(self, name):
1085 self.smeshpyD.SetName(self.GetMesh(), name)
1087 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1088 # The subMesh object gives access to the IDs of nodes and elements.
1089 # @param theSubObject a geometrical object (shape)
1090 # @param theName a name for the submesh
1091 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1092 # @ingroup l2_submeshes
1093 def GetSubMesh(self, theSubObject, theName):
1094 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1097 ## Returns the shape associated to the mesh
1098 # @return a GEOM_Object
1099 # @ingroup l2_construct
1103 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1104 # @param geom the shape to be meshed (GEOM_Object)
1105 # @ingroup l2_construct
1106 def SetShape(self, geom):
1107 self.mesh = self.smeshpyD.CreateMesh(geom)
1109 ## Returns true if the hypotheses are defined well
1110 # @param theSubObject a subshape of a mesh shape
1111 # @return True or False
1112 # @ingroup l2_construct
1113 def IsReadyToCompute(self, theSubObject):
1114 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1116 ## Returns errors of hypotheses definition.
1117 # The list of errors is empty if everything is OK.
1118 # @param theSubObject a subshape of a mesh shape
1119 # @return a list of errors
1120 # @ingroup l2_construct
1121 def GetAlgoState(self, theSubObject):
1122 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1124 ## Returns a geometrical object on which the given element was built.
1125 # The returned geometrical object, if not nil, is either found in the
1126 # study or published by this method with the given name
1127 # @param theElementID the id of the mesh element
1128 # @param theGeomName the user-defined name of the geometrical object
1129 # @return GEOM::GEOM_Object instance
1130 # @ingroup l2_construct
1131 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1132 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1134 ## Returns the mesh dimension depending on the dimension of the underlying shape
1135 # @return mesh dimension as an integer value [0,3]
1136 # @ingroup l1_auxiliary
1137 def MeshDimension(self):
1138 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1139 if len( shells ) > 0 :
1141 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1143 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1149 ## Creates a segment discretization 1D algorithm.
1150 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1151 # \n If the optional \a geom parameter is not set, this algorithm is global.
1152 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1153 # @param algo the type of the required algorithm. Possible values are:
1155 # - smesh.PYTHON for discretization via a python function,
1156 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1157 # @param geom If defined is the subshape to be meshed
1158 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1159 # @ingroup l3_algos_basic
1160 def Segment(self, algo=REGULAR, geom=0):
1161 ## if Segment(geom) is called by mistake
1162 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1163 algo, geom = geom, algo
1164 if not algo: algo = REGULAR
1167 return Mesh_Segment(self, geom)
1168 elif algo == PYTHON:
1169 return Mesh_Segment_Python(self, geom)
1170 elif algo == COMPOSITE:
1171 return Mesh_CompositeSegment(self, geom)
1173 return Mesh_Segment(self, geom)
1175 ## Enables creation of nodes and segments usable by 2D algoritms.
1176 # The added nodes and segments must be bound to edges and vertices by
1177 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1178 # If the optional \a geom parameter is not set, this algorithm is global.
1179 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1180 # @param geom the subshape to be manually meshed
1181 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1182 # @ingroup l3_algos_basic
1183 def UseExistingSegments(self, geom=0):
1184 algo = Mesh_UseExisting(1,self,geom)
1185 return algo.GetAlgorithm()
1187 ## Enables creation of nodes and faces usable by 3D algoritms.
1188 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1189 # and SetMeshElementOnShape()
1190 # If the optional \a geom parameter is not set, this algorithm is global.
1191 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1192 # @param geom the subshape to be manually meshed
1193 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1194 # @ingroup l3_algos_basic
1195 def UseExistingFaces(self, geom=0):
1196 algo = Mesh_UseExisting(2,self,geom)
1197 return algo.GetAlgorithm()
1199 ## Creates a triangle 2D algorithm for faces.
1200 # If the optional \a geom parameter is not set, this algorithm is global.
1201 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1202 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1203 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1204 # @return an instance of Mesh_Triangle algorithm
1205 # @ingroup l3_algos_basic
1206 def Triangle(self, algo=MEFISTO, geom=0):
1207 ## if Triangle(geom) is called by mistake
1208 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1211 return Mesh_Triangle(self, algo, geom)
1213 ## Creates a quadrangle 2D algorithm for faces.
1214 # If the optional \a geom parameter is not set, this algorithm is global.
1215 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1216 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1217 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1218 # @return an instance of Mesh_Quadrangle algorithm
1219 # @ingroup l3_algos_basic
1220 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1221 if algo==RADIAL_QUAD:
1222 return Mesh_RadialQuadrangle1D2D(self,geom)
1224 return Mesh_Quadrangle(self, geom)
1226 ## Creates a tetrahedron 3D algorithm for solids.
1227 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1228 # If the optional \a geom parameter is not set, this algorithm is global.
1229 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1230 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1231 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1232 # @return an instance of Mesh_Tetrahedron algorithm
1233 # @ingroup l3_algos_basic
1234 def Tetrahedron(self, algo=NETGEN, geom=0):
1235 ## if Tetrahedron(geom) is called by mistake
1236 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1237 algo, geom = geom, algo
1238 if not algo: algo = NETGEN
1240 return Mesh_Tetrahedron(self, algo, geom)
1242 ## Creates a hexahedron 3D algorithm for solids.
1243 # If the optional \a geom parameter is not set, this algorithm is global.
1244 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1245 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1246 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1247 # @return an instance of Mesh_Hexahedron algorithm
1248 # @ingroup l3_algos_basic
1249 def Hexahedron(self, algo=Hexa, geom=0):
1250 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1251 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1252 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1253 elif geom == 0: algo, geom = Hexa, algo
1254 return Mesh_Hexahedron(self, algo, geom)
1256 ## Deprecated, used only for compatibility!
1257 # @return an instance of Mesh_Netgen algorithm
1258 # @ingroup l3_algos_basic
1259 def Netgen(self, is3D, geom=0):
1260 return Mesh_Netgen(self, is3D, geom)
1262 ## Creates a projection 1D algorithm for edges.
1263 # If the optional \a geom parameter is not set, this algorithm is global.
1264 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1265 # @param geom If defined, the subshape to be meshed
1266 # @return an instance of Mesh_Projection1D algorithm
1267 # @ingroup l3_algos_proj
1268 def Projection1D(self, geom=0):
1269 return Mesh_Projection1D(self, geom)
1271 ## Creates a projection 2D algorithm for faces.
1272 # If the optional \a geom parameter is not set, this algorithm is global.
1273 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1274 # @param geom If defined, the subshape to be meshed
1275 # @return an instance of Mesh_Projection2D algorithm
1276 # @ingroup l3_algos_proj
1277 def Projection2D(self, geom=0):
1278 return Mesh_Projection2D(self, geom)
1280 ## Creates a projection 3D algorithm for solids.
1281 # If the optional \a geom parameter is not set, this algorithm is global.
1282 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1283 # @param geom If defined, the subshape to be meshed
1284 # @return an instance of Mesh_Projection3D algorithm
1285 # @ingroup l3_algos_proj
1286 def Projection3D(self, geom=0):
1287 return Mesh_Projection3D(self, geom)
1289 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1290 # If the optional \a geom parameter is not set, this algorithm is global.
1291 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1292 # @param geom If defined, the subshape to be meshed
1293 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1294 # @ingroup l3_algos_radialp l3_algos_3dextr
1295 def Prism(self, geom=0):
1299 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1300 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1301 if nbSolids == 0 or nbSolids == nbShells:
1302 return Mesh_Prism3D(self, geom)
1303 return Mesh_RadialPrism3D(self, geom)
1305 ## Evaluates size of prospective mesh on a shape
1306 # @return True or False
1307 def Evaluate(self, geom=0):
1308 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1310 geom = self.mesh.GetShapeToMesh()
1313 return self.smeshpyD.Evaluate(self.mesh, geom)
1316 ## Computes the mesh and returns the status of the computation
1317 # @param geom geomtrical shape on which mesh data should be computed
1318 # @param discardModifs if True and the mesh has been edited since
1319 # a last total re-compute and that may prevent successful partial re-compute,
1320 # then the mesh is cleaned before Compute()
1321 # @return True or False
1322 # @ingroup l2_construct
1323 def Compute(self, geom=0, discardModifs=False):
1324 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1326 geom = self.mesh.GetShapeToMesh()
1331 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1333 ok = self.smeshpyD.Compute(self.mesh, geom)
1334 except SALOME.SALOME_Exception, ex:
1335 print "Mesh computation failed, exception caught:"
1336 print " ", ex.details.text
1339 print "Mesh computation failed, exception caught:"
1340 traceback.print_exc()
1344 # Treat compute errors
1345 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1346 for err in computeErrors:
1348 if self.mesh.HasShapeToMesh():
1350 mainIOR = salome.orb.object_to_string(geom)
1351 for sname in salome.myStudyManager.GetOpenStudies():
1352 s = salome.myStudyManager.GetStudyByName(sname)
1354 mainSO = s.FindObjectIOR(mainIOR)
1355 if not mainSO: continue
1356 if err.subShapeID == 1:
1357 shapeText = ' on "%s"' % mainSO.GetName()
1358 subIt = s.NewChildIterator(mainSO)
1360 subSO = subIt.Value()
1362 obj = subSO.GetObject()
1363 if not obj: continue
1364 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1366 ids = go.GetSubShapeIndices()
1367 if len(ids) == 1 and ids[0] == err.subShapeID:
1368 shapeText = ' on "%s"' % subSO.GetName()
1371 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1373 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1375 shapeText = " on subshape #%s" % (err.subShapeID)
1377 shapeText = " on subshape #%s" % (err.subShapeID)
1379 stdErrors = ["OK", #COMPERR_OK
1380 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1381 "std::exception", #COMPERR_STD_EXCEPTION
1382 "OCC exception", #COMPERR_OCC_EXCEPTION
1383 "SALOME exception", #COMPERR_SLM_EXCEPTION
1384 "Unknown exception", #COMPERR_EXCEPTION
1385 "Memory allocation problem", #COMPERR_MEMORY_PB
1386 "Algorithm failed", #COMPERR_ALGO_FAILED
1387 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1389 if err.code < len(stdErrors): errText = stdErrors[err.code]
1391 errText = "code %s" % -err.code
1392 if errText: errText += ". "
1393 errText += err.comment
1394 if allReasons != "":allReasons += "\n"
1395 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1399 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1401 if err.isGlobalAlgo:
1409 reason = '%s %sD algorithm is missing' % (glob, dim)
1410 elif err.state == HYP_MISSING:
1411 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1412 % (glob, dim, name, dim))
1413 elif err.state == HYP_NOTCONFORM:
1414 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1415 elif err.state == HYP_BAD_PARAMETER:
1416 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1417 % ( glob, dim, name ))
1418 elif err.state == HYP_BAD_GEOMETRY:
1419 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1420 'geometry' % ( glob, dim, name ))
1422 reason = "For unknown reason."+\
1423 " Revise Mesh.Compute() implementation in smeshDC.py!"
1425 if allReasons != "":allReasons += "\n"
1426 allReasons += reason
1428 if allReasons != "":
1429 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1433 print '"' + GetName(self.mesh) + '"',"has not been computed."
1436 if salome.sg.hasDesktop():
1437 smeshgui = salome.ImportComponentGUI("SMESH")
1438 smeshgui.Init(self.mesh.GetStudyId())
1439 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1440 salome.sg.updateObjBrowser(1)
1444 ## Return submesh objects list in meshing order
1445 # @return list of list of submesh objects
1446 # @ingroup l2_construct
1447 def GetMeshOrder(self):
1448 return self.mesh.GetMeshOrder()
1450 ## Return submesh objects list in meshing order
1451 # @return list of list of submesh objects
1452 # @ingroup l2_construct
1453 def SetMeshOrder(self, submeshes):
1454 return self.mesh.SetMeshOrder(submeshes)
1456 ## Removes all nodes and elements
1457 # @ingroup l2_construct
1460 if salome.sg.hasDesktop():
1461 smeshgui = salome.ImportComponentGUI("SMESH")
1462 smeshgui.Init(self.mesh.GetStudyId())
1463 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1464 salome.sg.updateObjBrowser(1)
1466 ## Removes all nodes and elements of indicated shape
1467 # @ingroup l2_construct
1468 def ClearSubMesh(self, geomId):
1469 self.mesh.ClearSubMesh(geomId)
1470 if salome.sg.hasDesktop():
1471 smeshgui = salome.ImportComponentGUI("SMESH")
1472 smeshgui.Init(self.mesh.GetStudyId())
1473 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1474 salome.sg.updateObjBrowser(1)
1476 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1477 # @param fineness [0,-1] defines mesh fineness
1478 # @return True or False
1479 # @ingroup l3_algos_basic
1480 def AutomaticTetrahedralization(self, fineness=0):
1481 dim = self.MeshDimension()
1483 self.RemoveGlobalHypotheses()
1484 self.Segment().AutomaticLength(fineness)
1486 self.Triangle().LengthFromEdges()
1489 self.Tetrahedron(NETGEN)
1491 return self.Compute()
1493 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1494 # @param fineness [0,-1] defines mesh fineness
1495 # @return True or False
1496 # @ingroup l3_algos_basic
1497 def AutomaticHexahedralization(self, fineness=0):
1498 dim = self.MeshDimension()
1499 # assign the hypotheses
1500 self.RemoveGlobalHypotheses()
1501 self.Segment().AutomaticLength(fineness)
1508 return self.Compute()
1510 ## Assigns a hypothesis
1511 # @param hyp a hypothesis to assign
1512 # @param geom a subhape of mesh geometry
1513 # @return SMESH.Hypothesis_Status
1514 # @ingroup l2_hypotheses
1515 def AddHypothesis(self, hyp, geom=0):
1516 if isinstance( hyp, Mesh_Algorithm ):
1517 hyp = hyp.GetAlgorithm()
1522 geom = self.mesh.GetShapeToMesh()
1524 status = self.mesh.AddHypothesis(geom, hyp)
1525 isAlgo = hyp._narrow( SMESH_Algo )
1526 hyp_name = GetName( hyp )
1529 geom_name = GetName( geom )
1530 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1533 ## Unassigns a hypothesis
1534 # @param hyp a hypothesis to unassign
1535 # @param geom a subshape of mesh geometry
1536 # @return SMESH.Hypothesis_Status
1537 # @ingroup l2_hypotheses
1538 def RemoveHypothesis(self, hyp, geom=0):
1539 if isinstance( hyp, Mesh_Algorithm ):
1540 hyp = hyp.GetAlgorithm()
1545 status = self.mesh.RemoveHypothesis(geom, hyp)
1548 ## Gets the list of hypotheses added on a geometry
1549 # @param geom a subshape of mesh geometry
1550 # @return the sequence of SMESH_Hypothesis
1551 # @ingroup l2_hypotheses
1552 def GetHypothesisList(self, geom):
1553 return self.mesh.GetHypothesisList( geom )
1555 ## Removes all global hypotheses
1556 # @ingroup l2_hypotheses
1557 def RemoveGlobalHypotheses(self):
1558 current_hyps = self.mesh.GetHypothesisList( self.geom )
1559 for hyp in current_hyps:
1560 self.mesh.RemoveHypothesis( self.geom, hyp )
1564 ## Creates a mesh group based on the geometric object \a grp
1565 # and gives a \a name, \n if this parameter is not defined
1566 # the name is the same as the geometric group name \n
1567 # Note: Works like GroupOnGeom().
1568 # @param grp a geometric group, a vertex, an edge, a face or a solid
1569 # @param name the name of the mesh group
1570 # @return SMESH_GroupOnGeom
1571 # @ingroup l2_grps_create
1572 def Group(self, grp, name=""):
1573 return self.GroupOnGeom(grp, name)
1575 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1576 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1577 ## allowing to overwrite the file if it exists or add the exported data to its contents
1578 # @param f the file name
1579 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1580 # @param opt boolean parameter for creating/not creating
1581 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1582 # @param overwrite boolean parameter for overwriting/not overwriting the file
1583 # @ingroup l2_impexp
1584 def ExportToMED(self, f, version, opt=0, overwrite=1):
1585 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1587 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1588 ## allowing to overwrite the file if it exists or add the exported data to its contents
1589 # @param f is the file name
1590 # @param auto_groups boolean parameter for creating/not creating
1591 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1592 # the typical use is auto_groups=false.
1593 # @param version MED format version(MED_V2_1 or MED_V2_2)
1594 # @param overwrite boolean parameter for overwriting/not overwriting the file
1595 # @ingroup l2_impexp
1596 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1597 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1599 ## Exports the mesh in a file in DAT format
1600 # @param f the file name
1601 # @ingroup l2_impexp
1602 def ExportDAT(self, f):
1603 self.mesh.ExportDAT(f)
1605 ## Exports the mesh in a file in UNV format
1606 # @param f the file name
1607 # @ingroup l2_impexp
1608 def ExportUNV(self, f):
1609 self.mesh.ExportUNV(f)
1611 ## Export the mesh in a file in STL format
1612 # @param f the file name
1613 # @param ascii defines the file encoding
1614 # @ingroup l2_impexp
1615 def ExportSTL(self, f, ascii=1):
1616 self.mesh.ExportSTL(f, ascii)
1619 # Operations with groups:
1620 # ----------------------
1622 ## Creates an empty mesh group
1623 # @param elementType the type of elements in the group
1624 # @param name the name of the mesh group
1625 # @return SMESH_Group
1626 # @ingroup l2_grps_create
1627 def CreateEmptyGroup(self, elementType, name):
1628 return self.mesh.CreateGroup(elementType, name)
1630 ## Creates a mesh group based on the geometrical object \a grp
1631 # and gives a \a name, \n if this parameter is not defined
1632 # the name is the same as the geometrical group name
1633 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1634 # @param name the name of the mesh group
1635 # @param typ the type of elements in the group. If not set, it is
1636 # automatically detected by the type of the geometry
1637 # @return SMESH_GroupOnGeom
1638 # @ingroup l2_grps_create
1639 def GroupOnGeom(self, grp, name="", typ=None):
1641 name = grp.GetName()
1644 tgeo = str(grp.GetShapeType())
1645 if tgeo == "VERTEX":
1647 elif tgeo == "EDGE":
1649 elif tgeo == "FACE":
1651 elif tgeo == "SOLID":
1653 elif tgeo == "SHELL":
1655 elif tgeo == "COMPOUND":
1656 try: # it raises on a compound of compounds
1657 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1658 print "Mesh.Group: empty geometric group", GetName( grp )
1663 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1665 tgeo = self.geompyD.GetType(grp)
1666 if tgeo == geompyDC.ShapeType["VERTEX"]:
1668 elif tgeo == geompyDC.ShapeType["EDGE"]:
1670 elif tgeo == geompyDC.ShapeType["FACE"]:
1672 elif tgeo == geompyDC.ShapeType["SOLID"]:
1678 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1679 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1680 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1688 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1691 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1693 ## Creates a mesh group by the given ids of elements
1694 # @param groupName the name of the mesh group
1695 # @param elementType the type of elements in the group
1696 # @param elemIDs the list of ids
1697 # @return SMESH_Group
1698 # @ingroup l2_grps_create
1699 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1700 group = self.mesh.CreateGroup(elementType, groupName)
1704 ## Creates a mesh group by the given conditions
1705 # @param groupName the name of the mesh group
1706 # @param elementType the type of elements in the group
1707 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1708 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1709 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1710 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1711 # @return SMESH_Group
1712 # @ingroup l2_grps_create
1716 CritType=FT_Undefined,
1719 UnaryOp=FT_Undefined):
1720 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1721 group = self.MakeGroupByCriterion(groupName, aCriterion)
1724 ## Creates a mesh group by the given criterion
1725 # @param groupName the name of the mesh group
1726 # @param Criterion the instance of Criterion class
1727 # @return SMESH_Group
1728 # @ingroup l2_grps_create
1729 def MakeGroupByCriterion(self, groupName, Criterion):
1730 aFilterMgr = self.smeshpyD.CreateFilterManager()
1731 aFilter = aFilterMgr.CreateFilter()
1733 aCriteria.append(Criterion)
1734 aFilter.SetCriteria(aCriteria)
1735 group = self.MakeGroupByFilter(groupName, aFilter)
1736 aFilterMgr.Destroy()
1739 ## Creates a mesh group by the given criteria (list of criteria)
1740 # @param groupName the name of the mesh group
1741 # @param theCriteria the list of criteria
1742 # @return SMESH_Group
1743 # @ingroup l2_grps_create
1744 def MakeGroupByCriteria(self, groupName, theCriteria):
1745 aFilterMgr = self.smeshpyD.CreateFilterManager()
1746 aFilter = aFilterMgr.CreateFilter()
1747 aFilter.SetCriteria(theCriteria)
1748 group = self.MakeGroupByFilter(groupName, aFilter)
1749 aFilterMgr.Destroy()
1752 ## Creates a mesh group by the given filter
1753 # @param groupName the name of the mesh group
1754 # @param theFilter the instance of Filter class
1755 # @return SMESH_Group
1756 # @ingroup l2_grps_create
1757 def MakeGroupByFilter(self, groupName, theFilter):
1758 anIds = theFilter.GetElementsId(self.mesh)
1759 anElemType = theFilter.GetElementType()
1760 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1763 ## Passes mesh elements through the given filter and return IDs of fitting elements
1764 # @param theFilter SMESH_Filter
1765 # @return a list of ids
1766 # @ingroup l1_controls
1767 def GetIdsFromFilter(self, theFilter):
1768 return theFilter.GetElementsId(self.mesh)
1770 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1771 # Returns a list of special structures (borders).
1772 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1773 # @ingroup l1_controls
1774 def GetFreeBorders(self):
1775 aFilterMgr = self.smeshpyD.CreateFilterManager()
1776 aPredicate = aFilterMgr.CreateFreeEdges()
1777 aPredicate.SetMesh(self.mesh)
1778 aBorders = aPredicate.GetBorders()
1779 aFilterMgr.Destroy()
1783 # @ingroup l2_grps_delete
1784 def RemoveGroup(self, group):
1785 self.mesh.RemoveGroup(group)
1787 ## Removes a group with its contents
1788 # @ingroup l2_grps_delete
1789 def RemoveGroupWithContents(self, group):
1790 self.mesh.RemoveGroupWithContents(group)
1792 ## Gets the list of groups existing in the mesh
1793 # @return a sequence of SMESH_GroupBase
1794 # @ingroup l2_grps_create
1795 def GetGroups(self):
1796 return self.mesh.GetGroups()
1798 ## Gets the number of groups existing in the mesh
1799 # @return the quantity of groups as an integer value
1800 # @ingroup l2_grps_create
1802 return self.mesh.NbGroups()
1804 ## Gets the list of names of groups existing in the mesh
1805 # @return list of strings
1806 # @ingroup l2_grps_create
1807 def GetGroupNames(self):
1808 groups = self.GetGroups()
1810 for group in groups:
1811 names.append(group.GetName())
1814 ## Produces a union of two groups
1815 # A new group is created. All mesh elements that are
1816 # present in the initial groups are added to the new one
1817 # @return an instance of SMESH_Group
1818 # @ingroup l2_grps_operon
1819 def UnionGroups(self, group1, group2, name):
1820 return self.mesh.UnionGroups(group1, group2, name)
1822 ## Produces a union list of groups
1823 # New group is created. All mesh elements that are present in
1824 # initial groups are added to the new one
1825 # @return an instance of SMESH_Group
1826 # @ingroup l2_grps_operon
1827 def UnionListOfGroups(self, groups, name):
1828 return self.mesh.UnionListOfGroups(groups, name)
1830 ## Prodices an intersection of two groups
1831 # A new group is created. All mesh elements that are common
1832 # for the two initial groups are added to the new one.
1833 # @return an instance of SMESH_Group
1834 # @ingroup l2_grps_operon
1835 def IntersectGroups(self, group1, group2, name):
1836 return self.mesh.IntersectGroups(group1, group2, name)
1838 ## Produces an intersection of groups
1839 # New group is created. All mesh elements that are present in all
1840 # initial groups simultaneously are added to the new one
1841 # @return an instance of SMESH_Group
1842 # @ingroup l2_grps_operon
1843 def IntersectListOfGroups(self, groups, name):
1844 return self.mesh.IntersectListOfGroups(groups, name)
1846 ## Produces a cut of two groups
1847 # A new group is created. All mesh elements that are present in
1848 # the main group but are not present in the tool group are added to the new one
1849 # @return an instance of SMESH_Group
1850 # @ingroup l2_grps_operon
1851 def CutGroups(self, main_group, tool_group, name):
1852 return self.mesh.CutGroups(main_group, tool_group, name)
1854 ## Produces a cut of groups
1855 # A new group is created. All mesh elements that are present in main groups
1856 # but do not present in tool groups are added to the new one
1857 # @return an instance of SMESH_Group
1858 # @ingroup l2_grps_operon
1859 def CutListOfGroups(self, main_groups, tool_groups, name):
1860 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1862 ## Produces a group of elements with specified element type using list of existing groups
1863 # A new group is created. System
1864 # 1) extract all nodes on which groups elements are built
1865 # 2) combine all elements of specified dimension laying on these nodes
1866 # @return an instance of SMESH_Group
1867 # @ingroup l2_grps_operon
1868 def CreateDimGroup(self, groups, elem_type, name):
1869 return self.mesh.CreateDimGroup(groups, elem_type, name)
1872 ## Convert group on geom into standalone group
1873 # @ingroup l2_grps_delete
1874 def ConvertToStandalone(self, group):
1875 return self.mesh.ConvertToStandalone(group)
1877 # Get some info about mesh:
1878 # ------------------------
1880 ## Returns the log of nodes and elements added or removed
1881 # since the previous clear of the log.
1882 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1883 # @return list of log_block structures:
1888 # @ingroup l1_auxiliary
1889 def GetLog(self, clearAfterGet):
1890 return self.mesh.GetLog(clearAfterGet)
1892 ## Clears the log of nodes and elements added or removed since the previous
1893 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1894 # @ingroup l1_auxiliary
1896 self.mesh.ClearLog()
1898 ## Toggles auto color mode on the object.
1899 # @param theAutoColor the flag which toggles auto color mode.
1900 # @ingroup l1_auxiliary
1901 def SetAutoColor(self, theAutoColor):
1902 self.mesh.SetAutoColor(theAutoColor)
1904 ## Gets flag of object auto color mode.
1905 # @return True or False
1906 # @ingroup l1_auxiliary
1907 def GetAutoColor(self):
1908 return self.mesh.GetAutoColor()
1910 ## Gets the internal ID
1911 # @return integer value, which is the internal Id of the mesh
1912 # @ingroup l1_auxiliary
1914 return self.mesh.GetId()
1917 # @return integer value, which is the study Id of the mesh
1918 # @ingroup l1_auxiliary
1919 def GetStudyId(self):
1920 return self.mesh.GetStudyId()
1922 ## Checks the group names for duplications.
1923 # Consider the maximum group name length stored in MED file.
1924 # @return True or False
1925 # @ingroup l1_auxiliary
1926 def HasDuplicatedGroupNamesMED(self):
1927 return self.mesh.HasDuplicatedGroupNamesMED()
1929 ## Obtains the mesh editor tool
1930 # @return an instance of SMESH_MeshEditor
1931 # @ingroup l1_modifying
1932 def GetMeshEditor(self):
1933 return self.mesh.GetMeshEditor()
1936 # @return an instance of SALOME_MED::MESH
1937 # @ingroup l1_auxiliary
1938 def GetMEDMesh(self):
1939 return self.mesh.GetMEDMesh()
1942 # Get informations about mesh contents:
1943 # ------------------------------------
1945 ## Gets the mesh stattistic
1946 # @return dictionary type element - count of elements
1947 # @ingroup l1_meshinfo
1948 def GetMeshInfo(self, obj = None):
1949 if not obj: obj = self.mesh
1950 return self.smeshpyD.GetMeshInfo(obj)
1952 ## Returns the number of nodes in the mesh
1953 # @return an integer value
1954 # @ingroup l1_meshinfo
1956 return self.mesh.NbNodes()
1958 ## Returns the number of elements in the mesh
1959 # @return an integer value
1960 # @ingroup l1_meshinfo
1961 def NbElements(self):
1962 return self.mesh.NbElements()
1964 ## Returns the number of 0d elements in the mesh
1965 # @return an integer value
1966 # @ingroup l1_meshinfo
1967 def Nb0DElements(self):
1968 return self.mesh.Nb0DElements()
1970 ## Returns the number of edges in the mesh
1971 # @return an integer value
1972 # @ingroup l1_meshinfo
1974 return self.mesh.NbEdges()
1976 ## Returns the number of edges with the given order in the mesh
1977 # @param elementOrder the order of elements:
1978 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1979 # @return an integer value
1980 # @ingroup l1_meshinfo
1981 def NbEdgesOfOrder(self, elementOrder):
1982 return self.mesh.NbEdgesOfOrder(elementOrder)
1984 ## Returns the number of faces in the mesh
1985 # @return an integer value
1986 # @ingroup l1_meshinfo
1988 return self.mesh.NbFaces()
1990 ## Returns the number of faces with the given order in the mesh
1991 # @param elementOrder the order of elements:
1992 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1993 # @return an integer value
1994 # @ingroup l1_meshinfo
1995 def NbFacesOfOrder(self, elementOrder):
1996 return self.mesh.NbFacesOfOrder(elementOrder)
1998 ## Returns the number of triangles in the mesh
1999 # @return an integer value
2000 # @ingroup l1_meshinfo
2001 def NbTriangles(self):
2002 return self.mesh.NbTriangles()
2004 ## Returns the number of triangles with the given order in the mesh
2005 # @param elementOrder is the order of elements:
2006 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2007 # @return an integer value
2008 # @ingroup l1_meshinfo
2009 def NbTrianglesOfOrder(self, elementOrder):
2010 return self.mesh.NbTrianglesOfOrder(elementOrder)
2012 ## Returns the number of quadrangles in the mesh
2013 # @return an integer value
2014 # @ingroup l1_meshinfo
2015 def NbQuadrangles(self):
2016 return self.mesh.NbQuadrangles()
2018 ## Returns the number of quadrangles with the given order in the mesh
2019 # @param elementOrder the order of elements:
2020 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2021 # @return an integer value
2022 # @ingroup l1_meshinfo
2023 def NbQuadranglesOfOrder(self, elementOrder):
2024 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2026 ## Returns the number of polygons in the mesh
2027 # @return an integer value
2028 # @ingroup l1_meshinfo
2029 def NbPolygons(self):
2030 return self.mesh.NbPolygons()
2032 ## Returns the number of volumes in the mesh
2033 # @return an integer value
2034 # @ingroup l1_meshinfo
2035 def NbVolumes(self):
2036 return self.mesh.NbVolumes()
2038 ## Returns the number of volumes with the given order in the mesh
2039 # @param elementOrder the order of elements:
2040 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2041 # @return an integer value
2042 # @ingroup l1_meshinfo
2043 def NbVolumesOfOrder(self, elementOrder):
2044 return self.mesh.NbVolumesOfOrder(elementOrder)
2046 ## Returns the number of tetrahedrons in the mesh
2047 # @return an integer value
2048 # @ingroup l1_meshinfo
2050 return self.mesh.NbTetras()
2052 ## Returns the number of tetrahedrons with the given order in the mesh
2053 # @param elementOrder the order of elements:
2054 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2055 # @return an integer value
2056 # @ingroup l1_meshinfo
2057 def NbTetrasOfOrder(self, elementOrder):
2058 return self.mesh.NbTetrasOfOrder(elementOrder)
2060 ## Returns the number of hexahedrons in the mesh
2061 # @return an integer value
2062 # @ingroup l1_meshinfo
2064 return self.mesh.NbHexas()
2066 ## Returns the number of hexahedrons with the given order in the mesh
2067 # @param elementOrder the order of elements:
2068 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2069 # @return an integer value
2070 # @ingroup l1_meshinfo
2071 def NbHexasOfOrder(self, elementOrder):
2072 return self.mesh.NbHexasOfOrder(elementOrder)
2074 ## Returns the number of pyramids in the mesh
2075 # @return an integer value
2076 # @ingroup l1_meshinfo
2077 def NbPyramids(self):
2078 return self.mesh.NbPyramids()
2080 ## Returns the number of pyramids with the given order in the mesh
2081 # @param elementOrder the order of elements:
2082 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2083 # @return an integer value
2084 # @ingroup l1_meshinfo
2085 def NbPyramidsOfOrder(self, elementOrder):
2086 return self.mesh.NbPyramidsOfOrder(elementOrder)
2088 ## Returns the number of prisms in the mesh
2089 # @return an integer value
2090 # @ingroup l1_meshinfo
2092 return self.mesh.NbPrisms()
2094 ## Returns the number of prisms with the given order in the mesh
2095 # @param elementOrder the order of elements:
2096 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2097 # @return an integer value
2098 # @ingroup l1_meshinfo
2099 def NbPrismsOfOrder(self, elementOrder):
2100 return self.mesh.NbPrismsOfOrder(elementOrder)
2102 ## Returns the number of polyhedrons in the mesh
2103 # @return an integer value
2104 # @ingroup l1_meshinfo
2105 def NbPolyhedrons(self):
2106 return self.mesh.NbPolyhedrons()
2108 ## Returns the number of submeshes in the mesh
2109 # @return an integer value
2110 # @ingroup l1_meshinfo
2111 def NbSubMesh(self):
2112 return self.mesh.NbSubMesh()
2114 ## Returns the list of mesh elements IDs
2115 # @return the list of integer values
2116 # @ingroup l1_meshinfo
2117 def GetElementsId(self):
2118 return self.mesh.GetElementsId()
2120 ## Returns the list of IDs of mesh elements with the given type
2121 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2122 # @return list of integer values
2123 # @ingroup l1_meshinfo
2124 def GetElementsByType(self, elementType):
2125 return self.mesh.GetElementsByType(elementType)
2127 ## Returns the list of mesh nodes IDs
2128 # @return the list of integer values
2129 # @ingroup l1_meshinfo
2130 def GetNodesId(self):
2131 return self.mesh.GetNodesId()
2133 # Get the information about mesh elements:
2134 # ------------------------------------
2136 ## Returns the type of mesh element
2137 # @return the value from SMESH::ElementType enumeration
2138 # @ingroup l1_meshinfo
2139 def GetElementType(self, id, iselem):
2140 return self.mesh.GetElementType(id, iselem)
2142 ## Returns the geometric type of mesh element
2143 # @return the value from SMESH::EntityType enumeration
2144 # @ingroup l1_meshinfo
2145 def GetElementGeomType(self, id):
2146 return self.mesh.GetElementGeomType(id)
2148 ## Returns the list of submesh elements IDs
2149 # @param Shape a geom object(subshape) IOR
2150 # Shape must be the subshape of a ShapeToMesh()
2151 # @return the list of integer values
2152 # @ingroup l1_meshinfo
2153 def GetSubMeshElementsId(self, Shape):
2154 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2155 ShapeID = Shape.GetSubShapeIndices()[0]
2158 return self.mesh.GetSubMeshElementsId(ShapeID)
2160 ## Returns the list of submesh nodes IDs
2161 # @param Shape a geom object(subshape) IOR
2162 # Shape must be the subshape of a ShapeToMesh()
2163 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2164 # @return the list of integer values
2165 # @ingroup l1_meshinfo
2166 def GetSubMeshNodesId(self, Shape, all):
2167 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2168 ShapeID = Shape.GetSubShapeIndices()[0]
2171 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2173 ## Returns type of elements on given shape
2174 # @param Shape a geom object(subshape) IOR
2175 # Shape must be a subshape of a ShapeToMesh()
2176 # @return element type
2177 # @ingroup l1_meshinfo
2178 def GetSubMeshElementType(self, Shape):
2179 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2180 ShapeID = Shape.GetSubShapeIndices()[0]
2183 return self.mesh.GetSubMeshElementType(ShapeID)
2185 ## Gets the mesh description
2186 # @return string value
2187 # @ingroup l1_meshinfo
2189 return self.mesh.Dump()
2192 # Get the information about nodes and elements of a mesh by its IDs:
2193 # -----------------------------------------------------------
2195 ## Gets XYZ coordinates of a node
2196 # \n If there is no nodes for the given ID - returns an empty list
2197 # @return a list of double precision values
2198 # @ingroup l1_meshinfo
2199 def GetNodeXYZ(self, id):
2200 return self.mesh.GetNodeXYZ(id)
2202 ## Returns list of IDs of inverse elements for the given node
2203 # \n If there is no node for the given ID - returns an empty list
2204 # @return a list of integer values
2205 # @ingroup l1_meshinfo
2206 def GetNodeInverseElements(self, id):
2207 return self.mesh.GetNodeInverseElements(id)
2209 ## @brief Returns the position of a node on the shape
2210 # @return SMESH::NodePosition
2211 # @ingroup l1_meshinfo
2212 def GetNodePosition(self,NodeID):
2213 return self.mesh.GetNodePosition(NodeID)
2215 ## If the given element is a node, returns the ID of shape
2216 # \n If there is no node for the given ID - returns -1
2217 # @return an integer value
2218 # @ingroup l1_meshinfo
2219 def GetShapeID(self, id):
2220 return self.mesh.GetShapeID(id)
2222 ## Returns the ID of the result shape after
2223 # FindShape() from SMESH_MeshEditor for the given element
2224 # \n If there is no element for the given ID - returns -1
2225 # @return an integer value
2226 # @ingroup l1_meshinfo
2227 def GetShapeIDForElem(self,id):
2228 return self.mesh.GetShapeIDForElem(id)
2230 ## Returns the number of nodes for the given element
2231 # \n If there is no element for the given ID - returns -1
2232 # @return an integer value
2233 # @ingroup l1_meshinfo
2234 def GetElemNbNodes(self, id):
2235 return self.mesh.GetElemNbNodes(id)
2237 ## Returns the node ID the given index for the given element
2238 # \n If there is no element for the given ID - returns -1
2239 # \n If there is no node for the given index - returns -2
2240 # @return an integer value
2241 # @ingroup l1_meshinfo
2242 def GetElemNode(self, id, index):
2243 return self.mesh.GetElemNode(id, index)
2245 ## Returns the IDs of nodes of the given element
2246 # @return a list of integer values
2247 # @ingroup l1_meshinfo
2248 def GetElemNodes(self, id):
2249 return self.mesh.GetElemNodes(id)
2251 ## Returns true if the given node is the medium node in the given quadratic element
2252 # @ingroup l1_meshinfo
2253 def IsMediumNode(self, elementID, nodeID):
2254 return self.mesh.IsMediumNode(elementID, nodeID)
2256 ## Returns true if the given node is the medium node in one of quadratic elements
2257 # @ingroup l1_meshinfo
2258 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2259 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2261 ## Returns the number of edges for the given element
2262 # @ingroup l1_meshinfo
2263 def ElemNbEdges(self, id):
2264 return self.mesh.ElemNbEdges(id)
2266 ## Returns the number of faces for the given element
2267 # @ingroup l1_meshinfo
2268 def ElemNbFaces(self, id):
2269 return self.mesh.ElemNbFaces(id)
2271 ## Returns nodes of given face (counted from zero) for given volumic element.
2272 # @ingroup l1_meshinfo
2273 def GetElemFaceNodes(self,elemId, faceIndex):
2274 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2276 ## Returns an element based on all given nodes.
2277 # @ingroup l1_meshinfo
2278 def FindElementByNodes(self,nodes):
2279 return self.mesh.FindElementByNodes(nodes)
2281 ## Returns true if the given element is a polygon
2282 # @ingroup l1_meshinfo
2283 def IsPoly(self, id):
2284 return self.mesh.IsPoly(id)
2286 ## Returns true if the given element is quadratic
2287 # @ingroup l1_meshinfo
2288 def IsQuadratic(self, id):
2289 return self.mesh.IsQuadratic(id)
2291 ## Returns XYZ coordinates of the barycenter of the given element
2292 # \n If there is no element for the given ID - returns an empty list
2293 # @return a list of three double values
2294 # @ingroup l1_meshinfo
2295 def BaryCenter(self, id):
2296 return self.mesh.BaryCenter(id)
2299 # Get mesh measurements information:
2300 # ------------------------------------
2302 ## Get minimum distance between two nodes, elements or distance to the origin
2303 # @param id1 first node/element id
2304 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2305 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2306 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2307 # @return minimum distance value
2308 # @sa GetMinDistance()
2309 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2310 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2311 return aMeasure.value
2313 ## Get measure structure specifying minimum distance data between two objects
2314 # @param id1 first node/element id
2315 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2316 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2317 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2318 # @return Measure structure
2320 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2322 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2324 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2327 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2329 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2334 aMeasurements = self.smeshpyD.CreateMeasurements()
2335 aMeasure = aMeasurements.MinDistance(id1, id2)
2336 aMeasurements.Destroy()
2339 ## Get bounding box of the specified object(s)
2340 # @param objects single source object or list of source objects or list of nodes/elements IDs
2341 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2342 # @c False specifies that @a objects are nodes
2343 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2344 # @sa GetBoundingBox()
2345 def BoundingBox(self, objects=None, isElem=False):
2346 result = self.GetBoundingBox(objects, isElem)
2350 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2353 ## Get measure structure specifying bounding box data of the specified object(s)
2354 # @param objects single source object or list of source objects or list of nodes/elements IDs
2355 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2356 # @c False specifies that @a objects are nodes
2357 # @return Measure structure
2359 def GetBoundingBox(self, IDs=None, isElem=False):
2362 elif isinstance(IDs, tuple):
2364 if not isinstance(IDs, list):
2366 if len(IDs) > 0 and isinstance(IDs[0], int):
2370 if isinstance(o, Mesh):
2371 srclist.append(o.mesh)
2372 elif hasattr(o, "_narrow"):
2373 src = o._narrow(SMESH.SMESH_IDSource)
2374 if src: srclist.append(src)
2376 elif isinstance(o, list):
2378 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2380 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2383 aMeasurements = self.smeshpyD.CreateMeasurements()
2384 aMeasure = aMeasurements.BoundingBox(srclist)
2385 aMeasurements.Destroy()
2388 # Mesh edition (SMESH_MeshEditor functionality):
2389 # ---------------------------------------------
2391 ## Removes the elements from the mesh by ids
2392 # @param IDsOfElements is a list of ids of elements to remove
2393 # @return True or False
2394 # @ingroup l2_modif_del
2395 def RemoveElements(self, IDsOfElements):
2396 return self.editor.RemoveElements(IDsOfElements)
2398 ## Removes nodes from mesh by ids
2399 # @param IDsOfNodes is a list of ids of nodes to remove
2400 # @return True or False
2401 # @ingroup l2_modif_del
2402 def RemoveNodes(self, IDsOfNodes):
2403 return self.editor.RemoveNodes(IDsOfNodes)
2405 ## Removes all orphan (free) nodes from mesh
2406 # @return number of the removed nodes
2407 # @ingroup l2_modif_del
2408 def RemoveOrphanNodes(self):
2409 return self.editor.RemoveOrphanNodes()
2411 ## Add a node to the mesh by coordinates
2412 # @return Id of the new node
2413 # @ingroup l2_modif_add
2414 def AddNode(self, x, y, z):
2415 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2416 self.mesh.SetParameters(Parameters)
2417 return self.editor.AddNode( x, y, z)
2419 ## Creates a 0D element on a node with given number.
2420 # @param IDOfNode the ID of node for creation of the element.
2421 # @return the Id of the new 0D element
2422 # @ingroup l2_modif_add
2423 def Add0DElement(self, IDOfNode):
2424 return self.editor.Add0DElement(IDOfNode)
2426 ## Creates a linear or quadratic edge (this is determined
2427 # by the number of given nodes).
2428 # @param IDsOfNodes the list of node IDs for creation of the element.
2429 # The order of nodes in this list should correspond to the description
2430 # of MED. \n This description is located by the following link:
2431 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2432 # @return the Id of the new edge
2433 # @ingroup l2_modif_add
2434 def AddEdge(self, IDsOfNodes):
2435 return self.editor.AddEdge(IDsOfNodes)
2437 ## Creates a linear or quadratic face (this is determined
2438 # by the number of given nodes).
2439 # @param IDsOfNodes the list of node IDs for creation of the element.
2440 # The order of nodes in this list should correspond to the description
2441 # of MED. \n This description is located by the following link:
2442 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2443 # @return the Id of the new face
2444 # @ingroup l2_modif_add
2445 def AddFace(self, IDsOfNodes):
2446 return self.editor.AddFace(IDsOfNodes)
2448 ## Adds a polygonal face to the mesh by the list of node IDs
2449 # @param IdsOfNodes the list of node IDs for creation of the element.
2450 # @return the Id of the new face
2451 # @ingroup l2_modif_add
2452 def AddPolygonalFace(self, IdsOfNodes):
2453 return self.editor.AddPolygonalFace(IdsOfNodes)
2455 ## Creates both simple and quadratic volume (this is determined
2456 # by the number of given nodes).
2457 # @param IDsOfNodes the list of node IDs for creation of the element.
2458 # The order of nodes in this list should correspond to the description
2459 # of MED. \n This description is located by the following link:
2460 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2461 # @return the Id of the new volumic element
2462 # @ingroup l2_modif_add
2463 def AddVolume(self, IDsOfNodes):
2464 return self.editor.AddVolume(IDsOfNodes)
2466 ## Creates a volume of many faces, giving nodes for each face.
2467 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2468 # @param Quantities the list of integer values, Quantities[i]
2469 # gives the quantity of nodes in face number i.
2470 # @return the Id of the new volumic element
2471 # @ingroup l2_modif_add
2472 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2473 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2475 ## Creates a volume of many faces, giving the IDs of the existing faces.
2476 # @param IdsOfFaces the list of face IDs for volume creation.
2478 # Note: The created volume will refer only to the nodes
2479 # of the given faces, not to the faces themselves.
2480 # @return the Id of the new volumic element
2481 # @ingroup l2_modif_add
2482 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2483 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2486 ## @brief Binds a node to a vertex
2487 # @param NodeID a node ID
2488 # @param Vertex a vertex or vertex ID
2489 # @return True if succeed else raises an exception
2490 # @ingroup l2_modif_add
2491 def SetNodeOnVertex(self, NodeID, Vertex):
2492 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2493 VertexID = Vertex.GetSubShapeIndices()[0]
2497 self.editor.SetNodeOnVertex(NodeID, VertexID)
2498 except SALOME.SALOME_Exception, inst:
2499 raise ValueError, inst.details.text
2503 ## @brief Stores the node position on an edge
2504 # @param NodeID a node ID
2505 # @param Edge an edge or edge ID
2506 # @param paramOnEdge a parameter on the edge where the node is located
2507 # @return True if succeed else raises an exception
2508 # @ingroup l2_modif_add
2509 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2510 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2511 EdgeID = Edge.GetSubShapeIndices()[0]
2515 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2516 except SALOME.SALOME_Exception, inst:
2517 raise ValueError, inst.details.text
2520 ## @brief Stores node position on a face
2521 # @param NodeID a node ID
2522 # @param Face a face or face ID
2523 # @param u U parameter on the face where the node is located
2524 # @param v V parameter on the face where the node is located
2525 # @return True if succeed else raises an exception
2526 # @ingroup l2_modif_add
2527 def SetNodeOnFace(self, NodeID, Face, u, v):
2528 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2529 FaceID = Face.GetSubShapeIndices()[0]
2533 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2534 except SALOME.SALOME_Exception, inst:
2535 raise ValueError, inst.details.text
2538 ## @brief Binds a node to a solid
2539 # @param NodeID a node ID
2540 # @param Solid a solid or solid ID
2541 # @return True if succeed else raises an exception
2542 # @ingroup l2_modif_add
2543 def SetNodeInVolume(self, NodeID, Solid):
2544 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2545 SolidID = Solid.GetSubShapeIndices()[0]
2549 self.editor.SetNodeInVolume(NodeID, SolidID)
2550 except SALOME.SALOME_Exception, inst:
2551 raise ValueError, inst.details.text
2554 ## @brief Bind an element to a shape
2555 # @param ElementID an element ID
2556 # @param Shape a shape or shape ID
2557 # @return True if succeed else raises an exception
2558 # @ingroup l2_modif_add
2559 def SetMeshElementOnShape(self, ElementID, Shape):
2560 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2561 ShapeID = Shape.GetSubShapeIndices()[0]
2565 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2566 except SALOME.SALOME_Exception, inst:
2567 raise ValueError, inst.details.text
2571 ## Moves the node with the given id
2572 # @param NodeID the id of the node
2573 # @param x a new X coordinate
2574 # @param y a new Y coordinate
2575 # @param z a new Z coordinate
2576 # @return True if succeed else False
2577 # @ingroup l2_modif_movenode
2578 def MoveNode(self, NodeID, x, y, z):
2579 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2580 self.mesh.SetParameters(Parameters)
2581 return self.editor.MoveNode(NodeID, x, y, z)
2583 ## Finds the node closest to a point and moves it to a point location
2584 # @param x the X coordinate of a point
2585 # @param y the Y coordinate of a point
2586 # @param z the Z coordinate of a point
2587 # @param NodeID if specified (>0), the node with this ID is moved,
2588 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2589 # @return the ID of a node
2590 # @ingroup l2_modif_throughp
2591 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2592 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2593 self.mesh.SetParameters(Parameters)
2594 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2596 ## Finds the node closest to a point
2597 # @param x the X coordinate of a point
2598 # @param y the Y coordinate of a point
2599 # @param z the Z coordinate of a point
2600 # @return the ID of a node
2601 # @ingroup l2_modif_throughp
2602 def FindNodeClosestTo(self, x, y, z):
2603 #preview = self.mesh.GetMeshEditPreviewer()
2604 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2605 return self.editor.FindNodeClosestTo(x, y, z)
2607 ## Finds the elements where a point lays IN or ON
2608 # @param x the X coordinate of a point
2609 # @param y the Y coordinate of a point
2610 # @param z the Z coordinate of a point
2611 # @param elementType type of elements to find (SMESH.ALL type
2612 # means elements of any type excluding nodes and 0D elements)
2613 # @return list of IDs of found elements
2614 # @ingroup l2_modif_throughp
2615 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2616 return self.editor.FindElementsByPoint(x, y, z, elementType)
2618 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2619 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2621 def GetPointState(self, x, y, z):
2622 return self.editor.GetPointState(x, y, z)
2624 ## Finds the node closest to a point and moves it to a point location
2625 # @param x the X coordinate of a point
2626 # @param y the Y coordinate of a point
2627 # @param z the Z coordinate of a point
2628 # @return the ID of a moved node
2629 # @ingroup l2_modif_throughp
2630 def MeshToPassThroughAPoint(self, x, y, z):
2631 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2633 ## Replaces two neighbour triangles sharing Node1-Node2 link
2634 # with the triangles built on the same 4 nodes but having other common link.
2635 # @param NodeID1 the ID of the first node
2636 # @param NodeID2 the ID of the second node
2637 # @return false if proper faces were not found
2638 # @ingroup l2_modif_invdiag
2639 def InverseDiag(self, NodeID1, NodeID2):
2640 return self.editor.InverseDiag(NodeID1, NodeID2)
2642 ## Replaces two neighbour triangles sharing Node1-Node2 link
2643 # with a quadrangle built on the same 4 nodes.
2644 # @param NodeID1 the ID of the first node
2645 # @param NodeID2 the ID of the second node
2646 # @return false if proper faces were not found
2647 # @ingroup l2_modif_unitetri
2648 def DeleteDiag(self, NodeID1, NodeID2):
2649 return self.editor.DeleteDiag(NodeID1, NodeID2)
2651 ## Reorients elements by ids
2652 # @param IDsOfElements if undefined reorients all mesh elements
2653 # @return True if succeed else False
2654 # @ingroup l2_modif_changori
2655 def Reorient(self, IDsOfElements=None):
2656 if IDsOfElements == None:
2657 IDsOfElements = self.GetElementsId()
2658 return self.editor.Reorient(IDsOfElements)
2660 ## Reorients all elements of the object
2661 # @param theObject mesh, submesh or group
2662 # @return True if succeed else False
2663 # @ingroup l2_modif_changori
2664 def ReorientObject(self, theObject):
2665 if ( isinstance( theObject, Mesh )):
2666 theObject = theObject.GetMesh()
2667 return self.editor.ReorientObject(theObject)
2669 ## Fuses the neighbouring triangles into quadrangles.
2670 # @param IDsOfElements The triangles to be fused,
2671 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2672 # @param MaxAngle is the maximum angle between element normals at which the fusion
2673 # is still performed; theMaxAngle is mesured in radians.
2674 # Also it could be a name of variable which defines angle in degrees.
2675 # @return TRUE in case of success, FALSE otherwise.
2676 # @ingroup l2_modif_unitetri
2677 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2679 if isinstance(MaxAngle,str):
2681 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2683 MaxAngle = DegreesToRadians(MaxAngle)
2684 if IDsOfElements == []:
2685 IDsOfElements = self.GetElementsId()
2686 self.mesh.SetParameters(Parameters)
2688 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2689 Functor = theCriterion
2691 Functor = self.smeshpyD.GetFunctor(theCriterion)
2692 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2694 ## Fuses the neighbouring triangles of the object into quadrangles
2695 # @param theObject is mesh, submesh or group
2696 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2697 # @param MaxAngle a max angle between element normals at which the fusion
2698 # is still performed; theMaxAngle is mesured in radians.
2699 # @return TRUE in case of success, FALSE otherwise.
2700 # @ingroup l2_modif_unitetri
2701 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2702 if ( isinstance( theObject, Mesh )):
2703 theObject = theObject.GetMesh()
2704 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2706 ## Splits quadrangles into triangles.
2707 # @param IDsOfElements the faces to be splitted.
2708 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2709 # @return TRUE in case of success, FALSE otherwise.
2710 # @ingroup l2_modif_cutquadr
2711 def QuadToTri (self, IDsOfElements, theCriterion):
2712 if IDsOfElements == []:
2713 IDsOfElements = self.GetElementsId()
2714 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2716 ## Splits quadrangles into triangles.
2717 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2718 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2719 # @return TRUE in case of success, FALSE otherwise.
2720 # @ingroup l2_modif_cutquadr
2721 def QuadToTriObject (self, theObject, theCriterion):
2722 if ( isinstance( theObject, Mesh )):
2723 theObject = theObject.GetMesh()
2724 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2726 ## Splits quadrangles into triangles.
2727 # @param IDsOfElements the faces to be splitted
2728 # @param Diag13 is used to choose a diagonal for splitting.
2729 # @return TRUE in case of success, FALSE otherwise.
2730 # @ingroup l2_modif_cutquadr
2731 def SplitQuad (self, IDsOfElements, Diag13):
2732 if IDsOfElements == []:
2733 IDsOfElements = self.GetElementsId()
2734 return self.editor.SplitQuad(IDsOfElements, Diag13)
2736 ## Splits quadrangles into triangles.
2737 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2738 # @param Diag13 is used to choose a diagonal for splitting.
2739 # @return TRUE in case of success, FALSE otherwise.
2740 # @ingroup l2_modif_cutquadr
2741 def SplitQuadObject (self, theObject, Diag13):
2742 if ( isinstance( theObject, Mesh )):
2743 theObject = theObject.GetMesh()
2744 return self.editor.SplitQuadObject(theObject, Diag13)
2746 ## Finds a better splitting of the given quadrangle.
2747 # @param IDOfQuad the ID of the quadrangle to be splitted.
2748 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2749 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2750 # diagonal is better, 0 if error occurs.
2751 # @ingroup l2_modif_cutquadr
2752 def BestSplit (self, IDOfQuad, theCriterion):
2753 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2755 ## Splits volumic elements into tetrahedrons
2756 # @param elemIDs either list of elements or mesh or group or submesh
2757 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2758 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2759 # @ingroup l2_modif_cutquadr
2760 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2761 if isinstance( elemIDs, Mesh ):
2762 elemIDs = elemIDs.GetMesh()
2763 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2765 ## Splits quadrangle faces near triangular facets of volumes
2767 # @ingroup l1_auxiliary
2768 def SplitQuadsNearTriangularFacets(self):
2769 faces_array = self.GetElementsByType(SMESH.FACE)
2770 for face_id in faces_array:
2771 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2772 quad_nodes = self.mesh.GetElemNodes(face_id)
2773 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2774 isVolumeFound = False
2775 for node1_elem in node1_elems:
2776 if not isVolumeFound:
2777 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2778 nb_nodes = self.GetElemNbNodes(node1_elem)
2779 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2780 volume_elem = node1_elem
2781 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2782 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2783 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2784 isVolumeFound = True
2785 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2786 self.SplitQuad([face_id], False) # diagonal 2-4
2787 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2788 isVolumeFound = True
2789 self.SplitQuad([face_id], True) # diagonal 1-3
2790 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2791 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2792 isVolumeFound = True
2793 self.SplitQuad([face_id], True) # diagonal 1-3
2795 ## @brief Splits hexahedrons into tetrahedrons.
2797 # This operation uses pattern mapping functionality for splitting.
2798 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2799 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2800 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2801 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2802 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2803 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2804 # @return TRUE in case of success, FALSE otherwise.
2805 # @ingroup l1_auxiliary
2806 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2807 # Pattern: 5.---------.6
2812 # (0,0,1) 4.---------.7 * |
2819 # (0,0,0) 0.---------.3
2820 pattern_tetra = "!!! Nb of points: \n 8 \n\
2830 !!! Indices of points of 6 tetras: \n\
2838 pattern = self.smeshpyD.GetPattern()
2839 isDone = pattern.LoadFromFile(pattern_tetra)
2841 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2844 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2845 isDone = pattern.MakeMesh(self.mesh, False, False)
2846 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2848 # split quafrangle faces near triangular facets of volumes
2849 self.SplitQuadsNearTriangularFacets()
2853 ## @brief Split hexahedrons into prisms.
2855 # Uses the pattern mapping functionality for splitting.
2856 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2857 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2858 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2859 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2860 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2861 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2862 # @return TRUE in case of success, FALSE otherwise.
2863 # @ingroup l1_auxiliary
2864 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2865 # Pattern: 5.---------.6
2870 # (0,0,1) 4.---------.7 |
2877 # (0,0,0) 0.---------.3
2878 pattern_prism = "!!! Nb of points: \n 8 \n\
2888 !!! Indices of points of 2 prisms: \n\
2892 pattern = self.smeshpyD.GetPattern()
2893 isDone = pattern.LoadFromFile(pattern_prism)
2895 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2898 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2899 isDone = pattern.MakeMesh(self.mesh, False, False)
2900 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2902 # Splits quafrangle faces near triangular facets of volumes
2903 self.SplitQuadsNearTriangularFacets()
2907 ## Smoothes elements
2908 # @param IDsOfElements the list if ids of elements to smooth
2909 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2910 # Note that nodes built on edges and boundary nodes are always fixed.
2911 # @param MaxNbOfIterations the maximum number of iterations
2912 # @param MaxAspectRatio varies in range [1.0, inf]
2913 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2914 # @return TRUE in case of success, FALSE otherwise.
2915 # @ingroup l2_modif_smooth
2916 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2917 MaxNbOfIterations, MaxAspectRatio, Method):
2918 if IDsOfElements == []:
2919 IDsOfElements = self.GetElementsId()
2920 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2921 self.mesh.SetParameters(Parameters)
2922 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2923 MaxNbOfIterations, MaxAspectRatio, Method)
2925 ## Smoothes elements which belong to the given object
2926 # @param theObject the object to smooth
2927 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2928 # Note that nodes built on edges and boundary nodes are always fixed.
2929 # @param MaxNbOfIterations the maximum number of iterations
2930 # @param MaxAspectRatio varies in range [1.0, inf]
2931 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2932 # @return TRUE in case of success, FALSE otherwise.
2933 # @ingroup l2_modif_smooth
2934 def SmoothObject(self, theObject, IDsOfFixedNodes,
2935 MaxNbOfIterations, MaxAspectRatio, Method):
2936 if ( isinstance( theObject, Mesh )):
2937 theObject = theObject.GetMesh()
2938 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2939 MaxNbOfIterations, MaxAspectRatio, Method)
2941 ## Parametrically smoothes the given elements
2942 # @param IDsOfElements the list if ids of elements to smooth
2943 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2944 # Note that nodes built on edges and boundary nodes are always fixed.
2945 # @param MaxNbOfIterations the maximum number of iterations
2946 # @param MaxAspectRatio varies in range [1.0, inf]
2947 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2948 # @return TRUE in case of success, FALSE otherwise.
2949 # @ingroup l2_modif_smooth
2950 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2951 MaxNbOfIterations, MaxAspectRatio, Method):
2952 if IDsOfElements == []:
2953 IDsOfElements = self.GetElementsId()
2954 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2955 self.mesh.SetParameters(Parameters)
2956 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2957 MaxNbOfIterations, MaxAspectRatio, Method)
2959 ## Parametrically smoothes the elements which belong to the given object
2960 # @param theObject the object to smooth
2961 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2962 # Note that nodes built on edges and boundary nodes are always fixed.
2963 # @param MaxNbOfIterations the maximum number of iterations
2964 # @param MaxAspectRatio varies in range [1.0, inf]
2965 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2966 # @return TRUE in case of success, FALSE otherwise.
2967 # @ingroup l2_modif_smooth
2968 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2969 MaxNbOfIterations, MaxAspectRatio, Method):
2970 if ( isinstance( theObject, Mesh )):
2971 theObject = theObject.GetMesh()
2972 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2973 MaxNbOfIterations, MaxAspectRatio, Method)
2975 ## Converts the mesh to quadratic, deletes old elements, replacing
2976 # them with quadratic with the same id.
2977 # @param theForce3d new node creation method:
2978 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2979 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2980 # @ingroup l2_modif_tofromqu
2981 def ConvertToQuadratic(self, theForce3d):
2982 self.editor.ConvertToQuadratic(theForce3d)
2984 ## Converts the mesh from quadratic to ordinary,
2985 # deletes old quadratic elements, \n replacing
2986 # them with ordinary mesh elements with the same id.
2987 # @return TRUE in case of success, FALSE otherwise.
2988 # @ingroup l2_modif_tofromqu
2989 def ConvertFromQuadratic(self):
2990 return self.editor.ConvertFromQuadratic()
2992 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2993 # @return TRUE if operation has been completed successfully, FALSE otherwise
2994 # @ingroup l2_modif_edit
2995 def Make2DMeshFrom3D(self):
2996 return self.editor. Make2DMeshFrom3D()
2998 ## Renumber mesh nodes
2999 # @ingroup l2_modif_renumber
3000 def RenumberNodes(self):
3001 self.editor.RenumberNodes()
3003 ## Renumber mesh elements
3004 # @ingroup l2_modif_renumber
3005 def RenumberElements(self):
3006 self.editor.RenumberElements()
3008 ## Generates new elements by rotation of the elements around the axis
3009 # @param IDsOfElements the list of ids of elements to sweep
3010 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3011 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3012 # @param NbOfSteps the number of steps
3013 # @param Tolerance tolerance
3014 # @param MakeGroups forces the generation of new groups from existing ones
3015 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3016 # of all steps, else - size of each step
3017 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3018 # @ingroup l2_modif_extrurev
3019 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3020 MakeGroups=False, TotalAngle=False):
3022 if isinstance(AngleInRadians,str):
3024 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3026 AngleInRadians = DegreesToRadians(AngleInRadians)
3027 if IDsOfElements == []:
3028 IDsOfElements = self.GetElementsId()
3029 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3030 Axis = self.smeshpyD.GetAxisStruct(Axis)
3031 Axis,AxisParameters = ParseAxisStruct(Axis)
3032 if TotalAngle and NbOfSteps:
3033 AngleInRadians /= NbOfSteps
3034 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3035 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3036 self.mesh.SetParameters(Parameters)
3038 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3039 AngleInRadians, NbOfSteps, Tolerance)
3040 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3043 ## Generates new elements by rotation of the elements of object around the axis
3044 # @param theObject object which elements should be sweeped
3045 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3046 # @param AngleInRadians the angle of Rotation
3047 # @param NbOfSteps number of steps
3048 # @param Tolerance tolerance
3049 # @param MakeGroups forces the generation of new groups from existing ones
3050 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3051 # of all steps, else - size of each step
3052 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3053 # @ingroup l2_modif_extrurev
3054 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3055 MakeGroups=False, TotalAngle=False):
3057 if isinstance(AngleInRadians,str):
3059 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3061 AngleInRadians = DegreesToRadians(AngleInRadians)
3062 if ( isinstance( theObject, Mesh )):
3063 theObject = theObject.GetMesh()
3064 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3065 Axis = self.smeshpyD.GetAxisStruct(Axis)
3066 Axis,AxisParameters = ParseAxisStruct(Axis)
3067 if TotalAngle and NbOfSteps:
3068 AngleInRadians /= NbOfSteps
3069 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3070 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3071 self.mesh.SetParameters(Parameters)
3073 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3074 NbOfSteps, Tolerance)
3075 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3078 ## Generates new elements by rotation of the elements of object around the axis
3079 # @param theObject object which elements should be sweeped
3080 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3081 # @param AngleInRadians the angle of Rotation
3082 # @param NbOfSteps number of steps
3083 # @param Tolerance tolerance
3084 # @param MakeGroups forces the generation of new groups from existing ones
3085 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3086 # of all steps, else - size of each step
3087 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3088 # @ingroup l2_modif_extrurev
3089 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3090 MakeGroups=False, TotalAngle=False):
3092 if isinstance(AngleInRadians,str):
3094 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3096 AngleInRadians = DegreesToRadians(AngleInRadians)
3097 if ( isinstance( theObject, Mesh )):
3098 theObject = theObject.GetMesh()
3099 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3100 Axis = self.smeshpyD.GetAxisStruct(Axis)
3101 Axis,AxisParameters = ParseAxisStruct(Axis)
3102 if TotalAngle and NbOfSteps:
3103 AngleInRadians /= NbOfSteps
3104 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3105 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3106 self.mesh.SetParameters(Parameters)
3108 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3109 NbOfSteps, Tolerance)
3110 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3113 ## Generates new elements by rotation of the elements of object around the axis
3114 # @param theObject object which elements should be sweeped
3115 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3116 # @param AngleInRadians the angle of Rotation
3117 # @param NbOfSteps number of steps
3118 # @param Tolerance tolerance
3119 # @param MakeGroups forces the generation of new groups from existing ones
3120 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3121 # of all steps, else - size of each step
3122 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3123 # @ingroup l2_modif_extrurev
3124 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3125 MakeGroups=False, TotalAngle=False):
3127 if isinstance(AngleInRadians,str):
3129 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3131 AngleInRadians = DegreesToRadians(AngleInRadians)
3132 if ( isinstance( theObject, Mesh )):
3133 theObject = theObject.GetMesh()
3134 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3135 Axis = self.smeshpyD.GetAxisStruct(Axis)
3136 Axis,AxisParameters = ParseAxisStruct(Axis)
3137 if TotalAngle and NbOfSteps:
3138 AngleInRadians /= NbOfSteps
3139 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3140 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3141 self.mesh.SetParameters(Parameters)
3143 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3144 NbOfSteps, Tolerance)
3145 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3148 ## Generates new elements by extrusion of the elements with given ids
3149 # @param IDsOfElements the list of elements ids for extrusion
3150 # @param StepVector vector, defining the direction and value of extrusion
3151 # @param NbOfSteps the number of steps
3152 # @param MakeGroups forces the generation of new groups from existing ones
3153 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3154 # @ingroup l2_modif_extrurev
3155 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3156 if IDsOfElements == []:
3157 IDsOfElements = self.GetElementsId()
3158 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3159 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3160 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3161 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3162 Parameters = StepVectorParameters + var_separator + Parameters
3163 self.mesh.SetParameters(Parameters)
3165 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3166 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3169 ## Generates new elements by extrusion of the elements with given ids
3170 # @param IDsOfElements is ids of elements
3171 # @param StepVector vector, defining the direction and value of extrusion
3172 # @param NbOfSteps the number of steps
3173 # @param ExtrFlags sets flags for extrusion
3174 # @param SewTolerance uses for comparing locations of nodes if flag
3175 # EXTRUSION_FLAG_SEW is set
3176 # @param MakeGroups forces the generation of new groups from existing ones
3177 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3178 # @ingroup l2_modif_extrurev
3179 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3180 ExtrFlags, SewTolerance, MakeGroups=False):
3181 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3182 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3184 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3185 ExtrFlags, SewTolerance)
3186 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3187 ExtrFlags, SewTolerance)
3190 ## Generates new elements by extrusion of the elements which belong to the object
3191 # @param theObject the object which elements should be processed
3192 # @param StepVector vector, defining the direction and value of extrusion
3193 # @param NbOfSteps the number of steps
3194 # @param MakeGroups forces the generation of new groups from existing ones
3195 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3196 # @ingroup l2_modif_extrurev
3197 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3198 if ( isinstance( theObject, Mesh )):
3199 theObject = theObject.GetMesh()
3200 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3201 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3202 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3203 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3204 Parameters = StepVectorParameters + var_separator + Parameters
3205 self.mesh.SetParameters(Parameters)
3207 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3208 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3211 ## Generates new elements by extrusion of the elements which belong to the object
3212 # @param theObject object which elements should be processed
3213 # @param StepVector vector, defining the direction and value of extrusion
3214 # @param NbOfSteps the number of steps
3215 # @param MakeGroups to generate new groups from existing ones
3216 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3217 # @ingroup l2_modif_extrurev
3218 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3219 if ( isinstance( theObject, Mesh )):
3220 theObject = theObject.GetMesh()
3221 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3222 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3223 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3224 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3225 Parameters = StepVectorParameters + var_separator + Parameters
3226 self.mesh.SetParameters(Parameters)
3228 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3229 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3232 ## Generates new elements by extrusion of the elements which belong to the object
3233 # @param theObject object which elements should be processed
3234 # @param StepVector vector, defining the direction and value of extrusion
3235 # @param NbOfSteps the number of steps
3236 # @param MakeGroups forces the generation of new groups from existing ones
3237 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3238 # @ingroup l2_modif_extrurev
3239 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3240 if ( isinstance( theObject, Mesh )):
3241 theObject = theObject.GetMesh()
3242 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3243 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3244 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3245 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3246 Parameters = StepVectorParameters + var_separator + Parameters
3247 self.mesh.SetParameters(Parameters)
3249 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3250 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3255 ## Generates new elements by extrusion of the given elements
3256 # The path of extrusion must be a meshed edge.
3257 # @param Base mesh or list of ids of elements for extrusion
3258 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3259 # @param NodeStart the start node from Path. Defines the direction of extrusion
3260 # @param HasAngles allows the shape to be rotated around the path
3261 # to get the resulting mesh in a helical fashion
3262 # @param Angles list of angles in radians
3263 # @param LinearVariation forces the computation of rotation angles as linear
3264 # variation of the given Angles along path steps
3265 # @param HasRefPoint allows using the reference point
3266 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3267 # The User can specify any point as the Reference Point.
3268 # @param MakeGroups forces the generation of new groups from existing ones
3269 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3270 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3271 # only SMESH::Extrusion_Error otherwise
3272 # @ingroup l2_modif_extrurev
3273 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3274 HasAngles, Angles, LinearVariation,
3275 HasRefPoint, RefPoint, MakeGroups, ElemType):
3276 Angles,AnglesParameters = ParseAngles(Angles)
3277 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3278 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3279 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3281 Parameters = AnglesParameters + var_separator + RefPointParameters
3282 self.mesh.SetParameters(Parameters)
3284 if isinstance(Base,list):
3286 if Base == []: IDsOfElements = self.GetElementsId()
3287 else: IDsOfElements = Base
3288 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3289 HasAngles, Angles, LinearVariation,
3290 HasRefPoint, RefPoint, MakeGroups, ElemType)
3292 if isinstance(Base,Mesh):
3293 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3294 HasAngles, Angles, LinearVariation,
3295 HasRefPoint, RefPoint, MakeGroups, ElemType)
3297 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3300 ## Generates new elements by extrusion of the given elements
3301 # The path of extrusion must be a meshed edge.
3302 # @param IDsOfElements ids of elements
3303 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3304 # @param PathShape shape(edge) defines the sub-mesh for the path
3305 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3306 # @param HasAngles allows the shape to be rotated around the path
3307 # to get the resulting mesh in a helical fashion
3308 # @param Angles list of angles in radians
3309 # @param HasRefPoint allows using the reference point
3310 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3311 # The User can specify any point as the Reference Point.
3312 # @param MakeGroups forces the generation of new groups from existing ones
3313 # @param LinearVariation forces the computation of rotation angles as linear
3314 # variation of the given Angles along path steps
3315 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3316 # only SMESH::Extrusion_Error otherwise
3317 # @ingroup l2_modif_extrurev
3318 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3319 HasAngles, Angles, HasRefPoint, RefPoint,
3320 MakeGroups=False, LinearVariation=False):
3321 Angles,AnglesParameters = ParseAngles(Angles)
3322 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3323 if IDsOfElements == []:
3324 IDsOfElements = self.GetElementsId()
3325 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3326 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3328 if ( isinstance( PathMesh, Mesh )):
3329 PathMesh = PathMesh.GetMesh()
3330 if HasAngles and Angles and LinearVariation:
3331 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3333 Parameters = AnglesParameters + var_separator + RefPointParameters
3334 self.mesh.SetParameters(Parameters)
3336 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3337 PathShape, NodeStart, HasAngles,
3338 Angles, HasRefPoint, RefPoint)
3339 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3340 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3342 ## Generates new elements by extrusion of the elements which belong to the object
3343 # The path of extrusion must be a meshed edge.
3344 # @param theObject the object which elements should be processed
3345 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3346 # @param PathShape shape(edge) defines the sub-mesh for the path
3347 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3348 # @param HasAngles allows the shape to be rotated around the path
3349 # to get the resulting mesh in a helical fashion
3350 # @param Angles list of angles
3351 # @param HasRefPoint allows using the reference point
3352 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3353 # The User can specify any point as the Reference Point.
3354 # @param MakeGroups forces the generation of new groups from existing ones
3355 # @param LinearVariation forces the computation of rotation angles as linear
3356 # variation of the given Angles along path steps
3357 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3358 # only SMESH::Extrusion_Error otherwise
3359 # @ingroup l2_modif_extrurev
3360 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3361 HasAngles, Angles, HasRefPoint, RefPoint,
3362 MakeGroups=False, LinearVariation=False):
3363 Angles,AnglesParameters = ParseAngles(Angles)
3364 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3365 if ( isinstance( theObject, Mesh )):
3366 theObject = theObject.GetMesh()
3367 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3368 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3369 if ( isinstance( PathMesh, Mesh )):
3370 PathMesh = PathMesh.GetMesh()
3371 if HasAngles and Angles and LinearVariation:
3372 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3374 Parameters = AnglesParameters + var_separator + RefPointParameters
3375 self.mesh.SetParameters(Parameters)
3377 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3378 PathShape, NodeStart, HasAngles,
3379 Angles, HasRefPoint, RefPoint)
3380 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3381 NodeStart, HasAngles, Angles, HasRefPoint,
3384 ## Generates new elements by extrusion of the elements which belong to the object
3385 # The path of extrusion must be a meshed edge.
3386 # @param theObject the object which elements should be processed
3387 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3388 # @param PathShape shape(edge) defines the sub-mesh for the path
3389 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3390 # @param HasAngles allows the shape to be rotated around the path
3391 # to get the resulting mesh in a helical fashion
3392 # @param Angles list of angles
3393 # @param HasRefPoint allows using the reference point
3394 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3395 # The User can specify any point as the Reference Point.
3396 # @param MakeGroups forces the generation of new groups from existing ones
3397 # @param LinearVariation forces the computation of rotation angles as linear
3398 # variation of the given Angles along path steps
3399 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3400 # only SMESH::Extrusion_Error otherwise
3401 # @ingroup l2_modif_extrurev
3402 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3403 HasAngles, Angles, HasRefPoint, RefPoint,
3404 MakeGroups=False, LinearVariation=False):
3405 Angles,AnglesParameters = ParseAngles(Angles)
3406 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3407 if ( isinstance( theObject, Mesh )):
3408 theObject = theObject.GetMesh()
3409 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3410 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3411 if ( isinstance( PathMesh, Mesh )):
3412 PathMesh = PathMesh.GetMesh()
3413 if HasAngles and Angles and LinearVariation:
3414 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3416 Parameters = AnglesParameters + var_separator + RefPointParameters
3417 self.mesh.SetParameters(Parameters)
3419 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3420 PathShape, NodeStart, HasAngles,
3421 Angles, HasRefPoint, RefPoint)
3422 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3423 NodeStart, HasAngles, Angles, HasRefPoint,
3426 ## Generates new elements by extrusion of the elements which belong to the object
3427 # The path of extrusion must be a meshed edge.
3428 # @param theObject the object which elements should be processed
3429 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3430 # @param PathShape shape(edge) defines the sub-mesh for the path
3431 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3432 # @param HasAngles allows the shape to be rotated around the path
3433 # to get the resulting mesh in a helical fashion
3434 # @param Angles list of angles
3435 # @param HasRefPoint allows using the reference point
3436 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3437 # The User can specify any point as the Reference Point.
3438 # @param MakeGroups forces the generation of new groups from existing ones
3439 # @param LinearVariation forces the computation of rotation angles as linear
3440 # variation of the given Angles along path steps
3441 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3442 # only SMESH::Extrusion_Error otherwise
3443 # @ingroup l2_modif_extrurev
3444 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3445 HasAngles, Angles, HasRefPoint, RefPoint,
3446 MakeGroups=False, LinearVariation=False):
3447 Angles,AnglesParameters = ParseAngles(Angles)
3448 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3449 if ( isinstance( theObject, Mesh )):
3450 theObject = theObject.GetMesh()
3451 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3452 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3453 if ( isinstance( PathMesh, Mesh )):
3454 PathMesh = PathMesh.GetMesh()
3455 if HasAngles and Angles and LinearVariation:
3456 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3458 Parameters = AnglesParameters + var_separator + RefPointParameters
3459 self.mesh.SetParameters(Parameters)
3461 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3462 PathShape, NodeStart, HasAngles,
3463 Angles, HasRefPoint, RefPoint)
3464 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3465 NodeStart, HasAngles, Angles, HasRefPoint,
3468 ## Creates a symmetrical copy of mesh elements
3469 # @param IDsOfElements list of elements ids
3470 # @param Mirror is AxisStruct or geom object(point, line, plane)
3471 # @param theMirrorType is POINT, AXIS or PLANE
3472 # If the Mirror is a geom object this parameter is unnecessary
3473 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3474 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3475 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3476 # @ingroup l2_modif_trsf
3477 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3478 if IDsOfElements == []:
3479 IDsOfElements = self.GetElementsId()
3480 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3481 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3482 Mirror,Parameters = ParseAxisStruct(Mirror)
3483 self.mesh.SetParameters(Parameters)
3484 if Copy and MakeGroups:
3485 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3486 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3489 ## Creates a new mesh by a symmetrical copy of mesh elements
3490 # @param IDsOfElements the list of elements ids
3491 # @param Mirror is AxisStruct or geom object (point, line, plane)
3492 # @param theMirrorType is POINT, AXIS or PLANE
3493 # If the Mirror is a geom object this parameter is unnecessary
3494 # @param MakeGroups to generate new groups from existing ones
3495 # @param NewMeshName a name of the new mesh to create
3496 # @return instance of Mesh class
3497 # @ingroup l2_modif_trsf
3498 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3499 if IDsOfElements == []:
3500 IDsOfElements = self.GetElementsId()
3501 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3502 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3503 Mirror,Parameters = ParseAxisStruct(Mirror)
3504 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3505 MakeGroups, NewMeshName)
3506 mesh.SetParameters(Parameters)
3507 return Mesh(self.smeshpyD,self.geompyD,mesh)
3509 ## Creates a symmetrical copy of the object
3510 # @param theObject mesh, submesh or group
3511 # @param Mirror AxisStruct or geom object (point, line, plane)
3512 # @param theMirrorType is POINT, AXIS or PLANE
3513 # If the Mirror is a geom object this parameter is unnecessary
3514 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3515 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3516 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3517 # @ingroup l2_modif_trsf
3518 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3519 if ( isinstance( theObject, Mesh )):
3520 theObject = theObject.GetMesh()
3521 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3522 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3523 Mirror,Parameters = ParseAxisStruct(Mirror)
3524 self.mesh.SetParameters(Parameters)
3525 if Copy and MakeGroups:
3526 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3527 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3530 ## Creates a new mesh by a symmetrical copy of the object
3531 # @param theObject mesh, submesh or group
3532 # @param Mirror AxisStruct or geom object (point, line, plane)
3533 # @param theMirrorType POINT, AXIS or PLANE
3534 # If the Mirror is a geom object this parameter is unnecessary
3535 # @param MakeGroups forces the generation of new groups from existing ones
3536 # @param NewMeshName the name of the new mesh to create
3537 # @return instance of Mesh class
3538 # @ingroup l2_modif_trsf
3539 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3540 if ( isinstance( theObject, Mesh )):
3541 theObject = theObject.GetMesh()
3542 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3543 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3544 Mirror,Parameters = ParseAxisStruct(Mirror)
3545 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3546 MakeGroups, NewMeshName)
3547 mesh.SetParameters(Parameters)
3548 return Mesh( self.smeshpyD,self.geompyD,mesh )
3550 ## Translates the elements
3551 # @param IDsOfElements list of elements ids
3552 # @param Vector the direction of translation (DirStruct or vector)
3553 # @param Copy allows copying the translated elements
3554 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3555 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3556 # @ingroup l2_modif_trsf
3557 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3558 if IDsOfElements == []:
3559 IDsOfElements = self.GetElementsId()
3560 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3561 Vector = self.smeshpyD.GetDirStruct(Vector)
3562 Vector,Parameters = ParseDirStruct(Vector)
3563 self.mesh.SetParameters(Parameters)
3564 if Copy and MakeGroups:
3565 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3566 self.editor.Translate(IDsOfElements, Vector, Copy)
3569 ## Creates a new mesh of translated elements
3570 # @param IDsOfElements list of elements ids
3571 # @param Vector the direction of translation (DirStruct or vector)
3572 # @param MakeGroups forces the generation of new groups from existing ones
3573 # @param NewMeshName the name of the newly created mesh
3574 # @return instance of Mesh class
3575 # @ingroup l2_modif_trsf
3576 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3577 if IDsOfElements == []:
3578 IDsOfElements = self.GetElementsId()
3579 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3580 Vector = self.smeshpyD.GetDirStruct(Vector)
3581 Vector,Parameters = ParseDirStruct(Vector)
3582 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3583 mesh.SetParameters(Parameters)
3584 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3586 ## Translates the object
3587 # @param theObject the object to translate (mesh, submesh, or group)
3588 # @param Vector direction of translation (DirStruct or geom vector)
3589 # @param Copy allows copying the translated elements
3590 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3591 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3592 # @ingroup l2_modif_trsf
3593 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3594 if ( isinstance( theObject, Mesh )):
3595 theObject = theObject.GetMesh()
3596 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3597 Vector = self.smeshpyD.GetDirStruct(Vector)
3598 Vector,Parameters = ParseDirStruct(Vector)
3599 self.mesh.SetParameters(Parameters)
3600 if Copy and MakeGroups:
3601 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3602 self.editor.TranslateObject(theObject, Vector, Copy)
3605 ## Creates a new mesh from the translated object
3606 # @param theObject the object to translate (mesh, submesh, or group)
3607 # @param Vector the direction of translation (DirStruct or geom vector)
3608 # @param MakeGroups forces the generation of new groups from existing ones
3609 # @param NewMeshName the name of the newly created mesh
3610 # @return instance of Mesh class
3611 # @ingroup l2_modif_trsf
3612 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3613 if (isinstance(theObject, Mesh)):
3614 theObject = theObject.GetMesh()
3615 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3616 Vector = self.smeshpyD.GetDirStruct(Vector)
3617 Vector,Parameters = ParseDirStruct(Vector)
3618 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3619 mesh.SetParameters(Parameters)
3620 return Mesh( self.smeshpyD, self.geompyD, mesh )
3624 ## Scales the object
3625 # @param theObject - the object to translate (mesh, submesh, or group)
3626 # @param thePoint - base point for scale
3627 # @param theScaleFact - list of 1-3 scale factors for axises
3628 # @param Copy - allows copying the translated elements
3629 # @param MakeGroups - forces the generation of new groups from existing
3631 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3632 # empty list otherwise
3633 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3634 if ( isinstance( theObject, Mesh )):
3635 theObject = theObject.GetMesh()
3636 if ( isinstance( theObject, list )):
3637 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3639 thePoint, Parameters = ParsePointStruct(thePoint)
3640 self.mesh.SetParameters(Parameters)
3642 if Copy and MakeGroups:
3643 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3644 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3647 ## Creates a new mesh from the translated object
3648 # @param theObject - the object to translate (mesh, submesh, or group)
3649 # @param thePoint - base point for scale
3650 # @param theScaleFact - list of 1-3 scale factors for axises
3651 # @param MakeGroups - forces the generation of new groups from existing ones
3652 # @param NewMeshName - the name of the newly created mesh
3653 # @return instance of Mesh class
3654 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3655 if (isinstance(theObject, Mesh)):
3656 theObject = theObject.GetMesh()
3657 if ( isinstance( theObject, list )):
3658 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3660 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3661 MakeGroups, NewMeshName)
3662 #mesh.SetParameters(Parameters)
3663 return Mesh( self.smeshpyD, self.geompyD, mesh )
3667 ## Rotates the elements
3668 # @param IDsOfElements list of elements ids
3669 # @param Axis the axis of rotation (AxisStruct or geom line)
3670 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3671 # @param Copy allows copying the rotated elements
3672 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3673 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3674 # @ingroup l2_modif_trsf
3675 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3677 if isinstance(AngleInRadians,str):
3679 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3681 AngleInRadians = DegreesToRadians(AngleInRadians)
3682 if IDsOfElements == []:
3683 IDsOfElements = self.GetElementsId()
3684 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3685 Axis = self.smeshpyD.GetAxisStruct(Axis)
3686 Axis,AxisParameters = ParseAxisStruct(Axis)
3687 Parameters = AxisParameters + var_separator + Parameters
3688 self.mesh.SetParameters(Parameters)
3689 if Copy and MakeGroups:
3690 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3691 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3694 ## Creates a new mesh of rotated elements
3695 # @param IDsOfElements list of element ids
3696 # @param Axis the axis of rotation (AxisStruct or geom line)
3697 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3698 # @param MakeGroups forces the generation of new groups from existing ones
3699 # @param NewMeshName the name of the newly created mesh
3700 # @return instance of Mesh class
3701 # @ingroup l2_modif_trsf
3702 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3704 if isinstance(AngleInRadians,str):
3706 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3708 AngleInRadians = DegreesToRadians(AngleInRadians)
3709 if IDsOfElements == []:
3710 IDsOfElements = self.GetElementsId()
3711 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3712 Axis = self.smeshpyD.GetAxisStruct(Axis)
3713 Axis,AxisParameters = ParseAxisStruct(Axis)
3714 Parameters = AxisParameters + var_separator + Parameters
3715 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3716 MakeGroups, NewMeshName)
3717 mesh.SetParameters(Parameters)
3718 return Mesh( self.smeshpyD, self.geompyD, mesh )
3720 ## Rotates the object
3721 # @param theObject the object to rotate( mesh, submesh, or group)
3722 # @param Axis the axis of rotation (AxisStruct or geom line)
3723 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3724 # @param Copy allows copying the rotated elements
3725 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3726 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3727 # @ingroup l2_modif_trsf
3728 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3730 if isinstance(AngleInRadians,str):
3732 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3734 AngleInRadians = DegreesToRadians(AngleInRadians)
3735 if (isinstance(theObject, Mesh)):
3736 theObject = theObject.GetMesh()
3737 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3738 Axis = self.smeshpyD.GetAxisStruct(Axis)
3739 Axis,AxisParameters = ParseAxisStruct(Axis)
3740 Parameters = AxisParameters + ":" + Parameters
3741 self.mesh.SetParameters(Parameters)
3742 if Copy and MakeGroups:
3743 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3744 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3747 ## Creates a new mesh from the rotated object
3748 # @param theObject the object to rotate (mesh, submesh, or group)
3749 # @param Axis the axis of rotation (AxisStruct or geom line)
3750 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3751 # @param MakeGroups forces the generation of new groups from existing ones
3752 # @param NewMeshName the name of the newly created mesh
3753 # @return instance of Mesh class
3754 # @ingroup l2_modif_trsf
3755 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3757 if isinstance(AngleInRadians,str):
3759 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3761 AngleInRadians = DegreesToRadians(AngleInRadians)
3762 if (isinstance( theObject, Mesh )):
3763 theObject = theObject.GetMesh()
3764 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3765 Axis = self.smeshpyD.GetAxisStruct(Axis)
3766 Axis,AxisParameters = ParseAxisStruct(Axis)
3767 Parameters = AxisParameters + ":" + Parameters
3768 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3769 MakeGroups, NewMeshName)
3770 mesh.SetParameters(Parameters)
3771 return Mesh( self.smeshpyD, self.geompyD, mesh )
3773 ## Finds groups of ajacent nodes within Tolerance.
3774 # @param Tolerance the value of tolerance
3775 # @return the list of groups of nodes
3776 # @ingroup l2_modif_trsf
3777 def FindCoincidentNodes (self, Tolerance):
3778 return self.editor.FindCoincidentNodes(Tolerance)
3780 ## Finds groups of ajacent nodes within Tolerance.
3781 # @param Tolerance the value of tolerance
3782 # @param SubMeshOrGroup SubMesh or Group
3783 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3784 # @return the list of groups of nodes
3785 # @ingroup l2_modif_trsf
3786 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3787 if (isinstance( SubMeshOrGroup, Mesh )):
3788 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3789 if not isinstance( ExceptSubMeshOrGroups, list):
3790 ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
3791 if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
3792 ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
3793 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
3796 # @param GroupsOfNodes the list of groups of nodes
3797 # @ingroup l2_modif_trsf
3798 def MergeNodes (self, GroupsOfNodes):
3799 self.editor.MergeNodes(GroupsOfNodes)
3801 ## Finds the elements built on the same nodes.
3802 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3803 # @return a list of groups of equal elements
3804 # @ingroup l2_modif_trsf
3805 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3806 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3807 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3808 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3810 ## Merges elements in each given group.
3811 # @param GroupsOfElementsID groups of elements for merging
3812 # @ingroup l2_modif_trsf
3813 def MergeElements(self, GroupsOfElementsID):
3814 self.editor.MergeElements(GroupsOfElementsID)
3816 ## Leaves one element and removes all other elements built on the same nodes.
3817 # @ingroup l2_modif_trsf
3818 def MergeEqualElements(self):
3819 self.editor.MergeEqualElements()
3821 ## Sews free borders
3822 # @return SMESH::Sew_Error
3823 # @ingroup l2_modif_trsf
3824 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3825 FirstNodeID2, SecondNodeID2, LastNodeID2,
3826 CreatePolygons, CreatePolyedrs):
3827 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3828 FirstNodeID2, SecondNodeID2, LastNodeID2,
3829 CreatePolygons, CreatePolyedrs)
3831 ## Sews conform free borders
3832 # @return SMESH::Sew_Error
3833 # @ingroup l2_modif_trsf
3834 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3835 FirstNodeID2, SecondNodeID2):
3836 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3837 FirstNodeID2, SecondNodeID2)
3839 ## Sews border to side
3840 # @return SMESH::Sew_Error
3841 # @ingroup l2_modif_trsf
3842 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3843 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3844 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3845 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3847 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3848 # merged with the nodes of elements of Side2.
3849 # The number of elements in theSide1 and in theSide2 must be
3850 # equal and they should have similar nodal connectivity.
3851 # The nodes to merge should belong to side borders and
3852 # the first node should be linked to the second.
3853 # @return SMESH::Sew_Error
3854 # @ingroup l2_modif_trsf
3855 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3856 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3857 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3858 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3859 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3860 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3862 ## Sets new nodes for the given element.
3863 # @param ide the element id
3864 # @param newIDs nodes ids
3865 # @return If the number of nodes does not correspond to the type of element - returns false
3866 # @ingroup l2_modif_edit
3867 def ChangeElemNodes(self, ide, newIDs):
3868 return self.editor.ChangeElemNodes(ide, newIDs)
3870 ## If during the last operation of MeshEditor some nodes were
3871 # created, this method returns the list of their IDs, \n
3872 # if new nodes were not created - returns empty list
3873 # @return the list of integer values (can be empty)
3874 # @ingroup l1_auxiliary
3875 def GetLastCreatedNodes(self):
3876 return self.editor.GetLastCreatedNodes()
3878 ## If during the last operation of MeshEditor some elements were
3879 # created this method returns the list of their IDs, \n
3880 # if new elements were not created - returns empty list
3881 # @return the list of integer values (can be empty)
3882 # @ingroup l1_auxiliary
3883 def GetLastCreatedElems(self):
3884 return self.editor.GetLastCreatedElems()
3886 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3887 # @param theNodes identifiers of nodes to be doubled
3888 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3889 # nodes. If list of element identifiers is empty then nodes are doubled but
3890 # they not assigned to elements
3891 # @return TRUE if operation has been completed successfully, FALSE otherwise
3892 # @ingroup l2_modif_edit
3893 def DoubleNodes(self, theNodes, theModifiedElems):
3894 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3896 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3897 # This method provided for convenience works as DoubleNodes() described above.
3898 # @param theNodeId identifiers of node to be doubled
3899 # @param theModifiedElems identifiers of elements to be updated
3900 # @return TRUE if operation has been completed successfully, FALSE otherwise
3901 # @ingroup l2_modif_edit
3902 def DoubleNode(self, theNodeId, theModifiedElems):
3903 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3905 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3906 # This method provided for convenience works as DoubleNodes() described above.
3907 # @param theNodes group of nodes to be doubled
3908 # @param theModifiedElems group of elements to be updated.
3909 # @param theMakeGroup forces the generation of a group containing new nodes.
3910 # @return TRUE or a created group if operation has been completed successfully,
3911 # FALSE or None otherwise
3912 # @ingroup l2_modif_edit
3913 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3915 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3916 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3918 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3919 # This method provided for convenience works as DoubleNodes() described above.
3920 # @param theNodes list of groups of nodes to be doubled
3921 # @param theModifiedElems list of groups of elements to be updated.
3922 # @return TRUE if operation has been completed successfully, FALSE otherwise
3923 # @ingroup l2_modif_edit
3924 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3925 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3927 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3928 # @param theElems - the list of elements (edges or faces) to be replicated
3929 # The nodes for duplication could be found from these elements
3930 # @param theNodesNot - list of nodes to NOT replicate
3931 # @param theAffectedElems - the list of elements (cells and edges) to which the
3932 # replicated nodes should be associated to.
3933 # @return TRUE if operation has been completed successfully, FALSE otherwise
3934 # @ingroup l2_modif_edit
3935 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3936 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3938 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3939 # @param theElems - the list of elements (edges or faces) to be replicated
3940 # The nodes for duplication could be found from these elements
3941 # @param theNodesNot - list of nodes to NOT replicate
3942 # @param theShape - shape to detect affected elements (element which geometric center
3943 # located on or inside shape).
3944 # The replicated nodes should be associated to affected elements.
3945 # @return TRUE if operation has been completed successfully, FALSE otherwise
3946 # @ingroup l2_modif_edit
3947 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3948 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3950 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3951 # This method provided for convenience works as DoubleNodes() described above.
3952 # @param theElems - group of of elements (edges or faces) to be replicated
3953 # @param theNodesNot - group of nodes not to replicated
3954 # @param theAffectedElems - group of elements to which the replicated nodes
3955 # should be associated to.
3956 # @param theMakeGroup forces the generation of a group containing new elements.
3957 # @ingroup l2_modif_edit
3958 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3960 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3961 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3963 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3964 # This method provided for convenience works as DoubleNodes() described above.
3965 # @param theElems - group of of elements (edges or faces) to be replicated
3966 # @param theNodesNot - group of nodes not to replicated
3967 # @param theShape - shape to detect affected elements (element which geometric center
3968 # located on or inside shape).
3969 # The replicated nodes should be associated to affected elements.
3970 # @ingroup l2_modif_edit
3971 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3972 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3974 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3975 # This method provided for convenience works as DoubleNodes() described above.
3976 # @param theElems - list of groups of elements (edges or faces) to be replicated
3977 # @param theNodesNot - list of groups of nodes not to replicated
3978 # @param theAffectedElems - group of elements to which the replicated nodes
3979 # should be associated to.
3980 # @return TRUE if operation has been completed successfully, FALSE otherwise
3981 # @ingroup l2_modif_edit
3982 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3983 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3985 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3986 # This method provided for convenience works as DoubleNodes() described above.
3987 # @param theElems - list of groups of elements (edges or faces) to be replicated
3988 # @param theNodesNot - list of groups of nodes not to replicated
3989 # @param theShape - shape to detect affected elements (element which geometric center
3990 # located on or inside shape).
3991 # The replicated nodes should be associated to affected elements.
3992 # @return TRUE if operation has been completed successfully, FALSE otherwise
3993 # @ingroup l2_modif_edit
3994 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3995 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3997 def _valueFromFunctor(self, funcType, elemId):
3998 fn = self.smeshpyD.GetFunctor(funcType)
3999 fn.SetMesh(self.mesh)
4000 if fn.GetElementType() == self.GetElementType(elemId, True):
4001 val = fn.GetValue(elemId)
4006 ## Get length of 1D element.
4007 # @param elemId mesh element ID
4008 # @return element's length value
4009 # @ingroup l1_measurements
4010 def GetLength(self, elemId):
4011 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4013 ## Get area of 2D element.
4014 # @param elemId mesh element ID
4015 # @return element's area value
4016 # @ingroup l1_measurements
4017 def GetArea(self, elemId):
4018 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4020 ## Get volume of 3D element.
4021 # @param elemId mesh element ID
4022 # @return element's volume value
4023 # @ingroup l1_measurements
4024 def GetVolume(self, elemId):
4025 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4027 ## Get maximum element length.
4028 # @param elemId mesh element ID
4029 # @return element's maximum length value
4030 # @ingroup l1_measurements
4031 def GetMaxElementLength(self, elemId):
4032 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4033 ftype = SMESH.FT_MaxElementLength3D
4035 ftype = SMESH.FT_MaxElementLength2D
4036 return self._valueFromFunctor(ftype, elemId)
4038 ## Get aspect ratio of 2D or 3D element.
4039 # @param elemId mesh element ID
4040 # @return element's aspect ratio value
4041 # @ingroup l1_measurements
4042 def GetAspectRatio(self, elemId):
4043 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4044 ftype = SMESH.FT_AspectRatio3D
4046 ftype = SMESH.FT_AspectRatio
4047 return self._valueFromFunctor(ftype, elemId)
4049 ## Get warping angle of 2D element.
4050 # @param elemId mesh element ID
4051 # @return element's warping angle value
4052 # @ingroup l1_measurements
4053 def GetWarping(self, elemId):
4054 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4056 ## Get minimum angle of 2D element.
4057 # @param elemId mesh element ID
4058 # @return element's minimum angle value
4059 # @ingroup l1_measurements
4060 def GetMinimumAngle(self, elemId):
4061 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4063 ## Get taper of 2D element.
4064 # @param elemId mesh element ID
4065 # @return element's taper value
4066 # @ingroup l1_measurements
4067 def GetTaper(self, elemId):
4068 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4070 ## Get skew of 2D element.
4071 # @param elemId mesh element ID
4072 # @return element's skew value
4073 # @ingroup l1_measurements
4074 def GetSkew(self, elemId):
4075 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4077 ## The mother class to define algorithm, it is not recommended to use it directly.
4080 # @ingroup l2_algorithms
4081 class Mesh_Algorithm:
4082 # @class Mesh_Algorithm
4083 # @brief Class Mesh_Algorithm
4085 #def __init__(self,smesh):
4093 ## Finds a hypothesis in the study by its type name and parameters.
4094 # Finds only the hypotheses created in smeshpyD engine.
4095 # @return SMESH.SMESH_Hypothesis
4096 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4097 study = smeshpyD.GetCurrentStudy()
4098 #to do: find component by smeshpyD object, not by its data type
4099 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4100 if scomp is not None:
4101 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4102 # Check if the root label of the hypotheses exists
4103 if res and hypRoot is not None:
4104 iter = study.NewChildIterator(hypRoot)
4105 # Check all published hypotheses
4107 hypo_so_i = iter.Value()
4108 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4109 if attr is not None:
4110 anIOR = attr.Value()
4111 hypo_o_i = salome.orb.string_to_object(anIOR)
4112 if hypo_o_i is not None:
4113 # Check if this is a hypothesis
4114 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4115 if hypo_i is not None:
4116 # Check if the hypothesis belongs to current engine
4117 if smeshpyD.GetObjectId(hypo_i) > 0:
4118 # Check if this is the required hypothesis
4119 if hypo_i.GetName() == hypname:
4121 if CompareMethod(hypo_i, args):
4135 ## Finds the algorithm in the study by its type name.
4136 # Finds only the algorithms, which have been created in smeshpyD engine.
4137 # @return SMESH.SMESH_Algo
4138 def FindAlgorithm (self, algoname, smeshpyD):
4139 study = smeshpyD.GetCurrentStudy()
4140 #to do: find component by smeshpyD object, not by its data type
4141 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4142 if scomp is not None:
4143 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4144 # Check if the root label of the algorithms exists
4145 if res and hypRoot is not None:
4146 iter = study.NewChildIterator(hypRoot)
4147 # Check all published algorithms
4149 algo_so_i = iter.Value()
4150 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4151 if attr is not None:
4152 anIOR = attr.Value()
4153 algo_o_i = salome.orb.string_to_object(anIOR)
4154 if algo_o_i is not None:
4155 # Check if this is an algorithm
4156 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4157 if algo_i is not None:
4158 # Checks if the algorithm belongs to the current engine
4159 if smeshpyD.GetObjectId(algo_i) > 0:
4160 # Check if this is the required algorithm
4161 if algo_i.GetName() == algoname:
4174 ## If the algorithm is global, returns 0; \n
4175 # else returns the submesh associated to this algorithm.
4176 def GetSubMesh(self):
4179 ## Returns the wrapped mesher.
4180 def GetAlgorithm(self):
4183 ## Gets the list of hypothesis that can be used with this algorithm
4184 def GetCompatibleHypothesis(self):
4187 mylist = self.algo.GetCompatibleHypothesis()
4190 ## Gets the name of the algorithm
4194 ## Sets the name to the algorithm
4195 def SetName(self, name):
4196 self.mesh.smeshpyD.SetName(self.algo, name)
4198 ## Gets the id of the algorithm
4200 return self.algo.GetId()
4203 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4205 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4206 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4208 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4210 self.Assign(algo, mesh, geom)
4214 def Assign(self, algo, mesh, geom):
4216 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4225 name = GetName(geom)
4228 name = mesh.geompyD.SubShapeName(geom, piece)
4229 mesh.geompyD.addToStudyInFather(piece, geom, name)
4231 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4234 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4235 TreatHypoStatus( status, algo.GetName(), name, True )
4237 def CompareHyp (self, hyp, args):
4238 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4241 def CompareEqualHyp (self, hyp, args):
4245 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4246 UseExisting=0, CompareMethod=""):
4249 if CompareMethod == "": CompareMethod = self.CompareHyp
4250 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4253 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4259 a = a + s + str(args[i])
4263 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4265 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4266 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4269 ## Returns entry of the shape to mesh in the study
4270 def MainShapeEntry(self):
4272 if not self.mesh or not self.mesh.GetMesh(): return entry
4273 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4274 study = self.mesh.smeshpyD.GetCurrentStudy()
4275 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4276 sobj = study.FindObjectIOR(ior)
4277 if sobj: entry = sobj.GetID()
4278 if not entry: return ""
4281 # Public class: Mesh_Segment
4282 # --------------------------
4284 ## Class to define a segment 1D algorithm for discretization
4287 # @ingroup l3_algos_basic
4288 class Mesh_Segment(Mesh_Algorithm):
4290 ## Private constructor.
4291 def __init__(self, mesh, geom=0):
4292 Mesh_Algorithm.__init__(self)
4293 self.Create(mesh, geom, "Regular_1D")
4295 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4296 # @param l for the length of segments that cut an edge
4297 # @param UseExisting if ==true - searches for an existing hypothesis created with
4298 # the same parameters, else (default) - creates a new one
4299 # @param p precision, used for calculation of the number of segments.
4300 # The precision should be a positive, meaningful value within the range [0,1].
4301 # In general, the number of segments is calculated with the formula:
4302 # nb = ceil((edge_length / l) - p)
4303 # Function ceil rounds its argument to the higher integer.
4304 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4305 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4306 # p=1 means rounding of (edge_length / l) to the lower integer.
4307 # Default value is 1e-07.
4308 # @return an instance of StdMeshers_LocalLength hypothesis
4309 # @ingroup l3_hypos_1dhyps
4310 def LocalLength(self, l, UseExisting=0, p=1e-07):
4311 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4312 CompareMethod=self.CompareLocalLength)
4318 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4319 def CompareLocalLength(self, hyp, args):
4320 if IsEqual(hyp.GetLength(), args[0]):
4321 return IsEqual(hyp.GetPrecision(), args[1])
4324 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4325 # @param length is optional maximal allowed length of segment, if it is omitted
4326 # the preestimated length is used that depends on geometry size
4327 # @param UseExisting if ==true - searches for an existing hypothesis created with
4328 # the same parameters, else (default) - create a new one
4329 # @return an instance of StdMeshers_MaxLength hypothesis
4330 # @ingroup l3_hypos_1dhyps
4331 def MaxSize(self, length=0.0, UseExisting=0):
4332 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4335 hyp.SetLength(length)
4337 # set preestimated length
4338 gen = self.mesh.smeshpyD
4339 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4340 self.mesh.GetMesh(), self.mesh.GetShape(),
4342 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4344 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4347 hyp.SetUsePreestimatedLength( length == 0.0 )
4350 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4351 # @param n for the number of segments that cut an edge
4352 # @param s for the scale factor (optional)
4353 # @param reversedEdges is a list of edges to mesh using reversed orientation
4354 # @param UseExisting if ==true - searches for an existing hypothesis created with
4355 # the same parameters, else (default) - create a new one
4356 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4357 # @ingroup l3_hypos_1dhyps
4358 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4359 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4360 reversedEdges, UseExisting = [], reversedEdges
4361 entry = self.MainShapeEntry()
4363 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4364 UseExisting=UseExisting,
4365 CompareMethod=self.CompareNumberOfSegments)
4367 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4368 UseExisting=UseExisting,
4369 CompareMethod=self.CompareNumberOfSegments)
4370 hyp.SetDistrType( 1 )
4371 hyp.SetScaleFactor(s)
4372 hyp.SetNumberOfSegments(n)
4373 hyp.SetReversedEdges( reversedEdges )
4374 hyp.SetObjectEntry( entry )
4378 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4379 def CompareNumberOfSegments(self, hyp, args):
4380 if hyp.GetNumberOfSegments() == args[0]:
4382 if hyp.GetReversedEdges() == args[1]:
4383 if not args[1] or hyp.GetObjectEntry() == args[2]:
4386 if hyp.GetReversedEdges() == args[2]:
4387 if not args[2] or hyp.GetObjectEntry() == args[3]:
4388 if hyp.GetDistrType() == 1:
4389 if IsEqual(hyp.GetScaleFactor(), args[1]):
4393 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4394 # @param start defines the length of the first segment
4395 # @param end defines the length of the last segment
4396 # @param reversedEdges is a list of edges to mesh using reversed orientation
4397 # @param UseExisting if ==true - searches for an existing hypothesis created with
4398 # the same parameters, else (default) - creates a new one
4399 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4400 # @ingroup l3_hypos_1dhyps
4401 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4402 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4403 reversedEdges, UseExisting = [], reversedEdges
4404 entry = self.MainShapeEntry()
4405 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4406 UseExisting=UseExisting,
4407 CompareMethod=self.CompareArithmetic1D)
4408 hyp.SetStartLength(start)
4409 hyp.SetEndLength(end)
4410 hyp.SetReversedEdges( reversedEdges )
4411 hyp.SetObjectEntry( entry )
4415 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4416 def CompareArithmetic1D(self, hyp, args):
4417 if IsEqual(hyp.GetLength(1), args[0]):
4418 if IsEqual(hyp.GetLength(0), args[1]):
4419 if hyp.GetReversedEdges() == args[2]:
4420 if not args[2] or hyp.GetObjectEntry() == args[3]:
4425 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4426 # on curve from 0 to 1 (additionally it is neecessary to check
4427 # orientation of edges and create list of reversed edges if it is
4428 # needed) and sets numbers of segments between given points (default
4429 # values are equals 1
4430 # @param points defines the list of parameters on curve
4431 # @param nbSegs defines the list of numbers of segments
4432 # @param reversedEdges is a list of edges to mesh using reversed orientation
4433 # @param UseExisting if ==true - searches for an existing hypothesis created with
4434 # the same parameters, else (default) - creates a new one
4435 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4436 # @ingroup l3_hypos_1dhyps
4437 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4438 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4439 reversedEdges, UseExisting = [], reversedEdges
4440 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4441 for i in range( len( reversedEdges )):
4442 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4443 entry = self.MainShapeEntry()
4444 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4445 UseExisting=UseExisting,
4446 CompareMethod=self.CompareFixedPoints1D)
4447 hyp.SetPoints(points)
4448 hyp.SetNbSegments(nbSegs)
4449 hyp.SetReversedEdges(reversedEdges)
4450 hyp.SetObjectEntry(entry)
4454 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4455 ## as the given arguments
4456 def CompareFixedPoints1D(self, hyp, args):
4457 if hyp.GetPoints() == args[0]:
4458 if hyp.GetNbSegments() == args[1]:
4459 if hyp.GetReversedEdges() == args[2]:
4460 if not args[2] or hyp.GetObjectEntry() == args[3]:
4466 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4467 # @param start defines the length of the first segment
4468 # @param end defines the length of the last segment
4469 # @param reversedEdges is a list of edges to mesh using reversed orientation
4470 # @param UseExisting if ==true - searches for an existing hypothesis created with
4471 # the same parameters, else (default) - creates a new one
4472 # @return an instance of StdMeshers_StartEndLength hypothesis
4473 # @ingroup l3_hypos_1dhyps
4474 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4475 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4476 reversedEdges, UseExisting = [], reversedEdges
4477 entry = self.MainShapeEntry()
4478 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4479 UseExisting=UseExisting,
4480 CompareMethod=self.CompareStartEndLength)
4481 hyp.SetStartLength(start)
4482 hyp.SetEndLength(end)
4483 hyp.SetReversedEdges( reversedEdges )
4484 hyp.SetObjectEntry( entry )
4487 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4488 def CompareStartEndLength(self, hyp, args):
4489 if IsEqual(hyp.GetLength(1), args[0]):
4490 if IsEqual(hyp.GetLength(0), args[1]):
4491 if hyp.GetReversedEdges() == args[2]:
4492 if not args[2] or hyp.GetObjectEntry() == args[3]:
4496 ## Defines "Deflection1D" hypothesis
4497 # @param d for the deflection
4498 # @param UseExisting if ==true - searches for an existing hypothesis created with
4499 # the same parameters, else (default) - create a new one
4500 # @ingroup l3_hypos_1dhyps
4501 def Deflection1D(self, d, UseExisting=0):
4502 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4503 CompareMethod=self.CompareDeflection1D)
4504 hyp.SetDeflection(d)
4507 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4508 def CompareDeflection1D(self, hyp, args):
4509 return IsEqual(hyp.GetDeflection(), args[0])
4511 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4512 # the opposite side in case of quadrangular faces
4513 # @ingroup l3_hypos_additi
4514 def Propagation(self):
4515 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4517 ## Defines "AutomaticLength" hypothesis
4518 # @param fineness for the fineness [0-1]
4519 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4520 # same parameters, else (default) - create a new one
4521 # @ingroup l3_hypos_1dhyps
4522 def AutomaticLength(self, fineness=0, UseExisting=0):
4523 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4524 CompareMethod=self.CompareAutomaticLength)
4525 hyp.SetFineness( fineness )
4528 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4529 def CompareAutomaticLength(self, hyp, args):
4530 return IsEqual(hyp.GetFineness(), args[0])
4532 ## Defines "SegmentLengthAroundVertex" hypothesis
4533 # @param length for the segment length
4534 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4535 # Any other integer value means that the hypothesis will be set on the
4536 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4537 # @param UseExisting if ==true - searches for an existing hypothesis created with
4538 # the same parameters, else (default) - creates a new one
4539 # @ingroup l3_algos_segmarv
4540 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4542 store_geom = self.geom
4543 if type(vertex) is types.IntType:
4544 if vertex == 0 or vertex == 1:
4545 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4553 if self.geom is None:
4554 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4556 name = GetName(self.geom)
4559 piece = self.mesh.geom
4560 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4561 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4563 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4565 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4567 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4568 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4570 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4571 CompareMethod=self.CompareLengthNearVertex)
4572 self.geom = store_geom
4573 hyp.SetLength( length )
4576 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4577 # @ingroup l3_algos_segmarv
4578 def CompareLengthNearVertex(self, hyp, args):
4579 return IsEqual(hyp.GetLength(), args[0])
4581 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4582 # If the 2D mesher sees that all boundary edges are quadratic,
4583 # it generates quadratic faces, else it generates linear faces using
4584 # medium nodes as if they are vertices.
4585 # The 3D mesher generates quadratic volumes only if all boundary faces
4586 # are quadratic, else it fails.
4588 # @ingroup l3_hypos_additi
4589 def QuadraticMesh(self):
4590 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4593 # Public class: Mesh_CompositeSegment
4594 # --------------------------
4596 ## Defines a segment 1D algorithm for discretization
4598 # @ingroup l3_algos_basic
4599 class Mesh_CompositeSegment(Mesh_Segment):
4601 ## Private constructor.
4602 def __init__(self, mesh, geom=0):
4603 self.Create(mesh, geom, "CompositeSegment_1D")
4606 # Public class: Mesh_Segment_Python
4607 # ---------------------------------
4609 ## Defines a segment 1D algorithm for discretization with python function
4611 # @ingroup l3_algos_basic
4612 class Mesh_Segment_Python(Mesh_Segment):
4614 ## Private constructor.
4615 def __init__(self, mesh, geom=0):
4616 import Python1dPlugin
4617 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4619 ## Defines "PythonSplit1D" hypothesis
4620 # @param n for the number of segments that cut an edge
4621 # @param func for the python function that calculates the length of all segments
4622 # @param UseExisting if ==true - searches for the existing hypothesis created with
4623 # the same parameters, else (default) - creates a new one
4624 # @ingroup l3_hypos_1dhyps
4625 def PythonSplit1D(self, n, func, UseExisting=0):
4626 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4627 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4628 hyp.SetNumberOfSegments(n)
4629 hyp.SetPythonLog10RatioFunction(func)
4632 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4633 def ComparePythonSplit1D(self, hyp, args):
4634 #if hyp.GetNumberOfSegments() == args[0]:
4635 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4639 # Public class: Mesh_Triangle
4640 # ---------------------------
4642 ## Defines a triangle 2D algorithm
4644 # @ingroup l3_algos_basic
4645 class Mesh_Triangle(Mesh_Algorithm):
4654 ## Private constructor.
4655 def __init__(self, mesh, algoType, geom=0):
4656 Mesh_Algorithm.__init__(self)
4658 self.algoType = algoType
4659 if algoType == MEFISTO:
4660 self.Create(mesh, geom, "MEFISTO_2D")
4662 elif algoType == BLSURF:
4664 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4665 #self.SetPhysicalMesh() - PAL19680
4666 elif algoType == NETGEN:
4668 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4670 elif algoType == NETGEN_2D:
4672 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4675 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4676 # @param area for the maximum area of each triangle
4677 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4678 # same parameters, else (default) - creates a new one
4680 # Only for algoType == MEFISTO || NETGEN_2D
4681 # @ingroup l3_hypos_2dhyps
4682 def MaxElementArea(self, area, UseExisting=0):
4683 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4684 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4685 CompareMethod=self.CompareMaxElementArea)
4686 elif self.algoType == NETGEN:
4687 hyp = self.Parameters(SIMPLE)
4688 hyp.SetMaxElementArea(area)
4691 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4692 def CompareMaxElementArea(self, hyp, args):
4693 return IsEqual(hyp.GetMaxElementArea(), args[0])
4695 ## Defines "LengthFromEdges" hypothesis to build triangles
4696 # based on the length of the edges taken from the wire
4698 # Only for algoType == MEFISTO || NETGEN_2D
4699 # @ingroup l3_hypos_2dhyps
4700 def LengthFromEdges(self):
4701 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4702 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4704 elif self.algoType == NETGEN:
4705 hyp = self.Parameters(SIMPLE)
4706 hyp.LengthFromEdges()
4709 ## Sets a way to define size of mesh elements to generate.
4710 # @param thePhysicalMesh is: DefaultSize or Custom.
4711 # @ingroup l3_hypos_blsurf
4712 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4713 # Parameter of BLSURF algo
4714 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4716 ## Sets size of mesh elements to generate.
4717 # @ingroup l3_hypos_blsurf
4718 def SetPhySize(self, theVal):
4719 # Parameter of BLSURF algo
4720 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4721 self.Parameters().SetPhySize(theVal)
4723 ## Sets lower boundary of mesh element size (PhySize).
4724 # @ingroup l3_hypos_blsurf
4725 def SetPhyMin(self, theVal=-1):
4726 # Parameter of BLSURF algo
4727 self.Parameters().SetPhyMin(theVal)
4729 ## Sets upper boundary of mesh element size (PhySize).
4730 # @ingroup l3_hypos_blsurf
4731 def SetPhyMax(self, theVal=-1):
4732 # Parameter of BLSURF algo
4733 self.Parameters().SetPhyMax(theVal)
4735 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4736 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4737 # @ingroup l3_hypos_blsurf
4738 def SetGeometricMesh(self, theGeometricMesh=0):
4739 # Parameter of BLSURF algo
4740 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4741 self.params.SetGeometricMesh(theGeometricMesh)
4743 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4744 # @ingroup l3_hypos_blsurf
4745 def SetAngleMeshS(self, theVal=_angleMeshS):
4746 # Parameter of BLSURF algo
4747 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4748 self.params.SetAngleMeshS(theVal)
4750 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4751 # @ingroup l3_hypos_blsurf
4752 def SetAngleMeshC(self, theVal=_angleMeshS):
4753 # Parameter of BLSURF algo
4754 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4755 self.params.SetAngleMeshC(theVal)
4757 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4758 # @ingroup l3_hypos_blsurf
4759 def SetGeoMin(self, theVal=-1):
4760 # Parameter of BLSURF algo
4761 self.Parameters().SetGeoMin(theVal)
4763 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4764 # @ingroup l3_hypos_blsurf
4765 def SetGeoMax(self, theVal=-1):
4766 # Parameter of BLSURF algo
4767 self.Parameters().SetGeoMax(theVal)
4769 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4770 # @ingroup l3_hypos_blsurf
4771 def SetGradation(self, theVal=_gradation):
4772 # Parameter of BLSURF algo
4773 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4774 self.params.SetGradation(theVal)
4776 ## Sets topology usage way.
4777 # @param way defines how mesh conformity is assured <ul>
4778 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4779 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4780 # @ingroup l3_hypos_blsurf
4781 def SetTopology(self, way):
4782 # Parameter of BLSURF algo
4783 self.Parameters().SetTopology(way)
4785 ## To respect geometrical edges or not.
4786 # @ingroup l3_hypos_blsurf
4787 def SetDecimesh(self, toIgnoreEdges=False):
4788 # Parameter of BLSURF algo
4789 self.Parameters().SetDecimesh(toIgnoreEdges)
4791 ## Sets verbosity level in the range 0 to 100.
4792 # @ingroup l3_hypos_blsurf
4793 def SetVerbosity(self, level):
4794 # Parameter of BLSURF algo
4795 self.Parameters().SetVerbosity(level)
4797 ## Sets advanced option value.
4798 # @ingroup l3_hypos_blsurf
4799 def SetOptionValue(self, optionName, level):
4800 # Parameter of BLSURF algo
4801 self.Parameters().SetOptionValue(optionName,level)
4803 ## Sets QuadAllowed flag.
4804 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4805 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4806 def SetQuadAllowed(self, toAllow=True):
4807 if self.algoType == NETGEN_2D:
4808 if toAllow: # add QuadranglePreference
4809 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4810 else: # remove QuadranglePreference
4811 for hyp in self.mesh.GetHypothesisList( self.geom ):
4812 if hyp.GetName() == "QuadranglePreference":
4813 self.mesh.RemoveHypothesis( self.geom, hyp )
4818 if self.Parameters():
4819 self.params.SetQuadAllowed(toAllow)
4822 ## Defines hypothesis having several parameters
4824 # @ingroup l3_hypos_netgen
4825 def Parameters(self, which=SOLE):
4828 if self.algoType == NETGEN:
4830 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4831 "libNETGENEngine.so", UseExisting=0)
4833 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4834 "libNETGENEngine.so", UseExisting=0)
4836 elif self.algoType == MEFISTO:
4837 print "Mefisto algo support no multi-parameter hypothesis"
4839 elif self.algoType == NETGEN_2D:
4840 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4841 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4843 elif self.algoType == BLSURF:
4844 self.params = self.Hypothesis("BLSURF_Parameters", [],
4845 "libBLSURFEngine.so", UseExisting=0)
4848 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4853 # Only for algoType == NETGEN
4854 # @ingroup l3_hypos_netgen
4855 def SetMaxSize(self, theSize):
4856 if self.Parameters():
4857 self.params.SetMaxSize(theSize)
4859 ## Sets SecondOrder flag
4861 # Only for algoType == NETGEN
4862 # @ingroup l3_hypos_netgen
4863 def SetSecondOrder(self, theVal):
4864 if self.Parameters():
4865 self.params.SetSecondOrder(theVal)
4867 ## Sets Optimize flag
4869 # Only for algoType == NETGEN
4870 # @ingroup l3_hypos_netgen
4871 def SetOptimize(self, theVal):
4872 if self.Parameters():
4873 self.params.SetOptimize(theVal)
4876 # @param theFineness is:
4877 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4879 # Only for algoType == NETGEN
4880 # @ingroup l3_hypos_netgen
4881 def SetFineness(self, theFineness):
4882 if self.Parameters():
4883 self.params.SetFineness(theFineness)
4887 # Only for algoType == NETGEN
4888 # @ingroup l3_hypos_netgen
4889 def SetGrowthRate(self, theRate):
4890 if self.Parameters():
4891 self.params.SetGrowthRate(theRate)
4893 ## Sets NbSegPerEdge
4895 # Only for algoType == NETGEN
4896 # @ingroup l3_hypos_netgen
4897 def SetNbSegPerEdge(self, theVal):
4898 if self.Parameters():
4899 self.params.SetNbSegPerEdge(theVal)
4901 ## Sets NbSegPerRadius
4903 # Only for algoType == NETGEN
4904 # @ingroup l3_hypos_netgen
4905 def SetNbSegPerRadius(self, theVal):
4906 if self.Parameters():
4907 self.params.SetNbSegPerRadius(theVal)
4909 ## Sets number of segments overriding value set by SetLocalLength()
4911 # Only for algoType == NETGEN
4912 # @ingroup l3_hypos_netgen
4913 def SetNumberOfSegments(self, theVal):
4914 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4916 ## Sets number of segments overriding value set by SetNumberOfSegments()
4918 # Only for algoType == NETGEN
4919 # @ingroup l3_hypos_netgen
4920 def SetLocalLength(self, theVal):
4921 self.Parameters(SIMPLE).SetLocalLength(theVal)
4926 # Public class: Mesh_Quadrangle
4927 # -----------------------------
4929 ## Defines a quadrangle 2D algorithm
4931 # @ingroup l3_algos_basic
4932 class Mesh_Quadrangle(Mesh_Algorithm):
4934 ## Private constructor.
4935 def __init__(self, mesh, geom=0):
4936 Mesh_Algorithm.__init__(self)
4937 self.Create(mesh, geom, "Quadrangle_2D")
4939 ## Defines "QuadranglePreference" hypothesis, forcing construction
4940 # of quadrangles if the number of nodes on the opposite edges is not the same
4941 # while the total number of nodes on edges is even
4943 # @ingroup l3_hypos_additi
4944 def QuadranglePreference(self):
4945 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4946 CompareMethod=self.CompareEqualHyp)
4949 ## Defines "TrianglePreference" hypothesis, forcing construction
4950 # of triangles in the refinement area if the number of nodes
4951 # on the opposite edges is not the same
4953 # @ingroup l3_hypos_additi
4954 def TrianglePreference(self):
4955 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4956 CompareMethod=self.CompareEqualHyp)
4959 ## Defines "QuadrangleParams" hypothesis
4960 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4961 # will be created while other elements will be quadrangles.
4962 # Vertex can be either a GEOM_Object or a vertex ID within the
4964 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4965 # the same parameters, else (default) - creates a new one
4967 # @ingroup l3_hypos_additi
4968 def TriangleVertex(self, vertex, UseExisting=0):
4970 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4971 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4972 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4973 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4974 hyp.SetTriaVertex( vertexID )
4978 # Public class: Mesh_Tetrahedron
4979 # ------------------------------
4981 ## Defines a tetrahedron 3D algorithm
4983 # @ingroup l3_algos_basic
4984 class Mesh_Tetrahedron(Mesh_Algorithm):
4989 ## Private constructor.
4990 def __init__(self, mesh, algoType, geom=0):
4991 Mesh_Algorithm.__init__(self)
4993 if algoType == NETGEN:
4995 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4998 elif algoType == FULL_NETGEN:
5000 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5003 elif algoType == GHS3D:
5005 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5008 elif algoType == GHS3DPRL:
5009 CheckPlugin(GHS3DPRL)
5010 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5013 self.algoType = algoType
5015 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5016 # @param vol for the maximum volume of each tetrahedron
5017 # @param UseExisting if ==true - searches for the existing hypothesis created with
5018 # the same parameters, else (default) - creates a new one
5019 # @ingroup l3_hypos_maxvol
5020 def MaxElementVolume(self, vol, UseExisting=0):
5021 if self.algoType == NETGEN:
5022 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5023 CompareMethod=self.CompareMaxElementVolume)
5024 hyp.SetMaxElementVolume(vol)
5026 elif self.algoType == FULL_NETGEN:
5027 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5030 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5031 def CompareMaxElementVolume(self, hyp, args):
5032 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5034 ## Defines hypothesis having several parameters
5036 # @ingroup l3_hypos_netgen
5037 def Parameters(self, which=SOLE):
5041 if self.algoType == FULL_NETGEN:
5043 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5044 "libNETGENEngine.so", UseExisting=0)
5046 self.params = self.Hypothesis("NETGEN_Parameters", [],
5047 "libNETGENEngine.so", UseExisting=0)
5050 if self.algoType == GHS3D:
5051 self.params = self.Hypothesis("GHS3D_Parameters", [],
5052 "libGHS3DEngine.so", UseExisting=0)
5055 if self.algoType == GHS3DPRL:
5056 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5057 "libGHS3DPRLEngine.so", UseExisting=0)
5060 print "Algo supports no multi-parameter hypothesis"
5064 # Parameter of FULL_NETGEN
5065 # @ingroup l3_hypos_netgen
5066 def SetMaxSize(self, theSize):
5067 self.Parameters().SetMaxSize(theSize)
5069 ## Sets SecondOrder flag
5070 # Parameter of FULL_NETGEN
5071 # @ingroup l3_hypos_netgen
5072 def SetSecondOrder(self, theVal):
5073 self.Parameters().SetSecondOrder(theVal)
5075 ## Sets Optimize flag
5076 # Parameter of FULL_NETGEN
5077 # @ingroup l3_hypos_netgen
5078 def SetOptimize(self, theVal):
5079 self.Parameters().SetOptimize(theVal)
5082 # @param theFineness is:
5083 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5084 # Parameter of FULL_NETGEN
5085 # @ingroup l3_hypos_netgen
5086 def SetFineness(self, theFineness):
5087 self.Parameters().SetFineness(theFineness)
5090 # Parameter of FULL_NETGEN
5091 # @ingroup l3_hypos_netgen
5092 def SetGrowthRate(self, theRate):
5093 self.Parameters().SetGrowthRate(theRate)
5095 ## Sets NbSegPerEdge
5096 # Parameter of FULL_NETGEN
5097 # @ingroup l3_hypos_netgen
5098 def SetNbSegPerEdge(self, theVal):
5099 self.Parameters().SetNbSegPerEdge(theVal)
5101 ## Sets NbSegPerRadius
5102 # Parameter of FULL_NETGEN
5103 # @ingroup l3_hypos_netgen
5104 def SetNbSegPerRadius(self, theVal):
5105 self.Parameters().SetNbSegPerRadius(theVal)
5107 ## Sets number of segments overriding value set by SetLocalLength()
5108 # Only for algoType == NETGEN_FULL
5109 # @ingroup l3_hypos_netgen
5110 def SetNumberOfSegments(self, theVal):
5111 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5113 ## Sets number of segments overriding value set by SetNumberOfSegments()
5114 # Only for algoType == NETGEN_FULL
5115 # @ingroup l3_hypos_netgen
5116 def SetLocalLength(self, theVal):
5117 self.Parameters(SIMPLE).SetLocalLength(theVal)
5119 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5120 # Overrides value set by LengthFromEdges()
5121 # Only for algoType == NETGEN_FULL
5122 # @ingroup l3_hypos_netgen
5123 def MaxElementArea(self, area):
5124 self.Parameters(SIMPLE).SetMaxElementArea(area)
5126 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5127 # Overrides value set by MaxElementArea()
5128 # Only for algoType == NETGEN_FULL
5129 # @ingroup l3_hypos_netgen
5130 def LengthFromEdges(self):
5131 self.Parameters(SIMPLE).LengthFromEdges()
5133 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5134 # Overrides value set by MaxElementVolume()
5135 # Only for algoType == NETGEN_FULL
5136 # @ingroup l3_hypos_netgen
5137 def LengthFromFaces(self):
5138 self.Parameters(SIMPLE).LengthFromFaces()
5140 ## To mesh "holes" in a solid or not. Default is to mesh.
5141 # @ingroup l3_hypos_ghs3dh
5142 def SetToMeshHoles(self, toMesh):
5143 # Parameter of GHS3D
5144 self.Parameters().SetToMeshHoles(toMesh)
5146 ## Set Optimization level:
5147 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5148 # Strong_Optimization.
5149 # Default is Standard_Optimization
5150 # @ingroup l3_hypos_ghs3dh
5151 def SetOptimizationLevel(self, level):
5152 # Parameter of GHS3D
5153 self.Parameters().SetOptimizationLevel(level)
5155 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5156 # @ingroup l3_hypos_ghs3dh
5157 def SetMaximumMemory(self, MB):
5158 # Advanced parameter of GHS3D
5159 self.Parameters().SetMaximumMemory(MB)
5161 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5162 # automatic memory adjustment mode.
5163 # @ingroup l3_hypos_ghs3dh
5164 def SetInitialMemory(self, MB):
5165 # Advanced parameter of GHS3D
5166 self.Parameters().SetInitialMemory(MB)
5168 ## Path to working directory.
5169 # @ingroup l3_hypos_ghs3dh
5170 def SetWorkingDirectory(self, path):
5171 # Advanced parameter of GHS3D
5172 self.Parameters().SetWorkingDirectory(path)
5174 ## To keep working files or remove them. Log file remains in case of errors anyway.
5175 # @ingroup l3_hypos_ghs3dh
5176 def SetKeepFiles(self, toKeep):
5177 # Advanced parameter of GHS3D and GHS3DPRL
5178 self.Parameters().SetKeepFiles(toKeep)
5180 ## To set verbose level [0-10]. <ul>
5181 #<li> 0 - no standard output,
5182 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5183 # indicates when the final mesh is being saved. In addition the software
5184 # gives indication regarding the CPU time.
5185 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5186 # histogram of the skin mesh, quality statistics histogram together with
5187 # the characteristics of the final mesh.</ul>
5188 # @ingroup l3_hypos_ghs3dh
5189 def SetVerboseLevel(self, level):
5190 # Advanced parameter of GHS3D
5191 self.Parameters().SetVerboseLevel(level)
5193 ## To create new nodes.
5194 # @ingroup l3_hypos_ghs3dh
5195 def SetToCreateNewNodes(self, toCreate):
5196 # Advanced parameter of GHS3D
5197 self.Parameters().SetToCreateNewNodes(toCreate)
5199 ## To use boundary recovery version which tries to create mesh on a very poor
5200 # quality surface mesh.
5201 # @ingroup l3_hypos_ghs3dh
5202 def SetToUseBoundaryRecoveryVersion(self, toUse):
5203 # Advanced parameter of GHS3D
5204 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5206 ## Sets command line option as text.
5207 # @ingroup l3_hypos_ghs3dh
5208 def SetTextOption(self, option):
5209 # Advanced parameter of GHS3D
5210 self.Parameters().SetTextOption(option)
5212 ## Sets MED files name and path.
5213 def SetMEDName(self, value):
5214 self.Parameters().SetMEDName(value)
5216 ## Sets the number of partition of the initial mesh
5217 def SetNbPart(self, value):
5218 self.Parameters().SetNbPart(value)
5220 ## When big mesh, start tepal in background
5221 def SetBackground(self, value):
5222 self.Parameters().SetBackground(value)
5224 # Public class: Mesh_Hexahedron
5225 # ------------------------------
5227 ## Defines a hexahedron 3D algorithm
5229 # @ingroup l3_algos_basic
5230 class Mesh_Hexahedron(Mesh_Algorithm):
5235 ## Private constructor.
5236 def __init__(self, mesh, algoType=Hexa, geom=0):
5237 Mesh_Algorithm.__init__(self)
5239 self.algoType = algoType
5241 if algoType == Hexa:
5242 self.Create(mesh, geom, "Hexa_3D")
5245 elif algoType == Hexotic:
5246 CheckPlugin(Hexotic)
5247 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5250 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5251 # @ingroup l3_hypos_hexotic
5252 def MinMaxQuad(self, min=3, max=8, quad=True):
5253 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5255 self.params.SetHexesMinLevel(min)
5256 self.params.SetHexesMaxLevel(max)
5257 self.params.SetHexoticQuadrangles(quad)
5260 # Deprecated, only for compatibility!
5261 # Public class: Mesh_Netgen
5262 # ------------------------------
5264 ## Defines a NETGEN-based 2D or 3D algorithm
5265 # that needs no discrete boundary (i.e. independent)
5267 # This class is deprecated, only for compatibility!
5270 # @ingroup l3_algos_basic
5271 class Mesh_Netgen(Mesh_Algorithm):
5275 ## Private constructor.
5276 def __init__(self, mesh, is3D, geom=0):
5277 Mesh_Algorithm.__init__(self)
5283 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5287 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5290 ## Defines the hypothesis containing parameters of the algorithm
5291 def Parameters(self):
5293 hyp = self.Hypothesis("NETGEN_Parameters", [],
5294 "libNETGENEngine.so", UseExisting=0)
5296 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5297 "libNETGENEngine.so", UseExisting=0)
5300 # Public class: Mesh_Projection1D
5301 # ------------------------------
5303 ## Defines a projection 1D algorithm
5304 # @ingroup l3_algos_proj
5306 class Mesh_Projection1D(Mesh_Algorithm):
5308 ## Private constructor.
5309 def __init__(self, mesh, geom=0):
5310 Mesh_Algorithm.__init__(self)
5311 self.Create(mesh, geom, "Projection_1D")
5313 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5314 # a mesh pattern is taken, and, optionally, the association of vertices
5315 # between the source edge and a target edge (to which a hypothesis is assigned)
5316 # @param edge from which nodes distribution is taken
5317 # @param mesh from which nodes distribution is taken (optional)
5318 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5319 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5320 # to associate with \a srcV (optional)
5321 # @param UseExisting if ==true - searches for the existing hypothesis created with
5322 # the same parameters, else (default) - creates a new one
5323 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5324 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5326 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5327 hyp.SetSourceEdge( edge )
5328 if not mesh is None and isinstance(mesh, Mesh):
5329 mesh = mesh.GetMesh()
5330 hyp.SetSourceMesh( mesh )
5331 hyp.SetVertexAssociation( srcV, tgtV )
5334 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5335 #def CompareSourceEdge(self, hyp, args):
5336 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5340 # Public class: Mesh_Projection2D
5341 # ------------------------------
5343 ## Defines a projection 2D algorithm
5344 # @ingroup l3_algos_proj
5346 class Mesh_Projection2D(Mesh_Algorithm):
5348 ## Private constructor.
5349 def __init__(self, mesh, geom=0):
5350 Mesh_Algorithm.__init__(self)
5351 self.Create(mesh, geom, "Projection_2D")
5353 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5354 # a mesh pattern is taken, and, optionally, the association of vertices
5355 # between the source face and the target face (to which a hypothesis is assigned)
5356 # @param face from which the mesh pattern is taken
5357 # @param mesh from which the mesh pattern is taken (optional)
5358 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5359 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5360 # to associate with \a srcV1 (optional)
5361 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5362 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5363 # to associate with \a srcV2 (optional)
5364 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5365 # the same parameters, else (default) - forces the creation a new one
5367 # Note: all association vertices must belong to one edge of a face
5368 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5369 srcV2=None, tgtV2=None, UseExisting=0):
5370 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5372 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5373 hyp.SetSourceFace( face )
5374 if not mesh is None and isinstance(mesh, Mesh):
5375 mesh = mesh.GetMesh()
5376 hyp.SetSourceMesh( mesh )
5377 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5380 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5381 #def CompareSourceFace(self, hyp, args):
5382 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5385 # Public class: Mesh_Projection3D
5386 # ------------------------------
5388 ## Defines a projection 3D algorithm
5389 # @ingroup l3_algos_proj
5391 class Mesh_Projection3D(Mesh_Algorithm):
5393 ## Private constructor.
5394 def __init__(self, mesh, geom=0):
5395 Mesh_Algorithm.__init__(self)
5396 self.Create(mesh, geom, "Projection_3D")
5398 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5399 # the mesh pattern is taken, and, optionally, the association of vertices
5400 # between the source and the target solid (to which a hipothesis is assigned)
5401 # @param solid from where the mesh pattern is taken
5402 # @param mesh from where the mesh pattern is taken (optional)
5403 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5404 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5405 # to associate with \a srcV1 (optional)
5406 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5407 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5408 # to associate with \a srcV2 (optional)
5409 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5410 # the same parameters, else (default) - creates a new one
5412 # Note: association vertices must belong to one edge of a solid
5413 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5414 srcV2=0, tgtV2=0, UseExisting=0):
5415 hyp = self.Hypothesis("ProjectionSource3D",
5416 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5418 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5419 hyp.SetSource3DShape( solid )
5420 if not mesh is None and isinstance(mesh, Mesh):
5421 mesh = mesh.GetMesh()
5422 hyp.SetSourceMesh( mesh )
5423 if srcV1 and srcV2 and tgtV1 and tgtV2:
5424 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5425 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5428 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5429 #def CompareSourceShape3D(self, hyp, args):
5430 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5434 # Public class: Mesh_Prism
5435 # ------------------------
5437 ## Defines a 3D extrusion algorithm
5438 # @ingroup l3_algos_3dextr
5440 class Mesh_Prism3D(Mesh_Algorithm):
5442 ## Private constructor.
5443 def __init__(self, mesh, geom=0):
5444 Mesh_Algorithm.__init__(self)
5445 self.Create(mesh, geom, "Prism_3D")
5447 # Public class: Mesh_RadialPrism
5448 # -------------------------------
5450 ## Defines a Radial Prism 3D algorithm
5451 # @ingroup l3_algos_radialp
5453 class Mesh_RadialPrism3D(Mesh_Algorithm):
5455 ## Private constructor.
5456 def __init__(self, mesh, geom=0):
5457 Mesh_Algorithm.__init__(self)
5458 self.Create(mesh, geom, "RadialPrism_3D")
5460 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5461 self.nbLayers = None
5463 ## Return 3D hypothesis holding the 1D one
5464 def Get3DHypothesis(self):
5465 return self.distribHyp
5467 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5468 # hypothesis. Returns the created hypothesis
5469 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5470 #print "OwnHypothesis",hypType
5471 if not self.nbLayers is None:
5472 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5473 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5474 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5475 self.mesh.smeshpyD.SetCurrentStudy( None )
5476 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5477 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5478 self.distribHyp.SetLayerDistribution( hyp )
5481 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5482 # prisms to build between the inner and outer shells
5483 # @param n number of layers
5484 # @param UseExisting if ==true - searches for the existing hypothesis created with
5485 # the same parameters, else (default) - creates a new one
5486 def NumberOfLayers(self, n, UseExisting=0):
5487 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5488 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5489 CompareMethod=self.CompareNumberOfLayers)
5490 self.nbLayers.SetNumberOfLayers( n )
5491 return self.nbLayers
5493 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5494 def CompareNumberOfLayers(self, hyp, args):
5495 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5497 ## Defines "LocalLength" hypothesis, specifying the segment length
5498 # to build between the inner and the outer shells
5499 # @param l the length of segments
5500 # @param p the precision of rounding
5501 def LocalLength(self, l, p=1e-07):
5502 hyp = self.OwnHypothesis("LocalLength", [l,p])
5507 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5508 # prisms to build between the inner and the outer shells.
5509 # @param n the number of layers
5510 # @param s the scale factor (optional)
5511 def NumberOfSegments(self, n, s=[]):
5513 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5515 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5516 hyp.SetDistrType( 1 )
5517 hyp.SetScaleFactor(s)
5518 hyp.SetNumberOfSegments(n)
5521 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5522 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5523 # @param start the length of the first segment
5524 # @param end the length of the last segment
5525 def Arithmetic1D(self, start, end ):
5526 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5527 hyp.SetLength(start, 1)
5528 hyp.SetLength(end , 0)
5531 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5532 # to build between the inner and the outer shells as geometric length increasing
5533 # @param start for the length of the first segment
5534 # @param end for the length of the last segment
5535 def StartEndLength(self, start, end):
5536 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5537 hyp.SetLength(start, 1)
5538 hyp.SetLength(end , 0)
5541 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5542 # to build between the inner and outer shells
5543 # @param fineness defines the quality of the mesh within the range [0-1]
5544 def AutomaticLength(self, fineness=0):
5545 hyp = self.OwnHypothesis("AutomaticLength")
5546 hyp.SetFineness( fineness )
5549 # Public class: Mesh_RadialQuadrangle1D2D
5550 # -------------------------------
5552 ## Defines a Radial Quadrangle 1D2D algorithm
5553 # @ingroup l2_algos_radialq
5555 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5557 ## Private constructor.
5558 def __init__(self, mesh, geom=0):
5559 Mesh_Algorithm.__init__(self)
5560 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5562 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5563 self.nbLayers = None
5565 ## Return 2D hypothesis holding the 1D one
5566 def Get2DHypothesis(self):
5567 return self.distribHyp
5569 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5570 # hypothesis. Returns the created hypothesis
5571 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5572 #print "OwnHypothesis",hypType
5574 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5575 if self.distribHyp is None:
5576 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5578 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5579 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5580 self.mesh.smeshpyD.SetCurrentStudy( None )
5581 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5582 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5583 self.distribHyp.SetLayerDistribution( hyp )
5586 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5587 # @param n number of layers
5588 # @param UseExisting if ==true - searches for the existing hypothesis created with
5589 # the same parameters, else (default) - creates a new one
5590 def NumberOfLayers(self, n, UseExisting=0):
5592 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5593 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5594 CompareMethod=self.CompareNumberOfLayers)
5595 self.nbLayers.SetNumberOfLayers( n )
5596 return self.nbLayers
5598 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5599 def CompareNumberOfLayers(self, hyp, args):
5600 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5602 ## Defines "LocalLength" hypothesis, specifying the segment length
5603 # @param l the length of segments
5604 # @param p the precision of rounding
5605 def LocalLength(self, l, p=1e-07):
5606 hyp = self.OwnHypothesis("LocalLength", [l,p])
5611 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5612 # @param n the number of layers
5613 # @param s the scale factor (optional)
5614 def NumberOfSegments(self, n, s=[]):
5616 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5618 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5619 hyp.SetDistrType( 1 )
5620 hyp.SetScaleFactor(s)
5621 hyp.SetNumberOfSegments(n)
5624 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5625 # with a length that changes in arithmetic progression
5626 # @param start the length of the first segment
5627 # @param end the length of the last segment
5628 def Arithmetic1D(self, start, end ):
5629 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5630 hyp.SetLength(start, 1)
5631 hyp.SetLength(end , 0)
5634 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5635 # as geometric length increasing
5636 # @param start for the length of the first segment
5637 # @param end for the length of the last segment
5638 def StartEndLength(self, start, end):
5639 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5640 hyp.SetLength(start, 1)
5641 hyp.SetLength(end , 0)
5644 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5645 # @param fineness defines the quality of the mesh within the range [0-1]
5646 def AutomaticLength(self, fineness=0):
5647 hyp = self.OwnHypothesis("AutomaticLength")
5648 hyp.SetFineness( fineness )
5652 # Private class: Mesh_UseExisting
5653 # -------------------------------
5654 class Mesh_UseExisting(Mesh_Algorithm):
5656 def __init__(self, dim, mesh, geom=0):
5658 self.Create(mesh, geom, "UseExisting_1D")
5660 self.Create(mesh, geom, "UseExisting_2D")
5663 import salome_notebook
5664 notebook = salome_notebook.notebook
5666 ##Return values of the notebook variables
5667 def ParseParameters(last, nbParams,nbParam, value):
5671 listSize = len(last)
5672 for n in range(0,nbParams):
5674 if counter < listSize:
5675 strResult = strResult + last[counter]
5677 strResult = strResult + ""
5679 if isinstance(value, str):
5680 if notebook.isVariable(value):
5681 result = notebook.get(value)
5682 strResult=strResult+value
5684 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5686 strResult=strResult+str(value)
5688 if nbParams - 1 != counter:
5689 strResult=strResult+var_separator #":"
5691 return result, strResult
5693 #Wrapper class for StdMeshers_LocalLength hypothesis
5694 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5696 ## Set Length parameter value
5697 # @param length numerical value or name of variable from notebook
5698 def SetLength(self, length):
5699 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5700 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5701 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5703 ## Set Precision parameter value
5704 # @param precision numerical value or name of variable from notebook
5705 def SetPrecision(self, precision):
5706 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5707 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5708 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5710 #Registering the new proxy for LocalLength
5711 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5714 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5715 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5717 def SetLayerDistribution(self, hypo):
5718 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5719 hypo.ClearParameters();
5720 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5722 #Registering the new proxy for LayerDistribution
5723 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5725 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5726 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5728 ## Set Length parameter value
5729 # @param length numerical value or name of variable from notebook
5730 def SetLength(self, length):
5731 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5732 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5733 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5735 #Registering the new proxy for SegmentLengthAroundVertex
5736 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5739 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5740 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5742 ## Set Length parameter value
5743 # @param length numerical value or name of variable from notebook
5744 # @param isStart true is length is Start Length, otherwise false
5745 def SetLength(self, length, isStart):
5749 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5750 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5751 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5753 #Registering the new proxy for Arithmetic1D
5754 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5756 #Wrapper class for StdMeshers_Deflection1D hypothesis
5757 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5759 ## Set Deflection parameter value
5760 # @param deflection numerical value or name of variable from notebook
5761 def SetDeflection(self, deflection):
5762 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5763 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5764 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5766 #Registering the new proxy for Deflection1D
5767 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5769 #Wrapper class for StdMeshers_StartEndLength hypothesis
5770 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5772 ## Set Length parameter value
5773 # @param length numerical value or name of variable from notebook
5774 # @param isStart true is length is Start Length, otherwise false
5775 def SetLength(self, length, isStart):
5779 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5780 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5781 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5783 #Registering the new proxy for StartEndLength
5784 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5786 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5787 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5789 ## Set Max Element Area parameter value
5790 # @param area numerical value or name of variable from notebook
5791 def SetMaxElementArea(self, area):
5792 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5793 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5794 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5796 #Registering the new proxy for MaxElementArea
5797 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5800 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5801 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5803 ## Set Max Element Volume parameter value
5804 # @param volume numerical value or name of variable from notebook
5805 def SetMaxElementVolume(self, volume):
5806 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5807 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5808 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5810 #Registering the new proxy for MaxElementVolume
5811 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5814 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5815 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5817 ## Set Number Of Layers parameter value
5818 # @param nbLayers numerical value or name of variable from notebook
5819 def SetNumberOfLayers(self, nbLayers):
5820 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5821 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5822 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5824 #Registering the new proxy for NumberOfLayers
5825 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5827 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5828 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5830 ## Set Number Of Segments parameter value
5831 # @param nbSeg numerical value or name of variable from notebook
5832 def SetNumberOfSegments(self, nbSeg):
5833 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5834 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5835 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5836 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5838 ## Set Scale Factor parameter value
5839 # @param factor numerical value or name of variable from notebook
5840 def SetScaleFactor(self, factor):
5841 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5842 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5843 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5845 #Registering the new proxy for NumberOfSegments
5846 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5848 if not noNETGENPlugin:
5849 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5850 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5852 ## Set Max Size parameter value
5853 # @param maxsize numerical value or name of variable from notebook
5854 def SetMaxSize(self, maxsize):
5855 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5856 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5857 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5858 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5860 ## Set Growth Rate parameter value
5861 # @param value numerical value or name of variable from notebook
5862 def SetGrowthRate(self, value):
5863 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5864 value, parameters = ParseParameters(lastParameters,4,2,value)
5865 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5866 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5868 ## Set Number of Segments per Edge parameter value
5869 # @param value numerical value or name of variable from notebook
5870 def SetNbSegPerEdge(self, value):
5871 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5872 value, parameters = ParseParameters(lastParameters,4,3,value)
5873 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5874 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5876 ## Set Number of Segments per Radius parameter value
5877 # @param value numerical value or name of variable from notebook
5878 def SetNbSegPerRadius(self, value):
5879 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5880 value, parameters = ParseParameters(lastParameters,4,4,value)
5881 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5882 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5884 #Registering the new proxy for NETGENPlugin_Hypothesis
5885 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5888 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5889 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5892 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5893 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5895 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5896 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5898 ## Set Number of Segments parameter value
5899 # @param nbSeg numerical value or name of variable from notebook
5900 def SetNumberOfSegments(self, nbSeg):
5901 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5902 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5903 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5904 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5906 ## Set Local Length parameter value
5907 # @param length numerical value or name of variable from notebook
5908 def SetLocalLength(self, length):
5909 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5910 length, parameters = ParseParameters(lastParameters,2,1,length)
5911 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5912 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5914 ## Set Max Element Area parameter value
5915 # @param area numerical value or name of variable from notebook
5916 def SetMaxElementArea(self, area):
5917 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5918 area, parameters = ParseParameters(lastParameters,2,2,area)
5919 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5920 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5922 def LengthFromEdges(self):
5923 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5925 value, parameters = ParseParameters(lastParameters,2,2,value)
5926 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5927 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5929 #Registering the new proxy for NETGEN_SimpleParameters_2D
5930 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5933 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5934 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5935 ## Set Max Element Volume parameter value
5936 # @param volume numerical value or name of variable from notebook
5937 def SetMaxElementVolume(self, volume):
5938 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5939 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5940 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5941 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5943 def LengthFromFaces(self):
5944 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5946 value, parameters = ParseParameters(lastParameters,3,3,value)
5947 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5948 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5950 #Registering the new proxy for NETGEN_SimpleParameters_3D
5951 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5953 pass # if not noNETGENPlugin:
5955 class Pattern(SMESH._objref_SMESH_Pattern):
5957 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5959 if isinstance(theNodeIndexOnKeyPoint1,str):
5961 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5963 theNodeIndexOnKeyPoint1 -= 1
5964 theMesh.SetParameters(Parameters)
5965 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5967 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5970 if isinstance(theNode000Index,str):
5972 if isinstance(theNode001Index,str):
5974 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5976 theNode000Index -= 1
5978 theNode001Index -= 1
5979 theMesh.SetParameters(Parameters)
5980 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5982 #Registering the new proxy for Pattern
5983 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)