1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
90 ## @defgroup l1_measurements Measurements
95 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
168 # MirrorType enumeration
169 POINT = SMESH_MeshEditor.POINT
170 AXIS = SMESH_MeshEditor.AXIS
171 PLANE = SMESH_MeshEditor.PLANE
173 # Smooth_Method enumeration
174 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
175 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
177 # Fineness enumeration (for NETGEN)
185 # Optimization level of GHS3D
187 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
188 # V4.1 (partialy redefines V3.1). Issue 0020574
189 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
191 # Topology treatment way of BLSURF
192 FromCAD, PreProcess, PreProcessPlus = 0,1,2
194 # Element size flag of BLSURF
195 DefaultSize, DefaultGeom, Custom = 0,0,1
197 PrecisionConfusion = 1e-07
199 # TopAbs_State enumeration
200 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 # Methods of splitting a hexahedron into tetrahedra
203 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 ## Converts an angle from degrees to radians
206 def DegreesToRadians(AngleInDegrees):
208 return AngleInDegrees * pi / 180.0
210 # Salome notebook variable separator
213 # Parametrized substitute for PointStruct
214 class PointStructStr:
223 def __init__(self, xStr, yStr, zStr):
227 if isinstance(xStr, str) and notebook.isVariable(xStr):
228 self.x = notebook.get(xStr)
231 if isinstance(yStr, str) and notebook.isVariable(yStr):
232 self.y = notebook.get(yStr)
235 if isinstance(zStr, str) and notebook.isVariable(zStr):
236 self.z = notebook.get(zStr)
240 # Parametrized substitute for PointStruct (with 6 parameters)
241 class PointStructStr6:
256 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
263 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
264 self.x1 = notebook.get(x1Str)
267 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
268 self.x2 = notebook.get(x2Str)
271 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
272 self.y1 = notebook.get(y1Str)
275 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
276 self.y2 = notebook.get(y2Str)
279 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
280 self.z1 = notebook.get(z1Str)
283 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
284 self.z2 = notebook.get(z2Str)
288 # Parametrized substitute for AxisStruct
304 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
311 if isinstance(xStr, str) and notebook.isVariable(xStr):
312 self.x = notebook.get(xStr)
315 if isinstance(yStr, str) and notebook.isVariable(yStr):
316 self.y = notebook.get(yStr)
319 if isinstance(zStr, str) and notebook.isVariable(zStr):
320 self.z = notebook.get(zStr)
323 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
324 self.dx = notebook.get(dxStr)
327 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
328 self.dy = notebook.get(dyStr)
331 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
332 self.dz = notebook.get(dzStr)
336 # Parametrized substitute for DirStruct
339 def __init__(self, pointStruct):
340 self.pointStruct = pointStruct
342 # Returns list of variable values from salome notebook
343 def ParsePointStruct(Point):
344 Parameters = 2*var_separator
345 if isinstance(Point, PointStructStr):
346 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
347 Point = PointStruct(Point.x, Point.y, Point.z)
348 return Point, Parameters
350 # Returns list of variable values from salome notebook
351 def ParseDirStruct(Dir):
352 Parameters = 2*var_separator
353 if isinstance(Dir, DirStructStr):
354 pntStr = Dir.pointStruct
355 if isinstance(pntStr, PointStructStr6):
356 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
357 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
358 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
359 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
361 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
362 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
363 Dir = DirStruct(Point)
364 return Dir, Parameters
366 # Returns list of variable values from salome notebook
367 def ParseAxisStruct(Axis):
368 Parameters = 5*var_separator
369 if isinstance(Axis, AxisStructStr):
370 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
371 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
372 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
373 return Axis, Parameters
375 ## Return list of variable values from salome notebook
376 def ParseAngles(list):
379 for parameter in list:
380 if isinstance(parameter,str) and notebook.isVariable(parameter):
381 Result.append(DegreesToRadians(notebook.get(parameter)))
384 Result.append(parameter)
387 Parameters = Parameters + str(parameter)
388 Parameters = Parameters + var_separator
390 Parameters = Parameters[:len(Parameters)-1]
391 return Result, Parameters
393 def IsEqual(val1, val2, tol=PrecisionConfusion):
394 if abs(val1 - val2) < tol:
404 if isinstance(obj, SALOMEDS._objref_SObject):
407 ior = salome.orb.object_to_string(obj)
410 studies = salome.myStudyManager.GetOpenStudies()
411 for sname in studies:
412 s = salome.myStudyManager.GetStudyByName(sname)
414 sobj = s.FindObjectIOR(ior)
415 if not sobj: continue
416 return sobj.GetName()
417 if hasattr(obj, "GetName"):
418 # unknown CORBA object, having GetName() method
421 # unknown CORBA object, no GetName() method
424 if hasattr(obj, "GetName"):
425 # unknown non-CORBA object, having GetName() method
428 raise RuntimeError, "Null or invalid object"
430 ## Prints error message if a hypothesis was not assigned.
431 def TreatHypoStatus(status, hypName, geomName, isAlgo):
433 hypType = "algorithm"
435 hypType = "hypothesis"
437 if status == HYP_UNKNOWN_FATAL :
438 reason = "for unknown reason"
439 elif status == HYP_INCOMPATIBLE :
440 reason = "this hypothesis mismatches the algorithm"
441 elif status == HYP_NOTCONFORM :
442 reason = "a non-conform mesh would be built"
443 elif status == HYP_ALREADY_EXIST :
444 if isAlgo: return # it does not influence anything
445 reason = hypType + " of the same dimension is already assigned to this shape"
446 elif status == HYP_BAD_DIM :
447 reason = hypType + " mismatches the shape"
448 elif status == HYP_CONCURENT :
449 reason = "there are concurrent hypotheses on sub-shapes"
450 elif status == HYP_BAD_SUBSHAPE :
451 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
452 elif status == HYP_BAD_GEOMETRY:
453 reason = "geometry mismatches the expectation of the algorithm"
454 elif status == HYP_HIDDEN_ALGO:
455 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
456 elif status == HYP_HIDING_ALGO:
457 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
458 elif status == HYP_NEED_SHAPE:
459 reason = "Algorithm can't work without shape"
462 hypName = '"' + hypName + '"'
463 geomName= '"' + geomName+ '"'
464 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
465 print hypName, "was assigned to", geomName,"but", reason
466 elif not geomName == '""':
467 print hypName, "was not assigned to",geomName,":", reason
469 print hypName, "was not assigned:", reason
472 ## Check meshing plugin availability
473 def CheckPlugin(plugin):
474 if plugin == NETGEN and noNETGENPlugin:
475 print "Warning: NETGENPlugin module unavailable"
477 elif plugin == GHS3D and noGHS3DPlugin:
478 print "Warning: GHS3DPlugin module unavailable"
480 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
481 print "Warning: GHS3DPRLPlugin module unavailable"
483 elif plugin == Hexotic and noHexoticPlugin:
484 print "Warning: HexoticPlugin module unavailable"
486 elif plugin == BLSURF and noBLSURFPlugin:
487 print "Warning: BLSURFPlugin module unavailable"
491 # end of l1_auxiliary
494 # All methods of this class are accessible directly from the smesh.py package.
495 class smeshDC(SMESH._objref_SMESH_Gen):
497 ## Sets the current study and Geometry component
498 # @ingroup l1_auxiliary
499 def init_smesh(self,theStudy,geompyD):
500 self.SetCurrentStudy(theStudy,geompyD)
502 ## Creates an empty Mesh. This mesh can have an underlying geometry.
503 # @param obj the Geometrical object on which the mesh is built. If not defined,
504 # the mesh will have no underlying geometry.
505 # @param name the name for the new mesh.
506 # @return an instance of Mesh class.
507 # @ingroup l2_construct
508 def Mesh(self, obj=0, name=0):
509 if isinstance(obj,str):
511 return Mesh(self,self.geompyD,obj,name)
513 ## Returns a long value from enumeration
514 # Should be used for SMESH.FunctorType enumeration
515 # @ingroup l1_controls
516 def EnumToLong(self,theItem):
519 ## Returns a string representation of the color.
520 # To be used with filters.
521 # @param c color value (SALOMEDS.Color)
522 # @ingroup l1_controls
523 def ColorToString(self,c):
525 if isinstance(c, SALOMEDS.Color):
526 val = "%s;%s;%s" % (c.R, c.G, c.B)
527 elif isinstance(c, str):
530 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
533 ## Gets PointStruct from vertex
534 # @param theVertex a GEOM object(vertex)
535 # @return SMESH.PointStruct
536 # @ingroup l1_auxiliary
537 def GetPointStruct(self,theVertex):
538 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
539 return PointStruct(x,y,z)
541 ## Gets DirStruct from vector
542 # @param theVector a GEOM object(vector)
543 # @return SMESH.DirStruct
544 # @ingroup l1_auxiliary
545 def GetDirStruct(self,theVector):
546 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
547 if(len(vertices) != 2):
548 print "Error: vector object is incorrect."
550 p1 = self.geompyD.PointCoordinates(vertices[0])
551 p2 = self.geompyD.PointCoordinates(vertices[1])
552 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
553 dirst = DirStruct(pnt)
556 ## Makes DirStruct from a triplet
557 # @param x,y,z vector components
558 # @return SMESH.DirStruct
559 # @ingroup l1_auxiliary
560 def MakeDirStruct(self,x,y,z):
561 pnt = PointStruct(x,y,z)
562 return DirStruct(pnt)
564 ## Get AxisStruct from object
565 # @param theObj a GEOM object (line or plane)
566 # @return SMESH.AxisStruct
567 # @ingroup l1_auxiliary
568 def GetAxisStruct(self,theObj):
569 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
571 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
572 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
573 vertex1 = self.geompyD.PointCoordinates(vertex1)
574 vertex2 = self.geompyD.PointCoordinates(vertex2)
575 vertex3 = self.geompyD.PointCoordinates(vertex3)
576 vertex4 = self.geompyD.PointCoordinates(vertex4)
577 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
578 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
579 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
580 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
582 elif len(edges) == 1:
583 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
584 p1 = self.geompyD.PointCoordinates( vertex1 )
585 p2 = self.geompyD.PointCoordinates( vertex2 )
586 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
590 # From SMESH_Gen interface:
591 # ------------------------
593 ## Sets the given name to the object
594 # @param obj the object to rename
595 # @param name a new object name
596 # @ingroup l1_auxiliary
597 def SetName(self, obj, name):
598 if isinstance( obj, Mesh ):
600 elif isinstance( obj, Mesh_Algorithm ):
601 obj = obj.GetAlgorithm()
602 ior = salome.orb.object_to_string(obj)
603 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
605 ## Sets the current mode
606 # @ingroup l1_auxiliary
607 def SetEmbeddedMode( self,theMode ):
608 #self.SetEmbeddedMode(theMode)
609 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
611 ## Gets the current mode
612 # @ingroup l1_auxiliary
613 def IsEmbeddedMode(self):
614 #return self.IsEmbeddedMode()
615 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
617 ## Sets the current study
618 # @ingroup l1_auxiliary
619 def SetCurrentStudy( self, theStudy, geompyD = None ):
620 #self.SetCurrentStudy(theStudy)
623 geompyD = geompy.geom
626 self.SetGeomEngine(geompyD)
627 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
629 ## Gets the current study
630 # @ingroup l1_auxiliary
631 def GetCurrentStudy(self):
632 #return self.GetCurrentStudy()
633 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
635 ## Creates a Mesh object importing data from the given UNV file
636 # @return an instance of Mesh class
638 def CreateMeshesFromUNV( self,theFileName ):
639 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
640 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
643 ## Creates a Mesh object(s) importing data from the given MED file
644 # @return a list of Mesh class instances
646 def CreateMeshesFromMED( self,theFileName ):
647 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
649 for iMesh in range(len(aSmeshMeshes)) :
650 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
651 aMeshes.append(aMesh)
652 return aMeshes, aStatus
654 ## Creates a Mesh object importing data from the given STL file
655 # @return an instance of Mesh class
657 def CreateMeshesFromSTL( self, theFileName ):
658 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
659 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
662 ## From SMESH_Gen interface
663 # @return the list of integer values
664 # @ingroup l1_auxiliary
665 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
666 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
668 ## From SMESH_Gen interface. Creates a pattern
669 # @return an instance of SMESH_Pattern
671 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
672 # @ingroup l2_modif_patterns
673 def GetPattern(self):
674 return SMESH._objref_SMESH_Gen.GetPattern(self)
676 ## Sets number of segments per diagonal of boundary box of geometry by which
677 # default segment length of appropriate 1D hypotheses is defined.
678 # Default value is 10
679 # @ingroup l1_auxiliary
680 def SetBoundaryBoxSegmentation(self, nbSegments):
681 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
683 ## Concatenate the given meshes into one mesh.
684 # @return an instance of Mesh class
685 # @param meshes the meshes to combine into one mesh
686 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
687 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
688 # @param mergeTolerance tolerance for merging nodes
689 # @param allGroups forces creation of groups of all elements
690 def Concatenate( self, meshes, uniteIdenticalGroups,
691 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
692 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
693 for i,m in enumerate(meshes):
694 if isinstance(m, Mesh):
695 meshes[i] = m.GetMesh()
697 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
698 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
700 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
701 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
702 aSmeshMesh.SetParameters(Parameters)
703 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
706 # Filtering. Auxiliary functions:
707 # ------------------------------
709 ## Creates an empty criterion
710 # @return SMESH.Filter.Criterion
711 # @ingroup l1_controls
712 def GetEmptyCriterion(self):
713 Type = self.EnumToLong(FT_Undefined)
714 Compare = self.EnumToLong(FT_Undefined)
718 UnaryOp = self.EnumToLong(FT_Undefined)
719 BinaryOp = self.EnumToLong(FT_Undefined)
722 Precision = -1 ##@1e-07
723 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
724 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
726 ## Creates a criterion by the given parameters
727 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
728 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
729 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
730 # @param Treshold the threshold value (range of ids as string, shape, numeric)
731 # @param UnaryOp FT_LogicalNOT or FT_Undefined
732 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
733 # FT_Undefined (must be for the last criterion of all criteria)
734 # @return SMESH.Filter.Criterion
735 # @ingroup l1_controls
736 def GetCriterion(self,elementType,
738 Compare = FT_EqualTo,
740 UnaryOp=FT_Undefined,
741 BinaryOp=FT_Undefined):
742 aCriterion = self.GetEmptyCriterion()
743 aCriterion.TypeOfElement = elementType
744 aCriterion.Type = self.EnumToLong(CritType)
748 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
749 aCriterion.Compare = self.EnumToLong(Compare)
750 elif Compare == "=" or Compare == "==":
751 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
753 aCriterion.Compare = self.EnumToLong(FT_LessThan)
755 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
757 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
760 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
761 FT_BelongToCylinder, FT_LyingOnGeom]:
762 # Checks the treshold
763 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
764 aCriterion.ThresholdStr = GetName(aTreshold)
765 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
767 print "Error: The treshold should be a shape."
769 elif CritType == FT_RangeOfIds:
770 # Checks the treshold
771 if isinstance(aTreshold, str):
772 aCriterion.ThresholdStr = aTreshold
774 print "Error: The treshold should be a string."
776 elif CritType == FT_ElemGeomType:
777 # Checks the treshold
779 aCriterion.Threshold = self.EnumToLong(aTreshold)
781 if isinstance(aTreshold, int):
782 aCriterion.Threshold = aTreshold
784 print "Error: The treshold should be an integer or SMESH.GeometryType."
788 elif CritType == FT_GroupColor:
789 # Checks the treshold
791 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
793 print "Error: The threshold value should be of SALOMEDS.Color type"
796 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
797 FT_FreeFaces, FT_LinearOrQuadratic]:
798 # At this point the treshold is unnecessary
799 if aTreshold == FT_LogicalNOT:
800 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
801 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
802 aCriterion.BinaryOp = aTreshold
806 aTreshold = float(aTreshold)
807 aCriterion.Threshold = aTreshold
809 print "Error: The treshold should be a number."
812 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
813 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
815 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
816 aCriterion.BinaryOp = self.EnumToLong(Treshold)
818 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
819 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
821 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
822 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
826 ## Creates a filter with the given parameters
827 # @param elementType the type of elements in the group
828 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
829 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
830 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
831 # @param UnaryOp FT_LogicalNOT or FT_Undefined
832 # @return SMESH_Filter
833 # @ingroup l1_controls
834 def GetFilter(self,elementType,
835 CritType=FT_Undefined,
838 UnaryOp=FT_Undefined):
839 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
840 aFilterMgr = self.CreateFilterManager()
841 aFilter = aFilterMgr.CreateFilter()
843 aCriteria.append(aCriterion)
844 aFilter.SetCriteria(aCriteria)
848 ## Creates a numerical functor by its type
849 # @param theCriterion FT_...; functor type
850 # @return SMESH_NumericalFunctor
851 # @ingroup l1_controls
852 def GetFunctor(self,theCriterion):
853 aFilterMgr = self.CreateFilterManager()
854 if theCriterion == FT_AspectRatio:
855 return aFilterMgr.CreateAspectRatio()
856 elif theCriterion == FT_AspectRatio3D:
857 return aFilterMgr.CreateAspectRatio3D()
858 elif theCriterion == FT_Warping:
859 return aFilterMgr.CreateWarping()
860 elif theCriterion == FT_MinimumAngle:
861 return aFilterMgr.CreateMinimumAngle()
862 elif theCriterion == FT_Taper:
863 return aFilterMgr.CreateTaper()
864 elif theCriterion == FT_Skew:
865 return aFilterMgr.CreateSkew()
866 elif theCriterion == FT_Area:
867 return aFilterMgr.CreateArea()
868 elif theCriterion == FT_Volume3D:
869 return aFilterMgr.CreateVolume3D()
870 elif theCriterion == FT_MaxElementLength2D:
871 return aFilterMgr.CreateMaxElementLength2D()
872 elif theCriterion == FT_MaxElementLength3D:
873 return aFilterMgr.CreateMaxElementLength3D()
874 elif theCriterion == FT_MultiConnection:
875 return aFilterMgr.CreateMultiConnection()
876 elif theCriterion == FT_MultiConnection2D:
877 return aFilterMgr.CreateMultiConnection2D()
878 elif theCriterion == FT_Length:
879 return aFilterMgr.CreateLength()
880 elif theCriterion == FT_Length2D:
881 return aFilterMgr.CreateLength2D()
883 print "Error: given parameter is not numerucal functor type."
885 ## Creates hypothesis
886 # @param theHType mesh hypothesis type (string)
887 # @param theLibName mesh plug-in library name
888 # @return created hypothesis instance
889 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
890 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
892 ## Gets the mesh stattistic
893 # @return dictionary type element - count of elements
894 # @ingroup l1_meshinfo
895 def GetMeshInfo(self, obj):
896 if isinstance( obj, Mesh ):
899 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
900 values = obj.GetMeshInfo()
901 for i in range(SMESH.Entity_Last._v):
902 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
906 ## Get minimum distance between two objects
908 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
909 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
911 # @param src1 first source object
912 # @param src2 second source object
913 # @param id1 node/element id from the first source
914 # @param id2 node/element id from the second (or first) source
915 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
916 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
917 # @return minimum distance value
918 # @sa GetMinDistance()
919 # @ingroup l1_measurements
920 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
921 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
925 result = result.value
928 ## Get measure structure specifying minimum distance data between two objects
930 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
931 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
933 # @param src1 first source object
934 # @param src2 second source object
935 # @param id1 node/element id from the first source
936 # @param id2 node/element id from the second (or first) source
937 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
938 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
939 # @return Measure structure or None if input data is invalid
941 # @ingroup l1_measurements
942 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
943 if isinstance(src1, Mesh): src1 = src1.mesh
944 if isinstance(src2, Mesh): src2 = src2.mesh
945 if src2 is None and id2 != 0: src2 = src1
946 if not hasattr(src1, "_narrow"): return None
947 src1 = src1._narrow(SMESH.SMESH_IDSource)
948 if not src1: return None
951 e = m.GetMeshEditor()
953 src1 = e.MakeIDSource([id1], SMESH.FACE)
955 src1 = e.MakeIDSource([id1], SMESH.NODE)
957 if hasattr(src2, "_narrow"):
958 src2 = src2._narrow(SMESH.SMESH_IDSource)
959 if src2 and id2 != 0:
961 e = m.GetMeshEditor()
963 src2 = e.MakeIDSource([id2], SMESH.FACE)
965 src2 = e.MakeIDSource([id2], SMESH.NODE)
968 aMeasurements = self.CreateMeasurements()
969 result = aMeasurements.MinDistance(src1, src2)
970 aMeasurements.Destroy()
973 ## Get bounding box of the specified object(s)
974 # @param objects single source object or list of source objects
975 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
976 # @sa GetBoundingBox()
977 # @ingroup l1_measurements
978 def BoundingBox(self, objects):
979 result = self.GetBoundingBox(objects)
983 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
986 ## Get measure structure specifying bounding box data of the specified object(s)
987 # @param objects single source object or list of source objects
988 # @return Measure structure
990 # @ingroup l1_measurements
991 def GetBoundingBox(self, objects):
992 if isinstance(objects, tuple):
993 objects = list(objects)
994 if not isinstance(objects, list):
998 if isinstance(o, Mesh):
999 srclist.append(o.mesh)
1000 elif hasattr(o, "_narrow"):
1001 src = o._narrow(SMESH.SMESH_IDSource)
1002 if src: srclist.append(src)
1005 aMeasurements = self.CreateMeasurements()
1006 result = aMeasurements.BoundingBox(srclist)
1007 aMeasurements.Destroy()
1011 #Registering the new proxy for SMESH_Gen
1012 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1015 # Public class: Mesh
1016 # ==================
1018 ## This class allows defining and managing a mesh.
1019 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1020 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1021 # new nodes and elements and by changing the existing entities), to get information
1022 # about a mesh and to export a mesh into different formats.
1031 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1032 # sets the GUI name of this mesh to \a name.
1033 # @param smeshpyD an instance of smeshDC class
1034 # @param geompyD an instance of geompyDC class
1035 # @param obj Shape to be meshed or SMESH_Mesh object
1036 # @param name Study name of the mesh
1037 # @ingroup l2_construct
1038 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1039 self.smeshpyD=smeshpyD
1040 self.geompyD=geompyD
1044 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1046 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1047 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1050 self.mesh = self.smeshpyD.CreateEmptyMesh()
1052 self.smeshpyD.SetName(self.mesh, name)
1054 self.smeshpyD.SetName(self.mesh, GetName(obj))
1057 self.geom = self.mesh.GetShapeToMesh()
1059 self.editor = self.mesh.GetMeshEditor()
1061 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1062 # @param theMesh a SMESH_Mesh object
1063 # @ingroup l2_construct
1064 def SetMesh(self, theMesh):
1066 self.geom = self.mesh.GetShapeToMesh()
1068 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1069 # @return a SMESH_Mesh object
1070 # @ingroup l2_construct
1074 ## Gets the name of the mesh
1075 # @return the name of the mesh as a string
1076 # @ingroup l2_construct
1078 name = GetName(self.GetMesh())
1081 ## Sets a name to the mesh
1082 # @param name a new name of the mesh
1083 # @ingroup l2_construct
1084 def SetName(self, name):
1085 self.smeshpyD.SetName(self.GetMesh(), name)
1087 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1088 # The subMesh object gives access to the IDs of nodes and elements.
1089 # @param theSubObject a geometrical object (shape)
1090 # @param theName a name for the submesh
1091 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1092 # @ingroup l2_submeshes
1093 def GetSubMesh(self, theSubObject, theName):
1094 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1097 ## Returns the shape associated to the mesh
1098 # @return a GEOM_Object
1099 # @ingroup l2_construct
1103 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1104 # @param geom the shape to be meshed (GEOM_Object)
1105 # @ingroup l2_construct
1106 def SetShape(self, geom):
1107 self.mesh = self.smeshpyD.CreateMesh(geom)
1109 ## Returns true if the hypotheses are defined well
1110 # @param theSubObject a subshape of a mesh shape
1111 # @return True or False
1112 # @ingroup l2_construct
1113 def IsReadyToCompute(self, theSubObject):
1114 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1116 ## Returns errors of hypotheses definition.
1117 # The list of errors is empty if everything is OK.
1118 # @param theSubObject a subshape of a mesh shape
1119 # @return a list of errors
1120 # @ingroup l2_construct
1121 def GetAlgoState(self, theSubObject):
1122 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1124 ## Returns a geometrical object on which the given element was built.
1125 # The returned geometrical object, if not nil, is either found in the
1126 # study or published by this method with the given name
1127 # @param theElementID the id of the mesh element
1128 # @param theGeomName the user-defined name of the geometrical object
1129 # @return GEOM::GEOM_Object instance
1130 # @ingroup l2_construct
1131 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1132 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1134 ## Returns the mesh dimension depending on the dimension of the underlying shape
1135 # @return mesh dimension as an integer value [0,3]
1136 # @ingroup l1_auxiliary
1137 def MeshDimension(self):
1138 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1139 if len( shells ) > 0 :
1141 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1143 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1149 ## Creates a segment discretization 1D algorithm.
1150 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1151 # \n If the optional \a geom parameter is not set, this algorithm is global.
1152 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1153 # @param algo the type of the required algorithm. Possible values are:
1155 # - smesh.PYTHON for discretization via a python function,
1156 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1157 # @param geom If defined is the subshape to be meshed
1158 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1159 # @ingroup l3_algos_basic
1160 def Segment(self, algo=REGULAR, geom=0):
1161 ## if Segment(geom) is called by mistake
1162 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1163 algo, geom = geom, algo
1164 if not algo: algo = REGULAR
1167 return Mesh_Segment(self, geom)
1168 elif algo == PYTHON:
1169 return Mesh_Segment_Python(self, geom)
1170 elif algo == COMPOSITE:
1171 return Mesh_CompositeSegment(self, geom)
1173 return Mesh_Segment(self, geom)
1175 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1176 # If the optional \a geom parameter is not set, this algorithm is global.
1177 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1178 # @param geom If defined the subshape is to be meshed
1179 # @return an instance of Mesh_UseExistingElements class
1180 # @ingroup l3_algos_basic
1181 def UseExisting1DElements(self, geom=0):
1182 return Mesh_UseExistingElements(1,self, geom)
1184 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1185 # If the optional \a geom parameter is not set, this algorithm is global.
1186 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1187 # @param geom If defined the subshape is to be meshed
1188 # @return an instance of Mesh_UseExistingElements class
1189 # @ingroup l3_algos_basic
1190 def UseExisting2DElements(self, geom=0):
1191 return Mesh_UseExistingElements(2,self, geom)
1193 ## Enables creation of nodes and segments usable by 2D algoritms.
1194 # The added nodes and segments must be bound to edges and vertices by
1195 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1196 # If the optional \a geom parameter is not set, this algorithm is global.
1197 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1198 # @param geom the subshape to be manually meshed
1199 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1200 # @ingroup l3_algos_basic
1201 def UseExistingSegments(self, geom=0):
1202 algo = Mesh_UseExisting(1,self,geom)
1203 return algo.GetAlgorithm()
1205 ## Enables creation of nodes and faces usable by 3D algoritms.
1206 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1207 # and SetMeshElementOnShape()
1208 # If the optional \a geom parameter is not set, this algorithm is global.
1209 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1210 # @param geom the subshape to be manually meshed
1211 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1212 # @ingroup l3_algos_basic
1213 def UseExistingFaces(self, geom=0):
1214 algo = Mesh_UseExisting(2,self,geom)
1215 return algo.GetAlgorithm()
1217 ## Creates a triangle 2D algorithm for faces.
1218 # If the optional \a geom parameter is not set, this algorithm is global.
1219 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1220 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1221 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1222 # @return an instance of Mesh_Triangle algorithm
1223 # @ingroup l3_algos_basic
1224 def Triangle(self, algo=MEFISTO, geom=0):
1225 ## if Triangle(geom) is called by mistake
1226 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1229 return Mesh_Triangle(self, algo, geom)
1231 ## Creates a quadrangle 2D algorithm for faces.
1232 # If the optional \a geom parameter is not set, this algorithm is global.
1233 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1234 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1235 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1236 # @return an instance of Mesh_Quadrangle algorithm
1237 # @ingroup l3_algos_basic
1238 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1239 if algo==RADIAL_QUAD:
1240 return Mesh_RadialQuadrangle1D2D(self,geom)
1242 return Mesh_Quadrangle(self, geom)
1244 ## Creates a tetrahedron 3D algorithm for solids.
1245 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1246 # If the optional \a geom parameter is not set, this algorithm is global.
1247 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1248 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1249 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1250 # @return an instance of Mesh_Tetrahedron algorithm
1251 # @ingroup l3_algos_basic
1252 def Tetrahedron(self, algo=NETGEN, geom=0):
1253 ## if Tetrahedron(geom) is called by mistake
1254 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1255 algo, geom = geom, algo
1256 if not algo: algo = NETGEN
1258 return Mesh_Tetrahedron(self, algo, geom)
1260 ## Creates a hexahedron 3D algorithm for solids.
1261 # If the optional \a geom parameter is not set, this algorithm is global.
1262 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1263 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1264 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1265 # @return an instance of Mesh_Hexahedron algorithm
1266 # @ingroup l3_algos_basic
1267 def Hexahedron(self, algo=Hexa, geom=0):
1268 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1269 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1270 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1271 elif geom == 0: algo, geom = Hexa, algo
1272 return Mesh_Hexahedron(self, algo, geom)
1274 ## Deprecated, used only for compatibility!
1275 # @return an instance of Mesh_Netgen algorithm
1276 # @ingroup l3_algos_basic
1277 def Netgen(self, is3D, geom=0):
1278 return Mesh_Netgen(self, is3D, geom)
1280 ## Creates a projection 1D algorithm for edges.
1281 # If the optional \a geom parameter is not set, this algorithm is global.
1282 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1283 # @param geom If defined, the subshape to be meshed
1284 # @return an instance of Mesh_Projection1D algorithm
1285 # @ingroup l3_algos_proj
1286 def Projection1D(self, geom=0):
1287 return Mesh_Projection1D(self, geom)
1289 ## Creates a projection 2D algorithm for faces.
1290 # If the optional \a geom parameter is not set, this algorithm is global.
1291 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1292 # @param geom If defined, the subshape to be meshed
1293 # @return an instance of Mesh_Projection2D algorithm
1294 # @ingroup l3_algos_proj
1295 def Projection2D(self, geom=0):
1296 return Mesh_Projection2D(self, geom)
1298 ## Creates a projection 3D algorithm for solids.
1299 # If the optional \a geom parameter is not set, this algorithm is global.
1300 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1301 # @param geom If defined, the subshape to be meshed
1302 # @return an instance of Mesh_Projection3D algorithm
1303 # @ingroup l3_algos_proj
1304 def Projection3D(self, geom=0):
1305 return Mesh_Projection3D(self, geom)
1307 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1308 # If the optional \a geom parameter is not set, this algorithm is global.
1309 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1310 # @param geom If defined, the subshape to be meshed
1311 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1312 # @ingroup l3_algos_radialp l3_algos_3dextr
1313 def Prism(self, geom=0):
1317 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1318 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1319 if nbSolids == 0 or nbSolids == nbShells:
1320 return Mesh_Prism3D(self, geom)
1321 return Mesh_RadialPrism3D(self, geom)
1323 ## Evaluates size of prospective mesh on a shape
1324 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1325 # To know predicted number of e.g. edges, inquire it this way
1326 # Evaluate()[ EnumToLong( Entity_Edge )]
1327 def Evaluate(self, geom=0):
1328 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1330 geom = self.mesh.GetShapeToMesh()
1333 return self.smeshpyD.Evaluate(self.mesh, geom)
1336 ## Computes the mesh and returns the status of the computation
1337 # @param geom geomtrical shape on which mesh data should be computed
1338 # @param discardModifs if True and the mesh has been edited since
1339 # a last total re-compute and that may prevent successful partial re-compute,
1340 # then the mesh is cleaned before Compute()
1341 # @return True or False
1342 # @ingroup l2_construct
1343 def Compute(self, geom=0, discardModifs=False):
1344 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1346 geom = self.mesh.GetShapeToMesh()
1351 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1353 ok = self.smeshpyD.Compute(self.mesh, geom)
1354 except SALOME.SALOME_Exception, ex:
1355 print "Mesh computation failed, exception caught:"
1356 print " ", ex.details.text
1359 print "Mesh computation failed, exception caught:"
1360 traceback.print_exc()
1364 # Treat compute errors
1365 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1366 for err in computeErrors:
1368 if self.mesh.HasShapeToMesh():
1370 mainIOR = salome.orb.object_to_string(geom)
1371 for sname in salome.myStudyManager.GetOpenStudies():
1372 s = salome.myStudyManager.GetStudyByName(sname)
1374 mainSO = s.FindObjectIOR(mainIOR)
1375 if not mainSO: continue
1376 if err.subShapeID == 1:
1377 shapeText = ' on "%s"' % mainSO.GetName()
1378 subIt = s.NewChildIterator(mainSO)
1380 subSO = subIt.Value()
1382 obj = subSO.GetObject()
1383 if not obj: continue
1384 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1386 ids = go.GetSubShapeIndices()
1387 if len(ids) == 1 and ids[0] == err.subShapeID:
1388 shapeText = ' on "%s"' % subSO.GetName()
1391 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1393 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1395 shapeText = " on subshape #%s" % (err.subShapeID)
1397 shapeText = " on subshape #%s" % (err.subShapeID)
1399 stdErrors = ["OK", #COMPERR_OK
1400 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1401 "std::exception", #COMPERR_STD_EXCEPTION
1402 "OCC exception", #COMPERR_OCC_EXCEPTION
1403 "SALOME exception", #COMPERR_SLM_EXCEPTION
1404 "Unknown exception", #COMPERR_EXCEPTION
1405 "Memory allocation problem", #COMPERR_MEMORY_PB
1406 "Algorithm failed", #COMPERR_ALGO_FAILED
1407 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1409 if err.code < len(stdErrors): errText = stdErrors[err.code]
1411 errText = "code %s" % -err.code
1412 if errText: errText += ". "
1413 errText += err.comment
1414 if allReasons != "":allReasons += "\n"
1415 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1419 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1421 if err.isGlobalAlgo:
1429 reason = '%s %sD algorithm is missing' % (glob, dim)
1430 elif err.state == HYP_MISSING:
1431 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1432 % (glob, dim, name, dim))
1433 elif err.state == HYP_NOTCONFORM:
1434 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1435 elif err.state == HYP_BAD_PARAMETER:
1436 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1437 % ( glob, dim, name ))
1438 elif err.state == HYP_BAD_GEOMETRY:
1439 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1440 'geometry' % ( glob, dim, name ))
1442 reason = "For unknown reason."+\
1443 " Revise Mesh.Compute() implementation in smeshDC.py!"
1445 if allReasons != "":allReasons += "\n"
1446 allReasons += reason
1448 if allReasons != "":
1449 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1453 print '"' + GetName(self.mesh) + '"',"has not been computed."
1456 if salome.sg.hasDesktop():
1457 smeshgui = salome.ImportComponentGUI("SMESH")
1458 smeshgui.Init(self.mesh.GetStudyId())
1459 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1460 salome.sg.updateObjBrowser(1)
1464 ## Return submesh objects list in meshing order
1465 # @return list of list of submesh objects
1466 # @ingroup l2_construct
1467 def GetMeshOrder(self):
1468 return self.mesh.GetMeshOrder()
1470 ## Return submesh objects list in meshing order
1471 # @return list of list of submesh objects
1472 # @ingroup l2_construct
1473 def SetMeshOrder(self, submeshes):
1474 return self.mesh.SetMeshOrder(submeshes)
1476 ## Removes all nodes and elements
1477 # @ingroup l2_construct
1480 if salome.sg.hasDesktop():
1481 smeshgui = salome.ImportComponentGUI("SMESH")
1482 smeshgui.Init(self.mesh.GetStudyId())
1483 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1484 salome.sg.updateObjBrowser(1)
1486 ## Removes all nodes and elements of indicated shape
1487 # @ingroup l2_construct
1488 def ClearSubMesh(self, geomId):
1489 self.mesh.ClearSubMesh(geomId)
1490 if salome.sg.hasDesktop():
1491 smeshgui = salome.ImportComponentGUI("SMESH")
1492 smeshgui.Init(self.mesh.GetStudyId())
1493 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1494 salome.sg.updateObjBrowser(1)
1496 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1497 # @param fineness [0,-1] defines mesh fineness
1498 # @return True or False
1499 # @ingroup l3_algos_basic
1500 def AutomaticTetrahedralization(self, fineness=0):
1501 dim = self.MeshDimension()
1503 self.RemoveGlobalHypotheses()
1504 self.Segment().AutomaticLength(fineness)
1506 self.Triangle().LengthFromEdges()
1509 self.Tetrahedron(NETGEN)
1511 return self.Compute()
1513 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1514 # @param fineness [0,-1] defines mesh fineness
1515 # @return True or False
1516 # @ingroup l3_algos_basic
1517 def AutomaticHexahedralization(self, fineness=0):
1518 dim = self.MeshDimension()
1519 # assign the hypotheses
1520 self.RemoveGlobalHypotheses()
1521 self.Segment().AutomaticLength(fineness)
1528 return self.Compute()
1530 ## Assigns a hypothesis
1531 # @param hyp a hypothesis to assign
1532 # @param geom a subhape of mesh geometry
1533 # @return SMESH.Hypothesis_Status
1534 # @ingroup l2_hypotheses
1535 def AddHypothesis(self, hyp, geom=0):
1536 if isinstance( hyp, Mesh_Algorithm ):
1537 hyp = hyp.GetAlgorithm()
1542 geom = self.mesh.GetShapeToMesh()
1544 status = self.mesh.AddHypothesis(geom, hyp)
1545 isAlgo = hyp._narrow( SMESH_Algo )
1546 hyp_name = GetName( hyp )
1549 geom_name = GetName( geom )
1550 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1553 ## Unassigns a hypothesis
1554 # @param hyp a hypothesis to unassign
1555 # @param geom a subshape of mesh geometry
1556 # @return SMESH.Hypothesis_Status
1557 # @ingroup l2_hypotheses
1558 def RemoveHypothesis(self, hyp, geom=0):
1559 if isinstance( hyp, Mesh_Algorithm ):
1560 hyp = hyp.GetAlgorithm()
1565 status = self.mesh.RemoveHypothesis(geom, hyp)
1568 ## Gets the list of hypotheses added on a geometry
1569 # @param geom a subshape of mesh geometry
1570 # @return the sequence of SMESH_Hypothesis
1571 # @ingroup l2_hypotheses
1572 def GetHypothesisList(self, geom):
1573 return self.mesh.GetHypothesisList( geom )
1575 ## Removes all global hypotheses
1576 # @ingroup l2_hypotheses
1577 def RemoveGlobalHypotheses(self):
1578 current_hyps = self.mesh.GetHypothesisList( self.geom )
1579 for hyp in current_hyps:
1580 self.mesh.RemoveHypothesis( self.geom, hyp )
1584 ## Creates a mesh group based on the geometric object \a grp
1585 # and gives a \a name, \n if this parameter is not defined
1586 # the name is the same as the geometric group name \n
1587 # Note: Works like GroupOnGeom().
1588 # @param grp a geometric group, a vertex, an edge, a face or a solid
1589 # @param name the name of the mesh group
1590 # @return SMESH_GroupOnGeom
1591 # @ingroup l2_grps_create
1592 def Group(self, grp, name=""):
1593 return self.GroupOnGeom(grp, name)
1595 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1596 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1597 ## allowing to overwrite the file if it exists or add the exported data to its contents
1598 # @param f the file name
1599 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1600 # @param opt boolean parameter for creating/not creating
1601 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1602 # @param overwrite boolean parameter for overwriting/not overwriting the file
1603 # @ingroup l2_impexp
1604 def ExportToMED(self, f, version, opt=0, overwrite=1):
1605 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1607 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1608 ## allowing to overwrite the file if it exists or add the exported data to its contents
1609 # @param f is the file name
1610 # @param auto_groups boolean parameter for creating/not creating
1611 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1612 # the typical use is auto_groups=false.
1613 # @param version MED format version(MED_V2_1 or MED_V2_2)
1614 # @param overwrite boolean parameter for overwriting/not overwriting the file
1615 # @ingroup l2_impexp
1616 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1617 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1619 ## Exports the mesh in a file in DAT format
1620 # @param f the file name
1621 # @ingroup l2_impexp
1622 def ExportDAT(self, f):
1623 self.mesh.ExportDAT(f)
1625 ## Exports the mesh in a file in UNV format
1626 # @param f the file name
1627 # @ingroup l2_impexp
1628 def ExportUNV(self, f):
1629 self.mesh.ExportUNV(f)
1631 ## Export the mesh in a file in STL format
1632 # @param f the file name
1633 # @param ascii defines the file encoding
1634 # @ingroup l2_impexp
1635 def ExportSTL(self, f, ascii=1):
1636 self.mesh.ExportSTL(f, ascii)
1639 # Operations with groups:
1640 # ----------------------
1642 ## Creates an empty mesh group
1643 # @param elementType the type of elements in the group
1644 # @param name the name of the mesh group
1645 # @return SMESH_Group
1646 # @ingroup l2_grps_create
1647 def CreateEmptyGroup(self, elementType, name):
1648 return self.mesh.CreateGroup(elementType, name)
1650 ## Creates a mesh group based on the geometrical object \a grp
1651 # and gives a \a name, \n if this parameter is not defined
1652 # the name is the same as the geometrical group name
1653 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1654 # @param name the name of the mesh group
1655 # @param typ the type of elements in the group. If not set, it is
1656 # automatically detected by the type of the geometry
1657 # @return SMESH_GroupOnGeom
1658 # @ingroup l2_grps_create
1659 def GroupOnGeom(self, grp, name="", typ=None):
1661 name = grp.GetName()
1664 tgeo = str(grp.GetShapeType())
1665 if tgeo == "VERTEX":
1667 elif tgeo == "EDGE":
1669 elif tgeo == "FACE":
1671 elif tgeo == "SOLID":
1673 elif tgeo == "SHELL":
1675 elif tgeo == "COMPOUND":
1676 try: # it raises on a compound of compounds
1677 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1678 print "Mesh.Group: empty geometric group", GetName( grp )
1683 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1685 tgeo = self.geompyD.GetType(grp)
1686 if tgeo == geompyDC.ShapeType["VERTEX"]:
1688 elif tgeo == geompyDC.ShapeType["EDGE"]:
1690 elif tgeo == geompyDC.ShapeType["FACE"]:
1692 elif tgeo == geompyDC.ShapeType["SOLID"]:
1698 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1699 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1700 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1708 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1711 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1713 ## Creates a mesh group by the given ids of elements
1714 # @param groupName the name of the mesh group
1715 # @param elementType the type of elements in the group
1716 # @param elemIDs the list of ids
1717 # @return SMESH_Group
1718 # @ingroup l2_grps_create
1719 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1720 group = self.mesh.CreateGroup(elementType, groupName)
1724 ## Creates a mesh group by the given conditions
1725 # @param groupName the name of the mesh group
1726 # @param elementType the type of elements in the group
1727 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1728 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1729 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1730 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1731 # @return SMESH_Group
1732 # @ingroup l2_grps_create
1736 CritType=FT_Undefined,
1739 UnaryOp=FT_Undefined):
1740 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1741 group = self.MakeGroupByCriterion(groupName, aCriterion)
1744 ## Creates a mesh group by the given criterion
1745 # @param groupName the name of the mesh group
1746 # @param Criterion the instance of Criterion class
1747 # @return SMESH_Group
1748 # @ingroup l2_grps_create
1749 def MakeGroupByCriterion(self, groupName, Criterion):
1750 aFilterMgr = self.smeshpyD.CreateFilterManager()
1751 aFilter = aFilterMgr.CreateFilter()
1753 aCriteria.append(Criterion)
1754 aFilter.SetCriteria(aCriteria)
1755 group = self.MakeGroupByFilter(groupName, aFilter)
1756 aFilterMgr.Destroy()
1759 ## Creates a mesh group by the given criteria (list of criteria)
1760 # @param groupName the name of the mesh group
1761 # @param theCriteria the list of criteria
1762 # @return SMESH_Group
1763 # @ingroup l2_grps_create
1764 def MakeGroupByCriteria(self, groupName, theCriteria):
1765 aFilterMgr = self.smeshpyD.CreateFilterManager()
1766 aFilter = aFilterMgr.CreateFilter()
1767 aFilter.SetCriteria(theCriteria)
1768 group = self.MakeGroupByFilter(groupName, aFilter)
1769 aFilterMgr.Destroy()
1772 ## Creates a mesh group by the given filter
1773 # @param groupName the name of the mesh group
1774 # @param theFilter the instance of Filter class
1775 # @return SMESH_Group
1776 # @ingroup l2_grps_create
1777 def MakeGroupByFilter(self, groupName, theFilter):
1778 anIds = theFilter.GetElementsId(self.mesh)
1779 anElemType = theFilter.GetElementType()
1780 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1783 ## Passes mesh elements through the given filter and return IDs of fitting elements
1784 # @param theFilter SMESH_Filter
1785 # @return a list of ids
1786 # @ingroup l1_controls
1787 def GetIdsFromFilter(self, theFilter):
1788 return theFilter.GetElementsId(self.mesh)
1790 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1791 # Returns a list of special structures (borders).
1792 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1793 # @ingroup l1_controls
1794 def GetFreeBorders(self):
1795 aFilterMgr = self.smeshpyD.CreateFilterManager()
1796 aPredicate = aFilterMgr.CreateFreeEdges()
1797 aPredicate.SetMesh(self.mesh)
1798 aBorders = aPredicate.GetBorders()
1799 aFilterMgr.Destroy()
1803 # @ingroup l2_grps_delete
1804 def RemoveGroup(self, group):
1805 self.mesh.RemoveGroup(group)
1807 ## Removes a group with its contents
1808 # @ingroup l2_grps_delete
1809 def RemoveGroupWithContents(self, group):
1810 self.mesh.RemoveGroupWithContents(group)
1812 ## Gets the list of groups existing in the mesh
1813 # @return a sequence of SMESH_GroupBase
1814 # @ingroup l2_grps_create
1815 def GetGroups(self):
1816 return self.mesh.GetGroups()
1818 ## Gets the number of groups existing in the mesh
1819 # @return the quantity of groups as an integer value
1820 # @ingroup l2_grps_create
1822 return self.mesh.NbGroups()
1824 ## Gets the list of names of groups existing in the mesh
1825 # @return list of strings
1826 # @ingroup l2_grps_create
1827 def GetGroupNames(self):
1828 groups = self.GetGroups()
1830 for group in groups:
1831 names.append(group.GetName())
1834 ## Produces a union of two groups
1835 # A new group is created. All mesh elements that are
1836 # present in the initial groups are added to the new one
1837 # @return an instance of SMESH_Group
1838 # @ingroup l2_grps_operon
1839 def UnionGroups(self, group1, group2, name):
1840 return self.mesh.UnionGroups(group1, group2, name)
1842 ## Produces a union list of groups
1843 # New group is created. All mesh elements that are present in
1844 # initial groups are added to the new one
1845 # @return an instance of SMESH_Group
1846 # @ingroup l2_grps_operon
1847 def UnionListOfGroups(self, groups, name):
1848 return self.mesh.UnionListOfGroups(groups, name)
1850 ## Prodices an intersection of two groups
1851 # A new group is created. All mesh elements that are common
1852 # for the two initial groups are added to the new one.
1853 # @return an instance of SMESH_Group
1854 # @ingroup l2_grps_operon
1855 def IntersectGroups(self, group1, group2, name):
1856 return self.mesh.IntersectGroups(group1, group2, name)
1858 ## Produces an intersection of groups
1859 # New group is created. All mesh elements that are present in all
1860 # initial groups simultaneously are added to the new one
1861 # @return an instance of SMESH_Group
1862 # @ingroup l2_grps_operon
1863 def IntersectListOfGroups(self, groups, name):
1864 return self.mesh.IntersectListOfGroups(groups, name)
1866 ## Produces a cut of two groups
1867 # A new group is created. All mesh elements that are present in
1868 # the main group but are not present in the tool group are added to the new one
1869 # @return an instance of SMESH_Group
1870 # @ingroup l2_grps_operon
1871 def CutGroups(self, main_group, tool_group, name):
1872 return self.mesh.CutGroups(main_group, tool_group, name)
1874 ## Produces a cut of groups
1875 # A new group is created. All mesh elements that are present in main groups
1876 # but do not present in tool groups are added to the new one
1877 # @return an instance of SMESH_Group
1878 # @ingroup l2_grps_operon
1879 def CutListOfGroups(self, main_groups, tool_groups, name):
1880 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1882 ## Produces a group of elements with specified element type using list of existing groups
1883 # A new group is created. System
1884 # 1) extract all nodes on which groups elements are built
1885 # 2) combine all elements of specified dimension laying on these nodes
1886 # @return an instance of SMESH_Group
1887 # @ingroup l2_grps_operon
1888 def CreateDimGroup(self, groups, elem_type, name):
1889 return self.mesh.CreateDimGroup(groups, elem_type, name)
1892 ## Convert group on geom into standalone group
1893 # @ingroup l2_grps_delete
1894 def ConvertToStandalone(self, group):
1895 return self.mesh.ConvertToStandalone(group)
1897 # Get some info about mesh:
1898 # ------------------------
1900 ## Returns the log of nodes and elements added or removed
1901 # since the previous clear of the log.
1902 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1903 # @return list of log_block structures:
1908 # @ingroup l1_auxiliary
1909 def GetLog(self, clearAfterGet):
1910 return self.mesh.GetLog(clearAfterGet)
1912 ## Clears the log of nodes and elements added or removed since the previous
1913 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1914 # @ingroup l1_auxiliary
1916 self.mesh.ClearLog()
1918 ## Toggles auto color mode on the object.
1919 # @param theAutoColor the flag which toggles auto color mode.
1920 # @ingroup l1_auxiliary
1921 def SetAutoColor(self, theAutoColor):
1922 self.mesh.SetAutoColor(theAutoColor)
1924 ## Gets flag of object auto color mode.
1925 # @return True or False
1926 # @ingroup l1_auxiliary
1927 def GetAutoColor(self):
1928 return self.mesh.GetAutoColor()
1930 ## Gets the internal ID
1931 # @return integer value, which is the internal Id of the mesh
1932 # @ingroup l1_auxiliary
1934 return self.mesh.GetId()
1937 # @return integer value, which is the study Id of the mesh
1938 # @ingroup l1_auxiliary
1939 def GetStudyId(self):
1940 return self.mesh.GetStudyId()
1942 ## Checks the group names for duplications.
1943 # Consider the maximum group name length stored in MED file.
1944 # @return True or False
1945 # @ingroup l1_auxiliary
1946 def HasDuplicatedGroupNamesMED(self):
1947 return self.mesh.HasDuplicatedGroupNamesMED()
1949 ## Obtains the mesh editor tool
1950 # @return an instance of SMESH_MeshEditor
1951 # @ingroup l1_modifying
1952 def GetMeshEditor(self):
1953 return self.mesh.GetMeshEditor()
1956 # @return an instance of SALOME_MED::MESH
1957 # @ingroup l1_auxiliary
1958 def GetMEDMesh(self):
1959 return self.mesh.GetMEDMesh()
1962 # Get informations about mesh contents:
1963 # ------------------------------------
1965 ## Gets the mesh stattistic
1966 # @return dictionary type element - count of elements
1967 # @ingroup l1_meshinfo
1968 def GetMeshInfo(self, obj = None):
1969 if not obj: obj = self.mesh
1970 return self.smeshpyD.GetMeshInfo(obj)
1972 ## Returns the number of nodes in the mesh
1973 # @return an integer value
1974 # @ingroup l1_meshinfo
1976 return self.mesh.NbNodes()
1978 ## Returns the number of elements in the mesh
1979 # @return an integer value
1980 # @ingroup l1_meshinfo
1981 def NbElements(self):
1982 return self.mesh.NbElements()
1984 ## Returns the number of 0d elements in the mesh
1985 # @return an integer value
1986 # @ingroup l1_meshinfo
1987 def Nb0DElements(self):
1988 return self.mesh.Nb0DElements()
1990 ## Returns the number of edges in the mesh
1991 # @return an integer value
1992 # @ingroup l1_meshinfo
1994 return self.mesh.NbEdges()
1996 ## Returns the number of edges with the given order in the mesh
1997 # @param elementOrder the order of elements:
1998 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1999 # @return an integer value
2000 # @ingroup l1_meshinfo
2001 def NbEdgesOfOrder(self, elementOrder):
2002 return self.mesh.NbEdgesOfOrder(elementOrder)
2004 ## Returns the number of faces in the mesh
2005 # @return an integer value
2006 # @ingroup l1_meshinfo
2008 return self.mesh.NbFaces()
2010 ## Returns the number of faces with the given order in the mesh
2011 # @param elementOrder the order of elements:
2012 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2013 # @return an integer value
2014 # @ingroup l1_meshinfo
2015 def NbFacesOfOrder(self, elementOrder):
2016 return self.mesh.NbFacesOfOrder(elementOrder)
2018 ## Returns the number of triangles in the mesh
2019 # @return an integer value
2020 # @ingroup l1_meshinfo
2021 def NbTriangles(self):
2022 return self.mesh.NbTriangles()
2024 ## Returns the number of triangles with the given order in the mesh
2025 # @param elementOrder is the order of elements:
2026 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2027 # @return an integer value
2028 # @ingroup l1_meshinfo
2029 def NbTrianglesOfOrder(self, elementOrder):
2030 return self.mesh.NbTrianglesOfOrder(elementOrder)
2032 ## Returns the number of quadrangles in the mesh
2033 # @return an integer value
2034 # @ingroup l1_meshinfo
2035 def NbQuadrangles(self):
2036 return self.mesh.NbQuadrangles()
2038 ## Returns the number of quadrangles with the given order in the mesh
2039 # @param elementOrder the order of elements:
2040 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2041 # @return an integer value
2042 # @ingroup l1_meshinfo
2043 def NbQuadranglesOfOrder(self, elementOrder):
2044 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2046 ## Returns the number of polygons in the mesh
2047 # @return an integer value
2048 # @ingroup l1_meshinfo
2049 def NbPolygons(self):
2050 return self.mesh.NbPolygons()
2052 ## Returns the number of volumes in the mesh
2053 # @return an integer value
2054 # @ingroup l1_meshinfo
2055 def NbVolumes(self):
2056 return self.mesh.NbVolumes()
2058 ## Returns the number of volumes with the given order in the mesh
2059 # @param elementOrder the order of elements:
2060 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2061 # @return an integer value
2062 # @ingroup l1_meshinfo
2063 def NbVolumesOfOrder(self, elementOrder):
2064 return self.mesh.NbVolumesOfOrder(elementOrder)
2066 ## Returns the number of tetrahedrons in the mesh
2067 # @return an integer value
2068 # @ingroup l1_meshinfo
2070 return self.mesh.NbTetras()
2072 ## Returns the number of tetrahedrons with the given order in the mesh
2073 # @param elementOrder the order of elements:
2074 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2075 # @return an integer value
2076 # @ingroup l1_meshinfo
2077 def NbTetrasOfOrder(self, elementOrder):
2078 return self.mesh.NbTetrasOfOrder(elementOrder)
2080 ## Returns the number of hexahedrons in the mesh
2081 # @return an integer value
2082 # @ingroup l1_meshinfo
2084 return self.mesh.NbHexas()
2086 ## Returns the number of hexahedrons with the given order in the mesh
2087 # @param elementOrder the order of elements:
2088 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2089 # @return an integer value
2090 # @ingroup l1_meshinfo
2091 def NbHexasOfOrder(self, elementOrder):
2092 return self.mesh.NbHexasOfOrder(elementOrder)
2094 ## Returns the number of pyramids in the mesh
2095 # @return an integer value
2096 # @ingroup l1_meshinfo
2097 def NbPyramids(self):
2098 return self.mesh.NbPyramids()
2100 ## Returns the number of pyramids with the given order in the mesh
2101 # @param elementOrder the order of elements:
2102 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2103 # @return an integer value
2104 # @ingroup l1_meshinfo
2105 def NbPyramidsOfOrder(self, elementOrder):
2106 return self.mesh.NbPyramidsOfOrder(elementOrder)
2108 ## Returns the number of prisms in the mesh
2109 # @return an integer value
2110 # @ingroup l1_meshinfo
2112 return self.mesh.NbPrisms()
2114 ## Returns the number of prisms with the given order in the mesh
2115 # @param elementOrder the order of elements:
2116 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2117 # @return an integer value
2118 # @ingroup l1_meshinfo
2119 def NbPrismsOfOrder(self, elementOrder):
2120 return self.mesh.NbPrismsOfOrder(elementOrder)
2122 ## Returns the number of polyhedrons in the mesh
2123 # @return an integer value
2124 # @ingroup l1_meshinfo
2125 def NbPolyhedrons(self):
2126 return self.mesh.NbPolyhedrons()
2128 ## Returns the number of submeshes in the mesh
2129 # @return an integer value
2130 # @ingroup l1_meshinfo
2131 def NbSubMesh(self):
2132 return self.mesh.NbSubMesh()
2134 ## Returns the list of mesh elements IDs
2135 # @return the list of integer values
2136 # @ingroup l1_meshinfo
2137 def GetElementsId(self):
2138 return self.mesh.GetElementsId()
2140 ## Returns the list of IDs of mesh elements with the given type
2141 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2142 # @return list of integer values
2143 # @ingroup l1_meshinfo
2144 def GetElementsByType(self, elementType):
2145 return self.mesh.GetElementsByType(elementType)
2147 ## Returns the list of mesh nodes IDs
2148 # @return the list of integer values
2149 # @ingroup l1_meshinfo
2150 def GetNodesId(self):
2151 return self.mesh.GetNodesId()
2153 # Get the information about mesh elements:
2154 # ------------------------------------
2156 ## Returns the type of mesh element
2157 # @return the value from SMESH::ElementType enumeration
2158 # @ingroup l1_meshinfo
2159 def GetElementType(self, id, iselem):
2160 return self.mesh.GetElementType(id, iselem)
2162 ## Returns the geometric type of mesh element
2163 # @return the value from SMESH::EntityType enumeration
2164 # @ingroup l1_meshinfo
2165 def GetElementGeomType(self, id):
2166 return self.mesh.GetElementGeomType(id)
2168 ## Returns the list of submesh elements IDs
2169 # @param Shape a geom object(subshape) IOR
2170 # Shape must be the subshape of a ShapeToMesh()
2171 # @return the list of integer values
2172 # @ingroup l1_meshinfo
2173 def GetSubMeshElementsId(self, Shape):
2174 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2175 ShapeID = Shape.GetSubShapeIndices()[0]
2178 return self.mesh.GetSubMeshElementsId(ShapeID)
2180 ## Returns the list of submesh nodes IDs
2181 # @param Shape a geom object(subshape) IOR
2182 # Shape must be the subshape of a ShapeToMesh()
2183 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2184 # @return the list of integer values
2185 # @ingroup l1_meshinfo
2186 def GetSubMeshNodesId(self, Shape, all):
2187 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2188 ShapeID = Shape.GetSubShapeIndices()[0]
2191 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2193 ## Returns type of elements on given shape
2194 # @param Shape a geom object(subshape) IOR
2195 # Shape must be a subshape of a ShapeToMesh()
2196 # @return element type
2197 # @ingroup l1_meshinfo
2198 def GetSubMeshElementType(self, Shape):
2199 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2200 ShapeID = Shape.GetSubShapeIndices()[0]
2203 return self.mesh.GetSubMeshElementType(ShapeID)
2205 ## Gets the mesh description
2206 # @return string value
2207 # @ingroup l1_meshinfo
2209 return self.mesh.Dump()
2212 # Get the information about nodes and elements of a mesh by its IDs:
2213 # -----------------------------------------------------------
2215 ## Gets XYZ coordinates of a node
2216 # \n If there is no nodes for the given ID - returns an empty list
2217 # @return a list of double precision values
2218 # @ingroup l1_meshinfo
2219 def GetNodeXYZ(self, id):
2220 return self.mesh.GetNodeXYZ(id)
2222 ## Returns list of IDs of inverse elements for the given node
2223 # \n If there is no node for the given ID - returns an empty list
2224 # @return a list of integer values
2225 # @ingroup l1_meshinfo
2226 def GetNodeInverseElements(self, id):
2227 return self.mesh.GetNodeInverseElements(id)
2229 ## @brief Returns the position of a node on the shape
2230 # @return SMESH::NodePosition
2231 # @ingroup l1_meshinfo
2232 def GetNodePosition(self,NodeID):
2233 return self.mesh.GetNodePosition(NodeID)
2235 ## If the given element is a node, returns the ID of shape
2236 # \n If there is no node for the given ID - returns -1
2237 # @return an integer value
2238 # @ingroup l1_meshinfo
2239 def GetShapeID(self, id):
2240 return self.mesh.GetShapeID(id)
2242 ## Returns the ID of the result shape after
2243 # FindShape() from SMESH_MeshEditor for the given element
2244 # \n If there is no element for the given ID - returns -1
2245 # @return an integer value
2246 # @ingroup l1_meshinfo
2247 def GetShapeIDForElem(self,id):
2248 return self.mesh.GetShapeIDForElem(id)
2250 ## Returns the number of nodes for the given element
2251 # \n If there is no element for the given ID - returns -1
2252 # @return an integer value
2253 # @ingroup l1_meshinfo
2254 def GetElemNbNodes(self, id):
2255 return self.mesh.GetElemNbNodes(id)
2257 ## Returns the node ID the given index for the given element
2258 # \n If there is no element for the given ID - returns -1
2259 # \n If there is no node for the given index - returns -2
2260 # @return an integer value
2261 # @ingroup l1_meshinfo
2262 def GetElemNode(self, id, index):
2263 return self.mesh.GetElemNode(id, index)
2265 ## Returns the IDs of nodes of the given element
2266 # @return a list of integer values
2267 # @ingroup l1_meshinfo
2268 def GetElemNodes(self, id):
2269 return self.mesh.GetElemNodes(id)
2271 ## Returns true if the given node is the medium node in the given quadratic element
2272 # @ingroup l1_meshinfo
2273 def IsMediumNode(self, elementID, nodeID):
2274 return self.mesh.IsMediumNode(elementID, nodeID)
2276 ## Returns true if the given node is the medium node in one of quadratic elements
2277 # @ingroup l1_meshinfo
2278 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2279 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2281 ## Returns the number of edges for the given element
2282 # @ingroup l1_meshinfo
2283 def ElemNbEdges(self, id):
2284 return self.mesh.ElemNbEdges(id)
2286 ## Returns the number of faces for the given element
2287 # @ingroup l1_meshinfo
2288 def ElemNbFaces(self, id):
2289 return self.mesh.ElemNbFaces(id)
2291 ## Returns nodes of given face (counted from zero) for given volumic element.
2292 # @ingroup l1_meshinfo
2293 def GetElemFaceNodes(self,elemId, faceIndex):
2294 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2296 ## Returns an element based on all given nodes.
2297 # @ingroup l1_meshinfo
2298 def FindElementByNodes(self,nodes):
2299 return self.mesh.FindElementByNodes(nodes)
2301 ## Returns true if the given element is a polygon
2302 # @ingroup l1_meshinfo
2303 def IsPoly(self, id):
2304 return self.mesh.IsPoly(id)
2306 ## Returns true if the given element is quadratic
2307 # @ingroup l1_meshinfo
2308 def IsQuadratic(self, id):
2309 return self.mesh.IsQuadratic(id)
2311 ## Returns XYZ coordinates of the barycenter of the given element
2312 # \n If there is no element for the given ID - returns an empty list
2313 # @return a list of three double values
2314 # @ingroup l1_meshinfo
2315 def BaryCenter(self, id):
2316 return self.mesh.BaryCenter(id)
2319 # Get mesh measurements information:
2320 # ------------------------------------
2322 ## Get minimum distance between two nodes, elements or distance to the origin
2323 # @param id1 first node/element id
2324 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2325 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2326 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2327 # @return minimum distance value
2328 # @sa GetMinDistance()
2329 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2330 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2331 return aMeasure.value
2333 ## Get measure structure specifying minimum distance data between two objects
2334 # @param id1 first node/element id
2335 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2336 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2337 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2338 # @return Measure structure
2340 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2342 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2344 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2347 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2349 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2354 aMeasurements = self.smeshpyD.CreateMeasurements()
2355 aMeasure = aMeasurements.MinDistance(id1, id2)
2356 aMeasurements.Destroy()
2359 ## Get bounding box of the specified object(s)
2360 # @param objects single source object or list of source objects or list of nodes/elements IDs
2361 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2362 # @c False specifies that @a objects are nodes
2363 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2364 # @sa GetBoundingBox()
2365 def BoundingBox(self, objects=None, isElem=False):
2366 result = self.GetBoundingBox(objects, isElem)
2370 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2373 ## Get measure structure specifying bounding box data of the specified object(s)
2374 # @param objects single source object or list of source objects or list of nodes/elements IDs
2375 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2376 # @c False specifies that @a objects are nodes
2377 # @return Measure structure
2379 def GetBoundingBox(self, IDs=None, isElem=False):
2382 elif isinstance(IDs, tuple):
2384 if not isinstance(IDs, list):
2386 if len(IDs) > 0 and isinstance(IDs[0], int):
2390 if isinstance(o, Mesh):
2391 srclist.append(o.mesh)
2392 elif hasattr(o, "_narrow"):
2393 src = o._narrow(SMESH.SMESH_IDSource)
2394 if src: srclist.append(src)
2396 elif isinstance(o, list):
2398 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2400 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2403 aMeasurements = self.smeshpyD.CreateMeasurements()
2404 aMeasure = aMeasurements.BoundingBox(srclist)
2405 aMeasurements.Destroy()
2408 # Mesh edition (SMESH_MeshEditor functionality):
2409 # ---------------------------------------------
2411 ## Removes the elements from the mesh by ids
2412 # @param IDsOfElements is a list of ids of elements to remove
2413 # @return True or False
2414 # @ingroup l2_modif_del
2415 def RemoveElements(self, IDsOfElements):
2416 return self.editor.RemoveElements(IDsOfElements)
2418 ## Removes nodes from mesh by ids
2419 # @param IDsOfNodes is a list of ids of nodes to remove
2420 # @return True or False
2421 # @ingroup l2_modif_del
2422 def RemoveNodes(self, IDsOfNodes):
2423 return self.editor.RemoveNodes(IDsOfNodes)
2425 ## Removes all orphan (free) nodes from mesh
2426 # @return number of the removed nodes
2427 # @ingroup l2_modif_del
2428 def RemoveOrphanNodes(self):
2429 return self.editor.RemoveOrphanNodes()
2431 ## Add a node to the mesh by coordinates
2432 # @return Id of the new node
2433 # @ingroup l2_modif_add
2434 def AddNode(self, x, y, z):
2435 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2436 self.mesh.SetParameters(Parameters)
2437 return self.editor.AddNode( x, y, z)
2439 ## Creates a 0D element on a node with given number.
2440 # @param IDOfNode the ID of node for creation of the element.
2441 # @return the Id of the new 0D element
2442 # @ingroup l2_modif_add
2443 def Add0DElement(self, IDOfNode):
2444 return self.editor.Add0DElement(IDOfNode)
2446 ## Creates a linear or quadratic edge (this is determined
2447 # by the number of given nodes).
2448 # @param IDsOfNodes the list of node IDs for creation of the element.
2449 # The order of nodes in this list should correspond to the description
2450 # of MED. \n This description is located by the following link:
2451 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2452 # @return the Id of the new edge
2453 # @ingroup l2_modif_add
2454 def AddEdge(self, IDsOfNodes):
2455 return self.editor.AddEdge(IDsOfNodes)
2457 ## Creates a linear or quadratic face (this is determined
2458 # by the number of given nodes).
2459 # @param IDsOfNodes the list of node IDs for creation of the element.
2460 # The order of nodes in this list should correspond to the description
2461 # of MED. \n This description is located by the following link:
2462 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2463 # @return the Id of the new face
2464 # @ingroup l2_modif_add
2465 def AddFace(self, IDsOfNodes):
2466 return self.editor.AddFace(IDsOfNodes)
2468 ## Adds a polygonal face to the mesh by the list of node IDs
2469 # @param IdsOfNodes the list of node IDs for creation of the element.
2470 # @return the Id of the new face
2471 # @ingroup l2_modif_add
2472 def AddPolygonalFace(self, IdsOfNodes):
2473 return self.editor.AddPolygonalFace(IdsOfNodes)
2475 ## Creates both simple and quadratic volume (this is determined
2476 # by the number of given nodes).
2477 # @param IDsOfNodes the list of node IDs for creation of the element.
2478 # The order of nodes in this list should correspond to the description
2479 # of MED. \n This description is located by the following link:
2480 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2481 # @return the Id of the new volumic element
2482 # @ingroup l2_modif_add
2483 def AddVolume(self, IDsOfNodes):
2484 return self.editor.AddVolume(IDsOfNodes)
2486 ## Creates a volume of many faces, giving nodes for each face.
2487 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2488 # @param Quantities the list of integer values, Quantities[i]
2489 # gives the quantity of nodes in face number i.
2490 # @return the Id of the new volumic element
2491 # @ingroup l2_modif_add
2492 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2493 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2495 ## Creates a volume of many faces, giving the IDs of the existing faces.
2496 # @param IdsOfFaces the list of face IDs for volume creation.
2498 # Note: The created volume will refer only to the nodes
2499 # of the given faces, not to the faces themselves.
2500 # @return the Id of the new volumic element
2501 # @ingroup l2_modif_add
2502 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2503 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2506 ## @brief Binds a node to a vertex
2507 # @param NodeID a node ID
2508 # @param Vertex a vertex or vertex ID
2509 # @return True if succeed else raises an exception
2510 # @ingroup l2_modif_add
2511 def SetNodeOnVertex(self, NodeID, Vertex):
2512 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2513 VertexID = Vertex.GetSubShapeIndices()[0]
2517 self.editor.SetNodeOnVertex(NodeID, VertexID)
2518 except SALOME.SALOME_Exception, inst:
2519 raise ValueError, inst.details.text
2523 ## @brief Stores the node position on an edge
2524 # @param NodeID a node ID
2525 # @param Edge an edge or edge ID
2526 # @param paramOnEdge a parameter on the edge where the node is located
2527 # @return True if succeed else raises an exception
2528 # @ingroup l2_modif_add
2529 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2530 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2531 EdgeID = Edge.GetSubShapeIndices()[0]
2535 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2536 except SALOME.SALOME_Exception, inst:
2537 raise ValueError, inst.details.text
2540 ## @brief Stores node position on a face
2541 # @param NodeID a node ID
2542 # @param Face a face or face ID
2543 # @param u U parameter on the face where the node is located
2544 # @param v V parameter on the face where the node is located
2545 # @return True if succeed else raises an exception
2546 # @ingroup l2_modif_add
2547 def SetNodeOnFace(self, NodeID, Face, u, v):
2548 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2549 FaceID = Face.GetSubShapeIndices()[0]
2553 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2554 except SALOME.SALOME_Exception, inst:
2555 raise ValueError, inst.details.text
2558 ## @brief Binds a node to a solid
2559 # @param NodeID a node ID
2560 # @param Solid a solid or solid ID
2561 # @return True if succeed else raises an exception
2562 # @ingroup l2_modif_add
2563 def SetNodeInVolume(self, NodeID, Solid):
2564 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2565 SolidID = Solid.GetSubShapeIndices()[0]
2569 self.editor.SetNodeInVolume(NodeID, SolidID)
2570 except SALOME.SALOME_Exception, inst:
2571 raise ValueError, inst.details.text
2574 ## @brief Bind an element to a shape
2575 # @param ElementID an element ID
2576 # @param Shape a shape or shape ID
2577 # @return True if succeed else raises an exception
2578 # @ingroup l2_modif_add
2579 def SetMeshElementOnShape(self, ElementID, Shape):
2580 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2581 ShapeID = Shape.GetSubShapeIndices()[0]
2585 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2586 except SALOME.SALOME_Exception, inst:
2587 raise ValueError, inst.details.text
2591 ## Moves the node with the given id
2592 # @param NodeID the id of the node
2593 # @param x a new X coordinate
2594 # @param y a new Y coordinate
2595 # @param z a new Z coordinate
2596 # @return True if succeed else False
2597 # @ingroup l2_modif_movenode
2598 def MoveNode(self, NodeID, x, y, z):
2599 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2600 self.mesh.SetParameters(Parameters)
2601 return self.editor.MoveNode(NodeID, x, y, z)
2603 ## Finds the node closest to a point and moves it to a point location
2604 # @param x the X coordinate of a point
2605 # @param y the Y coordinate of a point
2606 # @param z the Z coordinate of a point
2607 # @param NodeID if specified (>0), the node with this ID is moved,
2608 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2609 # @return the ID of a node
2610 # @ingroup l2_modif_throughp
2611 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2612 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2613 self.mesh.SetParameters(Parameters)
2614 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2616 ## Finds the node closest to a point
2617 # @param x the X coordinate of a point
2618 # @param y the Y coordinate of a point
2619 # @param z the Z coordinate of a point
2620 # @return the ID of a node
2621 # @ingroup l2_modif_throughp
2622 def FindNodeClosestTo(self, x, y, z):
2623 #preview = self.mesh.GetMeshEditPreviewer()
2624 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2625 return self.editor.FindNodeClosestTo(x, y, z)
2627 ## Finds the elements where a point lays IN or ON
2628 # @param x the X coordinate of a point
2629 # @param y the Y coordinate of a point
2630 # @param z the Z coordinate of a point
2631 # @param elementType type of elements to find (SMESH.ALL type
2632 # means elements of any type excluding nodes and 0D elements)
2633 # @return list of IDs of found elements
2634 # @ingroup l2_modif_throughp
2635 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2636 return self.editor.FindElementsByPoint(x, y, z, elementType)
2638 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2639 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2641 def GetPointState(self, x, y, z):
2642 return self.editor.GetPointState(x, y, z)
2644 ## Finds the node closest to a point and moves it to a point location
2645 # @param x the X coordinate of a point
2646 # @param y the Y coordinate of a point
2647 # @param z the Z coordinate of a point
2648 # @return the ID of a moved node
2649 # @ingroup l2_modif_throughp
2650 def MeshToPassThroughAPoint(self, x, y, z):
2651 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2653 ## Replaces two neighbour triangles sharing Node1-Node2 link
2654 # with the triangles built on the same 4 nodes but having other common link.
2655 # @param NodeID1 the ID of the first node
2656 # @param NodeID2 the ID of the second node
2657 # @return false if proper faces were not found
2658 # @ingroup l2_modif_invdiag
2659 def InverseDiag(self, NodeID1, NodeID2):
2660 return self.editor.InverseDiag(NodeID1, NodeID2)
2662 ## Replaces two neighbour triangles sharing Node1-Node2 link
2663 # with a quadrangle built on the same 4 nodes.
2664 # @param NodeID1 the ID of the first node
2665 # @param NodeID2 the ID of the second node
2666 # @return false if proper faces were not found
2667 # @ingroup l2_modif_unitetri
2668 def DeleteDiag(self, NodeID1, NodeID2):
2669 return self.editor.DeleteDiag(NodeID1, NodeID2)
2671 ## Reorients elements by ids
2672 # @param IDsOfElements if undefined reorients all mesh elements
2673 # @return True if succeed else False
2674 # @ingroup l2_modif_changori
2675 def Reorient(self, IDsOfElements=None):
2676 if IDsOfElements == None:
2677 IDsOfElements = self.GetElementsId()
2678 return self.editor.Reorient(IDsOfElements)
2680 ## Reorients all elements of the object
2681 # @param theObject mesh, submesh or group
2682 # @return True if succeed else False
2683 # @ingroup l2_modif_changori
2684 def ReorientObject(self, theObject):
2685 if ( isinstance( theObject, Mesh )):
2686 theObject = theObject.GetMesh()
2687 return self.editor.ReorientObject(theObject)
2689 ## Fuses the neighbouring triangles into quadrangles.
2690 # @param IDsOfElements The triangles to be fused,
2691 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2692 # @param MaxAngle is the maximum angle between element normals at which the fusion
2693 # is still performed; theMaxAngle is mesured in radians.
2694 # Also it could be a name of variable which defines angle in degrees.
2695 # @return TRUE in case of success, FALSE otherwise.
2696 # @ingroup l2_modif_unitetri
2697 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2699 if isinstance(MaxAngle,str):
2701 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2703 MaxAngle = DegreesToRadians(MaxAngle)
2704 if IDsOfElements == []:
2705 IDsOfElements = self.GetElementsId()
2706 self.mesh.SetParameters(Parameters)
2708 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2709 Functor = theCriterion
2711 Functor = self.smeshpyD.GetFunctor(theCriterion)
2712 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2714 ## Fuses the neighbouring triangles of the object into quadrangles
2715 # @param theObject is mesh, submesh or group
2716 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2717 # @param MaxAngle a max angle between element normals at which the fusion
2718 # is still performed; theMaxAngle is mesured in radians.
2719 # @return TRUE in case of success, FALSE otherwise.
2720 # @ingroup l2_modif_unitetri
2721 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2722 if ( isinstance( theObject, Mesh )):
2723 theObject = theObject.GetMesh()
2724 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2726 ## Splits quadrangles into triangles.
2727 # @param IDsOfElements the faces to be splitted.
2728 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2729 # @return TRUE in case of success, FALSE otherwise.
2730 # @ingroup l2_modif_cutquadr
2731 def QuadToTri (self, IDsOfElements, theCriterion):
2732 if IDsOfElements == []:
2733 IDsOfElements = self.GetElementsId()
2734 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2736 ## Splits quadrangles into triangles.
2737 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2738 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2739 # @return TRUE in case of success, FALSE otherwise.
2740 # @ingroup l2_modif_cutquadr
2741 def QuadToTriObject (self, theObject, theCriterion):
2742 if ( isinstance( theObject, Mesh )):
2743 theObject = theObject.GetMesh()
2744 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2746 ## Splits quadrangles into triangles.
2747 # @param IDsOfElements the faces to be splitted
2748 # @param Diag13 is used to choose a diagonal for splitting.
2749 # @return TRUE in case of success, FALSE otherwise.
2750 # @ingroup l2_modif_cutquadr
2751 def SplitQuad (self, IDsOfElements, Diag13):
2752 if IDsOfElements == []:
2753 IDsOfElements = self.GetElementsId()
2754 return self.editor.SplitQuad(IDsOfElements, Diag13)
2756 ## Splits quadrangles into triangles.
2757 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2758 # @param Diag13 is used to choose a diagonal for splitting.
2759 # @return TRUE in case of success, FALSE otherwise.
2760 # @ingroup l2_modif_cutquadr
2761 def SplitQuadObject (self, theObject, Diag13):
2762 if ( isinstance( theObject, Mesh )):
2763 theObject = theObject.GetMesh()
2764 return self.editor.SplitQuadObject(theObject, Diag13)
2766 ## Finds a better splitting of the given quadrangle.
2767 # @param IDOfQuad the ID of the quadrangle to be splitted.
2768 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2769 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2770 # diagonal is better, 0 if error occurs.
2771 # @ingroup l2_modif_cutquadr
2772 def BestSplit (self, IDOfQuad, theCriterion):
2773 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2775 ## Splits volumic elements into tetrahedrons
2776 # @param elemIDs either list of elements or mesh or group or submesh
2777 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2778 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2779 # @ingroup l2_modif_cutquadr
2780 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2781 if isinstance( elemIDs, Mesh ):
2782 elemIDs = elemIDs.GetMesh()
2783 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2785 ## Splits quadrangle faces near triangular facets of volumes
2787 # @ingroup l1_auxiliary
2788 def SplitQuadsNearTriangularFacets(self):
2789 faces_array = self.GetElementsByType(SMESH.FACE)
2790 for face_id in faces_array:
2791 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2792 quad_nodes = self.mesh.GetElemNodes(face_id)
2793 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2794 isVolumeFound = False
2795 for node1_elem in node1_elems:
2796 if not isVolumeFound:
2797 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2798 nb_nodes = self.GetElemNbNodes(node1_elem)
2799 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2800 volume_elem = node1_elem
2801 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2802 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2803 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2804 isVolumeFound = True
2805 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2806 self.SplitQuad([face_id], False) # diagonal 2-4
2807 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2808 isVolumeFound = True
2809 self.SplitQuad([face_id], True) # diagonal 1-3
2810 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2811 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2812 isVolumeFound = True
2813 self.SplitQuad([face_id], True) # diagonal 1-3
2815 ## @brief Splits hexahedrons into tetrahedrons.
2817 # This operation uses pattern mapping functionality for splitting.
2818 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2819 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2820 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2821 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2822 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2823 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2824 # @return TRUE in case of success, FALSE otherwise.
2825 # @ingroup l1_auxiliary
2826 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2827 # Pattern: 5.---------.6
2832 # (0,0,1) 4.---------.7 * |
2839 # (0,0,0) 0.---------.3
2840 pattern_tetra = "!!! Nb of points: \n 8 \n\
2850 !!! Indices of points of 6 tetras: \n\
2858 pattern = self.smeshpyD.GetPattern()
2859 isDone = pattern.LoadFromFile(pattern_tetra)
2861 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2864 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2865 isDone = pattern.MakeMesh(self.mesh, False, False)
2866 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2868 # split quafrangle faces near triangular facets of volumes
2869 self.SplitQuadsNearTriangularFacets()
2873 ## @brief Split hexahedrons into prisms.
2875 # Uses the pattern mapping functionality for splitting.
2876 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2877 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2878 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2879 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2880 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2881 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2882 # @return TRUE in case of success, FALSE otherwise.
2883 # @ingroup l1_auxiliary
2884 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2885 # Pattern: 5.---------.6
2890 # (0,0,1) 4.---------.7 |
2897 # (0,0,0) 0.---------.3
2898 pattern_prism = "!!! Nb of points: \n 8 \n\
2908 !!! Indices of points of 2 prisms: \n\
2912 pattern = self.smeshpyD.GetPattern()
2913 isDone = pattern.LoadFromFile(pattern_prism)
2915 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2918 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2919 isDone = pattern.MakeMesh(self.mesh, False, False)
2920 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2922 # Splits quafrangle faces near triangular facets of volumes
2923 self.SplitQuadsNearTriangularFacets()
2927 ## Smoothes elements
2928 # @param IDsOfElements the list if ids of elements to smooth
2929 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2930 # Note that nodes built on edges and boundary nodes are always fixed.
2931 # @param MaxNbOfIterations the maximum number of iterations
2932 # @param MaxAspectRatio varies in range [1.0, inf]
2933 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2934 # @return TRUE in case of success, FALSE otherwise.
2935 # @ingroup l2_modif_smooth
2936 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2937 MaxNbOfIterations, MaxAspectRatio, Method):
2938 if IDsOfElements == []:
2939 IDsOfElements = self.GetElementsId()
2940 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2941 self.mesh.SetParameters(Parameters)
2942 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2943 MaxNbOfIterations, MaxAspectRatio, Method)
2945 ## Smoothes elements which belong to the given object
2946 # @param theObject the object to smooth
2947 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2948 # Note that nodes built on edges and boundary nodes are always fixed.
2949 # @param MaxNbOfIterations the maximum number of iterations
2950 # @param MaxAspectRatio varies in range [1.0, inf]
2951 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2952 # @return TRUE in case of success, FALSE otherwise.
2953 # @ingroup l2_modif_smooth
2954 def SmoothObject(self, theObject, IDsOfFixedNodes,
2955 MaxNbOfIterations, MaxAspectRatio, Method):
2956 if ( isinstance( theObject, Mesh )):
2957 theObject = theObject.GetMesh()
2958 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2959 MaxNbOfIterations, MaxAspectRatio, Method)
2961 ## Parametrically smoothes the given elements
2962 # @param IDsOfElements the list if ids of elements to smooth
2963 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2964 # Note that nodes built on edges and boundary nodes are always fixed.
2965 # @param MaxNbOfIterations the maximum number of iterations
2966 # @param MaxAspectRatio varies in range [1.0, inf]
2967 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2968 # @return TRUE in case of success, FALSE otherwise.
2969 # @ingroup l2_modif_smooth
2970 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2971 MaxNbOfIterations, MaxAspectRatio, Method):
2972 if IDsOfElements == []:
2973 IDsOfElements = self.GetElementsId()
2974 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2975 self.mesh.SetParameters(Parameters)
2976 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2977 MaxNbOfIterations, MaxAspectRatio, Method)
2979 ## Parametrically smoothes the elements which belong to the given object
2980 # @param theObject the object to smooth
2981 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2982 # Note that nodes built on edges and boundary nodes are always fixed.
2983 # @param MaxNbOfIterations the maximum number of iterations
2984 # @param MaxAspectRatio varies in range [1.0, inf]
2985 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2986 # @return TRUE in case of success, FALSE otherwise.
2987 # @ingroup l2_modif_smooth
2988 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2989 MaxNbOfIterations, MaxAspectRatio, Method):
2990 if ( isinstance( theObject, Mesh )):
2991 theObject = theObject.GetMesh()
2992 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2993 MaxNbOfIterations, MaxAspectRatio, Method)
2995 ## Converts the mesh to quadratic, deletes old elements, replacing
2996 # them with quadratic with the same id.
2997 # @param theForce3d new node creation method:
2998 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2999 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3000 # @ingroup l2_modif_tofromqu
3001 def ConvertToQuadratic(self, theForce3d):
3002 self.editor.ConvertToQuadratic(theForce3d)
3004 ## Converts the mesh from quadratic to ordinary,
3005 # deletes old quadratic elements, \n replacing
3006 # them with ordinary mesh elements with the same id.
3007 # @return TRUE in case of success, FALSE otherwise.
3008 # @ingroup l2_modif_tofromqu
3009 def ConvertFromQuadratic(self):
3010 return self.editor.ConvertFromQuadratic()
3012 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3013 # @return TRUE if operation has been completed successfully, FALSE otherwise
3014 # @ingroup l2_modif_edit
3015 def Make2DMeshFrom3D(self):
3016 return self.editor. Make2DMeshFrom3D()
3018 ## Renumber mesh nodes
3019 # @ingroup l2_modif_renumber
3020 def RenumberNodes(self):
3021 self.editor.RenumberNodes()
3023 ## Renumber mesh elements
3024 # @ingroup l2_modif_renumber
3025 def RenumberElements(self):
3026 self.editor.RenumberElements()
3028 ## Generates new elements by rotation of the elements around the axis
3029 # @param IDsOfElements the list of ids of elements to sweep
3030 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3031 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3032 # @param NbOfSteps the number of steps
3033 # @param Tolerance tolerance
3034 # @param MakeGroups forces the generation of new groups from existing ones
3035 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3036 # of all steps, else - size of each step
3037 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3038 # @ingroup l2_modif_extrurev
3039 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3040 MakeGroups=False, TotalAngle=False):
3042 if isinstance(AngleInRadians,str):
3044 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3046 AngleInRadians = DegreesToRadians(AngleInRadians)
3047 if IDsOfElements == []:
3048 IDsOfElements = self.GetElementsId()
3049 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3050 Axis = self.smeshpyD.GetAxisStruct(Axis)
3051 Axis,AxisParameters = ParseAxisStruct(Axis)
3052 if TotalAngle and NbOfSteps:
3053 AngleInRadians /= NbOfSteps
3054 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3055 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3056 self.mesh.SetParameters(Parameters)
3058 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3059 AngleInRadians, NbOfSteps, Tolerance)
3060 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3063 ## Generates new elements by rotation of the elements of object around the axis
3064 # @param theObject object which elements should be sweeped
3065 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3066 # @param AngleInRadians the angle of Rotation
3067 # @param NbOfSteps number of steps
3068 # @param Tolerance tolerance
3069 # @param MakeGroups forces the generation of new groups from existing ones
3070 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3071 # of all steps, else - size of each step
3072 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3073 # @ingroup l2_modif_extrurev
3074 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3075 MakeGroups=False, TotalAngle=False):
3077 if isinstance(AngleInRadians,str):
3079 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3081 AngleInRadians = DegreesToRadians(AngleInRadians)
3082 if ( isinstance( theObject, Mesh )):
3083 theObject = theObject.GetMesh()
3084 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3085 Axis = self.smeshpyD.GetAxisStruct(Axis)
3086 Axis,AxisParameters = ParseAxisStruct(Axis)
3087 if TotalAngle and NbOfSteps:
3088 AngleInRadians /= NbOfSteps
3089 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3090 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3091 self.mesh.SetParameters(Parameters)
3093 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3094 NbOfSteps, Tolerance)
3095 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3098 ## Generates new elements by rotation of the elements of object around the axis
3099 # @param theObject object which elements should be sweeped
3100 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3101 # @param AngleInRadians the angle of Rotation
3102 # @param NbOfSteps number of steps
3103 # @param Tolerance tolerance
3104 # @param MakeGroups forces the generation of new groups from existing ones
3105 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3106 # of all steps, else - size of each step
3107 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3108 # @ingroup l2_modif_extrurev
3109 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3110 MakeGroups=False, TotalAngle=False):
3112 if isinstance(AngleInRadians,str):
3114 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3116 AngleInRadians = DegreesToRadians(AngleInRadians)
3117 if ( isinstance( theObject, Mesh )):
3118 theObject = theObject.GetMesh()
3119 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3120 Axis = self.smeshpyD.GetAxisStruct(Axis)
3121 Axis,AxisParameters = ParseAxisStruct(Axis)
3122 if TotalAngle and NbOfSteps:
3123 AngleInRadians /= NbOfSteps
3124 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3125 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3126 self.mesh.SetParameters(Parameters)
3128 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3129 NbOfSteps, Tolerance)
3130 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3133 ## Generates new elements by rotation of the elements of object around the axis
3134 # @param theObject object which elements should be sweeped
3135 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3136 # @param AngleInRadians the angle of Rotation
3137 # @param NbOfSteps number of steps
3138 # @param Tolerance tolerance
3139 # @param MakeGroups forces the generation of new groups from existing ones
3140 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3141 # of all steps, else - size of each step
3142 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3143 # @ingroup l2_modif_extrurev
3144 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3145 MakeGroups=False, TotalAngle=False):
3147 if isinstance(AngleInRadians,str):
3149 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3151 AngleInRadians = DegreesToRadians(AngleInRadians)
3152 if ( isinstance( theObject, Mesh )):
3153 theObject = theObject.GetMesh()
3154 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3155 Axis = self.smeshpyD.GetAxisStruct(Axis)
3156 Axis,AxisParameters = ParseAxisStruct(Axis)
3157 if TotalAngle and NbOfSteps:
3158 AngleInRadians /= NbOfSteps
3159 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3160 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3161 self.mesh.SetParameters(Parameters)
3163 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3164 NbOfSteps, Tolerance)
3165 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3168 ## Generates new elements by extrusion of the elements with given ids
3169 # @param IDsOfElements the list of elements ids for extrusion
3170 # @param StepVector vector, defining the direction and value of extrusion
3171 # @param NbOfSteps the number of steps
3172 # @param MakeGroups forces the generation of new groups from existing ones
3173 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3174 # @ingroup l2_modif_extrurev
3175 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3176 if IDsOfElements == []:
3177 IDsOfElements = self.GetElementsId()
3178 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3179 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3180 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3181 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3182 Parameters = StepVectorParameters + var_separator + Parameters
3183 self.mesh.SetParameters(Parameters)
3185 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3186 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3189 ## Generates new elements by extrusion of the elements with given ids
3190 # @param IDsOfElements is ids of elements
3191 # @param StepVector vector, defining the direction and value of extrusion
3192 # @param NbOfSteps the number of steps
3193 # @param ExtrFlags sets flags for extrusion
3194 # @param SewTolerance uses for comparing locations of nodes if flag
3195 # EXTRUSION_FLAG_SEW is set
3196 # @param MakeGroups forces the generation of new groups from existing ones
3197 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3198 # @ingroup l2_modif_extrurev
3199 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3200 ExtrFlags, SewTolerance, MakeGroups=False):
3201 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3202 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3204 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3205 ExtrFlags, SewTolerance)
3206 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3207 ExtrFlags, SewTolerance)
3210 ## Generates new elements by extrusion of the elements which belong to the object
3211 # @param theObject the object which elements should be processed
3212 # @param StepVector vector, defining the direction and value of extrusion
3213 # @param NbOfSteps the number of steps
3214 # @param MakeGroups forces the generation of new groups from existing ones
3215 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3216 # @ingroup l2_modif_extrurev
3217 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3218 if ( isinstance( theObject, Mesh )):
3219 theObject = theObject.GetMesh()
3220 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3221 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3222 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3223 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3224 Parameters = StepVectorParameters + var_separator + Parameters
3225 self.mesh.SetParameters(Parameters)
3227 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3228 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3231 ## Generates new elements by extrusion of the elements which belong to the object
3232 # @param theObject object which elements should be processed
3233 # @param StepVector vector, defining the direction and value of extrusion
3234 # @param NbOfSteps the number of steps
3235 # @param MakeGroups to generate new groups from existing ones
3236 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3237 # @ingroup l2_modif_extrurev
3238 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3239 if ( isinstance( theObject, Mesh )):
3240 theObject = theObject.GetMesh()
3241 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3242 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3243 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3244 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3245 Parameters = StepVectorParameters + var_separator + Parameters
3246 self.mesh.SetParameters(Parameters)
3248 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3249 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3252 ## Generates new elements by extrusion of the elements which belong to the object
3253 # @param theObject object which elements should be processed
3254 # @param StepVector vector, defining the direction and value of extrusion
3255 # @param NbOfSteps the number of steps
3256 # @param MakeGroups forces the generation of new groups from existing ones
3257 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3258 # @ingroup l2_modif_extrurev
3259 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3260 if ( isinstance( theObject, Mesh )):
3261 theObject = theObject.GetMesh()
3262 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3263 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3264 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3265 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3266 Parameters = StepVectorParameters + var_separator + Parameters
3267 self.mesh.SetParameters(Parameters)
3269 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3270 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3275 ## Generates new elements by extrusion of the given elements
3276 # The path of extrusion must be a meshed edge.
3277 # @param Base mesh or list of ids of elements for extrusion
3278 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3279 # @param NodeStart the start node from Path. Defines the direction of extrusion
3280 # @param HasAngles allows the shape to be rotated around the path
3281 # to get the resulting mesh in a helical fashion
3282 # @param Angles list of angles in radians
3283 # @param LinearVariation forces the computation of rotation angles as linear
3284 # variation of the given Angles along path steps
3285 # @param HasRefPoint allows using the reference point
3286 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3287 # The User can specify any point as the Reference Point.
3288 # @param MakeGroups forces the generation of new groups from existing ones
3289 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3290 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3291 # only SMESH::Extrusion_Error otherwise
3292 # @ingroup l2_modif_extrurev
3293 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3294 HasAngles, Angles, LinearVariation,
3295 HasRefPoint, RefPoint, MakeGroups, ElemType):
3296 Angles,AnglesParameters = ParseAngles(Angles)
3297 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3298 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3299 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3301 Parameters = AnglesParameters + var_separator + RefPointParameters
3302 self.mesh.SetParameters(Parameters)
3304 if isinstance(Base,list):
3306 if Base == []: IDsOfElements = self.GetElementsId()
3307 else: IDsOfElements = Base
3308 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3309 HasAngles, Angles, LinearVariation,
3310 HasRefPoint, RefPoint, MakeGroups, ElemType)
3312 if isinstance(Base,Mesh):
3313 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3314 HasAngles, Angles, LinearVariation,
3315 HasRefPoint, RefPoint, MakeGroups, ElemType)
3317 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3320 ## Generates new elements by extrusion of the given elements
3321 # The path of extrusion must be a meshed edge.
3322 # @param IDsOfElements ids of elements
3323 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3324 # @param PathShape shape(edge) defines the sub-mesh for the path
3325 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3326 # @param HasAngles allows the shape to be rotated around the path
3327 # to get the resulting mesh in a helical fashion
3328 # @param Angles list of angles in radians
3329 # @param HasRefPoint allows using the reference point
3330 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3331 # The User can specify any point as the Reference Point.
3332 # @param MakeGroups forces the generation of new groups from existing ones
3333 # @param LinearVariation forces the computation of rotation angles as linear
3334 # variation of the given Angles along path steps
3335 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3336 # only SMESH::Extrusion_Error otherwise
3337 # @ingroup l2_modif_extrurev
3338 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3339 HasAngles, Angles, HasRefPoint, RefPoint,
3340 MakeGroups=False, LinearVariation=False):
3341 Angles,AnglesParameters = ParseAngles(Angles)
3342 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3343 if IDsOfElements == []:
3344 IDsOfElements = self.GetElementsId()
3345 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3346 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3348 if ( isinstance( PathMesh, Mesh )):
3349 PathMesh = PathMesh.GetMesh()
3350 if HasAngles and Angles and LinearVariation:
3351 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3353 Parameters = AnglesParameters + var_separator + RefPointParameters
3354 self.mesh.SetParameters(Parameters)
3356 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3357 PathShape, NodeStart, HasAngles,
3358 Angles, HasRefPoint, RefPoint)
3359 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3360 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3362 ## Generates new elements by extrusion of the elements which belong to the object
3363 # The path of extrusion must be a meshed edge.
3364 # @param theObject the object which elements should be processed
3365 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3366 # @param PathShape shape(edge) defines the sub-mesh for the path
3367 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3368 # @param HasAngles allows the shape to be rotated around the path
3369 # to get the resulting mesh in a helical fashion
3370 # @param Angles list of angles
3371 # @param HasRefPoint allows using the reference point
3372 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3373 # The User can specify any point as the Reference Point.
3374 # @param MakeGroups forces the generation of new groups from existing ones
3375 # @param LinearVariation forces the computation of rotation angles as linear
3376 # variation of the given Angles along path steps
3377 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3378 # only SMESH::Extrusion_Error otherwise
3379 # @ingroup l2_modif_extrurev
3380 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3381 HasAngles, Angles, HasRefPoint, RefPoint,
3382 MakeGroups=False, LinearVariation=False):
3383 Angles,AnglesParameters = ParseAngles(Angles)
3384 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3385 if ( isinstance( theObject, Mesh )):
3386 theObject = theObject.GetMesh()
3387 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3388 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3389 if ( isinstance( PathMesh, Mesh )):
3390 PathMesh = PathMesh.GetMesh()
3391 if HasAngles and Angles and LinearVariation:
3392 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3394 Parameters = AnglesParameters + var_separator + RefPointParameters
3395 self.mesh.SetParameters(Parameters)
3397 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3398 PathShape, NodeStart, HasAngles,
3399 Angles, HasRefPoint, RefPoint)
3400 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3401 NodeStart, HasAngles, Angles, HasRefPoint,
3404 ## Generates new elements by extrusion of the elements which belong to the object
3405 # The path of extrusion must be a meshed edge.
3406 # @param theObject the object which elements should be processed
3407 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3408 # @param PathShape shape(edge) defines the sub-mesh for the path
3409 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3410 # @param HasAngles allows the shape to be rotated around the path
3411 # to get the resulting mesh in a helical fashion
3412 # @param Angles list of angles
3413 # @param HasRefPoint allows using the reference point
3414 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3415 # The User can specify any point as the Reference Point.
3416 # @param MakeGroups forces the generation of new groups from existing ones
3417 # @param LinearVariation forces the computation of rotation angles as linear
3418 # variation of the given Angles along path steps
3419 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3420 # only SMESH::Extrusion_Error otherwise
3421 # @ingroup l2_modif_extrurev
3422 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3423 HasAngles, Angles, HasRefPoint, RefPoint,
3424 MakeGroups=False, LinearVariation=False):
3425 Angles,AnglesParameters = ParseAngles(Angles)
3426 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3427 if ( isinstance( theObject, Mesh )):
3428 theObject = theObject.GetMesh()
3429 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3430 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3431 if ( isinstance( PathMesh, Mesh )):
3432 PathMesh = PathMesh.GetMesh()
3433 if HasAngles and Angles and LinearVariation:
3434 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3436 Parameters = AnglesParameters + var_separator + RefPointParameters
3437 self.mesh.SetParameters(Parameters)
3439 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3440 PathShape, NodeStart, HasAngles,
3441 Angles, HasRefPoint, RefPoint)
3442 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3443 NodeStart, HasAngles, Angles, HasRefPoint,
3446 ## Generates new elements by extrusion of the elements which belong to the object
3447 # The path of extrusion must be a meshed edge.
3448 # @param theObject the object which elements should be processed
3449 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3450 # @param PathShape shape(edge) defines the sub-mesh for the path
3451 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3452 # @param HasAngles allows the shape to be rotated around the path
3453 # to get the resulting mesh in a helical fashion
3454 # @param Angles list of angles
3455 # @param HasRefPoint allows using the reference point
3456 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3457 # The User can specify any point as the Reference Point.
3458 # @param MakeGroups forces the generation of new groups from existing ones
3459 # @param LinearVariation forces the computation of rotation angles as linear
3460 # variation of the given Angles along path steps
3461 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3462 # only SMESH::Extrusion_Error otherwise
3463 # @ingroup l2_modif_extrurev
3464 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3465 HasAngles, Angles, HasRefPoint, RefPoint,
3466 MakeGroups=False, LinearVariation=False):
3467 Angles,AnglesParameters = ParseAngles(Angles)
3468 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3469 if ( isinstance( theObject, Mesh )):
3470 theObject = theObject.GetMesh()
3471 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3472 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3473 if ( isinstance( PathMesh, Mesh )):
3474 PathMesh = PathMesh.GetMesh()
3475 if HasAngles and Angles and LinearVariation:
3476 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3478 Parameters = AnglesParameters + var_separator + RefPointParameters
3479 self.mesh.SetParameters(Parameters)
3481 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3482 PathShape, NodeStart, HasAngles,
3483 Angles, HasRefPoint, RefPoint)
3484 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3485 NodeStart, HasAngles, Angles, HasRefPoint,
3488 ## Creates a symmetrical copy of mesh elements
3489 # @param IDsOfElements list of elements ids
3490 # @param Mirror is AxisStruct or geom object(point, line, plane)
3491 # @param theMirrorType is POINT, AXIS or PLANE
3492 # If the Mirror is a geom object this parameter is unnecessary
3493 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3494 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3495 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3496 # @ingroup l2_modif_trsf
3497 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3498 if IDsOfElements == []:
3499 IDsOfElements = self.GetElementsId()
3500 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3501 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3502 Mirror,Parameters = ParseAxisStruct(Mirror)
3503 self.mesh.SetParameters(Parameters)
3504 if Copy and MakeGroups:
3505 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3506 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3509 ## Creates a new mesh by a symmetrical copy of mesh elements
3510 # @param IDsOfElements the list of elements ids
3511 # @param Mirror is AxisStruct or geom object (point, line, plane)
3512 # @param theMirrorType is POINT, AXIS or PLANE
3513 # If the Mirror is a geom object this parameter is unnecessary
3514 # @param MakeGroups to generate new groups from existing ones
3515 # @param NewMeshName a name of the new mesh to create
3516 # @return instance of Mesh class
3517 # @ingroup l2_modif_trsf
3518 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3519 if IDsOfElements == []:
3520 IDsOfElements = self.GetElementsId()
3521 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3522 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3523 Mirror,Parameters = ParseAxisStruct(Mirror)
3524 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3525 MakeGroups, NewMeshName)
3526 mesh.SetParameters(Parameters)
3527 return Mesh(self.smeshpyD,self.geompyD,mesh)
3529 ## Creates a symmetrical copy of the object
3530 # @param theObject mesh, submesh or group
3531 # @param Mirror AxisStruct or geom object (point, line, plane)
3532 # @param theMirrorType is POINT, AXIS or PLANE
3533 # If the Mirror is a geom object this parameter is unnecessary
3534 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3535 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3536 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3537 # @ingroup l2_modif_trsf
3538 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3539 if ( isinstance( theObject, Mesh )):
3540 theObject = theObject.GetMesh()
3541 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3542 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3543 Mirror,Parameters = ParseAxisStruct(Mirror)
3544 self.mesh.SetParameters(Parameters)
3545 if Copy and MakeGroups:
3546 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3547 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3550 ## Creates a new mesh by a symmetrical copy of the object
3551 # @param theObject mesh, submesh or group
3552 # @param Mirror AxisStruct or geom object (point, line, plane)
3553 # @param theMirrorType POINT, AXIS or PLANE
3554 # If the Mirror is a geom object this parameter is unnecessary
3555 # @param MakeGroups forces the generation of new groups from existing ones
3556 # @param NewMeshName the name of the new mesh to create
3557 # @return instance of Mesh class
3558 # @ingroup l2_modif_trsf
3559 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3560 if ( isinstance( theObject, Mesh )):
3561 theObject = theObject.GetMesh()
3562 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3563 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3564 Mirror,Parameters = ParseAxisStruct(Mirror)
3565 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3566 MakeGroups, NewMeshName)
3567 mesh.SetParameters(Parameters)
3568 return Mesh( self.smeshpyD,self.geompyD,mesh )
3570 ## Translates the elements
3571 # @param IDsOfElements list of elements ids
3572 # @param Vector the direction of translation (DirStruct or vector)
3573 # @param Copy allows copying the translated elements
3574 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3575 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3576 # @ingroup l2_modif_trsf
3577 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3578 if IDsOfElements == []:
3579 IDsOfElements = self.GetElementsId()
3580 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3581 Vector = self.smeshpyD.GetDirStruct(Vector)
3582 Vector,Parameters = ParseDirStruct(Vector)
3583 self.mesh.SetParameters(Parameters)
3584 if Copy and MakeGroups:
3585 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3586 self.editor.Translate(IDsOfElements, Vector, Copy)
3589 ## Creates a new mesh of translated elements
3590 # @param IDsOfElements list of elements ids
3591 # @param Vector the direction of translation (DirStruct or vector)
3592 # @param MakeGroups forces the generation of new groups from existing ones
3593 # @param NewMeshName the name of the newly created mesh
3594 # @return instance of Mesh class
3595 # @ingroup l2_modif_trsf
3596 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3597 if IDsOfElements == []:
3598 IDsOfElements = self.GetElementsId()
3599 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3600 Vector = self.smeshpyD.GetDirStruct(Vector)
3601 Vector,Parameters = ParseDirStruct(Vector)
3602 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3603 mesh.SetParameters(Parameters)
3604 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3606 ## Translates the object
3607 # @param theObject the object to translate (mesh, submesh, or group)
3608 # @param Vector direction of translation (DirStruct or geom vector)
3609 # @param Copy allows copying the translated elements
3610 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3611 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3612 # @ingroup l2_modif_trsf
3613 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3614 if ( isinstance( theObject, Mesh )):
3615 theObject = theObject.GetMesh()
3616 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3617 Vector = self.smeshpyD.GetDirStruct(Vector)
3618 Vector,Parameters = ParseDirStruct(Vector)
3619 self.mesh.SetParameters(Parameters)
3620 if Copy and MakeGroups:
3621 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3622 self.editor.TranslateObject(theObject, Vector, Copy)
3625 ## Creates a new mesh from the translated object
3626 # @param theObject the object to translate (mesh, submesh, or group)
3627 # @param Vector the direction of translation (DirStruct or geom vector)
3628 # @param MakeGroups forces the generation of new groups from existing ones
3629 # @param NewMeshName the name of the newly created mesh
3630 # @return instance of Mesh class
3631 # @ingroup l2_modif_trsf
3632 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3633 if (isinstance(theObject, Mesh)):
3634 theObject = theObject.GetMesh()
3635 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3636 Vector = self.smeshpyD.GetDirStruct(Vector)
3637 Vector,Parameters = ParseDirStruct(Vector)
3638 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3639 mesh.SetParameters(Parameters)
3640 return Mesh( self.smeshpyD, self.geompyD, mesh )
3644 ## Scales the object
3645 # @param theObject - the object to translate (mesh, submesh, or group)
3646 # @param thePoint - base point for scale
3647 # @param theScaleFact - list of 1-3 scale factors for axises
3648 # @param Copy - allows copying the translated elements
3649 # @param MakeGroups - forces the generation of new groups from existing
3651 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3652 # empty list otherwise
3653 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3654 if ( isinstance( theObject, Mesh )):
3655 theObject = theObject.GetMesh()
3656 if ( isinstance( theObject, list )):
3657 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3659 thePoint, Parameters = ParsePointStruct(thePoint)
3660 self.mesh.SetParameters(Parameters)
3662 if Copy and MakeGroups:
3663 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3664 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3667 ## Creates a new mesh from the translated object
3668 # @param theObject - the object to translate (mesh, submesh, or group)
3669 # @param thePoint - base point for scale
3670 # @param theScaleFact - list of 1-3 scale factors for axises
3671 # @param MakeGroups - forces the generation of new groups from existing ones
3672 # @param NewMeshName - the name of the newly created mesh
3673 # @return instance of Mesh class
3674 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3675 if (isinstance(theObject, Mesh)):
3676 theObject = theObject.GetMesh()
3677 if ( isinstance( theObject, list )):
3678 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3680 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3681 MakeGroups, NewMeshName)
3682 #mesh.SetParameters(Parameters)
3683 return Mesh( self.smeshpyD, self.geompyD, mesh )
3687 ## Rotates the elements
3688 # @param IDsOfElements list of elements ids
3689 # @param Axis the axis of rotation (AxisStruct or geom line)
3690 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3691 # @param Copy allows copying the rotated elements
3692 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3693 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3694 # @ingroup l2_modif_trsf
3695 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3697 if isinstance(AngleInRadians,str):
3699 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3701 AngleInRadians = DegreesToRadians(AngleInRadians)
3702 if IDsOfElements == []:
3703 IDsOfElements = self.GetElementsId()
3704 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3705 Axis = self.smeshpyD.GetAxisStruct(Axis)
3706 Axis,AxisParameters = ParseAxisStruct(Axis)
3707 Parameters = AxisParameters + var_separator + Parameters
3708 self.mesh.SetParameters(Parameters)
3709 if Copy and MakeGroups:
3710 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3711 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3714 ## Creates a new mesh of rotated elements
3715 # @param IDsOfElements list of element ids
3716 # @param Axis the axis of rotation (AxisStruct or geom line)
3717 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3718 # @param MakeGroups forces the generation of new groups from existing ones
3719 # @param NewMeshName the name of the newly created mesh
3720 # @return instance of Mesh class
3721 # @ingroup l2_modif_trsf
3722 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3724 if isinstance(AngleInRadians,str):
3726 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3728 AngleInRadians = DegreesToRadians(AngleInRadians)
3729 if IDsOfElements == []:
3730 IDsOfElements = self.GetElementsId()
3731 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3732 Axis = self.smeshpyD.GetAxisStruct(Axis)
3733 Axis,AxisParameters = ParseAxisStruct(Axis)
3734 Parameters = AxisParameters + var_separator + Parameters
3735 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3736 MakeGroups, NewMeshName)
3737 mesh.SetParameters(Parameters)
3738 return Mesh( self.smeshpyD, self.geompyD, mesh )
3740 ## Rotates the object
3741 # @param theObject the object to rotate( mesh, submesh, or group)
3742 # @param Axis the axis of rotation (AxisStruct or geom line)
3743 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3744 # @param Copy allows copying the rotated elements
3745 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3746 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3747 # @ingroup l2_modif_trsf
3748 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3750 if isinstance(AngleInRadians,str):
3752 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3754 AngleInRadians = DegreesToRadians(AngleInRadians)
3755 if (isinstance(theObject, Mesh)):
3756 theObject = theObject.GetMesh()
3757 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3758 Axis = self.smeshpyD.GetAxisStruct(Axis)
3759 Axis,AxisParameters = ParseAxisStruct(Axis)
3760 Parameters = AxisParameters + ":" + Parameters
3761 self.mesh.SetParameters(Parameters)
3762 if Copy and MakeGroups:
3763 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3764 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3767 ## Creates a new mesh from the rotated object
3768 # @param theObject the object to rotate (mesh, submesh, or group)
3769 # @param Axis the axis of rotation (AxisStruct or geom line)
3770 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3771 # @param MakeGroups forces the generation of new groups from existing ones
3772 # @param NewMeshName the name of the newly created mesh
3773 # @return instance of Mesh class
3774 # @ingroup l2_modif_trsf
3775 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3777 if isinstance(AngleInRadians,str):
3779 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3781 AngleInRadians = DegreesToRadians(AngleInRadians)
3782 if (isinstance( theObject, Mesh )):
3783 theObject = theObject.GetMesh()
3784 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3785 Axis = self.smeshpyD.GetAxisStruct(Axis)
3786 Axis,AxisParameters = ParseAxisStruct(Axis)
3787 Parameters = AxisParameters + ":" + Parameters
3788 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3789 MakeGroups, NewMeshName)
3790 mesh.SetParameters(Parameters)
3791 return Mesh( self.smeshpyD, self.geompyD, mesh )
3793 ## Finds groups of ajacent nodes within Tolerance.
3794 # @param Tolerance the value of tolerance
3795 # @return the list of groups of nodes
3796 # @ingroup l2_modif_trsf
3797 def FindCoincidentNodes (self, Tolerance):
3798 return self.editor.FindCoincidentNodes(Tolerance)
3800 ## Finds groups of ajacent nodes within Tolerance.
3801 # @param Tolerance the value of tolerance
3802 # @param SubMeshOrGroup SubMesh or Group
3803 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3804 # @return the list of groups of nodes
3805 # @ingroup l2_modif_trsf
3806 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3807 if (isinstance( SubMeshOrGroup, Mesh )):
3808 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3809 if not isinstance( ExceptSubMeshOrGroups, list):
3810 ExceptSubMeshOrGroups = [ ExceptSubMeshOrGroups ]
3811 if ExceptSubMeshOrGroups and isinstance( ExceptSubMeshOrGroups[0], int):
3812 ExceptSubMeshOrGroups = [ self.editor.MakeIDSource( ExceptSubMeshOrGroups, SMESH.NODE)]
3813 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,ExceptSubMeshOrGroups)
3816 # @param GroupsOfNodes the list of groups of nodes
3817 # @ingroup l2_modif_trsf
3818 def MergeNodes (self, GroupsOfNodes):
3819 self.editor.MergeNodes(GroupsOfNodes)
3821 ## Finds the elements built on the same nodes.
3822 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3823 # @return a list of groups of equal elements
3824 # @ingroup l2_modif_trsf
3825 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3826 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3827 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3828 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3830 ## Merges elements in each given group.
3831 # @param GroupsOfElementsID groups of elements for merging
3832 # @ingroup l2_modif_trsf
3833 def MergeElements(self, GroupsOfElementsID):
3834 self.editor.MergeElements(GroupsOfElementsID)
3836 ## Leaves one element and removes all other elements built on the same nodes.
3837 # @ingroup l2_modif_trsf
3838 def MergeEqualElements(self):
3839 self.editor.MergeEqualElements()
3841 ## Sews free borders
3842 # @return SMESH::Sew_Error
3843 # @ingroup l2_modif_trsf
3844 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3845 FirstNodeID2, SecondNodeID2, LastNodeID2,
3846 CreatePolygons, CreatePolyedrs):
3847 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3848 FirstNodeID2, SecondNodeID2, LastNodeID2,
3849 CreatePolygons, CreatePolyedrs)
3851 ## Sews conform free borders
3852 # @return SMESH::Sew_Error
3853 # @ingroup l2_modif_trsf
3854 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3855 FirstNodeID2, SecondNodeID2):
3856 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3857 FirstNodeID2, SecondNodeID2)
3859 ## Sews border to side
3860 # @return SMESH::Sew_Error
3861 # @ingroup l2_modif_trsf
3862 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3863 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3864 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3865 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3867 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3868 # merged with the nodes of elements of Side2.
3869 # The number of elements in theSide1 and in theSide2 must be
3870 # equal and they should have similar nodal connectivity.
3871 # The nodes to merge should belong to side borders and
3872 # the first node should be linked to the second.
3873 # @return SMESH::Sew_Error
3874 # @ingroup l2_modif_trsf
3875 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3876 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3877 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3878 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3879 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3880 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3882 ## Sets new nodes for the given element.
3883 # @param ide the element id
3884 # @param newIDs nodes ids
3885 # @return If the number of nodes does not correspond to the type of element - returns false
3886 # @ingroup l2_modif_edit
3887 def ChangeElemNodes(self, ide, newIDs):
3888 return self.editor.ChangeElemNodes(ide, newIDs)
3890 ## If during the last operation of MeshEditor some nodes were
3891 # created, this method returns the list of their IDs, \n
3892 # if new nodes were not created - returns empty list
3893 # @return the list of integer values (can be empty)
3894 # @ingroup l1_auxiliary
3895 def GetLastCreatedNodes(self):
3896 return self.editor.GetLastCreatedNodes()
3898 ## If during the last operation of MeshEditor some elements were
3899 # created this method returns the list of their IDs, \n
3900 # if new elements were not created - returns empty list
3901 # @return the list of integer values (can be empty)
3902 # @ingroup l1_auxiliary
3903 def GetLastCreatedElems(self):
3904 return self.editor.GetLastCreatedElems()
3906 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3907 # @param theNodes identifiers of nodes to be doubled
3908 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3909 # nodes. If list of element identifiers is empty then nodes are doubled but
3910 # they not assigned to elements
3911 # @return TRUE if operation has been completed successfully, FALSE otherwise
3912 # @ingroup l2_modif_edit
3913 def DoubleNodes(self, theNodes, theModifiedElems):
3914 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3916 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3917 # This method provided for convenience works as DoubleNodes() described above.
3918 # @param theNodeId identifiers of node to be doubled
3919 # @param theModifiedElems identifiers of elements to be updated
3920 # @return TRUE if operation has been completed successfully, FALSE otherwise
3921 # @ingroup l2_modif_edit
3922 def DoubleNode(self, theNodeId, theModifiedElems):
3923 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3925 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3926 # This method provided for convenience works as DoubleNodes() described above.
3927 # @param theNodes group of nodes to be doubled
3928 # @param theModifiedElems group of elements to be updated.
3929 # @param theMakeGroup forces the generation of a group containing new nodes.
3930 # @return TRUE or a created group if operation has been completed successfully,
3931 # FALSE or None otherwise
3932 # @ingroup l2_modif_edit
3933 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3935 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3936 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3938 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3939 # This method provided for convenience works as DoubleNodes() described above.
3940 # @param theNodes list of groups of nodes to be doubled
3941 # @param theModifiedElems list of groups of elements to be updated.
3942 # @return TRUE if operation has been completed successfully, FALSE otherwise
3943 # @ingroup l2_modif_edit
3944 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3945 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3947 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3948 # @param theElems - the list of elements (edges or faces) to be replicated
3949 # The nodes for duplication could be found from these elements
3950 # @param theNodesNot - list of nodes to NOT replicate
3951 # @param theAffectedElems - the list of elements (cells and edges) to which the
3952 # replicated nodes should be associated to.
3953 # @return TRUE if operation has been completed successfully, FALSE otherwise
3954 # @ingroup l2_modif_edit
3955 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3956 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3958 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3959 # @param theElems - the list of elements (edges or faces) to be replicated
3960 # The nodes for duplication could be found from these elements
3961 # @param theNodesNot - list of nodes to NOT replicate
3962 # @param theShape - shape to detect affected elements (element which geometric center
3963 # located on or inside shape).
3964 # The replicated nodes should be associated to affected elements.
3965 # @return TRUE if operation has been completed successfully, FALSE otherwise
3966 # @ingroup l2_modif_edit
3967 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3968 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3970 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3971 # This method provided for convenience works as DoubleNodes() described above.
3972 # @param theElems - group of of elements (edges or faces) to be replicated
3973 # @param theNodesNot - group of nodes not to replicated
3974 # @param theAffectedElems - group of elements to which the replicated nodes
3975 # should be associated to.
3976 # @param theMakeGroup forces the generation of a group containing new elements.
3977 # @ingroup l2_modif_edit
3978 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3980 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3981 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3983 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3984 # This method provided for convenience works as DoubleNodes() described above.
3985 # @param theElems - group of of elements (edges or faces) to be replicated
3986 # @param theNodesNot - group of nodes not to replicated
3987 # @param theShape - shape to detect affected elements (element which geometric center
3988 # located on or inside shape).
3989 # The replicated nodes should be associated to affected elements.
3990 # @ingroup l2_modif_edit
3991 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3992 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3994 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3995 # This method provided for convenience works as DoubleNodes() described above.
3996 # @param theElems - list of groups of elements (edges or faces) to be replicated
3997 # @param theNodesNot - list of groups of nodes not to replicated
3998 # @param theAffectedElems - group of elements to which the replicated nodes
3999 # should be associated to.
4000 # @return TRUE if operation has been completed successfully, FALSE otherwise
4001 # @ingroup l2_modif_edit
4002 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
4003 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4005 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4006 # This method provided for convenience works as DoubleNodes() described above.
4007 # @param theElems - list of groups of elements (edges or faces) to be replicated
4008 # @param theNodesNot - list of groups of nodes not to replicated
4009 # @param theShape - shape to detect affected elements (element which geometric center
4010 # located on or inside shape).
4011 # The replicated nodes should be associated to affected elements.
4012 # @return TRUE if operation has been completed successfully, FALSE otherwise
4013 # @ingroup l2_modif_edit
4014 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4015 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4017 def _valueFromFunctor(self, funcType, elemId):
4018 fn = self.smeshpyD.GetFunctor(funcType)
4019 fn.SetMesh(self.mesh)
4020 if fn.GetElementType() == self.GetElementType(elemId, True):
4021 val = fn.GetValue(elemId)
4026 ## Get length of 1D element.
4027 # @param elemId mesh element ID
4028 # @return element's length value
4029 # @ingroup l1_measurements
4030 def GetLength(self, elemId):
4031 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4033 ## Get area of 2D element.
4034 # @param elemId mesh element ID
4035 # @return element's area value
4036 # @ingroup l1_measurements
4037 def GetArea(self, elemId):
4038 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4040 ## Get volume of 3D element.
4041 # @param elemId mesh element ID
4042 # @return element's volume value
4043 # @ingroup l1_measurements
4044 def GetVolume(self, elemId):
4045 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4047 ## Get maximum element length.
4048 # @param elemId mesh element ID
4049 # @return element's maximum length value
4050 # @ingroup l1_measurements
4051 def GetMaxElementLength(self, elemId):
4052 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4053 ftype = SMESH.FT_MaxElementLength3D
4055 ftype = SMESH.FT_MaxElementLength2D
4056 return self._valueFromFunctor(ftype, elemId)
4058 ## Get aspect ratio of 2D or 3D element.
4059 # @param elemId mesh element ID
4060 # @return element's aspect ratio value
4061 # @ingroup l1_measurements
4062 def GetAspectRatio(self, elemId):
4063 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4064 ftype = SMESH.FT_AspectRatio3D
4066 ftype = SMESH.FT_AspectRatio
4067 return self._valueFromFunctor(ftype, elemId)
4069 ## Get warping angle of 2D element.
4070 # @param elemId mesh element ID
4071 # @return element's warping angle value
4072 # @ingroup l1_measurements
4073 def GetWarping(self, elemId):
4074 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4076 ## Get minimum angle of 2D element.
4077 # @param elemId mesh element ID
4078 # @return element's minimum angle value
4079 # @ingroup l1_measurements
4080 def GetMinimumAngle(self, elemId):
4081 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4083 ## Get taper of 2D element.
4084 # @param elemId mesh element ID
4085 # @return element's taper value
4086 # @ingroup l1_measurements
4087 def GetTaper(self, elemId):
4088 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4090 ## Get skew of 2D element.
4091 # @param elemId mesh element ID
4092 # @return element's skew value
4093 # @ingroup l1_measurements
4094 def GetSkew(self, elemId):
4095 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4097 ## The mother class to define algorithm, it is not recommended to use it directly.
4100 # @ingroup l2_algorithms
4101 class Mesh_Algorithm:
4102 # @class Mesh_Algorithm
4103 # @brief Class Mesh_Algorithm
4105 #def __init__(self,smesh):
4113 ## Finds a hypothesis in the study by its type name and parameters.
4114 # Finds only the hypotheses created in smeshpyD engine.
4115 # @return SMESH.SMESH_Hypothesis
4116 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4117 study = smeshpyD.GetCurrentStudy()
4118 #to do: find component by smeshpyD object, not by its data type
4119 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4120 if scomp is not None:
4121 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4122 # Check if the root label of the hypotheses exists
4123 if res and hypRoot is not None:
4124 iter = study.NewChildIterator(hypRoot)
4125 # Check all published hypotheses
4127 hypo_so_i = iter.Value()
4128 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4129 if attr is not None:
4130 anIOR = attr.Value()
4131 hypo_o_i = salome.orb.string_to_object(anIOR)
4132 if hypo_o_i is not None:
4133 # Check if this is a hypothesis
4134 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4135 if hypo_i is not None:
4136 # Check if the hypothesis belongs to current engine
4137 if smeshpyD.GetObjectId(hypo_i) > 0:
4138 # Check if this is the required hypothesis
4139 if hypo_i.GetName() == hypname:
4141 if CompareMethod(hypo_i, args):
4155 ## Finds the algorithm in the study by its type name.
4156 # Finds only the algorithms, which have been created in smeshpyD engine.
4157 # @return SMESH.SMESH_Algo
4158 def FindAlgorithm (self, algoname, smeshpyD):
4159 study = smeshpyD.GetCurrentStudy()
4160 #to do: find component by smeshpyD object, not by its data type
4161 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4162 if scomp is not None:
4163 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4164 # Check if the root label of the algorithms exists
4165 if res and hypRoot is not None:
4166 iter = study.NewChildIterator(hypRoot)
4167 # Check all published algorithms
4169 algo_so_i = iter.Value()
4170 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4171 if attr is not None:
4172 anIOR = attr.Value()
4173 algo_o_i = salome.orb.string_to_object(anIOR)
4174 if algo_o_i is not None:
4175 # Check if this is an algorithm
4176 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4177 if algo_i is not None:
4178 # Checks if the algorithm belongs to the current engine
4179 if smeshpyD.GetObjectId(algo_i) > 0:
4180 # Check if this is the required algorithm
4181 if algo_i.GetName() == algoname:
4194 ## If the algorithm is global, returns 0; \n
4195 # else returns the submesh associated to this algorithm.
4196 def GetSubMesh(self):
4199 ## Returns the wrapped mesher.
4200 def GetAlgorithm(self):
4203 ## Gets the list of hypothesis that can be used with this algorithm
4204 def GetCompatibleHypothesis(self):
4207 mylist = self.algo.GetCompatibleHypothesis()
4210 ## Gets the name of the algorithm
4214 ## Sets the name to the algorithm
4215 def SetName(self, name):
4216 self.mesh.smeshpyD.SetName(self.algo, name)
4218 ## Gets the id of the algorithm
4220 return self.algo.GetId()
4223 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4225 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4226 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4228 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4230 self.Assign(algo, mesh, geom)
4234 def Assign(self, algo, mesh, geom):
4236 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4245 name = GetName(geom)
4248 name = mesh.geompyD.SubShapeName(geom, piece)
4249 mesh.geompyD.addToStudyInFather(piece, geom, name)
4251 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4254 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4255 TreatHypoStatus( status, algo.GetName(), name, True )
4257 def CompareHyp (self, hyp, args):
4258 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4261 def CompareEqualHyp (self, hyp, args):
4265 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4266 UseExisting=0, CompareMethod=""):
4269 if CompareMethod == "": CompareMethod = self.CompareHyp
4270 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4273 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4279 a = a + s + str(args[i])
4283 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4285 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4286 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4289 ## Returns entry of the shape to mesh in the study
4290 def MainShapeEntry(self):
4292 if not self.mesh or not self.mesh.GetMesh(): return entry
4293 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4294 study = self.mesh.smeshpyD.GetCurrentStudy()
4295 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4296 sobj = study.FindObjectIOR(ior)
4297 if sobj: entry = sobj.GetID()
4298 if not entry: return ""
4301 # Public class: Mesh_Segment
4302 # --------------------------
4304 ## Class to define a segment 1D algorithm for discretization
4307 # @ingroup l3_algos_basic
4308 class Mesh_Segment(Mesh_Algorithm):
4310 ## Private constructor.
4311 def __init__(self, mesh, geom=0):
4312 Mesh_Algorithm.__init__(self)
4313 self.Create(mesh, geom, "Regular_1D")
4315 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4316 # @param l for the length of segments that cut an edge
4317 # @param UseExisting if ==true - searches for an existing hypothesis created with
4318 # the same parameters, else (default) - creates a new one
4319 # @param p precision, used for calculation of the number of segments.
4320 # The precision should be a positive, meaningful value within the range [0,1].
4321 # In general, the number of segments is calculated with the formula:
4322 # nb = ceil((edge_length / l) - p)
4323 # Function ceil rounds its argument to the higher integer.
4324 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4325 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4326 # p=1 means rounding of (edge_length / l) to the lower integer.
4327 # Default value is 1e-07.
4328 # @return an instance of StdMeshers_LocalLength hypothesis
4329 # @ingroup l3_hypos_1dhyps
4330 def LocalLength(self, l, UseExisting=0, p=1e-07):
4331 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4332 CompareMethod=self.CompareLocalLength)
4338 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4339 def CompareLocalLength(self, hyp, args):
4340 if IsEqual(hyp.GetLength(), args[0]):
4341 return IsEqual(hyp.GetPrecision(), args[1])
4344 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4345 # @param length is optional maximal allowed length of segment, if it is omitted
4346 # the preestimated length is used that depends on geometry size
4347 # @param UseExisting if ==true - searches for an existing hypothesis created with
4348 # the same parameters, else (default) - create a new one
4349 # @return an instance of StdMeshers_MaxLength hypothesis
4350 # @ingroup l3_hypos_1dhyps
4351 def MaxSize(self, length=0.0, UseExisting=0):
4352 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4355 hyp.SetLength(length)
4357 # set preestimated length
4358 gen = self.mesh.smeshpyD
4359 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4360 self.mesh.GetMesh(), self.mesh.GetShape(),
4362 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4364 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4367 hyp.SetUsePreestimatedLength( length == 0.0 )
4370 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4371 # @param n for the number of segments that cut an edge
4372 # @param s for the scale factor (optional)
4373 # @param reversedEdges is a list of edges to mesh using reversed orientation
4374 # @param UseExisting if ==true - searches for an existing hypothesis created with
4375 # the same parameters, else (default) - create a new one
4376 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4377 # @ingroup l3_hypos_1dhyps
4378 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4379 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4380 reversedEdges, UseExisting = [], reversedEdges
4381 entry = self.MainShapeEntry()
4383 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4384 UseExisting=UseExisting,
4385 CompareMethod=self.CompareNumberOfSegments)
4387 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4388 UseExisting=UseExisting,
4389 CompareMethod=self.CompareNumberOfSegments)
4390 hyp.SetDistrType( 1 )
4391 hyp.SetScaleFactor(s)
4392 hyp.SetNumberOfSegments(n)
4393 hyp.SetReversedEdges( reversedEdges )
4394 hyp.SetObjectEntry( entry )
4398 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4399 def CompareNumberOfSegments(self, hyp, args):
4400 if hyp.GetNumberOfSegments() == args[0]:
4402 if hyp.GetReversedEdges() == args[1]:
4403 if not args[1] or hyp.GetObjectEntry() == args[2]:
4406 if hyp.GetReversedEdges() == args[2]:
4407 if not args[2] or hyp.GetObjectEntry() == args[3]:
4408 if hyp.GetDistrType() == 1:
4409 if IsEqual(hyp.GetScaleFactor(), args[1]):
4413 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4414 # @param start defines the length of the first segment
4415 # @param end defines the length of the last segment
4416 # @param reversedEdges is a list of edges to mesh using reversed orientation
4417 # @param UseExisting if ==true - searches for an existing hypothesis created with
4418 # the same parameters, else (default) - creates a new one
4419 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4420 # @ingroup l3_hypos_1dhyps
4421 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4422 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4423 reversedEdges, UseExisting = [], reversedEdges
4424 entry = self.MainShapeEntry()
4425 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4426 UseExisting=UseExisting,
4427 CompareMethod=self.CompareArithmetic1D)
4428 hyp.SetStartLength(start)
4429 hyp.SetEndLength(end)
4430 hyp.SetReversedEdges( reversedEdges )
4431 hyp.SetObjectEntry( entry )
4435 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4436 def CompareArithmetic1D(self, hyp, args):
4437 if IsEqual(hyp.GetLength(1), args[0]):
4438 if IsEqual(hyp.GetLength(0), args[1]):
4439 if hyp.GetReversedEdges() == args[2]:
4440 if not args[2] or hyp.GetObjectEntry() == args[3]:
4445 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4446 # on curve from 0 to 1 (additionally it is neecessary to check
4447 # orientation of edges and create list of reversed edges if it is
4448 # needed) and sets numbers of segments between given points (default
4449 # values are equals 1
4450 # @param points defines the list of parameters on curve
4451 # @param nbSegs defines the list of numbers of segments
4452 # @param reversedEdges is a list of edges to mesh using reversed orientation
4453 # @param UseExisting if ==true - searches for an existing hypothesis created with
4454 # the same parameters, else (default) - creates a new one
4455 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4456 # @ingroup l3_hypos_1dhyps
4457 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4458 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4459 reversedEdges, UseExisting = [], reversedEdges
4460 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4461 for i in range( len( reversedEdges )):
4462 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4463 entry = self.MainShapeEntry()
4464 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4465 UseExisting=UseExisting,
4466 CompareMethod=self.CompareFixedPoints1D)
4467 hyp.SetPoints(points)
4468 hyp.SetNbSegments(nbSegs)
4469 hyp.SetReversedEdges(reversedEdges)
4470 hyp.SetObjectEntry(entry)
4474 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4475 ## as the given arguments
4476 def CompareFixedPoints1D(self, hyp, args):
4477 if hyp.GetPoints() == args[0]:
4478 if hyp.GetNbSegments() == args[1]:
4479 if hyp.GetReversedEdges() == args[2]:
4480 if not args[2] or hyp.GetObjectEntry() == args[3]:
4486 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4487 # @param start defines the length of the first segment
4488 # @param end defines the length of the last segment
4489 # @param reversedEdges is a list of edges to mesh using reversed orientation
4490 # @param UseExisting if ==true - searches for an existing hypothesis created with
4491 # the same parameters, else (default) - creates a new one
4492 # @return an instance of StdMeshers_StartEndLength hypothesis
4493 # @ingroup l3_hypos_1dhyps
4494 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4495 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4496 reversedEdges, UseExisting = [], reversedEdges
4497 entry = self.MainShapeEntry()
4498 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4499 UseExisting=UseExisting,
4500 CompareMethod=self.CompareStartEndLength)
4501 hyp.SetStartLength(start)
4502 hyp.SetEndLength(end)
4503 hyp.SetReversedEdges( reversedEdges )
4504 hyp.SetObjectEntry( entry )
4507 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4508 def CompareStartEndLength(self, hyp, args):
4509 if IsEqual(hyp.GetLength(1), args[0]):
4510 if IsEqual(hyp.GetLength(0), args[1]):
4511 if hyp.GetReversedEdges() == args[2]:
4512 if not args[2] or hyp.GetObjectEntry() == args[3]:
4516 ## Defines "Deflection1D" hypothesis
4517 # @param d for the deflection
4518 # @param UseExisting if ==true - searches for an existing hypothesis created with
4519 # the same parameters, else (default) - create a new one
4520 # @ingroup l3_hypos_1dhyps
4521 def Deflection1D(self, d, UseExisting=0):
4522 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4523 CompareMethod=self.CompareDeflection1D)
4524 hyp.SetDeflection(d)
4527 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4528 def CompareDeflection1D(self, hyp, args):
4529 return IsEqual(hyp.GetDeflection(), args[0])
4531 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4532 # the opposite side in case of quadrangular faces
4533 # @ingroup l3_hypos_additi
4534 def Propagation(self):
4535 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4537 ## Defines "AutomaticLength" hypothesis
4538 # @param fineness for the fineness [0-1]
4539 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4540 # same parameters, else (default) - create a new one
4541 # @ingroup l3_hypos_1dhyps
4542 def AutomaticLength(self, fineness=0, UseExisting=0):
4543 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4544 CompareMethod=self.CompareAutomaticLength)
4545 hyp.SetFineness( fineness )
4548 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4549 def CompareAutomaticLength(self, hyp, args):
4550 return IsEqual(hyp.GetFineness(), args[0])
4552 ## Defines "SegmentLengthAroundVertex" hypothesis
4553 # @param length for the segment length
4554 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4555 # Any other integer value means that the hypothesis will be set on the
4556 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4557 # @param UseExisting if ==true - searches for an existing hypothesis created with
4558 # the same parameters, else (default) - creates a new one
4559 # @ingroup l3_algos_segmarv
4560 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4562 store_geom = self.geom
4563 if type(vertex) is types.IntType:
4564 if vertex == 0 or vertex == 1:
4565 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4573 if self.geom is None:
4574 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4576 name = GetName(self.geom)
4579 piece = self.mesh.geom
4580 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4581 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4583 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4585 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4587 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4588 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4590 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4591 CompareMethod=self.CompareLengthNearVertex)
4592 self.geom = store_geom
4593 hyp.SetLength( length )
4596 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4597 # @ingroup l3_algos_segmarv
4598 def CompareLengthNearVertex(self, hyp, args):
4599 return IsEqual(hyp.GetLength(), args[0])
4601 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4602 # If the 2D mesher sees that all boundary edges are quadratic,
4603 # it generates quadratic faces, else it generates linear faces using
4604 # medium nodes as if they are vertices.
4605 # The 3D mesher generates quadratic volumes only if all boundary faces
4606 # are quadratic, else it fails.
4608 # @ingroup l3_hypos_additi
4609 def QuadraticMesh(self):
4610 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4613 # Public class: Mesh_CompositeSegment
4614 # --------------------------
4616 ## Defines a segment 1D algorithm for discretization
4618 # @ingroup l3_algos_basic
4619 class Mesh_CompositeSegment(Mesh_Segment):
4621 ## Private constructor.
4622 def __init__(self, mesh, geom=0):
4623 self.Create(mesh, geom, "CompositeSegment_1D")
4626 # Public class: Mesh_Segment_Python
4627 # ---------------------------------
4629 ## Defines a segment 1D algorithm for discretization with python function
4631 # @ingroup l3_algos_basic
4632 class Mesh_Segment_Python(Mesh_Segment):
4634 ## Private constructor.
4635 def __init__(self, mesh, geom=0):
4636 import Python1dPlugin
4637 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4639 ## Defines "PythonSplit1D" hypothesis
4640 # @param n for the number of segments that cut an edge
4641 # @param func for the python function that calculates the length of all segments
4642 # @param UseExisting if ==true - searches for the existing hypothesis created with
4643 # the same parameters, else (default) - creates a new one
4644 # @ingroup l3_hypos_1dhyps
4645 def PythonSplit1D(self, n, func, UseExisting=0):
4646 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4647 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4648 hyp.SetNumberOfSegments(n)
4649 hyp.SetPythonLog10RatioFunction(func)
4652 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4653 def ComparePythonSplit1D(self, hyp, args):
4654 #if hyp.GetNumberOfSegments() == args[0]:
4655 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4659 # Public class: Mesh_Triangle
4660 # ---------------------------
4662 ## Defines a triangle 2D algorithm
4664 # @ingroup l3_algos_basic
4665 class Mesh_Triangle(Mesh_Algorithm):
4674 ## Private constructor.
4675 def __init__(self, mesh, algoType, geom=0):
4676 Mesh_Algorithm.__init__(self)
4678 self.algoType = algoType
4679 if algoType == MEFISTO:
4680 self.Create(mesh, geom, "MEFISTO_2D")
4682 elif algoType == BLSURF:
4684 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4685 #self.SetPhysicalMesh() - PAL19680
4686 elif algoType == NETGEN:
4688 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4690 elif algoType == NETGEN_2D:
4692 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4695 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4696 # @param area for the maximum area of each triangle
4697 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4698 # same parameters, else (default) - creates a new one
4700 # Only for algoType == MEFISTO || NETGEN_2D
4701 # @ingroup l3_hypos_2dhyps
4702 def MaxElementArea(self, area, UseExisting=0):
4703 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4704 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4705 CompareMethod=self.CompareMaxElementArea)
4706 elif self.algoType == NETGEN:
4707 hyp = self.Parameters(SIMPLE)
4708 hyp.SetMaxElementArea(area)
4711 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4712 def CompareMaxElementArea(self, hyp, args):
4713 return IsEqual(hyp.GetMaxElementArea(), args[0])
4715 ## Defines "LengthFromEdges" hypothesis to build triangles
4716 # based on the length of the edges taken from the wire
4718 # Only for algoType == MEFISTO || NETGEN_2D
4719 # @ingroup l3_hypos_2dhyps
4720 def LengthFromEdges(self):
4721 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4722 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4724 elif self.algoType == NETGEN:
4725 hyp = self.Parameters(SIMPLE)
4726 hyp.LengthFromEdges()
4729 ## Sets a way to define size of mesh elements to generate.
4730 # @param thePhysicalMesh is: DefaultSize or Custom.
4731 # @ingroup l3_hypos_blsurf
4732 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4733 # Parameter of BLSURF algo
4734 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4736 ## Sets size of mesh elements to generate.
4737 # @ingroup l3_hypos_blsurf
4738 def SetPhySize(self, theVal):
4739 # Parameter of BLSURF algo
4740 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4741 self.Parameters().SetPhySize(theVal)
4743 ## Sets lower boundary of mesh element size (PhySize).
4744 # @ingroup l3_hypos_blsurf
4745 def SetPhyMin(self, theVal=-1):
4746 # Parameter of BLSURF algo
4747 self.Parameters().SetPhyMin(theVal)
4749 ## Sets upper boundary of mesh element size (PhySize).
4750 # @ingroup l3_hypos_blsurf
4751 def SetPhyMax(self, theVal=-1):
4752 # Parameter of BLSURF algo
4753 self.Parameters().SetPhyMax(theVal)
4755 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4756 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4757 # @ingroup l3_hypos_blsurf
4758 def SetGeometricMesh(self, theGeometricMesh=0):
4759 # Parameter of BLSURF algo
4760 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4761 self.params.SetGeometricMesh(theGeometricMesh)
4763 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4764 # @ingroup l3_hypos_blsurf
4765 def SetAngleMeshS(self, theVal=_angleMeshS):
4766 # Parameter of BLSURF algo
4767 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4768 self.params.SetAngleMeshS(theVal)
4770 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4771 # @ingroup l3_hypos_blsurf
4772 def SetAngleMeshC(self, theVal=_angleMeshS):
4773 # Parameter of BLSURF algo
4774 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4775 self.params.SetAngleMeshC(theVal)
4777 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4778 # @ingroup l3_hypos_blsurf
4779 def SetGeoMin(self, theVal=-1):
4780 # Parameter of BLSURF algo
4781 self.Parameters().SetGeoMin(theVal)
4783 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4784 # @ingroup l3_hypos_blsurf
4785 def SetGeoMax(self, theVal=-1):
4786 # Parameter of BLSURF algo
4787 self.Parameters().SetGeoMax(theVal)
4789 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4790 # @ingroup l3_hypos_blsurf
4791 def SetGradation(self, theVal=_gradation):
4792 # Parameter of BLSURF algo
4793 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4794 self.params.SetGradation(theVal)
4796 ## Sets topology usage way.
4797 # @param way defines how mesh conformity is assured <ul>
4798 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4799 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4800 # @ingroup l3_hypos_blsurf
4801 def SetTopology(self, way):
4802 # Parameter of BLSURF algo
4803 self.Parameters().SetTopology(way)
4805 ## To respect geometrical edges or not.
4806 # @ingroup l3_hypos_blsurf
4807 def SetDecimesh(self, toIgnoreEdges=False):
4808 # Parameter of BLSURF algo
4809 self.Parameters().SetDecimesh(toIgnoreEdges)
4811 ## Sets verbosity level in the range 0 to 100.
4812 # @ingroup l3_hypos_blsurf
4813 def SetVerbosity(self, level):
4814 # Parameter of BLSURF algo
4815 self.Parameters().SetVerbosity(level)
4817 ## Sets advanced option value.
4818 # @ingroup l3_hypos_blsurf
4819 def SetOptionValue(self, optionName, level):
4820 # Parameter of BLSURF algo
4821 self.Parameters().SetOptionValue(optionName,level)
4823 ## Sets QuadAllowed flag.
4824 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4825 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4826 def SetQuadAllowed(self, toAllow=True):
4827 if self.algoType == NETGEN_2D:
4828 if toAllow: # add QuadranglePreference
4829 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4830 else: # remove QuadranglePreference
4831 for hyp in self.mesh.GetHypothesisList( self.geom ):
4832 if hyp.GetName() == "QuadranglePreference":
4833 self.mesh.RemoveHypothesis( self.geom, hyp )
4838 if self.Parameters():
4839 self.params.SetQuadAllowed(toAllow)
4842 ## Defines hypothesis having several parameters
4844 # @ingroup l3_hypos_netgen
4845 def Parameters(self, which=SOLE):
4848 if self.algoType == NETGEN:
4850 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4851 "libNETGENEngine.so", UseExisting=0)
4853 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4854 "libNETGENEngine.so", UseExisting=0)
4856 elif self.algoType == MEFISTO:
4857 print "Mefisto algo support no multi-parameter hypothesis"
4859 elif self.algoType == NETGEN_2D:
4860 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4861 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4863 elif self.algoType == BLSURF:
4864 self.params = self.Hypothesis("BLSURF_Parameters", [],
4865 "libBLSURFEngine.so", UseExisting=0)
4868 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4873 # Only for algoType == NETGEN
4874 # @ingroup l3_hypos_netgen
4875 def SetMaxSize(self, theSize):
4876 if self.Parameters():
4877 self.params.SetMaxSize(theSize)
4879 ## Sets SecondOrder flag
4881 # Only for algoType == NETGEN
4882 # @ingroup l3_hypos_netgen
4883 def SetSecondOrder(self, theVal):
4884 if self.Parameters():
4885 self.params.SetSecondOrder(theVal)
4887 ## Sets Optimize flag
4889 # Only for algoType == NETGEN
4890 # @ingroup l3_hypos_netgen
4891 def SetOptimize(self, theVal):
4892 if self.Parameters():
4893 self.params.SetOptimize(theVal)
4896 # @param theFineness is:
4897 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4899 # Only for algoType == NETGEN
4900 # @ingroup l3_hypos_netgen
4901 def SetFineness(self, theFineness):
4902 if self.Parameters():
4903 self.params.SetFineness(theFineness)
4907 # Only for algoType == NETGEN
4908 # @ingroup l3_hypos_netgen
4909 def SetGrowthRate(self, theRate):
4910 if self.Parameters():
4911 self.params.SetGrowthRate(theRate)
4913 ## Sets NbSegPerEdge
4915 # Only for algoType == NETGEN
4916 # @ingroup l3_hypos_netgen
4917 def SetNbSegPerEdge(self, theVal):
4918 if self.Parameters():
4919 self.params.SetNbSegPerEdge(theVal)
4921 ## Sets NbSegPerRadius
4923 # Only for algoType == NETGEN
4924 # @ingroup l3_hypos_netgen
4925 def SetNbSegPerRadius(self, theVal):
4926 if self.Parameters():
4927 self.params.SetNbSegPerRadius(theVal)
4929 ## Sets number of segments overriding value set by SetLocalLength()
4931 # Only for algoType == NETGEN
4932 # @ingroup l3_hypos_netgen
4933 def SetNumberOfSegments(self, theVal):
4934 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4936 ## Sets number of segments overriding value set by SetNumberOfSegments()
4938 # Only for algoType == NETGEN
4939 # @ingroup l3_hypos_netgen
4940 def SetLocalLength(self, theVal):
4941 self.Parameters(SIMPLE).SetLocalLength(theVal)
4946 # Public class: Mesh_Quadrangle
4947 # -----------------------------
4949 ## Defines a quadrangle 2D algorithm
4951 # @ingroup l3_algos_basic
4952 class Mesh_Quadrangle(Mesh_Algorithm):
4954 ## Private constructor.
4955 def __init__(self, mesh, geom=0):
4956 Mesh_Algorithm.__init__(self)
4957 self.Create(mesh, geom, "Quadrangle_2D")
4959 ## Defines "QuadranglePreference" hypothesis, forcing construction
4960 # of quadrangles if the number of nodes on the opposite edges is not the same
4961 # while the total number of nodes on edges is even
4963 # @ingroup l3_hypos_additi
4964 def QuadranglePreference(self):
4965 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4966 CompareMethod=self.CompareEqualHyp)
4969 ## Defines "TrianglePreference" hypothesis, forcing construction
4970 # of triangles in the refinement area if the number of nodes
4971 # on the opposite edges is not the same
4973 # @ingroup l3_hypos_additi
4974 def TrianglePreference(self):
4975 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4976 CompareMethod=self.CompareEqualHyp)
4979 ## Defines "QuadrangleParams" hypothesis
4980 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4981 # will be created while other elements will be quadrangles.
4982 # Vertex can be either a GEOM_Object or a vertex ID within the
4984 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4985 # the same parameters, else (default) - creates a new one
4987 # @ingroup l3_hypos_additi
4988 def TriangleVertex(self, vertex, UseExisting=0):
4990 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4991 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4992 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4993 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4994 hyp.SetTriaVertex( vertexID )
4998 # Public class: Mesh_Tetrahedron
4999 # ------------------------------
5001 ## Defines a tetrahedron 3D algorithm
5003 # @ingroup l3_algos_basic
5004 class Mesh_Tetrahedron(Mesh_Algorithm):
5009 ## Private constructor.
5010 def __init__(self, mesh, algoType, geom=0):
5011 Mesh_Algorithm.__init__(self)
5013 if algoType == NETGEN:
5015 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5018 elif algoType == FULL_NETGEN:
5020 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5023 elif algoType == GHS3D:
5025 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5028 elif algoType == GHS3DPRL:
5029 CheckPlugin(GHS3DPRL)
5030 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5033 self.algoType = algoType
5035 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5036 # @param vol for the maximum volume of each tetrahedron
5037 # @param UseExisting if ==true - searches for the existing hypothesis created with
5038 # the same parameters, else (default) - creates a new one
5039 # @ingroup l3_hypos_maxvol
5040 def MaxElementVolume(self, vol, UseExisting=0):
5041 if self.algoType == NETGEN:
5042 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5043 CompareMethod=self.CompareMaxElementVolume)
5044 hyp.SetMaxElementVolume(vol)
5046 elif self.algoType == FULL_NETGEN:
5047 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5050 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5051 def CompareMaxElementVolume(self, hyp, args):
5052 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5054 ## Defines hypothesis having several parameters
5056 # @ingroup l3_hypos_netgen
5057 def Parameters(self, which=SOLE):
5061 if self.algoType == FULL_NETGEN:
5063 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5064 "libNETGENEngine.so", UseExisting=0)
5066 self.params = self.Hypothesis("NETGEN_Parameters", [],
5067 "libNETGENEngine.so", UseExisting=0)
5070 if self.algoType == GHS3D:
5071 self.params = self.Hypothesis("GHS3D_Parameters", [],
5072 "libGHS3DEngine.so", UseExisting=0)
5075 if self.algoType == GHS3DPRL:
5076 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5077 "libGHS3DPRLEngine.so", UseExisting=0)
5080 print "Algo supports no multi-parameter hypothesis"
5084 # Parameter of FULL_NETGEN
5085 # @ingroup l3_hypos_netgen
5086 def SetMaxSize(self, theSize):
5087 self.Parameters().SetMaxSize(theSize)
5089 ## Sets SecondOrder flag
5090 # Parameter of FULL_NETGEN
5091 # @ingroup l3_hypos_netgen
5092 def SetSecondOrder(self, theVal):
5093 self.Parameters().SetSecondOrder(theVal)
5095 ## Sets Optimize flag
5096 # Parameter of FULL_NETGEN
5097 # @ingroup l3_hypos_netgen
5098 def SetOptimize(self, theVal):
5099 self.Parameters().SetOptimize(theVal)
5102 # @param theFineness is:
5103 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5104 # Parameter of FULL_NETGEN
5105 # @ingroup l3_hypos_netgen
5106 def SetFineness(self, theFineness):
5107 self.Parameters().SetFineness(theFineness)
5110 # Parameter of FULL_NETGEN
5111 # @ingroup l3_hypos_netgen
5112 def SetGrowthRate(self, theRate):
5113 self.Parameters().SetGrowthRate(theRate)
5115 ## Sets NbSegPerEdge
5116 # Parameter of FULL_NETGEN
5117 # @ingroup l3_hypos_netgen
5118 def SetNbSegPerEdge(self, theVal):
5119 self.Parameters().SetNbSegPerEdge(theVal)
5121 ## Sets NbSegPerRadius
5122 # Parameter of FULL_NETGEN
5123 # @ingroup l3_hypos_netgen
5124 def SetNbSegPerRadius(self, theVal):
5125 self.Parameters().SetNbSegPerRadius(theVal)
5127 ## Sets number of segments overriding value set by SetLocalLength()
5128 # Only for algoType == NETGEN_FULL
5129 # @ingroup l3_hypos_netgen
5130 def SetNumberOfSegments(self, theVal):
5131 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5133 ## Sets number of segments overriding value set by SetNumberOfSegments()
5134 # Only for algoType == NETGEN_FULL
5135 # @ingroup l3_hypos_netgen
5136 def SetLocalLength(self, theVal):
5137 self.Parameters(SIMPLE).SetLocalLength(theVal)
5139 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5140 # Overrides value set by LengthFromEdges()
5141 # Only for algoType == NETGEN_FULL
5142 # @ingroup l3_hypos_netgen
5143 def MaxElementArea(self, area):
5144 self.Parameters(SIMPLE).SetMaxElementArea(area)
5146 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5147 # Overrides value set by MaxElementArea()
5148 # Only for algoType == NETGEN_FULL
5149 # @ingroup l3_hypos_netgen
5150 def LengthFromEdges(self):
5151 self.Parameters(SIMPLE).LengthFromEdges()
5153 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5154 # Overrides value set by MaxElementVolume()
5155 # Only for algoType == NETGEN_FULL
5156 # @ingroup l3_hypos_netgen
5157 def LengthFromFaces(self):
5158 self.Parameters(SIMPLE).LengthFromFaces()
5160 ## To mesh "holes" in a solid or not. Default is to mesh.
5161 # @ingroup l3_hypos_ghs3dh
5162 def SetToMeshHoles(self, toMesh):
5163 # Parameter of GHS3D
5164 self.Parameters().SetToMeshHoles(toMesh)
5166 ## Set Optimization level:
5167 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5168 # Strong_Optimization.
5169 # Default is Standard_Optimization
5170 # @ingroup l3_hypos_ghs3dh
5171 def SetOptimizationLevel(self, level):
5172 # Parameter of GHS3D
5173 self.Parameters().SetOptimizationLevel(level)
5175 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5176 # @ingroup l3_hypos_ghs3dh
5177 def SetMaximumMemory(self, MB):
5178 # Advanced parameter of GHS3D
5179 self.Parameters().SetMaximumMemory(MB)
5181 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5182 # automatic memory adjustment mode.
5183 # @ingroup l3_hypos_ghs3dh
5184 def SetInitialMemory(self, MB):
5185 # Advanced parameter of GHS3D
5186 self.Parameters().SetInitialMemory(MB)
5188 ## Path to working directory.
5189 # @ingroup l3_hypos_ghs3dh
5190 def SetWorkingDirectory(self, path):
5191 # Advanced parameter of GHS3D
5192 self.Parameters().SetWorkingDirectory(path)
5194 ## To keep working files or remove them. Log file remains in case of errors anyway.
5195 # @ingroup l3_hypos_ghs3dh
5196 def SetKeepFiles(self, toKeep):
5197 # Advanced parameter of GHS3D and GHS3DPRL
5198 self.Parameters().SetKeepFiles(toKeep)
5200 ## To set verbose level [0-10]. <ul>
5201 #<li> 0 - no standard output,
5202 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5203 # indicates when the final mesh is being saved. In addition the software
5204 # gives indication regarding the CPU time.
5205 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5206 # histogram of the skin mesh, quality statistics histogram together with
5207 # the characteristics of the final mesh.</ul>
5208 # @ingroup l3_hypos_ghs3dh
5209 def SetVerboseLevel(self, level):
5210 # Advanced parameter of GHS3D
5211 self.Parameters().SetVerboseLevel(level)
5213 ## To create new nodes.
5214 # @ingroup l3_hypos_ghs3dh
5215 def SetToCreateNewNodes(self, toCreate):
5216 # Advanced parameter of GHS3D
5217 self.Parameters().SetToCreateNewNodes(toCreate)
5219 ## To use boundary recovery version which tries to create mesh on a very poor
5220 # quality surface mesh.
5221 # @ingroup l3_hypos_ghs3dh
5222 def SetToUseBoundaryRecoveryVersion(self, toUse):
5223 # Advanced parameter of GHS3D
5224 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5226 ## Sets command line option as text.
5227 # @ingroup l3_hypos_ghs3dh
5228 def SetTextOption(self, option):
5229 # Advanced parameter of GHS3D
5230 self.Parameters().SetTextOption(option)
5232 ## Sets MED files name and path.
5233 def SetMEDName(self, value):
5234 self.Parameters().SetMEDName(value)
5236 ## Sets the number of partition of the initial mesh
5237 def SetNbPart(self, value):
5238 self.Parameters().SetNbPart(value)
5240 ## When big mesh, start tepal in background
5241 def SetBackground(self, value):
5242 self.Parameters().SetBackground(value)
5244 # Public class: Mesh_Hexahedron
5245 # ------------------------------
5247 ## Defines a hexahedron 3D algorithm
5249 # @ingroup l3_algos_basic
5250 class Mesh_Hexahedron(Mesh_Algorithm):
5255 ## Private constructor.
5256 def __init__(self, mesh, algoType=Hexa, geom=0):
5257 Mesh_Algorithm.__init__(self)
5259 self.algoType = algoType
5261 if algoType == Hexa:
5262 self.Create(mesh, geom, "Hexa_3D")
5265 elif algoType == Hexotic:
5266 CheckPlugin(Hexotic)
5267 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5270 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5271 # @ingroup l3_hypos_hexotic
5272 def MinMaxQuad(self, min=3, max=8, quad=True):
5273 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5275 self.params.SetHexesMinLevel(min)
5276 self.params.SetHexesMaxLevel(max)
5277 self.params.SetHexoticQuadrangles(quad)
5280 # Deprecated, only for compatibility!
5281 # Public class: Mesh_Netgen
5282 # ------------------------------
5284 ## Defines a NETGEN-based 2D or 3D algorithm
5285 # that needs no discrete boundary (i.e. independent)
5287 # This class is deprecated, only for compatibility!
5290 # @ingroup l3_algos_basic
5291 class Mesh_Netgen(Mesh_Algorithm):
5295 ## Private constructor.
5296 def __init__(self, mesh, is3D, geom=0):
5297 Mesh_Algorithm.__init__(self)
5303 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5307 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5310 ## Defines the hypothesis containing parameters of the algorithm
5311 def Parameters(self):
5313 hyp = self.Hypothesis("NETGEN_Parameters", [],
5314 "libNETGENEngine.so", UseExisting=0)
5316 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5317 "libNETGENEngine.so", UseExisting=0)
5320 # Public class: Mesh_Projection1D
5321 # ------------------------------
5323 ## Defines a projection 1D algorithm
5324 # @ingroup l3_algos_proj
5326 class Mesh_Projection1D(Mesh_Algorithm):
5328 ## Private constructor.
5329 def __init__(self, mesh, geom=0):
5330 Mesh_Algorithm.__init__(self)
5331 self.Create(mesh, geom, "Projection_1D")
5333 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5334 # a mesh pattern is taken, and, optionally, the association of vertices
5335 # between the source edge and a target edge (to which a hypothesis is assigned)
5336 # @param edge from which nodes distribution is taken
5337 # @param mesh from which nodes distribution is taken (optional)
5338 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5339 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5340 # to associate with \a srcV (optional)
5341 # @param UseExisting if ==true - searches for the existing hypothesis created with
5342 # the same parameters, else (default) - creates a new one
5343 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5344 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5346 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5347 hyp.SetSourceEdge( edge )
5348 if not mesh is None and isinstance(mesh, Mesh):
5349 mesh = mesh.GetMesh()
5350 hyp.SetSourceMesh( mesh )
5351 hyp.SetVertexAssociation( srcV, tgtV )
5354 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5355 #def CompareSourceEdge(self, hyp, args):
5356 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5360 # Public class: Mesh_Projection2D
5361 # ------------------------------
5363 ## Defines a projection 2D algorithm
5364 # @ingroup l3_algos_proj
5366 class Mesh_Projection2D(Mesh_Algorithm):
5368 ## Private constructor.
5369 def __init__(self, mesh, geom=0):
5370 Mesh_Algorithm.__init__(self)
5371 self.Create(mesh, geom, "Projection_2D")
5373 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5374 # a mesh pattern is taken, and, optionally, the association of vertices
5375 # between the source face and the target face (to which a hypothesis is assigned)
5376 # @param face from which the mesh pattern is taken
5377 # @param mesh from which the mesh pattern is taken (optional)
5378 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5379 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5380 # to associate with \a srcV1 (optional)
5381 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5382 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5383 # to associate with \a srcV2 (optional)
5384 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5385 # the same parameters, else (default) - forces the creation a new one
5387 # Note: all association vertices must belong to one edge of a face
5388 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5389 srcV2=None, tgtV2=None, UseExisting=0):
5390 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5392 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5393 hyp.SetSourceFace( face )
5394 if not mesh is None and isinstance(mesh, Mesh):
5395 mesh = mesh.GetMesh()
5396 hyp.SetSourceMesh( mesh )
5397 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5400 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5401 #def CompareSourceFace(self, hyp, args):
5402 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5405 # Public class: Mesh_Projection3D
5406 # ------------------------------
5408 ## Defines a projection 3D algorithm
5409 # @ingroup l3_algos_proj
5411 class Mesh_Projection3D(Mesh_Algorithm):
5413 ## Private constructor.
5414 def __init__(self, mesh, geom=0):
5415 Mesh_Algorithm.__init__(self)
5416 self.Create(mesh, geom, "Projection_3D")
5418 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5419 # the mesh pattern is taken, and, optionally, the association of vertices
5420 # between the source and the target solid (to which a hipothesis is assigned)
5421 # @param solid from where the mesh pattern is taken
5422 # @param mesh from where the mesh pattern is taken (optional)
5423 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5424 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5425 # to associate with \a srcV1 (optional)
5426 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5427 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5428 # to associate with \a srcV2 (optional)
5429 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5430 # the same parameters, else (default) - creates a new one
5432 # Note: association vertices must belong to one edge of a solid
5433 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5434 srcV2=0, tgtV2=0, UseExisting=0):
5435 hyp = self.Hypothesis("ProjectionSource3D",
5436 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5438 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5439 hyp.SetSource3DShape( solid )
5440 if not mesh is None and isinstance(mesh, Mesh):
5441 mesh = mesh.GetMesh()
5442 hyp.SetSourceMesh( mesh )
5443 if srcV1 and srcV2 and tgtV1 and tgtV2:
5444 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5445 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5448 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5449 #def CompareSourceShape3D(self, hyp, args):
5450 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5454 # Public class: Mesh_Prism
5455 # ------------------------
5457 ## Defines a 3D extrusion algorithm
5458 # @ingroup l3_algos_3dextr
5460 class Mesh_Prism3D(Mesh_Algorithm):
5462 ## Private constructor.
5463 def __init__(self, mesh, geom=0):
5464 Mesh_Algorithm.__init__(self)
5465 self.Create(mesh, geom, "Prism_3D")
5467 # Public class: Mesh_RadialPrism
5468 # -------------------------------
5470 ## Defines a Radial Prism 3D algorithm
5471 # @ingroup l3_algos_radialp
5473 class Mesh_RadialPrism3D(Mesh_Algorithm):
5475 ## Private constructor.
5476 def __init__(self, mesh, geom=0):
5477 Mesh_Algorithm.__init__(self)
5478 self.Create(mesh, geom, "RadialPrism_3D")
5480 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5481 self.nbLayers = None
5483 ## Return 3D hypothesis holding the 1D one
5484 def Get3DHypothesis(self):
5485 return self.distribHyp
5487 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5488 # hypothesis. Returns the created hypothesis
5489 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5490 #print "OwnHypothesis",hypType
5491 if not self.nbLayers is None:
5492 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5493 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5494 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5495 self.mesh.smeshpyD.SetCurrentStudy( None )
5496 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5497 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5498 self.distribHyp.SetLayerDistribution( hyp )
5501 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5502 # prisms to build between the inner and outer shells
5503 # @param n number of layers
5504 # @param UseExisting if ==true - searches for the existing hypothesis created with
5505 # the same parameters, else (default) - creates a new one
5506 def NumberOfLayers(self, n, UseExisting=0):
5507 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5508 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5509 CompareMethod=self.CompareNumberOfLayers)
5510 self.nbLayers.SetNumberOfLayers( n )
5511 return self.nbLayers
5513 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5514 def CompareNumberOfLayers(self, hyp, args):
5515 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5517 ## Defines "LocalLength" hypothesis, specifying the segment length
5518 # to build between the inner and the outer shells
5519 # @param l the length of segments
5520 # @param p the precision of rounding
5521 def LocalLength(self, l, p=1e-07):
5522 hyp = self.OwnHypothesis("LocalLength", [l,p])
5527 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5528 # prisms to build between the inner and the outer shells.
5529 # @param n the number of layers
5530 # @param s the scale factor (optional)
5531 def NumberOfSegments(self, n, s=[]):
5533 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5535 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5536 hyp.SetDistrType( 1 )
5537 hyp.SetScaleFactor(s)
5538 hyp.SetNumberOfSegments(n)
5541 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5542 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5543 # @param start the length of the first segment
5544 # @param end the length of the last segment
5545 def Arithmetic1D(self, start, end ):
5546 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5547 hyp.SetLength(start, 1)
5548 hyp.SetLength(end , 0)
5551 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5552 # to build between the inner and the outer shells as geometric length increasing
5553 # @param start for the length of the first segment
5554 # @param end for the length of the last segment
5555 def StartEndLength(self, start, end):
5556 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5557 hyp.SetLength(start, 1)
5558 hyp.SetLength(end , 0)
5561 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5562 # to build between the inner and outer shells
5563 # @param fineness defines the quality of the mesh within the range [0-1]
5564 def AutomaticLength(self, fineness=0):
5565 hyp = self.OwnHypothesis("AutomaticLength")
5566 hyp.SetFineness( fineness )
5569 # Public class: Mesh_RadialQuadrangle1D2D
5570 # -------------------------------
5572 ## Defines a Radial Quadrangle 1D2D algorithm
5573 # @ingroup l2_algos_radialq
5575 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5577 ## Private constructor.
5578 def __init__(self, mesh, geom=0):
5579 Mesh_Algorithm.__init__(self)
5580 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5582 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5583 self.nbLayers = None
5585 ## Return 2D hypothesis holding the 1D one
5586 def Get2DHypothesis(self):
5587 return self.distribHyp
5589 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5590 # hypothesis. Returns the created hypothesis
5591 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5592 #print "OwnHypothesis",hypType
5594 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5595 if self.distribHyp is None:
5596 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5598 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5599 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5600 self.mesh.smeshpyD.SetCurrentStudy( None )
5601 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5602 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5603 self.distribHyp.SetLayerDistribution( hyp )
5606 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5607 # @param n number of layers
5608 # @param UseExisting if ==true - searches for the existing hypothesis created with
5609 # the same parameters, else (default) - creates a new one
5610 def NumberOfLayers(self, n, UseExisting=0):
5612 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5613 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5614 CompareMethod=self.CompareNumberOfLayers)
5615 self.nbLayers.SetNumberOfLayers( n )
5616 return self.nbLayers
5618 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5619 def CompareNumberOfLayers(self, hyp, args):
5620 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5622 ## Defines "LocalLength" hypothesis, specifying the segment length
5623 # @param l the length of segments
5624 # @param p the precision of rounding
5625 def LocalLength(self, l, p=1e-07):
5626 hyp = self.OwnHypothesis("LocalLength", [l,p])
5631 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5632 # @param n the number of layers
5633 # @param s the scale factor (optional)
5634 def NumberOfSegments(self, n, s=[]):
5636 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5638 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5639 hyp.SetDistrType( 1 )
5640 hyp.SetScaleFactor(s)
5641 hyp.SetNumberOfSegments(n)
5644 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5645 # with a length that changes in arithmetic progression
5646 # @param start the length of the first segment
5647 # @param end the length of the last segment
5648 def Arithmetic1D(self, start, end ):
5649 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5650 hyp.SetLength(start, 1)
5651 hyp.SetLength(end , 0)
5654 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5655 # as geometric length increasing
5656 # @param start for the length of the first segment
5657 # @param end for the length of the last segment
5658 def StartEndLength(self, start, end):
5659 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5660 hyp.SetLength(start, 1)
5661 hyp.SetLength(end , 0)
5664 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5665 # @param fineness defines the quality of the mesh within the range [0-1]
5666 def AutomaticLength(self, fineness=0):
5667 hyp = self.OwnHypothesis("AutomaticLength")
5668 hyp.SetFineness( fineness )
5672 # Public class: Mesh_UseExistingElements
5673 # --------------------------------------
5674 ## Defines a Radial Quadrangle 1D2D algorithm
5675 # @ingroup l3_algos_basic
5677 class Mesh_UseExistingElements(Mesh_Algorithm):
5679 def __init__(self, dim, mesh, geom=0):
5681 self.Create(mesh, geom, "Import_1D")
5683 self.Create(mesh, geom, "Import_1D2D")
5686 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5687 # @param groups list of groups of edges
5688 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5689 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5690 # @param UseExisting if ==true - searches for the existing hypothesis created with
5691 # the same parameters, else (default) - creates a new one
5692 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5693 if self.algo.GetName() == "Import_2D":
5694 raise ValueError, "algoritm dimension mismatch"
5695 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5696 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5697 hyp.SetSourceEdges(groups)
5698 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5701 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5702 # @param groups list of groups of faces
5703 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5704 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5705 # @param UseExisting if ==true - searches for the existing hypothesis created with
5706 # the same parameters, else (default) - creates a new one
5707 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5708 if self.algo.GetName() == "Import_1D":
5709 raise ValueError, "algoritm dimension mismatch"
5710 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5711 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5712 hyp.SetSourceFaces(groups)
5713 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5716 def _compareHyp(self,hyp,args):
5717 if hasattr( hyp, "GetSourceEdges"):
5718 entries = hyp.GetSourceEdges()
5720 entries = hyp.GetSourceFaces()
5722 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5723 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5725 study = self.mesh.smeshpyD.GetCurrentStudy()
5728 ior = salome.orb.object_to_string(g)
5729 sobj = study.FindObjectIOR(ior)
5730 if sobj: entries2.append( sobj.GetID() )
5735 return entries == entries2
5739 # Private class: Mesh_UseExisting
5740 # -------------------------------
5741 class Mesh_UseExisting(Mesh_Algorithm):
5743 def __init__(self, dim, mesh, geom=0):
5745 self.Create(mesh, geom, "UseExisting_1D")
5747 self.Create(mesh, geom, "UseExisting_2D")
5750 import salome_notebook
5751 notebook = salome_notebook.notebook
5753 ##Return values of the notebook variables
5754 def ParseParameters(last, nbParams,nbParam, value):
5758 listSize = len(last)
5759 for n in range(0,nbParams):
5761 if counter < listSize:
5762 strResult = strResult + last[counter]
5764 strResult = strResult + ""
5766 if isinstance(value, str):
5767 if notebook.isVariable(value):
5768 result = notebook.get(value)
5769 strResult=strResult+value
5771 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5773 strResult=strResult+str(value)
5775 if nbParams - 1 != counter:
5776 strResult=strResult+var_separator #":"
5778 return result, strResult
5780 #Wrapper class for StdMeshers_LocalLength hypothesis
5781 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5783 ## Set Length parameter value
5784 # @param length numerical value or name of variable from notebook
5785 def SetLength(self, length):
5786 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5787 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5788 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5790 ## Set Precision parameter value
5791 # @param precision numerical value or name of variable from notebook
5792 def SetPrecision(self, precision):
5793 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5794 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5795 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5797 #Registering the new proxy for LocalLength
5798 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5801 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5802 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5804 def SetLayerDistribution(self, hypo):
5805 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5806 hypo.ClearParameters();
5807 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5809 #Registering the new proxy for LayerDistribution
5810 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5812 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5813 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5815 ## Set Length parameter value
5816 # @param length numerical value or name of variable from notebook
5817 def SetLength(self, length):
5818 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5819 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5820 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5822 #Registering the new proxy for SegmentLengthAroundVertex
5823 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5826 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5827 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5829 ## Set Length parameter value
5830 # @param length numerical value or name of variable from notebook
5831 # @param isStart true is length is Start Length, otherwise false
5832 def SetLength(self, length, isStart):
5836 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5837 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5838 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5840 #Registering the new proxy for Arithmetic1D
5841 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5843 #Wrapper class for StdMeshers_Deflection1D hypothesis
5844 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5846 ## Set Deflection parameter value
5847 # @param deflection numerical value or name of variable from notebook
5848 def SetDeflection(self, deflection):
5849 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5850 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5851 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5853 #Registering the new proxy for Deflection1D
5854 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5856 #Wrapper class for StdMeshers_StartEndLength hypothesis
5857 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5859 ## Set Length parameter value
5860 # @param length numerical value or name of variable from notebook
5861 # @param isStart true is length is Start Length, otherwise false
5862 def SetLength(self, length, isStart):
5866 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5867 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5868 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5870 #Registering the new proxy for StartEndLength
5871 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5873 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5874 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5876 ## Set Max Element Area parameter value
5877 # @param area numerical value or name of variable from notebook
5878 def SetMaxElementArea(self, area):
5879 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5880 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5881 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5883 #Registering the new proxy for MaxElementArea
5884 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5887 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5888 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5890 ## Set Max Element Volume parameter value
5891 # @param volume numerical value or name of variable from notebook
5892 def SetMaxElementVolume(self, volume):
5893 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5894 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5895 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5897 #Registering the new proxy for MaxElementVolume
5898 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5901 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5902 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5904 ## Set Number Of Layers parameter value
5905 # @param nbLayers numerical value or name of variable from notebook
5906 def SetNumberOfLayers(self, nbLayers):
5907 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5908 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5909 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5911 #Registering the new proxy for NumberOfLayers
5912 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5914 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5915 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5917 ## Set Number Of Segments parameter value
5918 # @param nbSeg numerical value or name of variable from notebook
5919 def SetNumberOfSegments(self, nbSeg):
5920 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5921 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5922 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5923 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5925 ## Set Scale Factor parameter value
5926 # @param factor numerical value or name of variable from notebook
5927 def SetScaleFactor(self, factor):
5928 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5929 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5930 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5932 #Registering the new proxy for NumberOfSegments
5933 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5935 if not noNETGENPlugin:
5936 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5937 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5939 ## Set Max Size parameter value
5940 # @param maxsize numerical value or name of variable from notebook
5941 def SetMaxSize(self, maxsize):
5942 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5943 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5944 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5945 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5947 ## Set Growth Rate parameter value
5948 # @param value numerical value or name of variable from notebook
5949 def SetGrowthRate(self, value):
5950 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5951 value, parameters = ParseParameters(lastParameters,4,2,value)
5952 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5953 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5955 ## Set Number of Segments per Edge parameter value
5956 # @param value numerical value or name of variable from notebook
5957 def SetNbSegPerEdge(self, value):
5958 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5959 value, parameters = ParseParameters(lastParameters,4,3,value)
5960 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5961 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5963 ## Set Number of Segments per Radius parameter value
5964 # @param value numerical value or name of variable from notebook
5965 def SetNbSegPerRadius(self, value):
5966 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5967 value, parameters = ParseParameters(lastParameters,4,4,value)
5968 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5969 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5971 #Registering the new proxy for NETGENPlugin_Hypothesis
5972 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5975 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5976 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5979 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5980 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5982 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5983 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5985 ## Set Number of Segments parameter value
5986 # @param nbSeg numerical value or name of variable from notebook
5987 def SetNumberOfSegments(self, nbSeg):
5988 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5989 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5990 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5991 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5993 ## Set Local Length parameter value
5994 # @param length numerical value or name of variable from notebook
5995 def SetLocalLength(self, length):
5996 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5997 length, parameters = ParseParameters(lastParameters,2,1,length)
5998 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5999 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6001 ## Set Max Element Area parameter value
6002 # @param area numerical value or name of variable from notebook
6003 def SetMaxElementArea(self, area):
6004 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6005 area, parameters = ParseParameters(lastParameters,2,2,area)
6006 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6007 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6009 def LengthFromEdges(self):
6010 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6012 value, parameters = ParseParameters(lastParameters,2,2,value)
6013 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6014 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6016 #Registering the new proxy for NETGEN_SimpleParameters_2D
6017 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6020 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6021 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6022 ## Set Max Element Volume parameter value
6023 # @param volume numerical value or name of variable from notebook
6024 def SetMaxElementVolume(self, volume):
6025 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6026 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6027 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6028 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6030 def LengthFromFaces(self):
6031 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6033 value, parameters = ParseParameters(lastParameters,3,3,value)
6034 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6035 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6037 #Registering the new proxy for NETGEN_SimpleParameters_3D
6038 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6040 pass # if not noNETGENPlugin:
6042 class Pattern(SMESH._objref_SMESH_Pattern):
6044 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6046 if isinstance(theNodeIndexOnKeyPoint1,str):
6048 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6050 theNodeIndexOnKeyPoint1 -= 1
6051 theMesh.SetParameters(Parameters)
6052 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6054 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6057 if isinstance(theNode000Index,str):
6059 if isinstance(theNode001Index,str):
6061 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6063 theNode000Index -= 1
6065 theNode001Index -= 1
6066 theMesh.SetParameters(Parameters)
6067 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6069 #Registering the new proxy for Pattern
6070 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)