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_quad Quadrangle Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
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 # import items of enum QuadType
206 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
208 ## Converts an angle from degrees to radians
209 def DegreesToRadians(AngleInDegrees):
211 return AngleInDegrees * pi / 180.0
213 # Salome notebook variable separator
216 # Parametrized substitute for PointStruct
217 class PointStructStr:
226 def __init__(self, xStr, yStr, zStr):
230 if isinstance(xStr, str) and notebook.isVariable(xStr):
231 self.x = notebook.get(xStr)
234 if isinstance(yStr, str) and notebook.isVariable(yStr):
235 self.y = notebook.get(yStr)
238 if isinstance(zStr, str) and notebook.isVariable(zStr):
239 self.z = notebook.get(zStr)
243 # Parametrized substitute for PointStruct (with 6 parameters)
244 class PointStructStr6:
259 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
266 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
267 self.x1 = notebook.get(x1Str)
270 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
271 self.x2 = notebook.get(x2Str)
274 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
275 self.y1 = notebook.get(y1Str)
278 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
279 self.y2 = notebook.get(y2Str)
282 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
283 self.z1 = notebook.get(z1Str)
286 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
287 self.z2 = notebook.get(z2Str)
291 # Parametrized substitute for AxisStruct
307 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
314 if isinstance(xStr, str) and notebook.isVariable(xStr):
315 self.x = notebook.get(xStr)
318 if isinstance(yStr, str) and notebook.isVariable(yStr):
319 self.y = notebook.get(yStr)
322 if isinstance(zStr, str) and notebook.isVariable(zStr):
323 self.z = notebook.get(zStr)
326 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
327 self.dx = notebook.get(dxStr)
330 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
331 self.dy = notebook.get(dyStr)
334 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
335 self.dz = notebook.get(dzStr)
339 # Parametrized substitute for DirStruct
342 def __init__(self, pointStruct):
343 self.pointStruct = pointStruct
345 # Returns list of variable values from salome notebook
346 def ParsePointStruct(Point):
347 Parameters = 2*var_separator
348 if isinstance(Point, PointStructStr):
349 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
350 Point = PointStruct(Point.x, Point.y, Point.z)
351 return Point, Parameters
353 # Returns list of variable values from salome notebook
354 def ParseDirStruct(Dir):
355 Parameters = 2*var_separator
356 if isinstance(Dir, DirStructStr):
357 pntStr = Dir.pointStruct
358 if isinstance(pntStr, PointStructStr6):
359 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
360 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
361 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
362 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
364 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
365 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
366 Dir = DirStruct(Point)
367 return Dir, Parameters
369 # Returns list of variable values from salome notebook
370 def ParseAxisStruct(Axis):
371 Parameters = 5*var_separator
372 if isinstance(Axis, AxisStructStr):
373 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
374 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
375 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
376 return Axis, Parameters
378 ## Return list of variable values from salome notebook
379 def ParseAngles(list):
382 for parameter in list:
383 if isinstance(parameter,str) and notebook.isVariable(parameter):
384 Result.append(DegreesToRadians(notebook.get(parameter)))
387 Result.append(parameter)
390 Parameters = Parameters + str(parameter)
391 Parameters = Parameters + var_separator
393 Parameters = Parameters[:len(Parameters)-1]
394 return Result, Parameters
396 def IsEqual(val1, val2, tol=PrecisionConfusion):
397 if abs(val1 - val2) < tol:
407 if isinstance(obj, SALOMEDS._objref_SObject):
410 ior = salome.orb.object_to_string(obj)
413 studies = salome.myStudyManager.GetOpenStudies()
414 for sname in studies:
415 s = salome.myStudyManager.GetStudyByName(sname)
417 sobj = s.FindObjectIOR(ior)
418 if not sobj: continue
419 return sobj.GetName()
420 if hasattr(obj, "GetName"):
421 # unknown CORBA object, having GetName() method
424 # unknown CORBA object, no GetName() method
427 if hasattr(obj, "GetName"):
428 # unknown non-CORBA object, having GetName() method
431 raise RuntimeError, "Null or invalid object"
433 ## Prints error message if a hypothesis was not assigned.
434 def TreatHypoStatus(status, hypName, geomName, isAlgo):
436 hypType = "algorithm"
438 hypType = "hypothesis"
440 if status == HYP_UNKNOWN_FATAL :
441 reason = "for unknown reason"
442 elif status == HYP_INCOMPATIBLE :
443 reason = "this hypothesis mismatches the algorithm"
444 elif status == HYP_NOTCONFORM :
445 reason = "a non-conform mesh would be built"
446 elif status == HYP_ALREADY_EXIST :
447 if isAlgo: return # it does not influence anything
448 reason = hypType + " of the same dimension is already assigned to this shape"
449 elif status == HYP_BAD_DIM :
450 reason = hypType + " mismatches the shape"
451 elif status == HYP_CONCURENT :
452 reason = "there are concurrent hypotheses on sub-shapes"
453 elif status == HYP_BAD_SUBSHAPE :
454 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
455 elif status == HYP_BAD_GEOMETRY:
456 reason = "geometry mismatches the expectation of the algorithm"
457 elif status == HYP_HIDDEN_ALGO:
458 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
459 elif status == HYP_HIDING_ALGO:
460 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
461 elif status == HYP_NEED_SHAPE:
462 reason = "Algorithm can't work without shape"
465 hypName = '"' + hypName + '"'
466 geomName= '"' + geomName+ '"'
467 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
468 print hypName, "was assigned to", geomName,"but", reason
469 elif not geomName == '""':
470 print hypName, "was not assigned to",geomName,":", reason
472 print hypName, "was not assigned:", reason
475 ## Check meshing plugin availability
476 def CheckPlugin(plugin):
477 if plugin == NETGEN and noNETGENPlugin:
478 print "Warning: NETGENPlugin module unavailable"
480 elif plugin == GHS3D and noGHS3DPlugin:
481 print "Warning: GHS3DPlugin module unavailable"
483 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
484 print "Warning: GHS3DPRLPlugin module unavailable"
486 elif plugin == Hexotic and noHexoticPlugin:
487 print "Warning: HexoticPlugin module unavailable"
489 elif plugin == BLSURF and noBLSURFPlugin:
490 print "Warning: BLSURFPlugin module unavailable"
494 # end of l1_auxiliary
497 # All methods of this class are accessible directly from the smesh.py package.
498 class smeshDC(SMESH._objref_SMESH_Gen):
500 ## Sets the current study and Geometry component
501 # @ingroup l1_auxiliary
502 def init_smesh(self,theStudy,geompyD):
503 self.SetCurrentStudy(theStudy,geompyD)
505 ## Creates an empty Mesh. This mesh can have an underlying geometry.
506 # @param obj the Geometrical object on which the mesh is built. If not defined,
507 # the mesh will have no underlying geometry.
508 # @param name the name for the new mesh.
509 # @return an instance of Mesh class.
510 # @ingroup l2_construct
511 def Mesh(self, obj=0, name=0):
512 if isinstance(obj,str):
514 return Mesh(self,self.geompyD,obj,name)
516 ## Returns a long value from enumeration
517 # Should be used for SMESH.FunctorType enumeration
518 # @ingroup l1_controls
519 def EnumToLong(self,theItem):
522 ## Returns a string representation of the color.
523 # To be used with filters.
524 # @param c color value (SALOMEDS.Color)
525 # @ingroup l1_controls
526 def ColorToString(self,c):
528 if isinstance(c, SALOMEDS.Color):
529 val = "%s;%s;%s" % (c.R, c.G, c.B)
530 elif isinstance(c, str):
533 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
536 ## Gets PointStruct from vertex
537 # @param theVertex a GEOM object(vertex)
538 # @return SMESH.PointStruct
539 # @ingroup l1_auxiliary
540 def GetPointStruct(self,theVertex):
541 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
542 return PointStruct(x,y,z)
544 ## Gets DirStruct from vector
545 # @param theVector a GEOM object(vector)
546 # @return SMESH.DirStruct
547 # @ingroup l1_auxiliary
548 def GetDirStruct(self,theVector):
549 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
550 if(len(vertices) != 2):
551 print "Error: vector object is incorrect."
553 p1 = self.geompyD.PointCoordinates(vertices[0])
554 p2 = self.geompyD.PointCoordinates(vertices[1])
555 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
556 dirst = DirStruct(pnt)
559 ## Makes DirStruct from a triplet
560 # @param x,y,z vector components
561 # @return SMESH.DirStruct
562 # @ingroup l1_auxiliary
563 def MakeDirStruct(self,x,y,z):
564 pnt = PointStruct(x,y,z)
565 return DirStruct(pnt)
567 ## Get AxisStruct from object
568 # @param theObj a GEOM object (line or plane)
569 # @return SMESH.AxisStruct
570 # @ingroup l1_auxiliary
571 def GetAxisStruct(self,theObj):
572 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
574 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
575 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
576 vertex1 = self.geompyD.PointCoordinates(vertex1)
577 vertex2 = self.geompyD.PointCoordinates(vertex2)
578 vertex3 = self.geompyD.PointCoordinates(vertex3)
579 vertex4 = self.geompyD.PointCoordinates(vertex4)
580 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
581 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
582 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] ]
583 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
585 elif len(edges) == 1:
586 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
587 p1 = self.geompyD.PointCoordinates( vertex1 )
588 p2 = self.geompyD.PointCoordinates( vertex2 )
589 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
593 # From SMESH_Gen interface:
594 # ------------------------
596 ## Sets the given name to the object
597 # @param obj the object to rename
598 # @param name a new object name
599 # @ingroup l1_auxiliary
600 def SetName(self, obj, name):
601 if isinstance( obj, Mesh ):
603 elif isinstance( obj, Mesh_Algorithm ):
604 obj = obj.GetAlgorithm()
605 ior = salome.orb.object_to_string(obj)
606 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
608 ## Sets the current mode
609 # @ingroup l1_auxiliary
610 def SetEmbeddedMode( self,theMode ):
611 #self.SetEmbeddedMode(theMode)
612 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
614 ## Gets the current mode
615 # @ingroup l1_auxiliary
616 def IsEmbeddedMode(self):
617 #return self.IsEmbeddedMode()
618 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
620 ## Sets the current study
621 # @ingroup l1_auxiliary
622 def SetCurrentStudy( self, theStudy, geompyD = None ):
623 #self.SetCurrentStudy(theStudy)
626 geompyD = geompy.geom
629 self.SetGeomEngine(geompyD)
630 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
632 ## Gets the current study
633 # @ingroup l1_auxiliary
634 def GetCurrentStudy(self):
635 #return self.GetCurrentStudy()
636 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
638 ## Creates a Mesh object importing data from the given UNV file
639 # @return an instance of Mesh class
641 def CreateMeshesFromUNV( self,theFileName ):
642 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
643 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
646 ## Creates a Mesh object(s) importing data from the given MED file
647 # @return a list of Mesh class instances
649 def CreateMeshesFromMED( self,theFileName ):
650 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
652 for iMesh in range(len(aSmeshMeshes)) :
653 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
654 aMeshes.append(aMesh)
655 return aMeshes, aStatus
657 ## Creates a Mesh object importing data from the given STL file
658 # @return an instance of Mesh class
660 def CreateMeshesFromSTL( self, theFileName ):
661 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
662 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
665 ## From SMESH_Gen interface
666 # @return the list of integer values
667 # @ingroup l1_auxiliary
668 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
669 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
671 ## From SMESH_Gen interface. Creates a pattern
672 # @return an instance of SMESH_Pattern
674 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
675 # @ingroup l2_modif_patterns
676 def GetPattern(self):
677 return SMESH._objref_SMESH_Gen.GetPattern(self)
679 ## Sets number of segments per diagonal of boundary box of geometry by which
680 # default segment length of appropriate 1D hypotheses is defined.
681 # Default value is 10
682 # @ingroup l1_auxiliary
683 def SetBoundaryBoxSegmentation(self, nbSegments):
684 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
686 ## Concatenate the given meshes into one mesh.
687 # @return an instance of Mesh class
688 # @param meshes the meshes to combine into one mesh
689 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
690 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
691 # @param mergeTolerance tolerance for merging nodes
692 # @param allGroups forces creation of groups of all elements
693 def Concatenate( self, meshes, uniteIdenticalGroups,
694 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
695 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
696 for i,m in enumerate(meshes):
697 if isinstance(m, Mesh):
698 meshes[i] = m.GetMesh()
700 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
701 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
703 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
704 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
705 aSmeshMesh.SetParameters(Parameters)
706 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
709 # Filtering. Auxiliary functions:
710 # ------------------------------
712 ## Creates an empty criterion
713 # @return SMESH.Filter.Criterion
714 # @ingroup l1_controls
715 def GetEmptyCriterion(self):
716 Type = self.EnumToLong(FT_Undefined)
717 Compare = self.EnumToLong(FT_Undefined)
721 UnaryOp = self.EnumToLong(FT_Undefined)
722 BinaryOp = self.EnumToLong(FT_Undefined)
725 Precision = -1 ##@1e-07
726 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
727 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
729 ## Creates a criterion by the given parameters
730 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
731 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
732 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
733 # @param Treshold the threshold value (range of ids as string, shape, numeric)
734 # @param UnaryOp FT_LogicalNOT or FT_Undefined
735 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
736 # FT_Undefined (must be for the last criterion of all criteria)
737 # @return SMESH.Filter.Criterion
738 # @ingroup l1_controls
739 def GetCriterion(self,elementType,
741 Compare = FT_EqualTo,
743 UnaryOp=FT_Undefined,
744 BinaryOp=FT_Undefined):
745 aCriterion = self.GetEmptyCriterion()
746 aCriterion.TypeOfElement = elementType
747 aCriterion.Type = self.EnumToLong(CritType)
751 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
752 aCriterion.Compare = self.EnumToLong(Compare)
753 elif Compare == "=" or Compare == "==":
754 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
756 aCriterion.Compare = self.EnumToLong(FT_LessThan)
758 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
760 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
763 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
764 FT_BelongToCylinder, FT_LyingOnGeom]:
765 # Checks the treshold
766 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
767 aCriterion.ThresholdStr = GetName(aTreshold)
768 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
770 print "Error: The treshold should be a shape."
772 elif CritType == FT_RangeOfIds:
773 # Checks the treshold
774 if isinstance(aTreshold, str):
775 aCriterion.ThresholdStr = aTreshold
777 print "Error: The treshold should be a string."
779 elif CritType == FT_CoplanarFaces:
780 # Checks the treshold
781 if isinstance(aTreshold, int):
782 aCriterion.ThresholdID = "%s"%aTreshold
783 elif isinstance(aTreshold, str):
786 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
787 aCriterion.ThresholdID = aTreshold
790 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
791 elif CritType == FT_ElemGeomType:
792 # Checks the treshold
794 aCriterion.Threshold = self.EnumToLong(aTreshold)
796 if isinstance(aTreshold, int):
797 aCriterion.Threshold = aTreshold
799 print "Error: The treshold should be an integer or SMESH.GeometryType."
803 elif CritType == FT_GroupColor:
804 # Checks the treshold
806 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
808 print "Error: The threshold value should be of SALOMEDS.Color type"
811 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
812 FT_FreeFaces, FT_LinearOrQuadratic]:
813 # At this point the treshold is unnecessary
814 if aTreshold == FT_LogicalNOT:
815 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
816 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
817 aCriterion.BinaryOp = aTreshold
821 aTreshold = float(aTreshold)
822 aCriterion.Threshold = aTreshold
824 print "Error: The treshold should be a number."
827 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
828 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
830 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
831 aCriterion.BinaryOp = self.EnumToLong(Treshold)
833 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
834 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
836 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
837 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
841 ## Creates a filter with the given parameters
842 # @param elementType the type of elements in the group
843 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
844 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
845 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
846 # @param UnaryOp FT_LogicalNOT or FT_Undefined
847 # @return SMESH_Filter
848 # @ingroup l1_controls
849 def GetFilter(self,elementType,
850 CritType=FT_Undefined,
853 UnaryOp=FT_Undefined):
854 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
855 aFilterMgr = self.CreateFilterManager()
856 aFilter = aFilterMgr.CreateFilter()
857 aFilter.SetMesh( self.mesh )
859 aCriteria.append(aCriterion)
860 aFilter.SetCriteria(aCriteria)
863 ## Creates a numerical functor by its type
864 # @param theCriterion FT_...; functor type
865 # @return SMESH_NumericalFunctor
866 # @ingroup l1_controls
867 def GetFunctor(self,theCriterion):
868 aFilterMgr = self.CreateFilterManager()
869 if theCriterion == FT_AspectRatio:
870 return aFilterMgr.CreateAspectRatio()
871 elif theCriterion == FT_AspectRatio3D:
872 return aFilterMgr.CreateAspectRatio3D()
873 elif theCriterion == FT_Warping:
874 return aFilterMgr.CreateWarping()
875 elif theCriterion == FT_MinimumAngle:
876 return aFilterMgr.CreateMinimumAngle()
877 elif theCriterion == FT_Taper:
878 return aFilterMgr.CreateTaper()
879 elif theCriterion == FT_Skew:
880 return aFilterMgr.CreateSkew()
881 elif theCriterion == FT_Area:
882 return aFilterMgr.CreateArea()
883 elif theCriterion == FT_Volume3D:
884 return aFilterMgr.CreateVolume3D()
885 elif theCriterion == FT_MultiConnection:
886 return aFilterMgr.CreateMultiConnection()
887 elif theCriterion == FT_MultiConnection2D:
888 return aFilterMgr.CreateMultiConnection2D()
889 elif theCriterion == FT_Length:
890 return aFilterMgr.CreateLength()
891 elif theCriterion == FT_Length2D:
892 return aFilterMgr.CreateLength2D()
894 print "Error: given parameter is not numerucal functor type."
896 ## Creates hypothesis
897 # @param theHType mesh hypothesis type (string)
898 # @param theLibName mesh plug-in library name
899 # @return created hypothesis instance
900 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
901 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
903 ## Gets the mesh stattistic
904 # @return dictionary type element - count of elements
905 # @ingroup l1_meshinfo
906 def GetMeshInfo(self, obj):
907 if isinstance( obj, Mesh ):
910 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
911 values = obj.GetMeshInfo()
912 for i in range(SMESH.Entity_Last._v):
913 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
918 #Registering the new proxy for SMESH_Gen
919 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
925 ## This class allows defining and managing a mesh.
926 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
927 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
928 # new nodes and elements and by changing the existing entities), to get information
929 # about a mesh and to export a mesh into different formats.
938 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
939 # sets the GUI name of this mesh to \a name.
940 # @param smeshpyD an instance of smeshDC class
941 # @param geompyD an instance of geompyDC class
942 # @param obj Shape to be meshed or SMESH_Mesh object
943 # @param name Study name of the mesh
944 # @ingroup l2_construct
945 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
946 self.smeshpyD=smeshpyD
951 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
953 self.mesh = self.smeshpyD.CreateMesh(self.geom)
954 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
957 self.mesh = self.smeshpyD.CreateEmptyMesh()
959 self.smeshpyD.SetName(self.mesh, name)
961 self.smeshpyD.SetName(self.mesh, GetName(obj))
964 self.geom = self.mesh.GetShapeToMesh()
966 self.editor = self.mesh.GetMeshEditor()
968 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
969 # @param theMesh a SMESH_Mesh object
970 # @ingroup l2_construct
971 def SetMesh(self, theMesh):
973 self.geom = self.mesh.GetShapeToMesh()
975 ## Returns the mesh, that is an instance of SMESH_Mesh interface
976 # @return a SMESH_Mesh object
977 # @ingroup l2_construct
981 ## Gets the name of the mesh
982 # @return the name of the mesh as a string
983 # @ingroup l2_construct
985 name = GetName(self.GetMesh())
988 ## Sets a name to the mesh
989 # @param name a new name of the mesh
990 # @ingroup l2_construct
991 def SetName(self, name):
992 self.smeshpyD.SetName(self.GetMesh(), name)
994 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
995 # The subMesh object gives access to the IDs of nodes and elements.
996 # @param theSubObject a geometrical object (shape)
997 # @param theName a name for the submesh
998 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
999 # @ingroup l2_submeshes
1000 def GetSubMesh(self, theSubObject, theName):
1001 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1004 ## Returns the shape associated to the mesh
1005 # @return a GEOM_Object
1006 # @ingroup l2_construct
1010 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1011 # @param geom the shape to be meshed (GEOM_Object)
1012 # @ingroup l2_construct
1013 def SetShape(self, geom):
1014 self.mesh = self.smeshpyD.CreateMesh(geom)
1016 ## Returns true if the hypotheses are defined well
1017 # @param theSubObject a subshape of a mesh shape
1018 # @return True or False
1019 # @ingroup l2_construct
1020 def IsReadyToCompute(self, theSubObject):
1021 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1023 ## Returns errors of hypotheses definition.
1024 # The list of errors is empty if everything is OK.
1025 # @param theSubObject a subshape of a mesh shape
1026 # @return a list of errors
1027 # @ingroup l2_construct
1028 def GetAlgoState(self, theSubObject):
1029 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1031 ## Returns a geometrical object on which the given element was built.
1032 # The returned geometrical object, if not nil, is either found in the
1033 # study or published by this method with the given name
1034 # @param theElementID the id of the mesh element
1035 # @param theGeomName the user-defined name of the geometrical object
1036 # @return GEOM::GEOM_Object instance
1037 # @ingroup l2_construct
1038 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1039 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1041 ## Returns the mesh dimension depending on the dimension of the underlying shape
1042 # @return mesh dimension as an integer value [0,3]
1043 # @ingroup l1_auxiliary
1044 def MeshDimension(self):
1045 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1046 if len( shells ) > 0 :
1048 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1050 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1056 ## Creates a segment discretization 1D algorithm.
1057 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1058 # \n If the optional \a geom parameter is not set, this algorithm is global.
1059 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1060 # @param algo the type of the required algorithm. Possible values are:
1062 # - smesh.PYTHON for discretization via a python function,
1063 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1064 # @param geom If defined is the subshape to be meshed
1065 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1066 # @ingroup l3_algos_basic
1067 def Segment(self, algo=REGULAR, geom=0):
1068 ## if Segment(geom) is called by mistake
1069 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1070 algo, geom = geom, algo
1071 if not algo: algo = REGULAR
1074 return Mesh_Segment(self, geom)
1075 elif algo == PYTHON:
1076 return Mesh_Segment_Python(self, geom)
1077 elif algo == COMPOSITE:
1078 return Mesh_CompositeSegment(self, geom)
1080 return Mesh_Segment(self, geom)
1082 ## Enables creation of nodes and segments usable by 2D algoritms.
1083 # The added nodes and segments must be bound to edges and vertices by
1084 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1085 # If the optional \a geom parameter is not set, this algorithm is global.
1086 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1087 # @param geom the subshape to be manually meshed
1088 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1089 # @ingroup l3_algos_basic
1090 def UseExistingSegments(self, geom=0):
1091 algo = Mesh_UseExisting(1,self,geom)
1092 return algo.GetAlgorithm()
1094 ## Enables creation of nodes and faces usable by 3D algoritms.
1095 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1096 # and SetMeshElementOnShape()
1097 # If the optional \a geom parameter is not set, this algorithm is global.
1098 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1099 # @param geom the subshape to be manually meshed
1100 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1101 # @ingroup l3_algos_basic
1102 def UseExistingFaces(self, geom=0):
1103 algo = Mesh_UseExisting(2,self,geom)
1104 return algo.GetAlgorithm()
1106 ## Creates a triangle 2D algorithm for faces.
1107 # If the optional \a geom parameter is not set, this algorithm is global.
1108 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1109 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1110 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1111 # @return an instance of Mesh_Triangle algorithm
1112 # @ingroup l3_algos_basic
1113 def Triangle(self, algo=MEFISTO, geom=0):
1114 ## if Triangle(geom) is called by mistake
1115 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1118 return Mesh_Triangle(self, algo, geom)
1120 ## Creates a quadrangle 2D algorithm for faces.
1121 # If the optional \a geom parameter is not set, this algorithm is global.
1122 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1123 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1124 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1125 # @return an instance of Mesh_Quadrangle algorithm
1126 # @ingroup l3_algos_basic
1127 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1128 if algo==RADIAL_QUAD:
1129 return Mesh_RadialQuadrangle1D2D(self,geom)
1131 return Mesh_Quadrangle(self, geom)
1133 ## Creates a tetrahedron 3D algorithm for solids.
1134 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1135 # If the optional \a geom parameter is not set, this algorithm is global.
1136 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1137 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1138 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1139 # @return an instance of Mesh_Tetrahedron algorithm
1140 # @ingroup l3_algos_basic
1141 def Tetrahedron(self, algo=NETGEN, geom=0):
1142 ## if Tetrahedron(geom) is called by mistake
1143 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1144 algo, geom = geom, algo
1145 if not algo: algo = NETGEN
1147 return Mesh_Tetrahedron(self, algo, geom)
1149 ## Creates a hexahedron 3D algorithm for solids.
1150 # If the optional \a geom parameter is not set, this algorithm is global.
1151 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1152 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1153 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1154 # @return an instance of Mesh_Hexahedron algorithm
1155 # @ingroup l3_algos_basic
1156 def Hexahedron(self, algo=Hexa, geom=0):
1157 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1158 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1159 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1160 elif geom == 0: algo, geom = Hexa, algo
1161 return Mesh_Hexahedron(self, algo, geom)
1163 ## Deprecated, used only for compatibility!
1164 # @return an instance of Mesh_Netgen algorithm
1165 # @ingroup l3_algos_basic
1166 def Netgen(self, is3D, geom=0):
1167 return Mesh_Netgen(self, is3D, geom)
1169 ## Creates a projection 1D algorithm for edges.
1170 # If the optional \a geom parameter is not set, this algorithm is global.
1171 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1172 # @param geom If defined, the subshape to be meshed
1173 # @return an instance of Mesh_Projection1D algorithm
1174 # @ingroup l3_algos_proj
1175 def Projection1D(self, geom=0):
1176 return Mesh_Projection1D(self, geom)
1178 ## Creates a projection 2D algorithm for faces.
1179 # If the optional \a geom parameter is not set, this algorithm is global.
1180 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1181 # @param geom If defined, the subshape to be meshed
1182 # @return an instance of Mesh_Projection2D algorithm
1183 # @ingroup l3_algos_proj
1184 def Projection2D(self, geom=0):
1185 return Mesh_Projection2D(self, geom)
1187 ## Creates a projection 3D algorithm for solids.
1188 # If the optional \a geom parameter is not set, this algorithm is global.
1189 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1190 # @param geom If defined, the subshape to be meshed
1191 # @return an instance of Mesh_Projection3D algorithm
1192 # @ingroup l3_algos_proj
1193 def Projection3D(self, geom=0):
1194 return Mesh_Projection3D(self, geom)
1196 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1197 # If the optional \a geom parameter is not set, this algorithm is global.
1198 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1199 # @param geom If defined, the subshape to be meshed
1200 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1201 # @ingroup l3_algos_radialp l3_algos_3dextr
1202 def Prism(self, geom=0):
1206 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1207 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1208 if nbSolids == 0 or nbSolids == nbShells:
1209 return Mesh_Prism3D(self, geom)
1210 return Mesh_RadialPrism3D(self, geom)
1212 ## Evaluates size of prospective mesh on a shape
1213 # @return True or False
1214 def Evaluate(self, geom=0):
1215 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1217 geom = self.mesh.GetShapeToMesh()
1220 return self.smeshpyD.Evaluate(self.mesh, geom)
1223 ## Computes the mesh and returns the status of the computation
1224 # @param geom geomtrical shape on which mesh data should be computed
1225 # @param discardModifs if True and the mesh has been edited since
1226 # a last total re-compute and that may prevent successful partial re-compute,
1227 # then the mesh is cleaned before Compute()
1228 # @return True or False
1229 # @ingroup l2_construct
1230 def Compute(self, geom=0, discardModifs=False):
1231 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1233 geom = self.mesh.GetShapeToMesh()
1238 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1240 ok = self.smeshpyD.Compute(self.mesh, geom)
1241 except SALOME.SALOME_Exception, ex:
1242 print "Mesh computation failed, exception caught:"
1243 print " ", ex.details.text
1246 print "Mesh computation failed, exception caught:"
1247 traceback.print_exc()
1251 # Treat compute errors
1252 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1253 for err in computeErrors:
1255 if self.mesh.HasShapeToMesh():
1257 mainIOR = salome.orb.object_to_string(geom)
1258 for sname in salome.myStudyManager.GetOpenStudies():
1259 s = salome.myStudyManager.GetStudyByName(sname)
1261 mainSO = s.FindObjectIOR(mainIOR)
1262 if not mainSO: continue
1263 if err.subShapeID == 1:
1264 shapeText = ' on "%s"' % mainSO.GetName()
1265 subIt = s.NewChildIterator(mainSO)
1267 subSO = subIt.Value()
1269 obj = subSO.GetObject()
1270 if not obj: continue
1271 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1273 ids = go.GetSubShapeIndices()
1274 if len(ids) == 1 and ids[0] == err.subShapeID:
1275 shapeText = ' on "%s"' % subSO.GetName()
1278 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1280 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1282 shapeText = " on subshape #%s" % (err.subShapeID)
1284 shapeText = " on subshape #%s" % (err.subShapeID)
1286 stdErrors = ["OK", #COMPERR_OK
1287 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1288 "std::exception", #COMPERR_STD_EXCEPTION
1289 "OCC exception", #COMPERR_OCC_EXCEPTION
1290 "SALOME exception", #COMPERR_SLM_EXCEPTION
1291 "Unknown exception", #COMPERR_EXCEPTION
1292 "Memory allocation problem", #COMPERR_MEMORY_PB
1293 "Algorithm failed", #COMPERR_ALGO_FAILED
1294 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1296 if err.code < len(stdErrors): errText = stdErrors[err.code]
1298 errText = "code %s" % -err.code
1299 if errText: errText += ". "
1300 errText += err.comment
1301 if allReasons != "":allReasons += "\n"
1302 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1306 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1308 if err.isGlobalAlgo:
1316 reason = '%s %sD algorithm is missing' % (glob, dim)
1317 elif err.state == HYP_MISSING:
1318 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1319 % (glob, dim, name, dim))
1320 elif err.state == HYP_NOTCONFORM:
1321 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1322 elif err.state == HYP_BAD_PARAMETER:
1323 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1324 % ( glob, dim, name ))
1325 elif err.state == HYP_BAD_GEOMETRY:
1326 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1327 'geometry' % ( glob, dim, name ))
1329 reason = "For unknown reason."+\
1330 " Revise Mesh.Compute() implementation in smeshDC.py!"
1332 if allReasons != "":allReasons += "\n"
1333 allReasons += reason
1335 if allReasons != "":
1336 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1340 print '"' + GetName(self.mesh) + '"',"has not been computed."
1343 if salome.sg.hasDesktop():
1344 smeshgui = salome.ImportComponentGUI("SMESH")
1345 smeshgui.Init(self.mesh.GetStudyId())
1346 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1347 salome.sg.updateObjBrowser(1)
1351 ## Return submesh objects list in meshing order
1352 # @return list of list of submesh objects
1353 # @ingroup l2_construct
1354 def GetMeshOrder(self):
1355 return self.mesh.GetMeshOrder()
1357 ## Return submesh objects list in meshing order
1358 # @return list of list of submesh objects
1359 # @ingroup l2_construct
1360 def SetMeshOrder(self, submeshes):
1361 return self.mesh.SetMeshOrder(submeshes)
1363 ## Removes all nodes and elements
1364 # @ingroup l2_construct
1367 if salome.sg.hasDesktop():
1368 smeshgui = salome.ImportComponentGUI("SMESH")
1369 smeshgui.Init(self.mesh.GetStudyId())
1370 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1371 salome.sg.updateObjBrowser(1)
1373 ## Removes all nodes and elements of indicated shape
1374 # @ingroup l2_construct
1375 def ClearSubMesh(self, geomId):
1376 self.mesh.ClearSubMesh(geomId)
1377 if salome.sg.hasDesktop():
1378 smeshgui = salome.ImportComponentGUI("SMESH")
1379 smeshgui.Init(self.mesh.GetStudyId())
1380 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1381 salome.sg.updateObjBrowser(1)
1383 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1384 # @param fineness [0,-1] defines mesh fineness
1385 # @return True or False
1386 # @ingroup l3_algos_basic
1387 def AutomaticTetrahedralization(self, fineness=0):
1388 dim = self.MeshDimension()
1390 self.RemoveGlobalHypotheses()
1391 self.Segment().AutomaticLength(fineness)
1393 self.Triangle().LengthFromEdges()
1396 self.Tetrahedron(NETGEN)
1398 return self.Compute()
1400 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1401 # @param fineness [0,-1] defines mesh fineness
1402 # @return True or False
1403 # @ingroup l3_algos_basic
1404 def AutomaticHexahedralization(self, fineness=0):
1405 dim = self.MeshDimension()
1406 # assign the hypotheses
1407 self.RemoveGlobalHypotheses()
1408 self.Segment().AutomaticLength(fineness)
1415 return self.Compute()
1417 ## Assigns a hypothesis
1418 # @param hyp a hypothesis to assign
1419 # @param geom a subhape of mesh geometry
1420 # @return SMESH.Hypothesis_Status
1421 # @ingroup l2_hypotheses
1422 def AddHypothesis(self, hyp, geom=0):
1423 if isinstance( hyp, Mesh_Algorithm ):
1424 hyp = hyp.GetAlgorithm()
1429 geom = self.mesh.GetShapeToMesh()
1431 status = self.mesh.AddHypothesis(geom, hyp)
1432 isAlgo = hyp._narrow( SMESH_Algo )
1433 hyp_name = GetName( hyp )
1436 geom_name = GetName( geom )
1437 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1440 ## Unassigns a hypothesis
1441 # @param hyp a hypothesis to unassign
1442 # @param geom a subshape of mesh geometry
1443 # @return SMESH.Hypothesis_Status
1444 # @ingroup l2_hypotheses
1445 def RemoveHypothesis(self, hyp, geom=0):
1446 if isinstance( hyp, Mesh_Algorithm ):
1447 hyp = hyp.GetAlgorithm()
1452 status = self.mesh.RemoveHypothesis(geom, hyp)
1455 ## Gets the list of hypotheses added on a geometry
1456 # @param geom a subshape of mesh geometry
1457 # @return the sequence of SMESH_Hypothesis
1458 # @ingroup l2_hypotheses
1459 def GetHypothesisList(self, geom):
1460 return self.mesh.GetHypothesisList( geom )
1462 ## Removes all global hypotheses
1463 # @ingroup l2_hypotheses
1464 def RemoveGlobalHypotheses(self):
1465 current_hyps = self.mesh.GetHypothesisList( self.geom )
1466 for hyp in current_hyps:
1467 self.mesh.RemoveHypothesis( self.geom, hyp )
1471 ## Creates a mesh group based on the geometric object \a grp
1472 # and gives a \a name, \n if this parameter is not defined
1473 # the name is the same as the geometric group name \n
1474 # Note: Works like GroupOnGeom().
1475 # @param grp a geometric group, a vertex, an edge, a face or a solid
1476 # @param name the name of the mesh group
1477 # @return SMESH_GroupOnGeom
1478 # @ingroup l2_grps_create
1479 def Group(self, grp, name=""):
1480 return self.GroupOnGeom(grp, name)
1482 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1483 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1484 ## allowing to overwrite the file if it exists or add the exported data to its contents
1485 # @param f the file name
1486 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1487 # @param opt boolean parameter for creating/not creating
1488 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1489 # @param overwrite boolean parameter for overwriting/not overwriting the file
1490 # @ingroup l2_impexp
1491 def ExportToMED(self, f, version, opt=0, overwrite=1):
1492 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1494 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1495 ## allowing to overwrite the file if it exists or add the exported data to its contents
1496 # @param f is the file name
1497 # @param auto_groups boolean parameter for creating/not creating
1498 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1499 # the typical use is auto_groups=false.
1500 # @param version MED format version(MED_V2_1 or MED_V2_2)
1501 # @param overwrite boolean parameter for overwriting/not overwriting the file
1502 # @ingroup l2_impexp
1503 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1504 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1506 ## Exports the mesh in a file in DAT format
1507 # @param f the file name
1508 # @ingroup l2_impexp
1509 def ExportDAT(self, f):
1510 self.mesh.ExportDAT(f)
1512 ## Exports the mesh in a file in UNV format
1513 # @param f the file name
1514 # @ingroup l2_impexp
1515 def ExportUNV(self, f):
1516 self.mesh.ExportUNV(f)
1518 ## Export the mesh in a file in STL format
1519 # @param f the file name
1520 # @param ascii defines the file encoding
1521 # @ingroup l2_impexp
1522 def ExportSTL(self, f, ascii=1):
1523 self.mesh.ExportSTL(f, ascii)
1526 # Operations with groups:
1527 # ----------------------
1529 ## Creates an empty mesh group
1530 # @param elementType the type of elements in the group
1531 # @param name the name of the mesh group
1532 # @return SMESH_Group
1533 # @ingroup l2_grps_create
1534 def CreateEmptyGroup(self, elementType, name):
1535 return self.mesh.CreateGroup(elementType, name)
1537 ## Creates a mesh group based on the geometrical object \a grp
1538 # and gives a \a name, \n if this parameter is not defined
1539 # the name is the same as the geometrical group name
1540 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1541 # @param name the name of the mesh group
1542 # @param typ the type of elements in the group. If not set, it is
1543 # automatically detected by the type of the geometry
1544 # @return SMESH_GroupOnGeom
1545 # @ingroup l2_grps_create
1546 def GroupOnGeom(self, grp, name="", typ=None):
1548 name = grp.GetName()
1551 tgeo = str(grp.GetShapeType())
1552 if tgeo == "VERTEX":
1554 elif tgeo == "EDGE":
1556 elif tgeo == "FACE":
1558 elif tgeo == "SOLID":
1560 elif tgeo == "SHELL":
1562 elif tgeo == "COMPOUND":
1563 try: # it raises on a compound of compounds
1564 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1565 print "Mesh.Group: empty geometric group", GetName( grp )
1570 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1572 tgeo = self.geompyD.GetType(grp)
1573 if tgeo == geompyDC.ShapeType["VERTEX"]:
1575 elif tgeo == geompyDC.ShapeType["EDGE"]:
1577 elif tgeo == geompyDC.ShapeType["FACE"]:
1579 elif tgeo == geompyDC.ShapeType["SOLID"]:
1585 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1586 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1587 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1595 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1598 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1600 ## Creates a mesh group by the given ids of elements
1601 # @param groupName the name of the mesh group
1602 # @param elementType the type of elements in the group
1603 # @param elemIDs the list of ids
1604 # @return SMESH_Group
1605 # @ingroup l2_grps_create
1606 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1607 group = self.mesh.CreateGroup(elementType, groupName)
1611 ## Creates a mesh group by the given conditions
1612 # @param groupName the name of the mesh group
1613 # @param elementType the type of elements in the group
1614 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1615 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1616 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1617 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1618 # @return SMESH_Group
1619 # @ingroup l2_grps_create
1623 CritType=FT_Undefined,
1626 UnaryOp=FT_Undefined):
1627 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1628 group = self.MakeGroupByCriterion(groupName, aCriterion)
1631 ## Creates a mesh group by the given criterion
1632 # @param groupName the name of the mesh group
1633 # @param Criterion the instance of Criterion class
1634 # @return SMESH_Group
1635 # @ingroup l2_grps_create
1636 def MakeGroupByCriterion(self, groupName, Criterion):
1637 aFilterMgr = self.smeshpyD.CreateFilterManager()
1638 aFilter = aFilterMgr.CreateFilter()
1639 aFilter.SetMesh( self.mesh )
1641 aCriteria.append(Criterion)
1642 aFilter.SetCriteria(aCriteria)
1643 group = self.MakeGroupByFilter(groupName, aFilter)
1646 ## Creates a mesh group by the given criteria (list of criteria)
1647 # @param groupName the name of the mesh group
1648 # @param theCriteria the list of criteria
1649 # @return SMESH_Group
1650 # @ingroup l2_grps_create
1651 def MakeGroupByCriteria(self, groupName, theCriteria):
1652 aFilterMgr = self.smeshpyD.CreateFilterManager()
1653 aFilter = aFilterMgr.CreateFilter()
1654 aFilter.SetMesh( self.mesh )
1655 aFilter.SetCriteria(theCriteria)
1656 group = self.MakeGroupByFilter(groupName, aFilter)
1659 ## Creates a mesh group by the given filter
1660 # @param groupName the name of the mesh group
1661 # @param theFilter the instance of Filter class
1662 # @return SMESH_Group
1663 # @ingroup l2_grps_create
1664 def MakeGroupByFilter(self, groupName, theFilter):
1665 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1666 group.AddFrom( theFilter )
1669 ## Passes mesh elements through the given filter and return IDs of fitting elements
1670 # @param theFilter SMESH_Filter
1671 # @return a list of ids
1672 # @ingroup l1_controls
1673 def GetIdsFromFilter(self, theFilter):
1674 return theFilter.GetIDs()
1676 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1677 # Returns a list of special structures (borders).
1678 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1679 # @ingroup l1_controls
1680 def GetFreeBorders(self):
1681 aFilterMgr = self.smeshpyD.CreateFilterManager()
1682 aPredicate = aFilterMgr.CreateFreeEdges()
1683 aPredicate.SetMesh(self.mesh)
1684 aBorders = aPredicate.GetBorders()
1688 # @ingroup l2_grps_delete
1689 def RemoveGroup(self, group):
1690 self.mesh.RemoveGroup(group)
1692 ## Removes a group with its contents
1693 # @ingroup l2_grps_delete
1694 def RemoveGroupWithContents(self, group):
1695 self.mesh.RemoveGroupWithContents(group)
1697 ## Gets the list of groups existing in the mesh
1698 # @return a sequence of SMESH_GroupBase
1699 # @ingroup l2_grps_create
1700 def GetGroups(self):
1701 return self.mesh.GetGroups()
1703 ## Gets the number of groups existing in the mesh
1704 # @return the quantity of groups as an integer value
1705 # @ingroup l2_grps_create
1707 return self.mesh.NbGroups()
1709 ## Gets the list of names of groups existing in the mesh
1710 # @return list of strings
1711 # @ingroup l2_grps_create
1712 def GetGroupNames(self):
1713 groups = self.GetGroups()
1715 for group in groups:
1716 names.append(group.GetName())
1719 ## Produces a union of two groups
1720 # A new group is created. All mesh elements that are
1721 # present in the initial groups are added to the new one
1722 # @return an instance of SMESH_Group
1723 # @ingroup l2_grps_operon
1724 def UnionGroups(self, group1, group2, name):
1725 return self.mesh.UnionGroups(group1, group2, name)
1727 ## Produces a union list of groups
1728 # New group is created. All mesh elements that are present in
1729 # initial groups are added to the new one
1730 # @return an instance of SMESH_Group
1731 # @ingroup l2_grps_operon
1732 def UnionListOfGroups(self, groups, name):
1733 return self.mesh.UnionListOfGroups(groups, name)
1735 ## Prodices an intersection of two groups
1736 # A new group is created. All mesh elements that are common
1737 # for the two initial groups are added to the new one.
1738 # @return an instance of SMESH_Group
1739 # @ingroup l2_grps_operon
1740 def IntersectGroups(self, group1, group2, name):
1741 return self.mesh.IntersectGroups(group1, group2, name)
1743 ## Produces an intersection of groups
1744 # New group is created. All mesh elements that are present in all
1745 # initial groups simultaneously are added to the new one
1746 # @return an instance of SMESH_Group
1747 # @ingroup l2_grps_operon
1748 def IntersectListOfGroups(self, groups, name):
1749 return self.mesh.IntersectListOfGroups(groups, name)
1751 ## Produces a cut of two groups
1752 # A new group is created. All mesh elements that are present in
1753 # the main group but are not present in the tool group are added to the new one
1754 # @return an instance of SMESH_Group
1755 # @ingroup l2_grps_operon
1756 def CutGroups(self, main_group, tool_group, name):
1757 return self.mesh.CutGroups(main_group, tool_group, name)
1759 ## Produces a cut of groups
1760 # A new group is created. All mesh elements that are present in main groups
1761 # but do not present in tool groups are added to the new one
1762 # @return an instance of SMESH_Group
1763 # @ingroup l2_grps_operon
1764 def CutListOfGroups(self, main_groups, tool_groups, name):
1765 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1767 ## Produces a group of elements with specified element type using list of existing groups
1768 # A new group is created. System
1769 # 1) extract all nodes on which groups elements are built
1770 # 2) combine all elements of specified dimension laying on these nodes
1771 # @return an instance of SMESH_Group
1772 # @ingroup l2_grps_operon
1773 def CreateDimGroup(self, groups, elem_type, name):
1774 return self.mesh.CreateDimGroup(groups, elem_type, name)
1777 ## Convert group on geom into standalone group
1778 # @ingroup l2_grps_delete
1779 def ConvertToStandalone(self, group):
1780 return self.mesh.ConvertToStandalone(group)
1782 # Get some info about mesh:
1783 # ------------------------
1785 ## Returns the log of nodes and elements added or removed
1786 # since the previous clear of the log.
1787 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1788 # @return list of log_block structures:
1793 # @ingroup l1_auxiliary
1794 def GetLog(self, clearAfterGet):
1795 return self.mesh.GetLog(clearAfterGet)
1797 ## Clears the log of nodes and elements added or removed since the previous
1798 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1799 # @ingroup l1_auxiliary
1801 self.mesh.ClearLog()
1803 ## Toggles auto color mode on the object.
1804 # @param theAutoColor the flag which toggles auto color mode.
1805 # @ingroup l1_auxiliary
1806 def SetAutoColor(self, theAutoColor):
1807 self.mesh.SetAutoColor(theAutoColor)
1809 ## Gets flag of object auto color mode.
1810 # @return True or False
1811 # @ingroup l1_auxiliary
1812 def GetAutoColor(self):
1813 return self.mesh.GetAutoColor()
1815 ## Gets the internal ID
1816 # @return integer value, which is the internal Id of the mesh
1817 # @ingroup l1_auxiliary
1819 return self.mesh.GetId()
1822 # @return integer value, which is the study Id of the mesh
1823 # @ingroup l1_auxiliary
1824 def GetStudyId(self):
1825 return self.mesh.GetStudyId()
1827 ## Checks the group names for duplications.
1828 # Consider the maximum group name length stored in MED file.
1829 # @return True or False
1830 # @ingroup l1_auxiliary
1831 def HasDuplicatedGroupNamesMED(self):
1832 return self.mesh.HasDuplicatedGroupNamesMED()
1834 ## Obtains the mesh editor tool
1835 # @return an instance of SMESH_MeshEditor
1836 # @ingroup l1_modifying
1837 def GetMeshEditor(self):
1838 return self.mesh.GetMeshEditor()
1841 # @return an instance of SALOME_MED::MESH
1842 # @ingroup l1_auxiliary
1843 def GetMEDMesh(self):
1844 return self.mesh.GetMEDMesh()
1847 # Get informations about mesh contents:
1848 # ------------------------------------
1850 ## Gets the mesh stattistic
1851 # @return dictionary type element - count of elements
1852 # @ingroup l1_meshinfo
1853 def GetMeshInfo(self, obj = None):
1854 if not obj: obj = self.mesh
1855 return self.smeshpyD.GetMeshInfo(obj)
1857 ## Returns the number of nodes in the mesh
1858 # @return an integer value
1859 # @ingroup l1_meshinfo
1861 return self.mesh.NbNodes()
1863 ## Returns the number of elements in the mesh
1864 # @return an integer value
1865 # @ingroup l1_meshinfo
1866 def NbElements(self):
1867 return self.mesh.NbElements()
1869 ## Returns the number of 0d elements in the mesh
1870 # @return an integer value
1871 # @ingroup l1_meshinfo
1872 def Nb0DElements(self):
1873 return self.mesh.Nb0DElements()
1875 ## Returns the number of edges in the mesh
1876 # @return an integer value
1877 # @ingroup l1_meshinfo
1879 return self.mesh.NbEdges()
1881 ## Returns the number of edges with the given order in the mesh
1882 # @param elementOrder the order of elements:
1883 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1886 def NbEdgesOfOrder(self, elementOrder):
1887 return self.mesh.NbEdgesOfOrder(elementOrder)
1889 ## Returns the number of faces in the mesh
1890 # @return an integer value
1891 # @ingroup l1_meshinfo
1893 return self.mesh.NbFaces()
1895 ## Returns the number of faces with the given order in the mesh
1896 # @param elementOrder the order of elements:
1897 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1898 # @return an integer value
1899 # @ingroup l1_meshinfo
1900 def NbFacesOfOrder(self, elementOrder):
1901 return self.mesh.NbFacesOfOrder(elementOrder)
1903 ## Returns the number of triangles in the mesh
1904 # @return an integer value
1905 # @ingroup l1_meshinfo
1906 def NbTriangles(self):
1907 return self.mesh.NbTriangles()
1909 ## Returns the number of triangles with the given order in the mesh
1910 # @param elementOrder is the order of elements:
1911 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1912 # @return an integer value
1913 # @ingroup l1_meshinfo
1914 def NbTrianglesOfOrder(self, elementOrder):
1915 return self.mesh.NbTrianglesOfOrder(elementOrder)
1917 ## Returns the number of quadrangles in the mesh
1918 # @return an integer value
1919 # @ingroup l1_meshinfo
1920 def NbQuadrangles(self):
1921 return self.mesh.NbQuadrangles()
1923 ## Returns the number of quadrangles with the given order in the mesh
1924 # @param elementOrder the order of elements:
1925 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1926 # @return an integer value
1927 # @ingroup l1_meshinfo
1928 def NbQuadranglesOfOrder(self, elementOrder):
1929 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1931 ## Returns the number of polygons in the mesh
1932 # @return an integer value
1933 # @ingroup l1_meshinfo
1934 def NbPolygons(self):
1935 return self.mesh.NbPolygons()
1937 ## Returns the number of volumes in the mesh
1938 # @return an integer value
1939 # @ingroup l1_meshinfo
1940 def NbVolumes(self):
1941 return self.mesh.NbVolumes()
1943 ## Returns the number of volumes with the given order in the mesh
1944 # @param elementOrder the order of elements:
1945 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1946 # @return an integer value
1947 # @ingroup l1_meshinfo
1948 def NbVolumesOfOrder(self, elementOrder):
1949 return self.mesh.NbVolumesOfOrder(elementOrder)
1951 ## Returns the number of tetrahedrons in the mesh
1952 # @return an integer value
1953 # @ingroup l1_meshinfo
1955 return self.mesh.NbTetras()
1957 ## Returns the number of tetrahedrons with the given order in the mesh
1958 # @param elementOrder the order of elements:
1959 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1960 # @return an integer value
1961 # @ingroup l1_meshinfo
1962 def NbTetrasOfOrder(self, elementOrder):
1963 return self.mesh.NbTetrasOfOrder(elementOrder)
1965 ## Returns the number of hexahedrons in the mesh
1966 # @return an integer value
1967 # @ingroup l1_meshinfo
1969 return self.mesh.NbHexas()
1971 ## Returns the number of hexahedrons with the given order in the mesh
1972 # @param elementOrder the order of elements:
1973 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1974 # @return an integer value
1975 # @ingroup l1_meshinfo
1976 def NbHexasOfOrder(self, elementOrder):
1977 return self.mesh.NbHexasOfOrder(elementOrder)
1979 ## Returns the number of pyramids in the mesh
1980 # @return an integer value
1981 # @ingroup l1_meshinfo
1982 def NbPyramids(self):
1983 return self.mesh.NbPyramids()
1985 ## Returns the number of pyramids with the given order in the mesh
1986 # @param elementOrder the order of elements:
1987 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1988 # @return an integer value
1989 # @ingroup l1_meshinfo
1990 def NbPyramidsOfOrder(self, elementOrder):
1991 return self.mesh.NbPyramidsOfOrder(elementOrder)
1993 ## Returns the number of prisms in the mesh
1994 # @return an integer value
1995 # @ingroup l1_meshinfo
1997 return self.mesh.NbPrisms()
1999 ## Returns the number of prisms with the given order in the mesh
2000 # @param elementOrder the order of elements:
2001 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2002 # @return an integer value
2003 # @ingroup l1_meshinfo
2004 def NbPrismsOfOrder(self, elementOrder):
2005 return self.mesh.NbPrismsOfOrder(elementOrder)
2007 ## Returns the number of polyhedrons in the mesh
2008 # @return an integer value
2009 # @ingroup l1_meshinfo
2010 def NbPolyhedrons(self):
2011 return self.mesh.NbPolyhedrons()
2013 ## Returns the number of submeshes in the mesh
2014 # @return an integer value
2015 # @ingroup l1_meshinfo
2016 def NbSubMesh(self):
2017 return self.mesh.NbSubMesh()
2019 ## Returns the list of mesh elements IDs
2020 # @return the list of integer values
2021 # @ingroup l1_meshinfo
2022 def GetElementsId(self):
2023 return self.mesh.GetElementsId()
2025 ## Returns the list of IDs of mesh elements with the given type
2026 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2027 # @return list of integer values
2028 # @ingroup l1_meshinfo
2029 def GetElementsByType(self, elementType):
2030 return self.mesh.GetElementsByType(elementType)
2032 ## Returns the list of mesh nodes IDs
2033 # @return the list of integer values
2034 # @ingroup l1_meshinfo
2035 def GetNodesId(self):
2036 return self.mesh.GetNodesId()
2038 # Get the information about mesh elements:
2039 # ------------------------------------
2041 ## Returns the type of mesh element
2042 # @return the value from SMESH::ElementType enumeration
2043 # @ingroup l1_meshinfo
2044 def GetElementType(self, id, iselem):
2045 return self.mesh.GetElementType(id, iselem)
2047 ## Returns the geometric type of mesh element
2048 # @return the value from SMESH::EntityType enumeration
2049 # @ingroup l1_meshinfo
2050 def GetElementGeomType(self, id):
2051 return self.mesh.GetElementGeomType(id)
2053 ## Returns the list of submesh elements IDs
2054 # @param Shape a geom object(subshape) IOR
2055 # Shape must be the subshape of a ShapeToMesh()
2056 # @return the list of integer values
2057 # @ingroup l1_meshinfo
2058 def GetSubMeshElementsId(self, Shape):
2059 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2060 ShapeID = Shape.GetSubShapeIndices()[0]
2063 return self.mesh.GetSubMeshElementsId(ShapeID)
2065 ## Returns the list of submesh nodes IDs
2066 # @param Shape a geom object(subshape) IOR
2067 # Shape must be the subshape of a ShapeToMesh()
2068 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2069 # @return the list of integer values
2070 # @ingroup l1_meshinfo
2071 def GetSubMeshNodesId(self, Shape, all):
2072 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2073 ShapeID = Shape.GetSubShapeIndices()[0]
2076 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2078 ## Returns type of elements on given shape
2079 # @param Shape a geom object(subshape) IOR
2080 # Shape must be a subshape of a ShapeToMesh()
2081 # @return element type
2082 # @ingroup l1_meshinfo
2083 def GetSubMeshElementType(self, Shape):
2084 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2085 ShapeID = Shape.GetSubShapeIndices()[0]
2088 return self.mesh.GetSubMeshElementType(ShapeID)
2090 ## Gets the mesh description
2091 # @return string value
2092 # @ingroup l1_meshinfo
2094 return self.mesh.Dump()
2097 # Get the information about nodes and elements of a mesh by its IDs:
2098 # -----------------------------------------------------------
2100 ## Gets XYZ coordinates of a node
2101 # \n If there is no nodes for the given ID - returns an empty list
2102 # @return a list of double precision values
2103 # @ingroup l1_meshinfo
2104 def GetNodeXYZ(self, id):
2105 return self.mesh.GetNodeXYZ(id)
2107 ## Returns list of IDs of inverse elements for the given node
2108 # \n If there is no node for the given ID - returns an empty list
2109 # @return a list of integer values
2110 # @ingroup l1_meshinfo
2111 def GetNodeInverseElements(self, id):
2112 return self.mesh.GetNodeInverseElements(id)
2114 ## @brief Returns the position of a node on the shape
2115 # @return SMESH::NodePosition
2116 # @ingroup l1_meshinfo
2117 def GetNodePosition(self,NodeID):
2118 return self.mesh.GetNodePosition(NodeID)
2120 ## If the given element is a node, returns the ID of shape
2121 # \n If there is no node for the given ID - returns -1
2122 # @return an integer value
2123 # @ingroup l1_meshinfo
2124 def GetShapeID(self, id):
2125 return self.mesh.GetShapeID(id)
2127 ## Returns the ID of the result shape after
2128 # FindShape() from SMESH_MeshEditor for the given element
2129 # \n If there is no element for the given ID - returns -1
2130 # @return an integer value
2131 # @ingroup l1_meshinfo
2132 def GetShapeIDForElem(self,id):
2133 return self.mesh.GetShapeIDForElem(id)
2135 ## Returns the number of nodes for the given element
2136 # \n If there is no element for the given ID - returns -1
2137 # @return an integer value
2138 # @ingroup l1_meshinfo
2139 def GetElemNbNodes(self, id):
2140 return self.mesh.GetElemNbNodes(id)
2142 ## Returns the node ID the given index for the given element
2143 # \n If there is no element for the given ID - returns -1
2144 # \n If there is no node for the given index - returns -2
2145 # @return an integer value
2146 # @ingroup l1_meshinfo
2147 def GetElemNode(self, id, index):
2148 return self.mesh.GetElemNode(id, index)
2150 ## Returns the IDs of nodes of the given element
2151 # @return a list of integer values
2152 # @ingroup l1_meshinfo
2153 def GetElemNodes(self, id):
2154 return self.mesh.GetElemNodes(id)
2156 ## Returns true if the given node is the medium node in the given quadratic element
2157 # @ingroup l1_meshinfo
2158 def IsMediumNode(self, elementID, nodeID):
2159 return self.mesh.IsMediumNode(elementID, nodeID)
2161 ## Returns true if the given node is the medium node in one of quadratic elements
2162 # @ingroup l1_meshinfo
2163 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2164 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2166 ## Returns the number of edges for the given element
2167 # @ingroup l1_meshinfo
2168 def ElemNbEdges(self, id):
2169 return self.mesh.ElemNbEdges(id)
2171 ## Returns the number of faces for the given element
2172 # @ingroup l1_meshinfo
2173 def ElemNbFaces(self, id):
2174 return self.mesh.ElemNbFaces(id)
2176 ## Returns nodes of given face (counted from zero) for given volumic element.
2177 # @ingroup l1_meshinfo
2178 def GetElemFaceNodes(self,elemId, faceIndex):
2179 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2181 ## Returns an element based on all given nodes.
2182 # @ingroup l1_meshinfo
2183 def FindElementByNodes(self,nodes):
2184 return self.mesh.FindElementByNodes(nodes)
2186 ## Returns true if the given element is a polygon
2187 # @ingroup l1_meshinfo
2188 def IsPoly(self, id):
2189 return self.mesh.IsPoly(id)
2191 ## Returns true if the given element is quadratic
2192 # @ingroup l1_meshinfo
2193 def IsQuadratic(self, id):
2194 return self.mesh.IsQuadratic(id)
2196 ## Returns XYZ coordinates of the barycenter of the given element
2197 # \n If there is no element for the given ID - returns an empty list
2198 # @return a list of three double values
2199 # @ingroup l1_meshinfo
2200 def BaryCenter(self, id):
2201 return self.mesh.BaryCenter(id)
2204 # Mesh edition (SMESH_MeshEditor functionality):
2205 # ---------------------------------------------
2207 ## Removes the elements from the mesh by ids
2208 # @param IDsOfElements is a list of ids of elements to remove
2209 # @return True or False
2210 # @ingroup l2_modif_del
2211 def RemoveElements(self, IDsOfElements):
2212 return self.editor.RemoveElements(IDsOfElements)
2214 ## Removes nodes from mesh by ids
2215 # @param IDsOfNodes is a list of ids of nodes to remove
2216 # @return True or False
2217 # @ingroup l2_modif_del
2218 def RemoveNodes(self, IDsOfNodes):
2219 return self.editor.RemoveNodes(IDsOfNodes)
2221 ## Removes all orphan (free) nodes from mesh
2222 # @return number of the removed nodes
2223 # @ingroup l2_modif_del
2224 def RemoveOrphanNodes(self):
2225 return self.editor.RemoveOrphanNodes()
2227 ## Add a node to the mesh by coordinates
2228 # @return Id of the new node
2229 # @ingroup l2_modif_add
2230 def AddNode(self, x, y, z):
2231 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2232 self.mesh.SetParameters(Parameters)
2233 return self.editor.AddNode( x, y, z)
2235 ## Creates a 0D element on a node with given number.
2236 # @param IDOfNode the ID of node for creation of the element.
2237 # @return the Id of the new 0D element
2238 # @ingroup l2_modif_add
2239 def Add0DElement(self, IDOfNode):
2240 return self.editor.Add0DElement(IDOfNode)
2242 ## Creates a linear or quadratic edge (this is determined
2243 # by the number of given nodes).
2244 # @param IDsOfNodes the list of node IDs for creation of the element.
2245 # The order of nodes in this list should correspond to the description
2246 # of MED. \n This description is located by the following link:
2247 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2248 # @return the Id of the new edge
2249 # @ingroup l2_modif_add
2250 def AddEdge(self, IDsOfNodes):
2251 return self.editor.AddEdge(IDsOfNodes)
2253 ## Creates a linear or quadratic face (this is determined
2254 # by the number of given nodes).
2255 # @param IDsOfNodes the list of node IDs for creation of the element.
2256 # The order of nodes in this list should correspond to the description
2257 # of MED. \n This description is located by the following link:
2258 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2259 # @return the Id of the new face
2260 # @ingroup l2_modif_add
2261 def AddFace(self, IDsOfNodes):
2262 return self.editor.AddFace(IDsOfNodes)
2264 ## Adds a polygonal face to the mesh by the list of node IDs
2265 # @param IdsOfNodes the list of node IDs for creation of the element.
2266 # @return the Id of the new face
2267 # @ingroup l2_modif_add
2268 def AddPolygonalFace(self, IdsOfNodes):
2269 return self.editor.AddPolygonalFace(IdsOfNodes)
2271 ## Creates both simple and quadratic volume (this is determined
2272 # by the number of given nodes).
2273 # @param IDsOfNodes the list of node IDs for creation of the element.
2274 # The order of nodes in this list should correspond to the description
2275 # of MED. \n This description is located by the following link:
2276 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2277 # @return the Id of the new volumic element
2278 # @ingroup l2_modif_add
2279 def AddVolume(self, IDsOfNodes):
2280 return self.editor.AddVolume(IDsOfNodes)
2282 ## Creates a volume of many faces, giving nodes for each face.
2283 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2284 # @param Quantities the list of integer values, Quantities[i]
2285 # gives the quantity of nodes in face number i.
2286 # @return the Id of the new volumic element
2287 # @ingroup l2_modif_add
2288 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2289 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2291 ## Creates a volume of many faces, giving the IDs of the existing faces.
2292 # @param IdsOfFaces the list of face IDs for volume creation.
2294 # Note: The created volume will refer only to the nodes
2295 # of the given faces, not to the faces themselves.
2296 # @return the Id of the new volumic element
2297 # @ingroup l2_modif_add
2298 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2299 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2302 ## @brief Binds a node to a vertex
2303 # @param NodeID a node ID
2304 # @param Vertex a vertex or vertex ID
2305 # @return True if succeed else raises an exception
2306 # @ingroup l2_modif_add
2307 def SetNodeOnVertex(self, NodeID, Vertex):
2308 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2309 VertexID = Vertex.GetSubShapeIndices()[0]
2313 self.editor.SetNodeOnVertex(NodeID, VertexID)
2314 except SALOME.SALOME_Exception, inst:
2315 raise ValueError, inst.details.text
2319 ## @brief Stores the node position on an edge
2320 # @param NodeID a node ID
2321 # @param Edge an edge or edge ID
2322 # @param paramOnEdge a parameter on the edge where the node is located
2323 # @return True if succeed else raises an exception
2324 # @ingroup l2_modif_add
2325 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2326 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2327 EdgeID = Edge.GetSubShapeIndices()[0]
2331 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2332 except SALOME.SALOME_Exception, inst:
2333 raise ValueError, inst.details.text
2336 ## @brief Stores node position on a face
2337 # @param NodeID a node ID
2338 # @param Face a face or face ID
2339 # @param u U parameter on the face where the node is located
2340 # @param v V parameter on the face where the node is located
2341 # @return True if succeed else raises an exception
2342 # @ingroup l2_modif_add
2343 def SetNodeOnFace(self, NodeID, Face, u, v):
2344 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2345 FaceID = Face.GetSubShapeIndices()[0]
2349 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2350 except SALOME.SALOME_Exception, inst:
2351 raise ValueError, inst.details.text
2354 ## @brief Binds a node to a solid
2355 # @param NodeID a node ID
2356 # @param Solid a solid or solid ID
2357 # @return True if succeed else raises an exception
2358 # @ingroup l2_modif_add
2359 def SetNodeInVolume(self, NodeID, Solid):
2360 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2361 SolidID = Solid.GetSubShapeIndices()[0]
2365 self.editor.SetNodeInVolume(NodeID, SolidID)
2366 except SALOME.SALOME_Exception, inst:
2367 raise ValueError, inst.details.text
2370 ## @brief Bind an element to a shape
2371 # @param ElementID an element ID
2372 # @param Shape a shape or shape ID
2373 # @return True if succeed else raises an exception
2374 # @ingroup l2_modif_add
2375 def SetMeshElementOnShape(self, ElementID, Shape):
2376 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2377 ShapeID = Shape.GetSubShapeIndices()[0]
2381 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2382 except SALOME.SALOME_Exception, inst:
2383 raise ValueError, inst.details.text
2387 ## Moves the node with the given id
2388 # @param NodeID the id of the node
2389 # @param x a new X coordinate
2390 # @param y a new Y coordinate
2391 # @param z a new Z coordinate
2392 # @return True if succeed else False
2393 # @ingroup l2_modif_movenode
2394 def MoveNode(self, NodeID, x, y, z):
2395 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2396 self.mesh.SetParameters(Parameters)
2397 return self.editor.MoveNode(NodeID, x, y, z)
2399 ## Finds the node closest to a point and moves it to a point location
2400 # @param x the X coordinate of a point
2401 # @param y the Y coordinate of a point
2402 # @param z the Z coordinate of a point
2403 # @param NodeID if specified (>0), the node with this ID is moved,
2404 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2405 # @return the ID of a node
2406 # @ingroup l2_modif_throughp
2407 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2408 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2409 self.mesh.SetParameters(Parameters)
2410 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2412 ## Finds the node closest to a point
2413 # @param x the X coordinate of a point
2414 # @param y the Y coordinate of a point
2415 # @param z the Z coordinate of a point
2416 # @return the ID of a node
2417 # @ingroup l2_modif_throughp
2418 def FindNodeClosestTo(self, x, y, z):
2419 #preview = self.mesh.GetMeshEditPreviewer()
2420 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2421 return self.editor.FindNodeClosestTo(x, y, z)
2423 ## Finds the elements where a point lays IN or ON
2424 # @param x the X coordinate of a point
2425 # @param y the Y coordinate of a point
2426 # @param z the Z coordinate of a point
2427 # @param elementType type of elements to find (SMESH.ALL type
2428 # means elements of any type excluding nodes and 0D elements)
2429 # @return list of IDs of found elements
2430 # @ingroup l2_modif_throughp
2431 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2432 return self.editor.FindElementsByPoint(x, y, z, elementType)
2434 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2435 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2437 def GetPointState(self, x, y, z):
2438 return self.editor.GetPointState(x, y, z)
2440 ## Finds the node closest to a point and moves it to a point location
2441 # @param x the X coordinate of a point
2442 # @param y the Y coordinate of a point
2443 # @param z the Z coordinate of a point
2444 # @return the ID of a moved node
2445 # @ingroup l2_modif_throughp
2446 def MeshToPassThroughAPoint(self, x, y, z):
2447 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2449 ## Replaces two neighbour triangles sharing Node1-Node2 link
2450 # with the triangles built on the same 4 nodes but having other common link.
2451 # @param NodeID1 the ID of the first node
2452 # @param NodeID2 the ID of the second node
2453 # @return false if proper faces were not found
2454 # @ingroup l2_modif_invdiag
2455 def InverseDiag(self, NodeID1, NodeID2):
2456 return self.editor.InverseDiag(NodeID1, NodeID2)
2458 ## Replaces two neighbour triangles sharing Node1-Node2 link
2459 # with a quadrangle built on the same 4 nodes.
2460 # @param NodeID1 the ID of the first node
2461 # @param NodeID2 the ID of the second node
2462 # @return false if proper faces were not found
2463 # @ingroup l2_modif_unitetri
2464 def DeleteDiag(self, NodeID1, NodeID2):
2465 return self.editor.DeleteDiag(NodeID1, NodeID2)
2467 ## Reorients elements by ids
2468 # @param IDsOfElements if undefined reorients all mesh elements
2469 # @return True if succeed else False
2470 # @ingroup l2_modif_changori
2471 def Reorient(self, IDsOfElements=None):
2472 if IDsOfElements == None:
2473 IDsOfElements = self.GetElementsId()
2474 return self.editor.Reorient(IDsOfElements)
2476 ## Reorients all elements of the object
2477 # @param theObject mesh, submesh or group
2478 # @return True if succeed else False
2479 # @ingroup l2_modif_changori
2480 def ReorientObject(self, theObject):
2481 if ( isinstance( theObject, Mesh )):
2482 theObject = theObject.GetMesh()
2483 return self.editor.ReorientObject(theObject)
2485 ## Fuses the neighbouring triangles into quadrangles.
2486 # @param IDsOfElements The triangles to be fused,
2487 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2488 # @param MaxAngle is the maximum angle between element normals at which the fusion
2489 # is still performed; theMaxAngle is mesured in radians.
2490 # Also it could be a name of variable which defines angle in degrees.
2491 # @return TRUE in case of success, FALSE otherwise.
2492 # @ingroup l2_modif_unitetri
2493 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2495 if isinstance(MaxAngle,str):
2497 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2499 MaxAngle = DegreesToRadians(MaxAngle)
2500 if IDsOfElements == []:
2501 IDsOfElements = self.GetElementsId()
2502 self.mesh.SetParameters(Parameters)
2504 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2505 Functor = theCriterion
2507 Functor = self.smeshpyD.GetFunctor(theCriterion)
2508 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2510 ## Fuses the neighbouring triangles of the object into quadrangles
2511 # @param theObject is mesh, submesh or group
2512 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2513 # @param MaxAngle a max angle between element normals at which the fusion
2514 # is still performed; theMaxAngle is mesured in radians.
2515 # @return TRUE in case of success, FALSE otherwise.
2516 # @ingroup l2_modif_unitetri
2517 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2518 if ( isinstance( theObject, Mesh )):
2519 theObject = theObject.GetMesh()
2520 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2522 ## Splits quadrangles into triangles.
2523 # @param IDsOfElements the faces to be splitted.
2524 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2525 # @return TRUE in case of success, FALSE otherwise.
2526 # @ingroup l2_modif_cutquadr
2527 def QuadToTri (self, IDsOfElements, theCriterion):
2528 if IDsOfElements == []:
2529 IDsOfElements = self.GetElementsId()
2530 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2532 ## Splits quadrangles into triangles.
2533 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2534 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2535 # @return TRUE in case of success, FALSE otherwise.
2536 # @ingroup l2_modif_cutquadr
2537 def QuadToTriObject (self, theObject, theCriterion):
2538 if ( isinstance( theObject, Mesh )):
2539 theObject = theObject.GetMesh()
2540 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2542 ## Splits quadrangles into triangles.
2543 # @param IDsOfElements the faces to be splitted
2544 # @param Diag13 is used to choose a diagonal for splitting.
2545 # @return TRUE in case of success, FALSE otherwise.
2546 # @ingroup l2_modif_cutquadr
2547 def SplitQuad (self, IDsOfElements, Diag13):
2548 if IDsOfElements == []:
2549 IDsOfElements = self.GetElementsId()
2550 return self.editor.SplitQuad(IDsOfElements, Diag13)
2552 ## Splits quadrangles into triangles.
2553 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2554 # @param Diag13 is used to choose a diagonal for splitting.
2555 # @return TRUE in case of success, FALSE otherwise.
2556 # @ingroup l2_modif_cutquadr
2557 def SplitQuadObject (self, theObject, Diag13):
2558 if ( isinstance( theObject, Mesh )):
2559 theObject = theObject.GetMesh()
2560 return self.editor.SplitQuadObject(theObject, Diag13)
2562 ## Finds a better splitting of the given quadrangle.
2563 # @param IDOfQuad the ID of the quadrangle to be splitted.
2564 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2565 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2566 # diagonal is better, 0 if error occurs.
2567 # @ingroup l2_modif_cutquadr
2568 def BestSplit (self, IDOfQuad, theCriterion):
2569 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2571 ## Splits volumic elements into tetrahedrons
2572 # @param elemIDs either list of elements or mesh or group or submesh
2573 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2574 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2575 # @ingroup l2_modif_cutquadr
2576 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2577 if isinstance( elemIDs, Mesh ):
2578 elemIDs = elemIDs.GetMesh()
2579 if ( isinstance( elemIDs, list )):
2580 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2581 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2583 ## Splits quadrangle faces near triangular facets of volumes
2585 # @ingroup l1_auxiliary
2586 def SplitQuadsNearTriangularFacets(self):
2587 faces_array = self.GetElementsByType(SMESH.FACE)
2588 for face_id in faces_array:
2589 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2590 quad_nodes = self.mesh.GetElemNodes(face_id)
2591 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2592 isVolumeFound = False
2593 for node1_elem in node1_elems:
2594 if not isVolumeFound:
2595 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2596 nb_nodes = self.GetElemNbNodes(node1_elem)
2597 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2598 volume_elem = node1_elem
2599 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2600 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2601 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2602 isVolumeFound = True
2603 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2604 self.SplitQuad([face_id], False) # diagonal 2-4
2605 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2606 isVolumeFound = True
2607 self.SplitQuad([face_id], True) # diagonal 1-3
2608 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2609 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2610 isVolumeFound = True
2611 self.SplitQuad([face_id], True) # diagonal 1-3
2613 ## @brief Splits hexahedrons into tetrahedrons.
2615 # This operation uses pattern mapping functionality for splitting.
2616 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2617 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2618 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2619 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2620 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2621 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2622 # @return TRUE in case of success, FALSE otherwise.
2623 # @ingroup l1_auxiliary
2624 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2625 # Pattern: 5.---------.6
2630 # (0,0,1) 4.---------.7 * |
2637 # (0,0,0) 0.---------.3
2638 pattern_tetra = "!!! Nb of points: \n 8 \n\
2648 !!! Indices of points of 6 tetras: \n\
2656 pattern = self.smeshpyD.GetPattern()
2657 isDone = pattern.LoadFromFile(pattern_tetra)
2659 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2662 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2663 isDone = pattern.MakeMesh(self.mesh, False, False)
2664 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2666 # split quafrangle faces near triangular facets of volumes
2667 self.SplitQuadsNearTriangularFacets()
2671 ## @brief Split hexahedrons into prisms.
2673 # Uses the pattern mapping functionality for splitting.
2674 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2675 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2676 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2677 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2678 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2679 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2680 # @return TRUE in case of success, FALSE otherwise.
2681 # @ingroup l1_auxiliary
2682 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2683 # Pattern: 5.---------.6
2688 # (0,0,1) 4.---------.7 |
2695 # (0,0,0) 0.---------.3
2696 pattern_prism = "!!! Nb of points: \n 8 \n\
2706 !!! Indices of points of 2 prisms: \n\
2710 pattern = self.smeshpyD.GetPattern()
2711 isDone = pattern.LoadFromFile(pattern_prism)
2713 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2716 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2717 isDone = pattern.MakeMesh(self.mesh, False, False)
2718 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2720 # Splits quafrangle faces near triangular facets of volumes
2721 self.SplitQuadsNearTriangularFacets()
2725 ## Smoothes elements
2726 # @param IDsOfElements the list if ids of elements to smooth
2727 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2728 # Note that nodes built on edges and boundary nodes are always fixed.
2729 # @param MaxNbOfIterations the maximum number of iterations
2730 # @param MaxAspectRatio varies in range [1.0, inf]
2731 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2732 # @return TRUE in case of success, FALSE otherwise.
2733 # @ingroup l2_modif_smooth
2734 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2735 MaxNbOfIterations, MaxAspectRatio, Method):
2736 if IDsOfElements == []:
2737 IDsOfElements = self.GetElementsId()
2738 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2739 self.mesh.SetParameters(Parameters)
2740 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2741 MaxNbOfIterations, MaxAspectRatio, Method)
2743 ## Smoothes elements which belong to the given object
2744 # @param theObject the object to smooth
2745 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2746 # Note that nodes built on edges and boundary nodes are always fixed.
2747 # @param MaxNbOfIterations the maximum number of iterations
2748 # @param MaxAspectRatio varies in range [1.0, inf]
2749 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2750 # @return TRUE in case of success, FALSE otherwise.
2751 # @ingroup l2_modif_smooth
2752 def SmoothObject(self, theObject, IDsOfFixedNodes,
2753 MaxNbOfIterations, MaxAspectRatio, Method):
2754 if ( isinstance( theObject, Mesh )):
2755 theObject = theObject.GetMesh()
2756 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2757 MaxNbOfIterations, MaxAspectRatio, Method)
2759 ## Parametrically smoothes the given elements
2760 # @param IDsOfElements the list if ids of elements to smooth
2761 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2762 # Note that nodes built on edges and boundary nodes are always fixed.
2763 # @param MaxNbOfIterations the maximum number of iterations
2764 # @param MaxAspectRatio varies in range [1.0, inf]
2765 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2766 # @return TRUE in case of success, FALSE otherwise.
2767 # @ingroup l2_modif_smooth
2768 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2769 MaxNbOfIterations, MaxAspectRatio, Method):
2770 if IDsOfElements == []:
2771 IDsOfElements = self.GetElementsId()
2772 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2773 self.mesh.SetParameters(Parameters)
2774 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2775 MaxNbOfIterations, MaxAspectRatio, Method)
2777 ## Parametrically smoothes the elements which belong to the given object
2778 # @param theObject the object to smooth
2779 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2780 # Note that nodes built on edges and boundary nodes are always fixed.
2781 # @param MaxNbOfIterations the maximum number of iterations
2782 # @param MaxAspectRatio varies in range [1.0, inf]
2783 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2784 # @return TRUE in case of success, FALSE otherwise.
2785 # @ingroup l2_modif_smooth
2786 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2787 MaxNbOfIterations, MaxAspectRatio, Method):
2788 if ( isinstance( theObject, Mesh )):
2789 theObject = theObject.GetMesh()
2790 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2791 MaxNbOfIterations, MaxAspectRatio, Method)
2793 ## Converts the mesh to quadratic, deletes old elements, replacing
2794 # them with quadratic with the same id.
2795 # @param theForce3d new node creation method:
2796 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
2797 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
2798 # @ingroup l2_modif_tofromqu
2799 def ConvertToQuadratic(self, theForce3d):
2800 self.editor.ConvertToQuadratic(theForce3d)
2802 ## Converts the mesh from quadratic to ordinary,
2803 # deletes old quadratic elements, \n replacing
2804 # them with ordinary mesh elements with the same id.
2805 # @return TRUE in case of success, FALSE otherwise.
2806 # @ingroup l2_modif_tofromqu
2807 def ConvertFromQuadratic(self):
2808 return self.editor.ConvertFromQuadratic()
2810 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2811 # @return TRUE if operation has been completed successfully, FALSE otherwise
2812 # @ingroup l2_modif_edit
2813 def Make2DMeshFrom3D(self):
2814 return self.editor. Make2DMeshFrom3D()
2816 ## Creates missing boundary elements
2817 # @param elements - elements whose boundary is to be checked:
2818 # mesh, group, sub-mesh or list of elements
2819 # @param dimension - defines type of boundary elements to create:
2820 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
2821 # @param groupName - a name of group to store created boundary elements in,
2822 # "" means not to create the group
2823 # @param meshName - a name of new mesh to store created boundary elements in,
2824 # "" means not to create the new mesh
2825 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
2826 # @param toCopyExistingBondary - if true, not only new but also pre-existing
2827 # boundary elements will be copied into the new mesh
2828 # @return tuple (mesh, group) where bondary elements were added to
2829 # @ingroup l2_modif_edit
2830 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
2831 toCopyElements=False, toCopyExistingBondary=False):
2832 if isinstance( elements, Mesh ):
2833 elements = elements.GetMesh()
2834 if ( isinstance( elements, list )):
2835 elemType = SMESH.ALL
2836 if elements: elemType = self.GetElementType( elements[0], iselem=True)
2837 elements = self.editor.MakeIDSource(elements, elemType)
2838 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
2839 toCopyElements,toCopyExistingBondary)
2840 if mesh: mesh = self.smeshpyD.Mesh(mesh)
2843 ## Renumber mesh nodes
2844 # @ingroup l2_modif_renumber
2845 def RenumberNodes(self):
2846 self.editor.RenumberNodes()
2848 ## Renumber mesh elements
2849 # @ingroup l2_modif_renumber
2850 def RenumberElements(self):
2851 self.editor.RenumberElements()
2853 ## Generates new elements by rotation of the elements around the axis
2854 # @param IDsOfElements the list of ids of elements to sweep
2855 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2856 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2857 # @param NbOfSteps the number of steps
2858 # @param Tolerance tolerance
2859 # @param MakeGroups forces the generation of new groups from existing ones
2860 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2861 # of all steps, else - size of each step
2862 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2863 # @ingroup l2_modif_extrurev
2864 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2865 MakeGroups=False, TotalAngle=False):
2867 if isinstance(AngleInRadians,str):
2869 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2871 AngleInRadians = DegreesToRadians(AngleInRadians)
2872 if IDsOfElements == []:
2873 IDsOfElements = self.GetElementsId()
2874 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2875 Axis = self.smeshpyD.GetAxisStruct(Axis)
2876 Axis,AxisParameters = ParseAxisStruct(Axis)
2877 if TotalAngle and NbOfSteps:
2878 AngleInRadians /= NbOfSteps
2879 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2880 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2881 self.mesh.SetParameters(Parameters)
2883 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2884 AngleInRadians, NbOfSteps, Tolerance)
2885 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2888 ## Generates new elements by rotation of the elements of object around the axis
2889 # @param theObject object which elements should be sweeped
2890 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2891 # @param AngleInRadians the angle of Rotation
2892 # @param NbOfSteps number of steps
2893 # @param Tolerance tolerance
2894 # @param MakeGroups forces the generation of new groups from existing ones
2895 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2896 # of all steps, else - size of each step
2897 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2898 # @ingroup l2_modif_extrurev
2899 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2900 MakeGroups=False, TotalAngle=False):
2902 if isinstance(AngleInRadians,str):
2904 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2906 AngleInRadians = DegreesToRadians(AngleInRadians)
2907 if ( isinstance( theObject, Mesh )):
2908 theObject = theObject.GetMesh()
2909 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2910 Axis = self.smeshpyD.GetAxisStruct(Axis)
2911 Axis,AxisParameters = ParseAxisStruct(Axis)
2912 if TotalAngle and NbOfSteps:
2913 AngleInRadians /= NbOfSteps
2914 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2915 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2916 self.mesh.SetParameters(Parameters)
2918 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2919 NbOfSteps, Tolerance)
2920 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2923 ## Generates new elements by rotation of the elements of object around the axis
2924 # @param theObject object which elements should be sweeped
2925 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2926 # @param AngleInRadians the angle of Rotation
2927 # @param NbOfSteps number of steps
2928 # @param Tolerance tolerance
2929 # @param MakeGroups forces the generation of new groups from existing ones
2930 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2931 # of all steps, else - size of each step
2932 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2933 # @ingroup l2_modif_extrurev
2934 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2935 MakeGroups=False, TotalAngle=False):
2937 if isinstance(AngleInRadians,str):
2939 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2941 AngleInRadians = DegreesToRadians(AngleInRadians)
2942 if ( isinstance( theObject, Mesh )):
2943 theObject = theObject.GetMesh()
2944 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2945 Axis = self.smeshpyD.GetAxisStruct(Axis)
2946 Axis,AxisParameters = ParseAxisStruct(Axis)
2947 if TotalAngle and NbOfSteps:
2948 AngleInRadians /= NbOfSteps
2949 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2950 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2951 self.mesh.SetParameters(Parameters)
2953 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2954 NbOfSteps, Tolerance)
2955 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2958 ## Generates new elements by rotation of the elements of object around the axis
2959 # @param theObject object which elements should be sweeped
2960 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2961 # @param AngleInRadians the angle of Rotation
2962 # @param NbOfSteps number of steps
2963 # @param Tolerance tolerance
2964 # @param MakeGroups forces the generation of new groups from existing ones
2965 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2966 # of all steps, else - size of each step
2967 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2968 # @ingroup l2_modif_extrurev
2969 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2970 MakeGroups=False, TotalAngle=False):
2972 if isinstance(AngleInRadians,str):
2974 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2976 AngleInRadians = DegreesToRadians(AngleInRadians)
2977 if ( isinstance( theObject, Mesh )):
2978 theObject = theObject.GetMesh()
2979 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2980 Axis = self.smeshpyD.GetAxisStruct(Axis)
2981 Axis,AxisParameters = ParseAxisStruct(Axis)
2982 if TotalAngle and NbOfSteps:
2983 AngleInRadians /= NbOfSteps
2984 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2985 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2986 self.mesh.SetParameters(Parameters)
2988 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2989 NbOfSteps, Tolerance)
2990 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2993 ## Generates new elements by extrusion of the elements with given ids
2994 # @param IDsOfElements the list of elements ids for extrusion
2995 # @param StepVector vector, defining the direction and value of extrusion
2996 # @param NbOfSteps the number of steps
2997 # @param MakeGroups forces the generation of new groups from existing ones
2998 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2999 # @ingroup l2_modif_extrurev
3000 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3001 if IDsOfElements == []:
3002 IDsOfElements = self.GetElementsId()
3003 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3004 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3005 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3006 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3007 Parameters = StepVectorParameters + var_separator + Parameters
3008 self.mesh.SetParameters(Parameters)
3010 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3011 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3014 ## Generates new elements by extrusion of the elements with given ids
3015 # @param IDsOfElements is ids of elements
3016 # @param StepVector vector, defining the direction and value of extrusion
3017 # @param NbOfSteps the number of steps
3018 # @param ExtrFlags sets flags for extrusion
3019 # @param SewTolerance uses for comparing locations of nodes if flag
3020 # EXTRUSION_FLAG_SEW is set
3021 # @param MakeGroups forces the generation of new groups from existing ones
3022 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3023 # @ingroup l2_modif_extrurev
3024 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3025 ExtrFlags, SewTolerance, MakeGroups=False):
3026 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3027 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3029 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3030 ExtrFlags, SewTolerance)
3031 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3032 ExtrFlags, SewTolerance)
3035 ## Generates new elements by extrusion of the elements which belong to the object
3036 # @param theObject the object which elements should be processed
3037 # @param StepVector vector, defining the direction and value of extrusion
3038 # @param NbOfSteps the number of steps
3039 # @param MakeGroups forces the generation of new groups from existing ones
3040 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3041 # @ingroup l2_modif_extrurev
3042 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3043 if ( isinstance( theObject, Mesh )):
3044 theObject = theObject.GetMesh()
3045 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3046 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3047 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3048 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3049 Parameters = StepVectorParameters + var_separator + Parameters
3050 self.mesh.SetParameters(Parameters)
3052 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3053 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3056 ## Generates new elements by extrusion of the elements which belong to the object
3057 # @param theObject object which elements should be processed
3058 # @param StepVector vector, defining the direction and value of extrusion
3059 # @param NbOfSteps the number of steps
3060 # @param MakeGroups to generate new groups from existing ones
3061 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3062 # @ingroup l2_modif_extrurev
3063 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3064 if ( isinstance( theObject, Mesh )):
3065 theObject = theObject.GetMesh()
3066 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3067 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3068 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3069 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3070 Parameters = StepVectorParameters + var_separator + Parameters
3071 self.mesh.SetParameters(Parameters)
3073 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3074 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3077 ## Generates new elements by extrusion of the elements which belong to the object
3078 # @param theObject object which elements should be processed
3079 # @param StepVector vector, defining the direction and value of extrusion
3080 # @param NbOfSteps the number of steps
3081 # @param MakeGroups forces the generation of new groups from existing ones
3082 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3083 # @ingroup l2_modif_extrurev
3084 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3085 if ( isinstance( theObject, Mesh )):
3086 theObject = theObject.GetMesh()
3087 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3088 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3089 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3090 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3091 Parameters = StepVectorParameters + var_separator + Parameters
3092 self.mesh.SetParameters(Parameters)
3094 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3095 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3100 ## Generates new elements by extrusion of the given elements
3101 # The path of extrusion must be a meshed edge.
3102 # @param Base mesh or list of ids of elements for extrusion
3103 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3104 # @param NodeStart the start node from Path. Defines the direction of extrusion
3105 # @param HasAngles allows the shape to be rotated around the path
3106 # to get the resulting mesh in a helical fashion
3107 # @param Angles list of angles in radians
3108 # @param LinearVariation forces the computation of rotation angles as linear
3109 # variation of the given Angles along path steps
3110 # @param HasRefPoint allows using the reference point
3111 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3112 # The User can specify any point as the Reference Point.
3113 # @param MakeGroups forces the generation of new groups from existing ones
3114 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3115 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3116 # only SMESH::Extrusion_Error otherwise
3117 # @ingroup l2_modif_extrurev
3118 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3119 HasAngles, Angles, LinearVariation,
3120 HasRefPoint, RefPoint, MakeGroups, ElemType):
3121 Angles,AnglesParameters = ParseAngles(Angles)
3122 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3123 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3124 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3126 Parameters = AnglesParameters + var_separator + RefPointParameters
3127 self.mesh.SetParameters(Parameters)
3129 if isinstance(Base,list):
3131 if Base == []: IDsOfElements = self.GetElementsId()
3132 else: IDsOfElements = Base
3133 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3134 HasAngles, Angles, LinearVariation,
3135 HasRefPoint, RefPoint, MakeGroups, ElemType)
3137 if isinstance(Base,Mesh):
3138 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3139 HasAngles, Angles, LinearVariation,
3140 HasRefPoint, RefPoint, MakeGroups, ElemType)
3142 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3145 ## Generates new elements by extrusion of the given elements
3146 # The path of extrusion must be a meshed edge.
3147 # @param IDsOfElements ids of elements
3148 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3149 # @param PathShape shape(edge) defines the sub-mesh for the path
3150 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3151 # @param HasAngles allows the shape to be rotated around the path
3152 # to get the resulting mesh in a helical fashion
3153 # @param Angles list of angles in radians
3154 # @param HasRefPoint allows using the reference point
3155 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3156 # The User can specify any point as the Reference Point.
3157 # @param MakeGroups forces the generation of new groups from existing ones
3158 # @param LinearVariation forces the computation of rotation angles as linear
3159 # variation of the given Angles along path steps
3160 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3161 # only SMESH::Extrusion_Error otherwise
3162 # @ingroup l2_modif_extrurev
3163 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3164 HasAngles, Angles, HasRefPoint, RefPoint,
3165 MakeGroups=False, LinearVariation=False):
3166 Angles,AnglesParameters = ParseAngles(Angles)
3167 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3168 if IDsOfElements == []:
3169 IDsOfElements = self.GetElementsId()
3170 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3171 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3173 if ( isinstance( PathMesh, Mesh )):
3174 PathMesh = PathMesh.GetMesh()
3175 if HasAngles and Angles and LinearVariation:
3176 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3178 Parameters = AnglesParameters + var_separator + RefPointParameters
3179 self.mesh.SetParameters(Parameters)
3181 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3182 PathShape, NodeStart, HasAngles,
3183 Angles, HasRefPoint, RefPoint)
3184 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3185 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3187 ## Generates new elements by extrusion of the elements which belong to the object
3188 # The path of extrusion must be a meshed edge.
3189 # @param theObject the object which elements should be processed
3190 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3191 # @param PathShape shape(edge) defines the sub-mesh for the path
3192 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3193 # @param HasAngles allows the shape to be rotated around the path
3194 # to get the resulting mesh in a helical fashion
3195 # @param Angles list of angles
3196 # @param HasRefPoint allows using the reference point
3197 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3198 # The User can specify any point as the Reference Point.
3199 # @param MakeGroups forces the generation of new groups from existing ones
3200 # @param LinearVariation forces the computation of rotation angles as linear
3201 # variation of the given Angles along path steps
3202 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3203 # only SMESH::Extrusion_Error otherwise
3204 # @ingroup l2_modif_extrurev
3205 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3206 HasAngles, Angles, HasRefPoint, RefPoint,
3207 MakeGroups=False, LinearVariation=False):
3208 Angles,AnglesParameters = ParseAngles(Angles)
3209 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3210 if ( isinstance( theObject, Mesh )):
3211 theObject = theObject.GetMesh()
3212 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3213 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3214 if ( isinstance( PathMesh, Mesh )):
3215 PathMesh = PathMesh.GetMesh()
3216 if HasAngles and Angles and LinearVariation:
3217 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3219 Parameters = AnglesParameters + var_separator + RefPointParameters
3220 self.mesh.SetParameters(Parameters)
3222 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3223 PathShape, NodeStart, HasAngles,
3224 Angles, HasRefPoint, RefPoint)
3225 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3226 NodeStart, HasAngles, Angles, HasRefPoint,
3229 ## Generates new elements by extrusion of the elements which belong to the object
3230 # The path of extrusion must be a meshed edge.
3231 # @param theObject the object which elements should be processed
3232 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3233 # @param PathShape shape(edge) defines the sub-mesh for the path
3234 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3235 # @param HasAngles allows the shape to be rotated around the path
3236 # to get the resulting mesh in a helical fashion
3237 # @param Angles list of angles
3238 # @param HasRefPoint allows using the reference point
3239 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3240 # The User can specify any point as the Reference Point.
3241 # @param MakeGroups forces the generation of new groups from existing ones
3242 # @param LinearVariation forces the computation of rotation angles as linear
3243 # variation of the given Angles along path steps
3244 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3245 # only SMESH::Extrusion_Error otherwise
3246 # @ingroup l2_modif_extrurev
3247 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3248 HasAngles, Angles, HasRefPoint, RefPoint,
3249 MakeGroups=False, LinearVariation=False):
3250 Angles,AnglesParameters = ParseAngles(Angles)
3251 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3252 if ( isinstance( theObject, Mesh )):
3253 theObject = theObject.GetMesh()
3254 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3255 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3256 if ( isinstance( PathMesh, Mesh )):
3257 PathMesh = PathMesh.GetMesh()
3258 if HasAngles and Angles and LinearVariation:
3259 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3261 Parameters = AnglesParameters + var_separator + RefPointParameters
3262 self.mesh.SetParameters(Parameters)
3264 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3265 PathShape, NodeStart, HasAngles,
3266 Angles, HasRefPoint, RefPoint)
3267 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3268 NodeStart, HasAngles, Angles, HasRefPoint,
3271 ## Generates new elements by extrusion of the elements which belong to the object
3272 # The path of extrusion must be a meshed edge.
3273 # @param theObject the object which elements should be processed
3274 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3275 # @param PathShape shape(edge) defines the sub-mesh for the path
3276 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3277 # @param HasAngles allows the shape to be rotated around the path
3278 # to get the resulting mesh in a helical fashion
3279 # @param Angles list of angles
3280 # @param HasRefPoint allows using the reference point
3281 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3282 # The User can specify any point as the Reference Point.
3283 # @param MakeGroups forces the generation of new groups from existing ones
3284 # @param LinearVariation forces the computation of rotation angles as linear
3285 # variation of the given Angles along path steps
3286 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3287 # only SMESH::Extrusion_Error otherwise
3288 # @ingroup l2_modif_extrurev
3289 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3290 HasAngles, Angles, HasRefPoint, RefPoint,
3291 MakeGroups=False, LinearVariation=False):
3292 Angles,AnglesParameters = ParseAngles(Angles)
3293 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3294 if ( isinstance( theObject, Mesh )):
3295 theObject = theObject.GetMesh()
3296 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3297 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3298 if ( isinstance( PathMesh, Mesh )):
3299 PathMesh = PathMesh.GetMesh()
3300 if HasAngles and Angles and LinearVariation:
3301 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3303 Parameters = AnglesParameters + var_separator + RefPointParameters
3304 self.mesh.SetParameters(Parameters)
3306 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3307 PathShape, NodeStart, HasAngles,
3308 Angles, HasRefPoint, RefPoint)
3309 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3310 NodeStart, HasAngles, Angles, HasRefPoint,
3313 ## Creates a symmetrical copy of mesh elements
3314 # @param IDsOfElements list of elements ids
3315 # @param Mirror is AxisStruct or geom object(point, line, plane)
3316 # @param theMirrorType is POINT, AXIS or PLANE
3317 # If the Mirror is a geom object this parameter is unnecessary
3318 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3319 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3320 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3321 # @ingroup l2_modif_trsf
3322 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3323 if IDsOfElements == []:
3324 IDsOfElements = self.GetElementsId()
3325 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3326 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3327 Mirror,Parameters = ParseAxisStruct(Mirror)
3328 self.mesh.SetParameters(Parameters)
3329 if Copy and MakeGroups:
3330 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3331 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3334 ## Creates a new mesh by a symmetrical copy of mesh elements
3335 # @param IDsOfElements the list of elements ids
3336 # @param Mirror is AxisStruct or geom object (point, line, plane)
3337 # @param theMirrorType is POINT, AXIS or PLANE
3338 # If the Mirror is a geom object this parameter is unnecessary
3339 # @param MakeGroups to generate new groups from existing ones
3340 # @param NewMeshName a name of the new mesh to create
3341 # @return instance of Mesh class
3342 # @ingroup l2_modif_trsf
3343 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3344 if IDsOfElements == []:
3345 IDsOfElements = self.GetElementsId()
3346 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3347 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3348 Mirror,Parameters = ParseAxisStruct(Mirror)
3349 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3350 MakeGroups, NewMeshName)
3351 mesh.SetParameters(Parameters)
3352 return Mesh(self.smeshpyD,self.geompyD,mesh)
3354 ## Creates a symmetrical copy of the object
3355 # @param theObject mesh, submesh or group
3356 # @param Mirror AxisStruct or geom object (point, line, plane)
3357 # @param theMirrorType is POINT, AXIS or PLANE
3358 # If the Mirror is a geom object this parameter is unnecessary
3359 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3360 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3361 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3362 # @ingroup l2_modif_trsf
3363 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3364 if ( isinstance( theObject, Mesh )):
3365 theObject = theObject.GetMesh()
3366 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3367 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3368 Mirror,Parameters = ParseAxisStruct(Mirror)
3369 self.mesh.SetParameters(Parameters)
3370 if Copy and MakeGroups:
3371 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3372 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3375 ## Creates a new mesh by a symmetrical copy of the object
3376 # @param theObject mesh, submesh or group
3377 # @param Mirror AxisStruct or geom object (point, line, plane)
3378 # @param theMirrorType POINT, AXIS or PLANE
3379 # If the Mirror is a geom object this parameter is unnecessary
3380 # @param MakeGroups forces the generation of new groups from existing ones
3381 # @param NewMeshName the name of the new mesh to create
3382 # @return instance of Mesh class
3383 # @ingroup l2_modif_trsf
3384 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3385 if ( isinstance( theObject, Mesh )):
3386 theObject = theObject.GetMesh()
3387 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3388 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3389 Mirror,Parameters = ParseAxisStruct(Mirror)
3390 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3391 MakeGroups, NewMeshName)
3392 mesh.SetParameters(Parameters)
3393 return Mesh( self.smeshpyD,self.geompyD,mesh )
3395 ## Translates the elements
3396 # @param IDsOfElements list of elements ids
3397 # @param Vector the direction of translation (DirStruct or vector)
3398 # @param Copy allows copying the translated elements
3399 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3400 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3401 # @ingroup l2_modif_trsf
3402 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3403 if IDsOfElements == []:
3404 IDsOfElements = self.GetElementsId()
3405 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3406 Vector = self.smeshpyD.GetDirStruct(Vector)
3407 Vector,Parameters = ParseDirStruct(Vector)
3408 self.mesh.SetParameters(Parameters)
3409 if Copy and MakeGroups:
3410 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3411 self.editor.Translate(IDsOfElements, Vector, Copy)
3414 ## Creates a new mesh of translated elements
3415 # @param IDsOfElements list of elements ids
3416 # @param Vector the direction of translation (DirStruct or vector)
3417 # @param MakeGroups forces the generation of new groups from existing ones
3418 # @param NewMeshName the name of the newly created mesh
3419 # @return instance of Mesh class
3420 # @ingroup l2_modif_trsf
3421 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3422 if IDsOfElements == []:
3423 IDsOfElements = self.GetElementsId()
3424 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3425 Vector = self.smeshpyD.GetDirStruct(Vector)
3426 Vector,Parameters = ParseDirStruct(Vector)
3427 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3428 mesh.SetParameters(Parameters)
3429 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3431 ## Translates the object
3432 # @param theObject the object to translate (mesh, submesh, or group)
3433 # @param Vector direction of translation (DirStruct or geom vector)
3434 # @param Copy allows copying the translated elements
3435 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3436 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3437 # @ingroup l2_modif_trsf
3438 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3439 if ( isinstance( theObject, Mesh )):
3440 theObject = theObject.GetMesh()
3441 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3442 Vector = self.smeshpyD.GetDirStruct(Vector)
3443 Vector,Parameters = ParseDirStruct(Vector)
3444 self.mesh.SetParameters(Parameters)
3445 if Copy and MakeGroups:
3446 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3447 self.editor.TranslateObject(theObject, Vector, Copy)
3450 ## Creates a new mesh from the translated object
3451 # @param theObject the object to translate (mesh, submesh, or group)
3452 # @param Vector the direction of translation (DirStruct or geom vector)
3453 # @param MakeGroups forces the generation of new groups from existing ones
3454 # @param NewMeshName the name of the newly created mesh
3455 # @return instance of Mesh class
3456 # @ingroup l2_modif_trsf
3457 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3458 if (isinstance(theObject, Mesh)):
3459 theObject = theObject.GetMesh()
3460 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3461 Vector = self.smeshpyD.GetDirStruct(Vector)
3462 Vector,Parameters = ParseDirStruct(Vector)
3463 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3464 mesh.SetParameters(Parameters)
3465 return Mesh( self.smeshpyD, self.geompyD, mesh )
3469 ## Scales the object
3470 # @param theObject - the object to translate (mesh, submesh, or group)
3471 # @param thePoint - base point for scale
3472 # @param theScaleFact - list of 1-3 scale factors for axises
3473 # @param Copy - allows copying the translated elements
3474 # @param MakeGroups - forces the generation of new groups from existing
3476 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3477 # empty list otherwise
3478 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3479 if ( isinstance( theObject, Mesh )):
3480 theObject = theObject.GetMesh()
3481 if ( isinstance( theObject, list )):
3482 theObject = self.editor.MakeIDSource(theObject, SMESH.ALL)
3484 thePoint, Parameters = ParsePointStruct(thePoint)
3485 self.mesh.SetParameters(Parameters)
3487 if Copy and MakeGroups:
3488 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3489 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3492 ## Creates a new mesh from the translated object
3493 # @param theObject - the object to translate (mesh, submesh, or group)
3494 # @param thePoint - base point for scale
3495 # @param theScaleFact - list of 1-3 scale factors for axises
3496 # @param MakeGroups - forces the generation of new groups from existing ones
3497 # @param NewMeshName - the name of the newly created mesh
3498 # @return instance of Mesh class
3499 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3500 if (isinstance(theObject, Mesh)):
3501 theObject = theObject.GetMesh()
3502 if ( isinstance( theObject, list )):
3503 theObject = self.editor.MakeIDSource(theObject,SMESH.ALL)
3505 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3506 MakeGroups, NewMeshName)
3507 #mesh.SetParameters(Parameters)
3508 return Mesh( self.smeshpyD, self.geompyD, mesh )
3512 ## Rotates the elements
3513 # @param IDsOfElements list of elements ids
3514 # @param Axis the axis of rotation (AxisStruct or geom line)
3515 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3516 # @param Copy allows copying the rotated elements
3517 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3518 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3519 # @ingroup l2_modif_trsf
3520 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3522 if isinstance(AngleInRadians,str):
3524 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3526 AngleInRadians = DegreesToRadians(AngleInRadians)
3527 if IDsOfElements == []:
3528 IDsOfElements = self.GetElementsId()
3529 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3530 Axis = self.smeshpyD.GetAxisStruct(Axis)
3531 Axis,AxisParameters = ParseAxisStruct(Axis)
3532 Parameters = AxisParameters + var_separator + Parameters
3533 self.mesh.SetParameters(Parameters)
3534 if Copy and MakeGroups:
3535 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3536 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3539 ## Creates a new mesh of rotated elements
3540 # @param IDsOfElements list of element ids
3541 # @param Axis the axis of rotation (AxisStruct or geom line)
3542 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3543 # @param MakeGroups forces the generation of new groups from existing ones
3544 # @param NewMeshName the name of the newly created mesh
3545 # @return instance of Mesh class
3546 # @ingroup l2_modif_trsf
3547 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3549 if isinstance(AngleInRadians,str):
3551 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3553 AngleInRadians = DegreesToRadians(AngleInRadians)
3554 if IDsOfElements == []:
3555 IDsOfElements = self.GetElementsId()
3556 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3557 Axis = self.smeshpyD.GetAxisStruct(Axis)
3558 Axis,AxisParameters = ParseAxisStruct(Axis)
3559 Parameters = AxisParameters + var_separator + Parameters
3560 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3561 MakeGroups, NewMeshName)
3562 mesh.SetParameters(Parameters)
3563 return Mesh( self.smeshpyD, self.geompyD, mesh )
3565 ## Rotates the object
3566 # @param theObject the object to rotate( mesh, submesh, or group)
3567 # @param Axis the axis of rotation (AxisStruct or geom line)
3568 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3569 # @param Copy allows copying the rotated elements
3570 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3571 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3572 # @ingroup l2_modif_trsf
3573 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3575 if isinstance(AngleInRadians,str):
3577 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3579 AngleInRadians = DegreesToRadians(AngleInRadians)
3580 if (isinstance(theObject, Mesh)):
3581 theObject = theObject.GetMesh()
3582 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3583 Axis = self.smeshpyD.GetAxisStruct(Axis)
3584 Axis,AxisParameters = ParseAxisStruct(Axis)
3585 Parameters = AxisParameters + ":" + Parameters
3586 self.mesh.SetParameters(Parameters)
3587 if Copy and MakeGroups:
3588 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3589 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3592 ## Creates a new mesh from the rotated object
3593 # @param theObject the object to rotate (mesh, submesh, or group)
3594 # @param Axis the axis of rotation (AxisStruct or geom line)
3595 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3596 # @param MakeGroups forces the generation of new groups from existing ones
3597 # @param NewMeshName the name of the newly created mesh
3598 # @return instance of Mesh class
3599 # @ingroup l2_modif_trsf
3600 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3602 if isinstance(AngleInRadians,str):
3604 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3606 AngleInRadians = DegreesToRadians(AngleInRadians)
3607 if (isinstance( theObject, Mesh )):
3608 theObject = theObject.GetMesh()
3609 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3610 Axis = self.smeshpyD.GetAxisStruct(Axis)
3611 Axis,AxisParameters = ParseAxisStruct(Axis)
3612 Parameters = AxisParameters + ":" + Parameters
3613 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3614 MakeGroups, NewMeshName)
3615 mesh.SetParameters(Parameters)
3616 return Mesh( self.smeshpyD, self.geompyD, mesh )
3618 ## Finds groups of ajacent nodes within Tolerance.
3619 # @param Tolerance the value of tolerance
3620 # @return the list of groups of nodes
3621 # @ingroup l2_modif_trsf
3622 def FindCoincidentNodes (self, Tolerance):
3623 return self.editor.FindCoincidentNodes(Tolerance)
3625 ## Finds groups of ajacent nodes within Tolerance.
3626 # @param Tolerance the value of tolerance
3627 # @param SubMeshOrGroup SubMesh or Group
3628 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3629 # @return the list of groups of nodes
3630 # @ingroup l2_modif_trsf
3631 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3632 if (isinstance( SubMeshOrGroup, Mesh )):
3633 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3634 if not isinstance( exceptNodes, list):
3635 exceptNodes = [ exceptNodes ]
3636 if exceptNodes and isinstance( exceptNodes[0], int):
3637 exceptNodes = [ self.editor.MakeIDSource( exceptNodes, SMESH.NODE)]
3638 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3641 # @param GroupsOfNodes the list of groups of nodes
3642 # @ingroup l2_modif_trsf
3643 def MergeNodes (self, GroupsOfNodes):
3644 self.editor.MergeNodes(GroupsOfNodes)
3646 ## Finds the elements built on the same nodes.
3647 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3648 # @return a list of groups of equal elements
3649 # @ingroup l2_modif_trsf
3650 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3651 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3652 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3653 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3655 ## Merges elements in each given group.
3656 # @param GroupsOfElementsID groups of elements for merging
3657 # @ingroup l2_modif_trsf
3658 def MergeElements(self, GroupsOfElementsID):
3659 self.editor.MergeElements(GroupsOfElementsID)
3661 ## Leaves one element and removes all other elements built on the same nodes.
3662 # @ingroup l2_modif_trsf
3663 def MergeEqualElements(self):
3664 self.editor.MergeEqualElements()
3666 ## Sews free borders
3667 # @return SMESH::Sew_Error
3668 # @ingroup l2_modif_trsf
3669 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3670 FirstNodeID2, SecondNodeID2, LastNodeID2,
3671 CreatePolygons, CreatePolyedrs):
3672 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3673 FirstNodeID2, SecondNodeID2, LastNodeID2,
3674 CreatePolygons, CreatePolyedrs)
3676 ## Sews conform free borders
3677 # @return SMESH::Sew_Error
3678 # @ingroup l2_modif_trsf
3679 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3680 FirstNodeID2, SecondNodeID2):
3681 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3682 FirstNodeID2, SecondNodeID2)
3684 ## Sews border to side
3685 # @return SMESH::Sew_Error
3686 # @ingroup l2_modif_trsf
3687 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3688 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3689 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3690 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3692 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3693 # merged with the nodes of elements of Side2.
3694 # The number of elements in theSide1 and in theSide2 must be
3695 # equal and they should have similar nodal connectivity.
3696 # The nodes to merge should belong to side borders and
3697 # the first node should be linked to the second.
3698 # @return SMESH::Sew_Error
3699 # @ingroup l2_modif_trsf
3700 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3701 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3702 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3703 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3704 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3705 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3707 ## Sets new nodes for the given element.
3708 # @param ide the element id
3709 # @param newIDs nodes ids
3710 # @return If the number of nodes does not correspond to the type of element - returns false
3711 # @ingroup l2_modif_edit
3712 def ChangeElemNodes(self, ide, newIDs):
3713 return self.editor.ChangeElemNodes(ide, newIDs)
3715 ## If during the last operation of MeshEditor some nodes were
3716 # created, this method returns the list of their IDs, \n
3717 # if new nodes were not created - returns empty list
3718 # @return the list of integer values (can be empty)
3719 # @ingroup l1_auxiliary
3720 def GetLastCreatedNodes(self):
3721 return self.editor.GetLastCreatedNodes()
3723 ## If during the last operation of MeshEditor some elements were
3724 # created this method returns the list of their IDs, \n
3725 # if new elements were not created - returns empty list
3726 # @return the list of integer values (can be empty)
3727 # @ingroup l1_auxiliary
3728 def GetLastCreatedElems(self):
3729 return self.editor.GetLastCreatedElems()
3731 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3732 # @param theNodes identifiers of nodes to be doubled
3733 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3734 # nodes. If list of element identifiers is empty then nodes are doubled but
3735 # they not assigned to elements
3736 # @return TRUE if operation has been completed successfully, FALSE otherwise
3737 # @ingroup l2_modif_edit
3738 def DoubleNodes(self, theNodes, theModifiedElems):
3739 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3741 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3742 # This method provided for convenience works as DoubleNodes() described above.
3743 # @param theNodeId identifiers of node to be doubled
3744 # @param theModifiedElems identifiers of elements to be updated
3745 # @return TRUE if operation has been completed successfully, FALSE otherwise
3746 # @ingroup l2_modif_edit
3747 def DoubleNode(self, theNodeId, theModifiedElems):
3748 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3750 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3751 # This method provided for convenience works as DoubleNodes() described above.
3752 # @param theNodes group of nodes to be doubled
3753 # @param theModifiedElems group of elements to be updated.
3754 # @param theMakeGroup forces the generation of a group containing new nodes.
3755 # @return TRUE or a created group if operation has been completed successfully,
3756 # FALSE or None otherwise
3757 # @ingroup l2_modif_edit
3758 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
3760 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
3761 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3763 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3764 # This method provided for convenience works as DoubleNodes() described above.
3765 # @param theNodes list of groups of nodes to be doubled
3766 # @param theModifiedElems list of groups of elements to be updated.
3767 # @return TRUE if operation has been completed successfully, FALSE otherwise
3768 # @ingroup l2_modif_edit
3769 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3770 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3772 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3773 # @param theElems - the list of elements (edges or faces) to be replicated
3774 # The nodes for duplication could be found from these elements
3775 # @param theNodesNot - list of nodes to NOT replicate
3776 # @param theAffectedElems - the list of elements (cells and edges) to which the
3777 # replicated nodes should be associated to.
3778 # @return TRUE if operation has been completed successfully, FALSE otherwise
3779 # @ingroup l2_modif_edit
3780 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3781 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3783 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3784 # @param theElems - the list of elements (edges or faces) to be replicated
3785 # The nodes for duplication could be found from these elements
3786 # @param theNodesNot - list of nodes to NOT replicate
3787 # @param theShape - shape to detect affected elements (element which geometric center
3788 # located on or inside shape).
3789 # The replicated nodes should be associated to affected elements.
3790 # @return TRUE if operation has been completed successfully, FALSE otherwise
3791 # @ingroup l2_modif_edit
3792 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3793 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3795 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3796 # This method provided for convenience works as DoubleNodes() described above.
3797 # @param theElems - group of of elements (edges or faces) to be replicated
3798 # @param theNodesNot - group of nodes not to replicated
3799 # @param theAffectedElems - group of elements to which the replicated nodes
3800 # should be associated to.
3801 # @param theMakeGroup forces the generation of a group containing new elements.
3802 # @ingroup l2_modif_edit
3803 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
3805 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
3806 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3808 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3809 # This method provided for convenience works as DoubleNodes() described above.
3810 # @param theElems - group of of elements (edges or faces) to be replicated
3811 # @param theNodesNot - group of nodes not to replicated
3812 # @param theShape - shape to detect affected elements (element which geometric center
3813 # located on or inside shape).
3814 # The replicated nodes should be associated to affected elements.
3815 # @ingroup l2_modif_edit
3816 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3817 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3819 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3820 # This method provided for convenience works as DoubleNodes() described above.
3821 # @param theElems - list of groups of elements (edges or faces) to be replicated
3822 # @param theNodesNot - list of groups of nodes not to replicated
3823 # @param theAffectedElems - group of elements to which the replicated nodes
3824 # should be associated to.
3825 # @return TRUE if operation has been completed successfully, FALSE otherwise
3826 # @ingroup l2_modif_edit
3827 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3828 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3830 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3831 # This method provided for convenience works as DoubleNodes() described above.
3832 # @param theElems - list of groups of elements (edges or faces) to be replicated
3833 # @param theNodesNot - list of groups of nodes not to replicated
3834 # @param theShape - shape to detect affected elements (element which geometric center
3835 # located on or inside shape).
3836 # The replicated nodes should be associated to affected elements.
3837 # @return TRUE if operation has been completed successfully, FALSE otherwise
3838 # @ingroup l2_modif_edit
3839 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3840 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3842 ## The mother class to define algorithm, it is not recommended to use it directly.
3845 # @ingroup l2_algorithms
3846 class Mesh_Algorithm:
3847 # @class Mesh_Algorithm
3848 # @brief Class Mesh_Algorithm
3850 #def __init__(self,smesh):
3858 ## Finds a hypothesis in the study by its type name and parameters.
3859 # Finds only the hypotheses created in smeshpyD engine.
3860 # @return SMESH.SMESH_Hypothesis
3861 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3862 study = smeshpyD.GetCurrentStudy()
3863 #to do: find component by smeshpyD object, not by its data type
3864 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3865 if scomp is not None:
3866 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3867 # Check if the root label of the hypotheses exists
3868 if res and hypRoot is not None:
3869 iter = study.NewChildIterator(hypRoot)
3870 # Check all published hypotheses
3872 hypo_so_i = iter.Value()
3873 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3874 if attr is not None:
3875 anIOR = attr.Value()
3876 hypo_o_i = salome.orb.string_to_object(anIOR)
3877 if hypo_o_i is not None:
3878 # Check if this is a hypothesis
3879 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3880 if hypo_i is not None:
3881 # Check if the hypothesis belongs to current engine
3882 if smeshpyD.GetObjectId(hypo_i) > 0:
3883 # Check if this is the required hypothesis
3884 if hypo_i.GetName() == hypname:
3886 if CompareMethod(hypo_i, args):
3900 ## Finds the algorithm in the study by its type name.
3901 # Finds only the algorithms, which have been created in smeshpyD engine.
3902 # @return SMESH.SMESH_Algo
3903 def FindAlgorithm (self, algoname, smeshpyD):
3904 study = smeshpyD.GetCurrentStudy()
3905 #to do: find component by smeshpyD object, not by its data type
3906 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3907 if scomp is not None:
3908 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3909 # Check if the root label of the algorithms exists
3910 if res and hypRoot is not None:
3911 iter = study.NewChildIterator(hypRoot)
3912 # Check all published algorithms
3914 algo_so_i = iter.Value()
3915 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3916 if attr is not None:
3917 anIOR = attr.Value()
3918 algo_o_i = salome.orb.string_to_object(anIOR)
3919 if algo_o_i is not None:
3920 # Check if this is an algorithm
3921 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3922 if algo_i is not None:
3923 # Checks if the algorithm belongs to the current engine
3924 if smeshpyD.GetObjectId(algo_i) > 0:
3925 # Check if this is the required algorithm
3926 if algo_i.GetName() == algoname:
3939 ## If the algorithm is global, returns 0; \n
3940 # else returns the submesh associated to this algorithm.
3941 def GetSubMesh(self):
3944 ## Returns the wrapped mesher.
3945 def GetAlgorithm(self):
3948 ## Gets the list of hypothesis that can be used with this algorithm
3949 def GetCompatibleHypothesis(self):
3952 mylist = self.algo.GetCompatibleHypothesis()
3955 ## Gets the name of the algorithm
3959 ## Sets the name to the algorithm
3960 def SetName(self, name):
3961 self.mesh.smeshpyD.SetName(self.algo, name)
3963 ## Gets the id of the algorithm
3965 return self.algo.GetId()
3968 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3970 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3971 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3973 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3975 self.Assign(algo, mesh, geom)
3979 def Assign(self, algo, mesh, geom):
3981 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3990 name = GetName(geom)
3993 name = mesh.geompyD.SubShapeName(geom, piece)
3994 mesh.geompyD.addToStudyInFather(piece, geom, name)
3996 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3999 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4000 TreatHypoStatus( status, algo.GetName(), name, True )
4002 def CompareHyp (self, hyp, args):
4003 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4006 def CompareEqualHyp (self, hyp, args):
4010 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4011 UseExisting=0, CompareMethod=""):
4014 if CompareMethod == "": CompareMethod = self.CompareHyp
4015 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4018 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4024 a = a + s + str(args[i])
4028 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4030 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4031 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
4034 ## Returns entry of the shape to mesh in the study
4035 def MainShapeEntry(self):
4037 if not self.mesh or not self.mesh.GetMesh(): return entry
4038 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4039 study = self.mesh.smeshpyD.GetCurrentStudy()
4040 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4041 sobj = study.FindObjectIOR(ior)
4042 if sobj: entry = sobj.GetID()
4043 if not entry: return ""
4046 # Public class: Mesh_Segment
4047 # --------------------------
4049 ## Class to define a segment 1D algorithm for discretization
4052 # @ingroup l3_algos_basic
4053 class Mesh_Segment(Mesh_Algorithm):
4055 ## Private constructor.
4056 def __init__(self, mesh, geom=0):
4057 Mesh_Algorithm.__init__(self)
4058 self.Create(mesh, geom, "Regular_1D")
4060 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4061 # @param l for the length of segments that cut an edge
4062 # @param UseExisting if ==true - searches for an existing hypothesis created with
4063 # the same parameters, else (default) - creates a new one
4064 # @param p precision, used for calculation of the number of segments.
4065 # The precision should be a positive, meaningful value within the range [0,1].
4066 # In general, the number of segments is calculated with the formula:
4067 # nb = ceil((edge_length / l) - p)
4068 # Function ceil rounds its argument to the higher integer.
4069 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4070 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4071 # p=1 means rounding of (edge_length / l) to the lower integer.
4072 # Default value is 1e-07.
4073 # @return an instance of StdMeshers_LocalLength hypothesis
4074 # @ingroup l3_hypos_1dhyps
4075 def LocalLength(self, l, UseExisting=0, p=1e-07):
4076 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4077 CompareMethod=self.CompareLocalLength)
4083 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4084 def CompareLocalLength(self, hyp, args):
4085 if IsEqual(hyp.GetLength(), args[0]):
4086 return IsEqual(hyp.GetPrecision(), args[1])
4089 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4090 # @param length is optional maximal allowed length of segment, if it is omitted
4091 # the preestimated length is used that depends on geometry size
4092 # @param UseExisting if ==true - searches for an existing hypothesis created with
4093 # the same parameters, else (default) - create a new one
4094 # @return an instance of StdMeshers_MaxLength hypothesis
4095 # @ingroup l3_hypos_1dhyps
4096 def MaxSize(self, length=0.0, UseExisting=0):
4097 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4100 hyp.SetLength(length)
4102 # set preestimated length
4103 gen = self.mesh.smeshpyD
4104 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4105 self.mesh.GetMesh(), self.mesh.GetShape(),
4107 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4109 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4112 hyp.SetUsePreestimatedLength( length == 0.0 )
4115 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4116 # @param n for the number of segments that cut an edge
4117 # @param s for the scale factor (optional)
4118 # @param reversedEdges is a list of edges to mesh using reversed orientation
4119 # @param UseExisting if ==true - searches for an existing hypothesis created with
4120 # the same parameters, else (default) - create a new one
4121 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4122 # @ingroup l3_hypos_1dhyps
4123 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4124 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4125 reversedEdges, UseExisting = [], reversedEdges
4126 entry = self.MainShapeEntry()
4128 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4129 UseExisting=UseExisting,
4130 CompareMethod=self.CompareNumberOfSegments)
4132 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4133 UseExisting=UseExisting,
4134 CompareMethod=self.CompareNumberOfSegments)
4135 hyp.SetDistrType( 1 )
4136 hyp.SetScaleFactor(s)
4137 hyp.SetNumberOfSegments(n)
4138 hyp.SetReversedEdges( reversedEdges )
4139 hyp.SetObjectEntry( entry )
4143 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4144 def CompareNumberOfSegments(self, hyp, args):
4145 if hyp.GetNumberOfSegments() == args[0]:
4147 if hyp.GetReversedEdges() == args[1]:
4148 if not args[1] or hyp.GetObjectEntry() == args[2]:
4151 if hyp.GetReversedEdges() == args[2]:
4152 if not args[2] or hyp.GetObjectEntry() == args[3]:
4153 if hyp.GetDistrType() == 1:
4154 if IsEqual(hyp.GetScaleFactor(), args[1]):
4158 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4159 # @param start defines the length of the first segment
4160 # @param end defines the length of the last segment
4161 # @param reversedEdges is a list of edges to mesh using reversed orientation
4162 # @param UseExisting if ==true - searches for an existing hypothesis created with
4163 # the same parameters, else (default) - creates a new one
4164 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4165 # @ingroup l3_hypos_1dhyps
4166 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4167 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4168 reversedEdges, UseExisting = [], reversedEdges
4169 entry = self.MainShapeEntry()
4170 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4171 UseExisting=UseExisting,
4172 CompareMethod=self.CompareArithmetic1D)
4173 hyp.SetStartLength(start)
4174 hyp.SetEndLength(end)
4175 hyp.SetReversedEdges( reversedEdges )
4176 hyp.SetObjectEntry( entry )
4180 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4181 def CompareArithmetic1D(self, hyp, args):
4182 if IsEqual(hyp.GetLength(1), args[0]):
4183 if IsEqual(hyp.GetLength(0), args[1]):
4184 if hyp.GetReversedEdges() == args[2]:
4185 if not args[2] or hyp.GetObjectEntry() == args[3]:
4190 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4191 # on curve from 0 to 1 (additionally it is neecessary to check
4192 # orientation of edges and create list of reversed edges if it is
4193 # needed) and sets numbers of segments between given points (default
4194 # values are equals 1
4195 # @param points defines the list of parameters on curve
4196 # @param nbSegs defines the list of numbers of segments
4197 # @param reversedEdges is a list of edges to mesh using reversed orientation
4198 # @param UseExisting if ==true - searches for an existing hypothesis created with
4199 # the same parameters, else (default) - creates a new one
4200 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4201 # @ingroup l3_hypos_1dhyps
4202 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4203 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4204 reversedEdges, UseExisting = [], reversedEdges
4205 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4206 for i in range( len( reversedEdges )):
4207 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4208 entry = self.MainShapeEntry()
4209 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4210 UseExisting=UseExisting,
4211 CompareMethod=self.CompareFixedPoints1D)
4212 hyp.SetPoints(points)
4213 hyp.SetNbSegments(nbSegs)
4214 hyp.SetReversedEdges(reversedEdges)
4215 hyp.SetObjectEntry(entry)
4219 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4220 ## as the given arguments
4221 def CompareFixedPoints1D(self, hyp, args):
4222 if hyp.GetPoints() == args[0]:
4223 if hyp.GetNbSegments() == args[1]:
4224 if hyp.GetReversedEdges() == args[2]:
4225 if not args[2] or hyp.GetObjectEntry() == args[3]:
4231 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4232 # @param start defines the length of the first segment
4233 # @param end defines the length of the last segment
4234 # @param reversedEdges is a list of edges to mesh using reversed orientation
4235 # @param UseExisting if ==true - searches for an existing hypothesis created with
4236 # the same parameters, else (default) - creates a new one
4237 # @return an instance of StdMeshers_StartEndLength hypothesis
4238 # @ingroup l3_hypos_1dhyps
4239 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4240 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4241 reversedEdges, UseExisting = [], reversedEdges
4242 entry = self.MainShapeEntry()
4243 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4244 UseExisting=UseExisting,
4245 CompareMethod=self.CompareStartEndLength)
4246 hyp.SetStartLength(start)
4247 hyp.SetEndLength(end)
4248 hyp.SetReversedEdges( reversedEdges )
4249 hyp.SetObjectEntry( entry )
4252 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4253 def CompareStartEndLength(self, hyp, args):
4254 if IsEqual(hyp.GetLength(1), args[0]):
4255 if IsEqual(hyp.GetLength(0), args[1]):
4256 if hyp.GetReversedEdges() == args[2]:
4257 if not args[2] or hyp.GetObjectEntry() == args[3]:
4261 ## Defines "Deflection1D" hypothesis
4262 # @param d for the deflection
4263 # @param UseExisting if ==true - searches for an existing hypothesis created with
4264 # the same parameters, else (default) - create a new one
4265 # @ingroup l3_hypos_1dhyps
4266 def Deflection1D(self, d, UseExisting=0):
4267 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4268 CompareMethod=self.CompareDeflection1D)
4269 hyp.SetDeflection(d)
4272 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4273 def CompareDeflection1D(self, hyp, args):
4274 return IsEqual(hyp.GetDeflection(), args[0])
4276 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4277 # the opposite side in case of quadrangular faces
4278 # @ingroup l3_hypos_additi
4279 def Propagation(self):
4280 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4282 ## Defines "AutomaticLength" hypothesis
4283 # @param fineness for the fineness [0-1]
4284 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4285 # same parameters, else (default) - create a new one
4286 # @ingroup l3_hypos_1dhyps
4287 def AutomaticLength(self, fineness=0, UseExisting=0):
4288 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4289 CompareMethod=self.CompareAutomaticLength)
4290 hyp.SetFineness( fineness )
4293 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4294 def CompareAutomaticLength(self, hyp, args):
4295 return IsEqual(hyp.GetFineness(), args[0])
4297 ## Defines "SegmentLengthAroundVertex" hypothesis
4298 # @param length for the segment length
4299 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4300 # Any other integer value means that the hypothesis will be set on the
4301 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4302 # @param UseExisting if ==true - searches for an existing hypothesis created with
4303 # the same parameters, else (default) - creates a new one
4304 # @ingroup l3_algos_segmarv
4305 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4307 store_geom = self.geom
4308 if type(vertex) is types.IntType:
4309 if vertex == 0 or vertex == 1:
4310 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4318 if self.geom is None:
4319 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4321 name = GetName(self.geom)
4324 piece = self.mesh.geom
4325 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4326 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4328 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4330 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4332 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4333 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4335 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4336 CompareMethod=self.CompareLengthNearVertex)
4337 self.geom = store_geom
4338 hyp.SetLength( length )
4341 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4342 # @ingroup l3_algos_segmarv
4343 def CompareLengthNearVertex(self, hyp, args):
4344 return IsEqual(hyp.GetLength(), args[0])
4346 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4347 # If the 2D mesher sees that all boundary edges are quadratic,
4348 # it generates quadratic faces, else it generates linear faces using
4349 # medium nodes as if they are vertices.
4350 # The 3D mesher generates quadratic volumes only if all boundary faces
4351 # are quadratic, else it fails.
4353 # @ingroup l3_hypos_additi
4354 def QuadraticMesh(self):
4355 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4358 # Public class: Mesh_CompositeSegment
4359 # --------------------------
4361 ## Defines a segment 1D algorithm for discretization
4363 # @ingroup l3_algos_basic
4364 class Mesh_CompositeSegment(Mesh_Segment):
4366 ## Private constructor.
4367 def __init__(self, mesh, geom=0):
4368 self.Create(mesh, geom, "CompositeSegment_1D")
4371 # Public class: Mesh_Segment_Python
4372 # ---------------------------------
4374 ## Defines a segment 1D algorithm for discretization with python function
4376 # @ingroup l3_algos_basic
4377 class Mesh_Segment_Python(Mesh_Segment):
4379 ## Private constructor.
4380 def __init__(self, mesh, geom=0):
4381 import Python1dPlugin
4382 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4384 ## Defines "PythonSplit1D" hypothesis
4385 # @param n for the number of segments that cut an edge
4386 # @param func for the python function that calculates the length of all segments
4387 # @param UseExisting if ==true - searches for the existing hypothesis created with
4388 # the same parameters, else (default) - creates a new one
4389 # @ingroup l3_hypos_1dhyps
4390 def PythonSplit1D(self, n, func, UseExisting=0):
4391 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4392 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4393 hyp.SetNumberOfSegments(n)
4394 hyp.SetPythonLog10RatioFunction(func)
4397 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4398 def ComparePythonSplit1D(self, hyp, args):
4399 #if hyp.GetNumberOfSegments() == args[0]:
4400 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4404 # Public class: Mesh_Triangle
4405 # ---------------------------
4407 ## Defines a triangle 2D algorithm
4409 # @ingroup l3_algos_basic
4410 class Mesh_Triangle(Mesh_Algorithm):
4419 ## Private constructor.
4420 def __init__(self, mesh, algoType, geom=0):
4421 Mesh_Algorithm.__init__(self)
4423 self.algoType = algoType
4424 if algoType == MEFISTO:
4425 self.Create(mesh, geom, "MEFISTO_2D")
4427 elif algoType == BLSURF:
4429 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4430 #self.SetPhysicalMesh() - PAL19680
4431 elif algoType == NETGEN:
4433 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4435 elif algoType == NETGEN_2D:
4437 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4440 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4441 # @param area for the maximum area of each triangle
4442 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4443 # same parameters, else (default) - creates a new one
4445 # Only for algoType == MEFISTO || NETGEN_2D
4446 # @ingroup l3_hypos_2dhyps
4447 def MaxElementArea(self, area, UseExisting=0):
4448 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4449 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4450 CompareMethod=self.CompareMaxElementArea)
4451 elif self.algoType == NETGEN:
4452 hyp = self.Parameters(SIMPLE)
4453 hyp.SetMaxElementArea(area)
4456 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4457 def CompareMaxElementArea(self, hyp, args):
4458 return IsEqual(hyp.GetMaxElementArea(), args[0])
4460 ## Defines "LengthFromEdges" hypothesis to build triangles
4461 # based on the length of the edges taken from the wire
4463 # Only for algoType == MEFISTO || NETGEN_2D
4464 # @ingroup l3_hypos_2dhyps
4465 def LengthFromEdges(self):
4466 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4467 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4469 elif self.algoType == NETGEN:
4470 hyp = self.Parameters(SIMPLE)
4471 hyp.LengthFromEdges()
4474 ## Sets a way to define size of mesh elements to generate.
4475 # @param thePhysicalMesh is: DefaultSize or Custom.
4476 # @ingroup l3_hypos_blsurf
4477 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4478 # Parameter of BLSURF algo
4479 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4481 ## Sets size of mesh elements to generate.
4482 # @ingroup l3_hypos_blsurf
4483 def SetPhySize(self, theVal):
4484 # Parameter of BLSURF algo
4485 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4486 self.Parameters().SetPhySize(theVal)
4488 ## Sets lower boundary of mesh element size (PhySize).
4489 # @ingroup l3_hypos_blsurf
4490 def SetPhyMin(self, theVal=-1):
4491 # Parameter of BLSURF algo
4492 self.Parameters().SetPhyMin(theVal)
4494 ## Sets upper boundary of mesh element size (PhySize).
4495 # @ingroup l3_hypos_blsurf
4496 def SetPhyMax(self, theVal=-1):
4497 # Parameter of BLSURF algo
4498 self.Parameters().SetPhyMax(theVal)
4500 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4501 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4502 # @ingroup l3_hypos_blsurf
4503 def SetGeometricMesh(self, theGeometricMesh=0):
4504 # Parameter of BLSURF algo
4505 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4506 self.params.SetGeometricMesh(theGeometricMesh)
4508 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4509 # @ingroup l3_hypos_blsurf
4510 def SetAngleMeshS(self, theVal=_angleMeshS):
4511 # Parameter of BLSURF algo
4512 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4513 self.params.SetAngleMeshS(theVal)
4515 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4516 # @ingroup l3_hypos_blsurf
4517 def SetAngleMeshC(self, theVal=_angleMeshS):
4518 # Parameter of BLSURF algo
4519 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4520 self.params.SetAngleMeshC(theVal)
4522 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4523 # @ingroup l3_hypos_blsurf
4524 def SetGeoMin(self, theVal=-1):
4525 # Parameter of BLSURF algo
4526 self.Parameters().SetGeoMin(theVal)
4528 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4529 # @ingroup l3_hypos_blsurf
4530 def SetGeoMax(self, theVal=-1):
4531 # Parameter of BLSURF algo
4532 self.Parameters().SetGeoMax(theVal)
4534 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4535 # @ingroup l3_hypos_blsurf
4536 def SetGradation(self, theVal=_gradation):
4537 # Parameter of BLSURF algo
4538 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4539 self.params.SetGradation(theVal)
4541 ## Sets topology usage way.
4542 # @param way defines how mesh conformity is assured <ul>
4543 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4544 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4545 # @ingroup l3_hypos_blsurf
4546 def SetTopology(self, way):
4547 # Parameter of BLSURF algo
4548 self.Parameters().SetTopology(way)
4550 ## To respect geometrical edges or not.
4551 # @ingroup l3_hypos_blsurf
4552 def SetDecimesh(self, toIgnoreEdges=False):
4553 # Parameter of BLSURF algo
4554 self.Parameters().SetDecimesh(toIgnoreEdges)
4556 ## Sets verbosity level in the range 0 to 100.
4557 # @ingroup l3_hypos_blsurf
4558 def SetVerbosity(self, level):
4559 # Parameter of BLSURF algo
4560 self.Parameters().SetVerbosity(level)
4562 ## Sets advanced option value.
4563 # @ingroup l3_hypos_blsurf
4564 def SetOptionValue(self, optionName, level):
4565 # Parameter of BLSURF algo
4566 self.Parameters().SetOptionValue(optionName,level)
4568 ## Sets QuadAllowed flag.
4569 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4570 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4571 def SetQuadAllowed(self, toAllow=True):
4572 if self.algoType == NETGEN_2D:
4573 if toAllow: # add QuadranglePreference
4574 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4575 else: # remove QuadranglePreference
4576 for hyp in self.mesh.GetHypothesisList( self.geom ):
4577 if hyp.GetName() == "QuadranglePreference":
4578 self.mesh.RemoveHypothesis( self.geom, hyp )
4583 if self.Parameters():
4584 self.params.SetQuadAllowed(toAllow)
4587 ## Defines hypothesis having several parameters
4589 # @ingroup l3_hypos_netgen
4590 def Parameters(self, which=SOLE):
4593 if self.algoType == NETGEN:
4595 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4596 "libNETGENEngine.so", UseExisting=0)
4598 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4599 "libNETGENEngine.so", UseExisting=0)
4601 elif self.algoType == MEFISTO:
4602 print "Mefisto algo support no multi-parameter hypothesis"
4604 elif self.algoType == NETGEN_2D:
4605 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4606 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4608 elif self.algoType == BLSURF:
4609 self.params = self.Hypothesis("BLSURF_Parameters", [],
4610 "libBLSURFEngine.so", UseExisting=0)
4613 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4618 # Only for algoType == NETGEN
4619 # @ingroup l3_hypos_netgen
4620 def SetMaxSize(self, theSize):
4621 if self.Parameters():
4622 self.params.SetMaxSize(theSize)
4624 ## Sets SecondOrder flag
4626 # Only for algoType == NETGEN
4627 # @ingroup l3_hypos_netgen
4628 def SetSecondOrder(self, theVal):
4629 if self.Parameters():
4630 self.params.SetSecondOrder(theVal)
4632 ## Sets Optimize flag
4634 # Only for algoType == NETGEN
4635 # @ingroup l3_hypos_netgen
4636 def SetOptimize(self, theVal):
4637 if self.Parameters():
4638 self.params.SetOptimize(theVal)
4641 # @param theFineness is:
4642 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4644 # Only for algoType == NETGEN
4645 # @ingroup l3_hypos_netgen
4646 def SetFineness(self, theFineness):
4647 if self.Parameters():
4648 self.params.SetFineness(theFineness)
4652 # Only for algoType == NETGEN
4653 # @ingroup l3_hypos_netgen
4654 def SetGrowthRate(self, theRate):
4655 if self.Parameters():
4656 self.params.SetGrowthRate(theRate)
4658 ## Sets NbSegPerEdge
4660 # Only for algoType == NETGEN
4661 # @ingroup l3_hypos_netgen
4662 def SetNbSegPerEdge(self, theVal):
4663 if self.Parameters():
4664 self.params.SetNbSegPerEdge(theVal)
4666 ## Sets NbSegPerRadius
4668 # Only for algoType == NETGEN
4669 # @ingroup l3_hypos_netgen
4670 def SetNbSegPerRadius(self, theVal):
4671 if self.Parameters():
4672 self.params.SetNbSegPerRadius(theVal)
4674 ## Sets number of segments overriding value set by SetLocalLength()
4676 # Only for algoType == NETGEN
4677 # @ingroup l3_hypos_netgen
4678 def SetNumberOfSegments(self, theVal):
4679 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4681 ## Sets number of segments overriding value set by SetNumberOfSegments()
4683 # Only for algoType == NETGEN
4684 # @ingroup l3_hypos_netgen
4685 def SetLocalLength(self, theVal):
4686 self.Parameters(SIMPLE).SetLocalLength(theVal)
4691 # Public class: Mesh_Quadrangle
4692 # -----------------------------
4694 ## Defines a quadrangle 2D algorithm
4696 # @ingroup l3_algos_basic
4697 class Mesh_Quadrangle(Mesh_Algorithm):
4701 ## Private constructor.
4702 def __init__(self, mesh, geom=0):
4703 Mesh_Algorithm.__init__(self)
4704 self.Create(mesh, geom, "Quadrangle_2D")
4707 ## Defines "QuadrangleParameters" hypothesis
4708 # @param quadType defines the algorithm of transition between differently descretized
4709 # sides of a geometrical face:
4710 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
4711 # area along the finer meshed sides.
4712 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
4713 # finer meshed sides.
4714 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
4715 # the finer meshed sides, iff the total quantity of segments on
4716 # all four sides of the face is even (divisible by 2).
4717 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
4718 # area is located along the coarser meshed sides.
4719 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
4720 # is made gradually, layer by layer. This type has a limitation on
4721 # the number of segments: one pair of opposite sides must have the
4722 # same number of segments, the other pair must have an even difference
4723 # between the numbers of segments on the sides.
4724 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
4725 # will be created while other elements will be quadrangles.
4726 # Vertex can be either a GEOM_Object or a vertex ID within the
4728 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4729 # the same parameters, else (default) - creates a new one
4730 # @ingroup l3_hypos_quad
4731 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
4732 vertexID = triangleVertex
4733 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
4734 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
4736 compFun = lambda hyp,args: \
4737 hyp.GetQuadType() == args[0] and \
4738 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
4739 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
4740 UseExisting = UseExisting, CompareMethod=compFun)
4742 if self.params.GetQuadType() != quadType:
4743 self.params.SetQuadType(quadType)
4745 self.params.SetTriaVertex( vertexID )
4748 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
4749 # quadrangles are built in the transition area along the finer meshed sides,
4750 # iff the total quantity of segments on all four sides of the face is even.
4751 # @param reversed if True, transition area is located along the coarser meshed sides.
4752 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4753 # the same parameters, else (default) - creates a new one
4754 # @ingroup l3_hypos_quad
4755 def QuadranglePreference(self, reversed=False, UseExisting=0):
4757 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
4758 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
4760 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
4761 # triangles are built in the transition area along the finer meshed sides.
4762 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4763 # the same parameters, else (default) - creates a new one
4764 # @ingroup l3_hypos_quad
4765 def TrianglePreference(self, UseExisting=0):
4766 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
4768 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
4769 # quadrangles are built and the transition between the sides is made gradually,
4770 # layer by layer. This type has a limitation on the number of segments: one pair
4771 # of opposite sides must have the same number of segments, the other pair must
4772 # have an even difference between the numbers of segments on the sides.
4773 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4774 # the same parameters, else (default) - creates a new one
4775 # @ingroup l3_hypos_quad
4776 def Reduced(self, UseExisting=0):
4777 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
4779 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
4780 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4781 # will be created while other elements will be quadrangles.
4782 # Vertex can be either a GEOM_Object or a vertex ID within the
4784 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4785 # the same parameters, else (default) - creates a new one
4786 # @ingroup l3_hypos_quad
4787 def TriangleVertex(self, vertex, UseExisting=0):
4788 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
4791 # Public class: Mesh_Tetrahedron
4792 # ------------------------------
4794 ## Defines a tetrahedron 3D algorithm
4796 # @ingroup l3_algos_basic
4797 class Mesh_Tetrahedron(Mesh_Algorithm):
4802 ## Private constructor.
4803 def __init__(self, mesh, algoType, geom=0):
4804 Mesh_Algorithm.__init__(self)
4806 if algoType == NETGEN:
4808 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4811 elif algoType == FULL_NETGEN:
4813 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4816 elif algoType == GHS3D:
4818 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4821 elif algoType == GHS3DPRL:
4822 CheckPlugin(GHS3DPRL)
4823 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4826 self.algoType = algoType
4828 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4829 # @param vol for the maximum volume of each tetrahedron
4830 # @param UseExisting if ==true - searches for the existing hypothesis created with
4831 # the same parameters, else (default) - creates a new one
4832 # @ingroup l3_hypos_maxvol
4833 def MaxElementVolume(self, vol, UseExisting=0):
4834 if self.algoType == NETGEN:
4835 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4836 CompareMethod=self.CompareMaxElementVolume)
4837 hyp.SetMaxElementVolume(vol)
4839 elif self.algoType == FULL_NETGEN:
4840 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4843 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4844 def CompareMaxElementVolume(self, hyp, args):
4845 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4847 ## Defines hypothesis having several parameters
4849 # @ingroup l3_hypos_netgen
4850 def Parameters(self, which=SOLE):
4854 if self.algoType == FULL_NETGEN:
4856 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4857 "libNETGENEngine.so", UseExisting=0)
4859 self.params = self.Hypothesis("NETGEN_Parameters", [],
4860 "libNETGENEngine.so", UseExisting=0)
4863 if self.algoType == GHS3D:
4864 self.params = self.Hypothesis("GHS3D_Parameters", [],
4865 "libGHS3DEngine.so", UseExisting=0)
4868 if self.algoType == GHS3DPRL:
4869 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4870 "libGHS3DPRLEngine.so", UseExisting=0)
4873 print "Algo supports no multi-parameter hypothesis"
4877 # Parameter of FULL_NETGEN
4878 # @ingroup l3_hypos_netgen
4879 def SetMaxSize(self, theSize):
4880 self.Parameters().SetMaxSize(theSize)
4882 ## Sets SecondOrder flag
4883 # Parameter of FULL_NETGEN
4884 # @ingroup l3_hypos_netgen
4885 def SetSecondOrder(self, theVal):
4886 self.Parameters().SetSecondOrder(theVal)
4888 ## Sets Optimize flag
4889 # Parameter of FULL_NETGEN
4890 # @ingroup l3_hypos_netgen
4891 def SetOptimize(self, theVal):
4892 self.Parameters().SetOptimize(theVal)
4895 # @param theFineness is:
4896 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4897 # Parameter of FULL_NETGEN
4898 # @ingroup l3_hypos_netgen
4899 def SetFineness(self, theFineness):
4900 self.Parameters().SetFineness(theFineness)
4903 # Parameter of FULL_NETGEN
4904 # @ingroup l3_hypos_netgen
4905 def SetGrowthRate(self, theRate):
4906 self.Parameters().SetGrowthRate(theRate)
4908 ## Sets NbSegPerEdge
4909 # Parameter of FULL_NETGEN
4910 # @ingroup l3_hypos_netgen
4911 def SetNbSegPerEdge(self, theVal):
4912 self.Parameters().SetNbSegPerEdge(theVal)
4914 ## Sets NbSegPerRadius
4915 # Parameter of FULL_NETGEN
4916 # @ingroup l3_hypos_netgen
4917 def SetNbSegPerRadius(self, theVal):
4918 self.Parameters().SetNbSegPerRadius(theVal)
4920 ## Sets number of segments overriding value set by SetLocalLength()
4921 # Only for algoType == NETGEN_FULL
4922 # @ingroup l3_hypos_netgen
4923 def SetNumberOfSegments(self, theVal):
4924 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4926 ## Sets number of segments overriding value set by SetNumberOfSegments()
4927 # Only for algoType == NETGEN_FULL
4928 # @ingroup l3_hypos_netgen
4929 def SetLocalLength(self, theVal):
4930 self.Parameters(SIMPLE).SetLocalLength(theVal)
4932 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4933 # Overrides value set by LengthFromEdges()
4934 # Only for algoType == NETGEN_FULL
4935 # @ingroup l3_hypos_netgen
4936 def MaxElementArea(self, area):
4937 self.Parameters(SIMPLE).SetMaxElementArea(area)
4939 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4940 # Overrides value set by MaxElementArea()
4941 # Only for algoType == NETGEN_FULL
4942 # @ingroup l3_hypos_netgen
4943 def LengthFromEdges(self):
4944 self.Parameters(SIMPLE).LengthFromEdges()
4946 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4947 # Overrides value set by MaxElementVolume()
4948 # Only for algoType == NETGEN_FULL
4949 # @ingroup l3_hypos_netgen
4950 def LengthFromFaces(self):
4951 self.Parameters(SIMPLE).LengthFromFaces()
4953 ## To mesh "holes" in a solid or not. Default is to mesh.
4954 # @ingroup l3_hypos_ghs3dh
4955 def SetToMeshHoles(self, toMesh):
4956 # Parameter of GHS3D
4957 self.Parameters().SetToMeshHoles(toMesh)
4959 ## Set Optimization level:
4960 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4961 # Strong_Optimization.
4962 # Default is Standard_Optimization
4963 # @ingroup l3_hypos_ghs3dh
4964 def SetOptimizationLevel(self, level):
4965 # Parameter of GHS3D
4966 self.Parameters().SetOptimizationLevel(level)
4968 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4969 # @ingroup l3_hypos_ghs3dh
4970 def SetMaximumMemory(self, MB):
4971 # Advanced parameter of GHS3D
4972 self.Parameters().SetMaximumMemory(MB)
4974 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4975 # automatic memory adjustment mode.
4976 # @ingroup l3_hypos_ghs3dh
4977 def SetInitialMemory(self, MB):
4978 # Advanced parameter of GHS3D
4979 self.Parameters().SetInitialMemory(MB)
4981 ## Path to working directory.
4982 # @ingroup l3_hypos_ghs3dh
4983 def SetWorkingDirectory(self, path):
4984 # Advanced parameter of GHS3D
4985 self.Parameters().SetWorkingDirectory(path)
4987 ## To keep working files or remove them. Log file remains in case of errors anyway.
4988 # @ingroup l3_hypos_ghs3dh
4989 def SetKeepFiles(self, toKeep):
4990 # Advanced parameter of GHS3D and GHS3DPRL
4991 self.Parameters().SetKeepFiles(toKeep)
4993 ## To set verbose level [0-10]. <ul>
4994 #<li> 0 - no standard output,
4995 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4996 # indicates when the final mesh is being saved. In addition the software
4997 # gives indication regarding the CPU time.
4998 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4999 # histogram of the skin mesh, quality statistics histogram together with
5000 # the characteristics of the final mesh.</ul>
5001 # @ingroup l3_hypos_ghs3dh
5002 def SetVerboseLevel(self, level):
5003 # Advanced parameter of GHS3D
5004 self.Parameters().SetVerboseLevel(level)
5006 ## To create new nodes.
5007 # @ingroup l3_hypos_ghs3dh
5008 def SetToCreateNewNodes(self, toCreate):
5009 # Advanced parameter of GHS3D
5010 self.Parameters().SetToCreateNewNodes(toCreate)
5012 ## To use boundary recovery version which tries to create mesh on a very poor
5013 # quality surface mesh.
5014 # @ingroup l3_hypos_ghs3dh
5015 def SetToUseBoundaryRecoveryVersion(self, toUse):
5016 # Advanced parameter of GHS3D
5017 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5019 ## Sets command line option as text.
5020 # @ingroup l3_hypos_ghs3dh
5021 def SetTextOption(self, option):
5022 # Advanced parameter of GHS3D
5023 self.Parameters().SetTextOption(option)
5025 ## Sets MED files name and path.
5026 def SetMEDName(self, value):
5027 self.Parameters().SetMEDName(value)
5029 ## Sets the number of partition of the initial mesh
5030 def SetNbPart(self, value):
5031 self.Parameters().SetNbPart(value)
5033 ## When big mesh, start tepal in background
5034 def SetBackground(self, value):
5035 self.Parameters().SetBackground(value)
5037 # Public class: Mesh_Hexahedron
5038 # ------------------------------
5040 ## Defines a hexahedron 3D algorithm
5042 # @ingroup l3_algos_basic
5043 class Mesh_Hexahedron(Mesh_Algorithm):
5048 ## Private constructor.
5049 def __init__(self, mesh, algoType=Hexa, geom=0):
5050 Mesh_Algorithm.__init__(self)
5052 self.algoType = algoType
5054 if algoType == Hexa:
5055 self.Create(mesh, geom, "Hexa_3D")
5058 elif algoType == Hexotic:
5059 CheckPlugin(Hexotic)
5060 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5063 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5064 # @ingroup l3_hypos_hexotic
5065 def MinMaxQuad(self, min=3, max=8, quad=True):
5066 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5068 self.params.SetHexesMinLevel(min)
5069 self.params.SetHexesMaxLevel(max)
5070 self.params.SetHexoticQuadrangles(quad)
5073 # Deprecated, only for compatibility!
5074 # Public class: Mesh_Netgen
5075 # ------------------------------
5077 ## Defines a NETGEN-based 2D or 3D algorithm
5078 # that needs no discrete boundary (i.e. independent)
5080 # This class is deprecated, only for compatibility!
5083 # @ingroup l3_algos_basic
5084 class Mesh_Netgen(Mesh_Algorithm):
5088 ## Private constructor.
5089 def __init__(self, mesh, is3D, geom=0):
5090 Mesh_Algorithm.__init__(self)
5096 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5100 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5103 ## Defines the hypothesis containing parameters of the algorithm
5104 def Parameters(self):
5106 hyp = self.Hypothesis("NETGEN_Parameters", [],
5107 "libNETGENEngine.so", UseExisting=0)
5109 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5110 "libNETGENEngine.so", UseExisting=0)
5113 # Public class: Mesh_Projection1D
5114 # ------------------------------
5116 ## Defines a projection 1D algorithm
5117 # @ingroup l3_algos_proj
5119 class Mesh_Projection1D(Mesh_Algorithm):
5121 ## Private constructor.
5122 def __init__(self, mesh, geom=0):
5123 Mesh_Algorithm.__init__(self)
5124 self.Create(mesh, geom, "Projection_1D")
5126 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5127 # a mesh pattern is taken, and, optionally, the association of vertices
5128 # between the source edge and a target edge (to which a hypothesis is assigned)
5129 # @param edge from which nodes distribution is taken
5130 # @param mesh from which nodes distribution is taken (optional)
5131 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5132 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5133 # to associate with \a srcV (optional)
5134 # @param UseExisting if ==true - searches for the existing hypothesis created with
5135 # the same parameters, else (default) - creates a new one
5136 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5137 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5139 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5140 hyp.SetSourceEdge( edge )
5141 if not mesh is None and isinstance(mesh, Mesh):
5142 mesh = mesh.GetMesh()
5143 hyp.SetSourceMesh( mesh )
5144 hyp.SetVertexAssociation( srcV, tgtV )
5147 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5148 #def CompareSourceEdge(self, hyp, args):
5149 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5153 # Public class: Mesh_Projection2D
5154 # ------------------------------
5156 ## Defines a projection 2D algorithm
5157 # @ingroup l3_algos_proj
5159 class Mesh_Projection2D(Mesh_Algorithm):
5161 ## Private constructor.
5162 def __init__(self, mesh, geom=0):
5163 Mesh_Algorithm.__init__(self)
5164 self.Create(mesh, geom, "Projection_2D")
5166 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5167 # a mesh pattern is taken, and, optionally, the association of vertices
5168 # between the source face and the target face (to which a hypothesis is assigned)
5169 # @param face from which the mesh pattern is taken
5170 # @param mesh from which the mesh pattern is taken (optional)
5171 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5172 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5173 # to associate with \a srcV1 (optional)
5174 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5175 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5176 # to associate with \a srcV2 (optional)
5177 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5178 # the same parameters, else (default) - forces the creation a new one
5180 # Note: all association vertices must belong to one edge of a face
5181 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5182 srcV2=None, tgtV2=None, UseExisting=0):
5183 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5185 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5186 hyp.SetSourceFace( face )
5187 if not mesh is None and isinstance(mesh, Mesh):
5188 mesh = mesh.GetMesh()
5189 hyp.SetSourceMesh( mesh )
5190 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5193 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5194 #def CompareSourceFace(self, hyp, args):
5195 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5198 # Public class: Mesh_Projection3D
5199 # ------------------------------
5201 ## Defines a projection 3D algorithm
5202 # @ingroup l3_algos_proj
5204 class Mesh_Projection3D(Mesh_Algorithm):
5206 ## Private constructor.
5207 def __init__(self, mesh, geom=0):
5208 Mesh_Algorithm.__init__(self)
5209 self.Create(mesh, geom, "Projection_3D")
5211 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5212 # the mesh pattern is taken, and, optionally, the association of vertices
5213 # between the source and the target solid (to which a hipothesis is assigned)
5214 # @param solid from where the mesh pattern is taken
5215 # @param mesh from where the mesh pattern is taken (optional)
5216 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5217 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5218 # to associate with \a srcV1 (optional)
5219 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5220 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5221 # to associate with \a srcV2 (optional)
5222 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5223 # the same parameters, else (default) - creates a new one
5225 # Note: association vertices must belong to one edge of a solid
5226 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5227 srcV2=0, tgtV2=0, UseExisting=0):
5228 hyp = self.Hypothesis("ProjectionSource3D",
5229 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5231 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5232 hyp.SetSource3DShape( solid )
5233 if not mesh is None and isinstance(mesh, Mesh):
5234 mesh = mesh.GetMesh()
5235 hyp.SetSourceMesh( mesh )
5236 if srcV1 and srcV2 and tgtV1 and tgtV2:
5237 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5238 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5241 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5242 #def CompareSourceShape3D(self, hyp, args):
5243 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5247 # Public class: Mesh_Prism
5248 # ------------------------
5250 ## Defines a 3D extrusion algorithm
5251 # @ingroup l3_algos_3dextr
5253 class Mesh_Prism3D(Mesh_Algorithm):
5255 ## Private constructor.
5256 def __init__(self, mesh, geom=0):
5257 Mesh_Algorithm.__init__(self)
5258 self.Create(mesh, geom, "Prism_3D")
5260 # Public class: Mesh_RadialPrism
5261 # -------------------------------
5263 ## Defines a Radial Prism 3D algorithm
5264 # @ingroup l3_algos_radialp
5266 class Mesh_RadialPrism3D(Mesh_Algorithm):
5268 ## Private constructor.
5269 def __init__(self, mesh, geom=0):
5270 Mesh_Algorithm.__init__(self)
5271 self.Create(mesh, geom, "RadialPrism_3D")
5273 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5274 self.nbLayers = None
5276 ## Return 3D hypothesis holding the 1D one
5277 def Get3DHypothesis(self):
5278 return self.distribHyp
5280 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5281 # hypothesis. Returns the created hypothesis
5282 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5283 #print "OwnHypothesis",hypType
5284 if not self.nbLayers is None:
5285 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5286 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5287 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5288 self.mesh.smeshpyD.SetCurrentStudy( None )
5289 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5290 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5291 self.distribHyp.SetLayerDistribution( hyp )
5294 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5295 # prisms to build between the inner and outer shells
5296 # @param n number of layers
5297 # @param UseExisting if ==true - searches for the existing hypothesis created with
5298 # the same parameters, else (default) - creates a new one
5299 def NumberOfLayers(self, n, UseExisting=0):
5300 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5301 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5302 CompareMethod=self.CompareNumberOfLayers)
5303 self.nbLayers.SetNumberOfLayers( n )
5304 return self.nbLayers
5306 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5307 def CompareNumberOfLayers(self, hyp, args):
5308 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5310 ## Defines "LocalLength" hypothesis, specifying the segment length
5311 # to build between the inner and the outer shells
5312 # @param l the length of segments
5313 # @param p the precision of rounding
5314 def LocalLength(self, l, p=1e-07):
5315 hyp = self.OwnHypothesis("LocalLength", [l,p])
5320 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5321 # prisms to build between the inner and the outer shells.
5322 # @param n the number of layers
5323 # @param s the scale factor (optional)
5324 def NumberOfSegments(self, n, s=[]):
5326 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5328 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5329 hyp.SetDistrType( 1 )
5330 hyp.SetScaleFactor(s)
5331 hyp.SetNumberOfSegments(n)
5334 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5335 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5336 # @param start the length of the first segment
5337 # @param end the length of the last segment
5338 def Arithmetic1D(self, start, end ):
5339 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5340 hyp.SetLength(start, 1)
5341 hyp.SetLength(end , 0)
5344 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5345 # to build between the inner and the outer shells as geometric length increasing
5346 # @param start for the length of the first segment
5347 # @param end for the length of the last segment
5348 def StartEndLength(self, start, end):
5349 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5350 hyp.SetLength(start, 1)
5351 hyp.SetLength(end , 0)
5354 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5355 # to build between the inner and outer shells
5356 # @param fineness defines the quality of the mesh within the range [0-1]
5357 def AutomaticLength(self, fineness=0):
5358 hyp = self.OwnHypothesis("AutomaticLength")
5359 hyp.SetFineness( fineness )
5362 # Public class: Mesh_RadialQuadrangle1D2D
5363 # -------------------------------
5365 ## Defines a Radial Quadrangle 1D2D algorithm
5366 # @ingroup l2_algos_radialq
5368 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5370 ## Private constructor.
5371 def __init__(self, mesh, geom=0):
5372 Mesh_Algorithm.__init__(self)
5373 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5375 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5376 self.nbLayers = None
5378 ## Return 2D hypothesis holding the 1D one
5379 def Get2DHypothesis(self):
5380 return self.distribHyp
5382 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5383 # hypothesis. Returns the created hypothesis
5384 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5385 #print "OwnHypothesis",hypType
5387 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5388 if self.distribHyp is None:
5389 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5391 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5392 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5393 self.mesh.smeshpyD.SetCurrentStudy( None )
5394 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5395 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5396 self.distribHyp.SetLayerDistribution( hyp )
5399 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5400 # @param n number of layers
5401 # @param UseExisting if ==true - searches for the existing hypothesis created with
5402 # the same parameters, else (default) - creates a new one
5403 def NumberOfLayers(self, n, UseExisting=0):
5405 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5406 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5407 CompareMethod=self.CompareNumberOfLayers)
5408 self.nbLayers.SetNumberOfLayers( n )
5409 return self.nbLayers
5411 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5412 def CompareNumberOfLayers(self, hyp, args):
5413 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5415 ## Defines "LocalLength" hypothesis, specifying the segment length
5416 # @param l the length of segments
5417 # @param p the precision of rounding
5418 def LocalLength(self, l, p=1e-07):
5419 hyp = self.OwnHypothesis("LocalLength", [l,p])
5424 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5425 # @param n the number of layers
5426 # @param s the scale factor (optional)
5427 def NumberOfSegments(self, n, s=[]):
5429 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5431 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5432 hyp.SetDistrType( 1 )
5433 hyp.SetScaleFactor(s)
5434 hyp.SetNumberOfSegments(n)
5437 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5438 # with a length that changes in arithmetic progression
5439 # @param start the length of the first segment
5440 # @param end the length of the last segment
5441 def Arithmetic1D(self, start, end ):
5442 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5443 hyp.SetLength(start, 1)
5444 hyp.SetLength(end , 0)
5447 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5448 # as geometric length increasing
5449 # @param start for the length of the first segment
5450 # @param end for the length of the last segment
5451 def StartEndLength(self, start, end):
5452 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5453 hyp.SetLength(start, 1)
5454 hyp.SetLength(end , 0)
5457 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5458 # @param fineness defines the quality of the mesh within the range [0-1]
5459 def AutomaticLength(self, fineness=0):
5460 hyp = self.OwnHypothesis("AutomaticLength")
5461 hyp.SetFineness( fineness )
5465 # Private class: Mesh_UseExisting
5466 # -------------------------------
5467 class Mesh_UseExisting(Mesh_Algorithm):
5469 def __init__(self, dim, mesh, geom=0):
5471 self.Create(mesh, geom, "UseExisting_1D")
5473 self.Create(mesh, geom, "UseExisting_2D")
5476 import salome_notebook
5477 notebook = salome_notebook.notebook
5479 ##Return values of the notebook variables
5480 def ParseParameters(last, nbParams,nbParam, value):
5484 listSize = len(last)
5485 for n in range(0,nbParams):
5487 if counter < listSize:
5488 strResult = strResult + last[counter]
5490 strResult = strResult + ""
5492 if isinstance(value, str):
5493 if notebook.isVariable(value):
5494 result = notebook.get(value)
5495 strResult=strResult+value
5497 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5499 strResult=strResult+str(value)
5501 if nbParams - 1 != counter:
5502 strResult=strResult+var_separator #":"
5504 return result, strResult
5506 #Wrapper class for StdMeshers_LocalLength hypothesis
5507 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5509 ## Set Length parameter value
5510 # @param length numerical value or name of variable from notebook
5511 def SetLength(self, length):
5512 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5513 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5514 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5516 ## Set Precision parameter value
5517 # @param precision numerical value or name of variable from notebook
5518 def SetPrecision(self, precision):
5519 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5520 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5521 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5523 #Registering the new proxy for LocalLength
5524 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5527 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5528 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5530 def SetLayerDistribution(self, hypo):
5531 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5532 hypo.ClearParameters();
5533 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5535 #Registering the new proxy for LayerDistribution
5536 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5538 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5539 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5541 ## Set Length parameter value
5542 # @param length numerical value or name of variable from notebook
5543 def SetLength(self, length):
5544 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5545 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5546 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5548 #Registering the new proxy for SegmentLengthAroundVertex
5549 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5552 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5553 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5555 ## Set Length parameter value
5556 # @param length numerical value or name of variable from notebook
5557 # @param isStart true is length is Start Length, otherwise false
5558 def SetLength(self, length, isStart):
5562 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5563 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5564 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5566 #Registering the new proxy for Arithmetic1D
5567 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5569 #Wrapper class for StdMeshers_Deflection1D hypothesis
5570 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5572 ## Set Deflection parameter value
5573 # @param deflection numerical value or name of variable from notebook
5574 def SetDeflection(self, deflection):
5575 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5576 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5577 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5579 #Registering the new proxy for Deflection1D
5580 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5582 #Wrapper class for StdMeshers_StartEndLength hypothesis
5583 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5585 ## Set Length parameter value
5586 # @param length numerical value or name of variable from notebook
5587 # @param isStart true is length is Start Length, otherwise false
5588 def SetLength(self, length, isStart):
5592 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5593 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5594 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5596 #Registering the new proxy for StartEndLength
5597 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5599 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5600 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5602 ## Set Max Element Area parameter value
5603 # @param area numerical value or name of variable from notebook
5604 def SetMaxElementArea(self, area):
5605 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5606 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5607 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5609 #Registering the new proxy for MaxElementArea
5610 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5613 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5614 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5616 ## Set Max Element Volume parameter value
5617 # @param volume numerical value or name of variable from notebook
5618 def SetMaxElementVolume(self, volume):
5619 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5620 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5621 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5623 #Registering the new proxy for MaxElementVolume
5624 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5627 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5628 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5630 ## Set Number Of Layers parameter value
5631 # @param nbLayers numerical value or name of variable from notebook
5632 def SetNumberOfLayers(self, nbLayers):
5633 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5634 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5635 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5637 #Registering the new proxy for NumberOfLayers
5638 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5640 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5641 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5643 ## Set Number Of Segments parameter value
5644 # @param nbSeg numerical value or name of variable from notebook
5645 def SetNumberOfSegments(self, nbSeg):
5646 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5647 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5648 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5649 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5651 ## Set Scale Factor parameter value
5652 # @param factor numerical value or name of variable from notebook
5653 def SetScaleFactor(self, factor):
5654 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5655 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5656 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5658 #Registering the new proxy for NumberOfSegments
5659 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5661 if not noNETGENPlugin:
5662 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5663 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5665 ## Set Max Size parameter value
5666 # @param maxsize numerical value or name of variable from notebook
5667 def SetMaxSize(self, maxsize):
5668 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5669 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5670 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5671 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5673 ## Set Growth Rate parameter value
5674 # @param value numerical value or name of variable from notebook
5675 def SetGrowthRate(self, value):
5676 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5677 value, parameters = ParseParameters(lastParameters,4,2,value)
5678 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5679 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5681 ## Set Number of Segments per Edge parameter value
5682 # @param value numerical value or name of variable from notebook
5683 def SetNbSegPerEdge(self, value):
5684 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5685 value, parameters = ParseParameters(lastParameters,4,3,value)
5686 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5687 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5689 ## Set Number of Segments per Radius parameter value
5690 # @param value numerical value or name of variable from notebook
5691 def SetNbSegPerRadius(self, value):
5692 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5693 value, parameters = ParseParameters(lastParameters,4,4,value)
5694 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5695 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5697 #Registering the new proxy for NETGENPlugin_Hypothesis
5698 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5701 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5702 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5705 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5706 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5708 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5709 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5711 ## Set Number of Segments parameter value
5712 # @param nbSeg numerical value or name of variable from notebook
5713 def SetNumberOfSegments(self, nbSeg):
5714 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5715 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5716 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5717 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5719 ## Set Local Length parameter value
5720 # @param length numerical value or name of variable from notebook
5721 def SetLocalLength(self, length):
5722 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5723 length, parameters = ParseParameters(lastParameters,2,1,length)
5724 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5725 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5727 ## Set Max Element Area parameter value
5728 # @param area numerical value or name of variable from notebook
5729 def SetMaxElementArea(self, area):
5730 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5731 area, parameters = ParseParameters(lastParameters,2,2,area)
5732 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5733 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5735 def LengthFromEdges(self):
5736 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5738 value, parameters = ParseParameters(lastParameters,2,2,value)
5739 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5740 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5742 #Registering the new proxy for NETGEN_SimpleParameters_2D
5743 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5746 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5747 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5748 ## Set Max Element Volume parameter value
5749 # @param volume numerical value or name of variable from notebook
5750 def SetMaxElementVolume(self, volume):
5751 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5752 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5753 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5754 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5756 def LengthFromFaces(self):
5757 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5759 value, parameters = ParseParameters(lastParameters,3,3,value)
5760 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5761 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5763 #Registering the new proxy for NETGEN_SimpleParameters_3D
5764 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5766 pass # if not noNETGENPlugin:
5768 class Pattern(SMESH._objref_SMESH_Pattern):
5770 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5772 if isinstance(theNodeIndexOnKeyPoint1,str):
5774 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5776 theNodeIndexOnKeyPoint1 -= 1
5777 theMesh.SetParameters(Parameters)
5778 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5780 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5783 if isinstance(theNode000Index,str):
5785 if isinstance(theNode001Index,str):
5787 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5789 theNode000Index -= 1
5791 theNode001Index -= 1
5792 theMesh.SetParameters(Parameters)
5793 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5795 #Registering the new proxy for Pattern
5796 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)