1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 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
166 # MirrorType enumeration
167 POINT = SMESH_MeshEditor.POINT
168 AXIS = SMESH_MeshEditor.AXIS
169 PLANE = SMESH_MeshEditor.PLANE
171 # Smooth_Method enumeration
172 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
173 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
175 # Fineness enumeration (for NETGEN)
183 # Optimization level of GHS3D
185 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
186 # V4.1 (partialy redefines V3.1). Issue 0020574
187 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
189 # Topology treatment way of BLSURF
190 FromCAD, PreProcess, PreProcessPlus = 0,1,2
192 # Element size flag of BLSURF
193 DefaultSize, DefaultGeom, Custom = 0,0,1
195 PrecisionConfusion = 1e-07
197 ## Converts an angle from degrees to radians
198 def DegreesToRadians(AngleInDegrees):
200 return AngleInDegrees * pi / 180.0
202 # Salome notebook variable separator
205 # Parametrized substitute for PointStruct
206 class PointStructStr:
215 def __init__(self, xStr, yStr, zStr):
219 if isinstance(xStr, str) and notebook.isVariable(xStr):
220 self.x = notebook.get(xStr)
223 if isinstance(yStr, str) and notebook.isVariable(yStr):
224 self.y = notebook.get(yStr)
227 if isinstance(zStr, str) and notebook.isVariable(zStr):
228 self.z = notebook.get(zStr)
232 # Parametrized substitute for PointStruct (with 6 parameters)
233 class PointStructStr6:
248 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
255 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
256 self.x1 = notebook.get(x1Str)
259 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
260 self.x2 = notebook.get(x2Str)
263 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
264 self.y1 = notebook.get(y1Str)
267 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
268 self.y2 = notebook.get(y2Str)
271 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
272 self.z1 = notebook.get(z1Str)
275 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
276 self.z2 = notebook.get(z2Str)
280 # Parametrized substitute for AxisStruct
296 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
303 if isinstance(xStr, str) and notebook.isVariable(xStr):
304 self.x = notebook.get(xStr)
307 if isinstance(yStr, str) and notebook.isVariable(yStr):
308 self.y = notebook.get(yStr)
311 if isinstance(zStr, str) and notebook.isVariable(zStr):
312 self.z = notebook.get(zStr)
315 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
316 self.dx = notebook.get(dxStr)
319 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
320 self.dy = notebook.get(dyStr)
323 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
324 self.dz = notebook.get(dzStr)
328 # Parametrized substitute for DirStruct
331 def __init__(self, pointStruct):
332 self.pointStruct = pointStruct
334 # Returns list of variable values from salome notebook
335 def ParsePointStruct(Point):
336 Parameters = 2*var_separator
337 if isinstance(Point, PointStructStr):
338 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
339 Point = PointStruct(Point.x, Point.y, Point.z)
340 return Point, Parameters
342 # Returns list of variable values from salome notebook
343 def ParseDirStruct(Dir):
344 Parameters = 2*var_separator
345 if isinstance(Dir, DirStructStr):
346 pntStr = Dir.pointStruct
347 if isinstance(pntStr, PointStructStr6):
348 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
349 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
350 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
351 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
353 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
354 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
355 Dir = DirStruct(Point)
356 return Dir, Parameters
358 # Returns list of variable values from salome notebook
359 def ParseAxisStruct(Axis):
360 Parameters = 5*var_separator
361 if isinstance(Axis, AxisStructStr):
362 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
363 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
364 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
365 return Axis, Parameters
367 ## Return list of variable values from salome notebook
368 def ParseAngles(list):
371 for parameter in list:
372 if isinstance(parameter,str) and notebook.isVariable(parameter):
373 Result.append(DegreesToRadians(notebook.get(parameter)))
376 Result.append(parameter)
379 Parameters = Parameters + str(parameter)
380 Parameters = Parameters + var_separator
382 Parameters = Parameters[:len(Parameters)-1]
383 return Result, Parameters
385 def IsEqual(val1, val2, tol=PrecisionConfusion):
386 if abs(val1 - val2) < tol:
394 ior = salome.orb.object_to_string(obj)
395 sobj = salome.myStudy.FindObjectIOR(ior)
399 attr = sobj.FindAttribute("AttributeName")[1]
402 ## Prints error message if a hypothesis was not assigned.
403 def TreatHypoStatus(status, hypName, geomName, isAlgo):
405 hypType = "algorithm"
407 hypType = "hypothesis"
409 if status == HYP_UNKNOWN_FATAL :
410 reason = "for unknown reason"
411 elif status == HYP_INCOMPATIBLE :
412 reason = "this hypothesis mismatches the algorithm"
413 elif status == HYP_NOTCONFORM :
414 reason = "a non-conform mesh would be built"
415 elif status == HYP_ALREADY_EXIST :
416 reason = hypType + " of the same dimension is already assigned to this shape"
417 elif status == HYP_BAD_DIM :
418 reason = hypType + " mismatches the shape"
419 elif status == HYP_CONCURENT :
420 reason = "there are concurrent hypotheses on sub-shapes"
421 elif status == HYP_BAD_SUBSHAPE :
422 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
423 elif status == HYP_BAD_GEOMETRY:
424 reason = "geometry mismatches the expectation of the algorithm"
425 elif status == HYP_HIDDEN_ALGO:
426 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
427 elif status == HYP_HIDING_ALGO:
428 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
429 elif status == HYP_NEED_SHAPE:
430 reason = "Algorithm can't work without shape"
433 hypName = '"' + hypName + '"'
434 geomName= '"' + geomName+ '"'
435 if status < HYP_UNKNOWN_FATAL:
436 print hypName, "was assigned to", geomName,"but", reason
438 print hypName, "was not assigned to",geomName,":", reason
441 ## Check meshing plugin availability
442 def CheckPlugin(plugin):
443 if plugin == NETGEN and noNETGENPlugin:
444 print "Warning: NETGENPlugin module unavailable"
446 elif plugin == GHS3D and noGHS3DPlugin:
447 print "Warning: GHS3DPlugin module unavailable"
449 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
450 print "Warning: GHS3DPRLPlugin module unavailable"
452 elif plugin == Hexotic and noHexoticPlugin:
453 print "Warning: HexoticPlugin module unavailable"
455 elif plugin == BLSURF and noBLSURFPlugin:
456 print "Warning: BLSURFPlugin module unavailable"
460 # end of l1_auxiliary
463 # All methods of this class are accessible directly from the smesh.py package.
464 class smeshDC(SMESH._objref_SMESH_Gen):
466 ## Sets the current study and Geometry component
467 # @ingroup l1_auxiliary
468 def init_smesh(self,theStudy,geompyD):
469 self.SetCurrentStudy(theStudy,geompyD)
471 ## Creates an empty Mesh. This mesh can have an underlying geometry.
472 # @param obj the Geometrical object on which the mesh is built. If not defined,
473 # the mesh will have no underlying geometry.
474 # @param name the name for the new mesh.
475 # @return an instance of Mesh class.
476 # @ingroup l2_construct
477 def Mesh(self, obj=0, name=0):
478 if isinstance(obj,str):
480 return Mesh(self,self.geompyD,obj,name)
482 ## Returns a long value from enumeration
483 # Should be used for SMESH.FunctorType enumeration
484 # @ingroup l1_controls
485 def EnumToLong(self,theItem):
488 ## Gets PointStruct from vertex
489 # @param theVertex a GEOM object(vertex)
490 # @return SMESH.PointStruct
491 # @ingroup l1_auxiliary
492 def GetPointStruct(self,theVertex):
493 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
494 return PointStruct(x,y,z)
496 ## Gets DirStruct from vector
497 # @param theVector a GEOM object(vector)
498 # @return SMESH.DirStruct
499 # @ingroup l1_auxiliary
500 def GetDirStruct(self,theVector):
501 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
502 if(len(vertices) != 2):
503 print "Error: vector object is incorrect."
505 p1 = self.geompyD.PointCoordinates(vertices[0])
506 p2 = self.geompyD.PointCoordinates(vertices[1])
507 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
508 dirst = DirStruct(pnt)
511 ## Makes DirStruct from a triplet
512 # @param x,y,z vector components
513 # @return SMESH.DirStruct
514 # @ingroup l1_auxiliary
515 def MakeDirStruct(self,x,y,z):
516 pnt = PointStruct(x,y,z)
517 return DirStruct(pnt)
519 ## Get AxisStruct from object
520 # @param theObj a GEOM object (line or plane)
521 # @return SMESH.AxisStruct
522 # @ingroup l1_auxiliary
523 def GetAxisStruct(self,theObj):
524 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
526 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
527 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
528 vertex1 = self.geompyD.PointCoordinates(vertex1)
529 vertex2 = self.geompyD.PointCoordinates(vertex2)
530 vertex3 = self.geompyD.PointCoordinates(vertex3)
531 vertex4 = self.geompyD.PointCoordinates(vertex4)
532 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
533 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
534 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] ]
535 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
537 elif len(edges) == 1:
538 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
539 p1 = self.geompyD.PointCoordinates( vertex1 )
540 p2 = self.geompyD.PointCoordinates( vertex2 )
541 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
545 # From SMESH_Gen interface:
546 # ------------------------
548 ## Sets the given name to the object
549 # @param obj the object to rename
550 # @param name a new object name
551 # @ingroup l1_auxiliary
552 def SetName(self, obj, name):
553 if isinstance( obj, Mesh ):
555 elif isinstance( obj, Mesh_Algorithm ):
556 obj = obj.GetAlgorithm()
557 ior = salome.orb.object_to_string(obj)
558 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
560 ## Sets the current mode
561 # @ingroup l1_auxiliary
562 def SetEmbeddedMode( self,theMode ):
563 #self.SetEmbeddedMode(theMode)
564 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
566 ## Gets the current mode
567 # @ingroup l1_auxiliary
568 def IsEmbeddedMode(self):
569 #return self.IsEmbeddedMode()
570 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
572 ## Sets the current study
573 # @ingroup l1_auxiliary
574 def SetCurrentStudy( self, theStudy, geompyD = None ):
575 #self.SetCurrentStudy(theStudy)
578 geompyD = geompy.geom
581 self.SetGeomEngine(geompyD)
582 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
584 ## Gets the current study
585 # @ingroup l1_auxiliary
586 def GetCurrentStudy(self):
587 #return self.GetCurrentStudy()
588 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
590 ## Creates a Mesh object importing data from the given UNV file
591 # @return an instance of Mesh class
593 def CreateMeshesFromUNV( self,theFileName ):
594 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
595 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
598 ## Creates a Mesh object(s) importing data from the given MED file
599 # @return a list of Mesh class instances
601 def CreateMeshesFromMED( self,theFileName ):
602 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
604 for iMesh in range(len(aSmeshMeshes)) :
605 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
606 aMeshes.append(aMesh)
607 return aMeshes, aStatus
609 ## Creates a Mesh object importing data from the given STL file
610 # @return an instance of Mesh class
612 def CreateMeshesFromSTL( self, theFileName ):
613 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
614 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
617 ## From SMESH_Gen interface
618 # @return the list of integer values
619 # @ingroup l1_auxiliary
620 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
621 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
623 ## From SMESH_Gen interface. Creates a pattern
624 # @return an instance of SMESH_Pattern
626 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
627 # @ingroup l2_modif_patterns
628 def GetPattern(self):
629 return SMESH._objref_SMESH_Gen.GetPattern(self)
631 ## Sets number of segments per diagonal of boundary box of geometry by which
632 # default segment length of appropriate 1D hypotheses is defined.
633 # Default value is 10
634 # @ingroup l1_auxiliary
635 def SetBoundaryBoxSegmentation(self, nbSegments):
636 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
638 ## Concatenate the given meshes into one mesh.
639 # @return an instance of Mesh class
640 # @param meshes the meshes to combine into one mesh
641 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
642 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
643 # @param mergeTolerance tolerance for merging nodes
644 # @param allGroups forces creation of groups of all elements
645 def Concatenate( self, meshes, uniteIdenticalGroups,
646 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
647 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
649 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
650 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
652 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
653 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
654 aSmeshMesh.SetParameters(Parameters)
655 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
658 # Filtering. Auxiliary functions:
659 # ------------------------------
661 ## Creates an empty criterion
662 # @return SMESH.Filter.Criterion
663 # @ingroup l1_controls
664 def GetEmptyCriterion(self):
665 Type = self.EnumToLong(FT_Undefined)
666 Compare = self.EnumToLong(FT_Undefined)
670 UnaryOp = self.EnumToLong(FT_Undefined)
671 BinaryOp = self.EnumToLong(FT_Undefined)
674 Precision = -1 ##@1e-07
675 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
676 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
678 ## Creates a criterion by the given parameters
679 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
680 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
681 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
682 # @param Treshold the threshold value (range of ids as string, shape, numeric)
683 # @param UnaryOp FT_LogicalNOT or FT_Undefined
684 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
685 # FT_Undefined (must be for the last criterion of all criteria)
686 # @return SMESH.Filter.Criterion
687 # @ingroup l1_controls
688 def GetCriterion(self,elementType,
690 Compare = FT_EqualTo,
692 UnaryOp=FT_Undefined,
693 BinaryOp=FT_Undefined):
694 aCriterion = self.GetEmptyCriterion()
695 aCriterion.TypeOfElement = elementType
696 aCriterion.Type = self.EnumToLong(CritType)
700 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
701 aCriterion.Compare = self.EnumToLong(Compare)
702 elif Compare == "=" or Compare == "==":
703 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
705 aCriterion.Compare = self.EnumToLong(FT_LessThan)
707 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
709 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
712 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
713 FT_BelongToCylinder, FT_LyingOnGeom]:
714 # Checks the treshold
715 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
716 aCriterion.ThresholdStr = GetName(aTreshold)
717 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
719 print "Error: The treshold should be a shape."
721 elif CritType == FT_RangeOfIds:
722 # Checks the treshold
723 if isinstance(aTreshold, str):
724 aCriterion.ThresholdStr = aTreshold
726 print "Error: The treshold should be a string."
728 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
729 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
730 # At this point the treshold is unnecessary
731 if aTreshold == FT_LogicalNOT:
732 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
733 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
734 aCriterion.BinaryOp = aTreshold
738 aTreshold = float(aTreshold)
739 aCriterion.Threshold = aTreshold
741 print "Error: The treshold should be a number."
744 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
745 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
747 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
748 aCriterion.BinaryOp = self.EnumToLong(Treshold)
750 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
751 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
753 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
754 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
758 ## Creates a filter with the given parameters
759 # @param elementType the type of elements in the group
760 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
761 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
762 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
763 # @param UnaryOp FT_LogicalNOT or FT_Undefined
764 # @return SMESH_Filter
765 # @ingroup l1_controls
766 def GetFilter(self,elementType,
767 CritType=FT_Undefined,
770 UnaryOp=FT_Undefined):
771 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
772 aFilterMgr = self.CreateFilterManager()
773 aFilter = aFilterMgr.CreateFilter()
775 aCriteria.append(aCriterion)
776 aFilter.SetCriteria(aCriteria)
779 ## Creates a numerical functor by its type
780 # @param theCriterion FT_...; functor type
781 # @return SMESH_NumericalFunctor
782 # @ingroup l1_controls
783 def GetFunctor(self,theCriterion):
784 aFilterMgr = self.CreateFilterManager()
785 if theCriterion == FT_AspectRatio:
786 return aFilterMgr.CreateAspectRatio()
787 elif theCriterion == FT_AspectRatio3D:
788 return aFilterMgr.CreateAspectRatio3D()
789 elif theCriterion == FT_Warping:
790 return aFilterMgr.CreateWarping()
791 elif theCriterion == FT_MinimumAngle:
792 return aFilterMgr.CreateMinimumAngle()
793 elif theCriterion == FT_Taper:
794 return aFilterMgr.CreateTaper()
795 elif theCriterion == FT_Skew:
796 return aFilterMgr.CreateSkew()
797 elif theCriterion == FT_Area:
798 return aFilterMgr.CreateArea()
799 elif theCriterion == FT_Volume3D:
800 return aFilterMgr.CreateVolume3D()
801 elif theCriterion == FT_MultiConnection:
802 return aFilterMgr.CreateMultiConnection()
803 elif theCriterion == FT_MultiConnection2D:
804 return aFilterMgr.CreateMultiConnection2D()
805 elif theCriterion == FT_Length:
806 return aFilterMgr.CreateLength()
807 elif theCriterion == FT_Length2D:
808 return aFilterMgr.CreateLength2D()
810 print "Error: given parameter is not numerucal functor type."
812 ## Creates hypothesis
813 # @param theHType mesh hypothesis type (string)
814 # @param theLibName mesh plug-in library name
815 # @return created hypothesis instance
816 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
817 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
819 ## Gets the mesh stattistic
820 # @return dictionary type element - count of elements
821 # @ingroup l1_meshinfo
822 def GetMeshInfo(self, obj):
823 if isinstance( obj, Mesh ):
826 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
827 values = obj.GetMeshInfo()
828 for i in range(SMESH.Entity_Last._v):
829 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
834 #Registering the new proxy for SMESH_Gen
835 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
841 ## This class allows defining and managing a mesh.
842 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
843 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
844 # new nodes and elements and by changing the existing entities), to get information
845 # about a mesh and to export a mesh into different formats.
854 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
855 # sets the GUI name of this mesh to \a name.
856 # @param smeshpyD an instance of smeshDC class
857 # @param geompyD an instance of geompyDC class
858 # @param obj Shape to be meshed or SMESH_Mesh object
859 # @param name Study name of the mesh
860 # @ingroup l2_construct
861 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
862 self.smeshpyD=smeshpyD
867 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
869 self.mesh = self.smeshpyD.CreateMesh(self.geom)
870 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
873 self.mesh = self.smeshpyD.CreateEmptyMesh()
875 self.smeshpyD.SetName(self.mesh, name)
877 self.smeshpyD.SetName(self.mesh, GetName(obj))
880 self.geom = self.mesh.GetShapeToMesh()
882 self.editor = self.mesh.GetMeshEditor()
884 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
885 # @param theMesh a SMESH_Mesh object
886 # @ingroup l2_construct
887 def SetMesh(self, theMesh):
889 self.geom = self.mesh.GetShapeToMesh()
891 ## Returns the mesh, that is an instance of SMESH_Mesh interface
892 # @return a SMESH_Mesh object
893 # @ingroup l2_construct
897 ## Gets the name of the mesh
898 # @return the name of the mesh as a string
899 # @ingroup l2_construct
901 name = GetName(self.GetMesh())
904 ## Sets a name to the mesh
905 # @param name a new name of the mesh
906 # @ingroup l2_construct
907 def SetName(self, name):
908 self.smeshpyD.SetName(self.GetMesh(), name)
910 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
911 # The subMesh object gives access to the IDs of nodes and elements.
912 # @param theSubObject a geometrical object (shape)
913 # @param theName a name for the submesh
914 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
915 # @ingroup l2_submeshes
916 def GetSubMesh(self, theSubObject, theName):
917 submesh = self.mesh.GetSubMesh(theSubObject, theName)
920 ## Returns the shape associated to the mesh
921 # @return a GEOM_Object
922 # @ingroup l2_construct
926 ## Associates the given shape to the mesh (entails the recreation of the mesh)
927 # @param geom the shape to be meshed (GEOM_Object)
928 # @ingroup l2_construct
929 def SetShape(self, geom):
930 self.mesh = self.smeshpyD.CreateMesh(geom)
932 ## Returns true if the hypotheses are defined well
933 # @param theSubObject a subshape of a mesh shape
934 # @return True or False
935 # @ingroup l2_construct
936 def IsReadyToCompute(self, theSubObject):
937 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
939 ## Returns errors of hypotheses definition.
940 # The list of errors is empty if everything is OK.
941 # @param theSubObject a subshape of a mesh shape
942 # @return a list of errors
943 # @ingroup l2_construct
944 def GetAlgoState(self, theSubObject):
945 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
947 ## Returns a geometrical object on which the given element was built.
948 # The returned geometrical object, if not nil, is either found in the
949 # study or published by this method with the given name
950 # @param theElementID the id of the mesh element
951 # @param theGeomName the user-defined name of the geometrical object
952 # @return GEOM::GEOM_Object instance
953 # @ingroup l2_construct
954 def GetGeometryByMeshElement(self, theElementID, theGeomName):
955 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
957 ## Returns the mesh dimension depending on the dimension of the underlying shape
958 # @return mesh dimension as an integer value [0,3]
959 # @ingroup l1_auxiliary
960 def MeshDimension(self):
961 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
962 if len( shells ) > 0 :
964 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
966 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
972 ## Creates a segment discretization 1D algorithm.
973 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
974 # \n If the optional \a geom parameter is not set, this algorithm is global.
975 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
976 # @param algo the type of the required algorithm. Possible values are:
978 # - smesh.PYTHON for discretization via a python function,
979 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
980 # @param geom If defined is the subshape to be meshed
981 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
982 # @ingroup l3_algos_basic
983 def Segment(self, algo=REGULAR, geom=0):
984 ## if Segment(geom) is called by mistake
985 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
986 algo, geom = geom, algo
987 if not algo: algo = REGULAR
990 return Mesh_Segment(self, geom)
992 return Mesh_Segment_Python(self, geom)
993 elif algo == COMPOSITE:
994 return Mesh_CompositeSegment(self, geom)
996 return Mesh_Segment(self, geom)
998 ## Enables creation of nodes and segments usable by 2D algoritms.
999 # The added nodes and segments must be bound to edges and vertices by
1000 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1001 # If the optional \a geom parameter is not set, this algorithm is global.
1002 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1003 # @param geom the subshape to be manually meshed
1004 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1005 # @ingroup l3_algos_basic
1006 def UseExistingSegments(self, geom=0):
1007 algo = Mesh_UseExisting(1,self,geom)
1008 return algo.GetAlgorithm()
1010 ## Enables creation of nodes and faces usable by 3D algoritms.
1011 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1012 # and SetMeshElementOnShape()
1013 # If the optional \a geom parameter is not set, this algorithm is global.
1014 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1015 # @param geom the subshape to be manually meshed
1016 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1017 # @ingroup l3_algos_basic
1018 def UseExistingFaces(self, geom=0):
1019 algo = Mesh_UseExisting(2,self,geom)
1020 return algo.GetAlgorithm()
1022 ## Creates a triangle 2D algorithm for faces.
1023 # If the optional \a geom parameter is not set, this algorithm is global.
1024 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1025 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1026 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1027 # @return an instance of Mesh_Triangle algorithm
1028 # @ingroup l3_algos_basic
1029 def Triangle(self, algo=MEFISTO, geom=0):
1030 ## if Triangle(geom) is called by mistake
1031 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1035 return Mesh_Triangle(self, algo, geom)
1037 ## Creates a quadrangle 2D algorithm for faces.
1038 # If the optional \a geom parameter is not set, this algorithm is global.
1039 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1040 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1041 # @return an instance of Mesh_Quadrangle algorithm
1042 # @ingroup l3_algos_basic
1043 def Quadrangle(self, geom=0):
1044 return Mesh_Quadrangle(self, geom)
1046 ## Creates a tetrahedron 3D algorithm for solids.
1047 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1048 # If the optional \a geom parameter is not set, this algorithm is global.
1049 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1050 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1051 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1052 # @return an instance of Mesh_Tetrahedron algorithm
1053 # @ingroup l3_algos_basic
1054 def Tetrahedron(self, algo=NETGEN, geom=0):
1055 ## if Tetrahedron(geom) is called by mistake
1056 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1057 algo, geom = geom, algo
1058 if not algo: algo = NETGEN
1060 return Mesh_Tetrahedron(self, algo, geom)
1062 ## Creates a hexahedron 3D algorithm for solids.
1063 # If the optional \a geom parameter is not set, this algorithm is global.
1064 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1065 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1066 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1067 # @return an instance of Mesh_Hexahedron algorithm
1068 # @ingroup l3_algos_basic
1069 def Hexahedron(self, algo=Hexa, geom=0):
1070 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1071 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1072 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1073 elif geom == 0: algo, geom = Hexa, algo
1074 return Mesh_Hexahedron(self, algo, geom)
1076 ## Deprecated, used only for compatibility!
1077 # @return an instance of Mesh_Netgen algorithm
1078 # @ingroup l3_algos_basic
1079 def Netgen(self, is3D, geom=0):
1080 return Mesh_Netgen(self, is3D, geom)
1082 ## Creates a projection 1D algorithm for edges.
1083 # If the optional \a geom parameter is not set, this algorithm is global.
1084 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1085 # @param geom If defined, the subshape to be meshed
1086 # @return an instance of Mesh_Projection1D algorithm
1087 # @ingroup l3_algos_proj
1088 def Projection1D(self, geom=0):
1089 return Mesh_Projection1D(self, geom)
1091 ## Creates a projection 2D algorithm for faces.
1092 # If the optional \a geom parameter is not set, this algorithm is global.
1093 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1094 # @param geom If defined, the subshape to be meshed
1095 # @return an instance of Mesh_Projection2D algorithm
1096 # @ingroup l3_algos_proj
1097 def Projection2D(self, geom=0):
1098 return Mesh_Projection2D(self, geom)
1100 ## Creates a projection 3D algorithm for solids.
1101 # If the optional \a geom parameter is not set, this algorithm is global.
1102 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1103 # @param geom If defined, the subshape to be meshed
1104 # @return an instance of Mesh_Projection3D algorithm
1105 # @ingroup l3_algos_proj
1106 def Projection3D(self, geom=0):
1107 return Mesh_Projection3D(self, geom)
1109 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1110 # If the optional \a geom parameter is not set, this algorithm is global.
1111 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1112 # @param geom If defined, the subshape to be meshed
1113 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1114 # @ingroup l3_algos_radialp l3_algos_3dextr
1115 def Prism(self, geom=0):
1119 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1120 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1121 if nbSolids == 0 or nbSolids == nbShells:
1122 return Mesh_Prism3D(self, geom)
1123 return Mesh_RadialPrism3D(self, geom)
1125 ## Evaluates size of prospective mesh on a shape
1126 # @return True or False
1127 def Evaluate(self, geom=0):
1128 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1130 geom = self.mesh.GetShapeToMesh()
1133 return self.smeshpyD.Evaluate(self.mesh, geom)
1136 ## Computes the mesh and returns the status of the computation
1137 # @return True or False
1138 # @ingroup l2_construct
1139 def Compute(self, geom=0):
1140 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1142 geom = self.mesh.GetShapeToMesh()
1147 ok = self.smeshpyD.Compute(self.mesh, geom)
1148 except SALOME.SALOME_Exception, ex:
1149 print "Mesh computation failed, exception caught:"
1150 print " ", ex.details.text
1153 print "Mesh computation failed, exception caught:"
1154 traceback.print_exc()
1156 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1159 if err.isGlobalAlgo:
1167 reason = '%s %sD algorithm is missing' % (glob, dim)
1168 elif err.state == HYP_MISSING:
1169 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1170 % (glob, dim, name, dim))
1171 elif err.state == HYP_NOTCONFORM:
1172 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1173 elif err.state == HYP_BAD_PARAMETER:
1174 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1175 % ( glob, dim, name ))
1176 elif err.state == HYP_BAD_GEOMETRY:
1177 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1178 'geometry' % ( glob, dim, name ))
1180 reason = "For unknown reason."+\
1181 " Revise Mesh.Compute() implementation in smeshDC.py!"
1183 if allReasons != "":
1186 allReasons += reason
1188 if allReasons != "":
1189 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1193 print '"' + GetName(self.mesh) + '"',"has not been computed."
1196 if salome.sg.hasDesktop():
1197 smeshgui = salome.ImportComponentGUI("SMESH")
1198 smeshgui.Init(self.mesh.GetStudyId())
1199 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1200 salome.sg.updateObjBrowser(1)
1204 ## Removes all nodes and elements
1205 # @ingroup l2_construct
1208 if salome.sg.hasDesktop():
1209 smeshgui = salome.ImportComponentGUI("SMESH")
1210 smeshgui.Init(self.mesh.GetStudyId())
1211 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1212 salome.sg.updateObjBrowser(1)
1214 ## Removes all nodes and elements of indicated shape
1215 # @ingroup l2_construct
1216 def ClearSubMesh(self, geomId):
1217 self.mesh.ClearSubMesh(geomId)
1218 if salome.sg.hasDesktop():
1219 smeshgui = salome.ImportComponentGUI("SMESH")
1220 smeshgui.Init(self.mesh.GetStudyId())
1221 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1222 salome.sg.updateObjBrowser(1)
1224 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1225 # @param fineness [0,-1] defines mesh fineness
1226 # @return True or False
1227 # @ingroup l3_algos_basic
1228 def AutomaticTetrahedralization(self, fineness=0):
1229 dim = self.MeshDimension()
1231 self.RemoveGlobalHypotheses()
1232 self.Segment().AutomaticLength(fineness)
1234 self.Triangle().LengthFromEdges()
1237 self.Tetrahedron(NETGEN)
1239 return self.Compute()
1241 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1242 # @param fineness [0,-1] defines mesh fineness
1243 # @return True or False
1244 # @ingroup l3_algos_basic
1245 def AutomaticHexahedralization(self, fineness=0):
1246 dim = self.MeshDimension()
1247 # assign the hypotheses
1248 self.RemoveGlobalHypotheses()
1249 self.Segment().AutomaticLength(fineness)
1256 return self.Compute()
1258 ## Assigns a hypothesis
1259 # @param hyp a hypothesis to assign
1260 # @param geom a subhape of mesh geometry
1261 # @return SMESH.Hypothesis_Status
1262 # @ingroup l2_hypotheses
1263 def AddHypothesis(self, hyp, geom=0):
1264 if isinstance( hyp, Mesh_Algorithm ):
1265 hyp = hyp.GetAlgorithm()
1270 geom = self.mesh.GetShapeToMesh()
1272 status = self.mesh.AddHypothesis(geom, hyp)
1273 isAlgo = hyp._narrow( SMESH_Algo )
1274 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1277 ## Unassigns a hypothesis
1278 # @param hyp a hypothesis to unassign
1279 # @param geom a subshape of mesh geometry
1280 # @return SMESH.Hypothesis_Status
1281 # @ingroup l2_hypotheses
1282 def RemoveHypothesis(self, hyp, geom=0):
1283 if isinstance( hyp, Mesh_Algorithm ):
1284 hyp = hyp.GetAlgorithm()
1289 status = self.mesh.RemoveHypothesis(geom, hyp)
1292 ## Gets the list of hypotheses added on a geometry
1293 # @param geom a subshape of mesh geometry
1294 # @return the sequence of SMESH_Hypothesis
1295 # @ingroup l2_hypotheses
1296 def GetHypothesisList(self, geom):
1297 return self.mesh.GetHypothesisList( geom )
1299 ## Removes all global hypotheses
1300 # @ingroup l2_hypotheses
1301 def RemoveGlobalHypotheses(self):
1302 current_hyps = self.mesh.GetHypothesisList( self.geom )
1303 for hyp in current_hyps:
1304 self.mesh.RemoveHypothesis( self.geom, hyp )
1308 ## Creates a mesh group based on the geometric object \a grp
1309 # and gives a \a name, \n if this parameter is not defined
1310 # the name is the same as the geometric group name \n
1311 # Note: Works like GroupOnGeom().
1312 # @param grp a geometric group, a vertex, an edge, a face or a solid
1313 # @param name the name of the mesh group
1314 # @return SMESH_GroupOnGeom
1315 # @ingroup l2_grps_create
1316 def Group(self, grp, name=""):
1317 return self.GroupOnGeom(grp, name)
1319 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1320 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1321 # @param f the file name
1322 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1323 # @param opt boolean parameter for creating/not creating
1324 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1325 # @ingroup l2_impexp
1326 def ExportToMED(self, f, version, opt=0):
1327 self.mesh.ExportToMED(f, opt, version)
1329 ## Exports the mesh in a file in MED format
1330 # @param f is the file name
1331 # @param auto_groups boolean parameter for creating/not creating
1332 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1333 # the typical use is auto_groups=false.
1334 # @param version MED format version(MED_V2_1 or MED_V2_2)
1335 # @ingroup l2_impexp
1336 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1337 self.mesh.ExportToMED(f, auto_groups, version)
1339 ## Exports the mesh in a file in DAT format
1340 # @param f the file name
1341 # @ingroup l2_impexp
1342 def ExportDAT(self, f):
1343 self.mesh.ExportDAT(f)
1345 ## Exports the mesh in a file in UNV format
1346 # @param f the file name
1347 # @ingroup l2_impexp
1348 def ExportUNV(self, f):
1349 self.mesh.ExportUNV(f)
1351 ## Export the mesh in a file in STL format
1352 # @param f the file name
1353 # @param ascii defines the file encoding
1354 # @ingroup l2_impexp
1355 def ExportSTL(self, f, ascii=1):
1356 self.mesh.ExportSTL(f, ascii)
1359 # Operations with groups:
1360 # ----------------------
1362 ## Creates an empty mesh group
1363 # @param elementType the type of elements in the group
1364 # @param name the name of the mesh group
1365 # @return SMESH_Group
1366 # @ingroup l2_grps_create
1367 def CreateEmptyGroup(self, elementType, name):
1368 return self.mesh.CreateGroup(elementType, name)
1370 ## Creates a mesh group based on the geometrical object \a grp
1371 # and gives a \a name, \n if this parameter is not defined
1372 # the name is the same as the geometrical group name
1373 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1374 # @param name the name of the mesh group
1375 # @param typ the type of elements in the group. If not set, it is
1376 # automatically detected by the type of the geometry
1377 # @return SMESH_GroupOnGeom
1378 # @ingroup l2_grps_create
1379 def GroupOnGeom(self, grp, name="", typ=None):
1381 name = grp.GetName()
1384 tgeo = str(grp.GetShapeType())
1385 if tgeo == "VERTEX":
1387 elif tgeo == "EDGE":
1389 elif tgeo == "FACE":
1391 elif tgeo == "SOLID":
1393 elif tgeo == "SHELL":
1395 elif tgeo == "COMPOUND":
1396 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1397 print "Mesh.Group: empty geometric group", GetName( grp )
1399 tgeo = self.geompyD.GetType(grp)
1400 if tgeo == geompyDC.ShapeType["VERTEX"]:
1402 elif tgeo == geompyDC.ShapeType["EDGE"]:
1404 elif tgeo == geompyDC.ShapeType["FACE"]:
1406 elif tgeo == geompyDC.ShapeType["SOLID"]:
1410 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1413 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1415 ## Creates a mesh group by the given ids of elements
1416 # @param groupName the name of the mesh group
1417 # @param elementType the type of elements in the group
1418 # @param elemIDs the list of ids
1419 # @return SMESH_Group
1420 # @ingroup l2_grps_create
1421 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1422 group = self.mesh.CreateGroup(elementType, groupName)
1426 ## Creates a mesh group by the given conditions
1427 # @param groupName the name of the mesh group
1428 # @param elementType the type of elements in the group
1429 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1430 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1431 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1432 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1433 # @return SMESH_Group
1434 # @ingroup l2_grps_create
1438 CritType=FT_Undefined,
1441 UnaryOp=FT_Undefined):
1442 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1443 group = self.MakeGroupByCriterion(groupName, aCriterion)
1446 ## Creates a mesh group by the given criterion
1447 # @param groupName the name of the mesh group
1448 # @param Criterion the instance of Criterion class
1449 # @return SMESH_Group
1450 # @ingroup l2_grps_create
1451 def MakeGroupByCriterion(self, groupName, Criterion):
1452 aFilterMgr = self.smeshpyD.CreateFilterManager()
1453 aFilter = aFilterMgr.CreateFilter()
1455 aCriteria.append(Criterion)
1456 aFilter.SetCriteria(aCriteria)
1457 group = self.MakeGroupByFilter(groupName, aFilter)
1460 ## Creates a mesh group by the given criteria (list of criteria)
1461 # @param groupName the name of the mesh group
1462 # @param theCriteria the list of criteria
1463 # @return SMESH_Group
1464 # @ingroup l2_grps_create
1465 def MakeGroupByCriteria(self, groupName, theCriteria):
1466 aFilterMgr = self.smeshpyD.CreateFilterManager()
1467 aFilter = aFilterMgr.CreateFilter()
1468 aFilter.SetCriteria(theCriteria)
1469 group = self.MakeGroupByFilter(groupName, aFilter)
1472 ## Creates a mesh group by the given filter
1473 # @param groupName the name of the mesh group
1474 # @param theFilter the instance of Filter class
1475 # @return SMESH_Group
1476 # @ingroup l2_grps_create
1477 def MakeGroupByFilter(self, groupName, theFilter):
1478 anIds = theFilter.GetElementsId(self.mesh)
1479 anElemType = theFilter.GetElementType()
1480 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1483 ## Passes mesh elements through the given filter and return IDs of fitting elements
1484 # @param theFilter SMESH_Filter
1485 # @return a list of ids
1486 # @ingroup l1_controls
1487 def GetIdsFromFilter(self, theFilter):
1488 return theFilter.GetElementsId(self.mesh)
1490 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1491 # Returns a list of special structures (borders).
1492 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1493 # @ingroup l1_controls
1494 def GetFreeBorders(self):
1495 aFilterMgr = self.smeshpyD.CreateFilterManager()
1496 aPredicate = aFilterMgr.CreateFreeEdges()
1497 aPredicate.SetMesh(self.mesh)
1498 aBorders = aPredicate.GetBorders()
1502 # @ingroup l2_grps_delete
1503 def RemoveGroup(self, group):
1504 self.mesh.RemoveGroup(group)
1506 ## Removes a group with its contents
1507 # @ingroup l2_grps_delete
1508 def RemoveGroupWithContents(self, group):
1509 self.mesh.RemoveGroupWithContents(group)
1511 ## Gets the list of groups existing in the mesh
1512 # @return a sequence of SMESH_GroupBase
1513 # @ingroup l2_grps_create
1514 def GetGroups(self):
1515 return self.mesh.GetGroups()
1517 ## Gets the number of groups existing in the mesh
1518 # @return the quantity of groups as an integer value
1519 # @ingroup l2_grps_create
1521 return self.mesh.NbGroups()
1523 ## Gets the list of names of groups existing in the mesh
1524 # @return list of strings
1525 # @ingroup l2_grps_create
1526 def GetGroupNames(self):
1527 groups = self.GetGroups()
1529 for group in groups:
1530 names.append(group.GetName())
1533 ## Produces a union of two groups
1534 # A new group is created. All mesh elements that are
1535 # present in the initial groups are added to the new one
1536 # @return an instance of SMESH_Group
1537 # @ingroup l2_grps_operon
1538 def UnionGroups(self, group1, group2, name):
1539 return self.mesh.UnionGroups(group1, group2, name)
1541 ## Produces a union list of groups
1542 # New group is created. All mesh elements that are present in
1543 # initial groups are added to the new one
1544 # @return an instance of SMESH_Group
1545 # @ingroup l2_grps_operon
1546 def UnionListOfGroups(self, groups, name):
1547 return self.mesh.UnionListOfGroups(groups, name)
1549 ## Prodices an intersection of two groups
1550 # A new group is created. All mesh elements that are common
1551 # for the two initial groups are added to the new one.
1552 # @return an instance of SMESH_Group
1553 # @ingroup l2_grps_operon
1554 def IntersectGroups(self, group1, group2, name):
1555 return self.mesh.IntersectGroups(group1, group2, name)
1557 ## Produces an intersection of groups
1558 # New group is created. All mesh elements that are present in all
1559 # initial groups simultaneously are added to the new one
1560 # @return an instance of SMESH_Group
1561 # @ingroup l2_grps_operon
1562 def IntersectListOfGroups(self, groups, name):
1563 return self.mesh.IntersectListOfGroups(groups, name)
1565 ## Produces a cut of two groups
1566 # A new group is created. All mesh elements that are present in
1567 # the main group but are not present in the tool group are added to the new one
1568 # @return an instance of SMESH_Group
1569 # @ingroup l2_grps_operon
1570 def CutGroups(self, main_group, tool_group, name):
1571 return self.mesh.CutGroups(main_group, tool_group, name)
1573 ## Produces a cut of groups
1574 # A new group is created. All mesh elements that are present in main groups
1575 # but do not present in tool groups are added to the new one
1576 # @return an instance of SMESH_Group
1577 # @ingroup l2_grps_operon
1578 def CutListOfGroups(self, main_groups, tool_groups, name):
1579 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1581 ## Produces a group of elements with specified element type using list of existing groups
1582 # A new group is created. System
1583 # 1) extract all nodes on which groups elements are built
1584 # 2) combine all elements of specified dimension laying on these nodes
1585 # @return an instance of SMESH_Group
1586 # @ingroup l2_grps_operon
1587 def CreateDimGroup(self, groups, elem_type, name):
1588 return self.mesh.CreateDimGroup(groups, elem_type, name)
1591 ## Convert group on geom into standalone group
1592 # @ingroup l2_grps_delete
1593 def ConvertToStandalone(self, group):
1594 return self.mesh.ConvertToStandalone(group)
1596 # Get some info about mesh:
1597 # ------------------------
1599 ## Returns the log of nodes and elements added or removed
1600 # since the previous clear of the log.
1601 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1602 # @return list of log_block structures:
1607 # @ingroup l1_auxiliary
1608 def GetLog(self, clearAfterGet):
1609 return self.mesh.GetLog(clearAfterGet)
1611 ## Clears the log of nodes and elements added or removed since the previous
1612 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1613 # @ingroup l1_auxiliary
1615 self.mesh.ClearLog()
1617 ## Toggles auto color mode on the object.
1618 # @param theAutoColor the flag which toggles auto color mode.
1619 # @ingroup l1_auxiliary
1620 def SetAutoColor(self, theAutoColor):
1621 self.mesh.SetAutoColor(theAutoColor)
1623 ## Gets flag of object auto color mode.
1624 # @return True or False
1625 # @ingroup l1_auxiliary
1626 def GetAutoColor(self):
1627 return self.mesh.GetAutoColor()
1629 ## Gets the internal ID
1630 # @return integer value, which is the internal Id of the mesh
1631 # @ingroup l1_auxiliary
1633 return self.mesh.GetId()
1636 # @return integer value, which is the study Id of the mesh
1637 # @ingroup l1_auxiliary
1638 def GetStudyId(self):
1639 return self.mesh.GetStudyId()
1641 ## Checks the group names for duplications.
1642 # Consider the maximum group name length stored in MED file.
1643 # @return True or False
1644 # @ingroup l1_auxiliary
1645 def HasDuplicatedGroupNamesMED(self):
1646 return self.mesh.HasDuplicatedGroupNamesMED()
1648 ## Obtains the mesh editor tool
1649 # @return an instance of SMESH_MeshEditor
1650 # @ingroup l1_modifying
1651 def GetMeshEditor(self):
1652 return self.mesh.GetMeshEditor()
1655 # @return an instance of SALOME_MED::MESH
1656 # @ingroup l1_auxiliary
1657 def GetMEDMesh(self):
1658 return self.mesh.GetMEDMesh()
1661 # Get informations about mesh contents:
1662 # ------------------------------------
1664 ## Gets the mesh stattistic
1665 # @return dictionary type element - count of elements
1666 # @ingroup l1_meshinfo
1667 def GetMeshInfo(self, obj = None):
1668 if not obj: obj = self.mesh
1669 return self.smeshpyD.GetMeshInfo(obj)
1671 ## Returns the number of nodes in the mesh
1672 # @return an integer value
1673 # @ingroup l1_meshinfo
1675 return self.mesh.NbNodes()
1677 ## Returns the number of elements in the mesh
1678 # @return an integer value
1679 # @ingroup l1_meshinfo
1680 def NbElements(self):
1681 return self.mesh.NbElements()
1683 ## Returns the number of 0d elements in the mesh
1684 # @return an integer value
1685 # @ingroup l1_meshinfo
1686 def Nb0DElements(self):
1687 return self.mesh.Nb0DElements()
1689 ## Returns the number of edges in the mesh
1690 # @return an integer value
1691 # @ingroup l1_meshinfo
1693 return self.mesh.NbEdges()
1695 ## Returns the number of edges with the given order in the mesh
1696 # @param elementOrder the order of elements:
1697 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1698 # @return an integer value
1699 # @ingroup l1_meshinfo
1700 def NbEdgesOfOrder(self, elementOrder):
1701 return self.mesh.NbEdgesOfOrder(elementOrder)
1703 ## Returns the number of faces in the mesh
1704 # @return an integer value
1705 # @ingroup l1_meshinfo
1707 return self.mesh.NbFaces()
1709 ## Returns the number of faces with the given order in the mesh
1710 # @param elementOrder the order of elements:
1711 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1712 # @return an integer value
1713 # @ingroup l1_meshinfo
1714 def NbFacesOfOrder(self, elementOrder):
1715 return self.mesh.NbFacesOfOrder(elementOrder)
1717 ## Returns the number of triangles in the mesh
1718 # @return an integer value
1719 # @ingroup l1_meshinfo
1720 def NbTriangles(self):
1721 return self.mesh.NbTriangles()
1723 ## Returns the number of triangles with the given order in the mesh
1724 # @param elementOrder is the order of elements:
1725 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1726 # @return an integer value
1727 # @ingroup l1_meshinfo
1728 def NbTrianglesOfOrder(self, elementOrder):
1729 return self.mesh.NbTrianglesOfOrder(elementOrder)
1731 ## Returns the number of quadrangles in the mesh
1732 # @return an integer value
1733 # @ingroup l1_meshinfo
1734 def NbQuadrangles(self):
1735 return self.mesh.NbQuadrangles()
1737 ## Returns the number of quadrangles with the given order in the mesh
1738 # @param elementOrder the order of elements:
1739 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1740 # @return an integer value
1741 # @ingroup l1_meshinfo
1742 def NbQuadranglesOfOrder(self, elementOrder):
1743 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1745 ## Returns the number of polygons in the mesh
1746 # @return an integer value
1747 # @ingroup l1_meshinfo
1748 def NbPolygons(self):
1749 return self.mesh.NbPolygons()
1751 ## Returns the number of volumes in the mesh
1752 # @return an integer value
1753 # @ingroup l1_meshinfo
1754 def NbVolumes(self):
1755 return self.mesh.NbVolumes()
1757 ## Returns the number of volumes with the given order in the mesh
1758 # @param elementOrder the order of elements:
1759 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1760 # @return an integer value
1761 # @ingroup l1_meshinfo
1762 def NbVolumesOfOrder(self, elementOrder):
1763 return self.mesh.NbVolumesOfOrder(elementOrder)
1765 ## Returns the number of tetrahedrons in the mesh
1766 # @return an integer value
1767 # @ingroup l1_meshinfo
1769 return self.mesh.NbTetras()
1771 ## Returns the number of tetrahedrons with the given order in the mesh
1772 # @param elementOrder the order of elements:
1773 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1774 # @return an integer value
1775 # @ingroup l1_meshinfo
1776 def NbTetrasOfOrder(self, elementOrder):
1777 return self.mesh.NbTetrasOfOrder(elementOrder)
1779 ## Returns the number of hexahedrons in the mesh
1780 # @return an integer value
1781 # @ingroup l1_meshinfo
1783 return self.mesh.NbHexas()
1785 ## Returns the number of hexahedrons with the given order in the mesh
1786 # @param elementOrder the order of elements:
1787 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1788 # @return an integer value
1789 # @ingroup l1_meshinfo
1790 def NbHexasOfOrder(self, elementOrder):
1791 return self.mesh.NbHexasOfOrder(elementOrder)
1793 ## Returns the number of pyramids in the mesh
1794 # @return an integer value
1795 # @ingroup l1_meshinfo
1796 def NbPyramids(self):
1797 return self.mesh.NbPyramids()
1799 ## Returns the number of pyramids with the given order in the mesh
1800 # @param elementOrder the order of elements:
1801 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1802 # @return an integer value
1803 # @ingroup l1_meshinfo
1804 def NbPyramidsOfOrder(self, elementOrder):
1805 return self.mesh.NbPyramidsOfOrder(elementOrder)
1807 ## Returns the number of prisms in the mesh
1808 # @return an integer value
1809 # @ingroup l1_meshinfo
1811 return self.mesh.NbPrisms()
1813 ## Returns the number of prisms with the given order in the mesh
1814 # @param elementOrder the order of elements:
1815 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1816 # @return an integer value
1817 # @ingroup l1_meshinfo
1818 def NbPrismsOfOrder(self, elementOrder):
1819 return self.mesh.NbPrismsOfOrder(elementOrder)
1821 ## Returns the number of polyhedrons in the mesh
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1824 def NbPolyhedrons(self):
1825 return self.mesh.NbPolyhedrons()
1827 ## Returns the number of submeshes in the mesh
1828 # @return an integer value
1829 # @ingroup l1_meshinfo
1830 def NbSubMesh(self):
1831 return self.mesh.NbSubMesh()
1833 ## Returns the list of mesh elements IDs
1834 # @return the list of integer values
1835 # @ingroup l1_meshinfo
1836 def GetElementsId(self):
1837 return self.mesh.GetElementsId()
1839 ## Returns the list of IDs of mesh elements with the given type
1840 # @param elementType the required type of elements
1841 # @return list of integer values
1842 # @ingroup l1_meshinfo
1843 def GetElementsByType(self, elementType):
1844 return self.mesh.GetElementsByType(elementType)
1846 ## Returns the list of mesh nodes IDs
1847 # @return the list of integer values
1848 # @ingroup l1_meshinfo
1849 def GetNodesId(self):
1850 return self.mesh.GetNodesId()
1852 # Get the information about mesh elements:
1853 # ------------------------------------
1855 ## Returns the type of mesh element
1856 # @return the value from SMESH::ElementType enumeration
1857 # @ingroup l1_meshinfo
1858 def GetElementType(self, id, iselem):
1859 return self.mesh.GetElementType(id, iselem)
1861 ## Returns the list of submesh elements IDs
1862 # @param Shape a geom object(subshape) IOR
1863 # Shape must be the subshape of a ShapeToMesh()
1864 # @return the list of integer values
1865 # @ingroup l1_meshinfo
1866 def GetSubMeshElementsId(self, Shape):
1867 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1868 ShapeID = Shape.GetSubShapeIndices()[0]
1871 return self.mesh.GetSubMeshElementsId(ShapeID)
1873 ## Returns the list of submesh nodes IDs
1874 # @param Shape a geom object(subshape) IOR
1875 # Shape must be the subshape of a ShapeToMesh()
1876 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1877 # @return the list of integer values
1878 # @ingroup l1_meshinfo
1879 def GetSubMeshNodesId(self, Shape, all):
1880 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1881 ShapeID = Shape.GetSubShapeIndices()[0]
1884 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1886 ## Returns type of elements on given shape
1887 # @param Shape a geom object(subshape) IOR
1888 # Shape must be a subshape of a ShapeToMesh()
1889 # @return element type
1890 # @ingroup l1_meshinfo
1891 def GetSubMeshElementType(self, Shape):
1892 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1893 ShapeID = Shape.GetSubShapeIndices()[0]
1896 return self.mesh.GetSubMeshElementType(ShapeID)
1898 ## Gets the mesh description
1899 # @return string value
1900 # @ingroup l1_meshinfo
1902 return self.mesh.Dump()
1905 # Get the information about nodes and elements of a mesh by its IDs:
1906 # -----------------------------------------------------------
1908 ## Gets XYZ coordinates of a node
1909 # \n If there is no nodes for the given ID - returns an empty list
1910 # @return a list of double precision values
1911 # @ingroup l1_meshinfo
1912 def GetNodeXYZ(self, id):
1913 return self.mesh.GetNodeXYZ(id)
1915 ## Returns list of IDs of inverse elements for the given node
1916 # \n If there is no node for the given ID - returns an empty list
1917 # @return a list of integer values
1918 # @ingroup l1_meshinfo
1919 def GetNodeInverseElements(self, id):
1920 return self.mesh.GetNodeInverseElements(id)
1922 ## @brief Returns the position of a node on the shape
1923 # @return SMESH::NodePosition
1924 # @ingroup l1_meshinfo
1925 def GetNodePosition(self,NodeID):
1926 return self.mesh.GetNodePosition(NodeID)
1928 ## If the given element is a node, returns the ID of shape
1929 # \n If there is no node for the given ID - returns -1
1930 # @return an integer value
1931 # @ingroup l1_meshinfo
1932 def GetShapeID(self, id):
1933 return self.mesh.GetShapeID(id)
1935 ## Returns the ID of the result shape after
1936 # FindShape() from SMESH_MeshEditor for the given element
1937 # \n If there is no element for the given ID - returns -1
1938 # @return an integer value
1939 # @ingroup l1_meshinfo
1940 def GetShapeIDForElem(self,id):
1941 return self.mesh.GetShapeIDForElem(id)
1943 ## Returns the number of nodes for the given element
1944 # \n If there is no element for the given ID - returns -1
1945 # @return an integer value
1946 # @ingroup l1_meshinfo
1947 def GetElemNbNodes(self, id):
1948 return self.mesh.GetElemNbNodes(id)
1950 ## Returns the node ID the given index for the given element
1951 # \n If there is no element for the given ID - returns -1
1952 # \n If there is no node for the given index - returns -2
1953 # @return an integer value
1954 # @ingroup l1_meshinfo
1955 def GetElemNode(self, id, index):
1956 return self.mesh.GetElemNode(id, index)
1958 ## Returns the IDs of nodes of the given element
1959 # @return a list of integer values
1960 # @ingroup l1_meshinfo
1961 def GetElemNodes(self, id):
1962 return self.mesh.GetElemNodes(id)
1964 ## Returns true if the given node is the medium node in the given quadratic element
1965 # @ingroup l1_meshinfo
1966 def IsMediumNode(self, elementID, nodeID):
1967 return self.mesh.IsMediumNode(elementID, nodeID)
1969 ## Returns true if the given node is the medium node in one of quadratic elements
1970 # @ingroup l1_meshinfo
1971 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1972 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1974 ## Returns the number of edges for the given element
1975 # @ingroup l1_meshinfo
1976 def ElemNbEdges(self, id):
1977 return self.mesh.ElemNbEdges(id)
1979 ## Returns the number of faces for the given element
1980 # @ingroup l1_meshinfo
1981 def ElemNbFaces(self, id):
1982 return self.mesh.ElemNbFaces(id)
1984 ## Returns true if the given element is a polygon
1985 # @ingroup l1_meshinfo
1986 def IsPoly(self, id):
1987 return self.mesh.IsPoly(id)
1989 ## Returns true if the given element is quadratic
1990 # @ingroup l1_meshinfo
1991 def IsQuadratic(self, id):
1992 return self.mesh.IsQuadratic(id)
1994 ## Returns XYZ coordinates of the barycenter of the given element
1995 # \n If there is no element for the given ID - returns an empty list
1996 # @return a list of three double values
1997 # @ingroup l1_meshinfo
1998 def BaryCenter(self, id):
1999 return self.mesh.BaryCenter(id)
2002 # Mesh edition (SMESH_MeshEditor functionality):
2003 # ---------------------------------------------
2005 ## Removes the elements from the mesh by ids
2006 # @param IDsOfElements is a list of ids of elements to remove
2007 # @return True or False
2008 # @ingroup l2_modif_del
2009 def RemoveElements(self, IDsOfElements):
2010 return self.editor.RemoveElements(IDsOfElements)
2012 ## Removes nodes from mesh by ids
2013 # @param IDsOfNodes is a list of ids of nodes to remove
2014 # @return True or False
2015 # @ingroup l2_modif_del
2016 def RemoveNodes(self, IDsOfNodes):
2017 return self.editor.RemoveNodes(IDsOfNodes)
2019 ## Add a node to the mesh by coordinates
2020 # @return Id of the new node
2021 # @ingroup l2_modif_add
2022 def AddNode(self, x, y, z):
2023 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2024 self.mesh.SetParameters(Parameters)
2025 return self.editor.AddNode( x, y, z)
2027 ## Creates a 0D element on a node with given number.
2028 # @param IDOfNode the ID of node for creation of the element.
2029 # @return the Id of the new 0D element
2030 # @ingroup l2_modif_add
2031 def Add0DElement(self, IDOfNode):
2032 return self.editor.Add0DElement(IDOfNode)
2034 ## Creates a linear or quadratic edge (this is determined
2035 # by the number of given nodes).
2036 # @param IDsOfNodes the list of node IDs for creation of the element.
2037 # The order of nodes in this list should correspond to the description
2038 # of MED. \n This description is located by the following link:
2039 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2040 # @return the Id of the new edge
2041 # @ingroup l2_modif_add
2042 def AddEdge(self, IDsOfNodes):
2043 return self.editor.AddEdge(IDsOfNodes)
2045 ## Creates a linear or quadratic face (this is determined
2046 # by the number of given nodes).
2047 # @param IDsOfNodes the list of node IDs for creation of the element.
2048 # The order of nodes in this list should correspond to the description
2049 # of MED. \n This description is located by the following link:
2050 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2051 # @return the Id of the new face
2052 # @ingroup l2_modif_add
2053 def AddFace(self, IDsOfNodes):
2054 return self.editor.AddFace(IDsOfNodes)
2056 ## Adds a polygonal face to the mesh by the list of node IDs
2057 # @param IdsOfNodes the list of node IDs for creation of the element.
2058 # @return the Id of the new face
2059 # @ingroup l2_modif_add
2060 def AddPolygonalFace(self, IdsOfNodes):
2061 return self.editor.AddPolygonalFace(IdsOfNodes)
2063 ## Creates both simple and quadratic volume (this is determined
2064 # by the number of given nodes).
2065 # @param IDsOfNodes the list of node IDs for creation of the element.
2066 # The order of nodes in this list should correspond to the description
2067 # of MED. \n This description is located by the following link:
2068 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2069 # @return the Id of the new volumic element
2070 # @ingroup l2_modif_add
2071 def AddVolume(self, IDsOfNodes):
2072 return self.editor.AddVolume(IDsOfNodes)
2074 ## Creates a volume of many faces, giving nodes for each face.
2075 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2076 # @param Quantities the list of integer values, Quantities[i]
2077 # gives the quantity of nodes in face number i.
2078 # @return the Id of the new volumic element
2079 # @ingroup l2_modif_add
2080 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2081 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2083 ## Creates a volume of many faces, giving the IDs of the existing faces.
2084 # @param IdsOfFaces the list of face IDs for volume creation.
2086 # Note: The created volume will refer only to the nodes
2087 # of the given faces, not to the faces themselves.
2088 # @return the Id of the new volumic element
2089 # @ingroup l2_modif_add
2090 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2091 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2094 ## @brief Binds a node to a vertex
2095 # @param NodeID a node ID
2096 # @param Vertex a vertex or vertex ID
2097 # @return True if succeed else raises an exception
2098 # @ingroup l2_modif_add
2099 def SetNodeOnVertex(self, NodeID, Vertex):
2100 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2101 VertexID = Vertex.GetSubShapeIndices()[0]
2105 self.editor.SetNodeOnVertex(NodeID, VertexID)
2106 except SALOME.SALOME_Exception, inst:
2107 raise ValueError, inst.details.text
2111 ## @brief Stores the node position on an edge
2112 # @param NodeID a node ID
2113 # @param Edge an edge or edge ID
2114 # @param paramOnEdge a parameter on the edge where the node is located
2115 # @return True if succeed else raises an exception
2116 # @ingroup l2_modif_add
2117 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2118 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2119 EdgeID = Edge.GetSubShapeIndices()[0]
2123 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2124 except SALOME.SALOME_Exception, inst:
2125 raise ValueError, inst.details.text
2128 ## @brief Stores node position on a face
2129 # @param NodeID a node ID
2130 # @param Face a face or face ID
2131 # @param u U parameter on the face where the node is located
2132 # @param v V parameter on the face where the node is located
2133 # @return True if succeed else raises an exception
2134 # @ingroup l2_modif_add
2135 def SetNodeOnFace(self, NodeID, Face, u, v):
2136 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2137 FaceID = Face.GetSubShapeIndices()[0]
2141 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2142 except SALOME.SALOME_Exception, inst:
2143 raise ValueError, inst.details.text
2146 ## @brief Binds a node to a solid
2147 # @param NodeID a node ID
2148 # @param Solid a solid or solid ID
2149 # @return True if succeed else raises an exception
2150 # @ingroup l2_modif_add
2151 def SetNodeInVolume(self, NodeID, Solid):
2152 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2153 SolidID = Solid.GetSubShapeIndices()[0]
2157 self.editor.SetNodeInVolume(NodeID, SolidID)
2158 except SALOME.SALOME_Exception, inst:
2159 raise ValueError, inst.details.text
2162 ## @brief Bind an element to a shape
2163 # @param ElementID an element ID
2164 # @param Shape a shape or shape ID
2165 # @return True if succeed else raises an exception
2166 # @ingroup l2_modif_add
2167 def SetMeshElementOnShape(self, ElementID, Shape):
2168 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2169 ShapeID = Shape.GetSubShapeIndices()[0]
2173 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2174 except SALOME.SALOME_Exception, inst:
2175 raise ValueError, inst.details.text
2179 ## Moves the node with the given id
2180 # @param NodeID the id of the node
2181 # @param x a new X coordinate
2182 # @param y a new Y coordinate
2183 # @param z a new Z coordinate
2184 # @return True if succeed else False
2185 # @ingroup l2_modif_movenode
2186 def MoveNode(self, NodeID, x, y, z):
2187 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2188 self.mesh.SetParameters(Parameters)
2189 return self.editor.MoveNode(NodeID, x, y, z)
2191 ## Finds the node closest to a point and moves it to a point location
2192 # @param x the X coordinate of a point
2193 # @param y the Y coordinate of a point
2194 # @param z the Z coordinate of a point
2195 # @param NodeID if specified (>0), the node with this ID is moved,
2196 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2197 # @return the ID of a node
2198 # @ingroup l2_modif_throughp
2199 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2200 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2201 self.mesh.SetParameters(Parameters)
2202 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2204 ## Finds the node closest to a point
2205 # @param x the X coordinate of a point
2206 # @param y the Y coordinate of a point
2207 # @param z the Z coordinate of a point
2208 # @return the ID of a node
2209 # @ingroup l2_modif_throughp
2210 def FindNodeClosestTo(self, x, y, z):
2211 #preview = self.mesh.GetMeshEditPreviewer()
2212 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2213 return self.editor.FindNodeClosestTo(x, y, z)
2215 ## Finds the elements where a point lays IN or ON
2216 # @param x the X coordinate of a point
2217 # @param y the Y coordinate of a point
2218 # @param z the Z coordinate of a point
2219 # @param elementType type of elements to find (SMESH.ALL type
2220 # means elements of any type excluding nodes and 0D elements)
2221 # @return list of IDs of found elements
2222 # @ingroup l2_modif_throughp
2223 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2224 return self.editor.FindElementsByPoint(x, y, z, elementType)
2227 ## Finds the node closest to a point and moves it to a point location
2228 # @param x the X coordinate of a point
2229 # @param y the Y coordinate of a point
2230 # @param z the Z coordinate of a point
2231 # @return the ID of a moved node
2232 # @ingroup l2_modif_throughp
2233 def MeshToPassThroughAPoint(self, x, y, z):
2234 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2236 ## Replaces two neighbour triangles sharing Node1-Node2 link
2237 # with the triangles built on the same 4 nodes but having other common link.
2238 # @param NodeID1 the ID of the first node
2239 # @param NodeID2 the ID of the second node
2240 # @return false if proper faces were not found
2241 # @ingroup l2_modif_invdiag
2242 def InverseDiag(self, NodeID1, NodeID2):
2243 return self.editor.InverseDiag(NodeID1, NodeID2)
2245 ## Replaces two neighbour triangles sharing Node1-Node2 link
2246 # with a quadrangle built on the same 4 nodes.
2247 # @param NodeID1 the ID of the first node
2248 # @param NodeID2 the ID of the second node
2249 # @return false if proper faces were not found
2250 # @ingroup l2_modif_unitetri
2251 def DeleteDiag(self, NodeID1, NodeID2):
2252 return self.editor.DeleteDiag(NodeID1, NodeID2)
2254 ## Reorients elements by ids
2255 # @param IDsOfElements if undefined reorients all mesh elements
2256 # @return True if succeed else False
2257 # @ingroup l2_modif_changori
2258 def Reorient(self, IDsOfElements=None):
2259 if IDsOfElements == None:
2260 IDsOfElements = self.GetElementsId()
2261 return self.editor.Reorient(IDsOfElements)
2263 ## Reorients all elements of the object
2264 # @param theObject mesh, submesh or group
2265 # @return True if succeed else False
2266 # @ingroup l2_modif_changori
2267 def ReorientObject(self, theObject):
2268 if ( isinstance( theObject, Mesh )):
2269 theObject = theObject.GetMesh()
2270 return self.editor.ReorientObject(theObject)
2272 ## Fuses the neighbouring triangles into quadrangles.
2273 # @param IDsOfElements The triangles to be fused,
2274 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2275 # @param MaxAngle is the maximum angle between element normals at which the fusion
2276 # is still performed; theMaxAngle is mesured in radians.
2277 # Also it could be a name of variable which defines angle in degrees.
2278 # @return TRUE in case of success, FALSE otherwise.
2279 # @ingroup l2_modif_unitetri
2280 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2282 if isinstance(MaxAngle,str):
2284 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2286 MaxAngle = DegreesToRadians(MaxAngle)
2287 if IDsOfElements == []:
2288 IDsOfElements = self.GetElementsId()
2289 self.mesh.SetParameters(Parameters)
2291 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2292 Functor = theCriterion
2294 Functor = self.smeshpyD.GetFunctor(theCriterion)
2295 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2297 ## Fuses the neighbouring triangles of the object into quadrangles
2298 # @param theObject is mesh, submesh or group
2299 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2300 # @param MaxAngle a max angle between element normals at which the fusion
2301 # is still performed; theMaxAngle is mesured in radians.
2302 # @return TRUE in case of success, FALSE otherwise.
2303 # @ingroup l2_modif_unitetri
2304 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2305 if ( isinstance( theObject, Mesh )):
2306 theObject = theObject.GetMesh()
2307 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2309 ## Splits quadrangles into triangles.
2310 # @param IDsOfElements the faces to be splitted.
2311 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2312 # @return TRUE in case of success, FALSE otherwise.
2313 # @ingroup l2_modif_cutquadr
2314 def QuadToTri (self, IDsOfElements, theCriterion):
2315 if IDsOfElements == []:
2316 IDsOfElements = self.GetElementsId()
2317 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2319 ## Splits quadrangles into triangles.
2320 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2321 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2322 # @return TRUE in case of success, FALSE otherwise.
2323 # @ingroup l2_modif_cutquadr
2324 def QuadToTriObject (self, theObject, theCriterion):
2325 if ( isinstance( theObject, Mesh )):
2326 theObject = theObject.GetMesh()
2327 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2329 ## Splits quadrangles into triangles.
2330 # @param IDsOfElements the faces to be splitted
2331 # @param Diag13 is used to choose a diagonal for splitting.
2332 # @return TRUE in case of success, FALSE otherwise.
2333 # @ingroup l2_modif_cutquadr
2334 def SplitQuad (self, IDsOfElements, Diag13):
2335 if IDsOfElements == []:
2336 IDsOfElements = self.GetElementsId()
2337 return self.editor.SplitQuad(IDsOfElements, Diag13)
2339 ## Splits quadrangles into triangles.
2340 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2341 # @param Diag13 is used to choose a diagonal for splitting.
2342 # @return TRUE in case of success, FALSE otherwise.
2343 # @ingroup l2_modif_cutquadr
2344 def SplitQuadObject (self, theObject, Diag13):
2345 if ( isinstance( theObject, Mesh )):
2346 theObject = theObject.GetMesh()
2347 return self.editor.SplitQuadObject(theObject, Diag13)
2349 ## Finds a better splitting of the given quadrangle.
2350 # @param IDOfQuad the ID of the quadrangle to be splitted.
2351 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2352 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2353 # diagonal is better, 0 if error occurs.
2354 # @ingroup l2_modif_cutquadr
2355 def BestSplit (self, IDOfQuad, theCriterion):
2356 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2358 ## Splits quadrangle faces near triangular facets of volumes
2360 # @ingroup l1_auxiliary
2361 def SplitQuadsNearTriangularFacets(self):
2362 faces_array = self.GetElementsByType(SMESH.FACE)
2363 for face_id in faces_array:
2364 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2365 quad_nodes = self.mesh.GetElemNodes(face_id)
2366 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2367 isVolumeFound = False
2368 for node1_elem in node1_elems:
2369 if not isVolumeFound:
2370 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2371 nb_nodes = self.GetElemNbNodes(node1_elem)
2372 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2373 volume_elem = node1_elem
2374 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2375 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2376 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2377 isVolumeFound = True
2378 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2379 self.SplitQuad([face_id], False) # diagonal 2-4
2380 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2381 isVolumeFound = True
2382 self.SplitQuad([face_id], True) # diagonal 1-3
2383 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2384 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2385 isVolumeFound = True
2386 self.SplitQuad([face_id], True) # diagonal 1-3
2388 ## @brief Splits hexahedrons into tetrahedrons.
2390 # This operation uses pattern mapping functionality for splitting.
2391 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2392 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2393 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2394 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2395 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2396 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2397 # @return TRUE in case of success, FALSE otherwise.
2398 # @ingroup l1_auxiliary
2399 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2400 # Pattern: 5.---------.6
2405 # (0,0,1) 4.---------.7 * |
2412 # (0,0,0) 0.---------.3
2413 pattern_tetra = "!!! Nb of points: \n 8 \n\
2423 !!! Indices of points of 6 tetras: \n\
2431 pattern = self.smeshpyD.GetPattern()
2432 isDone = pattern.LoadFromFile(pattern_tetra)
2434 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2437 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2438 isDone = pattern.MakeMesh(self.mesh, False, False)
2439 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2441 # split quafrangle faces near triangular facets of volumes
2442 self.SplitQuadsNearTriangularFacets()
2446 ## @brief Split hexahedrons into prisms.
2448 # Uses the pattern mapping functionality for splitting.
2449 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2450 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2451 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2452 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2453 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2454 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2455 # @return TRUE in case of success, FALSE otherwise.
2456 # @ingroup l1_auxiliary
2457 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2458 # Pattern: 5.---------.6
2463 # (0,0,1) 4.---------.7 |
2470 # (0,0,0) 0.---------.3
2471 pattern_prism = "!!! Nb of points: \n 8 \n\
2481 !!! Indices of points of 2 prisms: \n\
2485 pattern = self.smeshpyD.GetPattern()
2486 isDone = pattern.LoadFromFile(pattern_prism)
2488 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2491 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2492 isDone = pattern.MakeMesh(self.mesh, False, False)
2493 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2495 # Splits quafrangle faces near triangular facets of volumes
2496 self.SplitQuadsNearTriangularFacets()
2500 ## Smoothes elements
2501 # @param IDsOfElements the list if ids of elements to smooth
2502 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2503 # Note that nodes built on edges and boundary nodes are always fixed.
2504 # @param MaxNbOfIterations the maximum number of iterations
2505 # @param MaxAspectRatio varies in range [1.0, inf]
2506 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2507 # @return TRUE in case of success, FALSE otherwise.
2508 # @ingroup l2_modif_smooth
2509 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2510 MaxNbOfIterations, MaxAspectRatio, Method):
2511 if IDsOfElements == []:
2512 IDsOfElements = self.GetElementsId()
2513 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2514 self.mesh.SetParameters(Parameters)
2515 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2516 MaxNbOfIterations, MaxAspectRatio, Method)
2518 ## Smoothes elements which belong to the given object
2519 # @param theObject the object to smooth
2520 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2521 # Note that nodes built on edges and boundary nodes are always fixed.
2522 # @param MaxNbOfIterations the maximum number of iterations
2523 # @param MaxAspectRatio varies in range [1.0, inf]
2524 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2525 # @return TRUE in case of success, FALSE otherwise.
2526 # @ingroup l2_modif_smooth
2527 def SmoothObject(self, theObject, IDsOfFixedNodes,
2528 MaxNbOfIterations, MaxAspectRatio, Method):
2529 if ( isinstance( theObject, Mesh )):
2530 theObject = theObject.GetMesh()
2531 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2532 MaxNbOfIterations, MaxAspectRatio, Method)
2534 ## Parametrically smoothes the given elements
2535 # @param IDsOfElements the list if ids of elements to smooth
2536 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2537 # Note that nodes built on edges and boundary nodes are always fixed.
2538 # @param MaxNbOfIterations the maximum number of iterations
2539 # @param MaxAspectRatio varies in range [1.0, inf]
2540 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2541 # @return TRUE in case of success, FALSE otherwise.
2542 # @ingroup l2_modif_smooth
2543 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2544 MaxNbOfIterations, MaxAspectRatio, Method):
2545 if IDsOfElements == []:
2546 IDsOfElements = self.GetElementsId()
2547 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2548 self.mesh.SetParameters(Parameters)
2549 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2550 MaxNbOfIterations, MaxAspectRatio, Method)
2552 ## Parametrically smoothes the elements which belong to the given object
2553 # @param theObject the object to smooth
2554 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2555 # Note that nodes built on edges and boundary nodes are always fixed.
2556 # @param MaxNbOfIterations the maximum number of iterations
2557 # @param MaxAspectRatio varies in range [1.0, inf]
2558 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2559 # @return TRUE in case of success, FALSE otherwise.
2560 # @ingroup l2_modif_smooth
2561 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2562 MaxNbOfIterations, MaxAspectRatio, Method):
2563 if ( isinstance( theObject, Mesh )):
2564 theObject = theObject.GetMesh()
2565 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2566 MaxNbOfIterations, MaxAspectRatio, Method)
2568 ## Converts the mesh to quadratic, deletes old elements, replacing
2569 # them with quadratic with the same id.
2570 # @ingroup l2_modif_tofromqu
2571 def ConvertToQuadratic(self, theForce3d):
2572 self.editor.ConvertToQuadratic(theForce3d)
2574 ## Converts the mesh from quadratic to ordinary,
2575 # deletes old quadratic elements, \n replacing
2576 # them with ordinary mesh elements with the same id.
2577 # @return TRUE in case of success, FALSE otherwise.
2578 # @ingroup l2_modif_tofromqu
2579 def ConvertFromQuadratic(self):
2580 return self.editor.ConvertFromQuadratic()
2582 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2583 # @return TRUE if operation has been completed successfully, FALSE otherwise
2584 # @ingroup l2_modif_edit
2585 def Make2DMeshFrom3D(self):
2586 return self.editor. Make2DMeshFrom3D()
2588 ## Renumber mesh nodes
2589 # @ingroup l2_modif_renumber
2590 def RenumberNodes(self):
2591 self.editor.RenumberNodes()
2593 ## Renumber mesh elements
2594 # @ingroup l2_modif_renumber
2595 def RenumberElements(self):
2596 self.editor.RenumberElements()
2598 ## Generates new elements by rotation of the elements around the axis
2599 # @param IDsOfElements the list of ids of elements to sweep
2600 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2601 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2602 # @param NbOfSteps the number of steps
2603 # @param Tolerance tolerance
2604 # @param MakeGroups forces the generation of new groups from existing ones
2605 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2606 # of all steps, else - size of each step
2607 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2608 # @ingroup l2_modif_extrurev
2609 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2610 MakeGroups=False, TotalAngle=False):
2612 if isinstance(AngleInRadians,str):
2614 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2616 AngleInRadians = DegreesToRadians(AngleInRadians)
2617 if IDsOfElements == []:
2618 IDsOfElements = self.GetElementsId()
2619 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2620 Axis = self.smeshpyD.GetAxisStruct(Axis)
2621 Axis,AxisParameters = ParseAxisStruct(Axis)
2622 if TotalAngle and NbOfSteps:
2623 AngleInRadians /= NbOfSteps
2624 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2625 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2626 self.mesh.SetParameters(Parameters)
2628 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2629 AngleInRadians, NbOfSteps, Tolerance)
2630 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2633 ## Generates new elements by rotation of the elements of object around the axis
2634 # @param theObject object which elements should be sweeped
2635 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2636 # @param AngleInRadians the angle of Rotation
2637 # @param NbOfSteps number of steps
2638 # @param Tolerance tolerance
2639 # @param MakeGroups forces the generation of new groups from existing ones
2640 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2641 # of all steps, else - size of each step
2642 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2643 # @ingroup l2_modif_extrurev
2644 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2645 MakeGroups=False, TotalAngle=False):
2647 if isinstance(AngleInRadians,str):
2649 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2651 AngleInRadians = DegreesToRadians(AngleInRadians)
2652 if ( isinstance( theObject, Mesh )):
2653 theObject = theObject.GetMesh()
2654 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2655 Axis = self.smeshpyD.GetAxisStruct(Axis)
2656 Axis,AxisParameters = ParseAxisStruct(Axis)
2657 if TotalAngle and NbOfSteps:
2658 AngleInRadians /= NbOfSteps
2659 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2660 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2661 self.mesh.SetParameters(Parameters)
2663 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2664 NbOfSteps, Tolerance)
2665 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2668 ## Generates new elements by rotation of the elements of object around the axis
2669 # @param theObject object which elements should be sweeped
2670 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2671 # @param AngleInRadians the angle of Rotation
2672 # @param NbOfSteps number of steps
2673 # @param Tolerance tolerance
2674 # @param MakeGroups forces the generation of new groups from existing ones
2675 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2676 # of all steps, else - size of each step
2677 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2678 # @ingroup l2_modif_extrurev
2679 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2680 MakeGroups=False, TotalAngle=False):
2682 if isinstance(AngleInRadians,str):
2684 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2686 AngleInRadians = DegreesToRadians(AngleInRadians)
2687 if ( isinstance( theObject, Mesh )):
2688 theObject = theObject.GetMesh()
2689 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2690 Axis = self.smeshpyD.GetAxisStruct(Axis)
2691 Axis,AxisParameters = ParseAxisStruct(Axis)
2692 if TotalAngle and NbOfSteps:
2693 AngleInRadians /= NbOfSteps
2694 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2695 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2696 self.mesh.SetParameters(Parameters)
2698 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2699 NbOfSteps, Tolerance)
2700 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2703 ## Generates new elements by rotation of the elements of object around the axis
2704 # @param theObject object which elements should be sweeped
2705 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2706 # @param AngleInRadians the angle of Rotation
2707 # @param NbOfSteps number of steps
2708 # @param Tolerance tolerance
2709 # @param MakeGroups forces the generation of new groups from existing ones
2710 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2711 # of all steps, else - size of each step
2712 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2713 # @ingroup l2_modif_extrurev
2714 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2715 MakeGroups=False, TotalAngle=False):
2717 if isinstance(AngleInRadians,str):
2719 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2721 AngleInRadians = DegreesToRadians(AngleInRadians)
2722 if ( isinstance( theObject, Mesh )):
2723 theObject = theObject.GetMesh()
2724 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2725 Axis = self.smeshpyD.GetAxisStruct(Axis)
2726 Axis,AxisParameters = ParseAxisStruct(Axis)
2727 if TotalAngle and NbOfSteps:
2728 AngleInRadians /= NbOfSteps
2729 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2730 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2731 self.mesh.SetParameters(Parameters)
2733 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2734 NbOfSteps, Tolerance)
2735 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2738 ## Generates new elements by extrusion of the elements with given ids
2739 # @param IDsOfElements the list of elements ids for extrusion
2740 # @param StepVector vector, defining the direction and value of extrusion
2741 # @param NbOfSteps the number of steps
2742 # @param MakeGroups forces the generation of new groups from existing ones
2743 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2744 # @ingroup l2_modif_extrurev
2745 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2746 if IDsOfElements == []:
2747 IDsOfElements = self.GetElementsId()
2748 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2749 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2750 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2751 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2752 Parameters = StepVectorParameters + var_separator + Parameters
2753 self.mesh.SetParameters(Parameters)
2755 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2756 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2759 ## Generates new elements by extrusion of the elements with given ids
2760 # @param IDsOfElements is ids of elements
2761 # @param StepVector vector, defining the direction and value of extrusion
2762 # @param NbOfSteps the number of steps
2763 # @param ExtrFlags sets flags for extrusion
2764 # @param SewTolerance uses for comparing locations of nodes if flag
2765 # EXTRUSION_FLAG_SEW is set
2766 # @param MakeGroups forces the generation of new groups from existing ones
2767 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2768 # @ingroup l2_modif_extrurev
2769 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2770 ExtrFlags, SewTolerance, MakeGroups=False):
2771 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2772 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2774 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2775 ExtrFlags, SewTolerance)
2776 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2777 ExtrFlags, SewTolerance)
2780 ## Generates new elements by extrusion of the elements which belong to the object
2781 # @param theObject the object which elements should be processed
2782 # @param StepVector vector, defining the direction and value of extrusion
2783 # @param NbOfSteps the number of steps
2784 # @param MakeGroups forces the generation of new groups from existing ones
2785 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2786 # @ingroup l2_modif_extrurev
2787 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2788 if ( isinstance( theObject, Mesh )):
2789 theObject = theObject.GetMesh()
2790 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2791 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2792 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2793 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2794 Parameters = StepVectorParameters + var_separator + Parameters
2795 self.mesh.SetParameters(Parameters)
2797 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2798 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2801 ## Generates new elements by extrusion of the elements which belong to the object
2802 # @param theObject object which elements should be processed
2803 # @param StepVector vector, defining the direction and value of extrusion
2804 # @param NbOfSteps the number of steps
2805 # @param MakeGroups to generate new groups from existing ones
2806 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2807 # @ingroup l2_modif_extrurev
2808 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2809 if ( isinstance( theObject, Mesh )):
2810 theObject = theObject.GetMesh()
2811 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2812 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2813 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2814 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2815 Parameters = StepVectorParameters + var_separator + Parameters
2816 self.mesh.SetParameters(Parameters)
2818 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2819 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2822 ## Generates new elements by extrusion of the elements which belong to the object
2823 # @param theObject object which elements should be processed
2824 # @param StepVector vector, defining the direction and value of extrusion
2825 # @param NbOfSteps the number of steps
2826 # @param MakeGroups forces the generation of new groups from existing ones
2827 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2828 # @ingroup l2_modif_extrurev
2829 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2830 if ( isinstance( theObject, Mesh )):
2831 theObject = theObject.GetMesh()
2832 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2833 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2834 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2835 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2836 Parameters = StepVectorParameters + var_separator + Parameters
2837 self.mesh.SetParameters(Parameters)
2839 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2840 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2845 ## Generates new elements by extrusion of the given elements
2846 # The path of extrusion must be a meshed edge.
2847 # @param Base mesh or list of ids of elements for extrusion
2848 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2849 # @param NodeStart the start node from Path. Defines the direction of extrusion
2850 # @param HasAngles allows the shape to be rotated around the path
2851 # to get the resulting mesh in a helical fashion
2852 # @param Angles list of angles in radians
2853 # @param LinearVariation forces the computation of rotation angles as linear
2854 # variation of the given Angles along path steps
2855 # @param HasRefPoint allows using the reference point
2856 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2857 # The User can specify any point as the Reference Point.
2858 # @param MakeGroups forces the generation of new groups from existing ones
2859 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2860 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2861 # only SMESH::Extrusion_Error otherwise
2862 # @ingroup l2_modif_extrurev
2863 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2864 HasAngles, Angles, LinearVariation,
2865 HasRefPoint, RefPoint, MakeGroups, ElemType):
2866 Angles,AnglesParameters = ParseAngles(Angles)
2867 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2868 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2869 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2871 Parameters = AnglesParameters + var_separator + RefPointParameters
2872 self.mesh.SetParameters(Parameters)
2874 if isinstance(Base,list):
2876 if Base == []: IDsOfElements = self.GetElementsId()
2877 else: IDsOfElements = Base
2878 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2879 HasAngles, Angles, LinearVariation,
2880 HasRefPoint, RefPoint, MakeGroups, ElemType)
2882 if isinstance(Base,Mesh):
2883 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2884 HasAngles, Angles, LinearVariation,
2885 HasRefPoint, RefPoint, MakeGroups, ElemType)
2887 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2890 ## Generates new elements by extrusion of the given elements
2891 # The path of extrusion must be a meshed edge.
2892 # @param IDsOfElements ids of elements
2893 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2894 # @param PathShape shape(edge) defines the sub-mesh for the path
2895 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2896 # @param HasAngles allows the shape to be rotated around the path
2897 # to get the resulting mesh in a helical fashion
2898 # @param Angles list of angles in radians
2899 # @param HasRefPoint allows using the reference point
2900 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2901 # The User can specify any point as the Reference Point.
2902 # @param MakeGroups forces the generation of new groups from existing ones
2903 # @param LinearVariation forces the computation of rotation angles as linear
2904 # variation of the given Angles along path steps
2905 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2906 # only SMESH::Extrusion_Error otherwise
2907 # @ingroup l2_modif_extrurev
2908 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2909 HasAngles, Angles, HasRefPoint, RefPoint,
2910 MakeGroups=False, LinearVariation=False):
2911 Angles,AnglesParameters = ParseAngles(Angles)
2912 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2913 if IDsOfElements == []:
2914 IDsOfElements = self.GetElementsId()
2915 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2916 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2918 if ( isinstance( PathMesh, Mesh )):
2919 PathMesh = PathMesh.GetMesh()
2920 if HasAngles and Angles and LinearVariation:
2921 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2923 Parameters = AnglesParameters + var_separator + RefPointParameters
2924 self.mesh.SetParameters(Parameters)
2926 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2927 PathShape, NodeStart, HasAngles,
2928 Angles, HasRefPoint, RefPoint)
2929 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2930 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2932 ## Generates new elements by extrusion of the elements which belong to the object
2933 # The path of extrusion must be a meshed edge.
2934 # @param theObject the object which elements should be processed
2935 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2936 # @param PathShape shape(edge) defines the sub-mesh for the path
2937 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2938 # @param HasAngles allows the shape to be rotated around the path
2939 # to get the resulting mesh in a helical fashion
2940 # @param Angles list of angles
2941 # @param HasRefPoint allows using the reference point
2942 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2943 # The User can specify any point as the Reference Point.
2944 # @param MakeGroups forces the generation of new groups from existing ones
2945 # @param LinearVariation forces the computation of rotation angles as linear
2946 # variation of the given Angles along path steps
2947 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2948 # only SMESH::Extrusion_Error otherwise
2949 # @ingroup l2_modif_extrurev
2950 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2951 HasAngles, Angles, HasRefPoint, RefPoint,
2952 MakeGroups=False, LinearVariation=False):
2953 Angles,AnglesParameters = ParseAngles(Angles)
2954 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2955 if ( isinstance( theObject, Mesh )):
2956 theObject = theObject.GetMesh()
2957 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2958 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2959 if ( isinstance( PathMesh, Mesh )):
2960 PathMesh = PathMesh.GetMesh()
2961 if HasAngles and Angles and LinearVariation:
2962 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2964 Parameters = AnglesParameters + var_separator + RefPointParameters
2965 self.mesh.SetParameters(Parameters)
2967 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2968 PathShape, NodeStart, HasAngles,
2969 Angles, HasRefPoint, RefPoint)
2970 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2971 NodeStart, HasAngles, Angles, HasRefPoint,
2974 ## Generates new elements by extrusion of the elements which belong to the object
2975 # The path of extrusion must be a meshed edge.
2976 # @param theObject the object which elements should be processed
2977 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2978 # @param PathShape shape(edge) defines the sub-mesh for the path
2979 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2980 # @param HasAngles allows the shape to be rotated around the path
2981 # to get the resulting mesh in a helical fashion
2982 # @param Angles list of angles
2983 # @param HasRefPoint allows using the reference point
2984 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2985 # The User can specify any point as the Reference Point.
2986 # @param MakeGroups forces the generation of new groups from existing ones
2987 # @param LinearVariation forces the computation of rotation angles as linear
2988 # variation of the given Angles along path steps
2989 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2990 # only SMESH::Extrusion_Error otherwise
2991 # @ingroup l2_modif_extrurev
2992 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2993 HasAngles, Angles, HasRefPoint, RefPoint,
2994 MakeGroups=False, LinearVariation=False):
2995 Angles,AnglesParameters = ParseAngles(Angles)
2996 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2997 if ( isinstance( theObject, Mesh )):
2998 theObject = theObject.GetMesh()
2999 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3000 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3001 if ( isinstance( PathMesh, Mesh )):
3002 PathMesh = PathMesh.GetMesh()
3003 if HasAngles and Angles and LinearVariation:
3004 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3006 Parameters = AnglesParameters + var_separator + RefPointParameters
3007 self.mesh.SetParameters(Parameters)
3009 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3010 PathShape, NodeStart, HasAngles,
3011 Angles, HasRefPoint, RefPoint)
3012 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3013 NodeStart, HasAngles, Angles, HasRefPoint,
3016 ## Generates new elements by extrusion of the elements which belong to the object
3017 # The path of extrusion must be a meshed edge.
3018 # @param theObject the object which elements should be processed
3019 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3020 # @param PathShape shape(edge) defines the sub-mesh for the path
3021 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3022 # @param HasAngles allows the shape to be rotated around the path
3023 # to get the resulting mesh in a helical fashion
3024 # @param Angles list of angles
3025 # @param HasRefPoint allows using the reference point
3026 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3027 # The User can specify any point as the Reference Point.
3028 # @param MakeGroups forces the generation of new groups from existing ones
3029 # @param LinearVariation forces the computation of rotation angles as linear
3030 # variation of the given Angles along path steps
3031 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3032 # only SMESH::Extrusion_Error otherwise
3033 # @ingroup l2_modif_extrurev
3034 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3035 HasAngles, Angles, HasRefPoint, RefPoint,
3036 MakeGroups=False, LinearVariation=False):
3037 Angles,AnglesParameters = ParseAngles(Angles)
3038 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3039 if ( isinstance( theObject, Mesh )):
3040 theObject = theObject.GetMesh()
3041 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3042 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3043 if ( isinstance( PathMesh, Mesh )):
3044 PathMesh = PathMesh.GetMesh()
3045 if HasAngles and Angles and LinearVariation:
3046 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3048 Parameters = AnglesParameters + var_separator + RefPointParameters
3049 self.mesh.SetParameters(Parameters)
3051 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3052 PathShape, NodeStart, HasAngles,
3053 Angles, HasRefPoint, RefPoint)
3054 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3055 NodeStart, HasAngles, Angles, HasRefPoint,
3058 ## Creates a symmetrical copy of mesh elements
3059 # @param IDsOfElements list of elements ids
3060 # @param Mirror is AxisStruct or geom object(point, line, plane)
3061 # @param theMirrorType is POINT, AXIS or PLANE
3062 # If the Mirror is a geom object this parameter is unnecessary
3063 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3064 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3065 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3066 # @ingroup l2_modif_trsf
3067 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3068 if IDsOfElements == []:
3069 IDsOfElements = self.GetElementsId()
3070 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3071 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3072 Mirror,Parameters = ParseAxisStruct(Mirror)
3073 self.mesh.SetParameters(Parameters)
3074 if Copy and MakeGroups:
3075 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3076 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3079 ## Creates a new mesh by a symmetrical copy of mesh elements
3080 # @param IDsOfElements the list of elements ids
3081 # @param Mirror is AxisStruct or geom object (point, line, plane)
3082 # @param theMirrorType is POINT, AXIS or PLANE
3083 # If the Mirror is a geom object this parameter is unnecessary
3084 # @param MakeGroups to generate new groups from existing ones
3085 # @param NewMeshName a name of the new mesh to create
3086 # @return instance of Mesh class
3087 # @ingroup l2_modif_trsf
3088 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3089 if IDsOfElements == []:
3090 IDsOfElements = self.GetElementsId()
3091 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3092 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3093 Mirror,Parameters = ParseAxisStruct(Mirror)
3094 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3095 MakeGroups, NewMeshName)
3096 mesh.SetParameters(Parameters)
3097 return Mesh(self.smeshpyD,self.geompyD,mesh)
3099 ## Creates a symmetrical copy of the object
3100 # @param theObject mesh, submesh or group
3101 # @param Mirror AxisStruct or geom object (point, line, plane)
3102 # @param theMirrorType is POINT, AXIS or PLANE
3103 # If the Mirror is a geom object this parameter is unnecessary
3104 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3105 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3106 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3107 # @ingroup l2_modif_trsf
3108 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3109 if ( isinstance( theObject, Mesh )):
3110 theObject = theObject.GetMesh()
3111 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3112 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3113 Mirror,Parameters = ParseAxisStruct(Mirror)
3114 self.mesh.SetParameters(Parameters)
3115 if Copy and MakeGroups:
3116 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3117 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3120 ## Creates a new mesh by a symmetrical copy of the object
3121 # @param theObject mesh, submesh or group
3122 # @param Mirror AxisStruct or geom object (point, line, plane)
3123 # @param theMirrorType POINT, AXIS or PLANE
3124 # If the Mirror is a geom object this parameter is unnecessary
3125 # @param MakeGroups forces the generation of new groups from existing ones
3126 # @param NewMeshName the name of the new mesh to create
3127 # @return instance of Mesh class
3128 # @ingroup l2_modif_trsf
3129 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3130 if ( isinstance( theObject, Mesh )):
3131 theObject = theObject.GetMesh()
3132 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3133 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3134 Mirror,Parameters = ParseAxisStruct(Mirror)
3135 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3136 MakeGroups, NewMeshName)
3137 mesh.SetParameters(Parameters)
3138 return Mesh( self.smeshpyD,self.geompyD,mesh )
3140 ## Translates the elements
3141 # @param IDsOfElements list of elements ids
3142 # @param Vector the direction of translation (DirStruct or vector)
3143 # @param Copy allows copying the translated elements
3144 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3145 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3146 # @ingroup l2_modif_trsf
3147 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3148 if IDsOfElements == []:
3149 IDsOfElements = self.GetElementsId()
3150 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3151 Vector = self.smeshpyD.GetDirStruct(Vector)
3152 Vector,Parameters = ParseDirStruct(Vector)
3153 self.mesh.SetParameters(Parameters)
3154 if Copy and MakeGroups:
3155 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3156 self.editor.Translate(IDsOfElements, Vector, Copy)
3159 ## Creates a new mesh of translated elements
3160 # @param IDsOfElements list of elements ids
3161 # @param Vector the direction of translation (DirStruct or vector)
3162 # @param MakeGroups forces the generation of new groups from existing ones
3163 # @param NewMeshName the name of the newly created mesh
3164 # @return instance of Mesh class
3165 # @ingroup l2_modif_trsf
3166 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3167 if IDsOfElements == []:
3168 IDsOfElements = self.GetElementsId()
3169 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3170 Vector = self.smeshpyD.GetDirStruct(Vector)
3171 Vector,Parameters = ParseDirStruct(Vector)
3172 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3173 mesh.SetParameters(Parameters)
3174 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3176 ## Translates the object
3177 # @param theObject the object to translate (mesh, submesh, or group)
3178 # @param Vector direction of translation (DirStruct or geom vector)
3179 # @param Copy allows copying the translated elements
3180 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3181 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3182 # @ingroup l2_modif_trsf
3183 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3184 if ( isinstance( theObject, Mesh )):
3185 theObject = theObject.GetMesh()
3186 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3187 Vector = self.smeshpyD.GetDirStruct(Vector)
3188 Vector,Parameters = ParseDirStruct(Vector)
3189 self.mesh.SetParameters(Parameters)
3190 if Copy and MakeGroups:
3191 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3192 self.editor.TranslateObject(theObject, Vector, Copy)
3195 ## Creates a new mesh from the translated object
3196 # @param theObject the object to translate (mesh, submesh, or group)
3197 # @param Vector the direction of translation (DirStruct or geom vector)
3198 # @param MakeGroups forces the generation of new groups from existing ones
3199 # @param NewMeshName the name of the newly created mesh
3200 # @return instance of Mesh class
3201 # @ingroup l2_modif_trsf
3202 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3203 if (isinstance(theObject, Mesh)):
3204 theObject = theObject.GetMesh()
3205 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3206 Vector = self.smeshpyD.GetDirStruct(Vector)
3207 Vector,Parameters = ParseDirStruct(Vector)
3208 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3209 mesh.SetParameters(Parameters)
3210 return Mesh( self.smeshpyD, self.geompyD, mesh )
3212 ## Rotates the elements
3213 # @param IDsOfElements list of elements ids
3214 # @param Axis the axis of rotation (AxisStruct or geom line)
3215 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3216 # @param Copy allows copying the rotated elements
3217 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3218 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3219 # @ingroup l2_modif_trsf
3220 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3222 if isinstance(AngleInRadians,str):
3224 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3226 AngleInRadians = DegreesToRadians(AngleInRadians)
3227 if IDsOfElements == []:
3228 IDsOfElements = self.GetElementsId()
3229 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3230 Axis = self.smeshpyD.GetAxisStruct(Axis)
3231 Axis,AxisParameters = ParseAxisStruct(Axis)
3232 Parameters = AxisParameters + var_separator + Parameters
3233 self.mesh.SetParameters(Parameters)
3234 if Copy and MakeGroups:
3235 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3236 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3239 ## Creates a new mesh of rotated elements
3240 # @param IDsOfElements list of element ids
3241 # @param Axis the axis of rotation (AxisStruct or geom line)
3242 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3243 # @param MakeGroups forces the generation of new groups from existing ones
3244 # @param NewMeshName the name of the newly created mesh
3245 # @return instance of Mesh class
3246 # @ingroup l2_modif_trsf
3247 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3249 if isinstance(AngleInRadians,str):
3251 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3253 AngleInRadians = DegreesToRadians(AngleInRadians)
3254 if IDsOfElements == []:
3255 IDsOfElements = self.GetElementsId()
3256 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3257 Axis = self.smeshpyD.GetAxisStruct(Axis)
3258 Axis,AxisParameters = ParseAxisStruct(Axis)
3259 Parameters = AxisParameters + var_separator + Parameters
3260 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3261 MakeGroups, NewMeshName)
3262 mesh.SetParameters(Parameters)
3263 return Mesh( self.smeshpyD, self.geompyD, mesh )
3265 ## Rotates the object
3266 # @param theObject the object to rotate( mesh, submesh, or group)
3267 # @param Axis the axis of rotation (AxisStruct or geom line)
3268 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3269 # @param Copy allows copying the rotated elements
3270 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3271 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3272 # @ingroup l2_modif_trsf
3273 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3275 if isinstance(AngleInRadians,str):
3277 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3279 AngleInRadians = DegreesToRadians(AngleInRadians)
3280 if (isinstance(theObject, Mesh)):
3281 theObject = theObject.GetMesh()
3282 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3283 Axis = self.smeshpyD.GetAxisStruct(Axis)
3284 Axis,AxisParameters = ParseAxisStruct(Axis)
3285 Parameters = AxisParameters + ":" + Parameters
3286 self.mesh.SetParameters(Parameters)
3287 if Copy and MakeGroups:
3288 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3289 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3292 ## Creates a new mesh from the rotated object
3293 # @param theObject the object to rotate (mesh, submesh, or group)
3294 # @param Axis the axis of rotation (AxisStruct or geom line)
3295 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3296 # @param MakeGroups forces the generation of new groups from existing ones
3297 # @param NewMeshName the name of the newly created mesh
3298 # @return instance of Mesh class
3299 # @ingroup l2_modif_trsf
3300 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3302 if isinstance(AngleInRadians,str):
3304 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3306 AngleInRadians = DegreesToRadians(AngleInRadians)
3307 if (isinstance( theObject, Mesh )):
3308 theObject = theObject.GetMesh()
3309 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3310 Axis = self.smeshpyD.GetAxisStruct(Axis)
3311 Axis,AxisParameters = ParseAxisStruct(Axis)
3312 Parameters = AxisParameters + ":" + Parameters
3313 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3314 MakeGroups, NewMeshName)
3315 mesh.SetParameters(Parameters)
3316 return Mesh( self.smeshpyD, self.geompyD, mesh )
3318 ## Finds groups of ajacent nodes within Tolerance.
3319 # @param Tolerance the value of tolerance
3320 # @return the list of groups of nodes
3321 # @ingroup l2_modif_trsf
3322 def FindCoincidentNodes (self, Tolerance):
3323 return self.editor.FindCoincidentNodes(Tolerance)
3325 ## Finds groups of ajacent nodes within Tolerance.
3326 # @param Tolerance the value of tolerance
3327 # @param SubMeshOrGroup SubMesh or Group
3328 # @return the list of groups of nodes
3329 # @ingroup l2_modif_trsf
3330 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3331 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3334 # @param GroupsOfNodes the list of groups of nodes
3335 # @ingroup l2_modif_trsf
3336 def MergeNodes (self, GroupsOfNodes):
3337 self.editor.MergeNodes(GroupsOfNodes)
3339 ## Finds the elements built on the same nodes.
3340 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3341 # @return a list of groups of equal elements
3342 # @ingroup l2_modif_trsf
3343 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3344 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3345 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3346 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3348 ## Merges elements in each given group.
3349 # @param GroupsOfElementsID groups of elements for merging
3350 # @ingroup l2_modif_trsf
3351 def MergeElements(self, GroupsOfElementsID):
3352 self.editor.MergeElements(GroupsOfElementsID)
3354 ## Leaves one element and removes all other elements built on the same nodes.
3355 # @ingroup l2_modif_trsf
3356 def MergeEqualElements(self):
3357 self.editor.MergeEqualElements()
3359 ## Sews free borders
3360 # @return SMESH::Sew_Error
3361 # @ingroup l2_modif_trsf
3362 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3363 FirstNodeID2, SecondNodeID2, LastNodeID2,
3364 CreatePolygons, CreatePolyedrs):
3365 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3366 FirstNodeID2, SecondNodeID2, LastNodeID2,
3367 CreatePolygons, CreatePolyedrs)
3369 ## Sews conform free borders
3370 # @return SMESH::Sew_Error
3371 # @ingroup l2_modif_trsf
3372 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3373 FirstNodeID2, SecondNodeID2):
3374 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3375 FirstNodeID2, SecondNodeID2)
3377 ## Sews border to side
3378 # @return SMESH::Sew_Error
3379 # @ingroup l2_modif_trsf
3380 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3381 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3382 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3383 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3385 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3386 # merged with the nodes of elements of Side2.
3387 # The number of elements in theSide1 and in theSide2 must be
3388 # equal and they should have similar nodal connectivity.
3389 # The nodes to merge should belong to side borders and
3390 # the first node should be linked to the second.
3391 # @return SMESH::Sew_Error
3392 # @ingroup l2_modif_trsf
3393 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3394 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3395 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3396 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3397 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3398 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3400 ## Sets new nodes for the given element.
3401 # @param ide the element id
3402 # @param newIDs nodes ids
3403 # @return If the number of nodes does not correspond to the type of element - returns false
3404 # @ingroup l2_modif_edit
3405 def ChangeElemNodes(self, ide, newIDs):
3406 return self.editor.ChangeElemNodes(ide, newIDs)
3408 ## If during the last operation of MeshEditor some nodes were
3409 # created, this method returns the list of their IDs, \n
3410 # if new nodes were not created - returns empty list
3411 # @return the list of integer values (can be empty)
3412 # @ingroup l1_auxiliary
3413 def GetLastCreatedNodes(self):
3414 return self.editor.GetLastCreatedNodes()
3416 ## If during the last operation of MeshEditor some elements were
3417 # created this method returns the list of their IDs, \n
3418 # if new elements were not created - returns empty list
3419 # @return the list of integer values (can be empty)
3420 # @ingroup l1_auxiliary
3421 def GetLastCreatedElems(self):
3422 return self.editor.GetLastCreatedElems()
3424 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3425 # @param theElems - the list of elements (edges or faces) to be replicated
3426 # The nodes for duplication could be found from these elements
3427 # @param theNodesNot - list of nodes to NOT replicate
3428 # @param theAffectedElems - the list of elements (cells and edges) to which the
3429 # replicated nodes should be associated to.
3430 # @return TRUE if operation has been completed successfully, FALSE otherwise
3431 # @ingroup l2_modif_edit
3432 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3433 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3435 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3436 # @param theElems - the list of elements (edges or faces) to be replicated
3437 # The nodes for duplication could be found from these elements
3438 # @param theNodesNot - list of nodes to NOT replicate
3439 # @param theShape - shape to detect affected elements (element which geometric center
3440 # located on or inside shape).
3441 # The replicated nodes should be associated to affected elements.
3442 # @return TRUE if operation has been completed successfully, FALSE otherwise
3443 # @ingroup l2_modif_edit
3444 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3445 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3447 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3448 # This method provided for convenience works as DoubleNodes() described above.
3449 # @param theElems - group of of elements (edges or faces) to be replicated
3450 # @param theNodesNot - group of nodes not to replicated
3451 # @param theAffectedElems - group of elements to which the replicated nodes
3452 # should be associated to.
3453 # @ingroup l2_modif_edit
3454 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3455 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3457 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3458 # This method provided for convenience works as DoubleNodes() described above.
3459 # @param theElems - group of of elements (edges or faces) to be replicated
3460 # @param theNodesNot - group of nodes not to replicated
3461 # @param theShape - shape to detect affected elements (element which geometric center
3462 # located on or inside shape).
3463 # The replicated nodes should be associated to affected elements.
3464 # @ingroup l2_modif_edit
3465 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3466 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3468 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3469 # This method provided for convenience works as DoubleNodes() described above.
3470 # @param theElems - list of groups of elements (edges or faces) to be replicated
3471 # @param theNodesNot - list of groups of nodes not to replicated
3472 # @param theAffectedElems - group of elements to which the replicated nodes
3473 # should be associated to.
3474 # @return TRUE if operation has been completed successfully, FALSE otherwise
3475 # @ingroup l2_modif_edit
3476 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3477 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3479 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3480 # This method provided for convenience works as DoubleNodes() described above.
3481 # @param theElems - list of groups of elements (edges or faces) to be replicated
3482 # @param theNodesNot - list of groups of nodes not to replicated
3483 # @param theShape - shape to detect affected elements (element which geometric center
3484 # located on or inside shape).
3485 # The replicated nodes should be associated to affected elements.
3486 # @return TRUE if operation has been completed successfully, FALSE otherwise
3487 # @ingroup l2_modif_edit
3488 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3489 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3491 ## The mother class to define algorithm, it is not recommended to use it directly.
3494 # @ingroup l2_algorithms
3495 class Mesh_Algorithm:
3496 # @class Mesh_Algorithm
3497 # @brief Class Mesh_Algorithm
3499 #def __init__(self,smesh):
3507 ## Finds a hypothesis in the study by its type name and parameters.
3508 # Finds only the hypotheses created in smeshpyD engine.
3509 # @return SMESH.SMESH_Hypothesis
3510 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3511 study = smeshpyD.GetCurrentStudy()
3512 #to do: find component by smeshpyD object, not by its data type
3513 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3514 if scomp is not None:
3515 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3516 # Check if the root label of the hypotheses exists
3517 if res and hypRoot is not None:
3518 iter = study.NewChildIterator(hypRoot)
3519 # Check all published hypotheses
3521 hypo_so_i = iter.Value()
3522 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3523 if attr is not None:
3524 anIOR = attr.Value()
3525 hypo_o_i = salome.orb.string_to_object(anIOR)
3526 if hypo_o_i is not None:
3527 # Check if this is a hypothesis
3528 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3529 if hypo_i is not None:
3530 # Check if the hypothesis belongs to current engine
3531 if smeshpyD.GetObjectId(hypo_i) > 0:
3532 # Check if this is the required hypothesis
3533 if hypo_i.GetName() == hypname:
3535 if CompareMethod(hypo_i, args):
3549 ## Finds the algorithm in the study by its type name.
3550 # Finds only the algorithms, which have been created in smeshpyD engine.
3551 # @return SMESH.SMESH_Algo
3552 def FindAlgorithm (self, algoname, smeshpyD):
3553 study = smeshpyD.GetCurrentStudy()
3554 #to do: find component by smeshpyD object, not by its data type
3555 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3556 if scomp is not None:
3557 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3558 # Check if the root label of the algorithms exists
3559 if res and hypRoot is not None:
3560 iter = study.NewChildIterator(hypRoot)
3561 # Check all published algorithms
3563 algo_so_i = iter.Value()
3564 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3565 if attr is not None:
3566 anIOR = attr.Value()
3567 algo_o_i = salome.orb.string_to_object(anIOR)
3568 if algo_o_i is not None:
3569 # Check if this is an algorithm
3570 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3571 if algo_i is not None:
3572 # Checks if the algorithm belongs to the current engine
3573 if smeshpyD.GetObjectId(algo_i) > 0:
3574 # Check if this is the required algorithm
3575 if algo_i.GetName() == algoname:
3588 ## If the algorithm is global, returns 0; \n
3589 # else returns the submesh associated to this algorithm.
3590 def GetSubMesh(self):
3593 ## Returns the wrapped mesher.
3594 def GetAlgorithm(self):
3597 ## Gets the list of hypothesis that can be used with this algorithm
3598 def GetCompatibleHypothesis(self):
3601 mylist = self.algo.GetCompatibleHypothesis()
3604 ## Gets the name of the algorithm
3608 ## Sets the name to the algorithm
3609 def SetName(self, name):
3610 self.mesh.smeshpyD.SetName(self.algo, name)
3612 ## Gets the id of the algorithm
3614 return self.algo.GetId()
3617 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3619 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3620 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3622 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3624 self.Assign(algo, mesh, geom)
3628 def Assign(self, algo, mesh, geom):
3630 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3637 name = GetName(geom)
3639 name = mesh.geompyD.SubShapeName(geom, piece)
3640 mesh.geompyD.addToStudyInFather(piece, geom, name)
3641 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3644 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3645 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3647 def CompareHyp (self, hyp, args):
3648 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3651 def CompareEqualHyp (self, hyp, args):
3655 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3656 UseExisting=0, CompareMethod=""):
3659 if CompareMethod == "": CompareMethod = self.CompareHyp
3660 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3663 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3669 a = a + s + str(args[i])
3673 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3675 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3676 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3679 ## Returns entry of the shape to mesh in the study
3680 def MainShapeEntry(self):
3682 if not self.mesh or not self.mesh.GetMesh(): return entry
3683 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3684 study = self.mesh.smeshpyD.GetCurrentStudy()
3685 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3686 sobj = study.FindObjectIOR(ior)
3687 if sobj: entry = sobj.GetID()
3688 if not entry: return ""
3691 # Public class: Mesh_Segment
3692 # --------------------------
3694 ## Class to define a segment 1D algorithm for discretization
3697 # @ingroup l3_algos_basic
3698 class Mesh_Segment(Mesh_Algorithm):
3700 ## Private constructor.
3701 def __init__(self, mesh, geom=0):
3702 Mesh_Algorithm.__init__(self)
3703 self.Create(mesh, geom, "Regular_1D")
3705 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3706 # @param l for the length of segments that cut an edge
3707 # @param UseExisting if ==true - searches for an existing hypothesis created with
3708 # the same parameters, else (default) - creates a new one
3709 # @param p precision, used for calculation of the number of segments.
3710 # The precision should be a positive, meaningful value within the range [0,1].
3711 # In general, the number of segments is calculated with the formula:
3712 # nb = ceil((edge_length / l) - p)
3713 # Function ceil rounds its argument to the higher integer.
3714 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3715 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3716 # p=1 means rounding of (edge_length / l) to the lower integer.
3717 # Default value is 1e-07.
3718 # @return an instance of StdMeshers_LocalLength hypothesis
3719 # @ingroup l3_hypos_1dhyps
3720 def LocalLength(self, l, UseExisting=0, p=1e-07):
3721 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3722 CompareMethod=self.CompareLocalLength)
3728 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3729 def CompareLocalLength(self, hyp, args):
3730 if IsEqual(hyp.GetLength(), args[0]):
3731 return IsEqual(hyp.GetPrecision(), args[1])
3734 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3735 # @param length is optional maximal allowed length of segment, if it is omitted
3736 # the preestimated length is used that depends on geometry size
3737 # @param UseExisting if ==true - searches for an existing hypothesis created with
3738 # the same parameters, else (default) - create a new one
3739 # @return an instance of StdMeshers_MaxLength hypothesis
3740 # @ingroup l3_hypos_1dhyps
3741 def MaxSize(self, length=0.0, UseExisting=0):
3742 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3745 hyp.SetLength(length)
3747 # set preestimated length
3748 gen = self.mesh.smeshpyD
3749 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3750 self.mesh.GetMesh(), self.mesh.GetShape(),
3752 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3754 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3757 hyp.SetUsePreestimatedLength( length == 0.0 )
3760 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3761 # @param n for the number of segments that cut an edge
3762 # @param s for the scale factor (optional)
3763 # @param reversedEdges is a list of edges to mesh using reversed orientation
3764 # @param UseExisting if ==true - searches for an existing hypothesis created with
3765 # the same parameters, else (default) - create a new one
3766 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3767 # @ingroup l3_hypos_1dhyps
3768 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3769 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3770 reversedEdges, UseExisting = [], reversedEdges
3771 entry = self.MainShapeEntry()
3773 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3774 UseExisting=UseExisting,
3775 CompareMethod=self.CompareNumberOfSegments)
3777 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3778 UseExisting=UseExisting,
3779 CompareMethod=self.CompareNumberOfSegments)
3780 hyp.SetDistrType( 1 )
3781 hyp.SetScaleFactor(s)
3782 hyp.SetNumberOfSegments(n)
3783 hyp.SetReversedEdges( reversedEdges )
3784 hyp.SetObjectEntry( entry )
3788 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3789 def CompareNumberOfSegments(self, hyp, args):
3790 if hyp.GetNumberOfSegments() == args[0]:
3792 if hyp.GetReversedEdges() == args[1]:
3793 if not args[1] or hyp.GetObjectEntry() == args[2]:
3796 if hyp.GetReversedEdges() == args[2]:
3797 if not args[2] or hyp.GetObjectEntry() == args[3]:
3798 if hyp.GetDistrType() == 1:
3799 if IsEqual(hyp.GetScaleFactor(), args[1]):
3803 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3804 # @param start defines the length of the first segment
3805 # @param end defines the length of the last segment
3806 # @param reversedEdges is a list of edges to mesh using reversed orientation
3807 # @param UseExisting if ==true - searches for an existing hypothesis created with
3808 # the same parameters, else (default) - creates a new one
3809 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3810 # @ingroup l3_hypos_1dhyps
3811 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3812 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3813 reversedEdges, UseExisting = [], reversedEdges
3814 entry = self.MainShapeEntry()
3815 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3816 UseExisting=UseExisting,
3817 CompareMethod=self.CompareArithmetic1D)
3818 hyp.SetStartLength(start)
3819 hyp.SetEndLength(end)
3820 hyp.SetReversedEdges( reversedEdges )
3821 hyp.SetObjectEntry( entry )
3825 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3826 def CompareArithmetic1D(self, hyp, args):
3827 if IsEqual(hyp.GetLength(1), args[0]):
3828 if IsEqual(hyp.GetLength(0), args[1]):
3829 if hyp.GetReversedEdges() == args[2]:
3830 if not args[2] or hyp.GetObjectEntry() == args[3]:
3835 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3836 # on curve from 0 to 1 (additionally it is neecessary to check
3837 # orientation of edges and create list of reversed edges if it is
3838 # needed) and sets numbers of segments between given points (default
3839 # values are equals 1
3840 # @param points defines the list of parameters on curve
3841 # @param nbSegs defines the list of numbers of segments
3842 # @param reversedEdges is a list of edges to mesh using reversed orientation
3843 # @param UseExisting if ==true - searches for an existing hypothesis created with
3844 # the same parameters, else (default) - creates a new one
3845 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3846 # @ingroup l3_hypos_1dhyps
3847 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3848 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3849 reversedEdges, UseExisting = [], reversedEdges
3850 entry = self.MainShapeEntry()
3851 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3852 UseExisting=UseExisting,
3853 CompareMethod=self.CompareArithmetic1D)
3854 hyp.SetPoints(points)
3855 hyp.SetNbSegments(nbSegs)
3856 hyp.SetReversedEdges(reversedEdges)
3857 hyp.SetObjectEntry(entry)
3861 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3862 ## as the given arguments
3863 def CompareFixedPoints1D(self, hyp, args):
3864 if hyp.GetPoints() == args[0]:
3865 if hyp.GetNbSegments() == args[1]:
3866 if hyp.GetReversedEdges() == args[2]:
3867 if not args[2] or hyp.GetObjectEntry() == args[3]:
3873 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3874 # @param start defines the length of the first segment
3875 # @param end defines the length of the last segment
3876 # @param reversedEdges is a list of edges to mesh using reversed orientation
3877 # @param UseExisting if ==true - searches for an existing hypothesis created with
3878 # the same parameters, else (default) - creates a new one
3879 # @return an instance of StdMeshers_StartEndLength hypothesis
3880 # @ingroup l3_hypos_1dhyps
3881 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3882 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3883 reversedEdges, UseExisting = [], reversedEdges
3884 entry = self.MainShapeEntry()
3885 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3886 UseExisting=UseExisting,
3887 CompareMethod=self.CompareStartEndLength)
3888 hyp.SetStartLength(start)
3889 hyp.SetEndLength(end)
3890 hyp.SetReversedEdges( reversedEdges )
3891 hyp.SetObjectEntry( entry )
3894 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3895 def CompareStartEndLength(self, hyp, args):
3896 if IsEqual(hyp.GetLength(1), args[0]):
3897 if IsEqual(hyp.GetLength(0), args[1]):
3898 if hyp.GetReversedEdges() == args[2]:
3899 if not args[2] or hyp.GetObjectEntry() == args[3]:
3903 ## Defines "Deflection1D" hypothesis
3904 # @param d for the deflection
3905 # @param UseExisting if ==true - searches for an existing hypothesis created with
3906 # the same parameters, else (default) - create a new one
3907 # @ingroup l3_hypos_1dhyps
3908 def Deflection1D(self, d, UseExisting=0):
3909 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3910 CompareMethod=self.CompareDeflection1D)
3911 hyp.SetDeflection(d)
3914 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3915 def CompareDeflection1D(self, hyp, args):
3916 return IsEqual(hyp.GetDeflection(), args[0])
3918 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3919 # the opposite side in case of quadrangular faces
3920 # @ingroup l3_hypos_additi
3921 def Propagation(self):
3922 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3924 ## Defines "AutomaticLength" hypothesis
3925 # @param fineness for the fineness [0-1]
3926 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3927 # same parameters, else (default) - create a new one
3928 # @ingroup l3_hypos_1dhyps
3929 def AutomaticLength(self, fineness=0, UseExisting=0):
3930 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3931 CompareMethod=self.CompareAutomaticLength)
3932 hyp.SetFineness( fineness )
3935 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3936 def CompareAutomaticLength(self, hyp, args):
3937 return IsEqual(hyp.GetFineness(), args[0])
3939 ## Defines "SegmentLengthAroundVertex" hypothesis
3940 # @param length for the segment length
3941 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3942 # Any other integer value means that the hypothesis will be set on the
3943 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3944 # @param UseExisting if ==true - searches for an existing hypothesis created with
3945 # the same parameters, else (default) - creates a new one
3946 # @ingroup l3_algos_segmarv
3947 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3949 store_geom = self.geom
3950 if type(vertex) is types.IntType:
3951 if vertex == 0 or vertex == 1:
3952 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3960 if self.geom is None:
3961 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3962 name = GetName(self.geom)
3964 piece = self.mesh.geom
3965 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3966 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3967 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3969 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3971 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3972 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3974 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3975 CompareMethod=self.CompareLengthNearVertex)
3976 self.geom = store_geom
3977 hyp.SetLength( length )
3980 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3981 # @ingroup l3_algos_segmarv
3982 def CompareLengthNearVertex(self, hyp, args):
3983 return IsEqual(hyp.GetLength(), args[0])
3985 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3986 # If the 2D mesher sees that all boundary edges are quadratic,
3987 # it generates quadratic faces, else it generates linear faces using
3988 # medium nodes as if they are vertices.
3989 # The 3D mesher generates quadratic volumes only if all boundary faces
3990 # are quadratic, else it fails.
3992 # @ingroup l3_hypos_additi
3993 def QuadraticMesh(self):
3994 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3997 # Public class: Mesh_CompositeSegment
3998 # --------------------------
4000 ## Defines a segment 1D algorithm for discretization
4002 # @ingroup l3_algos_basic
4003 class Mesh_CompositeSegment(Mesh_Segment):
4005 ## Private constructor.
4006 def __init__(self, mesh, geom=0):
4007 self.Create(mesh, geom, "CompositeSegment_1D")
4010 # Public class: Mesh_Segment_Python
4011 # ---------------------------------
4013 ## Defines a segment 1D algorithm for discretization with python function
4015 # @ingroup l3_algos_basic
4016 class Mesh_Segment_Python(Mesh_Segment):
4018 ## Private constructor.
4019 def __init__(self, mesh, geom=0):
4020 import Python1dPlugin
4021 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4023 ## Defines "PythonSplit1D" hypothesis
4024 # @param n for the number of segments that cut an edge
4025 # @param func for the python function that calculates the length of all segments
4026 # @param UseExisting if ==true - searches for the existing hypothesis created with
4027 # the same parameters, else (default) - creates a new one
4028 # @ingroup l3_hypos_1dhyps
4029 def PythonSplit1D(self, n, func, UseExisting=0):
4030 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4031 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4032 hyp.SetNumberOfSegments(n)
4033 hyp.SetPythonLog10RatioFunction(func)
4036 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4037 def ComparePythonSplit1D(self, hyp, args):
4038 #if hyp.GetNumberOfSegments() == args[0]:
4039 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4043 # Public class: Mesh_Triangle
4044 # ---------------------------
4046 ## Defines a triangle 2D algorithm
4048 # @ingroup l3_algos_basic
4049 class Mesh_Triangle(Mesh_Algorithm):
4058 ## Private constructor.
4059 def __init__(self, mesh, algoType, geom=0):
4060 Mesh_Algorithm.__init__(self)
4062 self.algoType = algoType
4063 if algoType == MEFISTO:
4064 self.Create(mesh, geom, "MEFISTO_2D")
4066 elif algoType == BLSURF:
4068 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4069 #self.SetPhysicalMesh() - PAL19680
4070 elif algoType == NETGEN:
4072 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4074 elif algoType == NETGEN_2D:
4076 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4079 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4080 # @param area for the maximum area of each triangle
4081 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4082 # same parameters, else (default) - creates a new one
4084 # Only for algoType == MEFISTO || NETGEN_2D
4085 # @ingroup l3_hypos_2dhyps
4086 def MaxElementArea(self, area, UseExisting=0):
4087 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4088 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4089 CompareMethod=self.CompareMaxElementArea)
4090 elif self.algoType == NETGEN:
4091 hyp = self.Parameters(SIMPLE)
4092 hyp.SetMaxElementArea(area)
4095 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4096 def CompareMaxElementArea(self, hyp, args):
4097 return IsEqual(hyp.GetMaxElementArea(), args[0])
4099 ## Defines "LengthFromEdges" hypothesis to build triangles
4100 # based on the length of the edges taken from the wire
4102 # Only for algoType == MEFISTO || NETGEN_2D
4103 # @ingroup l3_hypos_2dhyps
4104 def LengthFromEdges(self):
4105 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4106 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4108 elif self.algoType == NETGEN:
4109 hyp = self.Parameters(SIMPLE)
4110 hyp.LengthFromEdges()
4113 ## Sets a way to define size of mesh elements to generate.
4114 # @param thePhysicalMesh is: DefaultSize or Custom.
4115 # @ingroup l3_hypos_blsurf
4116 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4117 # Parameter of BLSURF algo
4118 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4120 ## Sets size of mesh elements to generate.
4121 # @ingroup l3_hypos_blsurf
4122 def SetPhySize(self, theVal):
4123 # Parameter of BLSURF algo
4124 self.Parameters().SetPhySize(theVal)
4126 ## Sets lower boundary of mesh element size (PhySize).
4127 # @ingroup l3_hypos_blsurf
4128 def SetPhyMin(self, theVal=-1):
4129 # Parameter of BLSURF algo
4130 self.Parameters().SetPhyMin(theVal)
4132 ## Sets upper boundary of mesh element size (PhySize).
4133 # @ingroup l3_hypos_blsurf
4134 def SetPhyMax(self, theVal=-1):
4135 # Parameter of BLSURF algo
4136 self.Parameters().SetPhyMax(theVal)
4138 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4139 # @param theGeometricMesh is: DefaultGeom or Custom
4140 # @ingroup l3_hypos_blsurf
4141 def SetGeometricMesh(self, theGeometricMesh=0):
4142 # Parameter of BLSURF algo
4143 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4144 self.params.SetGeometricMesh(theGeometricMesh)
4146 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4147 # @ingroup l3_hypos_blsurf
4148 def SetAngleMeshS(self, theVal=_angleMeshS):
4149 # Parameter of BLSURF algo
4150 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4151 self.params.SetAngleMeshS(theVal)
4153 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4154 # @ingroup l3_hypos_blsurf
4155 def SetAngleMeshC(self, theVal=_angleMeshS):
4156 # Parameter of BLSURF algo
4157 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4158 self.params.SetAngleMeshC(theVal)
4160 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4161 # @ingroup l3_hypos_blsurf
4162 def SetGeoMin(self, theVal=-1):
4163 # Parameter of BLSURF algo
4164 self.Parameters().SetGeoMin(theVal)
4166 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4167 # @ingroup l3_hypos_blsurf
4168 def SetGeoMax(self, theVal=-1):
4169 # Parameter of BLSURF algo
4170 self.Parameters().SetGeoMax(theVal)
4172 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4173 # @ingroup l3_hypos_blsurf
4174 def SetGradation(self, theVal=_gradation):
4175 # Parameter of BLSURF algo
4176 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4177 self.params.SetGradation(theVal)
4179 ## Sets topology usage way.
4180 # @param way defines how mesh conformity is assured <ul>
4181 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4182 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4183 # @ingroup l3_hypos_blsurf
4184 def SetTopology(self, way):
4185 # Parameter of BLSURF algo
4186 self.Parameters().SetTopology(way)
4188 ## To respect geometrical edges or not.
4189 # @ingroup l3_hypos_blsurf
4190 def SetDecimesh(self, toIgnoreEdges=False):
4191 # Parameter of BLSURF algo
4192 self.Parameters().SetDecimesh(toIgnoreEdges)
4194 ## Sets verbosity level in the range 0 to 100.
4195 # @ingroup l3_hypos_blsurf
4196 def SetVerbosity(self, level):
4197 # Parameter of BLSURF algo
4198 self.Parameters().SetVerbosity(level)
4200 ## Sets advanced option value.
4201 # @ingroup l3_hypos_blsurf
4202 def SetOptionValue(self, optionName, level):
4203 # Parameter of BLSURF algo
4204 self.Parameters().SetOptionValue(optionName,level)
4206 ## Sets QuadAllowed flag.
4207 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4208 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4209 def SetQuadAllowed(self, toAllow=True):
4210 if self.algoType == NETGEN_2D:
4211 if toAllow: # add QuadranglePreference
4212 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4213 else: # remove QuadranglePreference
4214 for hyp in self.mesh.GetHypothesisList( self.geom ):
4215 if hyp.GetName() == "QuadranglePreference":
4216 self.mesh.RemoveHypothesis( self.geom, hyp )
4221 if self.Parameters():
4222 self.params.SetQuadAllowed(toAllow)
4225 ## Defines hypothesis having several parameters
4227 # @ingroup l3_hypos_netgen
4228 def Parameters(self, which=SOLE):
4231 if self.algoType == NETGEN:
4233 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4234 "libNETGENEngine.so", UseExisting=0)
4236 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4237 "libNETGENEngine.so", UseExisting=0)
4239 elif self.algoType == MEFISTO:
4240 print "Mefisto algo support no multi-parameter hypothesis"
4242 elif self.algoType == NETGEN_2D:
4243 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4244 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4246 elif self.algoType == BLSURF:
4247 self.params = self.Hypothesis("BLSURF_Parameters", [],
4248 "libBLSURFEngine.so", UseExisting=0)
4251 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4256 # Only for algoType == NETGEN
4257 # @ingroup l3_hypos_netgen
4258 def SetMaxSize(self, theSize):
4259 if self.Parameters():
4260 self.params.SetMaxSize(theSize)
4262 ## Sets SecondOrder flag
4264 # Only for algoType == NETGEN
4265 # @ingroup l3_hypos_netgen
4266 def SetSecondOrder(self, theVal):
4267 if self.Parameters():
4268 self.params.SetSecondOrder(theVal)
4270 ## Sets Optimize flag
4272 # Only for algoType == NETGEN
4273 # @ingroup l3_hypos_netgen
4274 def SetOptimize(self, theVal):
4275 if self.Parameters():
4276 self.params.SetOptimize(theVal)
4279 # @param theFineness is:
4280 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4282 # Only for algoType == NETGEN
4283 # @ingroup l3_hypos_netgen
4284 def SetFineness(self, theFineness):
4285 if self.Parameters():
4286 self.params.SetFineness(theFineness)
4290 # Only for algoType == NETGEN
4291 # @ingroup l3_hypos_netgen
4292 def SetGrowthRate(self, theRate):
4293 if self.Parameters():
4294 self.params.SetGrowthRate(theRate)
4296 ## Sets NbSegPerEdge
4298 # Only for algoType == NETGEN
4299 # @ingroup l3_hypos_netgen
4300 def SetNbSegPerEdge(self, theVal):
4301 if self.Parameters():
4302 self.params.SetNbSegPerEdge(theVal)
4304 ## Sets NbSegPerRadius
4306 # Only for algoType == NETGEN
4307 # @ingroup l3_hypos_netgen
4308 def SetNbSegPerRadius(self, theVal):
4309 if self.Parameters():
4310 self.params.SetNbSegPerRadius(theVal)
4312 ## Sets number of segments overriding value set by SetLocalLength()
4314 # Only for algoType == NETGEN
4315 # @ingroup l3_hypos_netgen
4316 def SetNumberOfSegments(self, theVal):
4317 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4319 ## Sets number of segments overriding value set by SetNumberOfSegments()
4321 # Only for algoType == NETGEN
4322 # @ingroup l3_hypos_netgen
4323 def SetLocalLength(self, theVal):
4324 self.Parameters(SIMPLE).SetLocalLength(theVal)
4329 # Public class: Mesh_Quadrangle
4330 # -----------------------------
4332 ## Defines a quadrangle 2D algorithm
4334 # @ingroup l3_algos_basic
4335 class Mesh_Quadrangle(Mesh_Algorithm):
4337 ## Private constructor.
4338 def __init__(self, mesh, geom=0):
4339 Mesh_Algorithm.__init__(self)
4340 self.Create(mesh, geom, "Quadrangle_2D")
4342 ## Defines "QuadranglePreference" hypothesis, forcing construction
4343 # of quadrangles if the number of nodes on the opposite edges is not the same
4344 # while the total number of nodes on edges is even
4346 # @ingroup l3_hypos_additi
4347 def QuadranglePreference(self):
4348 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4349 CompareMethod=self.CompareEqualHyp)
4352 ## Defines "TrianglePreference" hypothesis, forcing construction
4353 # of triangles in the refinement area if the number of nodes
4354 # on the opposite edges is not the same
4356 # @ingroup l3_hypos_additi
4357 def TrianglePreference(self):
4358 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4359 CompareMethod=self.CompareEqualHyp)
4362 # Public class: Mesh_Tetrahedron
4363 # ------------------------------
4365 ## Defines a tetrahedron 3D algorithm
4367 # @ingroup l3_algos_basic
4368 class Mesh_Tetrahedron(Mesh_Algorithm):
4373 ## Private constructor.
4374 def __init__(self, mesh, algoType, geom=0):
4375 Mesh_Algorithm.__init__(self)
4377 if algoType == NETGEN:
4379 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4382 elif algoType == FULL_NETGEN:
4384 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4387 elif algoType == GHS3D:
4389 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4392 elif algoType == GHS3DPRL:
4393 CheckPlugin(GHS3DPRL)
4394 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4397 self.algoType = algoType
4399 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4400 # @param vol for the maximum volume of each tetrahedron
4401 # @param UseExisting if ==true - searches for the existing hypothesis created with
4402 # the same parameters, else (default) - creates a new one
4403 # @ingroup l3_hypos_maxvol
4404 def MaxElementVolume(self, vol, UseExisting=0):
4405 if self.algoType == NETGEN:
4406 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4407 CompareMethod=self.CompareMaxElementVolume)
4408 hyp.SetMaxElementVolume(vol)
4410 elif self.algoType == FULL_NETGEN:
4411 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4414 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4415 def CompareMaxElementVolume(self, hyp, args):
4416 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4418 ## Defines hypothesis having several parameters
4420 # @ingroup l3_hypos_netgen
4421 def Parameters(self, which=SOLE):
4425 if self.algoType == FULL_NETGEN:
4427 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4428 "libNETGENEngine.so", UseExisting=0)
4430 self.params = self.Hypothesis("NETGEN_Parameters", [],
4431 "libNETGENEngine.so", UseExisting=0)
4434 if self.algoType == GHS3D:
4435 self.params = self.Hypothesis("GHS3D_Parameters", [],
4436 "libGHS3DEngine.so", UseExisting=0)
4439 if self.algoType == GHS3DPRL:
4440 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4441 "libGHS3DPRLEngine.so", UseExisting=0)
4444 print "Algo supports no multi-parameter hypothesis"
4448 # Parameter of FULL_NETGEN
4449 # @ingroup l3_hypos_netgen
4450 def SetMaxSize(self, theSize):
4451 self.Parameters().SetMaxSize(theSize)
4453 ## Sets SecondOrder flag
4454 # Parameter of FULL_NETGEN
4455 # @ingroup l3_hypos_netgen
4456 def SetSecondOrder(self, theVal):
4457 self.Parameters().SetSecondOrder(theVal)
4459 ## Sets Optimize flag
4460 # Parameter of FULL_NETGEN
4461 # @ingroup l3_hypos_netgen
4462 def SetOptimize(self, theVal):
4463 self.Parameters().SetOptimize(theVal)
4466 # @param theFineness is:
4467 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4468 # Parameter of FULL_NETGEN
4469 # @ingroup l3_hypos_netgen
4470 def SetFineness(self, theFineness):
4471 self.Parameters().SetFineness(theFineness)
4474 # Parameter of FULL_NETGEN
4475 # @ingroup l3_hypos_netgen
4476 def SetGrowthRate(self, theRate):
4477 self.Parameters().SetGrowthRate(theRate)
4479 ## Sets NbSegPerEdge
4480 # Parameter of FULL_NETGEN
4481 # @ingroup l3_hypos_netgen
4482 def SetNbSegPerEdge(self, theVal):
4483 self.Parameters().SetNbSegPerEdge(theVal)
4485 ## Sets NbSegPerRadius
4486 # Parameter of FULL_NETGEN
4487 # @ingroup l3_hypos_netgen
4488 def SetNbSegPerRadius(self, theVal):
4489 self.Parameters().SetNbSegPerRadius(theVal)
4491 ## Sets number of segments overriding value set by SetLocalLength()
4492 # Only for algoType == NETGEN_FULL
4493 # @ingroup l3_hypos_netgen
4494 def SetNumberOfSegments(self, theVal):
4495 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4497 ## Sets number of segments overriding value set by SetNumberOfSegments()
4498 # Only for algoType == NETGEN_FULL
4499 # @ingroup l3_hypos_netgen
4500 def SetLocalLength(self, theVal):
4501 self.Parameters(SIMPLE).SetLocalLength(theVal)
4503 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4504 # Overrides value set by LengthFromEdges()
4505 # Only for algoType == NETGEN_FULL
4506 # @ingroup l3_hypos_netgen
4507 def MaxElementArea(self, area):
4508 self.Parameters(SIMPLE).SetMaxElementArea(area)
4510 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4511 # Overrides value set by MaxElementArea()
4512 # Only for algoType == NETGEN_FULL
4513 # @ingroup l3_hypos_netgen
4514 def LengthFromEdges(self):
4515 self.Parameters(SIMPLE).LengthFromEdges()
4517 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4518 # Overrides value set by MaxElementVolume()
4519 # Only for algoType == NETGEN_FULL
4520 # @ingroup l3_hypos_netgen
4521 def LengthFromFaces(self):
4522 self.Parameters(SIMPLE).LengthFromFaces()
4524 ## To mesh "holes" in a solid or not. Default is to mesh.
4525 # @ingroup l3_hypos_ghs3dh
4526 def SetToMeshHoles(self, toMesh):
4527 # Parameter of GHS3D
4528 self.Parameters().SetToMeshHoles(toMesh)
4530 ## Set Optimization level:
4531 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4532 # Strong_Optimization.
4533 # Default is Standard_Optimization
4534 # @ingroup l3_hypos_ghs3dh
4535 def SetOptimizationLevel(self, level):
4536 # Parameter of GHS3D
4537 self.Parameters().SetOptimizationLevel(level)
4539 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4540 # @ingroup l3_hypos_ghs3dh
4541 def SetMaximumMemory(self, MB):
4542 # Advanced parameter of GHS3D
4543 self.Parameters().SetMaximumMemory(MB)
4545 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4546 # automatic memory adjustment mode.
4547 # @ingroup l3_hypos_ghs3dh
4548 def SetInitialMemory(self, MB):
4549 # Advanced parameter of GHS3D
4550 self.Parameters().SetInitialMemory(MB)
4552 ## Path to working directory.
4553 # @ingroup l3_hypos_ghs3dh
4554 def SetWorkingDirectory(self, path):
4555 # Advanced parameter of GHS3D
4556 self.Parameters().SetWorkingDirectory(path)
4558 ## To keep working files or remove them. Log file remains in case of errors anyway.
4559 # @ingroup l3_hypos_ghs3dh
4560 def SetKeepFiles(self, toKeep):
4561 # Advanced parameter of GHS3D and GHS3DPRL
4562 self.Parameters().SetKeepFiles(toKeep)
4564 ## To set verbose level [0-10]. <ul>
4565 #<li> 0 - no standard output,
4566 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4567 # indicates when the final mesh is being saved. In addition the software
4568 # gives indication regarding the CPU time.
4569 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4570 # histogram of the skin mesh, quality statistics histogram together with
4571 # the characteristics of the final mesh.</ul>
4572 # @ingroup l3_hypos_ghs3dh
4573 def SetVerboseLevel(self, level):
4574 # Advanced parameter of GHS3D
4575 self.Parameters().SetVerboseLevel(level)
4577 ## To create new nodes.
4578 # @ingroup l3_hypos_ghs3dh
4579 def SetToCreateNewNodes(self, toCreate):
4580 # Advanced parameter of GHS3D
4581 self.Parameters().SetToCreateNewNodes(toCreate)
4583 ## To use boundary recovery version which tries to create mesh on a very poor
4584 # quality surface mesh.
4585 # @ingroup l3_hypos_ghs3dh
4586 def SetToUseBoundaryRecoveryVersion(self, toUse):
4587 # Advanced parameter of GHS3D
4588 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4590 ## Sets command line option as text.
4591 # @ingroup l3_hypos_ghs3dh
4592 def SetTextOption(self, option):
4593 # Advanced parameter of GHS3D
4594 self.Parameters().SetTextOption(option)
4596 ## Sets MED files name and path.
4597 def SetMEDName(self, value):
4598 self.Parameters().SetMEDName(value)
4600 ## Sets the number of partition of the initial mesh
4601 def SetNbPart(self, value):
4602 self.Parameters().SetNbPart(value)
4604 ## When big mesh, start tepal in background
4605 def SetBackground(self, value):
4606 self.Parameters().SetBackground(value)
4608 # Public class: Mesh_Hexahedron
4609 # ------------------------------
4611 ## Defines a hexahedron 3D algorithm
4613 # @ingroup l3_algos_basic
4614 class Mesh_Hexahedron(Mesh_Algorithm):
4619 ## Private constructor.
4620 def __init__(self, mesh, algoType=Hexa, geom=0):
4621 Mesh_Algorithm.__init__(self)
4623 self.algoType = algoType
4625 if algoType == Hexa:
4626 self.Create(mesh, geom, "Hexa_3D")
4629 elif algoType == Hexotic:
4630 CheckPlugin(Hexotic)
4631 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4634 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4635 # @ingroup l3_hypos_hexotic
4636 def MinMaxQuad(self, min=3, max=8, quad=True):
4637 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4639 self.params.SetHexesMinLevel(min)
4640 self.params.SetHexesMaxLevel(max)
4641 self.params.SetHexoticQuadrangles(quad)
4644 # Deprecated, only for compatibility!
4645 # Public class: Mesh_Netgen
4646 # ------------------------------
4648 ## Defines a NETGEN-based 2D or 3D algorithm
4649 # that needs no discrete boundary (i.e. independent)
4651 # This class is deprecated, only for compatibility!
4654 # @ingroup l3_algos_basic
4655 class Mesh_Netgen(Mesh_Algorithm):
4659 ## Private constructor.
4660 def __init__(self, mesh, is3D, geom=0):
4661 Mesh_Algorithm.__init__(self)
4667 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4671 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4674 ## Defines the hypothesis containing parameters of the algorithm
4675 def Parameters(self):
4677 hyp = self.Hypothesis("NETGEN_Parameters", [],
4678 "libNETGENEngine.so", UseExisting=0)
4680 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4681 "libNETGENEngine.so", UseExisting=0)
4684 # Public class: Mesh_Projection1D
4685 # ------------------------------
4687 ## Defines a projection 1D algorithm
4688 # @ingroup l3_algos_proj
4690 class Mesh_Projection1D(Mesh_Algorithm):
4692 ## Private constructor.
4693 def __init__(self, mesh, geom=0):
4694 Mesh_Algorithm.__init__(self)
4695 self.Create(mesh, geom, "Projection_1D")
4697 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4698 # a mesh pattern is taken, and, optionally, the association of vertices
4699 # between the source edge and a target edge (to which a hypothesis is assigned)
4700 # @param edge from which nodes distribution is taken
4701 # @param mesh from which nodes distribution is taken (optional)
4702 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4703 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4704 # to associate with \a srcV (optional)
4705 # @param UseExisting if ==true - searches for the existing hypothesis created with
4706 # the same parameters, else (default) - creates a new one
4707 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4708 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4710 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4711 hyp.SetSourceEdge( edge )
4712 if not mesh is None and isinstance(mesh, Mesh):
4713 mesh = mesh.GetMesh()
4714 hyp.SetSourceMesh( mesh )
4715 hyp.SetVertexAssociation( srcV, tgtV )
4718 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4719 #def CompareSourceEdge(self, hyp, args):
4720 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4724 # Public class: Mesh_Projection2D
4725 # ------------------------------
4727 ## Defines a projection 2D algorithm
4728 # @ingroup l3_algos_proj
4730 class Mesh_Projection2D(Mesh_Algorithm):
4732 ## Private constructor.
4733 def __init__(self, mesh, geom=0):
4734 Mesh_Algorithm.__init__(self)
4735 self.Create(mesh, geom, "Projection_2D")
4737 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4738 # a mesh pattern is taken, and, optionally, the association of vertices
4739 # between the source face and the target face (to which a hypothesis is assigned)
4740 # @param face from which the mesh pattern is taken
4741 # @param mesh from which the mesh pattern is taken (optional)
4742 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4743 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4744 # to associate with \a srcV1 (optional)
4745 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4746 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4747 # to associate with \a srcV2 (optional)
4748 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4749 # the same parameters, else (default) - forces the creation a new one
4751 # Note: all association vertices must belong to one edge of a face
4752 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4753 srcV2=None, tgtV2=None, UseExisting=0):
4754 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4756 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4757 hyp.SetSourceFace( face )
4758 if not mesh is None and isinstance(mesh, Mesh):
4759 mesh = mesh.GetMesh()
4760 hyp.SetSourceMesh( mesh )
4761 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4764 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4765 #def CompareSourceFace(self, hyp, args):
4766 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4769 # Public class: Mesh_Projection3D
4770 # ------------------------------
4772 ## Defines a projection 3D algorithm
4773 # @ingroup l3_algos_proj
4775 class Mesh_Projection3D(Mesh_Algorithm):
4777 ## Private constructor.
4778 def __init__(self, mesh, geom=0):
4779 Mesh_Algorithm.__init__(self)
4780 self.Create(mesh, geom, "Projection_3D")
4782 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4783 # the mesh pattern is taken, and, optionally, the association of vertices
4784 # between the source and the target solid (to which a hipothesis is assigned)
4785 # @param solid from where the mesh pattern is taken
4786 # @param mesh from where the mesh pattern is taken (optional)
4787 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4788 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4789 # to associate with \a srcV1 (optional)
4790 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4791 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4792 # to associate with \a srcV2 (optional)
4793 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4794 # the same parameters, else (default) - creates a new one
4796 # Note: association vertices must belong to one edge of a solid
4797 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4798 srcV2=0, tgtV2=0, UseExisting=0):
4799 hyp = self.Hypothesis("ProjectionSource3D",
4800 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4802 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4803 hyp.SetSource3DShape( solid )
4804 if not mesh is None and isinstance(mesh, Mesh):
4805 mesh = mesh.GetMesh()
4806 hyp.SetSourceMesh( mesh )
4807 if srcV1 and srcV2 and tgtV1 and tgtV2:
4808 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4809 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4812 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4813 #def CompareSourceShape3D(self, hyp, args):
4814 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4818 # Public class: Mesh_Prism
4819 # ------------------------
4821 ## Defines a 3D extrusion algorithm
4822 # @ingroup l3_algos_3dextr
4824 class Mesh_Prism3D(Mesh_Algorithm):
4826 ## Private constructor.
4827 def __init__(self, mesh, geom=0):
4828 Mesh_Algorithm.__init__(self)
4829 self.Create(mesh, geom, "Prism_3D")
4831 # Public class: Mesh_RadialPrism
4832 # -------------------------------
4834 ## Defines a Radial Prism 3D algorithm
4835 # @ingroup l3_algos_radialp
4837 class Mesh_RadialPrism3D(Mesh_Algorithm):
4839 ## Private constructor.
4840 def __init__(self, mesh, geom=0):
4841 Mesh_Algorithm.__init__(self)
4842 self.Create(mesh, geom, "RadialPrism_3D")
4844 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4845 self.nbLayers = None
4847 ## Return 3D hypothesis holding the 1D one
4848 def Get3DHypothesis(self):
4849 return self.distribHyp
4851 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4852 # hypothesis. Returns the created hypothesis
4853 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4854 #print "OwnHypothesis",hypType
4855 if not self.nbLayers is None:
4856 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4857 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4858 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4859 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4860 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4861 self.distribHyp.SetLayerDistribution( hyp )
4864 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4865 # prisms to build between the inner and outer shells
4866 # @param n number of layers
4867 # @param UseExisting if ==true - searches for the existing hypothesis created with
4868 # the same parameters, else (default) - creates a new one
4869 def NumberOfLayers(self, n, UseExisting=0):
4870 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4871 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4872 CompareMethod=self.CompareNumberOfLayers)
4873 self.nbLayers.SetNumberOfLayers( n )
4874 return self.nbLayers
4876 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4877 def CompareNumberOfLayers(self, hyp, args):
4878 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4880 ## Defines "LocalLength" hypothesis, specifying the segment length
4881 # to build between the inner and the outer shells
4882 # @param l the length of segments
4883 # @param p the precision of rounding
4884 def LocalLength(self, l, p=1e-07):
4885 hyp = self.OwnHypothesis("LocalLength", [l,p])
4890 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4891 # prisms to build between the inner and the outer shells.
4892 # @param n the number of layers
4893 # @param s the scale factor (optional)
4894 def NumberOfSegments(self, n, s=[]):
4896 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4898 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4899 hyp.SetDistrType( 1 )
4900 hyp.SetScaleFactor(s)
4901 hyp.SetNumberOfSegments(n)
4904 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4905 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4906 # @param start the length of the first segment
4907 # @param end the length of the last segment
4908 def Arithmetic1D(self, start, end ):
4909 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4910 hyp.SetLength(start, 1)
4911 hyp.SetLength(end , 0)
4914 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4915 # to build between the inner and the outer shells as geometric length increasing
4916 # @param start for the length of the first segment
4917 # @param end for the length of the last segment
4918 def StartEndLength(self, start, end):
4919 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4920 hyp.SetLength(start, 1)
4921 hyp.SetLength(end , 0)
4924 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4925 # to build between the inner and outer shells
4926 # @param fineness defines the quality of the mesh within the range [0-1]
4927 def AutomaticLength(self, fineness=0):
4928 hyp = self.OwnHypothesis("AutomaticLength")
4929 hyp.SetFineness( fineness )
4932 # Public class: Mesh_RadialQuadrangle1D2D
4933 # -------------------------------
4935 ## Defines a Radial Quadrangle 1D2D algorithm
4936 # @ingroup l2_algos_radialq
4938 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4940 ## Private constructor.
4941 def __init__(self, mesh, geom=0):
4942 Mesh_Algorithm.__init__(self)
4943 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4945 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4946 self.nbLayers = None
4948 ## Return 2D hypothesis holding the 1D one
4949 def Get2DHypothesis(self):
4950 return self.distribHyp
4952 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4953 # hypothesis. Returns the created hypothesis
4954 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4955 #print "OwnHypothesis",hypType
4956 if not self.nbLayers is None:
4957 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4958 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4959 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4960 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4961 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4962 self.distribHyp.SetLayerDistribution( hyp )
4965 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4966 # @param n number of layers
4967 # @param UseExisting if ==true - searches for the existing hypothesis created with
4968 # the same parameters, else (default) - creates a new one
4969 def NumberOfLayers2D(self, n, UseExisting=0):
4970 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4971 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4972 CompareMethod=self.CompareNumberOfLayers)
4973 self.nbLayers.SetNumberOfLayers( n )
4974 return self.nbLayers
4976 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4977 def CompareNumberOfLayers(self, hyp, args):
4978 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4980 ## Defines "LocalLength" hypothesis, specifying the segment length
4981 # @param l the length of segments
4982 # @param p the precision of rounding
4983 def LocalLength(self, l, p=1e-07):
4984 hyp = self.OwnHypothesis("LocalLength", [l,p])
4989 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4990 # @param n the number of layers
4991 # @param s the scale factor (optional)
4992 def NumberOfSegments(self, n, s=[]):
4994 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4996 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4997 hyp.SetDistrType( 1 )
4998 hyp.SetScaleFactor(s)
4999 hyp.SetNumberOfSegments(n)
5002 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5003 # with a length that changes in arithmetic progression
5004 # @param start the length of the first segment
5005 # @param end the length of the last segment
5006 def Arithmetic1D(self, start, end ):
5007 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5008 hyp.SetLength(start, 1)
5009 hyp.SetLength(end , 0)
5012 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5013 # as geometric length increasing
5014 # @param start for the length of the first segment
5015 # @param end for the length of the last segment
5016 def StartEndLength(self, start, end):
5017 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5018 hyp.SetLength(start, 1)
5019 hyp.SetLength(end , 0)
5022 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5023 # @param fineness defines the quality of the mesh within the range [0-1]
5024 def AutomaticLength(self, fineness=0):
5025 hyp = self.OwnHypothesis("AutomaticLength")
5026 hyp.SetFineness( fineness )
5030 # Private class: Mesh_UseExisting
5031 # -------------------------------
5032 class Mesh_UseExisting(Mesh_Algorithm):
5034 def __init__(self, dim, mesh, geom=0):
5036 self.Create(mesh, geom, "UseExisting_1D")
5038 self.Create(mesh, geom, "UseExisting_2D")
5041 import salome_notebook
5042 notebook = salome_notebook.notebook
5044 ##Return values of the notebook variables
5045 def ParseParameters(last, nbParams,nbParam, value):
5049 listSize = len(last)
5050 for n in range(0,nbParams):
5052 if counter < listSize:
5053 strResult = strResult + last[counter]
5055 strResult = strResult + ""
5057 if isinstance(value, str):
5058 if notebook.isVariable(value):
5059 result = notebook.get(value)
5060 strResult=strResult+value
5062 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5064 strResult=strResult+str(value)
5066 if nbParams - 1 != counter:
5067 strResult=strResult+var_separator #":"
5069 return result, strResult
5071 #Wrapper class for StdMeshers_LocalLength hypothesis
5072 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5074 ## Set Length parameter value
5075 # @param length numerical value or name of variable from notebook
5076 def SetLength(self, length):
5077 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5078 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5079 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5081 ## Set Precision parameter value
5082 # @param precision numerical value or name of variable from notebook
5083 def SetPrecision(self, precision):
5084 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5085 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5086 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5088 #Registering the new proxy for LocalLength
5089 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5092 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5093 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5095 def SetLayerDistribution(self, hypo):
5096 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5097 hypo.ClearParameters();
5098 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5100 #Registering the new proxy for LayerDistribution
5101 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5103 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5104 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5106 ## Set Length parameter value
5107 # @param length numerical value or name of variable from notebook
5108 def SetLength(self, length):
5109 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5110 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5111 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5113 #Registering the new proxy for SegmentLengthAroundVertex
5114 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5117 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5118 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5120 ## Set Length parameter value
5121 # @param length numerical value or name of variable from notebook
5122 # @param isStart true is length is Start Length, otherwise false
5123 def SetLength(self, length, isStart):
5127 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5128 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5129 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5131 #Registering the new proxy for Arithmetic1D
5132 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5134 #Wrapper class for StdMeshers_Deflection1D hypothesis
5135 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5137 ## Set Deflection parameter value
5138 # @param deflection numerical value or name of variable from notebook
5139 def SetDeflection(self, deflection):
5140 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5141 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5142 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5144 #Registering the new proxy for Deflection1D
5145 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5147 #Wrapper class for StdMeshers_StartEndLength hypothesis
5148 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5150 ## Set Length parameter value
5151 # @param length numerical value or name of variable from notebook
5152 # @param isStart true is length is Start Length, otherwise false
5153 def SetLength(self, length, isStart):
5157 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5158 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5159 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5161 #Registering the new proxy for StartEndLength
5162 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5164 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5165 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5167 ## Set Max Element Area parameter value
5168 # @param area numerical value or name of variable from notebook
5169 def SetMaxElementArea(self, area):
5170 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5171 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5172 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5174 #Registering the new proxy for MaxElementArea
5175 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5178 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5179 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5181 ## Set Max Element Volume parameter value
5182 # @param volume numerical value or name of variable from notebook
5183 def SetMaxElementVolume(self, volume):
5184 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5185 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5186 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5188 #Registering the new proxy for MaxElementVolume
5189 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5192 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5193 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5195 ## Set Number Of Layers parameter value
5196 # @param nbLayers numerical value or name of variable from notebook
5197 def SetNumberOfLayers(self, nbLayers):
5198 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5199 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5200 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5202 #Registering the new proxy for NumberOfLayers
5203 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5205 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5206 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5208 ## Set Number Of Segments parameter value
5209 # @param nbSeg numerical value or name of variable from notebook
5210 def SetNumberOfSegments(self, nbSeg):
5211 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5212 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5213 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5214 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5216 ## Set Scale Factor parameter value
5217 # @param factor numerical value or name of variable from notebook
5218 def SetScaleFactor(self, factor):
5219 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5220 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5221 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5223 #Registering the new proxy for NumberOfSegments
5224 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5226 if not noNETGENPlugin:
5227 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5228 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5230 ## Set Max Size parameter value
5231 # @param maxsize numerical value or name of variable from notebook
5232 def SetMaxSize(self, maxsize):
5233 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5234 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5235 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5236 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5238 ## Set Growth Rate parameter value
5239 # @param value numerical value or name of variable from notebook
5240 def SetGrowthRate(self, value):
5241 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5242 value, parameters = ParseParameters(lastParameters,4,2,value)
5243 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5244 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5246 ## Set Number of Segments per Edge parameter value
5247 # @param value numerical value or name of variable from notebook
5248 def SetNbSegPerEdge(self, value):
5249 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5250 value, parameters = ParseParameters(lastParameters,4,3,value)
5251 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5252 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5254 ## Set Number of Segments per Radius parameter value
5255 # @param value numerical value or name of variable from notebook
5256 def SetNbSegPerRadius(self, value):
5257 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5258 value, parameters = ParseParameters(lastParameters,4,4,value)
5259 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5260 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5262 #Registering the new proxy for NETGENPlugin_Hypothesis
5263 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5266 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5267 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5270 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5271 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5273 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5274 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5276 ## Set Number of Segments parameter value
5277 # @param nbSeg numerical value or name of variable from notebook
5278 def SetNumberOfSegments(self, nbSeg):
5279 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5280 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5281 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5282 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5284 ## Set Local Length parameter value
5285 # @param length numerical value or name of variable from notebook
5286 def SetLocalLength(self, length):
5287 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5288 length, parameters = ParseParameters(lastParameters,2,1,length)
5289 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5290 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5292 ## Set Max Element Area parameter value
5293 # @param area numerical value or name of variable from notebook
5294 def SetMaxElementArea(self, area):
5295 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5296 area, parameters = ParseParameters(lastParameters,2,2,area)
5297 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5298 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5300 def LengthFromEdges(self):
5301 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5303 value, parameters = ParseParameters(lastParameters,2,2,value)
5304 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5305 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5307 #Registering the new proxy for NETGEN_SimpleParameters_2D
5308 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5311 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5312 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5313 ## Set Max Element Volume parameter value
5314 # @param volume numerical value or name of variable from notebook
5315 def SetMaxElementVolume(self, volume):
5316 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5317 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5318 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5319 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5321 def LengthFromFaces(self):
5322 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5324 value, parameters = ParseParameters(lastParameters,3,3,value)
5325 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5326 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5328 #Registering the new proxy for NETGEN_SimpleParameters_3D
5329 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5331 pass # if not noNETGENPlugin:
5333 class Pattern(SMESH._objref_SMESH_Pattern):
5335 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5337 if isinstance(theNodeIndexOnKeyPoint1,str):
5339 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5341 theNodeIndexOnKeyPoint1 -= 1
5342 theMesh.SetParameters(Parameters)
5343 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5345 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5348 if isinstance(theNode000Index,str):
5350 if isinstance(theNode001Index,str):
5352 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5354 theNode000Index -= 1
5356 theNode001Index -= 1
5357 theMesh.SetParameters(Parameters)
5358 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5360 #Registering the new proxy for Pattern
5361 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)