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 FT_BareBorderFace, FT_BareBorderVolume]:
799 # At this point the treshold is unnecessary
800 if aTreshold == FT_LogicalNOT:
801 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
802 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
803 aCriterion.BinaryOp = aTreshold
807 aTreshold = float(aTreshold)
808 aCriterion.Threshold = aTreshold
810 print "Error: The treshold should be a number."
813 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
814 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
816 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
817 aCriterion.BinaryOp = self.EnumToLong(Treshold)
819 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
820 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
822 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
823 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
827 ## Creates a filter with the given parameters
828 # @param elementType the type of elements in the group
829 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
830 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
831 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
832 # @param UnaryOp FT_LogicalNOT or FT_Undefined
833 # @return SMESH_Filter
834 # @ingroup l1_controls
835 def GetFilter(self,elementType,
836 CritType=FT_Undefined,
839 UnaryOp=FT_Undefined):
840 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
841 aFilterMgr = self.CreateFilterManager()
842 aFilter = aFilterMgr.CreateFilter()
844 aCriteria.append(aCriterion)
845 aFilter.SetCriteria(aCriteria)
849 ## Creates a numerical functor by its type
850 # @param theCriterion FT_...; functor type
851 # @return SMESH_NumericalFunctor
852 # @ingroup l1_controls
853 def GetFunctor(self,theCriterion):
854 aFilterMgr = self.CreateFilterManager()
855 if theCriterion == FT_AspectRatio:
856 return aFilterMgr.CreateAspectRatio()
857 elif theCriterion == FT_AspectRatio3D:
858 return aFilterMgr.CreateAspectRatio3D()
859 elif theCriterion == FT_Warping:
860 return aFilterMgr.CreateWarping()
861 elif theCriterion == FT_MinimumAngle:
862 return aFilterMgr.CreateMinimumAngle()
863 elif theCriterion == FT_Taper:
864 return aFilterMgr.CreateTaper()
865 elif theCriterion == FT_Skew:
866 return aFilterMgr.CreateSkew()
867 elif theCriterion == FT_Area:
868 return aFilterMgr.CreateArea()
869 elif theCriterion == FT_Volume3D:
870 return aFilterMgr.CreateVolume3D()
871 elif theCriterion == FT_MaxElementLength2D:
872 return aFilterMgr.CreateMaxElementLength2D()
873 elif theCriterion == FT_MaxElementLength3D:
874 return aFilterMgr.CreateMaxElementLength3D()
875 elif theCriterion == FT_MultiConnection:
876 return aFilterMgr.CreateMultiConnection()
877 elif theCriterion == FT_MultiConnection2D:
878 return aFilterMgr.CreateMultiConnection2D()
879 elif theCriterion == FT_Length:
880 return aFilterMgr.CreateLength()
881 elif theCriterion == FT_Length2D:
882 return aFilterMgr.CreateLength2D()
884 print "Error: given parameter is not numerucal functor type."
886 ## Creates hypothesis
887 # @param theHType mesh hypothesis type (string)
888 # @param theLibName mesh plug-in library name
889 # @return created hypothesis instance
890 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
891 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
893 ## Gets the mesh stattistic
894 # @return dictionary type element - count of elements
895 # @ingroup l1_meshinfo
896 def GetMeshInfo(self, obj):
897 if isinstance( obj, Mesh ):
900 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
901 values = obj.GetMeshInfo()
902 for i in range(SMESH.Entity_Last._v):
903 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
907 ## Get minimum distance between two objects
909 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
910 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
912 # @param src1 first source object
913 # @param src2 second source object
914 # @param id1 node/element id from the first source
915 # @param id2 node/element id from the second (or first) source
916 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
917 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
918 # @return minimum distance value
919 # @sa GetMinDistance()
920 # @ingroup l1_measurements
921 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
922 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
926 result = result.value
929 ## Get measure structure specifying minimum distance data between two objects
931 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
932 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
934 # @param src1 first source object
935 # @param src2 second source object
936 # @param id1 node/element id from the first source
937 # @param id2 node/element id from the second (or first) source
938 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
939 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
940 # @return Measure structure or None if input data is invalid
942 # @ingroup l1_measurements
943 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
944 if isinstance(src1, Mesh): src1 = src1.mesh
945 if isinstance(src2, Mesh): src2 = src2.mesh
946 if src2 is None and id2 != 0: src2 = src1
947 if not hasattr(src1, "_narrow"): return None
948 src1 = src1._narrow(SMESH.SMESH_IDSource)
949 if not src1: return None
952 e = m.GetMeshEditor()
954 src1 = e.MakeIDSource([id1], SMESH.FACE)
956 src1 = e.MakeIDSource([id1], SMESH.NODE)
958 if hasattr(src2, "_narrow"):
959 src2 = src2._narrow(SMESH.SMESH_IDSource)
960 if src2 and id2 != 0:
962 e = m.GetMeshEditor()
964 src2 = e.MakeIDSource([id2], SMESH.FACE)
966 src2 = e.MakeIDSource([id2], SMESH.NODE)
969 aMeasurements = self.CreateMeasurements()
970 result = aMeasurements.MinDistance(src1, src2)
971 aMeasurements.Destroy()
974 ## Get bounding box of the specified object(s)
975 # @param objects single source object or list of source objects
976 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
977 # @sa GetBoundingBox()
978 # @ingroup l1_measurements
979 def BoundingBox(self, objects):
980 result = self.GetBoundingBox(objects)
984 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
987 ## Get measure structure specifying bounding box data of the specified object(s)
988 # @param objects single source object or list of source objects
989 # @return Measure structure
991 # @ingroup l1_measurements
992 def GetBoundingBox(self, objects):
993 if isinstance(objects, tuple):
994 objects = list(objects)
995 if not isinstance(objects, list):
999 if isinstance(o, Mesh):
1000 srclist.append(o.mesh)
1001 elif hasattr(o, "_narrow"):
1002 src = o._narrow(SMESH.SMESH_IDSource)
1003 if src: srclist.append(src)
1006 aMeasurements = self.CreateMeasurements()
1007 result = aMeasurements.BoundingBox(srclist)
1008 aMeasurements.Destroy()
1012 #Registering the new proxy for SMESH_Gen
1013 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1016 # Public class: Mesh
1017 # ==================
1019 ## This class allows defining and managing a mesh.
1020 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1021 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1022 # new nodes and elements and by changing the existing entities), to get information
1023 # about a mesh and to export a mesh into different formats.
1032 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1033 # sets the GUI name of this mesh to \a name.
1034 # @param smeshpyD an instance of smeshDC class
1035 # @param geompyD an instance of geompyDC class
1036 # @param obj Shape to be meshed or SMESH_Mesh object
1037 # @param name Study name of the mesh
1038 # @ingroup l2_construct
1039 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1040 self.smeshpyD=smeshpyD
1041 self.geompyD=geompyD
1045 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1047 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1048 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1051 self.mesh = self.smeshpyD.CreateEmptyMesh()
1053 self.smeshpyD.SetName(self.mesh, name)
1055 self.smeshpyD.SetName(self.mesh, GetName(obj))
1058 self.geom = self.mesh.GetShapeToMesh()
1060 self.editor = self.mesh.GetMeshEditor()
1062 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1063 # @param theMesh a SMESH_Mesh object
1064 # @ingroup l2_construct
1065 def SetMesh(self, theMesh):
1067 self.geom = self.mesh.GetShapeToMesh()
1069 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1070 # @return a SMESH_Mesh object
1071 # @ingroup l2_construct
1075 ## Gets the name of the mesh
1076 # @return the name of the mesh as a string
1077 # @ingroup l2_construct
1079 name = GetName(self.GetMesh())
1082 ## Sets a name to the mesh
1083 # @param name a new name of the mesh
1084 # @ingroup l2_construct
1085 def SetName(self, name):
1086 self.smeshpyD.SetName(self.GetMesh(), name)
1088 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1089 # The subMesh object gives access to the IDs of nodes and elements.
1090 # @param theSubObject a geometrical object (shape)
1091 # @param theName a name for the submesh
1092 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1093 # @ingroup l2_submeshes
1094 def GetSubMesh(self, theSubObject, theName):
1095 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1098 ## Returns the shape associated to the mesh
1099 # @return a GEOM_Object
1100 # @ingroup l2_construct
1104 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1105 # @param geom the shape to be meshed (GEOM_Object)
1106 # @ingroup l2_construct
1107 def SetShape(self, geom):
1108 self.mesh = self.smeshpyD.CreateMesh(geom)
1110 ## Returns true if the hypotheses are defined well
1111 # @param theSubObject a subshape of a mesh shape
1112 # @return True or False
1113 # @ingroup l2_construct
1114 def IsReadyToCompute(self, theSubObject):
1115 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1117 ## Returns errors of hypotheses definition.
1118 # The list of errors is empty if everything is OK.
1119 # @param theSubObject a subshape of a mesh shape
1120 # @return a list of errors
1121 # @ingroup l2_construct
1122 def GetAlgoState(self, theSubObject):
1123 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1125 ## Returns a geometrical object on which the given element was built.
1126 # The returned geometrical object, if not nil, is either found in the
1127 # study or published by this method with the given name
1128 # @param theElementID the id of the mesh element
1129 # @param theGeomName the user-defined name of the geometrical object
1130 # @return GEOM::GEOM_Object instance
1131 # @ingroup l2_construct
1132 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1133 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1135 ## Returns the mesh dimension depending on the dimension of the underlying shape
1136 # @return mesh dimension as an integer value [0,3]
1137 # @ingroup l1_auxiliary
1138 def MeshDimension(self):
1139 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1140 if len( shells ) > 0 :
1142 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1144 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1150 ## Creates a segment discretization 1D algorithm.
1151 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1152 # \n If the optional \a geom parameter is not set, this algorithm is global.
1153 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1154 # @param algo the type of the required algorithm. Possible values are:
1156 # - smesh.PYTHON for discretization via a python function,
1157 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1158 # @param geom If defined is the subshape to be meshed
1159 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1160 # @ingroup l3_algos_basic
1161 def Segment(self, algo=REGULAR, geom=0):
1162 ## if Segment(geom) is called by mistake
1163 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1164 algo, geom = geom, algo
1165 if not algo: algo = REGULAR
1168 return Mesh_Segment(self, geom)
1169 elif algo == PYTHON:
1170 return Mesh_Segment_Python(self, geom)
1171 elif algo == COMPOSITE:
1172 return Mesh_CompositeSegment(self, geom)
1174 return Mesh_Segment(self, geom)
1176 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1177 # If the optional \a geom parameter is not set, this algorithm is global.
1178 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1179 # @param geom If defined the subshape is to be meshed
1180 # @return an instance of Mesh_UseExistingElements class
1181 # @ingroup l3_algos_basic
1182 def UseExisting1DElements(self, geom=0):
1183 return Mesh_UseExistingElements(1,self, geom)
1185 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1186 # If the optional \a geom parameter is not set, this algorithm is global.
1187 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1188 # @param geom If defined the subshape is to be meshed
1189 # @return an instance of Mesh_UseExistingElements class
1190 # @ingroup l3_algos_basic
1191 def UseExisting2DElements(self, geom=0):
1192 return Mesh_UseExistingElements(2,self, geom)
1194 ## Enables creation of nodes and segments usable by 2D algoritms.
1195 # The added nodes and segments must be bound to edges and vertices by
1196 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1197 # If the optional \a geom parameter is not set, this algorithm is global.
1198 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1199 # @param geom the subshape to be manually meshed
1200 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1201 # @ingroup l3_algos_basic
1202 def UseExistingSegments(self, geom=0):
1203 algo = Mesh_UseExisting(1,self,geom)
1204 return algo.GetAlgorithm()
1206 ## Enables creation of nodes and faces usable by 3D algoritms.
1207 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1208 # and SetMeshElementOnShape()
1209 # If the optional \a geom parameter is not set, this algorithm is global.
1210 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1211 # @param geom the subshape to be manually meshed
1212 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1213 # @ingroup l3_algos_basic
1214 def UseExistingFaces(self, geom=0):
1215 algo = Mesh_UseExisting(2,self,geom)
1216 return algo.GetAlgorithm()
1218 ## Creates a triangle 2D algorithm for faces.
1219 # If the optional \a geom parameter is not set, this algorithm is global.
1220 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1221 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1222 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1223 # @return an instance of Mesh_Triangle algorithm
1224 # @ingroup l3_algos_basic
1225 def Triangle(self, algo=MEFISTO, geom=0):
1226 ## if Triangle(geom) is called by mistake
1227 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1230 return Mesh_Triangle(self, algo, geom)
1232 ## Creates a quadrangle 2D algorithm for faces.
1233 # If the optional \a geom parameter is not set, this algorithm is global.
1234 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1235 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1236 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1237 # @return an instance of Mesh_Quadrangle algorithm
1238 # @ingroup l3_algos_basic
1239 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1240 if algo==RADIAL_QUAD:
1241 return Mesh_RadialQuadrangle1D2D(self,geom)
1243 return Mesh_Quadrangle(self, geom)
1245 ## Creates a tetrahedron 3D algorithm for solids.
1246 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1247 # If the optional \a geom parameter is not set, this algorithm is global.
1248 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1249 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1250 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1251 # @return an instance of Mesh_Tetrahedron algorithm
1252 # @ingroup l3_algos_basic
1253 def Tetrahedron(self, algo=NETGEN, geom=0):
1254 ## if Tetrahedron(geom) is called by mistake
1255 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1256 algo, geom = geom, algo
1257 if not algo: algo = NETGEN
1259 return Mesh_Tetrahedron(self, algo, geom)
1261 ## Creates a hexahedron 3D algorithm for solids.
1262 # If the optional \a geom parameter is not set, this algorithm is global.
1263 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1264 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1265 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1266 # @return an instance of Mesh_Hexahedron algorithm
1267 # @ingroup l3_algos_basic
1268 def Hexahedron(self, algo=Hexa, geom=0):
1269 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1270 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1271 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1272 elif geom == 0: algo, geom = Hexa, algo
1273 return Mesh_Hexahedron(self, algo, geom)
1275 ## Deprecated, used only for compatibility!
1276 # @return an instance of Mesh_Netgen algorithm
1277 # @ingroup l3_algos_basic
1278 def Netgen(self, is3D, geom=0):
1279 return Mesh_Netgen(self, is3D, geom)
1281 ## Creates a projection 1D algorithm for edges.
1282 # If the optional \a geom parameter is not set, this algorithm is global.
1283 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1284 # @param geom If defined, the subshape to be meshed
1285 # @return an instance of Mesh_Projection1D algorithm
1286 # @ingroup l3_algos_proj
1287 def Projection1D(self, geom=0):
1288 return Mesh_Projection1D(self, geom)
1290 ## Creates a projection 2D algorithm for faces.
1291 # If the optional \a geom parameter is not set, this algorithm is global.
1292 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1293 # @param geom If defined, the subshape to be meshed
1294 # @return an instance of Mesh_Projection2D algorithm
1295 # @ingroup l3_algos_proj
1296 def Projection2D(self, geom=0):
1297 return Mesh_Projection2D(self, geom)
1299 ## Creates a projection 3D algorithm for solids.
1300 # If the optional \a geom parameter is not set, this algorithm is global.
1301 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1302 # @param geom If defined, the subshape to be meshed
1303 # @return an instance of Mesh_Projection3D algorithm
1304 # @ingroup l3_algos_proj
1305 def Projection3D(self, geom=0):
1306 return Mesh_Projection3D(self, geom)
1308 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1309 # If the optional \a geom parameter is not set, this algorithm is global.
1310 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1311 # @param geom If defined, the subshape to be meshed
1312 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1313 # @ingroup l3_algos_radialp l3_algos_3dextr
1314 def Prism(self, geom=0):
1318 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1319 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1320 if nbSolids == 0 or nbSolids == nbShells:
1321 return Mesh_Prism3D(self, geom)
1322 return Mesh_RadialPrism3D(self, geom)
1324 ## Evaluates size of prospective mesh on a shape
1325 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1326 # To know predicted number of e.g. edges, inquire it this way
1327 # Evaluate()[ EnumToLong( Entity_Edge )]
1328 def Evaluate(self, geom=0):
1329 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1331 geom = self.mesh.GetShapeToMesh()
1334 return self.smeshpyD.Evaluate(self.mesh, geom)
1337 ## Computes the mesh and returns the status of the computation
1338 # @param geom geomtrical shape on which mesh data should be computed
1339 # @param discardModifs if True and the mesh has been edited since
1340 # a last total re-compute and that may prevent successful partial re-compute,
1341 # then the mesh is cleaned before Compute()
1342 # @return True or False
1343 # @ingroup l2_construct
1344 def Compute(self, geom=0, discardModifs=False):
1345 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1347 geom = self.mesh.GetShapeToMesh()
1352 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1354 ok = self.smeshpyD.Compute(self.mesh, geom)
1355 except SALOME.SALOME_Exception, ex:
1356 print "Mesh computation failed, exception caught:"
1357 print " ", ex.details.text
1360 print "Mesh computation failed, exception caught:"
1361 traceback.print_exc()
1365 # Treat compute errors
1366 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1367 for err in computeErrors:
1369 if self.mesh.HasShapeToMesh():
1371 mainIOR = salome.orb.object_to_string(geom)
1372 for sname in salome.myStudyManager.GetOpenStudies():
1373 s = salome.myStudyManager.GetStudyByName(sname)
1375 mainSO = s.FindObjectIOR(mainIOR)
1376 if not mainSO: continue
1377 if err.subShapeID == 1:
1378 shapeText = ' on "%s"' % mainSO.GetName()
1379 subIt = s.NewChildIterator(mainSO)
1381 subSO = subIt.Value()
1383 obj = subSO.GetObject()
1384 if not obj: continue
1385 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1387 ids = go.GetSubShapeIndices()
1388 if len(ids) == 1 and ids[0] == err.subShapeID:
1389 shapeText = ' on "%s"' % subSO.GetName()
1392 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1394 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1396 shapeText = " on subshape #%s" % (err.subShapeID)
1398 shapeText = " on subshape #%s" % (err.subShapeID)
1400 stdErrors = ["OK", #COMPERR_OK
1401 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1402 "std::exception", #COMPERR_STD_EXCEPTION
1403 "OCC exception", #COMPERR_OCC_EXCEPTION
1404 "SALOME exception", #COMPERR_SLM_EXCEPTION
1405 "Unknown exception", #COMPERR_EXCEPTION
1406 "Memory allocation problem", #COMPERR_MEMORY_PB
1407 "Algorithm failed", #COMPERR_ALGO_FAILED
1408 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1410 if err.code < len(stdErrors): errText = stdErrors[err.code]
1412 errText = "code %s" % -err.code
1413 if errText: errText += ". "
1414 errText += err.comment
1415 if allReasons != "":allReasons += "\n"
1416 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1420 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1422 if err.isGlobalAlgo:
1430 reason = '%s %sD algorithm is missing' % (glob, dim)
1431 elif err.state == HYP_MISSING:
1432 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1433 % (glob, dim, name, dim))
1434 elif err.state == HYP_NOTCONFORM:
1435 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1436 elif err.state == HYP_BAD_PARAMETER:
1437 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1438 % ( glob, dim, name ))
1439 elif err.state == HYP_BAD_GEOMETRY:
1440 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1441 'geometry' % ( glob, dim, name ))
1443 reason = "For unknown reason."+\
1444 " Revise Mesh.Compute() implementation in smeshDC.py!"
1446 if allReasons != "":allReasons += "\n"
1447 allReasons += reason
1449 if allReasons != "":
1450 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1454 print '"' + GetName(self.mesh) + '"',"has not been computed."
1457 if salome.sg.hasDesktop():
1458 smeshgui = salome.ImportComponentGUI("SMESH")
1459 smeshgui.Init(self.mesh.GetStudyId())
1460 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1461 salome.sg.updateObjBrowser(1)
1465 ## Return submesh objects list in meshing order
1466 # @return list of list of submesh objects
1467 # @ingroup l2_construct
1468 def GetMeshOrder(self):
1469 return self.mesh.GetMeshOrder()
1471 ## Return submesh objects list in meshing order
1472 # @return list of list of submesh objects
1473 # @ingroup l2_construct
1474 def SetMeshOrder(self, submeshes):
1475 return self.mesh.SetMeshOrder(submeshes)
1477 ## Removes all nodes and elements
1478 # @ingroup l2_construct
1481 if salome.sg.hasDesktop():
1482 smeshgui = salome.ImportComponentGUI("SMESH")
1483 smeshgui.Init(self.mesh.GetStudyId())
1484 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1485 salome.sg.updateObjBrowser(1)
1487 ## Removes all nodes and elements of indicated shape
1488 # @ingroup l2_construct
1489 def ClearSubMesh(self, geomId):
1490 self.mesh.ClearSubMesh(geomId)
1491 if salome.sg.hasDesktop():
1492 smeshgui = salome.ImportComponentGUI("SMESH")
1493 smeshgui.Init(self.mesh.GetStudyId())
1494 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1495 salome.sg.updateObjBrowser(1)
1497 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1498 # @param fineness [0,-1] defines mesh fineness
1499 # @return True or False
1500 # @ingroup l3_algos_basic
1501 def AutomaticTetrahedralization(self, fineness=0):
1502 dim = self.MeshDimension()
1504 self.RemoveGlobalHypotheses()
1505 self.Segment().AutomaticLength(fineness)
1507 self.Triangle().LengthFromEdges()
1510 self.Tetrahedron(NETGEN)
1512 return self.Compute()
1514 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1515 # @param fineness [0,-1] defines mesh fineness
1516 # @return True or False
1517 # @ingroup l3_algos_basic
1518 def AutomaticHexahedralization(self, fineness=0):
1519 dim = self.MeshDimension()
1520 # assign the hypotheses
1521 self.RemoveGlobalHypotheses()
1522 self.Segment().AutomaticLength(fineness)
1529 return self.Compute()
1531 ## Assigns a hypothesis
1532 # @param hyp a hypothesis to assign
1533 # @param geom a subhape of mesh geometry
1534 # @return SMESH.Hypothesis_Status
1535 # @ingroup l2_hypotheses
1536 def AddHypothesis(self, hyp, geom=0):
1537 if isinstance( hyp, Mesh_Algorithm ):
1538 hyp = hyp.GetAlgorithm()
1543 geom = self.mesh.GetShapeToMesh()
1545 status = self.mesh.AddHypothesis(geom, hyp)
1546 isAlgo = hyp._narrow( SMESH_Algo )
1547 hyp_name = GetName( hyp )
1550 geom_name = GetName( geom )
1551 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1554 ## Unassigns a hypothesis
1555 # @param hyp a hypothesis to unassign
1556 # @param geom a subshape of mesh geometry
1557 # @return SMESH.Hypothesis_Status
1558 # @ingroup l2_hypotheses
1559 def RemoveHypothesis(self, hyp, geom=0):
1560 if isinstance( hyp, Mesh_Algorithm ):
1561 hyp = hyp.GetAlgorithm()
1566 status = self.mesh.RemoveHypothesis(geom, hyp)
1569 ## Gets the list of hypotheses added on a geometry
1570 # @param geom a subshape of mesh geometry
1571 # @return the sequence of SMESH_Hypothesis
1572 # @ingroup l2_hypotheses
1573 def GetHypothesisList(self, geom):
1574 return self.mesh.GetHypothesisList( geom )
1576 ## Removes all global hypotheses
1577 # @ingroup l2_hypotheses
1578 def RemoveGlobalHypotheses(self):
1579 current_hyps = self.mesh.GetHypothesisList( self.geom )
1580 for hyp in current_hyps:
1581 self.mesh.RemoveHypothesis( self.geom, hyp )
1585 ## Creates a mesh group based on the geometric object \a grp
1586 # and gives a \a name, \n if this parameter is not defined
1587 # the name is the same as the geometric group name \n
1588 # Note: Works like GroupOnGeom().
1589 # @param grp a geometric group, a vertex, an edge, a face or a solid
1590 # @param name the name of the mesh group
1591 # @return SMESH_GroupOnGeom
1592 # @ingroup l2_grps_create
1593 def Group(self, grp, name=""):
1594 return self.GroupOnGeom(grp, name)
1596 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1597 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1598 ## allowing to overwrite the file if it exists or add the exported data to its contents
1599 # @param f the file name
1600 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1601 # @param opt boolean parameter for creating/not creating
1602 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1603 # @param overwrite boolean parameter for overwriting/not overwriting the file
1604 # @ingroup l2_impexp
1605 def ExportToMED(self, f, version, opt=0, overwrite=1):
1606 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1608 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1609 ## allowing to overwrite the file if it exists or add the exported data to its contents
1610 # @param f is the file name
1611 # @param auto_groups boolean parameter for creating/not creating
1612 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1613 # the typical use is auto_groups=false.
1614 # @param version MED format version(MED_V2_1 or MED_V2_2)
1615 # @param overwrite boolean parameter for overwriting/not overwriting the file
1616 # @ingroup l2_impexp
1617 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1618 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1620 ## Exports the mesh in a file in DAT format
1621 # @param f the file name
1622 # @ingroup l2_impexp
1623 def ExportDAT(self, f):
1624 self.mesh.ExportDAT(f)
1626 ## Exports the mesh in a file in UNV format
1627 # @param f the file name
1628 # @ingroup l2_impexp
1629 def ExportUNV(self, f):
1630 self.mesh.ExportUNV(f)
1632 ## Export the mesh in a file in STL format
1633 # @param f the file name
1634 # @param ascii defines the file encoding
1635 # @ingroup l2_impexp
1636 def ExportSTL(self, f, ascii=1):
1637 self.mesh.ExportSTL(f, ascii)
1640 # Operations with groups:
1641 # ----------------------
1643 ## Creates an empty mesh group
1644 # @param elementType the type of elements in the group
1645 # @param name the name of the mesh group
1646 # @return SMESH_Group
1647 # @ingroup l2_grps_create
1648 def CreateEmptyGroup(self, elementType, name):
1649 return self.mesh.CreateGroup(elementType, name)
1651 ## Creates a mesh group based on the geometrical object \a grp
1652 # and gives a \a name, \n if this parameter is not defined
1653 # the name is the same as the geometrical group name
1654 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1655 # @param name the name of the mesh group
1656 # @param typ the type of elements in the group. If not set, it is
1657 # automatically detected by the type of the geometry
1658 # @return SMESH_GroupOnGeom
1659 # @ingroup l2_grps_create
1660 def GroupOnGeom(self, grp, name="", typ=None):
1662 name = grp.GetName()
1665 tgeo = str(grp.GetShapeType())
1666 if tgeo == "VERTEX":
1668 elif tgeo == "EDGE":
1670 elif tgeo == "FACE":
1672 elif tgeo == "SOLID":
1674 elif tgeo == "SHELL":
1676 elif tgeo == "COMPOUND":
1677 try: # it raises on a compound of compounds
1678 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1679 print "Mesh.Group: empty geometric group", GetName( grp )
1684 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1686 tgeo = self.geompyD.GetType(grp)
1687 if tgeo == geompyDC.ShapeType["VERTEX"]:
1689 elif tgeo == geompyDC.ShapeType["EDGE"]:
1691 elif tgeo == geompyDC.ShapeType["FACE"]:
1693 elif tgeo == geompyDC.ShapeType["SOLID"]:
1699 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1700 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1701 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1709 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1712 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1714 ## Creates a mesh group by the given ids of elements
1715 # @param groupName the name of the mesh group
1716 # @param elementType the type of elements in the group
1717 # @param elemIDs the list of ids
1718 # @return SMESH_Group
1719 # @ingroup l2_grps_create
1720 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1721 group = self.mesh.CreateGroup(elementType, groupName)
1725 ## Creates a mesh group by the given conditions
1726 # @param groupName the name of the mesh group
1727 # @param elementType the type of elements in the group
1728 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1729 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1730 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1731 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1732 # @return SMESH_Group
1733 # @ingroup l2_grps_create
1737 CritType=FT_Undefined,
1740 UnaryOp=FT_Undefined):
1741 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1742 group = self.MakeGroupByCriterion(groupName, aCriterion)
1745 ## Creates a mesh group by the given criterion
1746 # @param groupName the name of the mesh group
1747 # @param Criterion the instance of Criterion class
1748 # @return SMESH_Group
1749 # @ingroup l2_grps_create
1750 def MakeGroupByCriterion(self, groupName, Criterion):
1751 aFilterMgr = self.smeshpyD.CreateFilterManager()
1752 aFilter = aFilterMgr.CreateFilter()
1754 aCriteria.append(Criterion)
1755 aFilter.SetCriteria(aCriteria)
1756 group = self.MakeGroupByFilter(groupName, aFilter)
1757 aFilterMgr.Destroy()
1760 ## Creates a mesh group by the given criteria (list of criteria)
1761 # @param groupName the name of the mesh group
1762 # @param theCriteria the list of criteria
1763 # @return SMESH_Group
1764 # @ingroup l2_grps_create
1765 def MakeGroupByCriteria(self, groupName, theCriteria):
1766 aFilterMgr = self.smeshpyD.CreateFilterManager()
1767 aFilter = aFilterMgr.CreateFilter()
1768 aFilter.SetCriteria(theCriteria)
1769 group = self.MakeGroupByFilter(groupName, aFilter)
1770 aFilterMgr.Destroy()
1773 ## Creates a mesh group by the given filter
1774 # @param groupName the name of the mesh group
1775 # @param theFilter the instance of Filter class
1776 # @return SMESH_Group
1777 # @ingroup l2_grps_create
1778 def MakeGroupByFilter(self, groupName, theFilter):
1779 anIds = theFilter.GetElementsId(self.mesh)
1780 anElemType = theFilter.GetElementType()
1781 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1784 ## Passes mesh elements through the given filter and return IDs of fitting elements
1785 # @param theFilter SMESH_Filter
1786 # @return a list of ids
1787 # @ingroup l1_controls
1788 def GetIdsFromFilter(self, theFilter):
1789 return theFilter.GetElementsId(self.mesh)
1791 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1792 # Returns a list of special structures (borders).
1793 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1794 # @ingroup l1_controls
1795 def GetFreeBorders(self):
1796 aFilterMgr = self.smeshpyD.CreateFilterManager()
1797 aPredicate = aFilterMgr.CreateFreeEdges()
1798 aPredicate.SetMesh(self.mesh)
1799 aBorders = aPredicate.GetBorders()
1800 aFilterMgr.Destroy()
1804 # @ingroup l2_grps_delete
1805 def RemoveGroup(self, group):
1806 self.mesh.RemoveGroup(group)
1808 ## Removes a group with its contents
1809 # @ingroup l2_grps_delete
1810 def RemoveGroupWithContents(self, group):
1811 self.mesh.RemoveGroupWithContents(group)
1813 ## Gets the list of groups existing in the mesh
1814 # @return a sequence of SMESH_GroupBase
1815 # @ingroup l2_grps_create
1816 def GetGroups(self):
1817 return self.mesh.GetGroups()
1819 ## Gets the number of groups existing in the mesh
1820 # @return the quantity of groups as an integer value
1821 # @ingroup l2_grps_create
1823 return self.mesh.NbGroups()
1825 ## Gets the list of names of groups existing in the mesh
1826 # @return list of strings
1827 # @ingroup l2_grps_create
1828 def GetGroupNames(self):
1829 groups = self.GetGroups()
1831 for group in groups:
1832 names.append(group.GetName())
1835 ## Produces a union of two groups
1836 # A new group is created. All mesh elements that are
1837 # present in the initial groups are added to the new one
1838 # @return an instance of SMESH_Group
1839 # @ingroup l2_grps_operon
1840 def UnionGroups(self, group1, group2, name):
1841 return self.mesh.UnionGroups(group1, group2, name)
1843 ## Produces a union list of groups
1844 # New group is created. All mesh elements that are present in
1845 # initial groups are added to the new one
1846 # @return an instance of SMESH_Group
1847 # @ingroup l2_grps_operon
1848 def UnionListOfGroups(self, groups, name):
1849 return self.mesh.UnionListOfGroups(groups, name)
1851 ## Prodices an intersection of two groups
1852 # A new group is created. All mesh elements that are common
1853 # for the two initial groups are added to the new one.
1854 # @return an instance of SMESH_Group
1855 # @ingroup l2_grps_operon
1856 def IntersectGroups(self, group1, group2, name):
1857 return self.mesh.IntersectGroups(group1, group2, name)
1859 ## Produces an intersection of groups
1860 # New group is created. All mesh elements that are present in all
1861 # initial groups simultaneously are added to the new one
1862 # @return an instance of SMESH_Group
1863 # @ingroup l2_grps_operon
1864 def IntersectListOfGroups(self, groups, name):
1865 return self.mesh.IntersectListOfGroups(groups, name)
1867 ## Produces a cut of two groups
1868 # A new group is created. All mesh elements that are present in
1869 # the main group but are not present in the tool group are added to the new one
1870 # @return an instance of SMESH_Group
1871 # @ingroup l2_grps_operon
1872 def CutGroups(self, main_group, tool_group, name):
1873 return self.mesh.CutGroups(main_group, tool_group, name)
1875 ## Produces a cut of groups
1876 # A new group is created. All mesh elements that are present in main groups
1877 # but do not present in tool groups are added to the new one
1878 # @return an instance of SMESH_Group
1879 # @ingroup l2_grps_operon
1880 def CutListOfGroups(self, main_groups, tool_groups, name):
1881 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1883 ## Produces a group of elements with specified element type using list of existing groups
1884 # A new group is created. System
1885 # 1) extract all nodes on which groups elements are built
1886 # 2) combine all elements of specified dimension laying on these nodes
1887 # @return an instance of SMESH_Group
1888 # @ingroup l2_grps_operon
1889 def CreateDimGroup(self, groups, elem_type, name):
1890 return self.mesh.CreateDimGroup(groups, elem_type, name)
1893 ## Convert group on geom into standalone group
1894 # @ingroup l2_grps_delete
1895 def ConvertToStandalone(self, group):
1896 return self.mesh.ConvertToStandalone(group)
1898 # Get some info about mesh:
1899 # ------------------------
1901 ## Returns the log of nodes and elements added or removed
1902 # since the previous clear of the log.
1903 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1904 # @return list of log_block structures:
1909 # @ingroup l1_auxiliary
1910 def GetLog(self, clearAfterGet):
1911 return self.mesh.GetLog(clearAfterGet)
1913 ## Clears the log of nodes and elements added or removed since the previous
1914 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1915 # @ingroup l1_auxiliary
1917 self.mesh.ClearLog()
1919 ## Toggles auto color mode on the object.
1920 # @param theAutoColor the flag which toggles auto color mode.
1921 # @ingroup l1_auxiliary
1922 def SetAutoColor(self, theAutoColor):
1923 self.mesh.SetAutoColor(theAutoColor)
1925 ## Gets flag of object auto color mode.
1926 # @return True or False
1927 # @ingroup l1_auxiliary
1928 def GetAutoColor(self):
1929 return self.mesh.GetAutoColor()
1931 ## Gets the internal ID
1932 # @return integer value, which is the internal Id of the mesh
1933 # @ingroup l1_auxiliary
1935 return self.mesh.GetId()
1938 # @return integer value, which is the study Id of the mesh
1939 # @ingroup l1_auxiliary
1940 def GetStudyId(self):
1941 return self.mesh.GetStudyId()
1943 ## Checks the group names for duplications.
1944 # Consider the maximum group name length stored in MED file.
1945 # @return True or False
1946 # @ingroup l1_auxiliary
1947 def HasDuplicatedGroupNamesMED(self):
1948 return self.mesh.HasDuplicatedGroupNamesMED()
1950 ## Obtains the mesh editor tool
1951 # @return an instance of SMESH_MeshEditor
1952 # @ingroup l1_modifying
1953 def GetMeshEditor(self):
1954 return self.mesh.GetMeshEditor()
1957 # @return an instance of SALOME_MED::MESH
1958 # @ingroup l1_auxiliary
1959 def GetMEDMesh(self):
1960 return self.mesh.GetMEDMesh()
1963 # Get informations about mesh contents:
1964 # ------------------------------------
1966 ## Gets the mesh stattistic
1967 # @return dictionary type element - count of elements
1968 # @ingroup l1_meshinfo
1969 def GetMeshInfo(self, obj = None):
1970 if not obj: obj = self.mesh
1971 return self.smeshpyD.GetMeshInfo(obj)
1973 ## Returns the number of nodes in the mesh
1974 # @return an integer value
1975 # @ingroup l1_meshinfo
1977 return self.mesh.NbNodes()
1979 ## Returns the number of elements in the mesh
1980 # @return an integer value
1981 # @ingroup l1_meshinfo
1982 def NbElements(self):
1983 return self.mesh.NbElements()
1985 ## Returns the number of 0d elements in the mesh
1986 # @return an integer value
1987 # @ingroup l1_meshinfo
1988 def Nb0DElements(self):
1989 return self.mesh.Nb0DElements()
1991 ## Returns the number of edges in the mesh
1992 # @return an integer value
1993 # @ingroup l1_meshinfo
1995 return self.mesh.NbEdges()
1997 ## Returns the number of edges with the given order in the mesh
1998 # @param elementOrder the order of elements:
1999 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2000 # @return an integer value
2001 # @ingroup l1_meshinfo
2002 def NbEdgesOfOrder(self, elementOrder):
2003 return self.mesh.NbEdgesOfOrder(elementOrder)
2005 ## Returns the number of faces in the mesh
2006 # @return an integer value
2007 # @ingroup l1_meshinfo
2009 return self.mesh.NbFaces()
2011 ## Returns the number of faces with the given order in the mesh
2012 # @param elementOrder the order of elements:
2013 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2014 # @return an integer value
2015 # @ingroup l1_meshinfo
2016 def NbFacesOfOrder(self, elementOrder):
2017 return self.mesh.NbFacesOfOrder(elementOrder)
2019 ## Returns the number of triangles in the mesh
2020 # @return an integer value
2021 # @ingroup l1_meshinfo
2022 def NbTriangles(self):
2023 return self.mesh.NbTriangles()
2025 ## Returns the number of triangles with the given order in the mesh
2026 # @param elementOrder is the order of elements:
2027 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2028 # @return an integer value
2029 # @ingroup l1_meshinfo
2030 def NbTrianglesOfOrder(self, elementOrder):
2031 return self.mesh.NbTrianglesOfOrder(elementOrder)
2033 ## Returns the number of quadrangles in the mesh
2034 # @return an integer value
2035 # @ingroup l1_meshinfo
2036 def NbQuadrangles(self):
2037 return self.mesh.NbQuadrangles()
2039 ## Returns the number of quadrangles with the given order in the mesh
2040 # @param elementOrder the order of elements:
2041 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2042 # @return an integer value
2043 # @ingroup l1_meshinfo
2044 def NbQuadranglesOfOrder(self, elementOrder):
2045 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2047 ## Returns the number of polygons in the mesh
2048 # @return an integer value
2049 # @ingroup l1_meshinfo
2050 def NbPolygons(self):
2051 return self.mesh.NbPolygons()
2053 ## Returns the number of volumes in the mesh
2054 # @return an integer value
2055 # @ingroup l1_meshinfo
2056 def NbVolumes(self):
2057 return self.mesh.NbVolumes()
2059 ## Returns the number of volumes with the given order in the mesh
2060 # @param elementOrder the order of elements:
2061 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2062 # @return an integer value
2063 # @ingroup l1_meshinfo
2064 def NbVolumesOfOrder(self, elementOrder):
2065 return self.mesh.NbVolumesOfOrder(elementOrder)
2067 ## Returns the number of tetrahedrons in the mesh
2068 # @return an integer value
2069 # @ingroup l1_meshinfo
2071 return self.mesh.NbTetras()
2073 ## Returns the number of tetrahedrons with the given order in the mesh
2074 # @param elementOrder the order of elements:
2075 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2076 # @return an integer value
2077 # @ingroup l1_meshinfo
2078 def NbTetrasOfOrder(self, elementOrder):
2079 return self.mesh.NbTetrasOfOrder(elementOrder)
2081 ## Returns the number of hexahedrons in the mesh
2082 # @return an integer value
2083 # @ingroup l1_meshinfo
2085 return self.mesh.NbHexas()
2087 ## Returns the number of hexahedrons with the given order in the mesh
2088 # @param elementOrder the order of elements:
2089 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2090 # @return an integer value
2091 # @ingroup l1_meshinfo
2092 def NbHexasOfOrder(self, elementOrder):
2093 return self.mesh.NbHexasOfOrder(elementOrder)
2095 ## Returns the number of pyramids in the mesh
2096 # @return an integer value
2097 # @ingroup l1_meshinfo
2098 def NbPyramids(self):
2099 return self.mesh.NbPyramids()
2101 ## Returns the number of pyramids with the given order in the mesh
2102 # @param elementOrder the order of elements:
2103 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2104 # @return an integer value
2105 # @ingroup l1_meshinfo
2106 def NbPyramidsOfOrder(self, elementOrder):
2107 return self.mesh.NbPyramidsOfOrder(elementOrder)
2109 ## Returns the number of prisms in the mesh
2110 # @return an integer value
2111 # @ingroup l1_meshinfo
2113 return self.mesh.NbPrisms()
2115 ## Returns the number of prisms with the given order in the mesh
2116 # @param elementOrder the order of elements:
2117 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2118 # @return an integer value
2119 # @ingroup l1_meshinfo
2120 def NbPrismsOfOrder(self, elementOrder):
2121 return self.mesh.NbPrismsOfOrder(elementOrder)
2123 ## Returns the number of polyhedrons in the mesh
2124 # @return an integer value
2125 # @ingroup l1_meshinfo
2126 def NbPolyhedrons(self):
2127 return self.mesh.NbPolyhedrons()
2129 ## Returns the number of submeshes in the mesh
2130 # @return an integer value
2131 # @ingroup l1_meshinfo
2132 def NbSubMesh(self):
2133 return self.mesh.NbSubMesh()
2135 ## Returns the list of mesh elements IDs
2136 # @return the list of integer values
2137 # @ingroup l1_meshinfo
2138 def GetElementsId(self):
2139 return self.mesh.GetElementsId()
2141 ## Returns the list of IDs of mesh elements with the given type
2142 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2143 # @return list of integer values
2144 # @ingroup l1_meshinfo
2145 def GetElementsByType(self, elementType):
2146 return self.mesh.GetElementsByType(elementType)
2148 ## Returns the list of mesh nodes IDs
2149 # @return the list of integer values
2150 # @ingroup l1_meshinfo
2151 def GetNodesId(self):
2152 return self.mesh.GetNodesId()
2154 # Get the information about mesh elements:
2155 # ------------------------------------
2157 ## Returns the type of mesh element
2158 # @return the value from SMESH::ElementType enumeration
2159 # @ingroup l1_meshinfo
2160 def GetElementType(self, id, iselem):
2161 return self.mesh.GetElementType(id, iselem)
2163 ## Returns the geometric type of mesh element
2164 # @return the value from SMESH::EntityType enumeration
2165 # @ingroup l1_meshinfo
2166 def GetElementGeomType(self, id):
2167 return self.mesh.GetElementGeomType(id)
2169 ## Returns the list of submesh elements IDs
2170 # @param Shape a geom object(subshape) IOR
2171 # Shape must be the subshape of a ShapeToMesh()
2172 # @return the list of integer values
2173 # @ingroup l1_meshinfo
2174 def GetSubMeshElementsId(self, Shape):
2175 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2176 ShapeID = Shape.GetSubShapeIndices()[0]
2179 return self.mesh.GetSubMeshElementsId(ShapeID)
2181 ## Returns the list of submesh nodes IDs
2182 # @param Shape a geom object(subshape) IOR
2183 # Shape must be the subshape of a ShapeToMesh()
2184 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2185 # @return the list of integer values
2186 # @ingroup l1_meshinfo
2187 def GetSubMeshNodesId(self, Shape, all):
2188 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2189 ShapeID = Shape.GetSubShapeIndices()[0]
2192 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2194 ## Returns type of elements on given shape
2195 # @param Shape a geom object(subshape) IOR
2196 # Shape must be a subshape of a ShapeToMesh()
2197 # @return element type
2198 # @ingroup l1_meshinfo
2199 def GetSubMeshElementType(self, Shape):
2200 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2201 ShapeID = Shape.GetSubShapeIndices()[0]
2204 return self.mesh.GetSubMeshElementType(ShapeID)
2206 ## Gets the mesh description
2207 # @return string value
2208 # @ingroup l1_meshinfo
2210 return self.mesh.Dump()
2213 # Get the information about nodes and elements of a mesh by its IDs:
2214 # -----------------------------------------------------------
2216 ## Gets XYZ coordinates of a node
2217 # \n If there is no nodes for the given ID - returns an empty list
2218 # @return a list of double precision values
2219 # @ingroup l1_meshinfo
2220 def GetNodeXYZ(self, id):
2221 return self.mesh.GetNodeXYZ(id)
2223 ## Returns list of IDs of inverse elements for the given node
2224 # \n If there is no node for the given ID - returns an empty list
2225 # @return a list of integer values
2226 # @ingroup l1_meshinfo
2227 def GetNodeInverseElements(self, id):
2228 return self.mesh.GetNodeInverseElements(id)
2230 ## @brief Returns the position of a node on the shape
2231 # @return SMESH::NodePosition
2232 # @ingroup l1_meshinfo
2233 def GetNodePosition(self,NodeID):
2234 return self.mesh.GetNodePosition(NodeID)
2236 ## If the given element is a node, returns the ID of shape
2237 # \n If there is no node for the given ID - returns -1
2238 # @return an integer value
2239 # @ingroup l1_meshinfo
2240 def GetShapeID(self, id):
2241 return self.mesh.GetShapeID(id)
2243 ## Returns the ID of the result shape after
2244 # FindShape() from SMESH_MeshEditor for the given element
2245 # \n If there is no element for the given ID - returns -1
2246 # @return an integer value
2247 # @ingroup l1_meshinfo
2248 def GetShapeIDForElem(self,id):
2249 return self.mesh.GetShapeIDForElem(id)
2251 ## Returns the number of nodes for the given element
2252 # \n If there is no element for the given ID - returns -1
2253 # @return an integer value
2254 # @ingroup l1_meshinfo
2255 def GetElemNbNodes(self, id):
2256 return self.mesh.GetElemNbNodes(id)
2258 ## Returns the node ID the given index for the given element
2259 # \n If there is no element for the given ID - returns -1
2260 # \n If there is no node for the given index - returns -2
2261 # @return an integer value
2262 # @ingroup l1_meshinfo
2263 def GetElemNode(self, id, index):
2264 return self.mesh.GetElemNode(id, index)
2266 ## Returns the IDs of nodes of the given element
2267 # @return a list of integer values
2268 # @ingroup l1_meshinfo
2269 def GetElemNodes(self, id):
2270 return self.mesh.GetElemNodes(id)
2272 ## Returns true if the given node is the medium node in the given quadratic element
2273 # @ingroup l1_meshinfo
2274 def IsMediumNode(self, elementID, nodeID):
2275 return self.mesh.IsMediumNode(elementID, nodeID)
2277 ## Returns true if the given node is the medium node in one of quadratic elements
2278 # @ingroup l1_meshinfo
2279 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2280 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2282 ## Returns the number of edges for the given element
2283 # @ingroup l1_meshinfo
2284 def ElemNbEdges(self, id):
2285 return self.mesh.ElemNbEdges(id)
2287 ## Returns the number of faces for the given element
2288 # @ingroup l1_meshinfo
2289 def ElemNbFaces(self, id):
2290 return self.mesh.ElemNbFaces(id)
2292 ## Returns nodes of given face (counted from zero) for given volumic element.
2293 # @ingroup l1_meshinfo
2294 def GetElemFaceNodes(self,elemId, faceIndex):
2295 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2297 ## Returns an element based on all given nodes.
2298 # @ingroup l1_meshinfo
2299 def FindElementByNodes(self,nodes):
2300 return self.mesh.FindElementByNodes(nodes)
2302 ## Returns true if the given element is a polygon
2303 # @ingroup l1_meshinfo
2304 def IsPoly(self, id):
2305 return self.mesh.IsPoly(id)
2307 ## Returns true if the given element is quadratic
2308 # @ingroup l1_meshinfo
2309 def IsQuadratic(self, id):
2310 return self.mesh.IsQuadratic(id)
2312 ## Returns XYZ coordinates of the barycenter of the given element
2313 # \n If there is no element for the given ID - returns an empty list
2314 # @return a list of three double values
2315 # @ingroup l1_meshinfo
2316 def BaryCenter(self, id):
2317 return self.mesh.BaryCenter(id)
2320 # Get mesh measurements information:
2321 # ------------------------------------
2323 ## Get minimum distance between two nodes, elements or distance to the origin
2324 # @param id1 first node/element id
2325 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2326 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2327 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2328 # @return minimum distance value
2329 # @sa GetMinDistance()
2330 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2331 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2332 return aMeasure.value
2334 ## Get measure structure specifying minimum distance data between two objects
2335 # @param id1 first node/element id
2336 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2337 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2338 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2339 # @return Measure structure
2341 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2343 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2345 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2348 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2350 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2355 aMeasurements = self.smeshpyD.CreateMeasurements()
2356 aMeasure = aMeasurements.MinDistance(id1, id2)
2357 aMeasurements.Destroy()
2360 ## Get bounding box of the specified object(s)
2361 # @param objects single source object or list of source objects or list of nodes/elements IDs
2362 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2363 # @c False specifies that @a objects are nodes
2364 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2365 # @sa GetBoundingBox()
2366 def BoundingBox(self, objects=None, isElem=False):
2367 result = self.GetBoundingBox(objects, isElem)
2371 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2374 ## Get measure structure specifying bounding box data of the specified object(s)
2375 # @param objects single source object or list of source objects or list of nodes/elements IDs
2376 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2377 # @c False specifies that @a objects are nodes
2378 # @return Measure structure
2380 def GetBoundingBox(self, IDs=None, isElem=False):
2383 elif isinstance(IDs, tuple):
2385 if not isinstance(IDs, list):
2387 if len(IDs) > 0 and isinstance(IDs[0], int):
2391 if isinstance(o, Mesh):
2392 srclist.append(o.mesh)
2393 elif hasattr(o, "_narrow"):
2394 src = o._narrow(SMESH.SMESH_IDSource)
2395 if src: srclist.append(src)
2397 elif isinstance(o, list):
2399 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2401 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2404 aMeasurements = self.smeshpyD.CreateMeasurements()
2405 aMeasure = aMeasurements.BoundingBox(srclist)
2406 aMeasurements.Destroy()
2409 # Mesh edition (SMESH_MeshEditor functionality):
2410 # ---------------------------------------------
2412 ## Removes the elements from the mesh by ids
2413 # @param IDsOfElements is a list of ids of elements to remove
2414 # @return True or False
2415 # @ingroup l2_modif_del
2416 def RemoveElements(self, IDsOfElements):
2417 return self.editor.RemoveElements(IDsOfElements)
2419 ## Removes nodes from mesh by ids
2420 # @param IDsOfNodes is a list of ids of nodes to remove
2421 # @return True or False
2422 # @ingroup l2_modif_del
2423 def RemoveNodes(self, IDsOfNodes):
2424 return self.editor.RemoveNodes(IDsOfNodes)
2426 ## Removes all orphan (free) nodes from mesh
2427 # @return number of the removed nodes
2428 # @ingroup l2_modif_del
2429 def RemoveOrphanNodes(self):
2430 return self.editor.RemoveOrphanNodes()
2432 ## Add a node to the mesh by coordinates
2433 # @return Id of the new node
2434 # @ingroup l2_modif_add
2435 def AddNode(self, x, y, z):
2436 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2437 self.mesh.SetParameters(Parameters)
2438 return self.editor.AddNode( x, y, z)
2440 ## Creates a 0D element on a node with given number.
2441 # @param IDOfNode the ID of node for creation of the element.
2442 # @return the Id of the new 0D element
2443 # @ingroup l2_modif_add
2444 def Add0DElement(self, IDOfNode):
2445 return self.editor.Add0DElement(IDOfNode)
2447 ## Creates a linear or quadratic edge (this is determined
2448 # by the number of given nodes).
2449 # @param IDsOfNodes the list of node IDs for creation of the element.
2450 # The order of nodes in this list should correspond to the description
2451 # of MED. \n This description is located by the following link:
2452 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2453 # @return the Id of the new edge
2454 # @ingroup l2_modif_add
2455 def AddEdge(self, IDsOfNodes):
2456 return self.editor.AddEdge(IDsOfNodes)
2458 ## Creates a linear or quadratic face (this is determined
2459 # by the number of given nodes).
2460 # @param IDsOfNodes the list of node IDs for creation of the element.
2461 # The order of nodes in this list should correspond to the description
2462 # of MED. \n This description is located by the following link:
2463 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2464 # @return the Id of the new face
2465 # @ingroup l2_modif_add
2466 def AddFace(self, IDsOfNodes):
2467 return self.editor.AddFace(IDsOfNodes)
2469 ## Adds a polygonal face to the mesh by the list of node IDs
2470 # @param IdsOfNodes the list of node IDs for creation of the element.
2471 # @return the Id of the new face
2472 # @ingroup l2_modif_add
2473 def AddPolygonalFace(self, IdsOfNodes):
2474 return self.editor.AddPolygonalFace(IdsOfNodes)
2476 ## Creates both simple and quadratic volume (this is determined
2477 # by the number of given nodes).
2478 # @param IDsOfNodes the list of node IDs for creation of the element.
2479 # The order of nodes in this list should correspond to the description
2480 # of MED. \n This description is located by the following link:
2481 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2482 # @return the Id of the new volumic element
2483 # @ingroup l2_modif_add
2484 def AddVolume(self, IDsOfNodes):
2485 return self.editor.AddVolume(IDsOfNodes)
2487 ## Creates a volume of many faces, giving nodes for each face.
2488 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2489 # @param Quantities the list of integer values, Quantities[i]
2490 # gives the quantity of nodes in face number i.
2491 # @return the Id of the new volumic element
2492 # @ingroup l2_modif_add
2493 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2494 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2496 ## Creates a volume of many faces, giving the IDs of the existing faces.
2497 # @param IdsOfFaces the list of face IDs for volume creation.
2499 # Note: The created volume will refer only to the nodes
2500 # of the given faces, not to the faces themselves.
2501 # @return the Id of the new volumic element
2502 # @ingroup l2_modif_add
2503 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2504 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2507 ## @brief Binds a node to a vertex
2508 # @param NodeID a node ID
2509 # @param Vertex a vertex or vertex ID
2510 # @return True if succeed else raises an exception
2511 # @ingroup l2_modif_add
2512 def SetNodeOnVertex(self, NodeID, Vertex):
2513 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2514 VertexID = Vertex.GetSubShapeIndices()[0]
2518 self.editor.SetNodeOnVertex(NodeID, VertexID)
2519 except SALOME.SALOME_Exception, inst:
2520 raise ValueError, inst.details.text
2524 ## @brief Stores the node position on an edge
2525 # @param NodeID a node ID
2526 # @param Edge an edge or edge ID
2527 # @param paramOnEdge a parameter on the edge where the node is located
2528 # @return True if succeed else raises an exception
2529 # @ingroup l2_modif_add
2530 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2531 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2532 EdgeID = Edge.GetSubShapeIndices()[0]
2536 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2537 except SALOME.SALOME_Exception, inst:
2538 raise ValueError, inst.details.text
2541 ## @brief Stores node position on a face
2542 # @param NodeID a node ID
2543 # @param Face a face or face ID
2544 # @param u U parameter on the face where the node is located
2545 # @param v V parameter on the face where the node is located
2546 # @return True if succeed else raises an exception
2547 # @ingroup l2_modif_add
2548 def SetNodeOnFace(self, NodeID, Face, u, v):
2549 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2550 FaceID = Face.GetSubShapeIndices()[0]
2554 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2555 except SALOME.SALOME_Exception, inst:
2556 raise ValueError, inst.details.text
2559 ## @brief Binds a node to a solid
2560 # @param NodeID a node ID
2561 # @param Solid a solid or solid ID
2562 # @return True if succeed else raises an exception
2563 # @ingroup l2_modif_add
2564 def SetNodeInVolume(self, NodeID, Solid):
2565 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2566 SolidID = Solid.GetSubShapeIndices()[0]
2570 self.editor.SetNodeInVolume(NodeID, SolidID)
2571 except SALOME.SALOME_Exception, inst:
2572 raise ValueError, inst.details.text
2575 ## @brief Bind an element to a shape
2576 # @param ElementID an element ID
2577 # @param Shape a shape or shape ID
2578 # @return True if succeed else raises an exception
2579 # @ingroup l2_modif_add
2580 def SetMeshElementOnShape(self, ElementID, Shape):
2581 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2582 ShapeID = Shape.GetSubShapeIndices()[0]
2586 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2587 except SALOME.SALOME_Exception, inst:
2588 raise ValueError, inst.details.text
2592 ## Moves the node with the given id
2593 # @param NodeID the id of the node
2594 # @param x a new X coordinate
2595 # @param y a new Y coordinate
2596 # @param z a new Z coordinate
2597 # @return True if succeed else False
2598 # @ingroup l2_modif_movenode
2599 def MoveNode(self, NodeID, x, y, z):
2600 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2601 self.mesh.SetParameters(Parameters)
2602 return self.editor.MoveNode(NodeID, x, y, z)
2604 ## Finds the node closest to a point and moves it to a point location
2605 # @param x the X coordinate of a point
2606 # @param y the Y coordinate of a point
2607 # @param z the Z coordinate of a point
2608 # @param NodeID if specified (>0), the node with this ID is moved,
2609 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2610 # @return the ID of a node
2611 # @ingroup l2_modif_throughp
2612 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2613 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2614 self.mesh.SetParameters(Parameters)
2615 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2617 ## Finds the node closest to a point
2618 # @param x the X coordinate of a point
2619 # @param y the Y coordinate of a point
2620 # @param z the Z coordinate of a point
2621 # @return the ID of a node
2622 # @ingroup l2_modif_throughp
2623 def FindNodeClosestTo(self, x, y, z):
2624 #preview = self.mesh.GetMeshEditPreviewer()
2625 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2626 return self.editor.FindNodeClosestTo(x, y, z)
2628 ## Finds the elements where a point lays IN or ON
2629 # @param x the X coordinate of a point
2630 # @param y the Y coordinate of a point
2631 # @param z the Z coordinate of a point
2632 # @param elementType type of elements to find (SMESH.ALL type
2633 # means elements of any type excluding nodes and 0D elements)
2634 # @return list of IDs of found elements
2635 # @ingroup l2_modif_throughp
2636 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2637 return self.editor.FindElementsByPoint(x, y, z, elementType)
2639 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2640 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2642 def GetPointState(self, x, y, z):
2643 return self.editor.GetPointState(x, y, z)
2645 ## Finds the node closest to a point and moves it to a point location
2646 # @param x the X coordinate of a point
2647 # @param y the Y coordinate of a point
2648 # @param z the Z coordinate of a point
2649 # @return the ID of a moved node
2650 # @ingroup l2_modif_throughp
2651 def MeshToPassThroughAPoint(self, x, y, z):
2652 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2654 ## Replaces two neighbour triangles sharing Node1-Node2 link
2655 # with the triangles built on the same 4 nodes but having other common link.
2656 # @param NodeID1 the ID of the first node
2657 # @param NodeID2 the ID of the second node
2658 # @return false if proper faces were not found
2659 # @ingroup l2_modif_invdiag
2660 def InverseDiag(self, NodeID1, NodeID2):
2661 return self.editor.InverseDiag(NodeID1, NodeID2)
2663 ## Replaces two neighbour triangles sharing Node1-Node2 link
2664 # with a quadrangle built on the same 4 nodes.
2665 # @param NodeID1 the ID of the first node
2666 # @param NodeID2 the ID of the second node
2667 # @return false if proper faces were not found
2668 # @ingroup l2_modif_unitetri
2669 def DeleteDiag(self, NodeID1, NodeID2):
2670 return self.editor.DeleteDiag(NodeID1, NodeID2)
2672 ## Reorients elements by ids
2673 # @param IDsOfElements if undefined reorients all mesh elements
2674 # @return True if succeed else False
2675 # @ingroup l2_modif_changori
2676 def Reorient(self, IDsOfElements=None):
2677 if IDsOfElements == None:
2678 IDsOfElements = self.GetElementsId()
2679 return self.editor.Reorient(IDsOfElements)
2681 ## Reorients all elements of the object
2682 # @param theObject mesh, submesh or group
2683 # @return True if succeed else False
2684 # @ingroup l2_modif_changori
2685 def ReorientObject(self, theObject):
2686 if ( isinstance( theObject, Mesh )):
2687 theObject = theObject.GetMesh()
2688 return self.editor.ReorientObject(theObject)
2690 ## Fuses the neighbouring triangles into quadrangles.
2691 # @param IDsOfElements The triangles to be fused,
2692 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2693 # @param MaxAngle is the maximum angle between element normals at which the fusion
2694 # is still performed; theMaxAngle is mesured in radians.
2695 # Also it could be a name of variable which defines angle in degrees.
2696 # @return TRUE in case of success, FALSE otherwise.
2697 # @ingroup l2_modif_unitetri
2698 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2700 if isinstance(MaxAngle,str):
2702 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2704 MaxAngle = DegreesToRadians(MaxAngle)
2705 if IDsOfElements == []:
2706 IDsOfElements = self.GetElementsId()
2707 self.mesh.SetParameters(Parameters)
2709 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2710 Functor = theCriterion
2712 Functor = self.smeshpyD.GetFunctor(theCriterion)
2713 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2715 ## Fuses the neighbouring triangles of the object into quadrangles
2716 # @param theObject is mesh, submesh or group
2717 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2718 # @param MaxAngle a max angle between element normals at which the fusion
2719 # is still performed; theMaxAngle is mesured in radians.
2720 # @return TRUE in case of success, FALSE otherwise.
2721 # @ingroup l2_modif_unitetri
2722 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2723 if ( isinstance( theObject, Mesh )):
2724 theObject = theObject.GetMesh()
2725 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2727 ## Splits quadrangles into triangles.
2728 # @param IDsOfElements the faces to be splitted.
2729 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2730 # @return TRUE in case of success, FALSE otherwise.
2731 # @ingroup l2_modif_cutquadr
2732 def QuadToTri (self, IDsOfElements, theCriterion):
2733 if IDsOfElements == []:
2734 IDsOfElements = self.GetElementsId()
2735 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2737 ## Splits quadrangles into triangles.
2738 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2739 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2740 # @return TRUE in case of success, FALSE otherwise.
2741 # @ingroup l2_modif_cutquadr
2742 def QuadToTriObject (self, theObject, theCriterion):
2743 if ( isinstance( theObject, Mesh )):
2744 theObject = theObject.GetMesh()
2745 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2747 ## Splits quadrangles into triangles.
2748 # @param IDsOfElements the faces to be splitted
2749 # @param Diag13 is used to choose a diagonal for splitting.
2750 # @return TRUE in case of success, FALSE otherwise.
2751 # @ingroup l2_modif_cutquadr
2752 def SplitQuad (self, IDsOfElements, Diag13):
2753 if IDsOfElements == []:
2754 IDsOfElements = self.GetElementsId()
2755 return self.editor.SplitQuad(IDsOfElements, Diag13)
2757 ## Splits quadrangles into triangles.
2758 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2759 # @param Diag13 is used to choose a diagonal for splitting.
2760 # @return TRUE in case of success, FALSE otherwise.
2761 # @ingroup l2_modif_cutquadr
2762 def SplitQuadObject (self, theObject, Diag13):
2763 if ( isinstance( theObject, Mesh )):
2764 theObject = theObject.GetMesh()
2765 return self.editor.SplitQuadObject(theObject, Diag13)
2767 ## Finds a better splitting of the given quadrangle.
2768 # @param IDOfQuad the ID of the quadrangle to be splitted.
2769 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2770 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2771 # diagonal is better, 0 if error occurs.
2772 # @ingroup l2_modif_cutquadr
2773 def BestSplit (self, IDOfQuad, theCriterion):
2774 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2776 ## Splits volumic elements into tetrahedrons
2777 # @param elemIDs either list of elements or mesh or group or submesh
2778 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2779 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2780 # @ingroup l2_modif_cutquadr
2781 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2782 if isinstance( elemIDs, Mesh ):
2783 elemIDs = elemIDs.GetMesh()
2784 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2786 ## Splits quadrangle faces near triangular facets of volumes
2788 # @ingroup l1_auxiliary
2789 def SplitQuadsNearTriangularFacets(self):
2790 faces_array = self.GetElementsByType(SMESH.FACE)
2791 for face_id in faces_array:
2792 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2793 quad_nodes = self.mesh.GetElemNodes(face_id)
2794 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2795 isVolumeFound = False
2796 for node1_elem in node1_elems:
2797 if not isVolumeFound:
2798 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2799 nb_nodes = self.GetElemNbNodes(node1_elem)
2800 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2801 volume_elem = node1_elem
2802 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2803 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2804 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2805 isVolumeFound = True
2806 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2807 self.SplitQuad([face_id], False) # diagonal 2-4
2808 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2809 isVolumeFound = True
2810 self.SplitQuad([face_id], True) # diagonal 1-3
2811 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2812 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2813 isVolumeFound = True
2814 self.SplitQuad([face_id], True) # diagonal 1-3
2816 ## @brief Splits hexahedrons into tetrahedrons.
2818 # This operation uses pattern mapping functionality for splitting.
2819 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2820 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2821 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2822 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2823 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2824 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2825 # @return TRUE in case of success, FALSE otherwise.
2826 # @ingroup l1_auxiliary
2827 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2828 # Pattern: 5.---------.6
2833 # (0,0,1) 4.---------.7 * |
2840 # (0,0,0) 0.---------.3
2841 pattern_tetra = "!!! Nb of points: \n 8 \n\
2851 !!! Indices of points of 6 tetras: \n\
2859 pattern = self.smeshpyD.GetPattern()
2860 isDone = pattern.LoadFromFile(pattern_tetra)
2862 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2865 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2866 isDone = pattern.MakeMesh(self.mesh, False, False)
2867 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2869 # split quafrangle faces near triangular facets of volumes
2870 self.SplitQuadsNearTriangularFacets()
2874 ## @brief Split hexahedrons into prisms.
2876 # Uses the pattern mapping functionality for splitting.
2877 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2878 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2879 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2880 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2881 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2882 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2883 # @return TRUE in case of success, FALSE otherwise.
2884 # @ingroup l1_auxiliary
2885 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2886 # Pattern: 5.---------.6
2891 # (0,0,1) 4.---------.7 |
2898 # (0,0,0) 0.---------.3
2899 pattern_prism = "!!! Nb of points: \n 8 \n\
2909 !!! Indices of points of 2 prisms: \n\
2913 pattern = self.smeshpyD.GetPattern()
2914 isDone = pattern.LoadFromFile(pattern_prism)
2916 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2919 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2920 isDone = pattern.MakeMesh(self.mesh, False, False)
2921 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2923 # Splits quafrangle faces near triangular facets of volumes
2924 self.SplitQuadsNearTriangularFacets()
2928 ## Smoothes elements
2929 # @param IDsOfElements the list if ids of elements to smooth
2930 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2931 # Note that nodes built on edges and boundary nodes are always fixed.
2932 # @param MaxNbOfIterations the maximum number of iterations
2933 # @param MaxAspectRatio varies in range [1.0, inf]
2934 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2935 # @return TRUE in case of success, FALSE otherwise.
2936 # @ingroup l2_modif_smooth
2937 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2938 MaxNbOfIterations, MaxAspectRatio, Method):
2939 if IDsOfElements == []:
2940 IDsOfElements = self.GetElementsId()
2941 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2942 self.mesh.SetParameters(Parameters)
2943 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2944 MaxNbOfIterations, MaxAspectRatio, Method)
2946 ## Smoothes elements which belong to the given object
2947 # @param theObject the object to smooth
2948 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2949 # Note that nodes built on edges and boundary nodes are always fixed.
2950 # @param MaxNbOfIterations the maximum number of iterations
2951 # @param MaxAspectRatio varies in range [1.0, inf]
2952 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2953 # @return TRUE in case of success, FALSE otherwise.
2954 # @ingroup l2_modif_smooth
2955 def SmoothObject(self, theObject, IDsOfFixedNodes,
2956 MaxNbOfIterations, MaxAspectRatio, Method):
2957 if ( isinstance( theObject, Mesh )):
2958 theObject = theObject.GetMesh()
2959 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2960 MaxNbOfIterations, MaxAspectRatio, Method)
2962 ## Parametrically smoothes the given elements
2963 # @param IDsOfElements the list if ids of elements to smooth
2964 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2965 # Note that nodes built on edges and boundary nodes are always fixed.
2966 # @param MaxNbOfIterations the maximum number of iterations
2967 # @param MaxAspectRatio varies in range [1.0, inf]
2968 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2969 # @return TRUE in case of success, FALSE otherwise.
2970 # @ingroup l2_modif_smooth
2971 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2972 MaxNbOfIterations, MaxAspectRatio, Method):
2973 if IDsOfElements == []:
2974 IDsOfElements = self.GetElementsId()
2975 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2976 self.mesh.SetParameters(Parameters)
2977 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2978 MaxNbOfIterations, MaxAspectRatio, Method)
2980 ## Parametrically smoothes the elements which belong to the given object
2981 # @param theObject the object to smooth
2982 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2983 # Note that nodes built on edges and boundary nodes are always fixed.
2984 # @param MaxNbOfIterations the maximum number of iterations
2985 # @param MaxAspectRatio varies in range [1.0, inf]
2986 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2987 # @return TRUE in case of success, FALSE otherwise.
2988 # @ingroup l2_modif_smooth
2989 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2990 MaxNbOfIterations, MaxAspectRatio, Method):
2991 if ( isinstance( theObject, Mesh )):
2992 theObject = theObject.GetMesh()
2993 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2994 MaxNbOfIterations, MaxAspectRatio, Method)
2996 ## Converts the mesh to quadratic, deletes old elements, replacing
2997 # them with quadratic with the same id.
2998 # @param theForce3d new node creation method:
2999 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
3000 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3001 # @ingroup l2_modif_tofromqu
3002 def ConvertToQuadratic(self, theForce3d):
3003 self.editor.ConvertToQuadratic(theForce3d)
3005 ## Converts the mesh from quadratic to ordinary,
3006 # deletes old quadratic elements, \n replacing
3007 # them with ordinary mesh elements with the same id.
3008 # @return TRUE in case of success, FALSE otherwise.
3009 # @ingroup l2_modif_tofromqu
3010 def ConvertFromQuadratic(self):
3011 return self.editor.ConvertFromQuadratic()
3013 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3014 # @return TRUE if operation has been completed successfully, FALSE otherwise
3015 # @ingroup l2_modif_edit
3016 def Make2DMeshFrom3D(self):
3017 return self.editor. Make2DMeshFrom3D()
3019 ## Renumber mesh nodes
3020 # @ingroup l2_modif_renumber
3021 def RenumberNodes(self):
3022 self.editor.RenumberNodes()
3024 ## Renumber mesh elements
3025 # @ingroup l2_modif_renumber
3026 def RenumberElements(self):
3027 self.editor.RenumberElements()
3029 ## Generates new elements by rotation of the elements around the axis
3030 # @param IDsOfElements the list of ids of elements to sweep
3031 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3032 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3033 # @param NbOfSteps the number of steps
3034 # @param Tolerance tolerance
3035 # @param MakeGroups forces the generation of new groups from existing ones
3036 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3037 # of all steps, else - size of each step
3038 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3039 # @ingroup l2_modif_extrurev
3040 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3041 MakeGroups=False, TotalAngle=False):
3043 if isinstance(AngleInRadians,str):
3045 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3047 AngleInRadians = DegreesToRadians(AngleInRadians)
3048 if IDsOfElements == []:
3049 IDsOfElements = self.GetElementsId()
3050 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3051 Axis = self.smeshpyD.GetAxisStruct(Axis)
3052 Axis,AxisParameters = ParseAxisStruct(Axis)
3053 if TotalAngle and NbOfSteps:
3054 AngleInRadians /= NbOfSteps
3055 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3056 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3057 self.mesh.SetParameters(Parameters)
3059 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3060 AngleInRadians, NbOfSteps, Tolerance)
3061 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3064 ## Generates new elements by rotation of the elements of object around the axis
3065 # @param theObject object which elements should be sweeped
3066 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3067 # @param AngleInRadians the angle of Rotation
3068 # @param NbOfSteps number of steps
3069 # @param Tolerance tolerance
3070 # @param MakeGroups forces the generation of new groups from existing ones
3071 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3072 # of all steps, else - size of each step
3073 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3074 # @ingroup l2_modif_extrurev
3075 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3076 MakeGroups=False, TotalAngle=False):
3078 if isinstance(AngleInRadians,str):
3080 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3082 AngleInRadians = DegreesToRadians(AngleInRadians)
3083 if ( isinstance( theObject, Mesh )):
3084 theObject = theObject.GetMesh()
3085 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3086 Axis = self.smeshpyD.GetAxisStruct(Axis)
3087 Axis,AxisParameters = ParseAxisStruct(Axis)
3088 if TotalAngle and NbOfSteps:
3089 AngleInRadians /= NbOfSteps
3090 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3091 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3092 self.mesh.SetParameters(Parameters)
3094 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3095 NbOfSteps, Tolerance)
3096 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3099 ## Generates new elements by rotation of the elements of object around the axis
3100 # @param theObject object which elements should be sweeped
3101 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3102 # @param AngleInRadians the angle of Rotation
3103 # @param NbOfSteps number of steps
3104 # @param Tolerance tolerance
3105 # @param MakeGroups forces the generation of new groups from existing ones
3106 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3107 # of all steps, else - size of each step
3108 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3109 # @ingroup l2_modif_extrurev
3110 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3111 MakeGroups=False, TotalAngle=False):
3113 if isinstance(AngleInRadians,str):
3115 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3117 AngleInRadians = DegreesToRadians(AngleInRadians)
3118 if ( isinstance( theObject, Mesh )):
3119 theObject = theObject.GetMesh()
3120 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3121 Axis = self.smeshpyD.GetAxisStruct(Axis)
3122 Axis,AxisParameters = ParseAxisStruct(Axis)
3123 if TotalAngle and NbOfSteps:
3124 AngleInRadians /= NbOfSteps
3125 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3126 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3127 self.mesh.SetParameters(Parameters)
3129 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3130 NbOfSteps, Tolerance)
3131 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3134 ## Generates new elements by rotation of the elements of object around the axis
3135 # @param theObject object which elements should be sweeped
3136 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3137 # @param AngleInRadians the angle of Rotation
3138 # @param NbOfSteps number of steps
3139 # @param Tolerance tolerance
3140 # @param MakeGroups forces the generation of new groups from existing ones
3141 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3142 # of all steps, else - size of each step
3143 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3144 # @ingroup l2_modif_extrurev
3145 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3146 MakeGroups=False, TotalAngle=False):
3148 if isinstance(AngleInRadians,str):
3150 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3152 AngleInRadians = DegreesToRadians(AngleInRadians)
3153 if ( isinstance( theObject, Mesh )):
3154 theObject = theObject.GetMesh()
3155 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3156 Axis = self.smeshpyD.GetAxisStruct(Axis)
3157 Axis,AxisParameters = ParseAxisStruct(Axis)
3158 if TotalAngle and NbOfSteps:
3159 AngleInRadians /= NbOfSteps
3160 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3161 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3162 self.mesh.SetParameters(Parameters)
3164 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3165 NbOfSteps, Tolerance)
3166 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3169 ## Generates new elements by extrusion of the elements with given ids
3170 # @param IDsOfElements the list of elements ids for extrusion
3171 # @param StepVector vector, defining the direction and value of extrusion
3172 # @param NbOfSteps the number of steps
3173 # @param MakeGroups forces the generation of new groups from existing ones
3174 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3175 # @ingroup l2_modif_extrurev
3176 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3177 if IDsOfElements == []:
3178 IDsOfElements = self.GetElementsId()
3179 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3180 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3181 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3182 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3183 Parameters = StepVectorParameters + var_separator + Parameters
3184 self.mesh.SetParameters(Parameters)
3186 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3187 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3190 ## Generates new elements by extrusion of the elements with given ids
3191 # @param IDsOfElements is ids of elements
3192 # @param StepVector vector, defining the direction and value of extrusion
3193 # @param NbOfSteps the number of steps
3194 # @param ExtrFlags sets flags for extrusion
3195 # @param SewTolerance uses for comparing locations of nodes if flag
3196 # EXTRUSION_FLAG_SEW is set
3197 # @param MakeGroups forces the generation of new groups from existing ones
3198 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3199 # @ingroup l2_modif_extrurev
3200 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3201 ExtrFlags, SewTolerance, MakeGroups=False):
3202 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3203 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3205 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3206 ExtrFlags, SewTolerance)
3207 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3208 ExtrFlags, SewTolerance)
3211 ## Generates new elements by extrusion of the elements which belong to the object
3212 # @param theObject the 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 forces the generation of 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 ExtrusionSweepObject(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.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3229 self.editor.ExtrusionSweepObject(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 to generate 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 ExtrusionSweepObject1D(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.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3250 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3253 ## Generates new elements by extrusion of the elements which belong to the object
3254 # @param theObject object which elements should be processed
3255 # @param StepVector vector, defining the direction and value of extrusion
3256 # @param NbOfSteps the number of steps
3257 # @param MakeGroups forces the generation of new groups from existing ones
3258 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3259 # @ingroup l2_modif_extrurev
3260 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3261 if ( isinstance( theObject, Mesh )):
3262 theObject = theObject.GetMesh()
3263 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3264 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3265 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3266 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3267 Parameters = StepVectorParameters + var_separator + Parameters
3268 self.mesh.SetParameters(Parameters)
3270 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3271 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3276 ## Generates new elements by extrusion of the given elements
3277 # The path of extrusion must be a meshed edge.
3278 # @param Base mesh or list of ids of elements for extrusion
3279 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3280 # @param NodeStart the start node from Path. Defines the direction of extrusion
3281 # @param HasAngles allows the shape to be rotated around the path
3282 # to get the resulting mesh in a helical fashion
3283 # @param Angles list of angles in radians
3284 # @param LinearVariation forces the computation of rotation angles as linear
3285 # variation of the given Angles along path steps
3286 # @param HasRefPoint allows using the reference point
3287 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3288 # The User can specify any point as the Reference Point.
3289 # @param MakeGroups forces the generation of new groups from existing ones
3290 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3291 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3292 # only SMESH::Extrusion_Error otherwise
3293 # @ingroup l2_modif_extrurev
3294 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3295 HasAngles, Angles, LinearVariation,
3296 HasRefPoint, RefPoint, MakeGroups, ElemType):
3297 Angles,AnglesParameters = ParseAngles(Angles)
3298 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3299 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3300 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3302 Parameters = AnglesParameters + var_separator + RefPointParameters
3303 self.mesh.SetParameters(Parameters)
3305 if isinstance(Base,list):
3307 if Base == []: IDsOfElements = self.GetElementsId()
3308 else: IDsOfElements = Base
3309 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3310 HasAngles, Angles, LinearVariation,
3311 HasRefPoint, RefPoint, MakeGroups, ElemType)
3313 if isinstance(Base,Mesh):
3314 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3315 HasAngles, Angles, LinearVariation,
3316 HasRefPoint, RefPoint, MakeGroups, ElemType)
3318 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3321 ## Generates new elements by extrusion of the given elements
3322 # The path of extrusion must be a meshed edge.
3323 # @param IDsOfElements ids of elements
3324 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3325 # @param PathShape shape(edge) defines the sub-mesh for the path
3326 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3327 # @param HasAngles allows the shape to be rotated around the path
3328 # to get the resulting mesh in a helical fashion
3329 # @param Angles list of angles in radians
3330 # @param HasRefPoint allows using the reference point
3331 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3332 # The User can specify any point as the Reference Point.
3333 # @param MakeGroups forces the generation of new groups from existing ones
3334 # @param LinearVariation forces the computation of rotation angles as linear
3335 # variation of the given Angles along path steps
3336 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3337 # only SMESH::Extrusion_Error otherwise
3338 # @ingroup l2_modif_extrurev
3339 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3340 HasAngles, Angles, HasRefPoint, RefPoint,
3341 MakeGroups=False, LinearVariation=False):
3342 Angles,AnglesParameters = ParseAngles(Angles)
3343 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3344 if IDsOfElements == []:
3345 IDsOfElements = self.GetElementsId()
3346 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3347 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3349 if ( isinstance( PathMesh, Mesh )):
3350 PathMesh = PathMesh.GetMesh()
3351 if HasAngles and Angles and LinearVariation:
3352 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3354 Parameters = AnglesParameters + var_separator + RefPointParameters
3355 self.mesh.SetParameters(Parameters)
3357 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3358 PathShape, NodeStart, HasAngles,
3359 Angles, HasRefPoint, RefPoint)
3360 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3361 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3363 ## Generates new elements by extrusion of the elements which belong to the object
3364 # The path of extrusion must be a meshed edge.
3365 # @param theObject the object which elements should be processed
3366 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3367 # @param PathShape shape(edge) defines the sub-mesh for the path
3368 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3369 # @param HasAngles allows the shape to be rotated around the path
3370 # to get the resulting mesh in a helical fashion
3371 # @param Angles list of angles
3372 # @param HasRefPoint allows using the reference point
3373 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3374 # The User can specify any point as the Reference Point.
3375 # @param MakeGroups forces the generation of new groups from existing ones
3376 # @param LinearVariation forces the computation of rotation angles as linear
3377 # variation of the given Angles along path steps
3378 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3379 # only SMESH::Extrusion_Error otherwise
3380 # @ingroup l2_modif_extrurev
3381 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3382 HasAngles, Angles, HasRefPoint, RefPoint,
3383 MakeGroups=False, LinearVariation=False):
3384 Angles,AnglesParameters = ParseAngles(Angles)
3385 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3386 if ( isinstance( theObject, Mesh )):
3387 theObject = theObject.GetMesh()
3388 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3389 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3390 if ( isinstance( PathMesh, Mesh )):
3391 PathMesh = PathMesh.GetMesh()
3392 if HasAngles and Angles and LinearVariation:
3393 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3395 Parameters = AnglesParameters + var_separator + RefPointParameters
3396 self.mesh.SetParameters(Parameters)
3398 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3399 PathShape, NodeStart, HasAngles,
3400 Angles, HasRefPoint, RefPoint)
3401 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3402 NodeStart, HasAngles, Angles, HasRefPoint,
3405 ## Generates new elements by extrusion of the elements which belong to the object
3406 # The path of extrusion must be a meshed edge.
3407 # @param theObject the object which elements should be processed
3408 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3409 # @param PathShape shape(edge) defines the sub-mesh for the path
3410 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3411 # @param HasAngles allows the shape to be rotated around the path
3412 # to get the resulting mesh in a helical fashion
3413 # @param Angles list of angles
3414 # @param HasRefPoint allows using the reference point
3415 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3416 # The User can specify any point as the Reference Point.
3417 # @param MakeGroups forces the generation of new groups from existing ones
3418 # @param LinearVariation forces the computation of rotation angles as linear
3419 # variation of the given Angles along path steps
3420 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3421 # only SMESH::Extrusion_Error otherwise
3422 # @ingroup l2_modif_extrurev
3423 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3424 HasAngles, Angles, HasRefPoint, RefPoint,
3425 MakeGroups=False, LinearVariation=False):
3426 Angles,AnglesParameters = ParseAngles(Angles)
3427 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3428 if ( isinstance( theObject, Mesh )):
3429 theObject = theObject.GetMesh()
3430 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3431 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3432 if ( isinstance( PathMesh, Mesh )):
3433 PathMesh = PathMesh.GetMesh()
3434 if HasAngles and Angles and LinearVariation:
3435 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3437 Parameters = AnglesParameters + var_separator + RefPointParameters
3438 self.mesh.SetParameters(Parameters)
3440 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3441 PathShape, NodeStart, HasAngles,
3442 Angles, HasRefPoint, RefPoint)
3443 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3444 NodeStart, HasAngles, Angles, HasRefPoint,
3447 ## Generates new elements by extrusion of the elements which belong to the object
3448 # The path of extrusion must be a meshed edge.
3449 # @param theObject the object which elements should be processed
3450 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3451 # @param PathShape shape(edge) defines the sub-mesh for the path
3452 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3453 # @param HasAngles allows the shape to be rotated around the path
3454 # to get the resulting mesh in a helical fashion
3455 # @param Angles list of angles
3456 # @param HasRefPoint allows using the reference point
3457 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3458 # The User can specify any point as the Reference Point.
3459 # @param MakeGroups forces the generation of new groups from existing ones
3460 # @param LinearVariation forces the computation of rotation angles as linear
3461 # variation of the given Angles along path steps
3462 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3463 # only SMESH::Extrusion_Error otherwise
3464 # @ingroup l2_modif_extrurev
3465 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3466 HasAngles, Angles, HasRefPoint, RefPoint,
3467 MakeGroups=False, LinearVariation=False):
3468 Angles,AnglesParameters = ParseAngles(Angles)
3469 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3470 if ( isinstance( theObject, Mesh )):
3471 theObject = theObject.GetMesh()
3472 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3473 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3474 if ( isinstance( PathMesh, Mesh )):
3475 PathMesh = PathMesh.GetMesh()
3476 if HasAngles and Angles and LinearVariation:
3477 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3479 Parameters = AnglesParameters + var_separator + RefPointParameters
3480 self.mesh.SetParameters(Parameters)
3482 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3483 PathShape, NodeStart, HasAngles,
3484 Angles, HasRefPoint, RefPoint)
3485 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3486 NodeStart, HasAngles, Angles, HasRefPoint,
3489 ## Creates a symmetrical copy of mesh elements
3490 # @param IDsOfElements 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 Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3495 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3496 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3497 # @ingroup l2_modif_trsf
3498 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
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 self.mesh.SetParameters(Parameters)
3505 if Copy and MakeGroups:
3506 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3507 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3510 ## Creates a new mesh by a symmetrical copy of mesh elements
3511 # @param IDsOfElements the list of elements ids
3512 # @param Mirror is AxisStruct or geom object (point, line, plane)
3513 # @param theMirrorType is POINT, AXIS or PLANE
3514 # If the Mirror is a geom object this parameter is unnecessary
3515 # @param MakeGroups to generate new groups from existing ones
3516 # @param NewMeshName a name of the new mesh to create
3517 # @return instance of Mesh class
3518 # @ingroup l2_modif_trsf
3519 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3520 if IDsOfElements == []:
3521 IDsOfElements = self.GetElementsId()
3522 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3523 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3524 Mirror,Parameters = ParseAxisStruct(Mirror)
3525 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3526 MakeGroups, NewMeshName)
3527 mesh.SetParameters(Parameters)
3528 return Mesh(self.smeshpyD,self.geompyD,mesh)
3530 ## Creates 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 is POINT, AXIS or PLANE
3534 # If the Mirror is a geom object this parameter is unnecessary
3535 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3536 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3537 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3538 # @ingroup l2_modif_trsf
3539 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
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 self.mesh.SetParameters(Parameters)
3546 if Copy and MakeGroups:
3547 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3548 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3551 ## Creates a new mesh by a symmetrical copy of the object
3552 # @param theObject mesh, submesh or group
3553 # @param Mirror AxisStruct or geom object (point, line, plane)
3554 # @param theMirrorType POINT, AXIS or PLANE
3555 # If the Mirror is a geom object this parameter is unnecessary
3556 # @param MakeGroups forces the generation of new groups from existing ones
3557 # @param NewMeshName the name of the new mesh to create
3558 # @return instance of Mesh class
3559 # @ingroup l2_modif_trsf
3560 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3561 if ( isinstance( theObject, Mesh )):
3562 theObject = theObject.GetMesh()
3563 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3564 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3565 Mirror,Parameters = ParseAxisStruct(Mirror)
3566 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3567 MakeGroups, NewMeshName)
3568 mesh.SetParameters(Parameters)
3569 return Mesh( self.smeshpyD,self.geompyD,mesh )
3571 ## Translates the elements
3572 # @param IDsOfElements list of elements ids
3573 # @param Vector the direction of translation (DirStruct or vector)
3574 # @param Copy allows copying the translated elements
3575 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3576 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3577 # @ingroup l2_modif_trsf
3578 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3579 if IDsOfElements == []:
3580 IDsOfElements = self.GetElementsId()
3581 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3582 Vector = self.smeshpyD.GetDirStruct(Vector)
3583 Vector,Parameters = ParseDirStruct(Vector)
3584 self.mesh.SetParameters(Parameters)
3585 if Copy and MakeGroups:
3586 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3587 self.editor.Translate(IDsOfElements, Vector, Copy)
3590 ## Creates a new mesh of translated elements
3591 # @param IDsOfElements list of elements ids
3592 # @param Vector the direction of translation (DirStruct or vector)
3593 # @param MakeGroups forces the generation of new groups from existing ones
3594 # @param NewMeshName the name of the newly created mesh
3595 # @return instance of Mesh class
3596 # @ingroup l2_modif_trsf
3597 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3598 if IDsOfElements == []:
3599 IDsOfElements = self.GetElementsId()
3600 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3601 Vector = self.smeshpyD.GetDirStruct(Vector)
3602 Vector,Parameters = ParseDirStruct(Vector)
3603 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3604 mesh.SetParameters(Parameters)
3605 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3607 ## Translates the object
3608 # @param theObject the object to translate (mesh, submesh, or group)
3609 # @param Vector direction of translation (DirStruct or geom vector)
3610 # @param Copy allows copying the translated elements
3611 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3612 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3613 # @ingroup l2_modif_trsf
3614 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3615 if ( isinstance( theObject, Mesh )):
3616 theObject = theObject.GetMesh()
3617 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3618 Vector = self.smeshpyD.GetDirStruct(Vector)
3619 Vector,Parameters = ParseDirStruct(Vector)
3620 self.mesh.SetParameters(Parameters)
3621 if Copy and MakeGroups:
3622 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3623 self.editor.TranslateObject(theObject, Vector, Copy)
3626 ## Creates a new mesh from the translated object
3627 # @param theObject the object to translate (mesh, submesh, or group)
3628 # @param Vector the direction of translation (DirStruct or geom vector)
3629 # @param MakeGroups forces the generation of new groups from existing ones
3630 # @param NewMeshName the name of the newly created mesh
3631 # @return instance of Mesh class
3632 # @ingroup l2_modif_trsf
3633 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3634 if (isinstance(theObject, Mesh)):
3635 theObject = theObject.GetMesh()
3636 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3637 Vector = self.smeshpyD.GetDirStruct(Vector)
3638 Vector,Parameters = ParseDirStruct(Vector)
3639 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3640 mesh.SetParameters(Parameters)
3641 return Mesh( self.smeshpyD, self.geompyD, mesh )
3645 ## Scales the object
3646 # @param theObject - the object to translate (mesh, submesh, or group)
3647 # @param thePoint - base point for scale
3648 # @param theScaleFact - list of 1-3 scale factors for axises
3649 # @param Copy - allows copying the translated elements
3650 # @param MakeGroups - forces the generation of new groups from existing
3652 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3653 # empty list otherwise
3654 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3655 if ( isinstance( theObject, Mesh )):
3656 theObject = theObject.GetMesh()
3657 if ( isinstance( theObject, list )):
3658 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3660 thePoint, Parameters = ParsePointStruct(thePoint)
3661 self.mesh.SetParameters(Parameters)
3663 if Copy and MakeGroups:
3664 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3665 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3668 ## Creates a new mesh from the translated object
3669 # @param theObject - the object to translate (mesh, submesh, or group)
3670 # @param thePoint - base point for scale
3671 # @param theScaleFact - list of 1-3 scale factors for axises
3672 # @param MakeGroups - forces the generation of new groups from existing ones
3673 # @param NewMeshName - the name of the newly created mesh
3674 # @return instance of Mesh class
3675 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3676 if (isinstance(theObject, Mesh)):
3677 theObject = theObject.GetMesh()
3678 if ( isinstance( theObject, list )):
3679 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3681 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3682 MakeGroups, NewMeshName)
3683 #mesh.SetParameters(Parameters)
3684 return Mesh( self.smeshpyD, self.geompyD, mesh )
3688 ## Rotates the elements
3689 # @param IDsOfElements list of elements ids
3690 # @param Axis the axis of rotation (AxisStruct or geom line)
3691 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3692 # @param Copy allows copying the rotated elements
3693 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3694 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3695 # @ingroup l2_modif_trsf
3696 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3698 if isinstance(AngleInRadians,str):
3700 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3702 AngleInRadians = DegreesToRadians(AngleInRadians)
3703 if IDsOfElements == []:
3704 IDsOfElements = self.GetElementsId()
3705 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3706 Axis = self.smeshpyD.GetAxisStruct(Axis)
3707 Axis,AxisParameters = ParseAxisStruct(Axis)
3708 Parameters = AxisParameters + var_separator + Parameters
3709 self.mesh.SetParameters(Parameters)
3710 if Copy and MakeGroups:
3711 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3712 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3715 ## Creates a new mesh of rotated elements
3716 # @param IDsOfElements list of element ids
3717 # @param Axis the axis of rotation (AxisStruct or geom line)
3718 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3719 # @param MakeGroups forces the generation of new groups from existing ones
3720 # @param NewMeshName the name of the newly created mesh
3721 # @return instance of Mesh class
3722 # @ingroup l2_modif_trsf
3723 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3725 if isinstance(AngleInRadians,str):
3727 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3729 AngleInRadians = DegreesToRadians(AngleInRadians)
3730 if IDsOfElements == []:
3731 IDsOfElements = self.GetElementsId()
3732 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3733 Axis = self.smeshpyD.GetAxisStruct(Axis)
3734 Axis,AxisParameters = ParseAxisStruct(Axis)
3735 Parameters = AxisParameters + var_separator + Parameters
3736 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3737 MakeGroups, NewMeshName)
3738 mesh.SetParameters(Parameters)
3739 return Mesh( self.smeshpyD, self.geompyD, mesh )
3741 ## Rotates the object
3742 # @param theObject the object to rotate( mesh, submesh, or group)
3743 # @param Axis the axis of rotation (AxisStruct or geom line)
3744 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3745 # @param Copy allows copying the rotated elements
3746 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3747 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3748 # @ingroup l2_modif_trsf
3749 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3751 if isinstance(AngleInRadians,str):
3753 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3755 AngleInRadians = DegreesToRadians(AngleInRadians)
3756 if (isinstance(theObject, Mesh)):
3757 theObject = theObject.GetMesh()
3758 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3759 Axis = self.smeshpyD.GetAxisStruct(Axis)
3760 Axis,AxisParameters = ParseAxisStruct(Axis)
3761 Parameters = AxisParameters + ":" + Parameters
3762 self.mesh.SetParameters(Parameters)
3763 if Copy and MakeGroups:
3764 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3765 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3768 ## Creates a new mesh from the rotated object
3769 # @param theObject the object to rotate (mesh, submesh, or group)
3770 # @param Axis the axis of rotation (AxisStruct or geom line)
3771 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3772 # @param MakeGroups forces the generation of new groups from existing ones
3773 # @param NewMeshName the name of the newly created mesh
3774 # @return instance of Mesh class
3775 # @ingroup l2_modif_trsf
3776 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3778 if isinstance(AngleInRadians,str):
3780 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3782 AngleInRadians = DegreesToRadians(AngleInRadians)
3783 if (isinstance( theObject, Mesh )):
3784 theObject = theObject.GetMesh()
3785 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3786 Axis = self.smeshpyD.GetAxisStruct(Axis)
3787 Axis,AxisParameters = ParseAxisStruct(Axis)
3788 Parameters = AxisParameters + ":" + Parameters
3789 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3790 MakeGroups, NewMeshName)
3791 mesh.SetParameters(Parameters)
3792 return Mesh( self.smeshpyD, self.geompyD, mesh )
3794 ## Finds groups of ajacent nodes within Tolerance.
3795 # @param Tolerance the value of tolerance
3796 # @return the list of groups of nodes
3797 # @ingroup l2_modif_trsf
3798 def FindCoincidentNodes (self, Tolerance):
3799 return self.editor.FindCoincidentNodes(Tolerance)
3801 ## Finds groups of ajacent nodes within Tolerance.
3802 # @param Tolerance the value of tolerance
3803 # @param SubMeshOrGroup SubMesh or Group
3804 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3805 # @return the list of groups of nodes
3806 # @ingroup l2_modif_trsf
3807 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3808 if (isinstance( SubMeshOrGroup, Mesh )):
3809 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3810 if not isinstance( ExceptSubMeshOrGroups, list):
3811 ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
3812 if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
3813 ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
3814 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
3817 # @param GroupsOfNodes the list of groups of nodes
3818 # @ingroup l2_modif_trsf
3819 def MergeNodes (self, GroupsOfNodes):
3820 self.editor.MergeNodes(GroupsOfNodes)
3822 ## Finds the elements built on the same nodes.
3823 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3824 # @return a list of groups of equal elements
3825 # @ingroup l2_modif_trsf
3826 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3827 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3828 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3829 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3831 ## Merges elements in each given group.
3832 # @param GroupsOfElementsID groups of elements for merging
3833 # @ingroup l2_modif_trsf
3834 def MergeElements(self, GroupsOfElementsID):
3835 self.editor.MergeElements(GroupsOfElementsID)
3837 ## Leaves one element and removes all other elements built on the same nodes.
3838 # @ingroup l2_modif_trsf
3839 def MergeEqualElements(self):
3840 self.editor.MergeEqualElements()
3842 ## Sews free borders
3843 # @return SMESH::Sew_Error
3844 # @ingroup l2_modif_trsf
3845 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3846 FirstNodeID2, SecondNodeID2, LastNodeID2,
3847 CreatePolygons, CreatePolyedrs):
3848 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3849 FirstNodeID2, SecondNodeID2, LastNodeID2,
3850 CreatePolygons, CreatePolyedrs)
3852 ## Sews conform free borders
3853 # @return SMESH::Sew_Error
3854 # @ingroup l2_modif_trsf
3855 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3856 FirstNodeID2, SecondNodeID2):
3857 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3858 FirstNodeID2, SecondNodeID2)
3860 ## Sews border to side
3861 # @return SMESH::Sew_Error
3862 # @ingroup l2_modif_trsf
3863 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3864 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3865 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3866 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3868 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3869 # merged with the nodes of elements of Side2.
3870 # The number of elements in theSide1 and in theSide2 must be
3871 # equal and they should have similar nodal connectivity.
3872 # The nodes to merge should belong to side borders and
3873 # the first node should be linked to the second.
3874 # @return SMESH::Sew_Error
3875 # @ingroup l2_modif_trsf
3876 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3877 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3878 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3879 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3880 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3881 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3883 ## Sets new nodes for the given element.
3884 # @param ide the element id
3885 # @param newIDs nodes ids
3886 # @return If the number of nodes does not correspond to the type of element - returns false
3887 # @ingroup l2_modif_edit
3888 def ChangeElemNodes(self, ide, newIDs):
3889 return self.editor.ChangeElemNodes(ide, newIDs)
3891 ## If during the last operation of MeshEditor some nodes were
3892 # created, this method returns the list of their IDs, \n
3893 # if new nodes were not created - returns empty list
3894 # @return the list of integer values (can be empty)
3895 # @ingroup l1_auxiliary
3896 def GetLastCreatedNodes(self):
3897 return self.editor.GetLastCreatedNodes()
3899 ## If during the last operation of MeshEditor some elements were
3900 # created this method returns the list of their IDs, \n
3901 # if new elements were not created - returns empty list
3902 # @return the list of integer values (can be empty)
3903 # @ingroup l1_auxiliary
3904 def GetLastCreatedElems(self):
3905 return self.editor.GetLastCreatedElems()
3907 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3908 # @param theNodes identifiers of nodes to be doubled
3909 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3910 # nodes. If list of element identifiers is empty then nodes are doubled but
3911 # they not assigned to elements
3912 # @return TRUE if operation has been completed successfully, FALSE otherwise
3913 # @ingroup l2_modif_edit
3914 def DoubleNodes(self, theNodes, theModifiedElems):
3915 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3917 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3918 # This method provided for convenience works as DoubleNodes() described above.
3919 # @param theNodeId identifiers of node to be doubled
3920 # @param theModifiedElems identifiers of elements to be updated
3921 # @return TRUE if operation has been completed successfully, FALSE otherwise
3922 # @ingroup l2_modif_edit
3923 def DoubleNode(self, theNodeId, theModifiedElems):
3924 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3926 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3927 # This method provided for convenience works as DoubleNodes() described above.
3928 # @param theNodes group of nodes to be doubled
3929 # @param theModifiedElems group of elements to be updated.
3930 # @param theMakeGroup forces the generation of a group containing new nodes.
3931 # @return TRUE or a created group if operation has been completed successfully,
3932 # FALSE or None otherwise
3933 # @ingroup l2_modif_edit
3934 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3936 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3937 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3939 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3940 # This method provided for convenience works as DoubleNodes() described above.
3941 # @param theNodes list of groups of nodes to be doubled
3942 # @param theModifiedElems list of groups of elements to be updated.
3943 # @return TRUE if operation has been completed successfully, FALSE otherwise
3944 # @ingroup l2_modif_edit
3945 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3946 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3948 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3949 # @param theElems - the list of elements (edges or faces) to be replicated
3950 # The nodes for duplication could be found from these elements
3951 # @param theNodesNot - list of nodes to NOT replicate
3952 # @param theAffectedElems - the list of elements (cells and edges) to which the
3953 # replicated nodes should be associated to.
3954 # @return TRUE if operation has been completed successfully, FALSE otherwise
3955 # @ingroup l2_modif_edit
3956 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3957 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3959 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3960 # @param theElems - the list of elements (edges or faces) to be replicated
3961 # The nodes for duplication could be found from these elements
3962 # @param theNodesNot - list of nodes to NOT replicate
3963 # @param theShape - shape to detect affected elements (element which geometric center
3964 # located on or inside shape).
3965 # The replicated nodes should be associated to affected elements.
3966 # @return TRUE if operation has been completed successfully, FALSE otherwise
3967 # @ingroup l2_modif_edit
3968 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3969 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3971 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3972 # This method provided for convenience works as DoubleNodes() described above.
3973 # @param theElems - group of of elements (edges or faces) to be replicated
3974 # @param theNodesNot - group of nodes not to replicated
3975 # @param theAffectedElems - group of elements to which the replicated nodes
3976 # should be associated to.
3977 # @param theMakeGroup forces the generation of a group containing new elements.
3978 # @ingroup l2_modif_edit
3979 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3981 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3982 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3984 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3985 # This method provided for convenience works as DoubleNodes() described above.
3986 # @param theElems - group of of elements (edges or faces) to be replicated
3987 # @param theNodesNot - group of nodes not to replicated
3988 # @param theShape - shape to detect affected elements (element which geometric center
3989 # located on or inside shape).
3990 # The replicated nodes should be associated to affected elements.
3991 # @ingroup l2_modif_edit
3992 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3993 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3995 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3996 # This method provided for convenience works as DoubleNodes() described above.
3997 # @param theElems - list of groups of elements (edges or faces) to be replicated
3998 # @param theNodesNot - list of groups of nodes not to replicated
3999 # @param theAffectedElems - group of elements to which the replicated nodes
4000 # should be associated to.
4001 # @return TRUE if operation has been completed successfully, FALSE otherwise
4002 # @ingroup l2_modif_edit
4003 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
4004 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4006 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4007 # This method provided for convenience works as DoubleNodes() described above.
4008 # @param theElems - list of groups of elements (edges or faces) to be replicated
4009 # @param theNodesNot - list of groups of nodes not to replicated
4010 # @param theShape - shape to detect affected elements (element which geometric center
4011 # located on or inside shape).
4012 # The replicated nodes should be associated to affected elements.
4013 # @return TRUE if operation has been completed successfully, FALSE otherwise
4014 # @ingroup l2_modif_edit
4015 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4016 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4018 def _valueFromFunctor(self, funcType, elemId):
4019 fn = self.smeshpyD.GetFunctor(funcType)
4020 fn.SetMesh(self.mesh)
4021 if fn.GetElementType() == self.GetElementType(elemId, True):
4022 val = fn.GetValue(elemId)
4027 ## Get length of 1D element.
4028 # @param elemId mesh element ID
4029 # @return element's length value
4030 # @ingroup l1_measurements
4031 def GetLength(self, elemId):
4032 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4034 ## Get area of 2D element.
4035 # @param elemId mesh element ID
4036 # @return element's area value
4037 # @ingroup l1_measurements
4038 def GetArea(self, elemId):
4039 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4041 ## Get volume of 3D element.
4042 # @param elemId mesh element ID
4043 # @return element's volume value
4044 # @ingroup l1_measurements
4045 def GetVolume(self, elemId):
4046 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4048 ## Get maximum element length.
4049 # @param elemId mesh element ID
4050 # @return element's maximum length value
4051 # @ingroup l1_measurements
4052 def GetMaxElementLength(self, elemId):
4053 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4054 ftype = SMESH.FT_MaxElementLength3D
4056 ftype = SMESH.FT_MaxElementLength2D
4057 return self._valueFromFunctor(ftype, elemId)
4059 ## Get aspect ratio of 2D or 3D element.
4060 # @param elemId mesh element ID
4061 # @return element's aspect ratio value
4062 # @ingroup l1_measurements
4063 def GetAspectRatio(self, elemId):
4064 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4065 ftype = SMESH.FT_AspectRatio3D
4067 ftype = SMESH.FT_AspectRatio
4068 return self._valueFromFunctor(ftype, elemId)
4070 ## Get warping angle of 2D element.
4071 # @param elemId mesh element ID
4072 # @return element's warping angle value
4073 # @ingroup l1_measurements
4074 def GetWarping(self, elemId):
4075 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4077 ## Get minimum angle of 2D element.
4078 # @param elemId mesh element ID
4079 # @return element's minimum angle value
4080 # @ingroup l1_measurements
4081 def GetMinimumAngle(self, elemId):
4082 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4084 ## Get taper of 2D element.
4085 # @param elemId mesh element ID
4086 # @return element's taper value
4087 # @ingroup l1_measurements
4088 def GetTaper(self, elemId):
4089 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4091 ## Get skew of 2D element.
4092 # @param elemId mesh element ID
4093 # @return element's skew value
4094 # @ingroup l1_measurements
4095 def GetSkew(self, elemId):
4096 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4098 ## The mother class to define algorithm, it is not recommended to use it directly.
4101 # @ingroup l2_algorithms
4102 class Mesh_Algorithm:
4103 # @class Mesh_Algorithm
4104 # @brief Class Mesh_Algorithm
4106 #def __init__(self,smesh):
4114 ## Finds a hypothesis in the study by its type name and parameters.
4115 # Finds only the hypotheses created in smeshpyD engine.
4116 # @return SMESH.SMESH_Hypothesis
4117 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4118 study = smeshpyD.GetCurrentStudy()
4119 #to do: find component by smeshpyD object, not by its data type
4120 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4121 if scomp is not None:
4122 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4123 # Check if the root label of the hypotheses exists
4124 if res and hypRoot is not None:
4125 iter = study.NewChildIterator(hypRoot)
4126 # Check all published hypotheses
4128 hypo_so_i = iter.Value()
4129 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4130 if attr is not None:
4131 anIOR = attr.Value()
4132 hypo_o_i = salome.orb.string_to_object(anIOR)
4133 if hypo_o_i is not None:
4134 # Check if this is a hypothesis
4135 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4136 if hypo_i is not None:
4137 # Check if the hypothesis belongs to current engine
4138 if smeshpyD.GetObjectId(hypo_i) > 0:
4139 # Check if this is the required hypothesis
4140 if hypo_i.GetName() == hypname:
4142 if CompareMethod(hypo_i, args):
4156 ## Finds the algorithm in the study by its type name.
4157 # Finds only the algorithms, which have been created in smeshpyD engine.
4158 # @return SMESH.SMESH_Algo
4159 def FindAlgorithm (self, algoname, smeshpyD):
4160 study = smeshpyD.GetCurrentStudy()
4161 #to do: find component by smeshpyD object, not by its data type
4162 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4163 if scomp is not None:
4164 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4165 # Check if the root label of the algorithms exists
4166 if res and hypRoot is not None:
4167 iter = study.NewChildIterator(hypRoot)
4168 # Check all published algorithms
4170 algo_so_i = iter.Value()
4171 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4172 if attr is not None:
4173 anIOR = attr.Value()
4174 algo_o_i = salome.orb.string_to_object(anIOR)
4175 if algo_o_i is not None:
4176 # Check if this is an algorithm
4177 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4178 if algo_i is not None:
4179 # Checks if the algorithm belongs to the current engine
4180 if smeshpyD.GetObjectId(algo_i) > 0:
4181 # Check if this is the required algorithm
4182 if algo_i.GetName() == algoname:
4195 ## If the algorithm is global, returns 0; \n
4196 # else returns the submesh associated to this algorithm.
4197 def GetSubMesh(self):
4200 ## Returns the wrapped mesher.
4201 def GetAlgorithm(self):
4204 ## Gets the list of hypothesis that can be used with this algorithm
4205 def GetCompatibleHypothesis(self):
4208 mylist = self.algo.GetCompatibleHypothesis()
4211 ## Gets the name of the algorithm
4215 ## Sets the name to the algorithm
4216 def SetName(self, name):
4217 self.mesh.smeshpyD.SetName(self.algo, name)
4219 ## Gets the id of the algorithm
4221 return self.algo.GetId()
4224 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4226 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4227 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4229 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4231 self.Assign(algo, mesh, geom)
4235 def Assign(self, algo, mesh, geom):
4237 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4246 name = GetName(geom)
4249 name = mesh.geompyD.SubShapeName(geom, piece)
4250 mesh.geompyD.addToStudyInFather(piece, geom, name)
4252 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4255 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4256 TreatHypoStatus( status, algo.GetName(), name, True )
4258 def CompareHyp (self, hyp, args):
4259 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4262 def CompareEqualHyp (self, hyp, args):
4266 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4267 UseExisting=0, CompareMethod=""):
4270 if CompareMethod == "": CompareMethod = self.CompareHyp
4271 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4274 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4280 a = a + s + str(args[i])
4284 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4286 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4287 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4290 ## Returns entry of the shape to mesh in the study
4291 def MainShapeEntry(self):
4293 if not self.mesh or not self.mesh.GetMesh(): return entry
4294 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4295 study = self.mesh.smeshpyD.GetCurrentStudy()
4296 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4297 sobj = study.FindObjectIOR(ior)
4298 if sobj: entry = sobj.GetID()
4299 if not entry: return ""
4302 # Public class: Mesh_Segment
4303 # --------------------------
4305 ## Class to define a segment 1D algorithm for discretization
4308 # @ingroup l3_algos_basic
4309 class Mesh_Segment(Mesh_Algorithm):
4311 ## Private constructor.
4312 def __init__(self, mesh, geom=0):
4313 Mesh_Algorithm.__init__(self)
4314 self.Create(mesh, geom, "Regular_1D")
4316 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4317 # @param l for the length of segments that cut an edge
4318 # @param UseExisting if ==true - searches for an existing hypothesis created with
4319 # the same parameters, else (default) - creates a new one
4320 # @param p precision, used for calculation of the number of segments.
4321 # The precision should be a positive, meaningful value within the range [0,1].
4322 # In general, the number of segments is calculated with the formula:
4323 # nb = ceil((edge_length / l) - p)
4324 # Function ceil rounds its argument to the higher integer.
4325 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4326 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4327 # p=1 means rounding of (edge_length / l) to the lower integer.
4328 # Default value is 1e-07.
4329 # @return an instance of StdMeshers_LocalLength hypothesis
4330 # @ingroup l3_hypos_1dhyps
4331 def LocalLength(self, l, UseExisting=0, p=1e-07):
4332 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4333 CompareMethod=self.CompareLocalLength)
4339 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4340 def CompareLocalLength(self, hyp, args):
4341 if IsEqual(hyp.GetLength(), args[0]):
4342 return IsEqual(hyp.GetPrecision(), args[1])
4345 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4346 # @param length is optional maximal allowed length of segment, if it is omitted
4347 # the preestimated length is used that depends on geometry size
4348 # @param UseExisting if ==true - searches for an existing hypothesis created with
4349 # the same parameters, else (default) - create a new one
4350 # @return an instance of StdMeshers_MaxLength hypothesis
4351 # @ingroup l3_hypos_1dhyps
4352 def MaxSize(self, length=0.0, UseExisting=0):
4353 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4356 hyp.SetLength(length)
4358 # set preestimated length
4359 gen = self.mesh.smeshpyD
4360 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4361 self.mesh.GetMesh(), self.mesh.GetShape(),
4363 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4365 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4368 hyp.SetUsePreestimatedLength( length == 0.0 )
4371 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4372 # @param n for the number of segments that cut an edge
4373 # @param s for the scale factor (optional)
4374 # @param reversedEdges is a list of edges to mesh using reversed orientation
4375 # @param UseExisting if ==true - searches for an existing hypothesis created with
4376 # the same parameters, else (default) - create a new one
4377 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4378 # @ingroup l3_hypos_1dhyps
4379 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4380 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4381 reversedEdges, UseExisting = [], reversedEdges
4382 entry = self.MainShapeEntry()
4384 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4385 UseExisting=UseExisting,
4386 CompareMethod=self.CompareNumberOfSegments)
4388 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4389 UseExisting=UseExisting,
4390 CompareMethod=self.CompareNumberOfSegments)
4391 hyp.SetDistrType( 1 )
4392 hyp.SetScaleFactor(s)
4393 hyp.SetNumberOfSegments(n)
4394 hyp.SetReversedEdges( reversedEdges )
4395 hyp.SetObjectEntry( entry )
4399 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4400 def CompareNumberOfSegments(self, hyp, args):
4401 if hyp.GetNumberOfSegments() == args[0]:
4403 if hyp.GetReversedEdges() == args[1]:
4404 if not args[1] or hyp.GetObjectEntry() == args[2]:
4407 if hyp.GetReversedEdges() == args[2]:
4408 if not args[2] or hyp.GetObjectEntry() == args[3]:
4409 if hyp.GetDistrType() == 1:
4410 if IsEqual(hyp.GetScaleFactor(), args[1]):
4414 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4415 # @param start defines the length of the first segment
4416 # @param end defines the length of the last segment
4417 # @param reversedEdges is a list of edges to mesh using reversed orientation
4418 # @param UseExisting if ==true - searches for an existing hypothesis created with
4419 # the same parameters, else (default) - creates a new one
4420 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4421 # @ingroup l3_hypos_1dhyps
4422 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4423 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4424 reversedEdges, UseExisting = [], reversedEdges
4425 entry = self.MainShapeEntry()
4426 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4427 UseExisting=UseExisting,
4428 CompareMethod=self.CompareArithmetic1D)
4429 hyp.SetStartLength(start)
4430 hyp.SetEndLength(end)
4431 hyp.SetReversedEdges( reversedEdges )
4432 hyp.SetObjectEntry( entry )
4436 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4437 def CompareArithmetic1D(self, hyp, args):
4438 if IsEqual(hyp.GetLength(1), args[0]):
4439 if IsEqual(hyp.GetLength(0), args[1]):
4440 if hyp.GetReversedEdges() == args[2]:
4441 if not args[2] or hyp.GetObjectEntry() == args[3]:
4446 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4447 # on curve from 0 to 1 (additionally it is neecessary to check
4448 # orientation of edges and create list of reversed edges if it is
4449 # needed) and sets numbers of segments between given points (default
4450 # values are equals 1
4451 # @param points defines the list of parameters on curve
4452 # @param nbSegs defines the list of numbers of segments
4453 # @param reversedEdges is a list of edges to mesh using reversed orientation
4454 # @param UseExisting if ==true - searches for an existing hypothesis created with
4455 # the same parameters, else (default) - creates a new one
4456 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4457 # @ingroup l3_hypos_1dhyps
4458 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4459 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4460 reversedEdges, UseExisting = [], reversedEdges
4461 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4462 for i in range( len( reversedEdges )):
4463 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4464 entry = self.MainShapeEntry()
4465 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4466 UseExisting=UseExisting,
4467 CompareMethod=self.CompareFixedPoints1D)
4468 hyp.SetPoints(points)
4469 hyp.SetNbSegments(nbSegs)
4470 hyp.SetReversedEdges(reversedEdges)
4471 hyp.SetObjectEntry(entry)
4475 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4476 ## as the given arguments
4477 def CompareFixedPoints1D(self, hyp, args):
4478 if hyp.GetPoints() == args[0]:
4479 if hyp.GetNbSegments() == args[1]:
4480 if hyp.GetReversedEdges() == args[2]:
4481 if not args[2] or hyp.GetObjectEntry() == args[3]:
4487 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4488 # @param start defines the length of the first segment
4489 # @param end defines the length of the last segment
4490 # @param reversedEdges is a list of edges to mesh using reversed orientation
4491 # @param UseExisting if ==true - searches for an existing hypothesis created with
4492 # the same parameters, else (default) - creates a new one
4493 # @return an instance of StdMeshers_StartEndLength hypothesis
4494 # @ingroup l3_hypos_1dhyps
4495 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4496 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4497 reversedEdges, UseExisting = [], reversedEdges
4498 entry = self.MainShapeEntry()
4499 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4500 UseExisting=UseExisting,
4501 CompareMethod=self.CompareStartEndLength)
4502 hyp.SetStartLength(start)
4503 hyp.SetEndLength(end)
4504 hyp.SetReversedEdges( reversedEdges )
4505 hyp.SetObjectEntry( entry )
4508 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4509 def CompareStartEndLength(self, hyp, args):
4510 if IsEqual(hyp.GetLength(1), args[0]):
4511 if IsEqual(hyp.GetLength(0), args[1]):
4512 if hyp.GetReversedEdges() == args[2]:
4513 if not args[2] or hyp.GetObjectEntry() == args[3]:
4517 ## Defines "Deflection1D" hypothesis
4518 # @param d for the deflection
4519 # @param UseExisting if ==true - searches for an existing hypothesis created with
4520 # the same parameters, else (default) - create a new one
4521 # @ingroup l3_hypos_1dhyps
4522 def Deflection1D(self, d, UseExisting=0):
4523 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4524 CompareMethod=self.CompareDeflection1D)
4525 hyp.SetDeflection(d)
4528 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4529 def CompareDeflection1D(self, hyp, args):
4530 return IsEqual(hyp.GetDeflection(), args[0])
4532 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4533 # the opposite side in case of quadrangular faces
4534 # @ingroup l3_hypos_additi
4535 def Propagation(self):
4536 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4538 ## Defines "AutomaticLength" hypothesis
4539 # @param fineness for the fineness [0-1]
4540 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4541 # same parameters, else (default) - create a new one
4542 # @ingroup l3_hypos_1dhyps
4543 def AutomaticLength(self, fineness=0, UseExisting=0):
4544 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4545 CompareMethod=self.CompareAutomaticLength)
4546 hyp.SetFineness( fineness )
4549 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4550 def CompareAutomaticLength(self, hyp, args):
4551 return IsEqual(hyp.GetFineness(), args[0])
4553 ## Defines "SegmentLengthAroundVertex" hypothesis
4554 # @param length for the segment length
4555 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4556 # Any other integer value means that the hypothesis will be set on the
4557 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4558 # @param UseExisting if ==true - searches for an existing hypothesis created with
4559 # the same parameters, else (default) - creates a new one
4560 # @ingroup l3_algos_segmarv
4561 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4563 store_geom = self.geom
4564 if type(vertex) is types.IntType:
4565 if vertex == 0 or vertex == 1:
4566 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4574 if self.geom is None:
4575 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4577 name = GetName(self.geom)
4580 piece = self.mesh.geom
4581 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4582 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4584 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4586 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4588 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4589 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4591 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4592 CompareMethod=self.CompareLengthNearVertex)
4593 self.geom = store_geom
4594 hyp.SetLength( length )
4597 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4598 # @ingroup l3_algos_segmarv
4599 def CompareLengthNearVertex(self, hyp, args):
4600 return IsEqual(hyp.GetLength(), args[0])
4602 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4603 # If the 2D mesher sees that all boundary edges are quadratic,
4604 # it generates quadratic faces, else it generates linear faces using
4605 # medium nodes as if they are vertices.
4606 # The 3D mesher generates quadratic volumes only if all boundary faces
4607 # are quadratic, else it fails.
4609 # @ingroup l3_hypos_additi
4610 def QuadraticMesh(self):
4611 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4614 # Public class: Mesh_CompositeSegment
4615 # --------------------------
4617 ## Defines a segment 1D algorithm for discretization
4619 # @ingroup l3_algos_basic
4620 class Mesh_CompositeSegment(Mesh_Segment):
4622 ## Private constructor.
4623 def __init__(self, mesh, geom=0):
4624 self.Create(mesh, geom, "CompositeSegment_1D")
4627 # Public class: Mesh_Segment_Python
4628 # ---------------------------------
4630 ## Defines a segment 1D algorithm for discretization with python function
4632 # @ingroup l3_algos_basic
4633 class Mesh_Segment_Python(Mesh_Segment):
4635 ## Private constructor.
4636 def __init__(self, mesh, geom=0):
4637 import Python1dPlugin
4638 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4640 ## Defines "PythonSplit1D" hypothesis
4641 # @param n for the number of segments that cut an edge
4642 # @param func for the python function that calculates the length of all segments
4643 # @param UseExisting if ==true - searches for the existing hypothesis created with
4644 # the same parameters, else (default) - creates a new one
4645 # @ingroup l3_hypos_1dhyps
4646 def PythonSplit1D(self, n, func, UseExisting=0):
4647 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4648 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4649 hyp.SetNumberOfSegments(n)
4650 hyp.SetPythonLog10RatioFunction(func)
4653 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4654 def ComparePythonSplit1D(self, hyp, args):
4655 #if hyp.GetNumberOfSegments() == args[0]:
4656 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4660 # Public class: Mesh_Triangle
4661 # ---------------------------
4663 ## Defines a triangle 2D algorithm
4665 # @ingroup l3_algos_basic
4666 class Mesh_Triangle(Mesh_Algorithm):
4675 ## Private constructor.
4676 def __init__(self, mesh, algoType, geom=0):
4677 Mesh_Algorithm.__init__(self)
4679 self.algoType = algoType
4680 if algoType == MEFISTO:
4681 self.Create(mesh, geom, "MEFISTO_2D")
4683 elif algoType == BLSURF:
4685 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4686 #self.SetPhysicalMesh() - PAL19680
4687 elif algoType == NETGEN:
4689 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4691 elif algoType == NETGEN_2D:
4693 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4696 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4697 # @param area for the maximum area of each triangle
4698 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4699 # same parameters, else (default) - creates a new one
4701 # Only for algoType == MEFISTO || NETGEN_2D
4702 # @ingroup l3_hypos_2dhyps
4703 def MaxElementArea(self, area, UseExisting=0):
4704 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4705 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4706 CompareMethod=self.CompareMaxElementArea)
4707 elif self.algoType == NETGEN:
4708 hyp = self.Parameters(SIMPLE)
4709 hyp.SetMaxElementArea(area)
4712 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4713 def CompareMaxElementArea(self, hyp, args):
4714 return IsEqual(hyp.GetMaxElementArea(), args[0])
4716 ## Defines "LengthFromEdges" hypothesis to build triangles
4717 # based on the length of the edges taken from the wire
4719 # Only for algoType == MEFISTO || NETGEN_2D
4720 # @ingroup l3_hypos_2dhyps
4721 def LengthFromEdges(self):
4722 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4723 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4725 elif self.algoType == NETGEN:
4726 hyp = self.Parameters(SIMPLE)
4727 hyp.LengthFromEdges()
4730 ## Sets a way to define size of mesh elements to generate.
4731 # @param thePhysicalMesh is: DefaultSize or Custom.
4732 # @ingroup l3_hypos_blsurf
4733 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4734 # Parameter of BLSURF algo
4735 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4737 ## Sets size of mesh elements to generate.
4738 # @ingroup l3_hypos_blsurf
4739 def SetPhySize(self, theVal):
4740 # Parameter of BLSURF algo
4741 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4742 self.Parameters().SetPhySize(theVal)
4744 ## Sets lower boundary of mesh element size (PhySize).
4745 # @ingroup l3_hypos_blsurf
4746 def SetPhyMin(self, theVal=-1):
4747 # Parameter of BLSURF algo
4748 self.Parameters().SetPhyMin(theVal)
4750 ## Sets upper boundary of mesh element size (PhySize).
4751 # @ingroup l3_hypos_blsurf
4752 def SetPhyMax(self, theVal=-1):
4753 # Parameter of BLSURF algo
4754 self.Parameters().SetPhyMax(theVal)
4756 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4757 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4758 # @ingroup l3_hypos_blsurf
4759 def SetGeometricMesh(self, theGeometricMesh=0):
4760 # Parameter of BLSURF algo
4761 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4762 self.params.SetGeometricMesh(theGeometricMesh)
4764 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4765 # @ingroup l3_hypos_blsurf
4766 def SetAngleMeshS(self, theVal=_angleMeshS):
4767 # Parameter of BLSURF algo
4768 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4769 self.params.SetAngleMeshS(theVal)
4771 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4772 # @ingroup l3_hypos_blsurf
4773 def SetAngleMeshC(self, theVal=_angleMeshS):
4774 # Parameter of BLSURF algo
4775 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4776 self.params.SetAngleMeshC(theVal)
4778 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4779 # @ingroup l3_hypos_blsurf
4780 def SetGeoMin(self, theVal=-1):
4781 # Parameter of BLSURF algo
4782 self.Parameters().SetGeoMin(theVal)
4784 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4785 # @ingroup l3_hypos_blsurf
4786 def SetGeoMax(self, theVal=-1):
4787 # Parameter of BLSURF algo
4788 self.Parameters().SetGeoMax(theVal)
4790 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4791 # @ingroup l3_hypos_blsurf
4792 def SetGradation(self, theVal=_gradation):
4793 # Parameter of BLSURF algo
4794 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4795 self.params.SetGradation(theVal)
4797 ## Sets topology usage way.
4798 # @param way defines how mesh conformity is assured <ul>
4799 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4800 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4801 # @ingroup l3_hypos_blsurf
4802 def SetTopology(self, way):
4803 # Parameter of BLSURF algo
4804 self.Parameters().SetTopology(way)
4806 ## To respect geometrical edges or not.
4807 # @ingroup l3_hypos_blsurf
4808 def SetDecimesh(self, toIgnoreEdges=False):
4809 # Parameter of BLSURF algo
4810 self.Parameters().SetDecimesh(toIgnoreEdges)
4812 ## Sets verbosity level in the range 0 to 100.
4813 # @ingroup l3_hypos_blsurf
4814 def SetVerbosity(self, level):
4815 # Parameter of BLSURF algo
4816 self.Parameters().SetVerbosity(level)
4818 ## Sets advanced option value.
4819 # @ingroup l3_hypos_blsurf
4820 def SetOptionValue(self, optionName, level):
4821 # Parameter of BLSURF algo
4822 self.Parameters().SetOptionValue(optionName,level)
4824 ## Sets QuadAllowed flag.
4825 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4826 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4827 def SetQuadAllowed(self, toAllow=True):
4828 if self.algoType == NETGEN_2D:
4829 if toAllow: # add QuadranglePreference
4830 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4831 else: # remove QuadranglePreference
4832 for hyp in self.mesh.GetHypothesisList( self.geom ):
4833 if hyp.GetName() == "QuadranglePreference":
4834 self.mesh.RemoveHypothesis( self.geom, hyp )
4839 if self.Parameters():
4840 self.params.SetQuadAllowed(toAllow)
4843 ## Defines hypothesis having several parameters
4845 # @ingroup l3_hypos_netgen
4846 def Parameters(self, which=SOLE):
4849 if self.algoType == NETGEN:
4851 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4852 "libNETGENEngine.so", UseExisting=0)
4854 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4855 "libNETGENEngine.so", UseExisting=0)
4857 elif self.algoType == MEFISTO:
4858 print "Mefisto algo support no multi-parameter hypothesis"
4860 elif self.algoType == NETGEN_2D:
4861 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4862 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4864 elif self.algoType == BLSURF:
4865 self.params = self.Hypothesis("BLSURF_Parameters", [],
4866 "libBLSURFEngine.so", UseExisting=0)
4869 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4874 # Only for algoType == NETGEN
4875 # @ingroup l3_hypos_netgen
4876 def SetMaxSize(self, theSize):
4877 if self.Parameters():
4878 self.params.SetMaxSize(theSize)
4880 ## Sets SecondOrder flag
4882 # Only for algoType == NETGEN
4883 # @ingroup l3_hypos_netgen
4884 def SetSecondOrder(self, theVal):
4885 if self.Parameters():
4886 self.params.SetSecondOrder(theVal)
4888 ## Sets Optimize flag
4890 # Only for algoType == NETGEN
4891 # @ingroup l3_hypos_netgen
4892 def SetOptimize(self, theVal):
4893 if self.Parameters():
4894 self.params.SetOptimize(theVal)
4897 # @param theFineness is:
4898 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4900 # Only for algoType == NETGEN
4901 # @ingroup l3_hypos_netgen
4902 def SetFineness(self, theFineness):
4903 if self.Parameters():
4904 self.params.SetFineness(theFineness)
4908 # Only for algoType == NETGEN
4909 # @ingroup l3_hypos_netgen
4910 def SetGrowthRate(self, theRate):
4911 if self.Parameters():
4912 self.params.SetGrowthRate(theRate)
4914 ## Sets NbSegPerEdge
4916 # Only for algoType == NETGEN
4917 # @ingroup l3_hypos_netgen
4918 def SetNbSegPerEdge(self, theVal):
4919 if self.Parameters():
4920 self.params.SetNbSegPerEdge(theVal)
4922 ## Sets NbSegPerRadius
4924 # Only for algoType == NETGEN
4925 # @ingroup l3_hypos_netgen
4926 def SetNbSegPerRadius(self, theVal):
4927 if self.Parameters():
4928 self.params.SetNbSegPerRadius(theVal)
4930 ## Sets number of segments overriding value set by SetLocalLength()
4932 # Only for algoType == NETGEN
4933 # @ingroup l3_hypos_netgen
4934 def SetNumberOfSegments(self, theVal):
4935 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4937 ## Sets number of segments overriding value set by SetNumberOfSegments()
4939 # Only for algoType == NETGEN
4940 # @ingroup l3_hypos_netgen
4941 def SetLocalLength(self, theVal):
4942 self.Parameters(SIMPLE).SetLocalLength(theVal)
4947 # Public class: Mesh_Quadrangle
4948 # -----------------------------
4950 ## Defines a quadrangle 2D algorithm
4952 # @ingroup l3_algos_basic
4953 class Mesh_Quadrangle(Mesh_Algorithm):
4955 ## Private constructor.
4956 def __init__(self, mesh, geom=0):
4957 Mesh_Algorithm.__init__(self)
4958 self.Create(mesh, geom, "Quadrangle_2D")
4960 ## Defines "QuadranglePreference" hypothesis, forcing construction
4961 # of quadrangles if the number of nodes on the opposite edges is not the same
4962 # while the total number of nodes on edges is even
4964 # @ingroup l3_hypos_additi
4965 def QuadranglePreference(self):
4966 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4967 CompareMethod=self.CompareEqualHyp)
4970 ## Defines "TrianglePreference" hypothesis, forcing construction
4971 # of triangles in the refinement area if the number of nodes
4972 # on the opposite edges is not the same
4974 # @ingroup l3_hypos_additi
4975 def TrianglePreference(self):
4976 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4977 CompareMethod=self.CompareEqualHyp)
4980 ## Defines "QuadrangleParams" hypothesis
4981 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4982 # will be created while other elements will be quadrangles.
4983 # Vertex can be either a GEOM_Object or a vertex ID within the
4985 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4986 # the same parameters, else (default) - creates a new one
4988 # @ingroup l3_hypos_additi
4989 def TriangleVertex(self, vertex, UseExisting=0):
4991 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4992 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4993 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4994 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4995 hyp.SetTriaVertex( vertexID )
4999 # Public class: Mesh_Tetrahedron
5000 # ------------------------------
5002 ## Defines a tetrahedron 3D algorithm
5004 # @ingroup l3_algos_basic
5005 class Mesh_Tetrahedron(Mesh_Algorithm):
5010 ## Private constructor.
5011 def __init__(self, mesh, algoType, geom=0):
5012 Mesh_Algorithm.__init__(self)
5014 if algoType == NETGEN:
5016 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5019 elif algoType == FULL_NETGEN:
5021 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5024 elif algoType == GHS3D:
5026 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5029 elif algoType == GHS3DPRL:
5030 CheckPlugin(GHS3DPRL)
5031 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5034 self.algoType = algoType
5036 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5037 # @param vol for the maximum volume of each tetrahedron
5038 # @param UseExisting if ==true - searches for the existing hypothesis created with
5039 # the same parameters, else (default) - creates a new one
5040 # @ingroup l3_hypos_maxvol
5041 def MaxElementVolume(self, vol, UseExisting=0):
5042 if self.algoType == NETGEN:
5043 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5044 CompareMethod=self.CompareMaxElementVolume)
5045 hyp.SetMaxElementVolume(vol)
5047 elif self.algoType == FULL_NETGEN:
5048 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5051 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5052 def CompareMaxElementVolume(self, hyp, args):
5053 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5055 ## Defines hypothesis having several parameters
5057 # @ingroup l3_hypos_netgen
5058 def Parameters(self, which=SOLE):
5062 if self.algoType == FULL_NETGEN:
5064 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5065 "libNETGENEngine.so", UseExisting=0)
5067 self.params = self.Hypothesis("NETGEN_Parameters", [],
5068 "libNETGENEngine.so", UseExisting=0)
5071 if self.algoType == GHS3D:
5072 self.params = self.Hypothesis("GHS3D_Parameters", [],
5073 "libGHS3DEngine.so", UseExisting=0)
5076 if self.algoType == GHS3DPRL:
5077 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5078 "libGHS3DPRLEngine.so", UseExisting=0)
5081 print "Algo supports no multi-parameter hypothesis"
5085 # Parameter of FULL_NETGEN
5086 # @ingroup l3_hypos_netgen
5087 def SetMaxSize(self, theSize):
5088 self.Parameters().SetMaxSize(theSize)
5090 ## Sets SecondOrder flag
5091 # Parameter of FULL_NETGEN
5092 # @ingroup l3_hypos_netgen
5093 def SetSecondOrder(self, theVal):
5094 self.Parameters().SetSecondOrder(theVal)
5096 ## Sets Optimize flag
5097 # Parameter of FULL_NETGEN
5098 # @ingroup l3_hypos_netgen
5099 def SetOptimize(self, theVal):
5100 self.Parameters().SetOptimize(theVal)
5103 # @param theFineness is:
5104 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5105 # Parameter of FULL_NETGEN
5106 # @ingroup l3_hypos_netgen
5107 def SetFineness(self, theFineness):
5108 self.Parameters().SetFineness(theFineness)
5111 # Parameter of FULL_NETGEN
5112 # @ingroup l3_hypos_netgen
5113 def SetGrowthRate(self, theRate):
5114 self.Parameters().SetGrowthRate(theRate)
5116 ## Sets NbSegPerEdge
5117 # Parameter of FULL_NETGEN
5118 # @ingroup l3_hypos_netgen
5119 def SetNbSegPerEdge(self, theVal):
5120 self.Parameters().SetNbSegPerEdge(theVal)
5122 ## Sets NbSegPerRadius
5123 # Parameter of FULL_NETGEN
5124 # @ingroup l3_hypos_netgen
5125 def SetNbSegPerRadius(self, theVal):
5126 self.Parameters().SetNbSegPerRadius(theVal)
5128 ## Sets number of segments overriding value set by SetLocalLength()
5129 # Only for algoType == NETGEN_FULL
5130 # @ingroup l3_hypos_netgen
5131 def SetNumberOfSegments(self, theVal):
5132 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5134 ## Sets number of segments overriding value set by SetNumberOfSegments()
5135 # Only for algoType == NETGEN_FULL
5136 # @ingroup l3_hypos_netgen
5137 def SetLocalLength(self, theVal):
5138 self.Parameters(SIMPLE).SetLocalLength(theVal)
5140 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5141 # Overrides value set by LengthFromEdges()
5142 # Only for algoType == NETGEN_FULL
5143 # @ingroup l3_hypos_netgen
5144 def MaxElementArea(self, area):
5145 self.Parameters(SIMPLE).SetMaxElementArea(area)
5147 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5148 # Overrides value set by MaxElementArea()
5149 # Only for algoType == NETGEN_FULL
5150 # @ingroup l3_hypos_netgen
5151 def LengthFromEdges(self):
5152 self.Parameters(SIMPLE).LengthFromEdges()
5154 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5155 # Overrides value set by MaxElementVolume()
5156 # Only for algoType == NETGEN_FULL
5157 # @ingroup l3_hypos_netgen
5158 def LengthFromFaces(self):
5159 self.Parameters(SIMPLE).LengthFromFaces()
5161 ## To mesh "holes" in a solid or not. Default is to mesh.
5162 # @ingroup l3_hypos_ghs3dh
5163 def SetToMeshHoles(self, toMesh):
5164 # Parameter of GHS3D
5165 self.Parameters().SetToMeshHoles(toMesh)
5167 ## Set Optimization level:
5168 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5169 # Strong_Optimization.
5170 # Default is Standard_Optimization
5171 # @ingroup l3_hypos_ghs3dh
5172 def SetOptimizationLevel(self, level):
5173 # Parameter of GHS3D
5174 self.Parameters().SetOptimizationLevel(level)
5176 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5177 # @ingroup l3_hypos_ghs3dh
5178 def SetMaximumMemory(self, MB):
5179 # Advanced parameter of GHS3D
5180 self.Parameters().SetMaximumMemory(MB)
5182 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5183 # automatic memory adjustment mode.
5184 # @ingroup l3_hypos_ghs3dh
5185 def SetInitialMemory(self, MB):
5186 # Advanced parameter of GHS3D
5187 self.Parameters().SetInitialMemory(MB)
5189 ## Path to working directory.
5190 # @ingroup l3_hypos_ghs3dh
5191 def SetWorkingDirectory(self, path):
5192 # Advanced parameter of GHS3D
5193 self.Parameters().SetWorkingDirectory(path)
5195 ## To keep working files or remove them. Log file remains in case of errors anyway.
5196 # @ingroup l3_hypos_ghs3dh
5197 def SetKeepFiles(self, toKeep):
5198 # Advanced parameter of GHS3D and GHS3DPRL
5199 self.Parameters().SetKeepFiles(toKeep)
5201 ## To set verbose level [0-10]. <ul>
5202 #<li> 0 - no standard output,
5203 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5204 # indicates when the final mesh is being saved. In addition the software
5205 # gives indication regarding the CPU time.
5206 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5207 # histogram of the skin mesh, quality statistics histogram together with
5208 # the characteristics of the final mesh.</ul>
5209 # @ingroup l3_hypos_ghs3dh
5210 def SetVerboseLevel(self, level):
5211 # Advanced parameter of GHS3D
5212 self.Parameters().SetVerboseLevel(level)
5214 ## To create new nodes.
5215 # @ingroup l3_hypos_ghs3dh
5216 def SetToCreateNewNodes(self, toCreate):
5217 # Advanced parameter of GHS3D
5218 self.Parameters().SetToCreateNewNodes(toCreate)
5220 ## To use boundary recovery version which tries to create mesh on a very poor
5221 # quality surface mesh.
5222 # @ingroup l3_hypos_ghs3dh
5223 def SetToUseBoundaryRecoveryVersion(self, toUse):
5224 # Advanced parameter of GHS3D
5225 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5227 ## Sets command line option as text.
5228 # @ingroup l3_hypos_ghs3dh
5229 def SetTextOption(self, option):
5230 # Advanced parameter of GHS3D
5231 self.Parameters().SetTextOption(option)
5233 ## Sets MED files name and path.
5234 def SetMEDName(self, value):
5235 self.Parameters().SetMEDName(value)
5237 ## Sets the number of partition of the initial mesh
5238 def SetNbPart(self, value):
5239 self.Parameters().SetNbPart(value)
5241 ## When big mesh, start tepal in background
5242 def SetBackground(self, value):
5243 self.Parameters().SetBackground(value)
5245 # Public class: Mesh_Hexahedron
5246 # ------------------------------
5248 ## Defines a hexahedron 3D algorithm
5250 # @ingroup l3_algos_basic
5251 class Mesh_Hexahedron(Mesh_Algorithm):
5256 ## Private constructor.
5257 def __init__(self, mesh, algoType=Hexa, geom=0):
5258 Mesh_Algorithm.__init__(self)
5260 self.algoType = algoType
5262 if algoType == Hexa:
5263 self.Create(mesh, geom, "Hexa_3D")
5266 elif algoType == Hexotic:
5267 CheckPlugin(Hexotic)
5268 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5271 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5272 # @ingroup l3_hypos_hexotic
5273 def MinMaxQuad(self, min=3, max=8, quad=True):
5274 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5276 self.params.SetHexesMinLevel(min)
5277 self.params.SetHexesMaxLevel(max)
5278 self.params.SetHexoticQuadrangles(quad)
5281 # Deprecated, only for compatibility!
5282 # Public class: Mesh_Netgen
5283 # ------------------------------
5285 ## Defines a NETGEN-based 2D or 3D algorithm
5286 # that needs no discrete boundary (i.e. independent)
5288 # This class is deprecated, only for compatibility!
5291 # @ingroup l3_algos_basic
5292 class Mesh_Netgen(Mesh_Algorithm):
5296 ## Private constructor.
5297 def __init__(self, mesh, is3D, geom=0):
5298 Mesh_Algorithm.__init__(self)
5304 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5308 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5311 ## Defines the hypothesis containing parameters of the algorithm
5312 def Parameters(self):
5314 hyp = self.Hypothesis("NETGEN_Parameters", [],
5315 "libNETGENEngine.so", UseExisting=0)
5317 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5318 "libNETGENEngine.so", UseExisting=0)
5321 # Public class: Mesh_Projection1D
5322 # ------------------------------
5324 ## Defines a projection 1D algorithm
5325 # @ingroup l3_algos_proj
5327 class Mesh_Projection1D(Mesh_Algorithm):
5329 ## Private constructor.
5330 def __init__(self, mesh, geom=0):
5331 Mesh_Algorithm.__init__(self)
5332 self.Create(mesh, geom, "Projection_1D")
5334 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5335 # a mesh pattern is taken, and, optionally, the association of vertices
5336 # between the source edge and a target edge (to which a hypothesis is assigned)
5337 # @param edge from which nodes distribution is taken
5338 # @param mesh from which nodes distribution is taken (optional)
5339 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5340 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5341 # to associate with \a srcV (optional)
5342 # @param UseExisting if ==true - searches for the existing hypothesis created with
5343 # the same parameters, else (default) - creates a new one
5344 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5345 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5347 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5348 hyp.SetSourceEdge( edge )
5349 if not mesh is None and isinstance(mesh, Mesh):
5350 mesh = mesh.GetMesh()
5351 hyp.SetSourceMesh( mesh )
5352 hyp.SetVertexAssociation( srcV, tgtV )
5355 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5356 #def CompareSourceEdge(self, hyp, args):
5357 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5361 # Public class: Mesh_Projection2D
5362 # ------------------------------
5364 ## Defines a projection 2D algorithm
5365 # @ingroup l3_algos_proj
5367 class Mesh_Projection2D(Mesh_Algorithm):
5369 ## Private constructor.
5370 def __init__(self, mesh, geom=0):
5371 Mesh_Algorithm.__init__(self)
5372 self.Create(mesh, geom, "Projection_2D")
5374 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5375 # a mesh pattern is taken, and, optionally, the association of vertices
5376 # between the source face and the target face (to which a hypothesis is assigned)
5377 # @param face from which the mesh pattern is taken
5378 # @param mesh from which the mesh pattern is taken (optional)
5379 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5380 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5381 # to associate with \a srcV1 (optional)
5382 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5383 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5384 # to associate with \a srcV2 (optional)
5385 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5386 # the same parameters, else (default) - forces the creation a new one
5388 # Note: all association vertices must belong to one edge of a face
5389 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5390 srcV2=None, tgtV2=None, UseExisting=0):
5391 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5393 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5394 hyp.SetSourceFace( face )
5395 if not mesh is None and isinstance(mesh, Mesh):
5396 mesh = mesh.GetMesh()
5397 hyp.SetSourceMesh( mesh )
5398 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5401 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5402 #def CompareSourceFace(self, hyp, args):
5403 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5406 # Public class: Mesh_Projection3D
5407 # ------------------------------
5409 ## Defines a projection 3D algorithm
5410 # @ingroup l3_algos_proj
5412 class Mesh_Projection3D(Mesh_Algorithm):
5414 ## Private constructor.
5415 def __init__(self, mesh, geom=0):
5416 Mesh_Algorithm.__init__(self)
5417 self.Create(mesh, geom, "Projection_3D")
5419 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5420 # the mesh pattern is taken, and, optionally, the association of vertices
5421 # between the source and the target solid (to which a hipothesis is assigned)
5422 # @param solid from where the mesh pattern is taken
5423 # @param mesh from where the mesh pattern is taken (optional)
5424 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5425 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5426 # to associate with \a srcV1 (optional)
5427 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5428 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5429 # to associate with \a srcV2 (optional)
5430 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5431 # the same parameters, else (default) - creates a new one
5433 # Note: association vertices must belong to one edge of a solid
5434 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5435 srcV2=0, tgtV2=0, UseExisting=0):
5436 hyp = self.Hypothesis("ProjectionSource3D",
5437 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5439 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5440 hyp.SetSource3DShape( solid )
5441 if not mesh is None and isinstance(mesh, Mesh):
5442 mesh = mesh.GetMesh()
5443 hyp.SetSourceMesh( mesh )
5444 if srcV1 and srcV2 and tgtV1 and tgtV2:
5445 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5446 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5449 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5450 #def CompareSourceShape3D(self, hyp, args):
5451 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5455 # Public class: Mesh_Prism
5456 # ------------------------
5458 ## Defines a 3D extrusion algorithm
5459 # @ingroup l3_algos_3dextr
5461 class Mesh_Prism3D(Mesh_Algorithm):
5463 ## Private constructor.
5464 def __init__(self, mesh, geom=0):
5465 Mesh_Algorithm.__init__(self)
5466 self.Create(mesh, geom, "Prism_3D")
5468 # Public class: Mesh_RadialPrism
5469 # -------------------------------
5471 ## Defines a Radial Prism 3D algorithm
5472 # @ingroup l3_algos_radialp
5474 class Mesh_RadialPrism3D(Mesh_Algorithm):
5476 ## Private constructor.
5477 def __init__(self, mesh, geom=0):
5478 Mesh_Algorithm.__init__(self)
5479 self.Create(mesh, geom, "RadialPrism_3D")
5481 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5482 self.nbLayers = None
5484 ## Return 3D hypothesis holding the 1D one
5485 def Get3DHypothesis(self):
5486 return self.distribHyp
5488 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5489 # hypothesis. Returns the created hypothesis
5490 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5491 #print "OwnHypothesis",hypType
5492 if not self.nbLayers is None:
5493 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5494 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5495 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5496 self.mesh.smeshpyD.SetCurrentStudy( None )
5497 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5498 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5499 self.distribHyp.SetLayerDistribution( hyp )
5502 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5503 # prisms to build between the inner and outer shells
5504 # @param n number of layers
5505 # @param UseExisting if ==true - searches for the existing hypothesis created with
5506 # the same parameters, else (default) - creates a new one
5507 def NumberOfLayers(self, n, UseExisting=0):
5508 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5509 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5510 CompareMethod=self.CompareNumberOfLayers)
5511 self.nbLayers.SetNumberOfLayers( n )
5512 return self.nbLayers
5514 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5515 def CompareNumberOfLayers(self, hyp, args):
5516 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5518 ## Defines "LocalLength" hypothesis, specifying the segment length
5519 # to build between the inner and the outer shells
5520 # @param l the length of segments
5521 # @param p the precision of rounding
5522 def LocalLength(self, l, p=1e-07):
5523 hyp = self.OwnHypothesis("LocalLength", [l,p])
5528 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5529 # prisms to build between the inner and the outer shells.
5530 # @param n the number of layers
5531 # @param s the scale factor (optional)
5532 def NumberOfSegments(self, n, s=[]):
5534 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5536 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5537 hyp.SetDistrType( 1 )
5538 hyp.SetScaleFactor(s)
5539 hyp.SetNumberOfSegments(n)
5542 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5543 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5544 # @param start the length of the first segment
5545 # @param end the length of the last segment
5546 def Arithmetic1D(self, start, end ):
5547 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5548 hyp.SetLength(start, 1)
5549 hyp.SetLength(end , 0)
5552 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5553 # to build between the inner and the outer shells as geometric length increasing
5554 # @param start for the length of the first segment
5555 # @param end for the length of the last segment
5556 def StartEndLength(self, start, end):
5557 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5558 hyp.SetLength(start, 1)
5559 hyp.SetLength(end , 0)
5562 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5563 # to build between the inner and outer shells
5564 # @param fineness defines the quality of the mesh within the range [0-1]
5565 def AutomaticLength(self, fineness=0):
5566 hyp = self.OwnHypothesis("AutomaticLength")
5567 hyp.SetFineness( fineness )
5570 # Public class: Mesh_RadialQuadrangle1D2D
5571 # -------------------------------
5573 ## Defines a Radial Quadrangle 1D2D algorithm
5574 # @ingroup l2_algos_radialq
5576 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5578 ## Private constructor.
5579 def __init__(self, mesh, geom=0):
5580 Mesh_Algorithm.__init__(self)
5581 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5583 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5584 self.nbLayers = None
5586 ## Return 2D hypothesis holding the 1D one
5587 def Get2DHypothesis(self):
5588 return self.distribHyp
5590 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5591 # hypothesis. Returns the created hypothesis
5592 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5593 #print "OwnHypothesis",hypType
5595 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5596 if self.distribHyp is None:
5597 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5599 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5600 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5601 self.mesh.smeshpyD.SetCurrentStudy( None )
5602 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5603 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5604 self.distribHyp.SetLayerDistribution( hyp )
5607 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5608 # @param n number of layers
5609 # @param UseExisting if ==true - searches for the existing hypothesis created with
5610 # the same parameters, else (default) - creates a new one
5611 def NumberOfLayers(self, n, UseExisting=0):
5613 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5614 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5615 CompareMethod=self.CompareNumberOfLayers)
5616 self.nbLayers.SetNumberOfLayers( n )
5617 return self.nbLayers
5619 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5620 def CompareNumberOfLayers(self, hyp, args):
5621 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5623 ## Defines "LocalLength" hypothesis, specifying the segment length
5624 # @param l the length of segments
5625 # @param p the precision of rounding
5626 def LocalLength(self, l, p=1e-07):
5627 hyp = self.OwnHypothesis("LocalLength", [l,p])
5632 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5633 # @param n the number of layers
5634 # @param s the scale factor (optional)
5635 def NumberOfSegments(self, n, s=[]):
5637 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5639 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5640 hyp.SetDistrType( 1 )
5641 hyp.SetScaleFactor(s)
5642 hyp.SetNumberOfSegments(n)
5645 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5646 # with a length that changes in arithmetic progression
5647 # @param start the length of the first segment
5648 # @param end the length of the last segment
5649 def Arithmetic1D(self, start, end ):
5650 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5651 hyp.SetLength(start, 1)
5652 hyp.SetLength(end , 0)
5655 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5656 # as geometric length increasing
5657 # @param start for the length of the first segment
5658 # @param end for the length of the last segment
5659 def StartEndLength(self, start, end):
5660 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5661 hyp.SetLength(start, 1)
5662 hyp.SetLength(end , 0)
5665 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5666 # @param fineness defines the quality of the mesh within the range [0-1]
5667 def AutomaticLength(self, fineness=0):
5668 hyp = self.OwnHypothesis("AutomaticLength")
5669 hyp.SetFineness( fineness )
5673 # Public class: Mesh_UseExistingElements
5674 # --------------------------------------
5675 ## Defines a Radial Quadrangle 1D2D algorithm
5676 # @ingroup l3_algos_basic
5678 class Mesh_UseExistingElements(Mesh_Algorithm):
5680 def __init__(self, dim, mesh, geom=0):
5682 self.Create(mesh, geom, "Import_1D")
5684 self.Create(mesh, geom, "Import_1D2D")
5687 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5688 # @param groups list of groups of edges
5689 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5690 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5691 # @param UseExisting if ==true - searches for the existing hypothesis created with
5692 # the same parameters, else (default) - creates a new one
5693 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5694 if self.algo.GetName() == "Import_2D":
5695 raise ValueError, "algoritm dimension mismatch"
5696 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5697 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5698 hyp.SetSourceEdges(groups)
5699 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5702 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5703 # @param groups list of groups of faces
5704 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5705 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5706 # @param UseExisting if ==true - searches for the existing hypothesis created with
5707 # the same parameters, else (default) - creates a new one
5708 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5709 if self.algo.GetName() == "Import_1D":
5710 raise ValueError, "algoritm dimension mismatch"
5711 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5712 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5713 hyp.SetSourceFaces(groups)
5714 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5717 def _compareHyp(self,hyp,args):
5718 if hasattr( hyp, "GetSourceEdges"):
5719 entries = hyp.GetSourceEdges()
5721 entries = hyp.GetSourceFaces()
5723 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5724 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5726 study = self.mesh.smeshpyD.GetCurrentStudy()
5729 ior = salome.orb.object_to_string(g)
5730 sobj = study.FindObjectIOR(ior)
5731 if sobj: entries2.append( sobj.GetID() )
5736 return entries == entries2
5740 # Private class: Mesh_UseExisting
5741 # -------------------------------
5742 class Mesh_UseExisting(Mesh_Algorithm):
5744 def __init__(self, dim, mesh, geom=0):
5746 self.Create(mesh, geom, "UseExisting_1D")
5748 self.Create(mesh, geom, "UseExisting_2D")
5751 import salome_notebook
5752 notebook = salome_notebook.notebook
5754 ##Return values of the notebook variables
5755 def ParseParameters(last, nbParams,nbParam, value):
5759 listSize = len(last)
5760 for n in range(0,nbParams):
5762 if counter < listSize:
5763 strResult = strResult + last[counter]
5765 strResult = strResult + ""
5767 if isinstance(value, str):
5768 if notebook.isVariable(value):
5769 result = notebook.get(value)
5770 strResult=strResult+value
5772 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5774 strResult=strResult+str(value)
5776 if nbParams - 1 != counter:
5777 strResult=strResult+var_separator #":"
5779 return result, strResult
5781 #Wrapper class for StdMeshers_LocalLength hypothesis
5782 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5784 ## Set Length parameter value
5785 # @param length numerical value or name of variable from notebook
5786 def SetLength(self, length):
5787 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5788 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5789 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5791 ## Set Precision parameter value
5792 # @param precision numerical value or name of variable from notebook
5793 def SetPrecision(self, precision):
5794 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5795 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5796 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5798 #Registering the new proxy for LocalLength
5799 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5802 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5803 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5805 def SetLayerDistribution(self, hypo):
5806 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5807 hypo.ClearParameters();
5808 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5810 #Registering the new proxy for LayerDistribution
5811 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5813 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5814 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5816 ## Set Length parameter value
5817 # @param length numerical value or name of variable from notebook
5818 def SetLength(self, length):
5819 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5820 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5821 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5823 #Registering the new proxy for SegmentLengthAroundVertex
5824 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5827 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5828 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5830 ## Set Length parameter value
5831 # @param length numerical value or name of variable from notebook
5832 # @param isStart true is length is Start Length, otherwise false
5833 def SetLength(self, length, isStart):
5837 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5838 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5839 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5841 #Registering the new proxy for Arithmetic1D
5842 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5844 #Wrapper class for StdMeshers_Deflection1D hypothesis
5845 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5847 ## Set Deflection parameter value
5848 # @param deflection numerical value or name of variable from notebook
5849 def SetDeflection(self, deflection):
5850 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5851 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5852 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5854 #Registering the new proxy for Deflection1D
5855 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5857 #Wrapper class for StdMeshers_StartEndLength hypothesis
5858 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5860 ## Set Length parameter value
5861 # @param length numerical value or name of variable from notebook
5862 # @param isStart true is length is Start Length, otherwise false
5863 def SetLength(self, length, isStart):
5867 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5868 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5869 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5871 #Registering the new proxy for StartEndLength
5872 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5874 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5875 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5877 ## Set Max Element Area parameter value
5878 # @param area numerical value or name of variable from notebook
5879 def SetMaxElementArea(self, area):
5880 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5881 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5882 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5884 #Registering the new proxy for MaxElementArea
5885 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5888 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5889 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5891 ## Set Max Element Volume parameter value
5892 # @param volume numerical value or name of variable from notebook
5893 def SetMaxElementVolume(self, volume):
5894 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5895 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5896 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5898 #Registering the new proxy for MaxElementVolume
5899 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5902 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5903 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5905 ## Set Number Of Layers parameter value
5906 # @param nbLayers numerical value or name of variable from notebook
5907 def SetNumberOfLayers(self, nbLayers):
5908 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5909 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5910 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5912 #Registering the new proxy for NumberOfLayers
5913 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5915 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5916 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5918 ## Set Number Of Segments parameter value
5919 # @param nbSeg numerical value or name of variable from notebook
5920 def SetNumberOfSegments(self, nbSeg):
5921 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5922 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5923 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5924 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5926 ## Set Scale Factor parameter value
5927 # @param factor numerical value or name of variable from notebook
5928 def SetScaleFactor(self, factor):
5929 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5930 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5931 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5933 #Registering the new proxy for NumberOfSegments
5934 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5936 if not noNETGENPlugin:
5937 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5938 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5940 ## Set Max Size parameter value
5941 # @param maxsize numerical value or name of variable from notebook
5942 def SetMaxSize(self, maxsize):
5943 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5944 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5945 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5946 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5948 ## Set Growth Rate parameter value
5949 # @param value numerical value or name of variable from notebook
5950 def SetGrowthRate(self, value):
5951 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5952 value, parameters = ParseParameters(lastParameters,4,2,value)
5953 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5954 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5956 ## Set Number of Segments per Edge parameter value
5957 # @param value numerical value or name of variable from notebook
5958 def SetNbSegPerEdge(self, value):
5959 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5960 value, parameters = ParseParameters(lastParameters,4,3,value)
5961 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5962 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5964 ## Set Number of Segments per Radius parameter value
5965 # @param value numerical value or name of variable from notebook
5966 def SetNbSegPerRadius(self, value):
5967 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5968 value, parameters = ParseParameters(lastParameters,4,4,value)
5969 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5970 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5972 #Registering the new proxy for NETGENPlugin_Hypothesis
5973 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5976 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5977 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5980 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5981 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5983 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5984 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5986 ## Set Number of Segments parameter value
5987 # @param nbSeg numerical value or name of variable from notebook
5988 def SetNumberOfSegments(self, nbSeg):
5989 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5990 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5991 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5992 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5994 ## Set Local Length parameter value
5995 # @param length numerical value or name of variable from notebook
5996 def SetLocalLength(self, length):
5997 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5998 length, parameters = ParseParameters(lastParameters,2,1,length)
5999 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6000 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6002 ## Set Max Element Area parameter value
6003 # @param area numerical value or name of variable from notebook
6004 def SetMaxElementArea(self, area):
6005 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6006 area, parameters = ParseParameters(lastParameters,2,2,area)
6007 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6008 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6010 def LengthFromEdges(self):
6011 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6013 value, parameters = ParseParameters(lastParameters,2,2,value)
6014 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6015 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6017 #Registering the new proxy for NETGEN_SimpleParameters_2D
6018 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6021 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6022 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6023 ## Set Max Element Volume parameter value
6024 # @param volume numerical value or name of variable from notebook
6025 def SetMaxElementVolume(self, volume):
6026 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6027 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6028 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6029 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6031 def LengthFromFaces(self):
6032 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6034 value, parameters = ParseParameters(lastParameters,3,3,value)
6035 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6036 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6038 #Registering the new proxy for NETGEN_SimpleParameters_3D
6039 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6041 pass # if not noNETGENPlugin:
6043 class Pattern(SMESH._objref_SMESH_Pattern):
6045 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6047 if isinstance(theNodeIndexOnKeyPoint1,str):
6049 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6051 theNodeIndexOnKeyPoint1 -= 1
6052 theMesh.SetParameters(Parameters)
6053 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6055 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6058 if isinstance(theNode000Index,str):
6060 if isinstance(theNode001Index,str):
6062 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6064 theNode000Index -= 1
6066 theNode001Index -= 1
6067 theMesh.SetParameters(Parameters)
6068 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6070 #Registering the new proxy for Pattern
6071 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)