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 ## Return submesh objects list in meshing order
1205 # @return list of list of submesh objects
1206 # @ingroup l2_construct
1207 def GetMeshOrder(self):
1208 return self.mesh.GetMeshOrder()
1210 ## Return submesh objects list in meshing order
1211 # @return list of list of submesh objects
1212 # @ingroup l2_construct
1213 def SetMeshOrder(self, submeshes):
1214 return self.mesh.SetMeshOrder(submeshes)
1216 ## Removes all nodes and elements
1217 # @ingroup l2_construct
1220 if salome.sg.hasDesktop():
1221 smeshgui = salome.ImportComponentGUI("SMESH")
1222 smeshgui.Init(self.mesh.GetStudyId())
1223 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1224 salome.sg.updateObjBrowser(1)
1226 ## Removes all nodes and elements of indicated shape
1227 # @ingroup l2_construct
1228 def ClearSubMesh(self, geomId):
1229 self.mesh.ClearSubMesh(geomId)
1230 if salome.sg.hasDesktop():
1231 smeshgui = salome.ImportComponentGUI("SMESH")
1232 smeshgui.Init(self.mesh.GetStudyId())
1233 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1234 salome.sg.updateObjBrowser(1)
1236 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1237 # @param fineness [0,-1] defines mesh fineness
1238 # @return True or False
1239 # @ingroup l3_algos_basic
1240 def AutomaticTetrahedralization(self, fineness=0):
1241 dim = self.MeshDimension()
1243 self.RemoveGlobalHypotheses()
1244 self.Segment().AutomaticLength(fineness)
1246 self.Triangle().LengthFromEdges()
1249 self.Tetrahedron(NETGEN)
1251 return self.Compute()
1253 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1254 # @param fineness [0,-1] defines mesh fineness
1255 # @return True or False
1256 # @ingroup l3_algos_basic
1257 def AutomaticHexahedralization(self, fineness=0):
1258 dim = self.MeshDimension()
1259 # assign the hypotheses
1260 self.RemoveGlobalHypotheses()
1261 self.Segment().AutomaticLength(fineness)
1268 return self.Compute()
1270 ## Assigns a hypothesis
1271 # @param hyp a hypothesis to assign
1272 # @param geom a subhape of mesh geometry
1273 # @return SMESH.Hypothesis_Status
1274 # @ingroup l2_hypotheses
1275 def AddHypothesis(self, hyp, geom=0):
1276 if isinstance( hyp, Mesh_Algorithm ):
1277 hyp = hyp.GetAlgorithm()
1282 geom = self.mesh.GetShapeToMesh()
1284 status = self.mesh.AddHypothesis(geom, hyp)
1285 isAlgo = hyp._narrow( SMESH_Algo )
1286 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1289 ## Unassigns a hypothesis
1290 # @param hyp a hypothesis to unassign
1291 # @param geom a subshape of mesh geometry
1292 # @return SMESH.Hypothesis_Status
1293 # @ingroup l2_hypotheses
1294 def RemoveHypothesis(self, hyp, geom=0):
1295 if isinstance( hyp, Mesh_Algorithm ):
1296 hyp = hyp.GetAlgorithm()
1301 status = self.mesh.RemoveHypothesis(geom, hyp)
1304 ## Gets the list of hypotheses added on a geometry
1305 # @param geom a subshape of mesh geometry
1306 # @return the sequence of SMESH_Hypothesis
1307 # @ingroup l2_hypotheses
1308 def GetHypothesisList(self, geom):
1309 return self.mesh.GetHypothesisList( geom )
1311 ## Removes all global hypotheses
1312 # @ingroup l2_hypotheses
1313 def RemoveGlobalHypotheses(self):
1314 current_hyps = self.mesh.GetHypothesisList( self.geom )
1315 for hyp in current_hyps:
1316 self.mesh.RemoveHypothesis( self.geom, hyp )
1320 ## Creates a mesh group based on the geometric object \a grp
1321 # and gives a \a name, \n if this parameter is not defined
1322 # the name is the same as the geometric group name \n
1323 # Note: Works like GroupOnGeom().
1324 # @param grp a geometric group, a vertex, an edge, a face or a solid
1325 # @param name the name of the mesh group
1326 # @return SMESH_GroupOnGeom
1327 # @ingroup l2_grps_create
1328 def Group(self, grp, name=""):
1329 return self.GroupOnGeom(grp, name)
1331 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1332 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1333 # @param f the file name
1334 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1335 # @param opt boolean parameter for creating/not creating
1336 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1337 # @ingroup l2_impexp
1338 def ExportToMED(self, f, version, opt=0):
1339 self.mesh.ExportToMED(f, opt, version)
1341 ## Exports the mesh in a file in MED format
1342 # @param f is the file name
1343 # @param auto_groups boolean parameter for creating/not creating
1344 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1345 # the typical use is auto_groups=false.
1346 # @param version MED format version(MED_V2_1 or MED_V2_2)
1347 # @ingroup l2_impexp
1348 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1349 self.mesh.ExportToMED(f, auto_groups, version)
1351 ## Exports the mesh in a file in DAT format
1352 # @param f the file name
1353 # @ingroup l2_impexp
1354 def ExportDAT(self, f):
1355 self.mesh.ExportDAT(f)
1357 ## Exports the mesh in a file in UNV format
1358 # @param f the file name
1359 # @ingroup l2_impexp
1360 def ExportUNV(self, f):
1361 self.mesh.ExportUNV(f)
1363 ## Export the mesh in a file in STL format
1364 # @param f the file name
1365 # @param ascii defines the file encoding
1366 # @ingroup l2_impexp
1367 def ExportSTL(self, f, ascii=1):
1368 self.mesh.ExportSTL(f, ascii)
1371 # Operations with groups:
1372 # ----------------------
1374 ## Creates an empty mesh group
1375 # @param elementType the type of elements in the group
1376 # @param name the name of the mesh group
1377 # @return SMESH_Group
1378 # @ingroup l2_grps_create
1379 def CreateEmptyGroup(self, elementType, name):
1380 return self.mesh.CreateGroup(elementType, name)
1382 ## Creates a mesh group based on the geometrical object \a grp
1383 # and gives a \a name, \n if this parameter is not defined
1384 # the name is the same as the geometrical group name
1385 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1386 # @param name the name of the mesh group
1387 # @param typ the type of elements in the group. If not set, it is
1388 # automatically detected by the type of the geometry
1389 # @return SMESH_GroupOnGeom
1390 # @ingroup l2_grps_create
1391 def GroupOnGeom(self, grp, name="", typ=None):
1393 name = grp.GetName()
1396 tgeo = str(grp.GetShapeType())
1397 if tgeo == "VERTEX":
1399 elif tgeo == "EDGE":
1401 elif tgeo == "FACE":
1403 elif tgeo == "SOLID":
1405 elif tgeo == "SHELL":
1407 elif tgeo == "COMPOUND":
1408 try: # it raises on a compound of compounds
1409 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1410 print "Mesh.Group: empty geometric group", GetName( grp )
1415 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1417 tgeo = self.geompyD.GetType(grp)
1418 if tgeo == geompyDC.ShapeType["VERTEX"]:
1420 elif tgeo == geompyDC.ShapeType["EDGE"]:
1422 elif tgeo == geompyDC.ShapeType["FACE"]:
1424 elif tgeo == geompyDC.ShapeType["SOLID"]:
1430 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1431 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1432 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1440 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1443 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1445 ## Creates a mesh group by the given ids of elements
1446 # @param groupName the name of the mesh group
1447 # @param elementType the type of elements in the group
1448 # @param elemIDs the list of ids
1449 # @return SMESH_Group
1450 # @ingroup l2_grps_create
1451 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1452 group = self.mesh.CreateGroup(elementType, groupName)
1456 ## Creates a mesh group by the given conditions
1457 # @param groupName the name of the mesh group
1458 # @param elementType the type of elements in the group
1459 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1460 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1461 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1462 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1463 # @return SMESH_Group
1464 # @ingroup l2_grps_create
1468 CritType=FT_Undefined,
1471 UnaryOp=FT_Undefined):
1472 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1473 group = self.MakeGroupByCriterion(groupName, aCriterion)
1476 ## Creates a mesh group by the given criterion
1477 # @param groupName the name of the mesh group
1478 # @param Criterion the instance of Criterion class
1479 # @return SMESH_Group
1480 # @ingroup l2_grps_create
1481 def MakeGroupByCriterion(self, groupName, Criterion):
1482 aFilterMgr = self.smeshpyD.CreateFilterManager()
1483 aFilter = aFilterMgr.CreateFilter()
1485 aCriteria.append(Criterion)
1486 aFilter.SetCriteria(aCriteria)
1487 group = self.MakeGroupByFilter(groupName, aFilter)
1490 ## Creates a mesh group by the given criteria (list of criteria)
1491 # @param groupName the name of the mesh group
1492 # @param theCriteria the list of criteria
1493 # @return SMESH_Group
1494 # @ingroup l2_grps_create
1495 def MakeGroupByCriteria(self, groupName, theCriteria):
1496 aFilterMgr = self.smeshpyD.CreateFilterManager()
1497 aFilter = aFilterMgr.CreateFilter()
1498 aFilter.SetCriteria(theCriteria)
1499 group = self.MakeGroupByFilter(groupName, aFilter)
1502 ## Creates a mesh group by the given filter
1503 # @param groupName the name of the mesh group
1504 # @param theFilter the instance of Filter class
1505 # @return SMESH_Group
1506 # @ingroup l2_grps_create
1507 def MakeGroupByFilter(self, groupName, theFilter):
1508 anIds = theFilter.GetElementsId(self.mesh)
1509 anElemType = theFilter.GetElementType()
1510 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1513 ## Passes mesh elements through the given filter and return IDs of fitting elements
1514 # @param theFilter SMESH_Filter
1515 # @return a list of ids
1516 # @ingroup l1_controls
1517 def GetIdsFromFilter(self, theFilter):
1518 return theFilter.GetElementsId(self.mesh)
1520 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1521 # Returns a list of special structures (borders).
1522 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1523 # @ingroup l1_controls
1524 def GetFreeBorders(self):
1525 aFilterMgr = self.smeshpyD.CreateFilterManager()
1526 aPredicate = aFilterMgr.CreateFreeEdges()
1527 aPredicate.SetMesh(self.mesh)
1528 aBorders = aPredicate.GetBorders()
1532 # @ingroup l2_grps_delete
1533 def RemoveGroup(self, group):
1534 self.mesh.RemoveGroup(group)
1536 ## Removes a group with its contents
1537 # @ingroup l2_grps_delete
1538 def RemoveGroupWithContents(self, group):
1539 self.mesh.RemoveGroupWithContents(group)
1541 ## Gets the list of groups existing in the mesh
1542 # @return a sequence of SMESH_GroupBase
1543 # @ingroup l2_grps_create
1544 def GetGroups(self):
1545 return self.mesh.GetGroups()
1547 ## Gets the number of groups existing in the mesh
1548 # @return the quantity of groups as an integer value
1549 # @ingroup l2_grps_create
1551 return self.mesh.NbGroups()
1553 ## Gets the list of names of groups existing in the mesh
1554 # @return list of strings
1555 # @ingroup l2_grps_create
1556 def GetGroupNames(self):
1557 groups = self.GetGroups()
1559 for group in groups:
1560 names.append(group.GetName())
1563 ## Produces a union of two groups
1564 # A new group is created. All mesh elements that are
1565 # present in the initial groups are added to the new one
1566 # @return an instance of SMESH_Group
1567 # @ingroup l2_grps_operon
1568 def UnionGroups(self, group1, group2, name):
1569 return self.mesh.UnionGroups(group1, group2, name)
1571 ## Produces a union list of groups
1572 # New group is created. All mesh elements that are present in
1573 # initial groups are added to the new one
1574 # @return an instance of SMESH_Group
1575 # @ingroup l2_grps_operon
1576 def UnionListOfGroups(self, groups, name):
1577 return self.mesh.UnionListOfGroups(groups, name)
1579 ## Prodices an intersection of two groups
1580 # A new group is created. All mesh elements that are common
1581 # for the two initial groups are added to the new one.
1582 # @return an instance of SMESH_Group
1583 # @ingroup l2_grps_operon
1584 def IntersectGroups(self, group1, group2, name):
1585 return self.mesh.IntersectGroups(group1, group2, name)
1587 ## Produces an intersection of groups
1588 # New group is created. All mesh elements that are present in all
1589 # initial groups simultaneously are added to the new one
1590 # @return an instance of SMESH_Group
1591 # @ingroup l2_grps_operon
1592 def IntersectListOfGroups(self, groups, name):
1593 return self.mesh.IntersectListOfGroups(groups, name)
1595 ## Produces a cut of two groups
1596 # A new group is created. All mesh elements that are present in
1597 # the main group but are not present in the tool group are added to the new one
1598 # @return an instance of SMESH_Group
1599 # @ingroup l2_grps_operon
1600 def CutGroups(self, main_group, tool_group, name):
1601 return self.mesh.CutGroups(main_group, tool_group, name)
1603 ## Produces a cut of groups
1604 # A new group is created. All mesh elements that are present in main groups
1605 # but do not present in tool groups are added to the new one
1606 # @return an instance of SMESH_Group
1607 # @ingroup l2_grps_operon
1608 def CutListOfGroups(self, main_groups, tool_groups, name):
1609 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1611 ## Produces a group of elements with specified element type using list of existing groups
1612 # A new group is created. System
1613 # 1) extract all nodes on which groups elements are built
1614 # 2) combine all elements of specified dimension laying on these nodes
1615 # @return an instance of SMESH_Group
1616 # @ingroup l2_grps_operon
1617 def CreateDimGroup(self, groups, elem_type, name):
1618 return self.mesh.CreateDimGroup(groups, elem_type, name)
1621 ## Convert group on geom into standalone group
1622 # @ingroup l2_grps_delete
1623 def ConvertToStandalone(self, group):
1624 return self.mesh.ConvertToStandalone(group)
1626 # Get some info about mesh:
1627 # ------------------------
1629 ## Returns the log of nodes and elements added or removed
1630 # since the previous clear of the log.
1631 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1632 # @return list of log_block structures:
1637 # @ingroup l1_auxiliary
1638 def GetLog(self, clearAfterGet):
1639 return self.mesh.GetLog(clearAfterGet)
1641 ## Clears the log of nodes and elements added or removed since the previous
1642 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1643 # @ingroup l1_auxiliary
1645 self.mesh.ClearLog()
1647 ## Toggles auto color mode on the object.
1648 # @param theAutoColor the flag which toggles auto color mode.
1649 # @ingroup l1_auxiliary
1650 def SetAutoColor(self, theAutoColor):
1651 self.mesh.SetAutoColor(theAutoColor)
1653 ## Gets flag of object auto color mode.
1654 # @return True or False
1655 # @ingroup l1_auxiliary
1656 def GetAutoColor(self):
1657 return self.mesh.GetAutoColor()
1659 ## Gets the internal ID
1660 # @return integer value, which is the internal Id of the mesh
1661 # @ingroup l1_auxiliary
1663 return self.mesh.GetId()
1666 # @return integer value, which is the study Id of the mesh
1667 # @ingroup l1_auxiliary
1668 def GetStudyId(self):
1669 return self.mesh.GetStudyId()
1671 ## Checks the group names for duplications.
1672 # Consider the maximum group name length stored in MED file.
1673 # @return True or False
1674 # @ingroup l1_auxiliary
1675 def HasDuplicatedGroupNamesMED(self):
1676 return self.mesh.HasDuplicatedGroupNamesMED()
1678 ## Obtains the mesh editor tool
1679 # @return an instance of SMESH_MeshEditor
1680 # @ingroup l1_modifying
1681 def GetMeshEditor(self):
1682 return self.mesh.GetMeshEditor()
1685 # @return an instance of SALOME_MED::MESH
1686 # @ingroup l1_auxiliary
1687 def GetMEDMesh(self):
1688 return self.mesh.GetMEDMesh()
1691 # Get informations about mesh contents:
1692 # ------------------------------------
1694 ## Gets the mesh stattistic
1695 # @return dictionary type element - count of elements
1696 # @ingroup l1_meshinfo
1697 def GetMeshInfo(self, obj = None):
1698 if not obj: obj = self.mesh
1699 return self.smeshpyD.GetMeshInfo(obj)
1701 ## Returns the number of nodes in the mesh
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1705 return self.mesh.NbNodes()
1707 ## Returns the number of elements in the mesh
1708 # @return an integer value
1709 # @ingroup l1_meshinfo
1710 def NbElements(self):
1711 return self.mesh.NbElements()
1713 ## Returns the number of 0d elements in the mesh
1714 # @return an integer value
1715 # @ingroup l1_meshinfo
1716 def Nb0DElements(self):
1717 return self.mesh.Nb0DElements()
1719 ## Returns the number of edges in the mesh
1720 # @return an integer value
1721 # @ingroup l1_meshinfo
1723 return self.mesh.NbEdges()
1725 ## Returns the number of edges with the given order in the mesh
1726 # @param elementOrder the order of elements:
1727 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1728 # @return an integer value
1729 # @ingroup l1_meshinfo
1730 def NbEdgesOfOrder(self, elementOrder):
1731 return self.mesh.NbEdgesOfOrder(elementOrder)
1733 ## Returns the number of faces in the mesh
1734 # @return an integer value
1735 # @ingroup l1_meshinfo
1737 return self.mesh.NbFaces()
1739 ## Returns the number of faces with the given order in the mesh
1740 # @param elementOrder the order of elements:
1741 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1742 # @return an integer value
1743 # @ingroup l1_meshinfo
1744 def NbFacesOfOrder(self, elementOrder):
1745 return self.mesh.NbFacesOfOrder(elementOrder)
1747 ## Returns the number of triangles in the mesh
1748 # @return an integer value
1749 # @ingroup l1_meshinfo
1750 def NbTriangles(self):
1751 return self.mesh.NbTriangles()
1753 ## Returns the number of triangles with the given order in the mesh
1754 # @param elementOrder is the order of elements:
1755 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1756 # @return an integer value
1757 # @ingroup l1_meshinfo
1758 def NbTrianglesOfOrder(self, elementOrder):
1759 return self.mesh.NbTrianglesOfOrder(elementOrder)
1761 ## Returns the number of quadrangles in the mesh
1762 # @return an integer value
1763 # @ingroup l1_meshinfo
1764 def NbQuadrangles(self):
1765 return self.mesh.NbQuadrangles()
1767 ## Returns the number of quadrangles with the given order in the mesh
1768 # @param elementOrder the order of elements:
1769 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1770 # @return an integer value
1771 # @ingroup l1_meshinfo
1772 def NbQuadranglesOfOrder(self, elementOrder):
1773 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1775 ## Returns the number of polygons in the mesh
1776 # @return an integer value
1777 # @ingroup l1_meshinfo
1778 def NbPolygons(self):
1779 return self.mesh.NbPolygons()
1781 ## Returns the number of volumes in the mesh
1782 # @return an integer value
1783 # @ingroup l1_meshinfo
1784 def NbVolumes(self):
1785 return self.mesh.NbVolumes()
1787 ## Returns the number of volumes with the given order in the mesh
1788 # @param elementOrder the order of elements:
1789 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1790 # @return an integer value
1791 # @ingroup l1_meshinfo
1792 def NbVolumesOfOrder(self, elementOrder):
1793 return self.mesh.NbVolumesOfOrder(elementOrder)
1795 ## Returns the number of tetrahedrons in the mesh
1796 # @return an integer value
1797 # @ingroup l1_meshinfo
1799 return self.mesh.NbTetras()
1801 ## Returns the number of tetrahedrons with the given order in the mesh
1802 # @param elementOrder the order of elements:
1803 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1804 # @return an integer value
1805 # @ingroup l1_meshinfo
1806 def NbTetrasOfOrder(self, elementOrder):
1807 return self.mesh.NbTetrasOfOrder(elementOrder)
1809 ## Returns the number of hexahedrons in the mesh
1810 # @return an integer value
1811 # @ingroup l1_meshinfo
1813 return self.mesh.NbHexas()
1815 ## Returns the number of hexahedrons with the given order in the mesh
1816 # @param elementOrder the order of elements:
1817 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1818 # @return an integer value
1819 # @ingroup l1_meshinfo
1820 def NbHexasOfOrder(self, elementOrder):
1821 return self.mesh.NbHexasOfOrder(elementOrder)
1823 ## Returns the number of pyramids in the mesh
1824 # @return an integer value
1825 # @ingroup l1_meshinfo
1826 def NbPyramids(self):
1827 return self.mesh.NbPyramids()
1829 ## Returns the number of pyramids with the given order in the mesh
1830 # @param elementOrder the order of elements:
1831 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1832 # @return an integer value
1833 # @ingroup l1_meshinfo
1834 def NbPyramidsOfOrder(self, elementOrder):
1835 return self.mesh.NbPyramidsOfOrder(elementOrder)
1837 ## Returns the number of prisms in the mesh
1838 # @return an integer value
1839 # @ingroup l1_meshinfo
1841 return self.mesh.NbPrisms()
1843 ## Returns the number of prisms with the given order in the mesh
1844 # @param elementOrder the order of elements:
1845 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1846 # @return an integer value
1847 # @ingroup l1_meshinfo
1848 def NbPrismsOfOrder(self, elementOrder):
1849 return self.mesh.NbPrismsOfOrder(elementOrder)
1851 ## Returns the number of polyhedrons in the mesh
1852 # @return an integer value
1853 # @ingroup l1_meshinfo
1854 def NbPolyhedrons(self):
1855 return self.mesh.NbPolyhedrons()
1857 ## Returns the number of submeshes in the mesh
1858 # @return an integer value
1859 # @ingroup l1_meshinfo
1860 def NbSubMesh(self):
1861 return self.mesh.NbSubMesh()
1863 ## Returns the list of mesh elements IDs
1864 # @return the list of integer values
1865 # @ingroup l1_meshinfo
1866 def GetElementsId(self):
1867 return self.mesh.GetElementsId()
1869 ## Returns the list of IDs of mesh elements with the given type
1870 # @param elementType the required type of elements
1871 # @return list of integer values
1872 # @ingroup l1_meshinfo
1873 def GetElementsByType(self, elementType):
1874 return self.mesh.GetElementsByType(elementType)
1876 ## Returns the list of mesh nodes IDs
1877 # @return the list of integer values
1878 # @ingroup l1_meshinfo
1879 def GetNodesId(self):
1880 return self.mesh.GetNodesId()
1882 # Get the information about mesh elements:
1883 # ------------------------------------
1885 ## Returns the type of mesh element
1886 # @return the value from SMESH::ElementType enumeration
1887 # @ingroup l1_meshinfo
1888 def GetElementType(self, id, iselem):
1889 return self.mesh.GetElementType(id, iselem)
1891 ## Returns the list of submesh elements IDs
1892 # @param Shape a geom object(subshape) IOR
1893 # Shape must be the subshape of a ShapeToMesh()
1894 # @return the list of integer values
1895 # @ingroup l1_meshinfo
1896 def GetSubMeshElementsId(self, Shape):
1897 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1898 ShapeID = Shape.GetSubShapeIndices()[0]
1901 return self.mesh.GetSubMeshElementsId(ShapeID)
1903 ## Returns the list of submesh nodes IDs
1904 # @param Shape a geom object(subshape) IOR
1905 # Shape must be the subshape of a ShapeToMesh()
1906 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1907 # @return the list of integer values
1908 # @ingroup l1_meshinfo
1909 def GetSubMeshNodesId(self, Shape, all):
1910 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1911 ShapeID = Shape.GetSubShapeIndices()[0]
1914 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1916 ## Returns type of elements on given shape
1917 # @param Shape a geom object(subshape) IOR
1918 # Shape must be a subshape of a ShapeToMesh()
1919 # @return element type
1920 # @ingroup l1_meshinfo
1921 def GetSubMeshElementType(self, Shape):
1922 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1923 ShapeID = Shape.GetSubShapeIndices()[0]
1926 return self.mesh.GetSubMeshElementType(ShapeID)
1928 ## Gets the mesh description
1929 # @return string value
1930 # @ingroup l1_meshinfo
1932 return self.mesh.Dump()
1935 # Get the information about nodes and elements of a mesh by its IDs:
1936 # -----------------------------------------------------------
1938 ## Gets XYZ coordinates of a node
1939 # \n If there is no nodes for the given ID - returns an empty list
1940 # @return a list of double precision values
1941 # @ingroup l1_meshinfo
1942 def GetNodeXYZ(self, id):
1943 return self.mesh.GetNodeXYZ(id)
1945 ## Returns list of IDs of inverse elements for the given node
1946 # \n If there is no node for the given ID - returns an empty list
1947 # @return a list of integer values
1948 # @ingroup l1_meshinfo
1949 def GetNodeInverseElements(self, id):
1950 return self.mesh.GetNodeInverseElements(id)
1952 ## @brief Returns the position of a node on the shape
1953 # @return SMESH::NodePosition
1954 # @ingroup l1_meshinfo
1955 def GetNodePosition(self,NodeID):
1956 return self.mesh.GetNodePosition(NodeID)
1958 ## If the given element is a node, returns the ID of shape
1959 # \n If there is no node for the given ID - returns -1
1960 # @return an integer value
1961 # @ingroup l1_meshinfo
1962 def GetShapeID(self, id):
1963 return self.mesh.GetShapeID(id)
1965 ## Returns the ID of the result shape after
1966 # FindShape() from SMESH_MeshEditor for the given element
1967 # \n If there is no element for the given ID - returns -1
1968 # @return an integer value
1969 # @ingroup l1_meshinfo
1970 def GetShapeIDForElem(self,id):
1971 return self.mesh.GetShapeIDForElem(id)
1973 ## Returns the number of nodes for the given element
1974 # \n If there is no element for the given ID - returns -1
1975 # @return an integer value
1976 # @ingroup l1_meshinfo
1977 def GetElemNbNodes(self, id):
1978 return self.mesh.GetElemNbNodes(id)
1980 ## Returns the node ID the given index for the given element
1981 # \n If there is no element for the given ID - returns -1
1982 # \n If there is no node for the given index - returns -2
1983 # @return an integer value
1984 # @ingroup l1_meshinfo
1985 def GetElemNode(self, id, index):
1986 return self.mesh.GetElemNode(id, index)
1988 ## Returns the IDs of nodes of the given element
1989 # @return a list of integer values
1990 # @ingroup l1_meshinfo
1991 def GetElemNodes(self, id):
1992 return self.mesh.GetElemNodes(id)
1994 ## Returns true if the given node is the medium node in the given quadratic element
1995 # @ingroup l1_meshinfo
1996 def IsMediumNode(self, elementID, nodeID):
1997 return self.mesh.IsMediumNode(elementID, nodeID)
1999 ## Returns true if the given node is the medium node in one of quadratic elements
2000 # @ingroup l1_meshinfo
2001 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2002 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2004 ## Returns the number of edges for the given element
2005 # @ingroup l1_meshinfo
2006 def ElemNbEdges(self, id):
2007 return self.mesh.ElemNbEdges(id)
2009 ## Returns the number of faces for the given element
2010 # @ingroup l1_meshinfo
2011 def ElemNbFaces(self, id):
2012 return self.mesh.ElemNbFaces(id)
2014 ## Returns true if the given element is a polygon
2015 # @ingroup l1_meshinfo
2016 def IsPoly(self, id):
2017 return self.mesh.IsPoly(id)
2019 ## Returns true if the given element is quadratic
2020 # @ingroup l1_meshinfo
2021 def IsQuadratic(self, id):
2022 return self.mesh.IsQuadratic(id)
2024 ## Returns XYZ coordinates of the barycenter of the given element
2025 # \n If there is no element for the given ID - returns an empty list
2026 # @return a list of three double values
2027 # @ingroup l1_meshinfo
2028 def BaryCenter(self, id):
2029 return self.mesh.BaryCenter(id)
2032 # Mesh edition (SMESH_MeshEditor functionality):
2033 # ---------------------------------------------
2035 ## Removes the elements from the mesh by ids
2036 # @param IDsOfElements is a list of ids of elements to remove
2037 # @return True or False
2038 # @ingroup l2_modif_del
2039 def RemoveElements(self, IDsOfElements):
2040 return self.editor.RemoveElements(IDsOfElements)
2042 ## Removes nodes from mesh by ids
2043 # @param IDsOfNodes is a list of ids of nodes to remove
2044 # @return True or False
2045 # @ingroup l2_modif_del
2046 def RemoveNodes(self, IDsOfNodes):
2047 return self.editor.RemoveNodes(IDsOfNodes)
2049 ## Add a node to the mesh by coordinates
2050 # @return Id of the new node
2051 # @ingroup l2_modif_add
2052 def AddNode(self, x, y, z):
2053 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2054 self.mesh.SetParameters(Parameters)
2055 return self.editor.AddNode( x, y, z)
2057 ## Creates a 0D element on a node with given number.
2058 # @param IDOfNode the ID of node for creation of the element.
2059 # @return the Id of the new 0D element
2060 # @ingroup l2_modif_add
2061 def Add0DElement(self, IDOfNode):
2062 return self.editor.Add0DElement(IDOfNode)
2064 ## Creates a linear or quadratic edge (this is determined
2065 # by the number of given nodes).
2066 # @param IDsOfNodes the list of node IDs for creation of the element.
2067 # The order of nodes in this list should correspond to the description
2068 # of MED. \n This description is located by the following link:
2069 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2070 # @return the Id of the new edge
2071 # @ingroup l2_modif_add
2072 def AddEdge(self, IDsOfNodes):
2073 return self.editor.AddEdge(IDsOfNodes)
2075 ## Creates a linear or quadratic face (this is determined
2076 # by the number of given nodes).
2077 # @param IDsOfNodes the list of node IDs for creation of the element.
2078 # The order of nodes in this list should correspond to the description
2079 # of MED. \n This description is located by the following link:
2080 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2081 # @return the Id of the new face
2082 # @ingroup l2_modif_add
2083 def AddFace(self, IDsOfNodes):
2084 return self.editor.AddFace(IDsOfNodes)
2086 ## Adds a polygonal face to the mesh by the list of node IDs
2087 # @param IdsOfNodes the list of node IDs for creation of the element.
2088 # @return the Id of the new face
2089 # @ingroup l2_modif_add
2090 def AddPolygonalFace(self, IdsOfNodes):
2091 return self.editor.AddPolygonalFace(IdsOfNodes)
2093 ## Creates both simple and quadratic volume (this is determined
2094 # by the number of given nodes).
2095 # @param IDsOfNodes the list of node IDs for creation of the element.
2096 # The order of nodes in this list should correspond to the description
2097 # of MED. \n This description is located by the following link:
2098 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2099 # @return the Id of the new volumic element
2100 # @ingroup l2_modif_add
2101 def AddVolume(self, IDsOfNodes):
2102 return self.editor.AddVolume(IDsOfNodes)
2104 ## Creates a volume of many faces, giving nodes for each face.
2105 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2106 # @param Quantities the list of integer values, Quantities[i]
2107 # gives the quantity of nodes in face number i.
2108 # @return the Id of the new volumic element
2109 # @ingroup l2_modif_add
2110 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2111 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2113 ## Creates a volume of many faces, giving the IDs of the existing faces.
2114 # @param IdsOfFaces the list of face IDs for volume creation.
2116 # Note: The created volume will refer only to the nodes
2117 # of the given faces, not to the faces themselves.
2118 # @return the Id of the new volumic element
2119 # @ingroup l2_modif_add
2120 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2121 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2124 ## @brief Binds a node to a vertex
2125 # @param NodeID a node ID
2126 # @param Vertex a vertex or vertex ID
2127 # @return True if succeed else raises an exception
2128 # @ingroup l2_modif_add
2129 def SetNodeOnVertex(self, NodeID, Vertex):
2130 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2131 VertexID = Vertex.GetSubShapeIndices()[0]
2135 self.editor.SetNodeOnVertex(NodeID, VertexID)
2136 except SALOME.SALOME_Exception, inst:
2137 raise ValueError, inst.details.text
2141 ## @brief Stores the node position on an edge
2142 # @param NodeID a node ID
2143 # @param Edge an edge or edge ID
2144 # @param paramOnEdge a parameter on the edge where the node is located
2145 # @return True if succeed else raises an exception
2146 # @ingroup l2_modif_add
2147 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2148 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2149 EdgeID = Edge.GetSubShapeIndices()[0]
2153 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2154 except SALOME.SALOME_Exception, inst:
2155 raise ValueError, inst.details.text
2158 ## @brief Stores node position on a face
2159 # @param NodeID a node ID
2160 # @param Face a face or face ID
2161 # @param u U parameter on the face where the node is located
2162 # @param v V parameter on the face where the node is located
2163 # @return True if succeed else raises an exception
2164 # @ingroup l2_modif_add
2165 def SetNodeOnFace(self, NodeID, Face, u, v):
2166 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2167 FaceID = Face.GetSubShapeIndices()[0]
2171 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2172 except SALOME.SALOME_Exception, inst:
2173 raise ValueError, inst.details.text
2176 ## @brief Binds a node to a solid
2177 # @param NodeID a node ID
2178 # @param Solid a solid or solid ID
2179 # @return True if succeed else raises an exception
2180 # @ingroup l2_modif_add
2181 def SetNodeInVolume(self, NodeID, Solid):
2182 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2183 SolidID = Solid.GetSubShapeIndices()[0]
2187 self.editor.SetNodeInVolume(NodeID, SolidID)
2188 except SALOME.SALOME_Exception, inst:
2189 raise ValueError, inst.details.text
2192 ## @brief Bind an element to a shape
2193 # @param ElementID an element ID
2194 # @param Shape a shape or shape ID
2195 # @return True if succeed else raises an exception
2196 # @ingroup l2_modif_add
2197 def SetMeshElementOnShape(self, ElementID, Shape):
2198 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2199 ShapeID = Shape.GetSubShapeIndices()[0]
2203 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2204 except SALOME.SALOME_Exception, inst:
2205 raise ValueError, inst.details.text
2209 ## Moves the node with the given id
2210 # @param NodeID the id of the node
2211 # @param x a new X coordinate
2212 # @param y a new Y coordinate
2213 # @param z a new Z coordinate
2214 # @return True if succeed else False
2215 # @ingroup l2_modif_movenode
2216 def MoveNode(self, NodeID, x, y, z):
2217 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2218 self.mesh.SetParameters(Parameters)
2219 return self.editor.MoveNode(NodeID, x, y, z)
2221 ## Finds the node closest to a point and moves it to a point location
2222 # @param x the X coordinate of a point
2223 # @param y the Y coordinate of a point
2224 # @param z the Z coordinate of a point
2225 # @param NodeID if specified (>0), the node with this ID is moved,
2226 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2227 # @return the ID of a node
2228 # @ingroup l2_modif_throughp
2229 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2230 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2231 self.mesh.SetParameters(Parameters)
2232 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2234 ## Finds the node closest to a point
2235 # @param x the X coordinate of a point
2236 # @param y the Y coordinate of a point
2237 # @param z the Z coordinate of a point
2238 # @return the ID of a node
2239 # @ingroup l2_modif_throughp
2240 def FindNodeClosestTo(self, x, y, z):
2241 #preview = self.mesh.GetMeshEditPreviewer()
2242 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2243 return self.editor.FindNodeClosestTo(x, y, z)
2245 ## Finds the elements where a point lays IN or ON
2246 # @param x the X coordinate of a point
2247 # @param y the Y coordinate of a point
2248 # @param z the Z coordinate of a point
2249 # @param elementType type of elements to find (SMESH.ALL type
2250 # means elements of any type excluding nodes and 0D elements)
2251 # @return list of IDs of found elements
2252 # @ingroup l2_modif_throughp
2253 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2254 return self.editor.FindElementsByPoint(x, y, z, elementType)
2257 ## Finds the node closest to a point and moves it to a point location
2258 # @param x the X coordinate of a point
2259 # @param y the Y coordinate of a point
2260 # @param z the Z coordinate of a point
2261 # @return the ID of a moved node
2262 # @ingroup l2_modif_throughp
2263 def MeshToPassThroughAPoint(self, x, y, z):
2264 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2266 ## Replaces two neighbour triangles sharing Node1-Node2 link
2267 # with the triangles built on the same 4 nodes but having other common link.
2268 # @param NodeID1 the ID of the first node
2269 # @param NodeID2 the ID of the second node
2270 # @return false if proper faces were not found
2271 # @ingroup l2_modif_invdiag
2272 def InverseDiag(self, NodeID1, NodeID2):
2273 return self.editor.InverseDiag(NodeID1, NodeID2)
2275 ## Replaces two neighbour triangles sharing Node1-Node2 link
2276 # with a quadrangle built on the same 4 nodes.
2277 # @param NodeID1 the ID of the first node
2278 # @param NodeID2 the ID of the second node
2279 # @return false if proper faces were not found
2280 # @ingroup l2_modif_unitetri
2281 def DeleteDiag(self, NodeID1, NodeID2):
2282 return self.editor.DeleteDiag(NodeID1, NodeID2)
2284 ## Reorients elements by ids
2285 # @param IDsOfElements if undefined reorients all mesh elements
2286 # @return True if succeed else False
2287 # @ingroup l2_modif_changori
2288 def Reorient(self, IDsOfElements=None):
2289 if IDsOfElements == None:
2290 IDsOfElements = self.GetElementsId()
2291 return self.editor.Reorient(IDsOfElements)
2293 ## Reorients all elements of the object
2294 # @param theObject mesh, submesh or group
2295 # @return True if succeed else False
2296 # @ingroup l2_modif_changori
2297 def ReorientObject(self, theObject):
2298 if ( isinstance( theObject, Mesh )):
2299 theObject = theObject.GetMesh()
2300 return self.editor.ReorientObject(theObject)
2302 ## Fuses the neighbouring triangles into quadrangles.
2303 # @param IDsOfElements The triangles to be fused,
2304 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2305 # @param MaxAngle is the maximum angle between element normals at which the fusion
2306 # is still performed; theMaxAngle is mesured in radians.
2307 # Also it could be a name of variable which defines angle in degrees.
2308 # @return TRUE in case of success, FALSE otherwise.
2309 # @ingroup l2_modif_unitetri
2310 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2312 if isinstance(MaxAngle,str):
2314 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2316 MaxAngle = DegreesToRadians(MaxAngle)
2317 if IDsOfElements == []:
2318 IDsOfElements = self.GetElementsId()
2319 self.mesh.SetParameters(Parameters)
2321 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2322 Functor = theCriterion
2324 Functor = self.smeshpyD.GetFunctor(theCriterion)
2325 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2327 ## Fuses the neighbouring triangles of the object into quadrangles
2328 # @param theObject is mesh, submesh or group
2329 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2330 # @param MaxAngle a max angle between element normals at which the fusion
2331 # is still performed; theMaxAngle is mesured in radians.
2332 # @return TRUE in case of success, FALSE otherwise.
2333 # @ingroup l2_modif_unitetri
2334 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2335 if ( isinstance( theObject, Mesh )):
2336 theObject = theObject.GetMesh()
2337 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2339 ## Splits quadrangles into triangles.
2340 # @param IDsOfElements the faces to be splitted.
2341 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2342 # @return TRUE in case of success, FALSE otherwise.
2343 # @ingroup l2_modif_cutquadr
2344 def QuadToTri (self, IDsOfElements, theCriterion):
2345 if IDsOfElements == []:
2346 IDsOfElements = self.GetElementsId()
2347 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2349 ## Splits quadrangles into triangles.
2350 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2351 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2352 # @return TRUE in case of success, FALSE otherwise.
2353 # @ingroup l2_modif_cutquadr
2354 def QuadToTriObject (self, theObject, theCriterion):
2355 if ( isinstance( theObject, Mesh )):
2356 theObject = theObject.GetMesh()
2357 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2359 ## Splits quadrangles into triangles.
2360 # @param IDsOfElements the faces to be splitted
2361 # @param Diag13 is used to choose a diagonal for splitting.
2362 # @return TRUE in case of success, FALSE otherwise.
2363 # @ingroup l2_modif_cutquadr
2364 def SplitQuad (self, IDsOfElements, Diag13):
2365 if IDsOfElements == []:
2366 IDsOfElements = self.GetElementsId()
2367 return self.editor.SplitQuad(IDsOfElements, Diag13)
2369 ## Splits quadrangles into triangles.
2370 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2371 # @param Diag13 is used to choose a diagonal for splitting.
2372 # @return TRUE in case of success, FALSE otherwise.
2373 # @ingroup l2_modif_cutquadr
2374 def SplitQuadObject (self, theObject, Diag13):
2375 if ( isinstance( theObject, Mesh )):
2376 theObject = theObject.GetMesh()
2377 return self.editor.SplitQuadObject(theObject, Diag13)
2379 ## Finds a better splitting of the given quadrangle.
2380 # @param IDOfQuad the ID of the quadrangle to be splitted.
2381 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2382 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2383 # diagonal is better, 0 if error occurs.
2384 # @ingroup l2_modif_cutquadr
2385 def BestSplit (self, IDOfQuad, theCriterion):
2386 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2388 ## Splits quadrangle faces near triangular facets of volumes
2390 # @ingroup l1_auxiliary
2391 def SplitQuadsNearTriangularFacets(self):
2392 faces_array = self.GetElementsByType(SMESH.FACE)
2393 for face_id in faces_array:
2394 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2395 quad_nodes = self.mesh.GetElemNodes(face_id)
2396 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2397 isVolumeFound = False
2398 for node1_elem in node1_elems:
2399 if not isVolumeFound:
2400 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2401 nb_nodes = self.GetElemNbNodes(node1_elem)
2402 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2403 volume_elem = node1_elem
2404 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2405 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2406 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2407 isVolumeFound = True
2408 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2409 self.SplitQuad([face_id], False) # diagonal 2-4
2410 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2411 isVolumeFound = True
2412 self.SplitQuad([face_id], True) # diagonal 1-3
2413 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2414 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2415 isVolumeFound = True
2416 self.SplitQuad([face_id], True) # diagonal 1-3
2418 ## @brief Splits hexahedrons into tetrahedrons.
2420 # This operation uses pattern mapping functionality for splitting.
2421 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2422 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2423 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2424 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2425 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2426 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2427 # @return TRUE in case of success, FALSE otherwise.
2428 # @ingroup l1_auxiliary
2429 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2430 # Pattern: 5.---------.6
2435 # (0,0,1) 4.---------.7 * |
2442 # (0,0,0) 0.---------.3
2443 pattern_tetra = "!!! Nb of points: \n 8 \n\
2453 !!! Indices of points of 6 tetras: \n\
2461 pattern = self.smeshpyD.GetPattern()
2462 isDone = pattern.LoadFromFile(pattern_tetra)
2464 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2467 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2468 isDone = pattern.MakeMesh(self.mesh, False, False)
2469 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2471 # split quafrangle faces near triangular facets of volumes
2472 self.SplitQuadsNearTriangularFacets()
2476 ## @brief Split hexahedrons into prisms.
2478 # Uses the pattern mapping functionality for splitting.
2479 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2480 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2481 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2482 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2483 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2484 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2485 # @return TRUE in case of success, FALSE otherwise.
2486 # @ingroup l1_auxiliary
2487 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2488 # Pattern: 5.---------.6
2493 # (0,0,1) 4.---------.7 |
2500 # (0,0,0) 0.---------.3
2501 pattern_prism = "!!! Nb of points: \n 8 \n\
2511 !!! Indices of points of 2 prisms: \n\
2515 pattern = self.smeshpyD.GetPattern()
2516 isDone = pattern.LoadFromFile(pattern_prism)
2518 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2521 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2522 isDone = pattern.MakeMesh(self.mesh, False, False)
2523 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2525 # Splits quafrangle faces near triangular facets of volumes
2526 self.SplitQuadsNearTriangularFacets()
2530 ## Smoothes elements
2531 # @param IDsOfElements the list if ids of elements to smooth
2532 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2533 # Note that nodes built on edges and boundary nodes are always fixed.
2534 # @param MaxNbOfIterations the maximum number of iterations
2535 # @param MaxAspectRatio varies in range [1.0, inf]
2536 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2537 # @return TRUE in case of success, FALSE otherwise.
2538 # @ingroup l2_modif_smooth
2539 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2540 MaxNbOfIterations, MaxAspectRatio, Method):
2541 if IDsOfElements == []:
2542 IDsOfElements = self.GetElementsId()
2543 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2544 self.mesh.SetParameters(Parameters)
2545 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2546 MaxNbOfIterations, MaxAspectRatio, Method)
2548 ## Smoothes elements which belong to the given object
2549 # @param theObject the object to smooth
2550 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2551 # Note that nodes built on edges and boundary nodes are always fixed.
2552 # @param MaxNbOfIterations the maximum number of iterations
2553 # @param MaxAspectRatio varies in range [1.0, inf]
2554 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2555 # @return TRUE in case of success, FALSE otherwise.
2556 # @ingroup l2_modif_smooth
2557 def SmoothObject(self, theObject, IDsOfFixedNodes,
2558 MaxNbOfIterations, MaxAspectRatio, Method):
2559 if ( isinstance( theObject, Mesh )):
2560 theObject = theObject.GetMesh()
2561 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2562 MaxNbOfIterations, MaxAspectRatio, Method)
2564 ## Parametrically smoothes the given elements
2565 # @param IDsOfElements the list if ids of elements to smooth
2566 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2567 # Note that nodes built on edges and boundary nodes are always fixed.
2568 # @param MaxNbOfIterations the maximum number of iterations
2569 # @param MaxAspectRatio varies in range [1.0, inf]
2570 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2571 # @return TRUE in case of success, FALSE otherwise.
2572 # @ingroup l2_modif_smooth
2573 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2574 MaxNbOfIterations, MaxAspectRatio, Method):
2575 if IDsOfElements == []:
2576 IDsOfElements = self.GetElementsId()
2577 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2578 self.mesh.SetParameters(Parameters)
2579 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2580 MaxNbOfIterations, MaxAspectRatio, Method)
2582 ## Parametrically smoothes the elements which belong to the given object
2583 # @param theObject the object to smooth
2584 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2585 # Note that nodes built on edges and boundary nodes are always fixed.
2586 # @param MaxNbOfIterations the maximum number of iterations
2587 # @param MaxAspectRatio varies in range [1.0, inf]
2588 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2589 # @return TRUE in case of success, FALSE otherwise.
2590 # @ingroup l2_modif_smooth
2591 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2592 MaxNbOfIterations, MaxAspectRatio, Method):
2593 if ( isinstance( theObject, Mesh )):
2594 theObject = theObject.GetMesh()
2595 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2596 MaxNbOfIterations, MaxAspectRatio, Method)
2598 ## Converts the mesh to quadratic, deletes old elements, replacing
2599 # them with quadratic with the same id.
2600 # @ingroup l2_modif_tofromqu
2601 def ConvertToQuadratic(self, theForce3d):
2602 self.editor.ConvertToQuadratic(theForce3d)
2604 ## Converts the mesh from quadratic to ordinary,
2605 # deletes old quadratic elements, \n replacing
2606 # them with ordinary mesh elements with the same id.
2607 # @return TRUE in case of success, FALSE otherwise.
2608 # @ingroup l2_modif_tofromqu
2609 def ConvertFromQuadratic(self):
2610 return self.editor.ConvertFromQuadratic()
2612 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2613 # @return TRUE if operation has been completed successfully, FALSE otherwise
2614 # @ingroup l2_modif_edit
2615 def Make2DMeshFrom3D(self):
2616 return self.editor. Make2DMeshFrom3D()
2618 ## Renumber mesh nodes
2619 # @ingroup l2_modif_renumber
2620 def RenumberNodes(self):
2621 self.editor.RenumberNodes()
2623 ## Renumber mesh elements
2624 # @ingroup l2_modif_renumber
2625 def RenumberElements(self):
2626 self.editor.RenumberElements()
2628 ## Generates new elements by rotation of the elements around the axis
2629 # @param IDsOfElements the list of ids of elements to sweep
2630 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2631 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2632 # @param NbOfSteps the number of steps
2633 # @param Tolerance tolerance
2634 # @param MakeGroups forces the generation of new groups from existing ones
2635 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2636 # of all steps, else - size of each step
2637 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2638 # @ingroup l2_modif_extrurev
2639 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2640 MakeGroups=False, TotalAngle=False):
2642 if isinstance(AngleInRadians,str):
2644 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2646 AngleInRadians = DegreesToRadians(AngleInRadians)
2647 if IDsOfElements == []:
2648 IDsOfElements = self.GetElementsId()
2649 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2650 Axis = self.smeshpyD.GetAxisStruct(Axis)
2651 Axis,AxisParameters = ParseAxisStruct(Axis)
2652 if TotalAngle and NbOfSteps:
2653 AngleInRadians /= NbOfSteps
2654 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2655 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2656 self.mesh.SetParameters(Parameters)
2658 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2659 AngleInRadians, NbOfSteps, Tolerance)
2660 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2663 ## Generates new elements by rotation of the elements of object around the axis
2664 # @param theObject object which elements should be sweeped
2665 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2666 # @param AngleInRadians the angle of Rotation
2667 # @param NbOfSteps number of steps
2668 # @param Tolerance tolerance
2669 # @param MakeGroups forces the generation of new groups from existing ones
2670 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2671 # of all steps, else - size of each step
2672 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2673 # @ingroup l2_modif_extrurev
2674 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2675 MakeGroups=False, TotalAngle=False):
2677 if isinstance(AngleInRadians,str):
2679 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2681 AngleInRadians = DegreesToRadians(AngleInRadians)
2682 if ( isinstance( theObject, Mesh )):
2683 theObject = theObject.GetMesh()
2684 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2685 Axis = self.smeshpyD.GetAxisStruct(Axis)
2686 Axis,AxisParameters = ParseAxisStruct(Axis)
2687 if TotalAngle and NbOfSteps:
2688 AngleInRadians /= NbOfSteps
2689 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2690 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2691 self.mesh.SetParameters(Parameters)
2693 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2694 NbOfSteps, Tolerance)
2695 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2698 ## Generates new elements by rotation of the elements of object around the axis
2699 # @param theObject object which elements should be sweeped
2700 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2701 # @param AngleInRadians the angle of Rotation
2702 # @param NbOfSteps number of steps
2703 # @param Tolerance tolerance
2704 # @param MakeGroups forces the generation of new groups from existing ones
2705 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2706 # of all steps, else - size of each step
2707 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2708 # @ingroup l2_modif_extrurev
2709 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2710 MakeGroups=False, TotalAngle=False):
2712 if isinstance(AngleInRadians,str):
2714 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2716 AngleInRadians = DegreesToRadians(AngleInRadians)
2717 if ( isinstance( theObject, Mesh )):
2718 theObject = theObject.GetMesh()
2719 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2720 Axis = self.smeshpyD.GetAxisStruct(Axis)
2721 Axis,AxisParameters = ParseAxisStruct(Axis)
2722 if TotalAngle and NbOfSteps:
2723 AngleInRadians /= NbOfSteps
2724 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2725 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2726 self.mesh.SetParameters(Parameters)
2728 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2729 NbOfSteps, Tolerance)
2730 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2733 ## Generates new elements by rotation of the elements of object around the axis
2734 # @param theObject object which elements should be sweeped
2735 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2736 # @param AngleInRadians the angle of Rotation
2737 # @param NbOfSteps number of steps
2738 # @param Tolerance tolerance
2739 # @param MakeGroups forces the generation of new groups from existing ones
2740 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2741 # of all steps, else - size of each step
2742 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2743 # @ingroup l2_modif_extrurev
2744 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2745 MakeGroups=False, TotalAngle=False):
2747 if isinstance(AngleInRadians,str):
2749 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2751 AngleInRadians = DegreesToRadians(AngleInRadians)
2752 if ( isinstance( theObject, Mesh )):
2753 theObject = theObject.GetMesh()
2754 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2755 Axis = self.smeshpyD.GetAxisStruct(Axis)
2756 Axis,AxisParameters = ParseAxisStruct(Axis)
2757 if TotalAngle and NbOfSteps:
2758 AngleInRadians /= NbOfSteps
2759 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2760 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2761 self.mesh.SetParameters(Parameters)
2763 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2764 NbOfSteps, Tolerance)
2765 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2768 ## Generates new elements by extrusion of the elements with given ids
2769 # @param IDsOfElements the list of elements ids for extrusion
2770 # @param StepVector vector, defining the direction and value of extrusion
2771 # @param NbOfSteps the number of steps
2772 # @param MakeGroups forces the generation of new groups from existing ones
2773 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2774 # @ingroup l2_modif_extrurev
2775 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2776 if IDsOfElements == []:
2777 IDsOfElements = self.GetElementsId()
2778 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2779 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2780 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2781 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2782 Parameters = StepVectorParameters + var_separator + Parameters
2783 self.mesh.SetParameters(Parameters)
2785 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2786 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2789 ## Generates new elements by extrusion of the elements with given ids
2790 # @param IDsOfElements is ids of elements
2791 # @param StepVector vector, defining the direction and value of extrusion
2792 # @param NbOfSteps the number of steps
2793 # @param ExtrFlags sets flags for extrusion
2794 # @param SewTolerance uses for comparing locations of nodes if flag
2795 # EXTRUSION_FLAG_SEW is set
2796 # @param MakeGroups forces the generation of new groups from existing ones
2797 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2798 # @ingroup l2_modif_extrurev
2799 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2800 ExtrFlags, SewTolerance, MakeGroups=False):
2801 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2802 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2804 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2805 ExtrFlags, SewTolerance)
2806 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2807 ExtrFlags, SewTolerance)
2810 ## Generates new elements by extrusion of the elements which belong to the object
2811 # @param theObject the object which elements should be processed
2812 # @param StepVector vector, defining the direction and value of extrusion
2813 # @param NbOfSteps the number of steps
2814 # @param MakeGroups forces the generation of new groups from existing ones
2815 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2816 # @ingroup l2_modif_extrurev
2817 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2818 if ( isinstance( theObject, Mesh )):
2819 theObject = theObject.GetMesh()
2820 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2821 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2822 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2823 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2824 Parameters = StepVectorParameters + var_separator + Parameters
2825 self.mesh.SetParameters(Parameters)
2827 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2828 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2831 ## Generates new elements by extrusion of the elements which belong to the object
2832 # @param theObject object which elements should be processed
2833 # @param StepVector vector, defining the direction and value of extrusion
2834 # @param NbOfSteps the number of steps
2835 # @param MakeGroups to generate new groups from existing ones
2836 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2837 # @ingroup l2_modif_extrurev
2838 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2839 if ( isinstance( theObject, Mesh )):
2840 theObject = theObject.GetMesh()
2841 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2842 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2843 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2844 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2845 Parameters = StepVectorParameters + var_separator + Parameters
2846 self.mesh.SetParameters(Parameters)
2848 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2849 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2852 ## Generates new elements by extrusion of the elements which belong to the object
2853 # @param theObject object which elements should be processed
2854 # @param StepVector vector, defining the direction and value of extrusion
2855 # @param NbOfSteps the number of steps
2856 # @param MakeGroups forces the generation of new groups from existing ones
2857 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2858 # @ingroup l2_modif_extrurev
2859 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2860 if ( isinstance( theObject, Mesh )):
2861 theObject = theObject.GetMesh()
2862 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2863 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2864 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2865 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2866 Parameters = StepVectorParameters + var_separator + Parameters
2867 self.mesh.SetParameters(Parameters)
2869 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2870 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2875 ## Generates new elements by extrusion of the given elements
2876 # The path of extrusion must be a meshed edge.
2877 # @param Base mesh or list of ids of elements for extrusion
2878 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2879 # @param NodeStart the start node from Path. Defines the direction of extrusion
2880 # @param HasAngles allows the shape to be rotated around the path
2881 # to get the resulting mesh in a helical fashion
2882 # @param Angles list of angles in radians
2883 # @param LinearVariation forces the computation of rotation angles as linear
2884 # variation of the given Angles along path steps
2885 # @param HasRefPoint allows using the reference point
2886 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2887 # The User can specify any point as the Reference Point.
2888 # @param MakeGroups forces the generation of new groups from existing ones
2889 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2890 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2891 # only SMESH::Extrusion_Error otherwise
2892 # @ingroup l2_modif_extrurev
2893 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2894 HasAngles, Angles, LinearVariation,
2895 HasRefPoint, RefPoint, MakeGroups, ElemType):
2896 Angles,AnglesParameters = ParseAngles(Angles)
2897 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2898 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2899 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2901 Parameters = AnglesParameters + var_separator + RefPointParameters
2902 self.mesh.SetParameters(Parameters)
2904 if isinstance(Base,list):
2906 if Base == []: IDsOfElements = self.GetElementsId()
2907 else: IDsOfElements = Base
2908 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2909 HasAngles, Angles, LinearVariation,
2910 HasRefPoint, RefPoint, MakeGroups, ElemType)
2912 if isinstance(Base,Mesh):
2913 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2914 HasAngles, Angles, LinearVariation,
2915 HasRefPoint, RefPoint, MakeGroups, ElemType)
2917 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2920 ## Generates new elements by extrusion of the given elements
2921 # The path of extrusion must be a meshed edge.
2922 # @param IDsOfElements ids of elements
2923 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2924 # @param PathShape shape(edge) defines the sub-mesh for the path
2925 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2926 # @param HasAngles allows the shape to be rotated around the path
2927 # to get the resulting mesh in a helical fashion
2928 # @param Angles list of angles in radians
2929 # @param HasRefPoint allows using the reference point
2930 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2931 # The User can specify any point as the Reference Point.
2932 # @param MakeGroups forces the generation of new groups from existing ones
2933 # @param LinearVariation forces the computation of rotation angles as linear
2934 # variation of the given Angles along path steps
2935 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2936 # only SMESH::Extrusion_Error otherwise
2937 # @ingroup l2_modif_extrurev
2938 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2939 HasAngles, Angles, HasRefPoint, RefPoint,
2940 MakeGroups=False, LinearVariation=False):
2941 Angles,AnglesParameters = ParseAngles(Angles)
2942 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2943 if IDsOfElements == []:
2944 IDsOfElements = self.GetElementsId()
2945 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2946 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2948 if ( isinstance( PathMesh, Mesh )):
2949 PathMesh = PathMesh.GetMesh()
2950 if HasAngles and Angles and LinearVariation:
2951 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2953 Parameters = AnglesParameters + var_separator + RefPointParameters
2954 self.mesh.SetParameters(Parameters)
2956 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2957 PathShape, NodeStart, HasAngles,
2958 Angles, HasRefPoint, RefPoint)
2959 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2960 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2962 ## Generates new elements by extrusion of the elements which belong to the object
2963 # The path of extrusion must be a meshed edge.
2964 # @param theObject the object which elements should be processed
2965 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2966 # @param PathShape shape(edge) defines the sub-mesh for the path
2967 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2968 # @param HasAngles allows the shape to be rotated around the path
2969 # to get the resulting mesh in a helical fashion
2970 # @param Angles list of angles
2971 # @param HasRefPoint allows using the reference point
2972 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2973 # The User can specify any point as the Reference Point.
2974 # @param MakeGroups forces the generation of new groups from existing ones
2975 # @param LinearVariation forces the computation of rotation angles as linear
2976 # variation of the given Angles along path steps
2977 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2978 # only SMESH::Extrusion_Error otherwise
2979 # @ingroup l2_modif_extrurev
2980 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2981 HasAngles, Angles, HasRefPoint, RefPoint,
2982 MakeGroups=False, LinearVariation=False):
2983 Angles,AnglesParameters = ParseAngles(Angles)
2984 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2985 if ( isinstance( theObject, Mesh )):
2986 theObject = theObject.GetMesh()
2987 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2988 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2989 if ( isinstance( PathMesh, Mesh )):
2990 PathMesh = PathMesh.GetMesh()
2991 if HasAngles and Angles and LinearVariation:
2992 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2994 Parameters = AnglesParameters + var_separator + RefPointParameters
2995 self.mesh.SetParameters(Parameters)
2997 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2998 PathShape, NodeStart, HasAngles,
2999 Angles, HasRefPoint, RefPoint)
3000 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3001 NodeStart, HasAngles, Angles, HasRefPoint,
3004 ## Generates new elements by extrusion of the elements which belong to the object
3005 # The path of extrusion must be a meshed edge.
3006 # @param theObject the object which elements should be processed
3007 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3008 # @param PathShape shape(edge) defines the sub-mesh for the path
3009 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3010 # @param HasAngles allows the shape to be rotated around the path
3011 # to get the resulting mesh in a helical fashion
3012 # @param Angles list of angles
3013 # @param HasRefPoint allows using the reference point
3014 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3015 # The User can specify any point as the Reference Point.
3016 # @param MakeGroups forces the generation of new groups from existing ones
3017 # @param LinearVariation forces the computation of rotation angles as linear
3018 # variation of the given Angles along path steps
3019 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3020 # only SMESH::Extrusion_Error otherwise
3021 # @ingroup l2_modif_extrurev
3022 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3023 HasAngles, Angles, HasRefPoint, RefPoint,
3024 MakeGroups=False, LinearVariation=False):
3025 Angles,AnglesParameters = ParseAngles(Angles)
3026 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3027 if ( isinstance( theObject, Mesh )):
3028 theObject = theObject.GetMesh()
3029 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3030 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3031 if ( isinstance( PathMesh, Mesh )):
3032 PathMesh = PathMesh.GetMesh()
3033 if HasAngles and Angles and LinearVariation:
3034 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3036 Parameters = AnglesParameters + var_separator + RefPointParameters
3037 self.mesh.SetParameters(Parameters)
3039 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3040 PathShape, NodeStart, HasAngles,
3041 Angles, HasRefPoint, RefPoint)
3042 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3043 NodeStart, HasAngles, Angles, HasRefPoint,
3046 ## Generates new elements by extrusion of the elements which belong to the object
3047 # The path of extrusion must be a meshed edge.
3048 # @param theObject the object which elements should be processed
3049 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3050 # @param PathShape shape(edge) defines the sub-mesh for the path
3051 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3052 # @param HasAngles allows the shape to be rotated around the path
3053 # to get the resulting mesh in a helical fashion
3054 # @param Angles list of angles
3055 # @param HasRefPoint allows using the reference point
3056 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3057 # The User can specify any point as the Reference Point.
3058 # @param MakeGroups forces the generation of new groups from existing ones
3059 # @param LinearVariation forces the computation of rotation angles as linear
3060 # variation of the given Angles along path steps
3061 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3062 # only SMESH::Extrusion_Error otherwise
3063 # @ingroup l2_modif_extrurev
3064 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3065 HasAngles, Angles, HasRefPoint, RefPoint,
3066 MakeGroups=False, LinearVariation=False):
3067 Angles,AnglesParameters = ParseAngles(Angles)
3068 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3069 if ( isinstance( theObject, Mesh )):
3070 theObject = theObject.GetMesh()
3071 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3072 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3073 if ( isinstance( PathMesh, Mesh )):
3074 PathMesh = PathMesh.GetMesh()
3075 if HasAngles and Angles and LinearVariation:
3076 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3078 Parameters = AnglesParameters + var_separator + RefPointParameters
3079 self.mesh.SetParameters(Parameters)
3081 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3082 PathShape, NodeStart, HasAngles,
3083 Angles, HasRefPoint, RefPoint)
3084 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3085 NodeStart, HasAngles, Angles, HasRefPoint,
3088 ## Creates a symmetrical copy of mesh elements
3089 # @param IDsOfElements list of elements ids
3090 # @param Mirror is AxisStruct or geom object(point, line, plane)
3091 # @param theMirrorType is POINT, AXIS or PLANE
3092 # If the Mirror is a geom object this parameter is unnecessary
3093 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3094 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3095 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3096 # @ingroup l2_modif_trsf
3097 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3098 if IDsOfElements == []:
3099 IDsOfElements = self.GetElementsId()
3100 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3101 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3102 Mirror,Parameters = ParseAxisStruct(Mirror)
3103 self.mesh.SetParameters(Parameters)
3104 if Copy and MakeGroups:
3105 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3106 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3109 ## Creates a new mesh by a symmetrical copy of mesh elements
3110 # @param IDsOfElements the list of elements ids
3111 # @param Mirror is AxisStruct or geom object (point, line, plane)
3112 # @param theMirrorType is POINT, AXIS or PLANE
3113 # If the Mirror is a geom object this parameter is unnecessary
3114 # @param MakeGroups to generate new groups from existing ones
3115 # @param NewMeshName a name of the new mesh to create
3116 # @return instance of Mesh class
3117 # @ingroup l2_modif_trsf
3118 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3119 if IDsOfElements == []:
3120 IDsOfElements = self.GetElementsId()
3121 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3122 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3123 Mirror,Parameters = ParseAxisStruct(Mirror)
3124 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3125 MakeGroups, NewMeshName)
3126 mesh.SetParameters(Parameters)
3127 return Mesh(self.smeshpyD,self.geompyD,mesh)
3129 ## Creates a symmetrical copy of the object
3130 # @param theObject mesh, submesh or group
3131 # @param Mirror AxisStruct or geom object (point, line, plane)
3132 # @param theMirrorType is POINT, AXIS or PLANE
3133 # If the Mirror is a geom object this parameter is unnecessary
3134 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3135 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3136 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3137 # @ingroup l2_modif_trsf
3138 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3139 if ( isinstance( theObject, Mesh )):
3140 theObject = theObject.GetMesh()
3141 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3142 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3143 Mirror,Parameters = ParseAxisStruct(Mirror)
3144 self.mesh.SetParameters(Parameters)
3145 if Copy and MakeGroups:
3146 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3147 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3150 ## Creates a new mesh by a symmetrical copy of the object
3151 # @param theObject mesh, submesh or group
3152 # @param Mirror AxisStruct or geom object (point, line, plane)
3153 # @param theMirrorType POINT, AXIS or PLANE
3154 # If the Mirror is a geom object this parameter is unnecessary
3155 # @param MakeGroups forces the generation of new groups from existing ones
3156 # @param NewMeshName the name of the new mesh to create
3157 # @return instance of Mesh class
3158 # @ingroup l2_modif_trsf
3159 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3160 if ( isinstance( theObject, Mesh )):
3161 theObject = theObject.GetMesh()
3162 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3163 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3164 Mirror,Parameters = ParseAxisStruct(Mirror)
3165 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3166 MakeGroups, NewMeshName)
3167 mesh.SetParameters(Parameters)
3168 return Mesh( self.smeshpyD,self.geompyD,mesh )
3170 ## Translates the elements
3171 # @param IDsOfElements list of elements ids
3172 # @param Vector the direction of translation (DirStruct or vector)
3173 # @param Copy allows copying the translated elements
3174 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3175 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3176 # @ingroup l2_modif_trsf
3177 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3178 if IDsOfElements == []:
3179 IDsOfElements = self.GetElementsId()
3180 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3181 Vector = self.smeshpyD.GetDirStruct(Vector)
3182 Vector,Parameters = ParseDirStruct(Vector)
3183 self.mesh.SetParameters(Parameters)
3184 if Copy and MakeGroups:
3185 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3186 self.editor.Translate(IDsOfElements, Vector, Copy)
3189 ## Creates a new mesh of translated elements
3190 # @param IDsOfElements list of elements ids
3191 # @param Vector the direction of translation (DirStruct or vector)
3192 # @param MakeGroups forces the generation of new groups from existing ones
3193 # @param NewMeshName the name of the newly created mesh
3194 # @return instance of Mesh class
3195 # @ingroup l2_modif_trsf
3196 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3197 if IDsOfElements == []:
3198 IDsOfElements = self.GetElementsId()
3199 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3200 Vector = self.smeshpyD.GetDirStruct(Vector)
3201 Vector,Parameters = ParseDirStruct(Vector)
3202 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3203 mesh.SetParameters(Parameters)
3204 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3206 ## Translates the object
3207 # @param theObject the object to translate (mesh, submesh, or group)
3208 # @param Vector direction of translation (DirStruct or geom vector)
3209 # @param Copy allows copying the translated elements
3210 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3211 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3212 # @ingroup l2_modif_trsf
3213 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3214 if ( isinstance( theObject, Mesh )):
3215 theObject = theObject.GetMesh()
3216 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3217 Vector = self.smeshpyD.GetDirStruct(Vector)
3218 Vector,Parameters = ParseDirStruct(Vector)
3219 self.mesh.SetParameters(Parameters)
3220 if Copy and MakeGroups:
3221 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3222 self.editor.TranslateObject(theObject, Vector, Copy)
3225 ## Creates a new mesh from the translated object
3226 # @param theObject the object to translate (mesh, submesh, or group)
3227 # @param Vector the direction of translation (DirStruct or geom vector)
3228 # @param MakeGroups forces the generation of new groups from existing ones
3229 # @param NewMeshName the name of the newly created mesh
3230 # @return instance of Mesh class
3231 # @ingroup l2_modif_trsf
3232 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3233 if (isinstance(theObject, Mesh)):
3234 theObject = theObject.GetMesh()
3235 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3236 Vector = self.smeshpyD.GetDirStruct(Vector)
3237 Vector,Parameters = ParseDirStruct(Vector)
3238 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3239 mesh.SetParameters(Parameters)
3240 return Mesh( self.smeshpyD, self.geompyD, mesh )
3242 ## Rotates the elements
3243 # @param IDsOfElements list of elements ids
3244 # @param Axis the axis of rotation (AxisStruct or geom line)
3245 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3246 # @param Copy allows copying the rotated elements
3247 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3248 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3249 # @ingroup l2_modif_trsf
3250 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3252 if isinstance(AngleInRadians,str):
3254 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3256 AngleInRadians = DegreesToRadians(AngleInRadians)
3257 if IDsOfElements == []:
3258 IDsOfElements = self.GetElementsId()
3259 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3260 Axis = self.smeshpyD.GetAxisStruct(Axis)
3261 Axis,AxisParameters = ParseAxisStruct(Axis)
3262 Parameters = AxisParameters + var_separator + Parameters
3263 self.mesh.SetParameters(Parameters)
3264 if Copy and MakeGroups:
3265 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3266 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3269 ## Creates a new mesh of rotated elements
3270 # @param IDsOfElements list of element ids
3271 # @param Axis the axis of rotation (AxisStruct or geom line)
3272 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3273 # @param MakeGroups forces the generation of new groups from existing ones
3274 # @param NewMeshName the name of the newly created mesh
3275 # @return instance of Mesh class
3276 # @ingroup l2_modif_trsf
3277 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3279 if isinstance(AngleInRadians,str):
3281 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3283 AngleInRadians = DegreesToRadians(AngleInRadians)
3284 if IDsOfElements == []:
3285 IDsOfElements = self.GetElementsId()
3286 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3287 Axis = self.smeshpyD.GetAxisStruct(Axis)
3288 Axis,AxisParameters = ParseAxisStruct(Axis)
3289 Parameters = AxisParameters + var_separator + Parameters
3290 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3291 MakeGroups, NewMeshName)
3292 mesh.SetParameters(Parameters)
3293 return Mesh( self.smeshpyD, self.geompyD, mesh )
3295 ## Rotates the object
3296 # @param theObject the object to rotate( mesh, submesh, or group)
3297 # @param Axis the axis of rotation (AxisStruct or geom line)
3298 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3299 # @param Copy allows copying the rotated elements
3300 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3301 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3302 # @ingroup l2_modif_trsf
3303 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3305 if isinstance(AngleInRadians,str):
3307 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3309 AngleInRadians = DegreesToRadians(AngleInRadians)
3310 if (isinstance(theObject, Mesh)):
3311 theObject = theObject.GetMesh()
3312 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3313 Axis = self.smeshpyD.GetAxisStruct(Axis)
3314 Axis,AxisParameters = ParseAxisStruct(Axis)
3315 Parameters = AxisParameters + ":" + Parameters
3316 self.mesh.SetParameters(Parameters)
3317 if Copy and MakeGroups:
3318 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3319 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3322 ## Creates a new mesh from the rotated object
3323 # @param theObject the object to rotate (mesh, submesh, or group)
3324 # @param Axis the axis of rotation (AxisStruct or geom line)
3325 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3326 # @param MakeGroups forces the generation of new groups from existing ones
3327 # @param NewMeshName the name of the newly created mesh
3328 # @return instance of Mesh class
3329 # @ingroup l2_modif_trsf
3330 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3332 if isinstance(AngleInRadians,str):
3334 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3336 AngleInRadians = DegreesToRadians(AngleInRadians)
3337 if (isinstance( theObject, Mesh )):
3338 theObject = theObject.GetMesh()
3339 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3340 Axis = self.smeshpyD.GetAxisStruct(Axis)
3341 Axis,AxisParameters = ParseAxisStruct(Axis)
3342 Parameters = AxisParameters + ":" + Parameters
3343 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3344 MakeGroups, NewMeshName)
3345 mesh.SetParameters(Parameters)
3346 return Mesh( self.smeshpyD, self.geompyD, mesh )
3348 ## Finds groups of ajacent nodes within Tolerance.
3349 # @param Tolerance the value of tolerance
3350 # @return the list of groups of nodes
3351 # @ingroup l2_modif_trsf
3352 def FindCoincidentNodes (self, Tolerance):
3353 return self.editor.FindCoincidentNodes(Tolerance)
3355 ## Finds groups of ajacent nodes within Tolerance.
3356 # @param Tolerance the value of tolerance
3357 # @param SubMeshOrGroup SubMesh or Group
3358 # @return the list of groups of nodes
3359 # @ingroup l2_modif_trsf
3360 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3361 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3364 # @param GroupsOfNodes the list of groups of nodes
3365 # @ingroup l2_modif_trsf
3366 def MergeNodes (self, GroupsOfNodes):
3367 self.editor.MergeNodes(GroupsOfNodes)
3369 ## Finds the elements built on the same nodes.
3370 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3371 # @return a list of groups of equal elements
3372 # @ingroup l2_modif_trsf
3373 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3374 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3375 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3376 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3378 ## Merges elements in each given group.
3379 # @param GroupsOfElementsID groups of elements for merging
3380 # @ingroup l2_modif_trsf
3381 def MergeElements(self, GroupsOfElementsID):
3382 self.editor.MergeElements(GroupsOfElementsID)
3384 ## Leaves one element and removes all other elements built on the same nodes.
3385 # @ingroup l2_modif_trsf
3386 def MergeEqualElements(self):
3387 self.editor.MergeEqualElements()
3389 ## Sews free borders
3390 # @return SMESH::Sew_Error
3391 # @ingroup l2_modif_trsf
3392 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3393 FirstNodeID2, SecondNodeID2, LastNodeID2,
3394 CreatePolygons, CreatePolyedrs):
3395 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3396 FirstNodeID2, SecondNodeID2, LastNodeID2,
3397 CreatePolygons, CreatePolyedrs)
3399 ## Sews conform free borders
3400 # @return SMESH::Sew_Error
3401 # @ingroup l2_modif_trsf
3402 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3403 FirstNodeID2, SecondNodeID2):
3404 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3405 FirstNodeID2, SecondNodeID2)
3407 ## Sews border to side
3408 # @return SMESH::Sew_Error
3409 # @ingroup l2_modif_trsf
3410 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3411 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3412 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3413 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3415 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3416 # merged with the nodes of elements of Side2.
3417 # The number of elements in theSide1 and in theSide2 must be
3418 # equal and they should have similar nodal connectivity.
3419 # The nodes to merge should belong to side borders and
3420 # the first node should be linked to the second.
3421 # @return SMESH::Sew_Error
3422 # @ingroup l2_modif_trsf
3423 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3424 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3425 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3426 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3427 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3428 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3430 ## Sets new nodes for the given element.
3431 # @param ide the element id
3432 # @param newIDs nodes ids
3433 # @return If the number of nodes does not correspond to the type of element - returns false
3434 # @ingroup l2_modif_edit
3435 def ChangeElemNodes(self, ide, newIDs):
3436 return self.editor.ChangeElemNodes(ide, newIDs)
3438 ## If during the last operation of MeshEditor some nodes were
3439 # created, this method returns the list of their IDs, \n
3440 # if new nodes were not created - returns empty list
3441 # @return the list of integer values (can be empty)
3442 # @ingroup l1_auxiliary
3443 def GetLastCreatedNodes(self):
3444 return self.editor.GetLastCreatedNodes()
3446 ## If during the last operation of MeshEditor some elements were
3447 # created this method returns the list of their IDs, \n
3448 # if new elements were not created - returns empty list
3449 # @return the list of integer values (can be empty)
3450 # @ingroup l1_auxiliary
3451 def GetLastCreatedElems(self):
3452 return self.editor.GetLastCreatedElems()
3454 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3455 # @param theNodes identifiers of nodes to be doubled
3456 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3457 # nodes. If list of element identifiers is empty then nodes are doubled but
3458 # they not assigned to elements
3459 # @return TRUE if operation has been completed successfully, FALSE otherwise
3460 # @ingroup l2_modif_edit
3461 def DoubleNodes(self, theNodes, theModifiedElems):
3462 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3464 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3465 # This method provided for convenience works as DoubleNodes() described above.
3466 # @param theNodes identifiers of node to be doubled
3467 # @param theModifiedElems identifiers of elements to be updated
3468 # @return TRUE if operation has been completed successfully, FALSE otherwise
3469 # @ingroup l2_modif_edit
3470 def DoubleNode(self, theNodeId, theModifiedElems):
3471 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3473 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3474 # This method provided for convenience works as DoubleNodes() described above.
3475 # @param theNodes group of nodes to be doubled
3476 # @param theModifiedElems group of elements to be updated.
3477 # @return TRUE if operation has been completed successfully, FALSE otherwise
3478 # @ingroup l2_modif_edit
3479 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3480 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3482 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3483 # This method provided for convenience works as DoubleNodes() described above.
3484 # @param theNodes list of groups of nodes to be doubled
3485 # @param theModifiedElems list of groups of elements to be updated.
3486 # @return TRUE if operation has been completed successfully, FALSE otherwise
3487 # @ingroup l2_modif_edit
3488 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3489 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3491 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3492 # @param theElems - the list of elements (edges or faces) to be replicated
3493 # The nodes for duplication could be found from these elements
3494 # @param theNodesNot - list of nodes to NOT replicate
3495 # @param theAffectedElems - the list of elements (cells and edges) to which the
3496 # replicated nodes should be associated to.
3497 # @return TRUE if operation has been completed successfully, FALSE otherwise
3498 # @ingroup l2_modif_edit
3499 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3500 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3502 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3503 # @param theElems - the list of elements (edges or faces) to be replicated
3504 # The nodes for duplication could be found from these elements
3505 # @param theNodesNot - list of nodes to NOT replicate
3506 # @param theShape - shape to detect affected elements (element which geometric center
3507 # located on or inside shape).
3508 # The replicated nodes should be associated to affected elements.
3509 # @return TRUE if operation has been completed successfully, FALSE otherwise
3510 # @ingroup l2_modif_edit
3511 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3512 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3514 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3515 # This method provided for convenience works as DoubleNodes() described above.
3516 # @param theElems - group of of elements (edges or faces) to be replicated
3517 # @param theNodesNot - group of nodes not to replicated
3518 # @param theAffectedElems - group of elements to which the replicated nodes
3519 # should be associated to.
3520 # @ingroup l2_modif_edit
3521 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3522 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3524 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3525 # This method provided for convenience works as DoubleNodes() described above.
3526 # @param theElems - group of of elements (edges or faces) to be replicated
3527 # @param theNodesNot - group of nodes not to replicated
3528 # @param theShape - shape to detect affected elements (element which geometric center
3529 # located on or inside shape).
3530 # The replicated nodes should be associated to affected elements.
3531 # @ingroup l2_modif_edit
3532 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3533 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3535 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3536 # This method provided for convenience works as DoubleNodes() described above.
3537 # @param theElems - list of groups of elements (edges or faces) to be replicated
3538 # @param theNodesNot - list of groups of nodes not to replicated
3539 # @param theAffectedElems - group of elements to which the replicated nodes
3540 # should be associated to.
3541 # @return TRUE if operation has been completed successfully, FALSE otherwise
3542 # @ingroup l2_modif_edit
3543 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3544 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3546 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3547 # This method provided for convenience works as DoubleNodes() described above.
3548 # @param theElems - list of groups of elements (edges or faces) to be replicated
3549 # @param theNodesNot - list of groups of nodes not to replicated
3550 # @param theShape - shape to detect affected elements (element which geometric center
3551 # located on or inside shape).
3552 # The replicated nodes should be associated to affected elements.
3553 # @return TRUE if operation has been completed successfully, FALSE otherwise
3554 # @ingroup l2_modif_edit
3555 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3556 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3558 ## The mother class to define algorithm, it is not recommended to use it directly.
3561 # @ingroup l2_algorithms
3562 class Mesh_Algorithm:
3563 # @class Mesh_Algorithm
3564 # @brief Class Mesh_Algorithm
3566 #def __init__(self,smesh):
3574 ## Finds a hypothesis in the study by its type name and parameters.
3575 # Finds only the hypotheses created in smeshpyD engine.
3576 # @return SMESH.SMESH_Hypothesis
3577 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3578 study = smeshpyD.GetCurrentStudy()
3579 #to do: find component by smeshpyD object, not by its data type
3580 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3581 if scomp is not None:
3582 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3583 # Check if the root label of the hypotheses exists
3584 if res and hypRoot is not None:
3585 iter = study.NewChildIterator(hypRoot)
3586 # Check all published hypotheses
3588 hypo_so_i = iter.Value()
3589 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3590 if attr is not None:
3591 anIOR = attr.Value()
3592 hypo_o_i = salome.orb.string_to_object(anIOR)
3593 if hypo_o_i is not None:
3594 # Check if this is a hypothesis
3595 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3596 if hypo_i is not None:
3597 # Check if the hypothesis belongs to current engine
3598 if smeshpyD.GetObjectId(hypo_i) > 0:
3599 # Check if this is the required hypothesis
3600 if hypo_i.GetName() == hypname:
3602 if CompareMethod(hypo_i, args):
3616 ## Finds the algorithm in the study by its type name.
3617 # Finds only the algorithms, which have been created in smeshpyD engine.
3618 # @return SMESH.SMESH_Algo
3619 def FindAlgorithm (self, algoname, smeshpyD):
3620 study = smeshpyD.GetCurrentStudy()
3621 #to do: find component by smeshpyD object, not by its data type
3622 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3623 if scomp is not None:
3624 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3625 # Check if the root label of the algorithms exists
3626 if res and hypRoot is not None:
3627 iter = study.NewChildIterator(hypRoot)
3628 # Check all published algorithms
3630 algo_so_i = iter.Value()
3631 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3632 if attr is not None:
3633 anIOR = attr.Value()
3634 algo_o_i = salome.orb.string_to_object(anIOR)
3635 if algo_o_i is not None:
3636 # Check if this is an algorithm
3637 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3638 if algo_i is not None:
3639 # Checks if the algorithm belongs to the current engine
3640 if smeshpyD.GetObjectId(algo_i) > 0:
3641 # Check if this is the required algorithm
3642 if algo_i.GetName() == algoname:
3655 ## If the algorithm is global, returns 0; \n
3656 # else returns the submesh associated to this algorithm.
3657 def GetSubMesh(self):
3660 ## Returns the wrapped mesher.
3661 def GetAlgorithm(self):
3664 ## Gets the list of hypothesis that can be used with this algorithm
3665 def GetCompatibleHypothesis(self):
3668 mylist = self.algo.GetCompatibleHypothesis()
3671 ## Gets the name of the algorithm
3675 ## Sets the name to the algorithm
3676 def SetName(self, name):
3677 self.mesh.smeshpyD.SetName(self.algo, name)
3679 ## Gets the id of the algorithm
3681 return self.algo.GetId()
3684 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3686 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3687 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3689 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3691 self.Assign(algo, mesh, geom)
3695 def Assign(self, algo, mesh, geom):
3697 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3704 name = GetName(geom)
3706 name = mesh.geompyD.SubShapeName(geom, piece)
3707 mesh.geompyD.addToStudyInFather(piece, geom, name)
3708 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3711 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3712 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3714 def CompareHyp (self, hyp, args):
3715 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3718 def CompareEqualHyp (self, hyp, args):
3722 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3723 UseExisting=0, CompareMethod=""):
3726 if CompareMethod == "": CompareMethod = self.CompareHyp
3727 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3730 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3736 a = a + s + str(args[i])
3740 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3742 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3743 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3746 ## Returns entry of the shape to mesh in the study
3747 def MainShapeEntry(self):
3749 if not self.mesh or not self.mesh.GetMesh(): return entry
3750 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3751 study = self.mesh.smeshpyD.GetCurrentStudy()
3752 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3753 sobj = study.FindObjectIOR(ior)
3754 if sobj: entry = sobj.GetID()
3755 if not entry: return ""
3758 # Public class: Mesh_Segment
3759 # --------------------------
3761 ## Class to define a segment 1D algorithm for discretization
3764 # @ingroup l3_algos_basic
3765 class Mesh_Segment(Mesh_Algorithm):
3767 ## Private constructor.
3768 def __init__(self, mesh, geom=0):
3769 Mesh_Algorithm.__init__(self)
3770 self.Create(mesh, geom, "Regular_1D")
3772 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3773 # @param l for the length of segments that cut an edge
3774 # @param UseExisting if ==true - searches for an existing hypothesis created with
3775 # the same parameters, else (default) - creates a new one
3776 # @param p precision, used for calculation of the number of segments.
3777 # The precision should be a positive, meaningful value within the range [0,1].
3778 # In general, the number of segments is calculated with the formula:
3779 # nb = ceil((edge_length / l) - p)
3780 # Function ceil rounds its argument to the higher integer.
3781 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3782 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3783 # p=1 means rounding of (edge_length / l) to the lower integer.
3784 # Default value is 1e-07.
3785 # @return an instance of StdMeshers_LocalLength hypothesis
3786 # @ingroup l3_hypos_1dhyps
3787 def LocalLength(self, l, UseExisting=0, p=1e-07):
3788 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3789 CompareMethod=self.CompareLocalLength)
3795 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3796 def CompareLocalLength(self, hyp, args):
3797 if IsEqual(hyp.GetLength(), args[0]):
3798 return IsEqual(hyp.GetPrecision(), args[1])
3801 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3802 # @param length is optional maximal allowed length of segment, if it is omitted
3803 # the preestimated length is used that depends on geometry size
3804 # @param UseExisting if ==true - searches for an existing hypothesis created with
3805 # the same parameters, else (default) - create a new one
3806 # @return an instance of StdMeshers_MaxLength hypothesis
3807 # @ingroup l3_hypos_1dhyps
3808 def MaxSize(self, length=0.0, UseExisting=0):
3809 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3812 hyp.SetLength(length)
3814 # set preestimated length
3815 gen = self.mesh.smeshpyD
3816 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3817 self.mesh.GetMesh(), self.mesh.GetShape(),
3819 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3821 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3824 hyp.SetUsePreestimatedLength( length == 0.0 )
3827 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3828 # @param n for the number of segments that cut an edge
3829 # @param s for the scale factor (optional)
3830 # @param reversedEdges is a list of edges to mesh using reversed orientation
3831 # @param UseExisting if ==true - searches for an existing hypothesis created with
3832 # the same parameters, else (default) - create a new one
3833 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3834 # @ingroup l3_hypos_1dhyps
3835 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3836 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3837 reversedEdges, UseExisting = [], reversedEdges
3838 entry = self.MainShapeEntry()
3840 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3841 UseExisting=UseExisting,
3842 CompareMethod=self.CompareNumberOfSegments)
3844 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3845 UseExisting=UseExisting,
3846 CompareMethod=self.CompareNumberOfSegments)
3847 hyp.SetDistrType( 1 )
3848 hyp.SetScaleFactor(s)
3849 hyp.SetNumberOfSegments(n)
3850 hyp.SetReversedEdges( reversedEdges )
3851 hyp.SetObjectEntry( entry )
3855 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3856 def CompareNumberOfSegments(self, hyp, args):
3857 if hyp.GetNumberOfSegments() == args[0]:
3859 if hyp.GetReversedEdges() == args[1]:
3860 if not args[1] or hyp.GetObjectEntry() == args[2]:
3863 if hyp.GetReversedEdges() == args[2]:
3864 if not args[2] or hyp.GetObjectEntry() == args[3]:
3865 if hyp.GetDistrType() == 1:
3866 if IsEqual(hyp.GetScaleFactor(), args[1]):
3870 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3871 # @param start defines the length of the first segment
3872 # @param end defines the length of the last segment
3873 # @param reversedEdges is a list of edges to mesh using reversed orientation
3874 # @param UseExisting if ==true - searches for an existing hypothesis created with
3875 # the same parameters, else (default) - creates a new one
3876 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3877 # @ingroup l3_hypos_1dhyps
3878 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3879 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3880 reversedEdges, UseExisting = [], reversedEdges
3881 entry = self.MainShapeEntry()
3882 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3883 UseExisting=UseExisting,
3884 CompareMethod=self.CompareArithmetic1D)
3885 hyp.SetStartLength(start)
3886 hyp.SetEndLength(end)
3887 hyp.SetReversedEdges( reversedEdges )
3888 hyp.SetObjectEntry( entry )
3892 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3893 def CompareArithmetic1D(self, hyp, args):
3894 if IsEqual(hyp.GetLength(1), args[0]):
3895 if IsEqual(hyp.GetLength(0), args[1]):
3896 if hyp.GetReversedEdges() == args[2]:
3897 if not args[2] or hyp.GetObjectEntry() == args[3]:
3902 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3903 # on curve from 0 to 1 (additionally it is neecessary to check
3904 # orientation of edges and create list of reversed edges if it is
3905 # needed) and sets numbers of segments between given points (default
3906 # values are equals 1
3907 # @param points defines the list of parameters on curve
3908 # @param nbSegs defines the list of numbers of segments
3909 # @param reversedEdges is a list of edges to mesh using reversed orientation
3910 # @param UseExisting if ==true - searches for an existing hypothesis created with
3911 # the same parameters, else (default) - creates a new one
3912 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3913 # @ingroup l3_hypos_1dhyps
3914 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3915 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3916 reversedEdges, UseExisting = [], reversedEdges
3917 entry = self.MainShapeEntry()
3918 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3919 UseExisting=UseExisting,
3920 CompareMethod=self.CompareArithmetic1D)
3921 hyp.SetPoints(points)
3922 hyp.SetNbSegments(nbSegs)
3923 hyp.SetReversedEdges(reversedEdges)
3924 hyp.SetObjectEntry(entry)
3928 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3929 ## as the given arguments
3930 def CompareFixedPoints1D(self, hyp, args):
3931 if hyp.GetPoints() == args[0]:
3932 if hyp.GetNbSegments() == args[1]:
3933 if hyp.GetReversedEdges() == args[2]:
3934 if not args[2] or hyp.GetObjectEntry() == args[3]:
3940 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3941 # @param start defines the length of the first segment
3942 # @param end defines the length of the last segment
3943 # @param reversedEdges is a list of edges to mesh using reversed orientation
3944 # @param UseExisting if ==true - searches for an existing hypothesis created with
3945 # the same parameters, else (default) - creates a new one
3946 # @return an instance of StdMeshers_StartEndLength hypothesis
3947 # @ingroup l3_hypos_1dhyps
3948 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3949 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3950 reversedEdges, UseExisting = [], reversedEdges
3951 entry = self.MainShapeEntry()
3952 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3953 UseExisting=UseExisting,
3954 CompareMethod=self.CompareStartEndLength)
3955 hyp.SetStartLength(start)
3956 hyp.SetEndLength(end)
3957 hyp.SetReversedEdges( reversedEdges )
3958 hyp.SetObjectEntry( entry )
3961 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3962 def CompareStartEndLength(self, hyp, args):
3963 if IsEqual(hyp.GetLength(1), args[0]):
3964 if IsEqual(hyp.GetLength(0), args[1]):
3965 if hyp.GetReversedEdges() == args[2]:
3966 if not args[2] or hyp.GetObjectEntry() == args[3]:
3970 ## Defines "Deflection1D" hypothesis
3971 # @param d for the deflection
3972 # @param UseExisting if ==true - searches for an existing hypothesis created with
3973 # the same parameters, else (default) - create a new one
3974 # @ingroup l3_hypos_1dhyps
3975 def Deflection1D(self, d, UseExisting=0):
3976 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3977 CompareMethod=self.CompareDeflection1D)
3978 hyp.SetDeflection(d)
3981 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3982 def CompareDeflection1D(self, hyp, args):
3983 return IsEqual(hyp.GetDeflection(), args[0])
3985 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3986 # the opposite side in case of quadrangular faces
3987 # @ingroup l3_hypos_additi
3988 def Propagation(self):
3989 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3991 ## Defines "AutomaticLength" hypothesis
3992 # @param fineness for the fineness [0-1]
3993 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3994 # same parameters, else (default) - create a new one
3995 # @ingroup l3_hypos_1dhyps
3996 def AutomaticLength(self, fineness=0, UseExisting=0):
3997 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3998 CompareMethod=self.CompareAutomaticLength)
3999 hyp.SetFineness( fineness )
4002 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4003 def CompareAutomaticLength(self, hyp, args):
4004 return IsEqual(hyp.GetFineness(), args[0])
4006 ## Defines "SegmentLengthAroundVertex" hypothesis
4007 # @param length for the segment length
4008 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4009 # Any other integer value means that the hypothesis will be set on the
4010 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4011 # @param UseExisting if ==true - searches for an existing hypothesis created with
4012 # the same parameters, else (default) - creates a new one
4013 # @ingroup l3_algos_segmarv
4014 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4016 store_geom = self.geom
4017 if type(vertex) is types.IntType:
4018 if vertex == 0 or vertex == 1:
4019 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4027 if self.geom is None:
4028 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4029 name = GetName(self.geom)
4031 piece = self.mesh.geom
4032 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4033 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4034 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4036 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4038 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4039 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4041 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4042 CompareMethod=self.CompareLengthNearVertex)
4043 self.geom = store_geom
4044 hyp.SetLength( length )
4047 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4048 # @ingroup l3_algos_segmarv
4049 def CompareLengthNearVertex(self, hyp, args):
4050 return IsEqual(hyp.GetLength(), args[0])
4052 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4053 # If the 2D mesher sees that all boundary edges are quadratic,
4054 # it generates quadratic faces, else it generates linear faces using
4055 # medium nodes as if they are vertices.
4056 # The 3D mesher generates quadratic volumes only if all boundary faces
4057 # are quadratic, else it fails.
4059 # @ingroup l3_hypos_additi
4060 def QuadraticMesh(self):
4061 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4064 # Public class: Mesh_CompositeSegment
4065 # --------------------------
4067 ## Defines a segment 1D algorithm for discretization
4069 # @ingroup l3_algos_basic
4070 class Mesh_CompositeSegment(Mesh_Segment):
4072 ## Private constructor.
4073 def __init__(self, mesh, geom=0):
4074 self.Create(mesh, geom, "CompositeSegment_1D")
4077 # Public class: Mesh_Segment_Python
4078 # ---------------------------------
4080 ## Defines a segment 1D algorithm for discretization with python function
4082 # @ingroup l3_algos_basic
4083 class Mesh_Segment_Python(Mesh_Segment):
4085 ## Private constructor.
4086 def __init__(self, mesh, geom=0):
4087 import Python1dPlugin
4088 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4090 ## Defines "PythonSplit1D" hypothesis
4091 # @param n for the number of segments that cut an edge
4092 # @param func for the python function that calculates the length of all segments
4093 # @param UseExisting if ==true - searches for the existing hypothesis created with
4094 # the same parameters, else (default) - creates a new one
4095 # @ingroup l3_hypos_1dhyps
4096 def PythonSplit1D(self, n, func, UseExisting=0):
4097 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4098 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4099 hyp.SetNumberOfSegments(n)
4100 hyp.SetPythonLog10RatioFunction(func)
4103 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4104 def ComparePythonSplit1D(self, hyp, args):
4105 #if hyp.GetNumberOfSegments() == args[0]:
4106 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4110 # Public class: Mesh_Triangle
4111 # ---------------------------
4113 ## Defines a triangle 2D algorithm
4115 # @ingroup l3_algos_basic
4116 class Mesh_Triangle(Mesh_Algorithm):
4125 ## Private constructor.
4126 def __init__(self, mesh, algoType, geom=0):
4127 Mesh_Algorithm.__init__(self)
4129 self.algoType = algoType
4130 if algoType == MEFISTO:
4131 self.Create(mesh, geom, "MEFISTO_2D")
4133 elif algoType == BLSURF:
4135 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4136 #self.SetPhysicalMesh() - PAL19680
4137 elif algoType == NETGEN:
4139 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4141 elif algoType == NETGEN_2D:
4143 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4146 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4147 # @param area for the maximum area of each triangle
4148 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4149 # same parameters, else (default) - creates a new one
4151 # Only for algoType == MEFISTO || NETGEN_2D
4152 # @ingroup l3_hypos_2dhyps
4153 def MaxElementArea(self, area, UseExisting=0):
4154 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4155 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4156 CompareMethod=self.CompareMaxElementArea)
4157 elif self.algoType == NETGEN:
4158 hyp = self.Parameters(SIMPLE)
4159 hyp.SetMaxElementArea(area)
4162 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4163 def CompareMaxElementArea(self, hyp, args):
4164 return IsEqual(hyp.GetMaxElementArea(), args[0])
4166 ## Defines "LengthFromEdges" hypothesis to build triangles
4167 # based on the length of the edges taken from the wire
4169 # Only for algoType == MEFISTO || NETGEN_2D
4170 # @ingroup l3_hypos_2dhyps
4171 def LengthFromEdges(self):
4172 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4173 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4175 elif self.algoType == NETGEN:
4176 hyp = self.Parameters(SIMPLE)
4177 hyp.LengthFromEdges()
4180 ## Sets a way to define size of mesh elements to generate.
4181 # @param thePhysicalMesh is: DefaultSize or Custom.
4182 # @ingroup l3_hypos_blsurf
4183 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4184 # Parameter of BLSURF algo
4185 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4187 ## Sets size of mesh elements to generate.
4188 # @ingroup l3_hypos_blsurf
4189 def SetPhySize(self, theVal):
4190 # Parameter of BLSURF algo
4191 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4192 self.Parameters().SetPhySize(theVal)
4194 ## Sets lower boundary of mesh element size (PhySize).
4195 # @ingroup l3_hypos_blsurf
4196 def SetPhyMin(self, theVal=-1):
4197 # Parameter of BLSURF algo
4198 self.Parameters().SetPhyMin(theVal)
4200 ## Sets upper boundary of mesh element size (PhySize).
4201 # @ingroup l3_hypos_blsurf
4202 def SetPhyMax(self, theVal=-1):
4203 # Parameter of BLSURF algo
4204 self.Parameters().SetPhyMax(theVal)
4206 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4207 # @param theGeometricMesh is: DefaultGeom or Custom
4208 # @ingroup l3_hypos_blsurf
4209 def SetGeometricMesh(self, theGeometricMesh=0):
4210 # Parameter of BLSURF algo
4211 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4212 self.params.SetGeometricMesh(theGeometricMesh)
4214 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4215 # @ingroup l3_hypos_blsurf
4216 def SetAngleMeshS(self, theVal=_angleMeshS):
4217 # Parameter of BLSURF algo
4218 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4219 self.params.SetAngleMeshS(theVal)
4221 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4222 # @ingroup l3_hypos_blsurf
4223 def SetAngleMeshC(self, theVal=_angleMeshS):
4224 # Parameter of BLSURF algo
4225 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4226 self.params.SetAngleMeshC(theVal)
4228 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4229 # @ingroup l3_hypos_blsurf
4230 def SetGeoMin(self, theVal=-1):
4231 # Parameter of BLSURF algo
4232 self.Parameters().SetGeoMin(theVal)
4234 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4235 # @ingroup l3_hypos_blsurf
4236 def SetGeoMax(self, theVal=-1):
4237 # Parameter of BLSURF algo
4238 self.Parameters().SetGeoMax(theVal)
4240 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4241 # @ingroup l3_hypos_blsurf
4242 def SetGradation(self, theVal=_gradation):
4243 # Parameter of BLSURF algo
4244 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4245 self.params.SetGradation(theVal)
4247 ## Sets topology usage way.
4248 # @param way defines how mesh conformity is assured <ul>
4249 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4250 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4251 # @ingroup l3_hypos_blsurf
4252 def SetTopology(self, way):
4253 # Parameter of BLSURF algo
4254 self.Parameters().SetTopology(way)
4256 ## To respect geometrical edges or not.
4257 # @ingroup l3_hypos_blsurf
4258 def SetDecimesh(self, toIgnoreEdges=False):
4259 # Parameter of BLSURF algo
4260 self.Parameters().SetDecimesh(toIgnoreEdges)
4262 ## Sets verbosity level in the range 0 to 100.
4263 # @ingroup l3_hypos_blsurf
4264 def SetVerbosity(self, level):
4265 # Parameter of BLSURF algo
4266 self.Parameters().SetVerbosity(level)
4268 ## Sets advanced option value.
4269 # @ingroup l3_hypos_blsurf
4270 def SetOptionValue(self, optionName, level):
4271 # Parameter of BLSURF algo
4272 self.Parameters().SetOptionValue(optionName,level)
4274 ## Sets QuadAllowed flag.
4275 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4276 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4277 def SetQuadAllowed(self, toAllow=True):
4278 if self.algoType == NETGEN_2D:
4279 if toAllow: # add QuadranglePreference
4280 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4281 else: # remove QuadranglePreference
4282 for hyp in self.mesh.GetHypothesisList( self.geom ):
4283 if hyp.GetName() == "QuadranglePreference":
4284 self.mesh.RemoveHypothesis( self.geom, hyp )
4289 if self.Parameters():
4290 self.params.SetQuadAllowed(toAllow)
4293 ## Defines hypothesis having several parameters
4295 # @ingroup l3_hypos_netgen
4296 def Parameters(self, which=SOLE):
4299 if self.algoType == NETGEN:
4301 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4302 "libNETGENEngine.so", UseExisting=0)
4304 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4305 "libNETGENEngine.so", UseExisting=0)
4307 elif self.algoType == MEFISTO:
4308 print "Mefisto algo support no multi-parameter hypothesis"
4310 elif self.algoType == NETGEN_2D:
4311 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4312 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4314 elif self.algoType == BLSURF:
4315 self.params = self.Hypothesis("BLSURF_Parameters", [],
4316 "libBLSURFEngine.so", UseExisting=0)
4319 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4324 # Only for algoType == NETGEN
4325 # @ingroup l3_hypos_netgen
4326 def SetMaxSize(self, theSize):
4327 if self.Parameters():
4328 self.params.SetMaxSize(theSize)
4330 ## Sets SecondOrder flag
4332 # Only for algoType == NETGEN
4333 # @ingroup l3_hypos_netgen
4334 def SetSecondOrder(self, theVal):
4335 if self.Parameters():
4336 self.params.SetSecondOrder(theVal)
4338 ## Sets Optimize flag
4340 # Only for algoType == NETGEN
4341 # @ingroup l3_hypos_netgen
4342 def SetOptimize(self, theVal):
4343 if self.Parameters():
4344 self.params.SetOptimize(theVal)
4347 # @param theFineness is:
4348 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4350 # Only for algoType == NETGEN
4351 # @ingroup l3_hypos_netgen
4352 def SetFineness(self, theFineness):
4353 if self.Parameters():
4354 self.params.SetFineness(theFineness)
4358 # Only for algoType == NETGEN
4359 # @ingroup l3_hypos_netgen
4360 def SetGrowthRate(self, theRate):
4361 if self.Parameters():
4362 self.params.SetGrowthRate(theRate)
4364 ## Sets NbSegPerEdge
4366 # Only for algoType == NETGEN
4367 # @ingroup l3_hypos_netgen
4368 def SetNbSegPerEdge(self, theVal):
4369 if self.Parameters():
4370 self.params.SetNbSegPerEdge(theVal)
4372 ## Sets NbSegPerRadius
4374 # Only for algoType == NETGEN
4375 # @ingroup l3_hypos_netgen
4376 def SetNbSegPerRadius(self, theVal):
4377 if self.Parameters():
4378 self.params.SetNbSegPerRadius(theVal)
4380 ## Sets number of segments overriding value set by SetLocalLength()
4382 # Only for algoType == NETGEN
4383 # @ingroup l3_hypos_netgen
4384 def SetNumberOfSegments(self, theVal):
4385 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4387 ## Sets number of segments overriding value set by SetNumberOfSegments()
4389 # Only for algoType == NETGEN
4390 # @ingroup l3_hypos_netgen
4391 def SetLocalLength(self, theVal):
4392 self.Parameters(SIMPLE).SetLocalLength(theVal)
4397 # Public class: Mesh_Quadrangle
4398 # -----------------------------
4400 ## Defines a quadrangle 2D algorithm
4402 # @ingroup l3_algos_basic
4403 class Mesh_Quadrangle(Mesh_Algorithm):
4405 ## Private constructor.
4406 def __init__(self, mesh, geom=0):
4407 Mesh_Algorithm.__init__(self)
4408 self.Create(mesh, geom, "Quadrangle_2D")
4410 ## Defines "QuadranglePreference" hypothesis, forcing construction
4411 # of quadrangles if the number of nodes on the opposite edges is not the same
4412 # while the total number of nodes on edges is even
4414 # @ingroup l3_hypos_additi
4415 def QuadranglePreference(self):
4416 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4417 CompareMethod=self.CompareEqualHyp)
4420 ## Defines "TrianglePreference" hypothesis, forcing construction
4421 # of triangles in the refinement area if the number of nodes
4422 # on the opposite edges is not the same
4424 # @ingroup l3_hypos_additi
4425 def TrianglePreference(self):
4426 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4427 CompareMethod=self.CompareEqualHyp)
4430 # Public class: Mesh_Tetrahedron
4431 # ------------------------------
4433 ## Defines a tetrahedron 3D algorithm
4435 # @ingroup l3_algos_basic
4436 class Mesh_Tetrahedron(Mesh_Algorithm):
4441 ## Private constructor.
4442 def __init__(self, mesh, algoType, geom=0):
4443 Mesh_Algorithm.__init__(self)
4445 if algoType == NETGEN:
4447 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4450 elif algoType == FULL_NETGEN:
4452 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4455 elif algoType == GHS3D:
4457 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4460 elif algoType == GHS3DPRL:
4461 CheckPlugin(GHS3DPRL)
4462 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4465 self.algoType = algoType
4467 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4468 # @param vol for the maximum volume of each tetrahedron
4469 # @param UseExisting if ==true - searches for the existing hypothesis created with
4470 # the same parameters, else (default) - creates a new one
4471 # @ingroup l3_hypos_maxvol
4472 def MaxElementVolume(self, vol, UseExisting=0):
4473 if self.algoType == NETGEN:
4474 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4475 CompareMethod=self.CompareMaxElementVolume)
4476 hyp.SetMaxElementVolume(vol)
4478 elif self.algoType == FULL_NETGEN:
4479 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4482 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4483 def CompareMaxElementVolume(self, hyp, args):
4484 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4486 ## Defines hypothesis having several parameters
4488 # @ingroup l3_hypos_netgen
4489 def Parameters(self, which=SOLE):
4493 if self.algoType == FULL_NETGEN:
4495 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4496 "libNETGENEngine.so", UseExisting=0)
4498 self.params = self.Hypothesis("NETGEN_Parameters", [],
4499 "libNETGENEngine.so", UseExisting=0)
4502 if self.algoType == GHS3D:
4503 self.params = self.Hypothesis("GHS3D_Parameters", [],
4504 "libGHS3DEngine.so", UseExisting=0)
4507 if self.algoType == GHS3DPRL:
4508 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4509 "libGHS3DPRLEngine.so", UseExisting=0)
4512 print "Algo supports no multi-parameter hypothesis"
4516 # Parameter of FULL_NETGEN
4517 # @ingroup l3_hypos_netgen
4518 def SetMaxSize(self, theSize):
4519 self.Parameters().SetMaxSize(theSize)
4521 ## Sets SecondOrder flag
4522 # Parameter of FULL_NETGEN
4523 # @ingroup l3_hypos_netgen
4524 def SetSecondOrder(self, theVal):
4525 self.Parameters().SetSecondOrder(theVal)
4527 ## Sets Optimize flag
4528 # Parameter of FULL_NETGEN
4529 # @ingroup l3_hypos_netgen
4530 def SetOptimize(self, theVal):
4531 self.Parameters().SetOptimize(theVal)
4534 # @param theFineness is:
4535 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4536 # Parameter of FULL_NETGEN
4537 # @ingroup l3_hypos_netgen
4538 def SetFineness(self, theFineness):
4539 self.Parameters().SetFineness(theFineness)
4542 # Parameter of FULL_NETGEN
4543 # @ingroup l3_hypos_netgen
4544 def SetGrowthRate(self, theRate):
4545 self.Parameters().SetGrowthRate(theRate)
4547 ## Sets NbSegPerEdge
4548 # Parameter of FULL_NETGEN
4549 # @ingroup l3_hypos_netgen
4550 def SetNbSegPerEdge(self, theVal):
4551 self.Parameters().SetNbSegPerEdge(theVal)
4553 ## Sets NbSegPerRadius
4554 # Parameter of FULL_NETGEN
4555 # @ingroup l3_hypos_netgen
4556 def SetNbSegPerRadius(self, theVal):
4557 self.Parameters().SetNbSegPerRadius(theVal)
4559 ## Sets number of segments overriding value set by SetLocalLength()
4560 # Only for algoType == NETGEN_FULL
4561 # @ingroup l3_hypos_netgen
4562 def SetNumberOfSegments(self, theVal):
4563 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4565 ## Sets number of segments overriding value set by SetNumberOfSegments()
4566 # Only for algoType == NETGEN_FULL
4567 # @ingroup l3_hypos_netgen
4568 def SetLocalLength(self, theVal):
4569 self.Parameters(SIMPLE).SetLocalLength(theVal)
4571 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4572 # Overrides value set by LengthFromEdges()
4573 # Only for algoType == NETGEN_FULL
4574 # @ingroup l3_hypos_netgen
4575 def MaxElementArea(self, area):
4576 self.Parameters(SIMPLE).SetMaxElementArea(area)
4578 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4579 # Overrides value set by MaxElementArea()
4580 # Only for algoType == NETGEN_FULL
4581 # @ingroup l3_hypos_netgen
4582 def LengthFromEdges(self):
4583 self.Parameters(SIMPLE).LengthFromEdges()
4585 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4586 # Overrides value set by MaxElementVolume()
4587 # Only for algoType == NETGEN_FULL
4588 # @ingroup l3_hypos_netgen
4589 def LengthFromFaces(self):
4590 self.Parameters(SIMPLE).LengthFromFaces()
4592 ## To mesh "holes" in a solid or not. Default is to mesh.
4593 # @ingroup l3_hypos_ghs3dh
4594 def SetToMeshHoles(self, toMesh):
4595 # Parameter of GHS3D
4596 self.Parameters().SetToMeshHoles(toMesh)
4598 ## Set Optimization level:
4599 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4600 # Strong_Optimization.
4601 # Default is Standard_Optimization
4602 # @ingroup l3_hypos_ghs3dh
4603 def SetOptimizationLevel(self, level):
4604 # Parameter of GHS3D
4605 self.Parameters().SetOptimizationLevel(level)
4607 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4608 # @ingroup l3_hypos_ghs3dh
4609 def SetMaximumMemory(self, MB):
4610 # Advanced parameter of GHS3D
4611 self.Parameters().SetMaximumMemory(MB)
4613 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4614 # automatic memory adjustment mode.
4615 # @ingroup l3_hypos_ghs3dh
4616 def SetInitialMemory(self, MB):
4617 # Advanced parameter of GHS3D
4618 self.Parameters().SetInitialMemory(MB)
4620 ## Path to working directory.
4621 # @ingroup l3_hypos_ghs3dh
4622 def SetWorkingDirectory(self, path):
4623 # Advanced parameter of GHS3D
4624 self.Parameters().SetWorkingDirectory(path)
4626 ## To keep working files or remove them. Log file remains in case of errors anyway.
4627 # @ingroup l3_hypos_ghs3dh
4628 def SetKeepFiles(self, toKeep):
4629 # Advanced parameter of GHS3D and GHS3DPRL
4630 self.Parameters().SetKeepFiles(toKeep)
4632 ## To set verbose level [0-10]. <ul>
4633 #<li> 0 - no standard output,
4634 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4635 # indicates when the final mesh is being saved. In addition the software
4636 # gives indication regarding the CPU time.
4637 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4638 # histogram of the skin mesh, quality statistics histogram together with
4639 # the characteristics of the final mesh.</ul>
4640 # @ingroup l3_hypos_ghs3dh
4641 def SetVerboseLevel(self, level):
4642 # Advanced parameter of GHS3D
4643 self.Parameters().SetVerboseLevel(level)
4645 ## To create new nodes.
4646 # @ingroup l3_hypos_ghs3dh
4647 def SetToCreateNewNodes(self, toCreate):
4648 # Advanced parameter of GHS3D
4649 self.Parameters().SetToCreateNewNodes(toCreate)
4651 ## To use boundary recovery version which tries to create mesh on a very poor
4652 # quality surface mesh.
4653 # @ingroup l3_hypos_ghs3dh
4654 def SetToUseBoundaryRecoveryVersion(self, toUse):
4655 # Advanced parameter of GHS3D
4656 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4658 ## Sets command line option as text.
4659 # @ingroup l3_hypos_ghs3dh
4660 def SetTextOption(self, option):
4661 # Advanced parameter of GHS3D
4662 self.Parameters().SetTextOption(option)
4664 ## Sets MED files name and path.
4665 def SetMEDName(self, value):
4666 self.Parameters().SetMEDName(value)
4668 ## Sets the number of partition of the initial mesh
4669 def SetNbPart(self, value):
4670 self.Parameters().SetNbPart(value)
4672 ## When big mesh, start tepal in background
4673 def SetBackground(self, value):
4674 self.Parameters().SetBackground(value)
4676 # Public class: Mesh_Hexahedron
4677 # ------------------------------
4679 ## Defines a hexahedron 3D algorithm
4681 # @ingroup l3_algos_basic
4682 class Mesh_Hexahedron(Mesh_Algorithm):
4687 ## Private constructor.
4688 def __init__(self, mesh, algoType=Hexa, geom=0):
4689 Mesh_Algorithm.__init__(self)
4691 self.algoType = algoType
4693 if algoType == Hexa:
4694 self.Create(mesh, geom, "Hexa_3D")
4697 elif algoType == Hexotic:
4698 CheckPlugin(Hexotic)
4699 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4702 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4703 # @ingroup l3_hypos_hexotic
4704 def MinMaxQuad(self, min=3, max=8, quad=True):
4705 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4707 self.params.SetHexesMinLevel(min)
4708 self.params.SetHexesMaxLevel(max)
4709 self.params.SetHexoticQuadrangles(quad)
4712 # Deprecated, only for compatibility!
4713 # Public class: Mesh_Netgen
4714 # ------------------------------
4716 ## Defines a NETGEN-based 2D or 3D algorithm
4717 # that needs no discrete boundary (i.e. independent)
4719 # This class is deprecated, only for compatibility!
4722 # @ingroup l3_algos_basic
4723 class Mesh_Netgen(Mesh_Algorithm):
4727 ## Private constructor.
4728 def __init__(self, mesh, is3D, geom=0):
4729 Mesh_Algorithm.__init__(self)
4735 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4739 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4742 ## Defines the hypothesis containing parameters of the algorithm
4743 def Parameters(self):
4745 hyp = self.Hypothesis("NETGEN_Parameters", [],
4746 "libNETGENEngine.so", UseExisting=0)
4748 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4749 "libNETGENEngine.so", UseExisting=0)
4752 # Public class: Mesh_Projection1D
4753 # ------------------------------
4755 ## Defines a projection 1D algorithm
4756 # @ingroup l3_algos_proj
4758 class Mesh_Projection1D(Mesh_Algorithm):
4760 ## Private constructor.
4761 def __init__(self, mesh, geom=0):
4762 Mesh_Algorithm.__init__(self)
4763 self.Create(mesh, geom, "Projection_1D")
4765 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4766 # a mesh pattern is taken, and, optionally, the association of vertices
4767 # between the source edge and a target edge (to which a hypothesis is assigned)
4768 # @param edge from which nodes distribution is taken
4769 # @param mesh from which nodes distribution is taken (optional)
4770 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4771 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4772 # to associate with \a srcV (optional)
4773 # @param UseExisting if ==true - searches for the existing hypothesis created with
4774 # the same parameters, else (default) - creates a new one
4775 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4776 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4778 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4779 hyp.SetSourceEdge( edge )
4780 if not mesh is None and isinstance(mesh, Mesh):
4781 mesh = mesh.GetMesh()
4782 hyp.SetSourceMesh( mesh )
4783 hyp.SetVertexAssociation( srcV, tgtV )
4786 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4787 #def CompareSourceEdge(self, hyp, args):
4788 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4792 # Public class: Mesh_Projection2D
4793 # ------------------------------
4795 ## Defines a projection 2D algorithm
4796 # @ingroup l3_algos_proj
4798 class Mesh_Projection2D(Mesh_Algorithm):
4800 ## Private constructor.
4801 def __init__(self, mesh, geom=0):
4802 Mesh_Algorithm.__init__(self)
4803 self.Create(mesh, geom, "Projection_2D")
4805 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4806 # a mesh pattern is taken, and, optionally, the association of vertices
4807 # between the source face and the target face (to which a hypothesis is assigned)
4808 # @param face from which the mesh pattern is taken
4809 # @param mesh from which the mesh pattern is taken (optional)
4810 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4811 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4812 # to associate with \a srcV1 (optional)
4813 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4814 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4815 # to associate with \a srcV2 (optional)
4816 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4817 # the same parameters, else (default) - forces the creation a new one
4819 # Note: all association vertices must belong to one edge of a face
4820 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4821 srcV2=None, tgtV2=None, UseExisting=0):
4822 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4824 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4825 hyp.SetSourceFace( face )
4826 if not mesh is None and isinstance(mesh, Mesh):
4827 mesh = mesh.GetMesh()
4828 hyp.SetSourceMesh( mesh )
4829 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4832 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4833 #def CompareSourceFace(self, hyp, args):
4834 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4837 # Public class: Mesh_Projection3D
4838 # ------------------------------
4840 ## Defines a projection 3D algorithm
4841 # @ingroup l3_algos_proj
4843 class Mesh_Projection3D(Mesh_Algorithm):
4845 ## Private constructor.
4846 def __init__(self, mesh, geom=0):
4847 Mesh_Algorithm.__init__(self)
4848 self.Create(mesh, geom, "Projection_3D")
4850 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4851 # the mesh pattern is taken, and, optionally, the association of vertices
4852 # between the source and the target solid (to which a hipothesis is assigned)
4853 # @param solid from where the mesh pattern is taken
4854 # @param mesh from where the mesh pattern is taken (optional)
4855 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4856 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4857 # to associate with \a srcV1 (optional)
4858 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4859 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4860 # to associate with \a srcV2 (optional)
4861 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4862 # the same parameters, else (default) - creates a new one
4864 # Note: association vertices must belong to one edge of a solid
4865 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4866 srcV2=0, tgtV2=0, UseExisting=0):
4867 hyp = self.Hypothesis("ProjectionSource3D",
4868 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4870 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4871 hyp.SetSource3DShape( solid )
4872 if not mesh is None and isinstance(mesh, Mesh):
4873 mesh = mesh.GetMesh()
4874 hyp.SetSourceMesh( mesh )
4875 if srcV1 and srcV2 and tgtV1 and tgtV2:
4876 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4877 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4880 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4881 #def CompareSourceShape3D(self, hyp, args):
4882 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4886 # Public class: Mesh_Prism
4887 # ------------------------
4889 ## Defines a 3D extrusion algorithm
4890 # @ingroup l3_algos_3dextr
4892 class Mesh_Prism3D(Mesh_Algorithm):
4894 ## Private constructor.
4895 def __init__(self, mesh, geom=0):
4896 Mesh_Algorithm.__init__(self)
4897 self.Create(mesh, geom, "Prism_3D")
4899 # Public class: Mesh_RadialPrism
4900 # -------------------------------
4902 ## Defines a Radial Prism 3D algorithm
4903 # @ingroup l3_algos_radialp
4905 class Mesh_RadialPrism3D(Mesh_Algorithm):
4907 ## Private constructor.
4908 def __init__(self, mesh, geom=0):
4909 Mesh_Algorithm.__init__(self)
4910 self.Create(mesh, geom, "RadialPrism_3D")
4912 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4913 self.nbLayers = None
4915 ## Return 3D hypothesis holding the 1D one
4916 def Get3DHypothesis(self):
4917 return self.distribHyp
4919 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4920 # hypothesis. Returns the created hypothesis
4921 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4922 #print "OwnHypothesis",hypType
4923 if not self.nbLayers is None:
4924 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4925 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4926 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4927 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4928 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4929 self.distribHyp.SetLayerDistribution( hyp )
4932 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4933 # prisms to build between the inner and outer shells
4934 # @param n number of layers
4935 # @param UseExisting if ==true - searches for the existing hypothesis created with
4936 # the same parameters, else (default) - creates a new one
4937 def NumberOfLayers(self, n, UseExisting=0):
4938 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4939 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4940 CompareMethod=self.CompareNumberOfLayers)
4941 self.nbLayers.SetNumberOfLayers( n )
4942 return self.nbLayers
4944 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4945 def CompareNumberOfLayers(self, hyp, args):
4946 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4948 ## Defines "LocalLength" hypothesis, specifying the segment length
4949 # to build between the inner and the outer shells
4950 # @param l the length of segments
4951 # @param p the precision of rounding
4952 def LocalLength(self, l, p=1e-07):
4953 hyp = self.OwnHypothesis("LocalLength", [l,p])
4958 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4959 # prisms to build between the inner and the outer shells.
4960 # @param n the number of layers
4961 # @param s the scale factor (optional)
4962 def NumberOfSegments(self, n, s=[]):
4964 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4966 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4967 hyp.SetDistrType( 1 )
4968 hyp.SetScaleFactor(s)
4969 hyp.SetNumberOfSegments(n)
4972 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4973 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4974 # @param start the length of the first segment
4975 # @param end the length of the last segment
4976 def Arithmetic1D(self, start, end ):
4977 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4978 hyp.SetLength(start, 1)
4979 hyp.SetLength(end , 0)
4982 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4983 # to build between the inner and the outer shells as geometric length increasing
4984 # @param start for the length of the first segment
4985 # @param end for the length of the last segment
4986 def StartEndLength(self, start, end):
4987 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4988 hyp.SetLength(start, 1)
4989 hyp.SetLength(end , 0)
4992 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4993 # to build between the inner and outer shells
4994 # @param fineness defines the quality of the mesh within the range [0-1]
4995 def AutomaticLength(self, fineness=0):
4996 hyp = self.OwnHypothesis("AutomaticLength")
4997 hyp.SetFineness( fineness )
5000 # Public class: Mesh_RadialQuadrangle1D2D
5001 # -------------------------------
5003 ## Defines a Radial Quadrangle 1D2D algorithm
5004 # @ingroup l2_algos_radialq
5006 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5008 ## Private constructor.
5009 def __init__(self, mesh, geom=0):
5010 Mesh_Algorithm.__init__(self)
5011 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5013 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5014 self.nbLayers = None
5016 ## Return 2D hypothesis holding the 1D one
5017 def Get2DHypothesis(self):
5018 return self.distribHyp
5020 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5021 # hypothesis. Returns the created hypothesis
5022 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5023 #print "OwnHypothesis",hypType
5024 if not self.nbLayers is None:
5025 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5026 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5027 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5028 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5029 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5030 self.distribHyp.SetLayerDistribution( hyp )
5033 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
5034 # @param n number of layers
5035 # @param UseExisting if ==true - searches for the existing hypothesis created with
5036 # the same parameters, else (default) - creates a new one
5037 def NumberOfLayers2D(self, n, UseExisting=0):
5038 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5039 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5040 CompareMethod=self.CompareNumberOfLayers)
5041 self.nbLayers.SetNumberOfLayers( n )
5042 return self.nbLayers
5044 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5045 def CompareNumberOfLayers(self, hyp, args):
5046 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5048 ## Defines "LocalLength" hypothesis, specifying the segment length
5049 # @param l the length of segments
5050 # @param p the precision of rounding
5051 def LocalLength(self, l, p=1e-07):
5052 hyp = self.OwnHypothesis("LocalLength", [l,p])
5057 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5058 # @param n the number of layers
5059 # @param s the scale factor (optional)
5060 def NumberOfSegments(self, n, s=[]):
5062 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5064 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5065 hyp.SetDistrType( 1 )
5066 hyp.SetScaleFactor(s)
5067 hyp.SetNumberOfSegments(n)
5070 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5071 # with a length that changes in arithmetic progression
5072 # @param start the length of the first segment
5073 # @param end the length of the last segment
5074 def Arithmetic1D(self, start, end ):
5075 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5076 hyp.SetLength(start, 1)
5077 hyp.SetLength(end , 0)
5080 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5081 # as geometric length increasing
5082 # @param start for the length of the first segment
5083 # @param end for the length of the last segment
5084 def StartEndLength(self, start, end):
5085 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5086 hyp.SetLength(start, 1)
5087 hyp.SetLength(end , 0)
5090 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5091 # @param fineness defines the quality of the mesh within the range [0-1]
5092 def AutomaticLength(self, fineness=0):
5093 hyp = self.OwnHypothesis("AutomaticLength")
5094 hyp.SetFineness( fineness )
5098 # Private class: Mesh_UseExisting
5099 # -------------------------------
5100 class Mesh_UseExisting(Mesh_Algorithm):
5102 def __init__(self, dim, mesh, geom=0):
5104 self.Create(mesh, geom, "UseExisting_1D")
5106 self.Create(mesh, geom, "UseExisting_2D")
5109 import salome_notebook
5110 notebook = salome_notebook.notebook
5112 ##Return values of the notebook variables
5113 def ParseParameters(last, nbParams,nbParam, value):
5117 listSize = len(last)
5118 for n in range(0,nbParams):
5120 if counter < listSize:
5121 strResult = strResult + last[counter]
5123 strResult = strResult + ""
5125 if isinstance(value, str):
5126 if notebook.isVariable(value):
5127 result = notebook.get(value)
5128 strResult=strResult+value
5130 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5132 strResult=strResult+str(value)
5134 if nbParams - 1 != counter:
5135 strResult=strResult+var_separator #":"
5137 return result, strResult
5139 #Wrapper class for StdMeshers_LocalLength hypothesis
5140 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5142 ## Set Length parameter value
5143 # @param length numerical value or name of variable from notebook
5144 def SetLength(self, length):
5145 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5146 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5147 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5149 ## Set Precision parameter value
5150 # @param precision numerical value or name of variable from notebook
5151 def SetPrecision(self, precision):
5152 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5153 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5154 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5156 #Registering the new proxy for LocalLength
5157 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5160 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5161 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5163 def SetLayerDistribution(self, hypo):
5164 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5165 hypo.ClearParameters();
5166 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5168 #Registering the new proxy for LayerDistribution
5169 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5171 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5172 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5174 ## Set Length parameter value
5175 # @param length numerical value or name of variable from notebook
5176 def SetLength(self, length):
5177 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5178 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5179 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5181 #Registering the new proxy for SegmentLengthAroundVertex
5182 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5185 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5186 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5188 ## Set Length parameter value
5189 # @param length numerical value or name of variable from notebook
5190 # @param isStart true is length is Start Length, otherwise false
5191 def SetLength(self, length, isStart):
5195 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5196 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5197 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5199 #Registering the new proxy for Arithmetic1D
5200 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5202 #Wrapper class for StdMeshers_Deflection1D hypothesis
5203 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5205 ## Set Deflection parameter value
5206 # @param deflection numerical value or name of variable from notebook
5207 def SetDeflection(self, deflection):
5208 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5209 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5210 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5212 #Registering the new proxy for Deflection1D
5213 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5215 #Wrapper class for StdMeshers_StartEndLength hypothesis
5216 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5218 ## Set Length parameter value
5219 # @param length numerical value or name of variable from notebook
5220 # @param isStart true is length is Start Length, otherwise false
5221 def SetLength(self, length, isStart):
5225 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5226 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5227 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5229 #Registering the new proxy for StartEndLength
5230 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5232 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5233 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5235 ## Set Max Element Area parameter value
5236 # @param area numerical value or name of variable from notebook
5237 def SetMaxElementArea(self, area):
5238 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5239 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5240 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5242 #Registering the new proxy for MaxElementArea
5243 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5246 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5247 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5249 ## Set Max Element Volume parameter value
5250 # @param volume numerical value or name of variable from notebook
5251 def SetMaxElementVolume(self, volume):
5252 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5253 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5254 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5256 #Registering the new proxy for MaxElementVolume
5257 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5260 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5261 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5263 ## Set Number Of Layers parameter value
5264 # @param nbLayers numerical value or name of variable from notebook
5265 def SetNumberOfLayers(self, nbLayers):
5266 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5267 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5268 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5270 #Registering the new proxy for NumberOfLayers
5271 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5273 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5274 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
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 = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5280 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5281 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5282 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5284 ## Set Scale Factor parameter value
5285 # @param factor numerical value or name of variable from notebook
5286 def SetScaleFactor(self, factor):
5287 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5288 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5289 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5291 #Registering the new proxy for NumberOfSegments
5292 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5294 if not noNETGENPlugin:
5295 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5296 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5298 ## Set Max Size parameter value
5299 # @param maxsize numerical value or name of variable from notebook
5300 def SetMaxSize(self, maxsize):
5301 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5302 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5303 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5304 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5306 ## Set Growth Rate parameter value
5307 # @param value numerical value or name of variable from notebook
5308 def SetGrowthRate(self, value):
5309 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5310 value, parameters = ParseParameters(lastParameters,4,2,value)
5311 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5312 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5314 ## Set Number of Segments per Edge parameter value
5315 # @param value numerical value or name of variable from notebook
5316 def SetNbSegPerEdge(self, value):
5317 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5318 value, parameters = ParseParameters(lastParameters,4,3,value)
5319 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5320 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5322 ## Set Number of Segments per Radius parameter value
5323 # @param value numerical value or name of variable from notebook
5324 def SetNbSegPerRadius(self, value):
5325 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5326 value, parameters = ParseParameters(lastParameters,4,4,value)
5327 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5328 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5330 #Registering the new proxy for NETGENPlugin_Hypothesis
5331 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5334 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5335 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5338 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5339 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5341 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5342 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5344 ## Set Number of Segments parameter value
5345 # @param nbSeg numerical value or name of variable from notebook
5346 def SetNumberOfSegments(self, nbSeg):
5347 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5348 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5349 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5350 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5352 ## Set Local Length parameter value
5353 # @param length numerical value or name of variable from notebook
5354 def SetLocalLength(self, length):
5355 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5356 length, parameters = ParseParameters(lastParameters,2,1,length)
5357 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5358 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5360 ## Set Max Element Area parameter value
5361 # @param area numerical value or name of variable from notebook
5362 def SetMaxElementArea(self, area):
5363 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5364 area, parameters = ParseParameters(lastParameters,2,2,area)
5365 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5366 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5368 def LengthFromEdges(self):
5369 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5371 value, parameters = ParseParameters(lastParameters,2,2,value)
5372 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5373 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5375 #Registering the new proxy for NETGEN_SimpleParameters_2D
5376 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5379 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5380 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5381 ## Set Max Element Volume parameter value
5382 # @param volume numerical value or name of variable from notebook
5383 def SetMaxElementVolume(self, volume):
5384 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5385 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5386 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5387 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5389 def LengthFromFaces(self):
5390 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5392 value, parameters = ParseParameters(lastParameters,3,3,value)
5393 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5394 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5396 #Registering the new proxy for NETGEN_SimpleParameters_3D
5397 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5399 pass # if not noNETGENPlugin:
5401 class Pattern(SMESH._objref_SMESH_Pattern):
5403 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5405 if isinstance(theNodeIndexOnKeyPoint1,str):
5407 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5409 theNodeIndexOnKeyPoint1 -= 1
5410 theMesh.SetParameters(Parameters)
5411 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5413 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5416 if isinstance(theNode000Index,str):
5418 if isinstance(theNode001Index,str):
5420 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5422 theNode000Index -= 1
5424 theNode001Index -= 1
5425 theMesh.SetParameters(Parameters)
5426 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5428 #Registering the new proxy for Pattern
5429 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)