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
104 # import NETGENPlugin module if possible
112 # import GHS3DPlugin module if possible
120 # import GHS3DPRLPlugin module if possible
123 import GHS3DPRLPlugin
128 # import HexoticPlugin module if possible
136 # import BLSURFPlugin module if possible
144 ## @addtogroup l1_auxiliary
147 # Types of algorithms
160 NETGEN_1D2D3D = FULL_NETGEN
161 NETGEN_FULL = FULL_NETGEN
169 # MirrorType enumeration
170 POINT = SMESH_MeshEditor.POINT
171 AXIS = SMESH_MeshEditor.AXIS
172 PLANE = SMESH_MeshEditor.PLANE
174 # Smooth_Method enumeration
175 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
176 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
178 # Fineness enumeration (for NETGEN)
186 # Optimization level of GHS3D
188 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
189 # V4.1 (partialy redefines V3.1). Issue 0020574
190 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
192 # Topology treatment way of BLSURF
193 FromCAD, PreProcess, PreProcessPlus = 0,1,2
195 # Element size flag of BLSURF
196 DefaultSize, DefaultGeom, Custom = 0,0,1
198 PrecisionConfusion = 1e-07
200 ## Converts an angle from degrees to radians
201 def DegreesToRadians(AngleInDegrees):
203 return AngleInDegrees * pi / 180.0
205 # Salome notebook variable separator
208 # Parametrized substitute for PointStruct
209 class PointStructStr:
218 def __init__(self, xStr, yStr, zStr):
222 if isinstance(xStr, str) and notebook.isVariable(xStr):
223 self.x = notebook.get(xStr)
226 if isinstance(yStr, str) and notebook.isVariable(yStr):
227 self.y = notebook.get(yStr)
230 if isinstance(zStr, str) and notebook.isVariable(zStr):
231 self.z = notebook.get(zStr)
235 # Parametrized substitute for PointStruct (with 6 parameters)
236 class PointStructStr6:
251 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
258 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
259 self.x1 = notebook.get(x1Str)
262 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
263 self.x2 = notebook.get(x2Str)
266 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
267 self.y1 = notebook.get(y1Str)
270 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
271 self.y2 = notebook.get(y2Str)
274 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
275 self.z1 = notebook.get(z1Str)
278 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
279 self.z2 = notebook.get(z2Str)
283 # Parametrized substitute for AxisStruct
299 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
306 if isinstance(xStr, str) and notebook.isVariable(xStr):
307 self.x = notebook.get(xStr)
310 if isinstance(yStr, str) and notebook.isVariable(yStr):
311 self.y = notebook.get(yStr)
314 if isinstance(zStr, str) and notebook.isVariable(zStr):
315 self.z = notebook.get(zStr)
318 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
319 self.dx = notebook.get(dxStr)
322 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
323 self.dy = notebook.get(dyStr)
326 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
327 self.dz = notebook.get(dzStr)
331 # Parametrized substitute for DirStruct
334 def __init__(self, pointStruct):
335 self.pointStruct = pointStruct
337 # Returns list of variable values from salome notebook
338 def ParsePointStruct(Point):
339 Parameters = 2*var_separator
340 if isinstance(Point, PointStructStr):
341 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
342 Point = PointStruct(Point.x, Point.y, Point.z)
343 return Point, Parameters
345 # Returns list of variable values from salome notebook
346 def ParseDirStruct(Dir):
347 Parameters = 2*var_separator
348 if isinstance(Dir, DirStructStr):
349 pntStr = Dir.pointStruct
350 if isinstance(pntStr, PointStructStr6):
351 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
352 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
353 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
354 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
356 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
357 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
358 Dir = DirStruct(Point)
359 return Dir, Parameters
361 # Returns list of variable values from salome notebook
362 def ParseAxisStruct(Axis):
363 Parameters = 5*var_separator
364 if isinstance(Axis, AxisStructStr):
365 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
366 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
367 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
368 return Axis, Parameters
370 ## Return list of variable values from salome notebook
371 def ParseAngles(list):
374 for parameter in list:
375 if isinstance(parameter,str) and notebook.isVariable(parameter):
376 Result.append(DegreesToRadians(notebook.get(parameter)))
379 Result.append(parameter)
382 Parameters = Parameters + str(parameter)
383 Parameters = Parameters + var_separator
385 Parameters = Parameters[:len(Parameters)-1]
386 return Result, Parameters
388 def IsEqual(val1, val2, tol=PrecisionConfusion):
389 if abs(val1 - val2) < tol:
399 if isinstance(obj, SALOMEDS._objref_SObject):
402 ior = salome.orb.object_to_string(obj)
405 studies = salome.myStudyManager.GetOpenStudies()
406 for sname in studies:
407 s = salome.myStudyManager.GetStudyByName(sname)
409 sobj = s.FindObjectIOR(ior)
410 if not sobj: continue
411 return sobj.GetName()
412 if hasattr(obj, "GetName"):
413 # unknown CORBA object, having GetName() method
416 # unknown CORBA object, no GetName() method
419 if hasattr(obj, "GetName"):
420 # unknown non-CORBA object, having GetName() method
423 raise RuntimeError, "Null or invalid object"
425 ## Prints error message if a hypothesis was not assigned.
426 def TreatHypoStatus(status, hypName, geomName, isAlgo):
428 hypType = "algorithm"
430 hypType = "hypothesis"
432 if status == HYP_UNKNOWN_FATAL :
433 reason = "for unknown reason"
434 elif status == HYP_INCOMPATIBLE :
435 reason = "this hypothesis mismatches the algorithm"
436 elif status == HYP_NOTCONFORM :
437 reason = "a non-conform mesh would be built"
438 elif status == HYP_ALREADY_EXIST :
439 reason = hypType + " of the same dimension is already assigned to this shape"
440 elif status == HYP_BAD_DIM :
441 reason = hypType + " mismatches the shape"
442 elif status == HYP_CONCURENT :
443 reason = "there are concurrent hypotheses on sub-shapes"
444 elif status == HYP_BAD_SUBSHAPE :
445 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
446 elif status == HYP_BAD_GEOMETRY:
447 reason = "geometry mismatches the expectation of the algorithm"
448 elif status == HYP_HIDDEN_ALGO:
449 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
450 elif status == HYP_HIDING_ALGO:
451 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
452 elif status == HYP_NEED_SHAPE:
453 reason = "Algorithm can't work without shape"
456 hypName = '"' + hypName + '"'
457 geomName= '"' + geomName+ '"'
458 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
459 print hypName, "was assigned to", geomName,"but", reason
460 elif not geomName == '""':
461 print hypName, "was not assigned to",geomName,":", reason
463 print hypName, "was not assigned:", reason
466 ## Check meshing plugin availability
467 def CheckPlugin(plugin):
468 if plugin == NETGEN and noNETGENPlugin:
469 print "Warning: NETGENPlugin module unavailable"
471 elif plugin == GHS3D and noGHS3DPlugin:
472 print "Warning: GHS3DPlugin module unavailable"
474 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
475 print "Warning: GHS3DPRLPlugin module unavailable"
477 elif plugin == Hexotic and noHexoticPlugin:
478 print "Warning: HexoticPlugin module unavailable"
480 elif plugin == BLSURF and noBLSURFPlugin:
481 print "Warning: BLSURFPlugin module unavailable"
485 # end of l1_auxiliary
488 # All methods of this class are accessible directly from the smesh.py package.
489 class smeshDC(SMESH._objref_SMESH_Gen):
491 ## Sets the current study and Geometry component
492 # @ingroup l1_auxiliary
493 def init_smesh(self,theStudy,geompyD):
494 self.SetCurrentStudy(theStudy,geompyD)
496 ## Creates an empty Mesh. This mesh can have an underlying geometry.
497 # @param obj the Geometrical object on which the mesh is built. If not defined,
498 # the mesh will have no underlying geometry.
499 # @param name the name for the new mesh.
500 # @return an instance of Mesh class.
501 # @ingroup l2_construct
502 def Mesh(self, obj=0, name=0):
503 if isinstance(obj,str):
505 return Mesh(self,self.geompyD,obj,name)
507 ## Returns a long value from enumeration
508 # Should be used for SMESH.FunctorType enumeration
509 # @ingroup l1_controls
510 def EnumToLong(self,theItem):
513 ## Gets PointStruct from vertex
514 # @param theVertex a GEOM object(vertex)
515 # @return SMESH.PointStruct
516 # @ingroup l1_auxiliary
517 def GetPointStruct(self,theVertex):
518 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
519 return PointStruct(x,y,z)
521 ## Gets DirStruct from vector
522 # @param theVector a GEOM object(vector)
523 # @return SMESH.DirStruct
524 # @ingroup l1_auxiliary
525 def GetDirStruct(self,theVector):
526 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
527 if(len(vertices) != 2):
528 print "Error: vector object is incorrect."
530 p1 = self.geompyD.PointCoordinates(vertices[0])
531 p2 = self.geompyD.PointCoordinates(vertices[1])
532 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
533 dirst = DirStruct(pnt)
536 ## Makes DirStruct from a triplet
537 # @param x,y,z vector components
538 # @return SMESH.DirStruct
539 # @ingroup l1_auxiliary
540 def MakeDirStruct(self,x,y,z):
541 pnt = PointStruct(x,y,z)
542 return DirStruct(pnt)
544 ## Get AxisStruct from object
545 # @param theObj a GEOM object (line or plane)
546 # @return SMESH.AxisStruct
547 # @ingroup l1_auxiliary
548 def GetAxisStruct(self,theObj):
549 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
551 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
552 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
553 vertex1 = self.geompyD.PointCoordinates(vertex1)
554 vertex2 = self.geompyD.PointCoordinates(vertex2)
555 vertex3 = self.geompyD.PointCoordinates(vertex3)
556 vertex4 = self.geompyD.PointCoordinates(vertex4)
557 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
558 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
559 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] ]
560 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
562 elif len(edges) == 1:
563 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
564 p1 = self.geompyD.PointCoordinates( vertex1 )
565 p2 = self.geompyD.PointCoordinates( vertex2 )
566 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
570 # From SMESH_Gen interface:
571 # ------------------------
573 ## Sets the given name to the object
574 # @param obj the object to rename
575 # @param name a new object name
576 # @ingroup l1_auxiliary
577 def SetName(self, obj, name):
578 if isinstance( obj, Mesh ):
580 elif isinstance( obj, Mesh_Algorithm ):
581 obj = obj.GetAlgorithm()
582 ior = salome.orb.object_to_string(obj)
583 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
585 ## Sets the current mode
586 # @ingroup l1_auxiliary
587 def SetEmbeddedMode( self,theMode ):
588 #self.SetEmbeddedMode(theMode)
589 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
591 ## Gets the current mode
592 # @ingroup l1_auxiliary
593 def IsEmbeddedMode(self):
594 #return self.IsEmbeddedMode()
595 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
597 ## Sets the current study
598 # @ingroup l1_auxiliary
599 def SetCurrentStudy( self, theStudy, geompyD = None ):
600 #self.SetCurrentStudy(theStudy)
603 geompyD = geompy.geom
606 self.SetGeomEngine(geompyD)
607 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
609 ## Gets the current study
610 # @ingroup l1_auxiliary
611 def GetCurrentStudy(self):
612 #return self.GetCurrentStudy()
613 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
615 ## Creates a Mesh object importing data from the given UNV file
616 # @return an instance of Mesh class
618 def CreateMeshesFromUNV( self,theFileName ):
619 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
620 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
623 ## Creates a Mesh object(s) importing data from the given MED file
624 # @return a list of Mesh class instances
626 def CreateMeshesFromMED( self,theFileName ):
627 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
629 for iMesh in range(len(aSmeshMeshes)) :
630 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
631 aMeshes.append(aMesh)
632 return aMeshes, aStatus
634 ## Creates a Mesh object importing data from the given STL file
635 # @return an instance of Mesh class
637 def CreateMeshesFromSTL( self, theFileName ):
638 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
639 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
642 ## From SMESH_Gen interface
643 # @return the list of integer values
644 # @ingroup l1_auxiliary
645 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
646 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
648 ## From SMESH_Gen interface. Creates a pattern
649 # @return an instance of SMESH_Pattern
651 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
652 # @ingroup l2_modif_patterns
653 def GetPattern(self):
654 return SMESH._objref_SMESH_Gen.GetPattern(self)
656 ## Sets number of segments per diagonal of boundary box of geometry by which
657 # default segment length of appropriate 1D hypotheses is defined.
658 # Default value is 10
659 # @ingroup l1_auxiliary
660 def SetBoundaryBoxSegmentation(self, nbSegments):
661 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
663 ## Concatenate the given meshes into one mesh.
664 # @return an instance of Mesh class
665 # @param meshes the meshes to combine into one mesh
666 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
667 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
668 # @param mergeTolerance tolerance for merging nodes
669 # @param allGroups forces creation of groups of all elements
670 def Concatenate( self, meshes, uniteIdenticalGroups,
671 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
672 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
674 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
675 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
677 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
678 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
679 aSmeshMesh.SetParameters(Parameters)
680 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
683 # Filtering. Auxiliary functions:
684 # ------------------------------
686 ## Creates an empty criterion
687 # @return SMESH.Filter.Criterion
688 # @ingroup l1_controls
689 def GetEmptyCriterion(self):
690 Type = self.EnumToLong(FT_Undefined)
691 Compare = self.EnumToLong(FT_Undefined)
695 UnaryOp = self.EnumToLong(FT_Undefined)
696 BinaryOp = self.EnumToLong(FT_Undefined)
699 Precision = -1 ##@1e-07
700 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
701 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
703 ## Creates a criterion by the given parameters
704 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
705 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
706 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
707 # @param Treshold the threshold value (range of ids as string, shape, numeric)
708 # @param UnaryOp FT_LogicalNOT or FT_Undefined
709 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
710 # FT_Undefined (must be for the last criterion of all criteria)
711 # @return SMESH.Filter.Criterion
712 # @ingroup l1_controls
713 def GetCriterion(self,elementType,
715 Compare = FT_EqualTo,
717 UnaryOp=FT_Undefined,
718 BinaryOp=FT_Undefined):
719 aCriterion = self.GetEmptyCriterion()
720 aCriterion.TypeOfElement = elementType
721 aCriterion.Type = self.EnumToLong(CritType)
725 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
726 aCriterion.Compare = self.EnumToLong(Compare)
727 elif Compare == "=" or Compare == "==":
728 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
730 aCriterion.Compare = self.EnumToLong(FT_LessThan)
732 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
734 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
737 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
738 FT_BelongToCylinder, FT_LyingOnGeom]:
739 # Checks the treshold
740 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
741 aCriterion.ThresholdStr = GetName(aTreshold)
742 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
744 print "Error: The treshold should be a shape."
746 elif CritType == FT_RangeOfIds:
747 # Checks the treshold
748 if isinstance(aTreshold, str):
749 aCriterion.ThresholdStr = aTreshold
751 print "Error: The treshold should be a string."
753 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
754 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
755 # At this point the treshold is unnecessary
756 if aTreshold == FT_LogicalNOT:
757 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
758 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
759 aCriterion.BinaryOp = aTreshold
763 aTreshold = float(aTreshold)
764 aCriterion.Threshold = aTreshold
766 print "Error: The treshold should be a number."
769 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
770 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
772 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
773 aCriterion.BinaryOp = self.EnumToLong(Treshold)
775 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
776 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
778 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
779 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
783 ## Creates a filter with the given parameters
784 # @param elementType the type of elements in the group
785 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
786 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
787 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
788 # @param UnaryOp FT_LogicalNOT or FT_Undefined
789 # @return SMESH_Filter
790 # @ingroup l1_controls
791 def GetFilter(self,elementType,
792 CritType=FT_Undefined,
795 UnaryOp=FT_Undefined):
796 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
797 aFilterMgr = self.CreateFilterManager()
798 aFilter = aFilterMgr.CreateFilter()
800 aCriteria.append(aCriterion)
801 aFilter.SetCriteria(aCriteria)
804 ## Creates a numerical functor by its type
805 # @param theCriterion FT_...; functor type
806 # @return SMESH_NumericalFunctor
807 # @ingroup l1_controls
808 def GetFunctor(self,theCriterion):
809 aFilterMgr = self.CreateFilterManager()
810 if theCriterion == FT_AspectRatio:
811 return aFilterMgr.CreateAspectRatio()
812 elif theCriterion == FT_AspectRatio3D:
813 return aFilterMgr.CreateAspectRatio3D()
814 elif theCriterion == FT_Warping:
815 return aFilterMgr.CreateWarping()
816 elif theCriterion == FT_MinimumAngle:
817 return aFilterMgr.CreateMinimumAngle()
818 elif theCriterion == FT_Taper:
819 return aFilterMgr.CreateTaper()
820 elif theCriterion == FT_Skew:
821 return aFilterMgr.CreateSkew()
822 elif theCriterion == FT_Area:
823 return aFilterMgr.CreateArea()
824 elif theCriterion == FT_Volume3D:
825 return aFilterMgr.CreateVolume3D()
826 elif theCriterion == FT_MultiConnection:
827 return aFilterMgr.CreateMultiConnection()
828 elif theCriterion == FT_MultiConnection2D:
829 return aFilterMgr.CreateMultiConnection2D()
830 elif theCriterion == FT_Length:
831 return aFilterMgr.CreateLength()
832 elif theCriterion == FT_Length2D:
833 return aFilterMgr.CreateLength2D()
835 print "Error: given parameter is not numerucal functor type."
837 ## Creates hypothesis
838 # @param theHType mesh hypothesis type (string)
839 # @param theLibName mesh plug-in library name
840 # @return created hypothesis instance
841 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
842 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
844 ## Gets the mesh stattistic
845 # @return dictionary type element - count of elements
846 # @ingroup l1_meshinfo
847 def GetMeshInfo(self, obj):
848 if isinstance( obj, Mesh ):
851 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
852 values = obj.GetMeshInfo()
853 for i in range(SMESH.Entity_Last._v):
854 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
859 #Registering the new proxy for SMESH_Gen
860 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
866 ## This class allows defining and managing a mesh.
867 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
868 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
869 # new nodes and elements and by changing the existing entities), to get information
870 # about a mesh and to export a mesh into different formats.
879 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
880 # sets the GUI name of this mesh to \a name.
881 # @param smeshpyD an instance of smeshDC class
882 # @param geompyD an instance of geompyDC class
883 # @param obj Shape to be meshed or SMESH_Mesh object
884 # @param name Study name of the mesh
885 # @ingroup l2_construct
886 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
887 self.smeshpyD=smeshpyD
892 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
894 self.mesh = self.smeshpyD.CreateMesh(self.geom)
895 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
898 self.mesh = self.smeshpyD.CreateEmptyMesh()
900 self.smeshpyD.SetName(self.mesh, name)
902 self.smeshpyD.SetName(self.mesh, GetName(obj))
905 self.geom = self.mesh.GetShapeToMesh()
907 self.editor = self.mesh.GetMeshEditor()
909 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
910 # @param theMesh a SMESH_Mesh object
911 # @ingroup l2_construct
912 def SetMesh(self, theMesh):
914 self.geom = self.mesh.GetShapeToMesh()
916 ## Returns the mesh, that is an instance of SMESH_Mesh interface
917 # @return a SMESH_Mesh object
918 # @ingroup l2_construct
922 ## Gets the name of the mesh
923 # @return the name of the mesh as a string
924 # @ingroup l2_construct
926 name = GetName(self.GetMesh())
929 ## Sets a name to the mesh
930 # @param name a new name of the mesh
931 # @ingroup l2_construct
932 def SetName(self, name):
933 self.smeshpyD.SetName(self.GetMesh(), name)
935 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
936 # The subMesh object gives access to the IDs of nodes and elements.
937 # @param theSubObject a geometrical object (shape)
938 # @param theName a name for the submesh
939 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
940 # @ingroup l2_submeshes
941 def GetSubMesh(self, theSubObject, theName):
942 submesh = self.mesh.GetSubMesh(theSubObject, theName)
945 ## Returns the shape associated to the mesh
946 # @return a GEOM_Object
947 # @ingroup l2_construct
951 ## Associates the given shape to the mesh (entails the recreation of the mesh)
952 # @param geom the shape to be meshed (GEOM_Object)
953 # @ingroup l2_construct
954 def SetShape(self, geom):
955 self.mesh = self.smeshpyD.CreateMesh(geom)
957 ## Returns true if the hypotheses are defined well
958 # @param theSubObject a subshape of a mesh shape
959 # @return True or False
960 # @ingroup l2_construct
961 def IsReadyToCompute(self, theSubObject):
962 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
964 ## Returns errors of hypotheses definition.
965 # The list of errors is empty if everything is OK.
966 # @param theSubObject a subshape of a mesh shape
967 # @return a list of errors
968 # @ingroup l2_construct
969 def GetAlgoState(self, theSubObject):
970 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
972 ## Returns a geometrical object on which the given element was built.
973 # The returned geometrical object, if not nil, is either found in the
974 # study or published by this method with the given name
975 # @param theElementID the id of the mesh element
976 # @param theGeomName the user-defined name of the geometrical object
977 # @return GEOM::GEOM_Object instance
978 # @ingroup l2_construct
979 def GetGeometryByMeshElement(self, theElementID, theGeomName):
980 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
982 ## Returns the mesh dimension depending on the dimension of the underlying shape
983 # @return mesh dimension as an integer value [0,3]
984 # @ingroup l1_auxiliary
985 def MeshDimension(self):
986 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
987 if len( shells ) > 0 :
989 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
991 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
997 ## Creates a segment discretization 1D algorithm.
998 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
999 # \n If the optional \a geom parameter is not set, this algorithm is global.
1000 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1001 # @param algo the type of the required algorithm. Possible values are:
1003 # - smesh.PYTHON for discretization via a python function,
1004 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1005 # @param geom If defined is the subshape to be meshed
1006 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1007 # @ingroup l3_algos_basic
1008 def Segment(self, algo=REGULAR, geom=0):
1009 ## if Segment(geom) is called by mistake
1010 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1011 algo, geom = geom, algo
1012 if not algo: algo = REGULAR
1015 return Mesh_Segment(self, geom)
1016 elif algo == PYTHON:
1017 return Mesh_Segment_Python(self, geom)
1018 elif algo == COMPOSITE:
1019 return Mesh_CompositeSegment(self, geom)
1021 return Mesh_Segment(self, geom)
1023 ## Enables creation of nodes and segments usable by 2D algoritms.
1024 # The added nodes and segments must be bound to edges and vertices by
1025 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1026 # If the optional \a geom parameter is not set, this algorithm is global.
1027 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1028 # @param geom the subshape to be manually meshed
1029 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1030 # @ingroup l3_algos_basic
1031 def UseExistingSegments(self, geom=0):
1032 algo = Mesh_UseExisting(1,self,geom)
1033 return algo.GetAlgorithm()
1035 ## Enables creation of nodes and faces usable by 3D algoritms.
1036 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1037 # and SetMeshElementOnShape()
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 the subshape to be manually meshed
1041 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1042 # @ingroup l3_algos_basic
1043 def UseExistingFaces(self, geom=0):
1044 algo = Mesh_UseExisting(2,self,geom)
1045 return algo.GetAlgorithm()
1047 ## Creates a triangle 2D algorithm for faces.
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.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1051 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1052 # @return an instance of Mesh_Triangle algorithm
1053 # @ingroup l3_algos_basic
1054 def Triangle(self, algo=MEFISTO, geom=0):
1055 ## if Triangle(geom) is called by mistake
1056 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1059 return Mesh_Triangle(self, algo, geom)
1061 ## Creates a quadrangle 2D algorithm for faces.
1062 # If the optional \a geom parameter is not set, this algorithm is global.
1063 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1064 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1065 # @param algo values are: smesh.QUARDANGLE || smesh.RADIAL_QUAD
1066 # @return an instance of Mesh_Quadrangle algorithm
1067 # @ingroup l3_algos_basic
1068 def Quadrangle(self, geom=0, algo=QUARDANGLE):
1069 if algo==RADIAL_QUAD:
1070 return Mesh_RadialQuadrangle1D2D(self,geom)
1072 return Mesh_Quadrangle(self, geom)
1074 ## Creates a tetrahedron 3D algorithm for solids.
1075 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1076 # If the optional \a geom parameter is not set, this algorithm is global.
1077 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1078 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1079 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1080 # @return an instance of Mesh_Tetrahedron algorithm
1081 # @ingroup l3_algos_basic
1082 def Tetrahedron(self, algo=NETGEN, geom=0):
1083 ## if Tetrahedron(geom) is called by mistake
1084 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1085 algo, geom = geom, algo
1086 if not algo: algo = NETGEN
1088 return Mesh_Tetrahedron(self, algo, geom)
1090 ## Creates a hexahedron 3D algorithm for solids.
1091 # If the optional \a geom parameter is not set, this algorithm is global.
1092 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1093 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1094 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1095 # @return an instance of Mesh_Hexahedron algorithm
1096 # @ingroup l3_algos_basic
1097 def Hexahedron(self, algo=Hexa, geom=0):
1098 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1099 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1100 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1101 elif geom == 0: algo, geom = Hexa, algo
1102 return Mesh_Hexahedron(self, algo, geom)
1104 ## Deprecated, used only for compatibility!
1105 # @return an instance of Mesh_Netgen algorithm
1106 # @ingroup l3_algos_basic
1107 def Netgen(self, is3D, geom=0):
1108 return Mesh_Netgen(self, is3D, geom)
1110 ## Creates a projection 1D algorithm for edges.
1111 # If the optional \a geom parameter is not set, this algorithm is global.
1112 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1113 # @param geom If defined, the subshape to be meshed
1114 # @return an instance of Mesh_Projection1D algorithm
1115 # @ingroup l3_algos_proj
1116 def Projection1D(self, geom=0):
1117 return Mesh_Projection1D(self, geom)
1119 ## Creates a projection 2D algorithm for faces.
1120 # If the optional \a geom parameter is not set, this algorithm is global.
1121 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1122 # @param geom If defined, the subshape to be meshed
1123 # @return an instance of Mesh_Projection2D algorithm
1124 # @ingroup l3_algos_proj
1125 def Projection2D(self, geom=0):
1126 return Mesh_Projection2D(self, geom)
1128 ## Creates a projection 3D algorithm for solids.
1129 # If the optional \a geom parameter is not set, this algorithm is global.
1130 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1131 # @param geom If defined, the subshape to be meshed
1132 # @return an instance of Mesh_Projection3D algorithm
1133 # @ingroup l3_algos_proj
1134 def Projection3D(self, geom=0):
1135 return Mesh_Projection3D(self, geom)
1137 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1138 # If the optional \a geom parameter is not set, this algorithm is global.
1139 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1140 # @param geom If defined, the subshape to be meshed
1141 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1142 # @ingroup l3_algos_radialp l3_algos_3dextr
1143 def Prism(self, geom=0):
1147 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1148 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1149 if nbSolids == 0 or nbSolids == nbShells:
1150 return Mesh_Prism3D(self, geom)
1151 return Mesh_RadialPrism3D(self, geom)
1153 ## Evaluates size of prospective mesh on a shape
1154 # @return True or False
1155 def Evaluate(self, geom=0):
1156 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1158 geom = self.mesh.GetShapeToMesh()
1161 return self.smeshpyD.Evaluate(self.mesh, geom)
1164 ## Computes the mesh and returns the status of the computation
1165 # @return True or False
1166 # @ingroup l2_construct
1167 def Compute(self, geom=0):
1168 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1170 geom = self.mesh.GetShapeToMesh()
1175 ok = self.smeshpyD.Compute(self.mesh, geom)
1176 except SALOME.SALOME_Exception, ex:
1177 print "Mesh computation failed, exception caught:"
1178 print " ", ex.details.text
1181 print "Mesh computation failed, exception caught:"
1182 traceback.print_exc()
1184 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1187 if err.isGlobalAlgo:
1195 reason = '%s %sD algorithm is missing' % (glob, dim)
1196 elif err.state == HYP_MISSING:
1197 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1198 % (glob, dim, name, dim))
1199 elif err.state == HYP_NOTCONFORM:
1200 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1201 elif err.state == HYP_BAD_PARAMETER:
1202 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1203 % ( glob, dim, name ))
1204 elif err.state == HYP_BAD_GEOMETRY:
1205 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1206 'geometry' % ( glob, dim, name ))
1208 reason = "For unknown reason."+\
1209 " Revise Mesh.Compute() implementation in smeshDC.py!"
1211 if allReasons != "":
1214 allReasons += reason
1216 if allReasons != "":
1217 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1221 print '"' + GetName(self.mesh) + '"',"has not been computed."
1224 if salome.sg.hasDesktop():
1225 smeshgui = salome.ImportComponentGUI("SMESH")
1226 smeshgui.Init(self.mesh.GetStudyId())
1227 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1228 salome.sg.updateObjBrowser(1)
1232 ## Return submesh objects list in meshing order
1233 # @return list of list of submesh objects
1234 # @ingroup l2_construct
1235 def GetMeshOrder(self):
1236 return self.mesh.GetMeshOrder()
1238 ## Return submesh objects list in meshing order
1239 # @return list of list of submesh objects
1240 # @ingroup l2_construct
1241 def SetMeshOrder(self, submeshes):
1242 return self.mesh.SetMeshOrder(submeshes)
1244 ## Removes all nodes and elements
1245 # @ingroup l2_construct
1248 if salome.sg.hasDesktop():
1249 smeshgui = salome.ImportComponentGUI("SMESH")
1250 smeshgui.Init(self.mesh.GetStudyId())
1251 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1252 salome.sg.updateObjBrowser(1)
1254 ## Removes all nodes and elements of indicated shape
1255 # @ingroup l2_construct
1256 def ClearSubMesh(self, geomId):
1257 self.mesh.ClearSubMesh(geomId)
1258 if salome.sg.hasDesktop():
1259 smeshgui = salome.ImportComponentGUI("SMESH")
1260 smeshgui.Init(self.mesh.GetStudyId())
1261 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1262 salome.sg.updateObjBrowser(1)
1264 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1265 # @param fineness [0,-1] defines mesh fineness
1266 # @return True or False
1267 # @ingroup l3_algos_basic
1268 def AutomaticTetrahedralization(self, fineness=0):
1269 dim = self.MeshDimension()
1271 self.RemoveGlobalHypotheses()
1272 self.Segment().AutomaticLength(fineness)
1274 self.Triangle().LengthFromEdges()
1277 self.Tetrahedron(NETGEN)
1279 return self.Compute()
1281 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1282 # @param fineness [0,-1] defines mesh fineness
1283 # @return True or False
1284 # @ingroup l3_algos_basic
1285 def AutomaticHexahedralization(self, fineness=0):
1286 dim = self.MeshDimension()
1287 # assign the hypotheses
1288 self.RemoveGlobalHypotheses()
1289 self.Segment().AutomaticLength(fineness)
1296 return self.Compute()
1298 ## Assigns a hypothesis
1299 # @param hyp a hypothesis to assign
1300 # @param geom a subhape of mesh geometry
1301 # @return SMESH.Hypothesis_Status
1302 # @ingroup l2_hypotheses
1303 def AddHypothesis(self, hyp, geom=0):
1304 if isinstance( hyp, Mesh_Algorithm ):
1305 hyp = hyp.GetAlgorithm()
1310 geom = self.mesh.GetShapeToMesh()
1312 status = self.mesh.AddHypothesis(geom, hyp)
1313 isAlgo = hyp._narrow( SMESH_Algo )
1314 hyp_name = GetName( hyp )
1317 geom_name = GetName( geom )
1318 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1321 ## Unassigns a hypothesis
1322 # @param hyp a hypothesis to unassign
1323 # @param geom a subshape of mesh geometry
1324 # @return SMESH.Hypothesis_Status
1325 # @ingroup l2_hypotheses
1326 def RemoveHypothesis(self, hyp, geom=0):
1327 if isinstance( hyp, Mesh_Algorithm ):
1328 hyp = hyp.GetAlgorithm()
1333 status = self.mesh.RemoveHypothesis(geom, hyp)
1336 ## Gets the list of hypotheses added on a geometry
1337 # @param geom a subshape of mesh geometry
1338 # @return the sequence of SMESH_Hypothesis
1339 # @ingroup l2_hypotheses
1340 def GetHypothesisList(self, geom):
1341 return self.mesh.GetHypothesisList( geom )
1343 ## Removes all global hypotheses
1344 # @ingroup l2_hypotheses
1345 def RemoveGlobalHypotheses(self):
1346 current_hyps = self.mesh.GetHypothesisList( self.geom )
1347 for hyp in current_hyps:
1348 self.mesh.RemoveHypothesis( self.geom, hyp )
1352 ## Creates a mesh group based on the geometric object \a grp
1353 # and gives a \a name, \n if this parameter is not defined
1354 # the name is the same as the geometric group name \n
1355 # Note: Works like GroupOnGeom().
1356 # @param grp a geometric group, a vertex, an edge, a face or a solid
1357 # @param name the name of the mesh group
1358 # @return SMESH_GroupOnGeom
1359 # @ingroup l2_grps_create
1360 def Group(self, grp, name=""):
1361 return self.GroupOnGeom(grp, name)
1363 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1364 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1365 # @param f the file name
1366 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1367 # @param opt boolean parameter for creating/not creating
1368 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1369 # @ingroup l2_impexp
1370 def ExportToMED(self, f, version, opt=0):
1371 self.mesh.ExportToMED(f, opt, version)
1373 ## Exports the mesh in a file in MED format
1374 # @param f is the file name
1375 # @param auto_groups boolean parameter for creating/not creating
1376 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1377 # the typical use is auto_groups=false.
1378 # @param version MED format version(MED_V2_1 or MED_V2_2)
1379 # @ingroup l2_impexp
1380 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1381 self.mesh.ExportToMED(f, auto_groups, version)
1383 ## Exports the mesh in a file in DAT format
1384 # @param f the file name
1385 # @ingroup l2_impexp
1386 def ExportDAT(self, f):
1387 self.mesh.ExportDAT(f)
1389 ## Exports the mesh in a file in UNV format
1390 # @param f the file name
1391 # @ingroup l2_impexp
1392 def ExportUNV(self, f):
1393 self.mesh.ExportUNV(f)
1395 ## Export the mesh in a file in STL format
1396 # @param f the file name
1397 # @param ascii defines the file encoding
1398 # @ingroup l2_impexp
1399 def ExportSTL(self, f, ascii=1):
1400 self.mesh.ExportSTL(f, ascii)
1403 # Operations with groups:
1404 # ----------------------
1406 ## Creates an empty mesh group
1407 # @param elementType the type of elements in the group
1408 # @param name the name of the mesh group
1409 # @return SMESH_Group
1410 # @ingroup l2_grps_create
1411 def CreateEmptyGroup(self, elementType, name):
1412 return self.mesh.CreateGroup(elementType, name)
1414 ## Creates a mesh group based on the geometrical object \a grp
1415 # and gives a \a name, \n if this parameter is not defined
1416 # the name is the same as the geometrical group name
1417 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1418 # @param name the name of the mesh group
1419 # @param typ the type of elements in the group. If not set, it is
1420 # automatically detected by the type of the geometry
1421 # @return SMESH_GroupOnGeom
1422 # @ingroup l2_grps_create
1423 def GroupOnGeom(self, grp, name="", typ=None):
1425 name = grp.GetName()
1428 tgeo = str(grp.GetShapeType())
1429 if tgeo == "VERTEX":
1431 elif tgeo == "EDGE":
1433 elif tgeo == "FACE":
1435 elif tgeo == "SOLID":
1437 elif tgeo == "SHELL":
1439 elif tgeo == "COMPOUND":
1440 try: # it raises on a compound of compounds
1441 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1442 print "Mesh.Group: empty geometric group", GetName( grp )
1447 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1449 tgeo = self.geompyD.GetType(grp)
1450 if tgeo == geompyDC.ShapeType["VERTEX"]:
1452 elif tgeo == geompyDC.ShapeType["EDGE"]:
1454 elif tgeo == geompyDC.ShapeType["FACE"]:
1456 elif tgeo == geompyDC.ShapeType["SOLID"]:
1462 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1463 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1464 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1472 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1475 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1477 ## Creates a mesh group by the given ids of elements
1478 # @param groupName the name of the mesh group
1479 # @param elementType the type of elements in the group
1480 # @param elemIDs the list of ids
1481 # @return SMESH_Group
1482 # @ingroup l2_grps_create
1483 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1484 group = self.mesh.CreateGroup(elementType, groupName)
1488 ## Creates a mesh group by the given conditions
1489 # @param groupName the name of the mesh group
1490 # @param elementType the type of elements in the group
1491 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1492 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1493 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1494 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1495 # @return SMESH_Group
1496 # @ingroup l2_grps_create
1500 CritType=FT_Undefined,
1503 UnaryOp=FT_Undefined):
1504 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1505 group = self.MakeGroupByCriterion(groupName, aCriterion)
1508 ## Creates a mesh group by the given criterion
1509 # @param groupName the name of the mesh group
1510 # @param Criterion the instance of Criterion class
1511 # @return SMESH_Group
1512 # @ingroup l2_grps_create
1513 def MakeGroupByCriterion(self, groupName, Criterion):
1514 aFilterMgr = self.smeshpyD.CreateFilterManager()
1515 aFilter = aFilterMgr.CreateFilter()
1517 aCriteria.append(Criterion)
1518 aFilter.SetCriteria(aCriteria)
1519 group = self.MakeGroupByFilter(groupName, aFilter)
1522 ## Creates a mesh group by the given criteria (list of criteria)
1523 # @param groupName the name of the mesh group
1524 # @param theCriteria the list of criteria
1525 # @return SMESH_Group
1526 # @ingroup l2_grps_create
1527 def MakeGroupByCriteria(self, groupName, theCriteria):
1528 aFilterMgr = self.smeshpyD.CreateFilterManager()
1529 aFilter = aFilterMgr.CreateFilter()
1530 aFilter.SetCriteria(theCriteria)
1531 group = self.MakeGroupByFilter(groupName, aFilter)
1534 ## Creates a mesh group by the given filter
1535 # @param groupName the name of the mesh group
1536 # @param theFilter the instance of Filter class
1537 # @return SMESH_Group
1538 # @ingroup l2_grps_create
1539 def MakeGroupByFilter(self, groupName, theFilter):
1540 anIds = theFilter.GetElementsId(self.mesh)
1541 anElemType = theFilter.GetElementType()
1542 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1545 ## Passes mesh elements through the given filter and return IDs of fitting elements
1546 # @param theFilter SMESH_Filter
1547 # @return a list of ids
1548 # @ingroup l1_controls
1549 def GetIdsFromFilter(self, theFilter):
1550 return theFilter.GetElementsId(self.mesh)
1552 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1553 # Returns a list of special structures (borders).
1554 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1555 # @ingroup l1_controls
1556 def GetFreeBorders(self):
1557 aFilterMgr = self.smeshpyD.CreateFilterManager()
1558 aPredicate = aFilterMgr.CreateFreeEdges()
1559 aPredicate.SetMesh(self.mesh)
1560 aBorders = aPredicate.GetBorders()
1564 # @ingroup l2_grps_delete
1565 def RemoveGroup(self, group):
1566 self.mesh.RemoveGroup(group)
1568 ## Removes a group with its contents
1569 # @ingroup l2_grps_delete
1570 def RemoveGroupWithContents(self, group):
1571 self.mesh.RemoveGroupWithContents(group)
1573 ## Gets the list of groups existing in the mesh
1574 # @return a sequence of SMESH_GroupBase
1575 # @ingroup l2_grps_create
1576 def GetGroups(self):
1577 return self.mesh.GetGroups()
1579 ## Gets the number of groups existing in the mesh
1580 # @return the quantity of groups as an integer value
1581 # @ingroup l2_grps_create
1583 return self.mesh.NbGroups()
1585 ## Gets the list of names of groups existing in the mesh
1586 # @return list of strings
1587 # @ingroup l2_grps_create
1588 def GetGroupNames(self):
1589 groups = self.GetGroups()
1591 for group in groups:
1592 names.append(group.GetName())
1595 ## Produces a union of two groups
1596 # A new group is created. All mesh elements that are
1597 # present in the initial groups are added to the new one
1598 # @return an instance of SMESH_Group
1599 # @ingroup l2_grps_operon
1600 def UnionGroups(self, group1, group2, name):
1601 return self.mesh.UnionGroups(group1, group2, name)
1603 ## Produces a union list of groups
1604 # New group is created. All mesh elements that are present in
1605 # initial groups are added to the new one
1606 # @return an instance of SMESH_Group
1607 # @ingroup l2_grps_operon
1608 def UnionListOfGroups(self, groups, name):
1609 return self.mesh.UnionListOfGroups(groups, name)
1611 ## Prodices an intersection of two groups
1612 # A new group is created. All mesh elements that are common
1613 # for the two initial groups are added to the new one.
1614 # @return an instance of SMESH_Group
1615 # @ingroup l2_grps_operon
1616 def IntersectGroups(self, group1, group2, name):
1617 return self.mesh.IntersectGroups(group1, group2, name)
1619 ## Produces an intersection of groups
1620 # New group is created. All mesh elements that are present in all
1621 # initial groups simultaneously are added to the new one
1622 # @return an instance of SMESH_Group
1623 # @ingroup l2_grps_operon
1624 def IntersectListOfGroups(self, groups, name):
1625 return self.mesh.IntersectListOfGroups(groups, name)
1627 ## Produces a cut of two groups
1628 # A new group is created. All mesh elements that are present in
1629 # the main group but are not present in the tool group are added to the new one
1630 # @return an instance of SMESH_Group
1631 # @ingroup l2_grps_operon
1632 def CutGroups(self, main_group, tool_group, name):
1633 return self.mesh.CutGroups(main_group, tool_group, name)
1635 ## Produces a cut of groups
1636 # A new group is created. All mesh elements that are present in main groups
1637 # but do not present in tool groups are added to the new one
1638 # @return an instance of SMESH_Group
1639 # @ingroup l2_grps_operon
1640 def CutListOfGroups(self, main_groups, tool_groups, name):
1641 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1643 ## Produces a group of elements with specified element type using list of existing groups
1644 # A new group is created. System
1645 # 1) extract all nodes on which groups elements are built
1646 # 2) combine all elements of specified dimension laying on these nodes
1647 # @return an instance of SMESH_Group
1648 # @ingroup l2_grps_operon
1649 def CreateDimGroup(self, groups, elem_type, name):
1650 return self.mesh.CreateDimGroup(groups, elem_type, name)
1653 ## Convert group on geom into standalone group
1654 # @ingroup l2_grps_delete
1655 def ConvertToStandalone(self, group):
1656 return self.mesh.ConvertToStandalone(group)
1658 # Get some info about mesh:
1659 # ------------------------
1661 ## Returns the log of nodes and elements added or removed
1662 # since the previous clear of the log.
1663 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1664 # @return list of log_block structures:
1669 # @ingroup l1_auxiliary
1670 def GetLog(self, clearAfterGet):
1671 return self.mesh.GetLog(clearAfterGet)
1673 ## Clears the log of nodes and elements added or removed since the previous
1674 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1675 # @ingroup l1_auxiliary
1677 self.mesh.ClearLog()
1679 ## Toggles auto color mode on the object.
1680 # @param theAutoColor the flag which toggles auto color mode.
1681 # @ingroup l1_auxiliary
1682 def SetAutoColor(self, theAutoColor):
1683 self.mesh.SetAutoColor(theAutoColor)
1685 ## Gets flag of object auto color mode.
1686 # @return True or False
1687 # @ingroup l1_auxiliary
1688 def GetAutoColor(self):
1689 return self.mesh.GetAutoColor()
1691 ## Gets the internal ID
1692 # @return integer value, which is the internal Id of the mesh
1693 # @ingroup l1_auxiliary
1695 return self.mesh.GetId()
1698 # @return integer value, which is the study Id of the mesh
1699 # @ingroup l1_auxiliary
1700 def GetStudyId(self):
1701 return self.mesh.GetStudyId()
1703 ## Checks the group names for duplications.
1704 # Consider the maximum group name length stored in MED file.
1705 # @return True or False
1706 # @ingroup l1_auxiliary
1707 def HasDuplicatedGroupNamesMED(self):
1708 return self.mesh.HasDuplicatedGroupNamesMED()
1710 ## Obtains the mesh editor tool
1711 # @return an instance of SMESH_MeshEditor
1712 # @ingroup l1_modifying
1713 def GetMeshEditor(self):
1714 return self.mesh.GetMeshEditor()
1717 # @return an instance of SALOME_MED::MESH
1718 # @ingroup l1_auxiliary
1719 def GetMEDMesh(self):
1720 return self.mesh.GetMEDMesh()
1723 # Get informations about mesh contents:
1724 # ------------------------------------
1726 ## Gets the mesh stattistic
1727 # @return dictionary type element - count of elements
1728 # @ingroup l1_meshinfo
1729 def GetMeshInfo(self, obj = None):
1730 if not obj: obj = self.mesh
1731 return self.smeshpyD.GetMeshInfo(obj)
1733 ## Returns the number of nodes in the mesh
1734 # @return an integer value
1735 # @ingroup l1_meshinfo
1737 return self.mesh.NbNodes()
1739 ## Returns the number of elements in the mesh
1740 # @return an integer value
1741 # @ingroup l1_meshinfo
1742 def NbElements(self):
1743 return self.mesh.NbElements()
1745 ## Returns the number of 0d elements in the mesh
1746 # @return an integer value
1747 # @ingroup l1_meshinfo
1748 def Nb0DElements(self):
1749 return self.mesh.Nb0DElements()
1751 ## Returns the number of edges in the mesh
1752 # @return an integer value
1753 # @ingroup l1_meshinfo
1755 return self.mesh.NbEdges()
1757 ## Returns the number of edges with the given order in the mesh
1758 # @param elementOrder the order of elements:
1759 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1760 # @return an integer value
1761 # @ingroup l1_meshinfo
1762 def NbEdgesOfOrder(self, elementOrder):
1763 return self.mesh.NbEdgesOfOrder(elementOrder)
1765 ## Returns the number of faces in the mesh
1766 # @return an integer value
1767 # @ingroup l1_meshinfo
1769 return self.mesh.NbFaces()
1771 ## Returns the number of faces with the given order in the mesh
1772 # @param elementOrder the order of elements:
1773 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1774 # @return an integer value
1775 # @ingroup l1_meshinfo
1776 def NbFacesOfOrder(self, elementOrder):
1777 return self.mesh.NbFacesOfOrder(elementOrder)
1779 ## Returns the number of triangles in the mesh
1780 # @return an integer value
1781 # @ingroup l1_meshinfo
1782 def NbTriangles(self):
1783 return self.mesh.NbTriangles()
1785 ## Returns the number of triangles with the given order in the mesh
1786 # @param elementOrder is the order of elements:
1787 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1788 # @return an integer value
1789 # @ingroup l1_meshinfo
1790 def NbTrianglesOfOrder(self, elementOrder):
1791 return self.mesh.NbTrianglesOfOrder(elementOrder)
1793 ## Returns the number of quadrangles in the mesh
1794 # @return an integer value
1795 # @ingroup l1_meshinfo
1796 def NbQuadrangles(self):
1797 return self.mesh.NbQuadrangles()
1799 ## Returns the number of quadrangles with the given order in the mesh
1800 # @param elementOrder the order of elements:
1801 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1802 # @return an integer value
1803 # @ingroup l1_meshinfo
1804 def NbQuadranglesOfOrder(self, elementOrder):
1805 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1807 ## Returns the number of polygons in the mesh
1808 # @return an integer value
1809 # @ingroup l1_meshinfo
1810 def NbPolygons(self):
1811 return self.mesh.NbPolygons()
1813 ## Returns the number of volumes in the mesh
1814 # @return an integer value
1815 # @ingroup l1_meshinfo
1816 def NbVolumes(self):
1817 return self.mesh.NbVolumes()
1819 ## Returns the number of volumes with the given order in the mesh
1820 # @param elementOrder the order of elements:
1821 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1824 def NbVolumesOfOrder(self, elementOrder):
1825 return self.mesh.NbVolumesOfOrder(elementOrder)
1827 ## Returns the number of tetrahedrons in the mesh
1828 # @return an integer value
1829 # @ingroup l1_meshinfo
1831 return self.mesh.NbTetras()
1833 ## Returns the number of tetrahedrons with the given order in the mesh
1834 # @param elementOrder the order of elements:
1835 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1836 # @return an integer value
1837 # @ingroup l1_meshinfo
1838 def NbTetrasOfOrder(self, elementOrder):
1839 return self.mesh.NbTetrasOfOrder(elementOrder)
1841 ## Returns the number of hexahedrons in the mesh
1842 # @return an integer value
1843 # @ingroup l1_meshinfo
1845 return self.mesh.NbHexas()
1847 ## Returns the number of hexahedrons with the given order in the mesh
1848 # @param elementOrder the order of elements:
1849 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def NbHexasOfOrder(self, elementOrder):
1853 return self.mesh.NbHexasOfOrder(elementOrder)
1855 ## Returns the number of pyramids in the mesh
1856 # @return an integer value
1857 # @ingroup l1_meshinfo
1858 def NbPyramids(self):
1859 return self.mesh.NbPyramids()
1861 ## Returns the number of pyramids with the given order in the mesh
1862 # @param elementOrder the order of elements:
1863 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1864 # @return an integer value
1865 # @ingroup l1_meshinfo
1866 def NbPyramidsOfOrder(self, elementOrder):
1867 return self.mesh.NbPyramidsOfOrder(elementOrder)
1869 ## Returns the number of prisms in the mesh
1870 # @return an integer value
1871 # @ingroup l1_meshinfo
1873 return self.mesh.NbPrisms()
1875 ## Returns the number of prisms with the given order in the mesh
1876 # @param elementOrder the order of elements:
1877 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1878 # @return an integer value
1879 # @ingroup l1_meshinfo
1880 def NbPrismsOfOrder(self, elementOrder):
1881 return self.mesh.NbPrismsOfOrder(elementOrder)
1883 ## Returns the number of polyhedrons in the mesh
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1886 def NbPolyhedrons(self):
1887 return self.mesh.NbPolyhedrons()
1889 ## Returns the number of submeshes in the mesh
1890 # @return an integer value
1891 # @ingroup l1_meshinfo
1892 def NbSubMesh(self):
1893 return self.mesh.NbSubMesh()
1895 ## Returns the list of mesh elements IDs
1896 # @return the list of integer values
1897 # @ingroup l1_meshinfo
1898 def GetElementsId(self):
1899 return self.mesh.GetElementsId()
1901 ## Returns the list of IDs of mesh elements with the given type
1902 # @param elementType the required type of elements
1903 # @return list of integer values
1904 # @ingroup l1_meshinfo
1905 def GetElementsByType(self, elementType):
1906 return self.mesh.GetElementsByType(elementType)
1908 ## Returns the list of mesh nodes IDs
1909 # @return the list of integer values
1910 # @ingroup l1_meshinfo
1911 def GetNodesId(self):
1912 return self.mesh.GetNodesId()
1914 # Get the information about mesh elements:
1915 # ------------------------------------
1917 ## Returns the type of mesh element
1918 # @return the value from SMESH::ElementType enumeration
1919 # @ingroup l1_meshinfo
1920 def GetElementType(self, id, iselem):
1921 return self.mesh.GetElementType(id, iselem)
1923 ## Returns the list of submesh elements IDs
1924 # @param Shape a geom object(subshape) IOR
1925 # Shape must be the subshape of a ShapeToMesh()
1926 # @return the list of integer values
1927 # @ingroup l1_meshinfo
1928 def GetSubMeshElementsId(self, Shape):
1929 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1930 ShapeID = Shape.GetSubShapeIndices()[0]
1933 return self.mesh.GetSubMeshElementsId(ShapeID)
1935 ## Returns the list of submesh nodes IDs
1936 # @param Shape a geom object(subshape) IOR
1937 # Shape must be the subshape of a ShapeToMesh()
1938 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1939 # @return the list of integer values
1940 # @ingroup l1_meshinfo
1941 def GetSubMeshNodesId(self, Shape, all):
1942 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1943 ShapeID = Shape.GetSubShapeIndices()[0]
1946 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1948 ## Returns type of elements on given shape
1949 # @param Shape a geom object(subshape) IOR
1950 # Shape must be a subshape of a ShapeToMesh()
1951 # @return element type
1952 # @ingroup l1_meshinfo
1953 def GetSubMeshElementType(self, Shape):
1954 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1955 ShapeID = Shape.GetSubShapeIndices()[0]
1958 return self.mesh.GetSubMeshElementType(ShapeID)
1960 ## Gets the mesh description
1961 # @return string value
1962 # @ingroup l1_meshinfo
1964 return self.mesh.Dump()
1967 # Get the information about nodes and elements of a mesh by its IDs:
1968 # -----------------------------------------------------------
1970 ## Gets XYZ coordinates of a node
1971 # \n If there is no nodes for the given ID - returns an empty list
1972 # @return a list of double precision values
1973 # @ingroup l1_meshinfo
1974 def GetNodeXYZ(self, id):
1975 return self.mesh.GetNodeXYZ(id)
1977 ## Returns list of IDs of inverse elements for the given node
1978 # \n If there is no node for the given ID - returns an empty list
1979 # @return a list of integer values
1980 # @ingroup l1_meshinfo
1981 def GetNodeInverseElements(self, id):
1982 return self.mesh.GetNodeInverseElements(id)
1984 ## @brief Returns the position of a node on the shape
1985 # @return SMESH::NodePosition
1986 # @ingroup l1_meshinfo
1987 def GetNodePosition(self,NodeID):
1988 return self.mesh.GetNodePosition(NodeID)
1990 ## If the given element is a node, returns the ID of shape
1991 # \n If there is no node for the given ID - returns -1
1992 # @return an integer value
1993 # @ingroup l1_meshinfo
1994 def GetShapeID(self, id):
1995 return self.mesh.GetShapeID(id)
1997 ## Returns the ID of the result shape after
1998 # FindShape() from SMESH_MeshEditor for the given element
1999 # \n If there is no element for the given ID - returns -1
2000 # @return an integer value
2001 # @ingroup l1_meshinfo
2002 def GetShapeIDForElem(self,id):
2003 return self.mesh.GetShapeIDForElem(id)
2005 ## Returns the number of nodes for the given element
2006 # \n If there is no element for the given ID - returns -1
2007 # @return an integer value
2008 # @ingroup l1_meshinfo
2009 def GetElemNbNodes(self, id):
2010 return self.mesh.GetElemNbNodes(id)
2012 ## Returns the node ID the given index for the given element
2013 # \n If there is no element for the given ID - returns -1
2014 # \n If there is no node for the given index - returns -2
2015 # @return an integer value
2016 # @ingroup l1_meshinfo
2017 def GetElemNode(self, id, index):
2018 return self.mesh.GetElemNode(id, index)
2020 ## Returns the IDs of nodes of the given element
2021 # @return a list of integer values
2022 # @ingroup l1_meshinfo
2023 def GetElemNodes(self, id):
2024 return self.mesh.GetElemNodes(id)
2026 ## Returns true if the given node is the medium node in the given quadratic element
2027 # @ingroup l1_meshinfo
2028 def IsMediumNode(self, elementID, nodeID):
2029 return self.mesh.IsMediumNode(elementID, nodeID)
2031 ## Returns true if the given node is the medium node in one of quadratic elements
2032 # @ingroup l1_meshinfo
2033 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2034 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2036 ## Returns the number of edges for the given element
2037 # @ingroup l1_meshinfo
2038 def ElemNbEdges(self, id):
2039 return self.mesh.ElemNbEdges(id)
2041 ## Returns the number of faces for the given element
2042 # @ingroup l1_meshinfo
2043 def ElemNbFaces(self, id):
2044 return self.mesh.ElemNbFaces(id)
2046 ## Returns true if the given element is a polygon
2047 # @ingroup l1_meshinfo
2048 def IsPoly(self, id):
2049 return self.mesh.IsPoly(id)
2051 ## Returns true if the given element is quadratic
2052 # @ingroup l1_meshinfo
2053 def IsQuadratic(self, id):
2054 return self.mesh.IsQuadratic(id)
2056 ## Returns XYZ coordinates of the barycenter of the given element
2057 # \n If there is no element for the given ID - returns an empty list
2058 # @return a list of three double values
2059 # @ingroup l1_meshinfo
2060 def BaryCenter(self, id):
2061 return self.mesh.BaryCenter(id)
2064 # Mesh edition (SMESH_MeshEditor functionality):
2065 # ---------------------------------------------
2067 ## Removes the elements from the mesh by ids
2068 # @param IDsOfElements is a list of ids of elements to remove
2069 # @return True or False
2070 # @ingroup l2_modif_del
2071 def RemoveElements(self, IDsOfElements):
2072 return self.editor.RemoveElements(IDsOfElements)
2074 ## Removes nodes from mesh by ids
2075 # @param IDsOfNodes is a list of ids of nodes to remove
2076 # @return True or False
2077 # @ingroup l2_modif_del
2078 def RemoveNodes(self, IDsOfNodes):
2079 return self.editor.RemoveNodes(IDsOfNodes)
2081 ## Add a node to the mesh by coordinates
2082 # @return Id of the new node
2083 # @ingroup l2_modif_add
2084 def AddNode(self, x, y, z):
2085 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2086 self.mesh.SetParameters(Parameters)
2087 return self.editor.AddNode( x, y, z)
2089 ## Creates a 0D element on a node with given number.
2090 # @param IDOfNode the ID of node for creation of the element.
2091 # @return the Id of the new 0D element
2092 # @ingroup l2_modif_add
2093 def Add0DElement(self, IDOfNode):
2094 return self.editor.Add0DElement(IDOfNode)
2096 ## Creates a linear or quadratic edge (this is determined
2097 # by the number of given nodes).
2098 # @param IDsOfNodes the list of node IDs for creation of the element.
2099 # The order of nodes in this list should correspond to the description
2100 # of MED. \n This description is located by the following link:
2101 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2102 # @return the Id of the new edge
2103 # @ingroup l2_modif_add
2104 def AddEdge(self, IDsOfNodes):
2105 return self.editor.AddEdge(IDsOfNodes)
2107 ## Creates a linear or quadratic face (this is determined
2108 # by the number of given nodes).
2109 # @param IDsOfNodes the list of node IDs for creation of the element.
2110 # The order of nodes in this list should correspond to the description
2111 # of MED. \n This description is located by the following link:
2112 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2113 # @return the Id of the new face
2114 # @ingroup l2_modif_add
2115 def AddFace(self, IDsOfNodes):
2116 return self.editor.AddFace(IDsOfNodes)
2118 ## Adds a polygonal face to the mesh by the list of node IDs
2119 # @param IdsOfNodes the list of node IDs for creation of the element.
2120 # @return the Id of the new face
2121 # @ingroup l2_modif_add
2122 def AddPolygonalFace(self, IdsOfNodes):
2123 return self.editor.AddPolygonalFace(IdsOfNodes)
2125 ## Creates both simple and quadratic volume (this is determined
2126 # by the number of given nodes).
2127 # @param IDsOfNodes the list of node IDs for creation of the element.
2128 # The order of nodes in this list should correspond to the description
2129 # of MED. \n This description is located by the following link:
2130 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2131 # @return the Id of the new volumic element
2132 # @ingroup l2_modif_add
2133 def AddVolume(self, IDsOfNodes):
2134 return self.editor.AddVolume(IDsOfNodes)
2136 ## Creates a volume of many faces, giving nodes for each face.
2137 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2138 # @param Quantities the list of integer values, Quantities[i]
2139 # gives the quantity of nodes in face number i.
2140 # @return the Id of the new volumic element
2141 # @ingroup l2_modif_add
2142 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2143 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2145 ## Creates a volume of many faces, giving the IDs of the existing faces.
2146 # @param IdsOfFaces the list of face IDs for volume creation.
2148 # Note: The created volume will refer only to the nodes
2149 # of the given faces, not to the faces themselves.
2150 # @return the Id of the new volumic element
2151 # @ingroup l2_modif_add
2152 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2153 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2156 ## @brief Binds a node to a vertex
2157 # @param NodeID a node ID
2158 # @param Vertex a vertex or vertex ID
2159 # @return True if succeed else raises an exception
2160 # @ingroup l2_modif_add
2161 def SetNodeOnVertex(self, NodeID, Vertex):
2162 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2163 VertexID = Vertex.GetSubShapeIndices()[0]
2167 self.editor.SetNodeOnVertex(NodeID, VertexID)
2168 except SALOME.SALOME_Exception, inst:
2169 raise ValueError, inst.details.text
2173 ## @brief Stores the node position on an edge
2174 # @param NodeID a node ID
2175 # @param Edge an edge or edge ID
2176 # @param paramOnEdge a parameter on the edge where the node is located
2177 # @return True if succeed else raises an exception
2178 # @ingroup l2_modif_add
2179 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2180 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2181 EdgeID = Edge.GetSubShapeIndices()[0]
2185 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2186 except SALOME.SALOME_Exception, inst:
2187 raise ValueError, inst.details.text
2190 ## @brief Stores node position on a face
2191 # @param NodeID a node ID
2192 # @param Face a face or face ID
2193 # @param u U parameter on the face where the node is located
2194 # @param v V parameter on the face where the node is located
2195 # @return True if succeed else raises an exception
2196 # @ingroup l2_modif_add
2197 def SetNodeOnFace(self, NodeID, Face, u, v):
2198 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2199 FaceID = Face.GetSubShapeIndices()[0]
2203 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2204 except SALOME.SALOME_Exception, inst:
2205 raise ValueError, inst.details.text
2208 ## @brief Binds a node to a solid
2209 # @param NodeID a node ID
2210 # @param Solid a solid or solid ID
2211 # @return True if succeed else raises an exception
2212 # @ingroup l2_modif_add
2213 def SetNodeInVolume(self, NodeID, Solid):
2214 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2215 SolidID = Solid.GetSubShapeIndices()[0]
2219 self.editor.SetNodeInVolume(NodeID, SolidID)
2220 except SALOME.SALOME_Exception, inst:
2221 raise ValueError, inst.details.text
2224 ## @brief Bind an element to a shape
2225 # @param ElementID an element ID
2226 # @param Shape a shape or shape ID
2227 # @return True if succeed else raises an exception
2228 # @ingroup l2_modif_add
2229 def SetMeshElementOnShape(self, ElementID, Shape):
2230 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2231 ShapeID = Shape.GetSubShapeIndices()[0]
2235 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2236 except SALOME.SALOME_Exception, inst:
2237 raise ValueError, inst.details.text
2241 ## Moves the node with the given id
2242 # @param NodeID the id of the node
2243 # @param x a new X coordinate
2244 # @param y a new Y coordinate
2245 # @param z a new Z coordinate
2246 # @return True if succeed else False
2247 # @ingroup l2_modif_movenode
2248 def MoveNode(self, NodeID, x, y, z):
2249 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2250 self.mesh.SetParameters(Parameters)
2251 return self.editor.MoveNode(NodeID, x, y, z)
2253 ## Finds the node closest to a point and moves it to a point location
2254 # @param x the X coordinate of a point
2255 # @param y the Y coordinate of a point
2256 # @param z the Z coordinate of a point
2257 # @param NodeID if specified (>0), the node with this ID is moved,
2258 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2259 # @return the ID of a node
2260 # @ingroup l2_modif_throughp
2261 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2262 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2263 self.mesh.SetParameters(Parameters)
2264 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2266 ## Finds the node closest to a point
2267 # @param x the X coordinate of a point
2268 # @param y the Y coordinate of a point
2269 # @param z the Z coordinate of a point
2270 # @return the ID of a node
2271 # @ingroup l2_modif_throughp
2272 def FindNodeClosestTo(self, x, y, z):
2273 #preview = self.mesh.GetMeshEditPreviewer()
2274 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2275 return self.editor.FindNodeClosestTo(x, y, z)
2277 ## Finds the elements where a point lays IN or ON
2278 # @param x the X coordinate of a point
2279 # @param y the Y coordinate of a point
2280 # @param z the Z coordinate of a point
2281 # @param elementType type of elements to find (SMESH.ALL type
2282 # means elements of any type excluding nodes and 0D elements)
2283 # @return list of IDs of found elements
2284 # @ingroup l2_modif_throughp
2285 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2286 return self.editor.FindElementsByPoint(x, y, z, elementType)
2289 ## Finds the node closest to a point and moves it to a point location
2290 # @param x the X coordinate of a point
2291 # @param y the Y coordinate of a point
2292 # @param z the Z coordinate of a point
2293 # @return the ID of a moved node
2294 # @ingroup l2_modif_throughp
2295 def MeshToPassThroughAPoint(self, x, y, z):
2296 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2298 ## Replaces two neighbour triangles sharing Node1-Node2 link
2299 # with the triangles built on the same 4 nodes but having other common link.
2300 # @param NodeID1 the ID of the first node
2301 # @param NodeID2 the ID of the second node
2302 # @return false if proper faces were not found
2303 # @ingroup l2_modif_invdiag
2304 def InverseDiag(self, NodeID1, NodeID2):
2305 return self.editor.InverseDiag(NodeID1, NodeID2)
2307 ## Replaces two neighbour triangles sharing Node1-Node2 link
2308 # with a quadrangle built on the same 4 nodes.
2309 # @param NodeID1 the ID of the first node
2310 # @param NodeID2 the ID of the second node
2311 # @return false if proper faces were not found
2312 # @ingroup l2_modif_unitetri
2313 def DeleteDiag(self, NodeID1, NodeID2):
2314 return self.editor.DeleteDiag(NodeID1, NodeID2)
2316 ## Reorients elements by ids
2317 # @param IDsOfElements if undefined reorients all mesh elements
2318 # @return True if succeed else False
2319 # @ingroup l2_modif_changori
2320 def Reorient(self, IDsOfElements=None):
2321 if IDsOfElements == None:
2322 IDsOfElements = self.GetElementsId()
2323 return self.editor.Reorient(IDsOfElements)
2325 ## Reorients all elements of the object
2326 # @param theObject mesh, submesh or group
2327 # @return True if succeed else False
2328 # @ingroup l2_modif_changori
2329 def ReorientObject(self, theObject):
2330 if ( isinstance( theObject, Mesh )):
2331 theObject = theObject.GetMesh()
2332 return self.editor.ReorientObject(theObject)
2334 ## Fuses the neighbouring triangles into quadrangles.
2335 # @param IDsOfElements The triangles to be fused,
2336 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2337 # @param MaxAngle is the maximum angle between element normals at which the fusion
2338 # is still performed; theMaxAngle is mesured in radians.
2339 # Also it could be a name of variable which defines angle in degrees.
2340 # @return TRUE in case of success, FALSE otherwise.
2341 # @ingroup l2_modif_unitetri
2342 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2344 if isinstance(MaxAngle,str):
2346 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2348 MaxAngle = DegreesToRadians(MaxAngle)
2349 if IDsOfElements == []:
2350 IDsOfElements = self.GetElementsId()
2351 self.mesh.SetParameters(Parameters)
2353 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2354 Functor = theCriterion
2356 Functor = self.smeshpyD.GetFunctor(theCriterion)
2357 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2359 ## Fuses the neighbouring triangles of the object into quadrangles
2360 # @param theObject is mesh, submesh or group
2361 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2362 # @param MaxAngle a max angle between element normals at which the fusion
2363 # is still performed; theMaxAngle is mesured in radians.
2364 # @return TRUE in case of success, FALSE otherwise.
2365 # @ingroup l2_modif_unitetri
2366 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2367 if ( isinstance( theObject, Mesh )):
2368 theObject = theObject.GetMesh()
2369 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2371 ## Splits quadrangles into triangles.
2372 # @param IDsOfElements the faces to be splitted.
2373 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2374 # @return TRUE in case of success, FALSE otherwise.
2375 # @ingroup l2_modif_cutquadr
2376 def QuadToTri (self, IDsOfElements, theCriterion):
2377 if IDsOfElements == []:
2378 IDsOfElements = self.GetElementsId()
2379 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2381 ## Splits quadrangles into triangles.
2382 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2383 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2384 # @return TRUE in case of success, FALSE otherwise.
2385 # @ingroup l2_modif_cutquadr
2386 def QuadToTriObject (self, theObject, theCriterion):
2387 if ( isinstance( theObject, Mesh )):
2388 theObject = theObject.GetMesh()
2389 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2391 ## Splits quadrangles into triangles.
2392 # @param IDsOfElements the faces to be splitted
2393 # @param Diag13 is used to choose a diagonal for splitting.
2394 # @return TRUE in case of success, FALSE otherwise.
2395 # @ingroup l2_modif_cutquadr
2396 def SplitQuad (self, IDsOfElements, Diag13):
2397 if IDsOfElements == []:
2398 IDsOfElements = self.GetElementsId()
2399 return self.editor.SplitQuad(IDsOfElements, Diag13)
2401 ## Splits quadrangles into triangles.
2402 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2403 # @param Diag13 is used to choose a diagonal for splitting.
2404 # @return TRUE in case of success, FALSE otherwise.
2405 # @ingroup l2_modif_cutquadr
2406 def SplitQuadObject (self, theObject, Diag13):
2407 if ( isinstance( theObject, Mesh )):
2408 theObject = theObject.GetMesh()
2409 return self.editor.SplitQuadObject(theObject, Diag13)
2411 ## Finds a better splitting of the given quadrangle.
2412 # @param IDOfQuad the ID of the quadrangle to be splitted.
2413 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2414 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2415 # diagonal is better, 0 if error occurs.
2416 # @ingroup l2_modif_cutquadr
2417 def BestSplit (self, IDOfQuad, theCriterion):
2418 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2420 ## Splits quadrangle faces near triangular facets of volumes
2422 # @ingroup l1_auxiliary
2423 def SplitQuadsNearTriangularFacets(self):
2424 faces_array = self.GetElementsByType(SMESH.FACE)
2425 for face_id in faces_array:
2426 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2427 quad_nodes = self.mesh.GetElemNodes(face_id)
2428 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2429 isVolumeFound = False
2430 for node1_elem in node1_elems:
2431 if not isVolumeFound:
2432 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2433 nb_nodes = self.GetElemNbNodes(node1_elem)
2434 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2435 volume_elem = node1_elem
2436 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2437 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2438 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2439 isVolumeFound = True
2440 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2441 self.SplitQuad([face_id], False) # diagonal 2-4
2442 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2443 isVolumeFound = True
2444 self.SplitQuad([face_id], True) # diagonal 1-3
2445 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2446 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2447 isVolumeFound = True
2448 self.SplitQuad([face_id], True) # diagonal 1-3
2450 ## @brief Splits hexahedrons into tetrahedrons.
2452 # This operation uses pattern mapping functionality for splitting.
2453 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2454 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2455 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2456 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2457 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2458 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2459 # @return TRUE in case of success, FALSE otherwise.
2460 # @ingroup l1_auxiliary
2461 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2462 # Pattern: 5.---------.6
2467 # (0,0,1) 4.---------.7 * |
2474 # (0,0,0) 0.---------.3
2475 pattern_tetra = "!!! Nb of points: \n 8 \n\
2485 !!! Indices of points of 6 tetras: \n\
2493 pattern = self.smeshpyD.GetPattern()
2494 isDone = pattern.LoadFromFile(pattern_tetra)
2496 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2499 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2500 isDone = pattern.MakeMesh(self.mesh, False, False)
2501 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2503 # split quafrangle faces near triangular facets of volumes
2504 self.SplitQuadsNearTriangularFacets()
2508 ## @brief Split hexahedrons into prisms.
2510 # Uses the pattern mapping functionality for splitting.
2511 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2512 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2513 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2514 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2515 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2516 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2517 # @return TRUE in case of success, FALSE otherwise.
2518 # @ingroup l1_auxiliary
2519 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2520 # Pattern: 5.---------.6
2525 # (0,0,1) 4.---------.7 |
2532 # (0,0,0) 0.---------.3
2533 pattern_prism = "!!! Nb of points: \n 8 \n\
2543 !!! Indices of points of 2 prisms: \n\
2547 pattern = self.smeshpyD.GetPattern()
2548 isDone = pattern.LoadFromFile(pattern_prism)
2550 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2553 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2554 isDone = pattern.MakeMesh(self.mesh, False, False)
2555 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2557 # Splits quafrangle faces near triangular facets of volumes
2558 self.SplitQuadsNearTriangularFacets()
2562 ## Smoothes elements
2563 # @param IDsOfElements the list if ids of elements to smooth
2564 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2565 # Note that nodes built on edges and boundary nodes are always fixed.
2566 # @param MaxNbOfIterations the maximum number of iterations
2567 # @param MaxAspectRatio varies in range [1.0, inf]
2568 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2569 # @return TRUE in case of success, FALSE otherwise.
2570 # @ingroup l2_modif_smooth
2571 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2572 MaxNbOfIterations, MaxAspectRatio, Method):
2573 if IDsOfElements == []:
2574 IDsOfElements = self.GetElementsId()
2575 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2576 self.mesh.SetParameters(Parameters)
2577 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2578 MaxNbOfIterations, MaxAspectRatio, Method)
2580 ## Smoothes elements which belong to the given object
2581 # @param theObject the object to smooth
2582 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2583 # Note that nodes built on edges and boundary nodes are always fixed.
2584 # @param MaxNbOfIterations the maximum number of iterations
2585 # @param MaxAspectRatio varies in range [1.0, inf]
2586 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2587 # @return TRUE in case of success, FALSE otherwise.
2588 # @ingroup l2_modif_smooth
2589 def SmoothObject(self, theObject, IDsOfFixedNodes,
2590 MaxNbOfIterations, MaxAspectRatio, Method):
2591 if ( isinstance( theObject, Mesh )):
2592 theObject = theObject.GetMesh()
2593 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2594 MaxNbOfIterations, MaxAspectRatio, Method)
2596 ## Parametrically smoothes the given elements
2597 # @param IDsOfElements the list if ids of elements to smooth
2598 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2599 # Note that nodes built on edges and boundary nodes are always fixed.
2600 # @param MaxNbOfIterations the maximum number of iterations
2601 # @param MaxAspectRatio varies in range [1.0, inf]
2602 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2603 # @return TRUE in case of success, FALSE otherwise.
2604 # @ingroup l2_modif_smooth
2605 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2606 MaxNbOfIterations, MaxAspectRatio, Method):
2607 if IDsOfElements == []:
2608 IDsOfElements = self.GetElementsId()
2609 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2610 self.mesh.SetParameters(Parameters)
2611 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2612 MaxNbOfIterations, MaxAspectRatio, Method)
2614 ## Parametrically smoothes the elements which belong to the given object
2615 # @param theObject the object to smooth
2616 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2617 # Note that nodes built on edges and boundary nodes are always fixed.
2618 # @param MaxNbOfIterations the maximum number of iterations
2619 # @param MaxAspectRatio varies in range [1.0, inf]
2620 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2621 # @return TRUE in case of success, FALSE otherwise.
2622 # @ingroup l2_modif_smooth
2623 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2624 MaxNbOfIterations, MaxAspectRatio, Method):
2625 if ( isinstance( theObject, Mesh )):
2626 theObject = theObject.GetMesh()
2627 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2628 MaxNbOfIterations, MaxAspectRatio, Method)
2630 ## Converts the mesh to quadratic, deletes old elements, replacing
2631 # them with quadratic with the same id.
2632 # @ingroup l2_modif_tofromqu
2633 def ConvertToQuadratic(self, theForce3d):
2634 self.editor.ConvertToQuadratic(theForce3d)
2636 ## Converts the mesh from quadratic to ordinary,
2637 # deletes old quadratic elements, \n replacing
2638 # them with ordinary mesh elements with the same id.
2639 # @return TRUE in case of success, FALSE otherwise.
2640 # @ingroup l2_modif_tofromqu
2641 def ConvertFromQuadratic(self):
2642 return self.editor.ConvertFromQuadratic()
2644 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2645 # @return TRUE if operation has been completed successfully, FALSE otherwise
2646 # @ingroup l2_modif_edit
2647 def Make2DMeshFrom3D(self):
2648 return self.editor. Make2DMeshFrom3D()
2650 ## Renumber mesh nodes
2651 # @ingroup l2_modif_renumber
2652 def RenumberNodes(self):
2653 self.editor.RenumberNodes()
2655 ## Renumber mesh elements
2656 # @ingroup l2_modif_renumber
2657 def RenumberElements(self):
2658 self.editor.RenumberElements()
2660 ## Generates new elements by rotation of the elements around the axis
2661 # @param IDsOfElements the list of ids of elements to sweep
2662 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2663 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2664 # @param NbOfSteps the number of steps
2665 # @param Tolerance tolerance
2666 # @param MakeGroups forces the generation of new groups from existing ones
2667 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2668 # of all steps, else - size of each step
2669 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2670 # @ingroup l2_modif_extrurev
2671 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2672 MakeGroups=False, TotalAngle=False):
2674 if isinstance(AngleInRadians,str):
2676 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2678 AngleInRadians = DegreesToRadians(AngleInRadians)
2679 if IDsOfElements == []:
2680 IDsOfElements = self.GetElementsId()
2681 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2682 Axis = self.smeshpyD.GetAxisStruct(Axis)
2683 Axis,AxisParameters = ParseAxisStruct(Axis)
2684 if TotalAngle and NbOfSteps:
2685 AngleInRadians /= NbOfSteps
2686 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2687 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2688 self.mesh.SetParameters(Parameters)
2690 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2691 AngleInRadians, NbOfSteps, Tolerance)
2692 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2695 ## Generates new elements by rotation of the elements of object around the axis
2696 # @param theObject object which elements should be sweeped
2697 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2698 # @param AngleInRadians the angle of Rotation
2699 # @param NbOfSteps number of steps
2700 # @param Tolerance tolerance
2701 # @param MakeGroups forces the generation of new groups from existing ones
2702 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2703 # of all steps, else - size of each step
2704 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2705 # @ingroup l2_modif_extrurev
2706 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2707 MakeGroups=False, TotalAngle=False):
2709 if isinstance(AngleInRadians,str):
2711 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2713 AngleInRadians = DegreesToRadians(AngleInRadians)
2714 if ( isinstance( theObject, Mesh )):
2715 theObject = theObject.GetMesh()
2716 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2717 Axis = self.smeshpyD.GetAxisStruct(Axis)
2718 Axis,AxisParameters = ParseAxisStruct(Axis)
2719 if TotalAngle and NbOfSteps:
2720 AngleInRadians /= NbOfSteps
2721 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2722 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2723 self.mesh.SetParameters(Parameters)
2725 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2726 NbOfSteps, Tolerance)
2727 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2730 ## Generates new elements by rotation of the elements of object around the axis
2731 # @param theObject object which elements should be sweeped
2732 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2733 # @param AngleInRadians the angle of Rotation
2734 # @param NbOfSteps number of steps
2735 # @param Tolerance tolerance
2736 # @param MakeGroups forces the generation of new groups from existing ones
2737 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2738 # of all steps, else - size of each step
2739 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2740 # @ingroup l2_modif_extrurev
2741 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2742 MakeGroups=False, TotalAngle=False):
2744 if isinstance(AngleInRadians,str):
2746 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2748 AngleInRadians = DegreesToRadians(AngleInRadians)
2749 if ( isinstance( theObject, Mesh )):
2750 theObject = theObject.GetMesh()
2751 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2752 Axis = self.smeshpyD.GetAxisStruct(Axis)
2753 Axis,AxisParameters = ParseAxisStruct(Axis)
2754 if TotalAngle and NbOfSteps:
2755 AngleInRadians /= NbOfSteps
2756 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2757 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2758 self.mesh.SetParameters(Parameters)
2760 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2761 NbOfSteps, Tolerance)
2762 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2765 ## Generates new elements by rotation of the elements of object around the axis
2766 # @param theObject object which elements should be sweeped
2767 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2768 # @param AngleInRadians the angle of Rotation
2769 # @param NbOfSteps number of steps
2770 # @param Tolerance tolerance
2771 # @param MakeGroups forces the generation of new groups from existing ones
2772 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2773 # of all steps, else - size of each step
2774 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2775 # @ingroup l2_modif_extrurev
2776 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2777 MakeGroups=False, TotalAngle=False):
2779 if isinstance(AngleInRadians,str):
2781 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2783 AngleInRadians = DegreesToRadians(AngleInRadians)
2784 if ( isinstance( theObject, Mesh )):
2785 theObject = theObject.GetMesh()
2786 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2787 Axis = self.smeshpyD.GetAxisStruct(Axis)
2788 Axis,AxisParameters = ParseAxisStruct(Axis)
2789 if TotalAngle and NbOfSteps:
2790 AngleInRadians /= NbOfSteps
2791 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2792 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2793 self.mesh.SetParameters(Parameters)
2795 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2796 NbOfSteps, Tolerance)
2797 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2800 ## Generates new elements by extrusion of the elements with given ids
2801 # @param IDsOfElements the list of elements ids for extrusion
2802 # @param StepVector vector, defining the direction and value of extrusion
2803 # @param NbOfSteps the number of steps
2804 # @param MakeGroups forces the generation of new groups from existing ones
2805 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2806 # @ingroup l2_modif_extrurev
2807 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2808 if IDsOfElements == []:
2809 IDsOfElements = self.GetElementsId()
2810 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2811 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2812 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2813 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2814 Parameters = StepVectorParameters + var_separator + Parameters
2815 self.mesh.SetParameters(Parameters)
2817 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2818 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2821 ## Generates new elements by extrusion of the elements with given ids
2822 # @param IDsOfElements is ids of elements
2823 # @param StepVector vector, defining the direction and value of extrusion
2824 # @param NbOfSteps the number of steps
2825 # @param ExtrFlags sets flags for extrusion
2826 # @param SewTolerance uses for comparing locations of nodes if flag
2827 # EXTRUSION_FLAG_SEW is set
2828 # @param MakeGroups forces the generation of new groups from existing ones
2829 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2830 # @ingroup l2_modif_extrurev
2831 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2832 ExtrFlags, SewTolerance, MakeGroups=False):
2833 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2834 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2836 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2837 ExtrFlags, SewTolerance)
2838 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2839 ExtrFlags, SewTolerance)
2842 ## Generates new elements by extrusion of the elements which belong to the object
2843 # @param theObject the object which elements should be processed
2844 # @param StepVector vector, defining the direction and value of extrusion
2845 # @param NbOfSteps the number of steps
2846 # @param MakeGroups forces the generation of new groups from existing ones
2847 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2848 # @ingroup l2_modif_extrurev
2849 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2850 if ( isinstance( theObject, Mesh )):
2851 theObject = theObject.GetMesh()
2852 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2853 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2854 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2855 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2856 Parameters = StepVectorParameters + var_separator + Parameters
2857 self.mesh.SetParameters(Parameters)
2859 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2860 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2863 ## Generates new elements by extrusion of the elements which belong to the object
2864 # @param theObject object which elements should be processed
2865 # @param StepVector vector, defining the direction and value of extrusion
2866 # @param NbOfSteps the number of steps
2867 # @param MakeGroups to generate new groups from existing ones
2868 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2869 # @ingroup l2_modif_extrurev
2870 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2871 if ( isinstance( theObject, Mesh )):
2872 theObject = theObject.GetMesh()
2873 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2874 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2875 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2876 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2877 Parameters = StepVectorParameters + var_separator + Parameters
2878 self.mesh.SetParameters(Parameters)
2880 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2881 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2884 ## Generates new elements by extrusion of the elements which belong to the object
2885 # @param theObject object which elements should be processed
2886 # @param StepVector vector, defining the direction and value of extrusion
2887 # @param NbOfSteps the number of steps
2888 # @param MakeGroups forces the generation of new groups from existing ones
2889 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2890 # @ingroup l2_modif_extrurev
2891 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2892 if ( isinstance( theObject, Mesh )):
2893 theObject = theObject.GetMesh()
2894 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2895 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2896 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2897 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2898 Parameters = StepVectorParameters + var_separator + Parameters
2899 self.mesh.SetParameters(Parameters)
2901 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2902 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2907 ## Generates new elements by extrusion of the given elements
2908 # The path of extrusion must be a meshed edge.
2909 # @param Base mesh or list of ids of elements for extrusion
2910 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2911 # @param NodeStart the start node from Path. Defines the direction of extrusion
2912 # @param HasAngles allows the shape to be rotated around the path
2913 # to get the resulting mesh in a helical fashion
2914 # @param Angles list of angles in radians
2915 # @param LinearVariation forces the computation of rotation angles as linear
2916 # variation of the given Angles along path steps
2917 # @param HasRefPoint allows using the reference point
2918 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2919 # The User can specify any point as the Reference Point.
2920 # @param MakeGroups forces the generation of new groups from existing ones
2921 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2922 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2923 # only SMESH::Extrusion_Error otherwise
2924 # @ingroup l2_modif_extrurev
2925 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2926 HasAngles, Angles, LinearVariation,
2927 HasRefPoint, RefPoint, MakeGroups, ElemType):
2928 Angles,AnglesParameters = ParseAngles(Angles)
2929 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2930 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2931 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2933 Parameters = AnglesParameters + var_separator + RefPointParameters
2934 self.mesh.SetParameters(Parameters)
2936 if isinstance(Base,list):
2938 if Base == []: IDsOfElements = self.GetElementsId()
2939 else: IDsOfElements = Base
2940 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2941 HasAngles, Angles, LinearVariation,
2942 HasRefPoint, RefPoint, MakeGroups, ElemType)
2944 if isinstance(Base,Mesh):
2945 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2946 HasAngles, Angles, LinearVariation,
2947 HasRefPoint, RefPoint, MakeGroups, ElemType)
2949 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2952 ## Generates new elements by extrusion of the given elements
2953 # The path of extrusion must be a meshed edge.
2954 # @param IDsOfElements ids of elements
2955 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2956 # @param PathShape shape(edge) defines the sub-mesh for the path
2957 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2958 # @param HasAngles allows the shape to be rotated around the path
2959 # to get the resulting mesh in a helical fashion
2960 # @param Angles list of angles in radians
2961 # @param HasRefPoint allows using the reference point
2962 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2963 # The User can specify any point as the Reference Point.
2964 # @param MakeGroups forces the generation of new groups from existing ones
2965 # @param LinearVariation forces the computation of rotation angles as linear
2966 # variation of the given Angles along path steps
2967 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2968 # only SMESH::Extrusion_Error otherwise
2969 # @ingroup l2_modif_extrurev
2970 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2971 HasAngles, Angles, HasRefPoint, RefPoint,
2972 MakeGroups=False, LinearVariation=False):
2973 Angles,AnglesParameters = ParseAngles(Angles)
2974 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2975 if IDsOfElements == []:
2976 IDsOfElements = self.GetElementsId()
2977 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2978 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2980 if ( isinstance( PathMesh, Mesh )):
2981 PathMesh = PathMesh.GetMesh()
2982 if HasAngles and Angles and LinearVariation:
2983 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2985 Parameters = AnglesParameters + var_separator + RefPointParameters
2986 self.mesh.SetParameters(Parameters)
2988 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2989 PathShape, NodeStart, HasAngles,
2990 Angles, HasRefPoint, RefPoint)
2991 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2992 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2994 ## Generates new elements by extrusion of the elements which belong to the object
2995 # The path of extrusion must be a meshed edge.
2996 # @param theObject the object which elements should be processed
2997 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2998 # @param PathShape shape(edge) defines the sub-mesh for the path
2999 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3000 # @param HasAngles allows the shape to be rotated around the path
3001 # to get the resulting mesh in a helical fashion
3002 # @param Angles list of angles
3003 # @param HasRefPoint allows using the reference point
3004 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3005 # The User can specify any point as the Reference Point.
3006 # @param MakeGroups forces the generation of new groups from existing ones
3007 # @param LinearVariation forces the computation of rotation angles as linear
3008 # variation of the given Angles along path steps
3009 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3010 # only SMESH::Extrusion_Error otherwise
3011 # @ingroup l2_modif_extrurev
3012 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3013 HasAngles, Angles, HasRefPoint, RefPoint,
3014 MakeGroups=False, LinearVariation=False):
3015 Angles,AnglesParameters = ParseAngles(Angles)
3016 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3017 if ( isinstance( theObject, Mesh )):
3018 theObject = theObject.GetMesh()
3019 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3020 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3021 if ( isinstance( PathMesh, Mesh )):
3022 PathMesh = PathMesh.GetMesh()
3023 if HasAngles and Angles and LinearVariation:
3024 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3026 Parameters = AnglesParameters + var_separator + RefPointParameters
3027 self.mesh.SetParameters(Parameters)
3029 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3030 PathShape, NodeStart, HasAngles,
3031 Angles, HasRefPoint, RefPoint)
3032 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3033 NodeStart, HasAngles, Angles, HasRefPoint,
3036 ## Generates new elements by extrusion of the elements which belong to the object
3037 # The path of extrusion must be a meshed edge.
3038 # @param theObject the object which elements should be processed
3039 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3040 # @param PathShape shape(edge) defines the sub-mesh for the path
3041 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3042 # @param HasAngles allows the shape to be rotated around the path
3043 # to get the resulting mesh in a helical fashion
3044 # @param Angles list of angles
3045 # @param HasRefPoint allows using the reference point
3046 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3047 # The User can specify any point as the Reference Point.
3048 # @param MakeGroups forces the generation of new groups from existing ones
3049 # @param LinearVariation forces the computation of rotation angles as linear
3050 # variation of the given Angles along path steps
3051 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3052 # only SMESH::Extrusion_Error otherwise
3053 # @ingroup l2_modif_extrurev
3054 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3055 HasAngles, Angles, HasRefPoint, RefPoint,
3056 MakeGroups=False, LinearVariation=False):
3057 Angles,AnglesParameters = ParseAngles(Angles)
3058 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3059 if ( isinstance( theObject, Mesh )):
3060 theObject = theObject.GetMesh()
3061 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3062 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3063 if ( isinstance( PathMesh, Mesh )):
3064 PathMesh = PathMesh.GetMesh()
3065 if HasAngles and Angles and LinearVariation:
3066 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3068 Parameters = AnglesParameters + var_separator + RefPointParameters
3069 self.mesh.SetParameters(Parameters)
3071 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3072 PathShape, NodeStart, HasAngles,
3073 Angles, HasRefPoint, RefPoint)
3074 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3075 NodeStart, HasAngles, Angles, HasRefPoint,
3078 ## Generates new elements by extrusion of the elements which belong to the object
3079 # The path of extrusion must be a meshed edge.
3080 # @param theObject the object which elements should be processed
3081 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3082 # @param PathShape shape(edge) defines the sub-mesh for the path
3083 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3084 # @param HasAngles allows the shape to be rotated around the path
3085 # to get the resulting mesh in a helical fashion
3086 # @param Angles list of angles
3087 # @param HasRefPoint allows using the reference point
3088 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3089 # The User can specify any point as the Reference Point.
3090 # @param MakeGroups forces the generation of new groups from existing ones
3091 # @param LinearVariation forces the computation of rotation angles as linear
3092 # variation of the given Angles along path steps
3093 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3094 # only SMESH::Extrusion_Error otherwise
3095 # @ingroup l2_modif_extrurev
3096 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3097 HasAngles, Angles, HasRefPoint, RefPoint,
3098 MakeGroups=False, LinearVariation=False):
3099 Angles,AnglesParameters = ParseAngles(Angles)
3100 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3101 if ( isinstance( theObject, Mesh )):
3102 theObject = theObject.GetMesh()
3103 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3104 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3105 if ( isinstance( PathMesh, Mesh )):
3106 PathMesh = PathMesh.GetMesh()
3107 if HasAngles and Angles and LinearVariation:
3108 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3110 Parameters = AnglesParameters + var_separator + RefPointParameters
3111 self.mesh.SetParameters(Parameters)
3113 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3114 PathShape, NodeStart, HasAngles,
3115 Angles, HasRefPoint, RefPoint)
3116 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3117 NodeStart, HasAngles, Angles, HasRefPoint,
3120 ## Creates a symmetrical copy of mesh elements
3121 # @param IDsOfElements list of elements ids
3122 # @param Mirror is AxisStruct or geom object(point, line, plane)
3123 # @param theMirrorType is POINT, AXIS or PLANE
3124 # If the Mirror is a geom object this parameter is unnecessary
3125 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3126 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3127 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3128 # @ingroup l2_modif_trsf
3129 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3130 if IDsOfElements == []:
3131 IDsOfElements = self.GetElementsId()
3132 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3133 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3134 Mirror,Parameters = ParseAxisStruct(Mirror)
3135 self.mesh.SetParameters(Parameters)
3136 if Copy and MakeGroups:
3137 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3138 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3141 ## Creates a new mesh by a symmetrical copy of mesh elements
3142 # @param IDsOfElements the list of elements ids
3143 # @param Mirror is AxisStruct or geom object (point, line, plane)
3144 # @param theMirrorType is POINT, AXIS or PLANE
3145 # If the Mirror is a geom object this parameter is unnecessary
3146 # @param MakeGroups to generate new groups from existing ones
3147 # @param NewMeshName a name of the new mesh to create
3148 # @return instance of Mesh class
3149 # @ingroup l2_modif_trsf
3150 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3151 if IDsOfElements == []:
3152 IDsOfElements = self.GetElementsId()
3153 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3154 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3155 Mirror,Parameters = ParseAxisStruct(Mirror)
3156 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3157 MakeGroups, NewMeshName)
3158 mesh.SetParameters(Parameters)
3159 return Mesh(self.smeshpyD,self.geompyD,mesh)
3161 ## Creates a symmetrical copy of the object
3162 # @param theObject mesh, submesh or group
3163 # @param Mirror AxisStruct or geom object (point, line, plane)
3164 # @param theMirrorType is POINT, AXIS or PLANE
3165 # If the Mirror is a geom object this parameter is unnecessary
3166 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3167 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3168 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3169 # @ingroup l2_modif_trsf
3170 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3171 if ( isinstance( theObject, Mesh )):
3172 theObject = theObject.GetMesh()
3173 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3174 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3175 Mirror,Parameters = ParseAxisStruct(Mirror)
3176 self.mesh.SetParameters(Parameters)
3177 if Copy and MakeGroups:
3178 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3179 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3182 ## Creates a new mesh by a symmetrical copy of the object
3183 # @param theObject mesh, submesh or group
3184 # @param Mirror AxisStruct or geom object (point, line, plane)
3185 # @param theMirrorType POINT, AXIS or PLANE
3186 # If the Mirror is a geom object this parameter is unnecessary
3187 # @param MakeGroups forces the generation of new groups from existing ones
3188 # @param NewMeshName the name of the new mesh to create
3189 # @return instance of Mesh class
3190 # @ingroup l2_modif_trsf
3191 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3192 if ( isinstance( theObject, Mesh )):
3193 theObject = theObject.GetMesh()
3194 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3195 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3196 Mirror,Parameters = ParseAxisStruct(Mirror)
3197 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3198 MakeGroups, NewMeshName)
3199 mesh.SetParameters(Parameters)
3200 return Mesh( self.smeshpyD,self.geompyD,mesh )
3202 ## Translates the elements
3203 # @param IDsOfElements list of elements ids
3204 # @param Vector the direction of translation (DirStruct or vector)
3205 # @param Copy allows copying the translated elements
3206 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3207 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3208 # @ingroup l2_modif_trsf
3209 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3210 if IDsOfElements == []:
3211 IDsOfElements = self.GetElementsId()
3212 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3213 Vector = self.smeshpyD.GetDirStruct(Vector)
3214 Vector,Parameters = ParseDirStruct(Vector)
3215 self.mesh.SetParameters(Parameters)
3216 if Copy and MakeGroups:
3217 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3218 self.editor.Translate(IDsOfElements, Vector, Copy)
3221 ## Creates a new mesh of translated elements
3222 # @param IDsOfElements list of elements ids
3223 # @param Vector the direction of translation (DirStruct or vector)
3224 # @param MakeGroups forces the generation of new groups from existing ones
3225 # @param NewMeshName the name of the newly created mesh
3226 # @return instance of Mesh class
3227 # @ingroup l2_modif_trsf
3228 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3229 if IDsOfElements == []:
3230 IDsOfElements = self.GetElementsId()
3231 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3232 Vector = self.smeshpyD.GetDirStruct(Vector)
3233 Vector,Parameters = ParseDirStruct(Vector)
3234 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3235 mesh.SetParameters(Parameters)
3236 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3238 ## Translates the object
3239 # @param theObject the object to translate (mesh, submesh, or group)
3240 # @param Vector direction of translation (DirStruct or geom vector)
3241 # @param Copy allows copying the translated elements
3242 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3243 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3244 # @ingroup l2_modif_trsf
3245 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3246 if ( isinstance( theObject, Mesh )):
3247 theObject = theObject.GetMesh()
3248 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3249 Vector = self.smeshpyD.GetDirStruct(Vector)
3250 Vector,Parameters = ParseDirStruct(Vector)
3251 self.mesh.SetParameters(Parameters)
3252 if Copy and MakeGroups:
3253 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3254 self.editor.TranslateObject(theObject, Vector, Copy)
3257 ## Creates a new mesh from the translated object
3258 # @param theObject the object to translate (mesh, submesh, or group)
3259 # @param Vector the direction of translation (DirStruct or geom vector)
3260 # @param MakeGroups forces the generation of new groups from existing ones
3261 # @param NewMeshName the name of the newly created mesh
3262 # @return instance of Mesh class
3263 # @ingroup l2_modif_trsf
3264 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3265 if (isinstance(theObject, Mesh)):
3266 theObject = theObject.GetMesh()
3267 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3268 Vector = self.smeshpyD.GetDirStruct(Vector)
3269 Vector,Parameters = ParseDirStruct(Vector)
3270 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3271 mesh.SetParameters(Parameters)
3272 return Mesh( self.smeshpyD, self.geompyD, mesh )
3274 ## Rotates the elements
3275 # @param IDsOfElements list of elements ids
3276 # @param Axis the axis of rotation (AxisStruct or geom line)
3277 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3278 # @param Copy allows copying the rotated elements
3279 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3280 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3281 # @ingroup l2_modif_trsf
3282 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3284 if isinstance(AngleInRadians,str):
3286 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3288 AngleInRadians = DegreesToRadians(AngleInRadians)
3289 if IDsOfElements == []:
3290 IDsOfElements = self.GetElementsId()
3291 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3292 Axis = self.smeshpyD.GetAxisStruct(Axis)
3293 Axis,AxisParameters = ParseAxisStruct(Axis)
3294 Parameters = AxisParameters + var_separator + Parameters
3295 self.mesh.SetParameters(Parameters)
3296 if Copy and MakeGroups:
3297 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3298 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3301 ## Creates a new mesh of rotated elements
3302 # @param IDsOfElements list of element ids
3303 # @param Axis the axis of rotation (AxisStruct or geom line)
3304 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3305 # @param MakeGroups forces the generation of new groups from existing ones
3306 # @param NewMeshName the name of the newly created mesh
3307 # @return instance of Mesh class
3308 # @ingroup l2_modif_trsf
3309 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3311 if isinstance(AngleInRadians,str):
3313 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3315 AngleInRadians = DegreesToRadians(AngleInRadians)
3316 if IDsOfElements == []:
3317 IDsOfElements = self.GetElementsId()
3318 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3319 Axis = self.smeshpyD.GetAxisStruct(Axis)
3320 Axis,AxisParameters = ParseAxisStruct(Axis)
3321 Parameters = AxisParameters + var_separator + Parameters
3322 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3323 MakeGroups, NewMeshName)
3324 mesh.SetParameters(Parameters)
3325 return Mesh( self.smeshpyD, self.geompyD, mesh )
3327 ## Rotates the object
3328 # @param theObject the object to rotate( mesh, submesh, or group)
3329 # @param Axis the axis of rotation (AxisStruct or geom line)
3330 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3331 # @param Copy allows copying the rotated elements
3332 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3333 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3334 # @ingroup l2_modif_trsf
3335 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3337 if isinstance(AngleInRadians,str):
3339 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3341 AngleInRadians = DegreesToRadians(AngleInRadians)
3342 if (isinstance(theObject, Mesh)):
3343 theObject = theObject.GetMesh()
3344 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3345 Axis = self.smeshpyD.GetAxisStruct(Axis)
3346 Axis,AxisParameters = ParseAxisStruct(Axis)
3347 Parameters = AxisParameters + ":" + Parameters
3348 self.mesh.SetParameters(Parameters)
3349 if Copy and MakeGroups:
3350 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3351 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3354 ## Creates a new mesh from the rotated object
3355 # @param theObject the object to rotate (mesh, submesh, or group)
3356 # @param Axis the axis of rotation (AxisStruct or geom line)
3357 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3358 # @param MakeGroups forces the generation of new groups from existing ones
3359 # @param NewMeshName the name of the newly created mesh
3360 # @return instance of Mesh class
3361 # @ingroup l2_modif_trsf
3362 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3364 if isinstance(AngleInRadians,str):
3366 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3368 AngleInRadians = DegreesToRadians(AngleInRadians)
3369 if (isinstance( theObject, Mesh )):
3370 theObject = theObject.GetMesh()
3371 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3372 Axis = self.smeshpyD.GetAxisStruct(Axis)
3373 Axis,AxisParameters = ParseAxisStruct(Axis)
3374 Parameters = AxisParameters + ":" + Parameters
3375 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3376 MakeGroups, NewMeshName)
3377 mesh.SetParameters(Parameters)
3378 return Mesh( self.smeshpyD, self.geompyD, mesh )
3380 ## Finds groups of ajacent nodes within Tolerance.
3381 # @param Tolerance the value of tolerance
3382 # @return the list of groups of nodes
3383 # @ingroup l2_modif_trsf
3384 def FindCoincidentNodes (self, Tolerance):
3385 return self.editor.FindCoincidentNodes(Tolerance)
3387 ## Finds groups of ajacent nodes within Tolerance.
3388 # @param Tolerance the value of tolerance
3389 # @param SubMeshOrGroup SubMesh or Group
3390 # @return the list of groups of nodes
3391 # @ingroup l2_modif_trsf
3392 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3393 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3396 # @param GroupsOfNodes the list of groups of nodes
3397 # @ingroup l2_modif_trsf
3398 def MergeNodes (self, GroupsOfNodes):
3399 self.editor.MergeNodes(GroupsOfNodes)
3401 ## Finds the elements built on the same nodes.
3402 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3403 # @return a list of groups of equal elements
3404 # @ingroup l2_modif_trsf
3405 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3406 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3407 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3408 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3410 ## Merges elements in each given group.
3411 # @param GroupsOfElementsID groups of elements for merging
3412 # @ingroup l2_modif_trsf
3413 def MergeElements(self, GroupsOfElementsID):
3414 self.editor.MergeElements(GroupsOfElementsID)
3416 ## Leaves one element and removes all other elements built on the same nodes.
3417 # @ingroup l2_modif_trsf
3418 def MergeEqualElements(self):
3419 self.editor.MergeEqualElements()
3421 ## Sews free borders
3422 # @return SMESH::Sew_Error
3423 # @ingroup l2_modif_trsf
3424 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3425 FirstNodeID2, SecondNodeID2, LastNodeID2,
3426 CreatePolygons, CreatePolyedrs):
3427 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3428 FirstNodeID2, SecondNodeID2, LastNodeID2,
3429 CreatePolygons, CreatePolyedrs)
3431 ## Sews conform free borders
3432 # @return SMESH::Sew_Error
3433 # @ingroup l2_modif_trsf
3434 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3435 FirstNodeID2, SecondNodeID2):
3436 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3437 FirstNodeID2, SecondNodeID2)
3439 ## Sews border to side
3440 # @return SMESH::Sew_Error
3441 # @ingroup l2_modif_trsf
3442 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3443 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3444 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3445 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3447 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3448 # merged with the nodes of elements of Side2.
3449 # The number of elements in theSide1 and in theSide2 must be
3450 # equal and they should have similar nodal connectivity.
3451 # The nodes to merge should belong to side borders and
3452 # the first node should be linked to the second.
3453 # @return SMESH::Sew_Error
3454 # @ingroup l2_modif_trsf
3455 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3456 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3457 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3458 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3459 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3460 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3462 ## Sets new nodes for the given element.
3463 # @param ide the element id
3464 # @param newIDs nodes ids
3465 # @return If the number of nodes does not correspond to the type of element - returns false
3466 # @ingroup l2_modif_edit
3467 def ChangeElemNodes(self, ide, newIDs):
3468 return self.editor.ChangeElemNodes(ide, newIDs)
3470 ## If during the last operation of MeshEditor some nodes were
3471 # created, this method returns the list of their IDs, \n
3472 # if new nodes were not created - returns empty list
3473 # @return the list of integer values (can be empty)
3474 # @ingroup l1_auxiliary
3475 def GetLastCreatedNodes(self):
3476 return self.editor.GetLastCreatedNodes()
3478 ## If during the last operation of MeshEditor some elements were
3479 # created this method returns the list of their IDs, \n
3480 # if new elements were not created - returns empty list
3481 # @return the list of integer values (can be empty)
3482 # @ingroup l1_auxiliary
3483 def GetLastCreatedElems(self):
3484 return self.editor.GetLastCreatedElems()
3486 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3487 # @param theNodes identifiers of nodes to be doubled
3488 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3489 # nodes. If list of element identifiers is empty then nodes are doubled but
3490 # they not assigned to elements
3491 # @return TRUE if operation has been completed successfully, FALSE otherwise
3492 # @ingroup l2_modif_edit
3493 def DoubleNodes(self, theNodes, theModifiedElems):
3494 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3496 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3497 # This method provided for convenience works as DoubleNodes() described above.
3498 # @param theNodes identifiers of node to be doubled
3499 # @param theModifiedElems identifiers of elements to be updated
3500 # @return TRUE if operation has been completed successfully, FALSE otherwise
3501 # @ingroup l2_modif_edit
3502 def DoubleNode(self, theNodeId, theModifiedElems):
3503 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3505 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3506 # This method provided for convenience works as DoubleNodes() described above.
3507 # @param theNodes group of nodes to be doubled
3508 # @param theModifiedElems group of elements to be updated.
3509 # @return TRUE if operation has been completed successfully, FALSE otherwise
3510 # @ingroup l2_modif_edit
3511 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3512 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
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 theNodes list of groups of nodes to be doubled
3517 # @param theModifiedElems list of groups of elements to be updated.
3518 # @return TRUE if operation has been completed successfully, FALSE otherwise
3519 # @ingroup l2_modif_edit
3520 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3521 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3523 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3524 # @param theElems - the list of elements (edges or faces) to be replicated
3525 # The nodes for duplication could be found from these elements
3526 # @param theNodesNot - list of nodes to NOT replicate
3527 # @param theAffectedElems - the list of elements (cells and edges) to which the
3528 # replicated nodes should be associated to.
3529 # @return TRUE if operation has been completed successfully, FALSE otherwise
3530 # @ingroup l2_modif_edit
3531 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3532 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3534 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3535 # @param theElems - the list of elements (edges or faces) to be replicated
3536 # The nodes for duplication could be found from these elements
3537 # @param theNodesNot - list of nodes to NOT replicate
3538 # @param theShape - shape to detect affected elements (element which geometric center
3539 # located on or inside shape).
3540 # The replicated nodes should be associated to affected elements.
3541 # @return TRUE if operation has been completed successfully, FALSE otherwise
3542 # @ingroup l2_modif_edit
3543 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3544 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
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 - group of of elements (edges or faces) to be replicated
3549 # @param theNodesNot - group of nodes not to replicated
3550 # @param theAffectedElems - group of elements to which the replicated nodes
3551 # should be associated to.
3552 # @ingroup l2_modif_edit
3553 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3554 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3556 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3557 # This method provided for convenience works as DoubleNodes() described above.
3558 # @param theElems - group of of elements (edges or faces) to be replicated
3559 # @param theNodesNot - group of nodes not to replicated
3560 # @param theShape - shape to detect affected elements (element which geometric center
3561 # located on or inside shape).
3562 # The replicated nodes should be associated to affected elements.
3563 # @ingroup l2_modif_edit
3564 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3565 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3567 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3568 # This method provided for convenience works as DoubleNodes() described above.
3569 # @param theElems - list of groups of elements (edges or faces) to be replicated
3570 # @param theNodesNot - list of groups of nodes not to replicated
3571 # @param theAffectedElems - group of elements to which the replicated nodes
3572 # should be associated to.
3573 # @return TRUE if operation has been completed successfully, FALSE otherwise
3574 # @ingroup l2_modif_edit
3575 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3576 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3578 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3579 # This method provided for convenience works as DoubleNodes() described above.
3580 # @param theElems - list of groups of elements (edges or faces) to be replicated
3581 # @param theNodesNot - list of groups of nodes not to replicated
3582 # @param theShape - shape to detect affected elements (element which geometric center
3583 # located on or inside shape).
3584 # The replicated nodes should be associated to affected elements.
3585 # @return TRUE if operation has been completed successfully, FALSE otherwise
3586 # @ingroup l2_modif_edit
3587 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3588 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3590 ## The mother class to define algorithm, it is not recommended to use it directly.
3593 # @ingroup l2_algorithms
3594 class Mesh_Algorithm:
3595 # @class Mesh_Algorithm
3596 # @brief Class Mesh_Algorithm
3598 #def __init__(self,smesh):
3606 ## Finds a hypothesis in the study by its type name and parameters.
3607 # Finds only the hypotheses created in smeshpyD engine.
3608 # @return SMESH.SMESH_Hypothesis
3609 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3610 study = smeshpyD.GetCurrentStudy()
3611 #to do: find component by smeshpyD object, not by its data type
3612 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3613 if scomp is not None:
3614 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3615 # Check if the root label of the hypotheses exists
3616 if res and hypRoot is not None:
3617 iter = study.NewChildIterator(hypRoot)
3618 # Check all published hypotheses
3620 hypo_so_i = iter.Value()
3621 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3622 if attr is not None:
3623 anIOR = attr.Value()
3624 hypo_o_i = salome.orb.string_to_object(anIOR)
3625 if hypo_o_i is not None:
3626 # Check if this is a hypothesis
3627 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3628 if hypo_i is not None:
3629 # Check if the hypothesis belongs to current engine
3630 if smeshpyD.GetObjectId(hypo_i) > 0:
3631 # Check if this is the required hypothesis
3632 if hypo_i.GetName() == hypname:
3634 if CompareMethod(hypo_i, args):
3648 ## Finds the algorithm in the study by its type name.
3649 # Finds only the algorithms, which have been created in smeshpyD engine.
3650 # @return SMESH.SMESH_Algo
3651 def FindAlgorithm (self, algoname, smeshpyD):
3652 study = smeshpyD.GetCurrentStudy()
3653 #to do: find component by smeshpyD object, not by its data type
3654 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3655 if scomp is not None:
3656 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3657 # Check if the root label of the algorithms exists
3658 if res and hypRoot is not None:
3659 iter = study.NewChildIterator(hypRoot)
3660 # Check all published algorithms
3662 algo_so_i = iter.Value()
3663 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3664 if attr is not None:
3665 anIOR = attr.Value()
3666 algo_o_i = salome.orb.string_to_object(anIOR)
3667 if algo_o_i is not None:
3668 # Check if this is an algorithm
3669 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3670 if algo_i is not None:
3671 # Checks if the algorithm belongs to the current engine
3672 if smeshpyD.GetObjectId(algo_i) > 0:
3673 # Check if this is the required algorithm
3674 if algo_i.GetName() == algoname:
3687 ## If the algorithm is global, returns 0; \n
3688 # else returns the submesh associated to this algorithm.
3689 def GetSubMesh(self):
3692 ## Returns the wrapped mesher.
3693 def GetAlgorithm(self):
3696 ## Gets the list of hypothesis that can be used with this algorithm
3697 def GetCompatibleHypothesis(self):
3700 mylist = self.algo.GetCompatibleHypothesis()
3703 ## Gets the name of the algorithm
3707 ## Sets the name to the algorithm
3708 def SetName(self, name):
3709 self.mesh.smeshpyD.SetName(self.algo, name)
3711 ## Gets the id of the algorithm
3713 return self.algo.GetId()
3716 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3718 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3719 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3721 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3723 self.Assign(algo, mesh, geom)
3727 def Assign(self, algo, mesh, geom):
3729 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3738 name = GetName(geom)
3741 name = mesh.geompyD.SubShapeName(geom, piece)
3742 mesh.geompyD.addToStudyInFather(piece, geom, name)
3744 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3747 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3748 TreatHypoStatus( status, algo.GetName(), name, True )
3750 def CompareHyp (self, hyp, args):
3751 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3754 def CompareEqualHyp (self, hyp, args):
3758 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3759 UseExisting=0, CompareMethod=""):
3762 if CompareMethod == "": CompareMethod = self.CompareHyp
3763 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3766 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3772 a = a + s + str(args[i])
3776 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3778 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3779 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3782 ## Returns entry of the shape to mesh in the study
3783 def MainShapeEntry(self):
3785 if not self.mesh or not self.mesh.GetMesh(): return entry
3786 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3787 study = self.mesh.smeshpyD.GetCurrentStudy()
3788 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3789 sobj = study.FindObjectIOR(ior)
3790 if sobj: entry = sobj.GetID()
3791 if not entry: return ""
3794 # Public class: Mesh_Segment
3795 # --------------------------
3797 ## Class to define a segment 1D algorithm for discretization
3800 # @ingroup l3_algos_basic
3801 class Mesh_Segment(Mesh_Algorithm):
3803 ## Private constructor.
3804 def __init__(self, mesh, geom=0):
3805 Mesh_Algorithm.__init__(self)
3806 self.Create(mesh, geom, "Regular_1D")
3808 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3809 # @param l for the length of segments that cut an edge
3810 # @param UseExisting if ==true - searches for an existing hypothesis created with
3811 # the same parameters, else (default) - creates a new one
3812 # @param p precision, used for calculation of the number of segments.
3813 # The precision should be a positive, meaningful value within the range [0,1].
3814 # In general, the number of segments is calculated with the formula:
3815 # nb = ceil((edge_length / l) - p)
3816 # Function ceil rounds its argument to the higher integer.
3817 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3818 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3819 # p=1 means rounding of (edge_length / l) to the lower integer.
3820 # Default value is 1e-07.
3821 # @return an instance of StdMeshers_LocalLength hypothesis
3822 # @ingroup l3_hypos_1dhyps
3823 def LocalLength(self, l, UseExisting=0, p=1e-07):
3824 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3825 CompareMethod=self.CompareLocalLength)
3831 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3832 def CompareLocalLength(self, hyp, args):
3833 if IsEqual(hyp.GetLength(), args[0]):
3834 return IsEqual(hyp.GetPrecision(), args[1])
3837 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3838 # @param length is optional maximal allowed length of segment, if it is omitted
3839 # the preestimated length is used that depends on geometry size
3840 # @param UseExisting if ==true - searches for an existing hypothesis created with
3841 # the same parameters, else (default) - create a new one
3842 # @return an instance of StdMeshers_MaxLength hypothesis
3843 # @ingroup l3_hypos_1dhyps
3844 def MaxSize(self, length=0.0, UseExisting=0):
3845 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3848 hyp.SetLength(length)
3850 # set preestimated length
3851 gen = self.mesh.smeshpyD
3852 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3853 self.mesh.GetMesh(), self.mesh.GetShape(),
3855 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3857 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3860 hyp.SetUsePreestimatedLength( length == 0.0 )
3863 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3864 # @param n for the number of segments that cut an edge
3865 # @param s for the scale factor (optional)
3866 # @param reversedEdges is a list of edges to mesh using reversed orientation
3867 # @param UseExisting if ==true - searches for an existing hypothesis created with
3868 # the same parameters, else (default) - create a new one
3869 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3870 # @ingroup l3_hypos_1dhyps
3871 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3872 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3873 reversedEdges, UseExisting = [], reversedEdges
3874 entry = self.MainShapeEntry()
3876 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3877 UseExisting=UseExisting,
3878 CompareMethod=self.CompareNumberOfSegments)
3880 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3881 UseExisting=UseExisting,
3882 CompareMethod=self.CompareNumberOfSegments)
3883 hyp.SetDistrType( 1 )
3884 hyp.SetScaleFactor(s)
3885 hyp.SetNumberOfSegments(n)
3886 hyp.SetReversedEdges( reversedEdges )
3887 hyp.SetObjectEntry( entry )
3891 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3892 def CompareNumberOfSegments(self, hyp, args):
3893 if hyp.GetNumberOfSegments() == args[0]:
3895 if hyp.GetReversedEdges() == args[1]:
3896 if not args[1] or hyp.GetObjectEntry() == args[2]:
3899 if hyp.GetReversedEdges() == args[2]:
3900 if not args[2] or hyp.GetObjectEntry() == args[3]:
3901 if hyp.GetDistrType() == 1:
3902 if IsEqual(hyp.GetScaleFactor(), args[1]):
3906 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3907 # @param start defines the length of the first segment
3908 # @param end defines the length of the last segment
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 Arithmetic1D(self, start, end, 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("Arithmetic1D", [start, end, reversedEdges, entry],
3919 UseExisting=UseExisting,
3920 CompareMethod=self.CompareArithmetic1D)
3921 hyp.SetStartLength(start)
3922 hyp.SetEndLength(end)
3923 hyp.SetReversedEdges( reversedEdges )
3924 hyp.SetObjectEntry( entry )
3928 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3929 def CompareArithmetic1D(self, hyp, args):
3930 if IsEqual(hyp.GetLength(1), args[0]):
3931 if IsEqual(hyp.GetLength(0), args[1]):
3932 if hyp.GetReversedEdges() == args[2]:
3933 if not args[2] or hyp.GetObjectEntry() == args[3]:
3938 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3939 # on curve from 0 to 1 (additionally it is neecessary to check
3940 # orientation of edges and create list of reversed edges if it is
3941 # needed) and sets numbers of segments between given points (default
3942 # values are equals 1
3943 # @param points defines the list of parameters on curve
3944 # @param nbSegs defines the list of numbers of segments
3945 # @param reversedEdges is a list of edges to mesh using reversed orientation
3946 # @param UseExisting if ==true - searches for an existing hypothesis created with
3947 # the same parameters, else (default) - creates a new one
3948 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3949 # @ingroup l3_hypos_1dhyps
3950 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3951 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3952 reversedEdges, UseExisting = [], reversedEdges
3953 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
3954 for i in range( len( reversedEdges )):
3955 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
3956 entry = self.MainShapeEntry()
3957 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3958 UseExisting=UseExisting,
3959 CompareMethod=self.CompareFixedPoints1D)
3960 hyp.SetPoints(points)
3961 hyp.SetNbSegments(nbSegs)
3962 hyp.SetReversedEdges(reversedEdges)
3963 hyp.SetObjectEntry(entry)
3967 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3968 ## as the given arguments
3969 def CompareFixedPoints1D(self, hyp, args):
3970 if hyp.GetPoints() == args[0]:
3971 if hyp.GetNbSegments() == args[1]:
3972 if hyp.GetReversedEdges() == args[2]:
3973 if not args[2] or hyp.GetObjectEntry() == args[3]:
3979 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3980 # @param start defines the length of the first segment
3981 # @param end defines the length of the last segment
3982 # @param reversedEdges is a list of edges to mesh using reversed orientation
3983 # @param UseExisting if ==true - searches for an existing hypothesis created with
3984 # the same parameters, else (default) - creates a new one
3985 # @return an instance of StdMeshers_StartEndLength hypothesis
3986 # @ingroup l3_hypos_1dhyps
3987 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3988 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3989 reversedEdges, UseExisting = [], reversedEdges
3990 entry = self.MainShapeEntry()
3991 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3992 UseExisting=UseExisting,
3993 CompareMethod=self.CompareStartEndLength)
3994 hyp.SetStartLength(start)
3995 hyp.SetEndLength(end)
3996 hyp.SetReversedEdges( reversedEdges )
3997 hyp.SetObjectEntry( entry )
4000 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4001 def CompareStartEndLength(self, hyp, args):
4002 if IsEqual(hyp.GetLength(1), args[0]):
4003 if IsEqual(hyp.GetLength(0), args[1]):
4004 if hyp.GetReversedEdges() == args[2]:
4005 if not args[2] or hyp.GetObjectEntry() == args[3]:
4009 ## Defines "Deflection1D" hypothesis
4010 # @param d for the deflection
4011 # @param UseExisting if ==true - searches for an existing hypothesis created with
4012 # the same parameters, else (default) - create a new one
4013 # @ingroup l3_hypos_1dhyps
4014 def Deflection1D(self, d, UseExisting=0):
4015 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4016 CompareMethod=self.CompareDeflection1D)
4017 hyp.SetDeflection(d)
4020 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4021 def CompareDeflection1D(self, hyp, args):
4022 return IsEqual(hyp.GetDeflection(), args[0])
4024 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4025 # the opposite side in case of quadrangular faces
4026 # @ingroup l3_hypos_additi
4027 def Propagation(self):
4028 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4030 ## Defines "AutomaticLength" hypothesis
4031 # @param fineness for the fineness [0-1]
4032 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4033 # same parameters, else (default) - create a new one
4034 # @ingroup l3_hypos_1dhyps
4035 def AutomaticLength(self, fineness=0, UseExisting=0):
4036 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4037 CompareMethod=self.CompareAutomaticLength)
4038 hyp.SetFineness( fineness )
4041 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4042 def CompareAutomaticLength(self, hyp, args):
4043 return IsEqual(hyp.GetFineness(), args[0])
4045 ## Defines "SegmentLengthAroundVertex" hypothesis
4046 # @param length for the segment length
4047 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4048 # Any other integer value means that the hypothesis will be set on the
4049 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4050 # @param UseExisting if ==true - searches for an existing hypothesis created with
4051 # the same parameters, else (default) - creates a new one
4052 # @ingroup l3_algos_segmarv
4053 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4055 store_geom = self.geom
4056 if type(vertex) is types.IntType:
4057 if vertex == 0 or vertex == 1:
4058 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4066 if self.geom is None:
4067 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4069 name = GetName(self.geom)
4072 piece = self.mesh.geom
4073 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4074 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4076 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4078 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4080 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4081 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4083 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4084 CompareMethod=self.CompareLengthNearVertex)
4085 self.geom = store_geom
4086 hyp.SetLength( length )
4089 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4090 # @ingroup l3_algos_segmarv
4091 def CompareLengthNearVertex(self, hyp, args):
4092 return IsEqual(hyp.GetLength(), args[0])
4094 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4095 # If the 2D mesher sees that all boundary edges are quadratic,
4096 # it generates quadratic faces, else it generates linear faces using
4097 # medium nodes as if they are vertices.
4098 # The 3D mesher generates quadratic volumes only if all boundary faces
4099 # are quadratic, else it fails.
4101 # @ingroup l3_hypos_additi
4102 def QuadraticMesh(self):
4103 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4106 # Public class: Mesh_CompositeSegment
4107 # --------------------------
4109 ## Defines a segment 1D algorithm for discretization
4111 # @ingroup l3_algos_basic
4112 class Mesh_CompositeSegment(Mesh_Segment):
4114 ## Private constructor.
4115 def __init__(self, mesh, geom=0):
4116 self.Create(mesh, geom, "CompositeSegment_1D")
4119 # Public class: Mesh_Segment_Python
4120 # ---------------------------------
4122 ## Defines a segment 1D algorithm for discretization with python function
4124 # @ingroup l3_algos_basic
4125 class Mesh_Segment_Python(Mesh_Segment):
4127 ## Private constructor.
4128 def __init__(self, mesh, geom=0):
4129 import Python1dPlugin
4130 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4132 ## Defines "PythonSplit1D" hypothesis
4133 # @param n for the number of segments that cut an edge
4134 # @param func for the python function that calculates the length of all segments
4135 # @param UseExisting if ==true - searches for the existing hypothesis created with
4136 # the same parameters, else (default) - creates a new one
4137 # @ingroup l3_hypos_1dhyps
4138 def PythonSplit1D(self, n, func, UseExisting=0):
4139 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4140 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4141 hyp.SetNumberOfSegments(n)
4142 hyp.SetPythonLog10RatioFunction(func)
4145 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4146 def ComparePythonSplit1D(self, hyp, args):
4147 #if hyp.GetNumberOfSegments() == args[0]:
4148 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4152 # Public class: Mesh_Triangle
4153 # ---------------------------
4155 ## Defines a triangle 2D algorithm
4157 # @ingroup l3_algos_basic
4158 class Mesh_Triangle(Mesh_Algorithm):
4167 ## Private constructor.
4168 def __init__(self, mesh, algoType, geom=0):
4169 Mesh_Algorithm.__init__(self)
4171 self.algoType = algoType
4172 if algoType == MEFISTO:
4173 self.Create(mesh, geom, "MEFISTO_2D")
4175 elif algoType == BLSURF:
4177 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4178 #self.SetPhysicalMesh() - PAL19680
4179 elif algoType == NETGEN:
4181 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4183 elif algoType == NETGEN_2D:
4185 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4188 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4189 # @param area for the maximum area of each triangle
4190 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4191 # same parameters, else (default) - creates a new one
4193 # Only for algoType == MEFISTO || NETGEN_2D
4194 # @ingroup l3_hypos_2dhyps
4195 def MaxElementArea(self, area, UseExisting=0):
4196 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4197 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4198 CompareMethod=self.CompareMaxElementArea)
4199 elif self.algoType == NETGEN:
4200 hyp = self.Parameters(SIMPLE)
4201 hyp.SetMaxElementArea(area)
4204 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4205 def CompareMaxElementArea(self, hyp, args):
4206 return IsEqual(hyp.GetMaxElementArea(), args[0])
4208 ## Defines "LengthFromEdges" hypothesis to build triangles
4209 # based on the length of the edges taken from the wire
4211 # Only for algoType == MEFISTO || NETGEN_2D
4212 # @ingroup l3_hypos_2dhyps
4213 def LengthFromEdges(self):
4214 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4215 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4217 elif self.algoType == NETGEN:
4218 hyp = self.Parameters(SIMPLE)
4219 hyp.LengthFromEdges()
4222 ## Sets a way to define size of mesh elements to generate.
4223 # @param thePhysicalMesh is: DefaultSize or Custom.
4224 # @ingroup l3_hypos_blsurf
4225 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4226 # Parameter of BLSURF algo
4227 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4229 ## Sets size of mesh elements to generate.
4230 # @ingroup l3_hypos_blsurf
4231 def SetPhySize(self, theVal):
4232 # Parameter of BLSURF algo
4233 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4234 self.Parameters().SetPhySize(theVal)
4236 ## Sets lower boundary of mesh element size (PhySize).
4237 # @ingroup l3_hypos_blsurf
4238 def SetPhyMin(self, theVal=-1):
4239 # Parameter of BLSURF algo
4240 self.Parameters().SetPhyMin(theVal)
4242 ## Sets upper boundary of mesh element size (PhySize).
4243 # @ingroup l3_hypos_blsurf
4244 def SetPhyMax(self, theVal=-1):
4245 # Parameter of BLSURF algo
4246 self.Parameters().SetPhyMax(theVal)
4248 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4249 # @param theGeometricMesh is: DefaultGeom or Custom
4250 # @ingroup l3_hypos_blsurf
4251 def SetGeometricMesh(self, theGeometricMesh=0):
4252 # Parameter of BLSURF algo
4253 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4254 self.params.SetGeometricMesh(theGeometricMesh)
4256 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4257 # @ingroup l3_hypos_blsurf
4258 def SetAngleMeshS(self, theVal=_angleMeshS):
4259 # Parameter of BLSURF algo
4260 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4261 self.params.SetAngleMeshS(theVal)
4263 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4264 # @ingroup l3_hypos_blsurf
4265 def SetAngleMeshC(self, theVal=_angleMeshS):
4266 # Parameter of BLSURF algo
4267 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4268 self.params.SetAngleMeshC(theVal)
4270 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4271 # @ingroup l3_hypos_blsurf
4272 def SetGeoMin(self, theVal=-1):
4273 # Parameter of BLSURF algo
4274 self.Parameters().SetGeoMin(theVal)
4276 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4277 # @ingroup l3_hypos_blsurf
4278 def SetGeoMax(self, theVal=-1):
4279 # Parameter of BLSURF algo
4280 self.Parameters().SetGeoMax(theVal)
4282 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4283 # @ingroup l3_hypos_blsurf
4284 def SetGradation(self, theVal=_gradation):
4285 # Parameter of BLSURF algo
4286 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4287 self.params.SetGradation(theVal)
4289 ## Sets topology usage way.
4290 # @param way defines how mesh conformity is assured <ul>
4291 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4292 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4293 # @ingroup l3_hypos_blsurf
4294 def SetTopology(self, way):
4295 # Parameter of BLSURF algo
4296 self.Parameters().SetTopology(way)
4298 ## To respect geometrical edges or not.
4299 # @ingroup l3_hypos_blsurf
4300 def SetDecimesh(self, toIgnoreEdges=False):
4301 # Parameter of BLSURF algo
4302 self.Parameters().SetDecimesh(toIgnoreEdges)
4304 ## Sets verbosity level in the range 0 to 100.
4305 # @ingroup l3_hypos_blsurf
4306 def SetVerbosity(self, level):
4307 # Parameter of BLSURF algo
4308 self.Parameters().SetVerbosity(level)
4310 ## Sets advanced option value.
4311 # @ingroup l3_hypos_blsurf
4312 def SetOptionValue(self, optionName, level):
4313 # Parameter of BLSURF algo
4314 self.Parameters().SetOptionValue(optionName,level)
4316 ## Sets QuadAllowed flag.
4317 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4318 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4319 def SetQuadAllowed(self, toAllow=True):
4320 if self.algoType == NETGEN_2D:
4321 if toAllow: # add QuadranglePreference
4322 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4323 else: # remove QuadranglePreference
4324 for hyp in self.mesh.GetHypothesisList( self.geom ):
4325 if hyp.GetName() == "QuadranglePreference":
4326 self.mesh.RemoveHypothesis( self.geom, hyp )
4331 if self.Parameters():
4332 self.params.SetQuadAllowed(toAllow)
4335 ## Defines hypothesis having several parameters
4337 # @ingroup l3_hypos_netgen
4338 def Parameters(self, which=SOLE):
4341 if self.algoType == NETGEN:
4343 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4344 "libNETGENEngine.so", UseExisting=0)
4346 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4347 "libNETGENEngine.so", UseExisting=0)
4349 elif self.algoType == MEFISTO:
4350 print "Mefisto algo support no multi-parameter hypothesis"
4352 elif self.algoType == NETGEN_2D:
4353 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4354 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4356 elif self.algoType == BLSURF:
4357 self.params = self.Hypothesis("BLSURF_Parameters", [],
4358 "libBLSURFEngine.so", UseExisting=0)
4361 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4366 # Only for algoType == NETGEN
4367 # @ingroup l3_hypos_netgen
4368 def SetMaxSize(self, theSize):
4369 if self.Parameters():
4370 self.params.SetMaxSize(theSize)
4372 ## Sets SecondOrder flag
4374 # Only for algoType == NETGEN
4375 # @ingroup l3_hypos_netgen
4376 def SetSecondOrder(self, theVal):
4377 if self.Parameters():
4378 self.params.SetSecondOrder(theVal)
4380 ## Sets Optimize flag
4382 # Only for algoType == NETGEN
4383 # @ingroup l3_hypos_netgen
4384 def SetOptimize(self, theVal):
4385 if self.Parameters():
4386 self.params.SetOptimize(theVal)
4389 # @param theFineness is:
4390 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4392 # Only for algoType == NETGEN
4393 # @ingroup l3_hypos_netgen
4394 def SetFineness(self, theFineness):
4395 if self.Parameters():
4396 self.params.SetFineness(theFineness)
4400 # Only for algoType == NETGEN
4401 # @ingroup l3_hypos_netgen
4402 def SetGrowthRate(self, theRate):
4403 if self.Parameters():
4404 self.params.SetGrowthRate(theRate)
4406 ## Sets NbSegPerEdge
4408 # Only for algoType == NETGEN
4409 # @ingroup l3_hypos_netgen
4410 def SetNbSegPerEdge(self, theVal):
4411 if self.Parameters():
4412 self.params.SetNbSegPerEdge(theVal)
4414 ## Sets NbSegPerRadius
4416 # Only for algoType == NETGEN
4417 # @ingroup l3_hypos_netgen
4418 def SetNbSegPerRadius(self, theVal):
4419 if self.Parameters():
4420 self.params.SetNbSegPerRadius(theVal)
4422 ## Sets number of segments overriding value set by SetLocalLength()
4424 # Only for algoType == NETGEN
4425 # @ingroup l3_hypos_netgen
4426 def SetNumberOfSegments(self, theVal):
4427 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4429 ## Sets number of segments overriding value set by SetNumberOfSegments()
4431 # Only for algoType == NETGEN
4432 # @ingroup l3_hypos_netgen
4433 def SetLocalLength(self, theVal):
4434 self.Parameters(SIMPLE).SetLocalLength(theVal)
4439 # Public class: Mesh_Quadrangle
4440 # -----------------------------
4442 ## Defines a quadrangle 2D algorithm
4444 # @ingroup l3_algos_basic
4445 class Mesh_Quadrangle(Mesh_Algorithm):
4447 ## Private constructor.
4448 def __init__(self, mesh, geom=0):
4449 Mesh_Algorithm.__init__(self)
4450 self.Create(mesh, geom, "Quadrangle_2D")
4452 ## Defines "QuadranglePreference" hypothesis, forcing construction
4453 # of quadrangles if the number of nodes on the opposite edges is not the same
4454 # while the total number of nodes on edges is even
4456 # @ingroup l3_hypos_additi
4457 def QuadranglePreference(self):
4458 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4459 CompareMethod=self.CompareEqualHyp)
4462 ## Defines "TrianglePreference" hypothesis, forcing construction
4463 # of triangles in the refinement area if the number of nodes
4464 # on the opposite edges is not the same
4466 # @ingroup l3_hypos_additi
4467 def TrianglePreference(self):
4468 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4469 CompareMethod=self.CompareEqualHyp)
4472 ## Defines "QuadrangleParams" hypothesis
4473 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4474 # will be created while other elements will be quadrangles.
4475 # Vertex can be either a GEOM_Object or a vertex ID within the
4478 # @ingroup l3_hypos_additi
4479 def TriangleVertex(self, vertex, UseExisting=0):
4481 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4482 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4483 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4484 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4485 hyp.SetTriaVertex( vertexID )
4489 # Public class: Mesh_Tetrahedron
4490 # ------------------------------
4492 ## Defines a tetrahedron 3D algorithm
4494 # @ingroup l3_algos_basic
4495 class Mesh_Tetrahedron(Mesh_Algorithm):
4500 ## Private constructor.
4501 def __init__(self, mesh, algoType, geom=0):
4502 Mesh_Algorithm.__init__(self)
4504 if algoType == NETGEN:
4506 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4509 elif algoType == FULL_NETGEN:
4511 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4514 elif algoType == GHS3D:
4516 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4519 elif algoType == GHS3DPRL:
4520 CheckPlugin(GHS3DPRL)
4521 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4524 self.algoType = algoType
4526 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4527 # @param vol for the maximum volume of each tetrahedron
4528 # @param UseExisting if ==true - searches for the existing hypothesis created with
4529 # the same parameters, else (default) - creates a new one
4530 # @ingroup l3_hypos_maxvol
4531 def MaxElementVolume(self, vol, UseExisting=0):
4532 if self.algoType == NETGEN:
4533 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4534 CompareMethod=self.CompareMaxElementVolume)
4535 hyp.SetMaxElementVolume(vol)
4537 elif self.algoType == FULL_NETGEN:
4538 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4541 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4542 def CompareMaxElementVolume(self, hyp, args):
4543 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4545 ## Defines hypothesis having several parameters
4547 # @ingroup l3_hypos_netgen
4548 def Parameters(self, which=SOLE):
4552 if self.algoType == FULL_NETGEN:
4554 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4555 "libNETGENEngine.so", UseExisting=0)
4557 self.params = self.Hypothesis("NETGEN_Parameters", [],
4558 "libNETGENEngine.so", UseExisting=0)
4561 if self.algoType == GHS3D:
4562 self.params = self.Hypothesis("GHS3D_Parameters", [],
4563 "libGHS3DEngine.so", UseExisting=0)
4566 if self.algoType == GHS3DPRL:
4567 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4568 "libGHS3DPRLEngine.so", UseExisting=0)
4571 print "Algo supports no multi-parameter hypothesis"
4575 # Parameter of FULL_NETGEN
4576 # @ingroup l3_hypos_netgen
4577 def SetMaxSize(self, theSize):
4578 self.Parameters().SetMaxSize(theSize)
4580 ## Sets SecondOrder flag
4581 # Parameter of FULL_NETGEN
4582 # @ingroup l3_hypos_netgen
4583 def SetSecondOrder(self, theVal):
4584 self.Parameters().SetSecondOrder(theVal)
4586 ## Sets Optimize flag
4587 # Parameter of FULL_NETGEN
4588 # @ingroup l3_hypos_netgen
4589 def SetOptimize(self, theVal):
4590 self.Parameters().SetOptimize(theVal)
4593 # @param theFineness is:
4594 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4595 # Parameter of FULL_NETGEN
4596 # @ingroup l3_hypos_netgen
4597 def SetFineness(self, theFineness):
4598 self.Parameters().SetFineness(theFineness)
4601 # Parameter of FULL_NETGEN
4602 # @ingroup l3_hypos_netgen
4603 def SetGrowthRate(self, theRate):
4604 self.Parameters().SetGrowthRate(theRate)
4606 ## Sets NbSegPerEdge
4607 # Parameter of FULL_NETGEN
4608 # @ingroup l3_hypos_netgen
4609 def SetNbSegPerEdge(self, theVal):
4610 self.Parameters().SetNbSegPerEdge(theVal)
4612 ## Sets NbSegPerRadius
4613 # Parameter of FULL_NETGEN
4614 # @ingroup l3_hypos_netgen
4615 def SetNbSegPerRadius(self, theVal):
4616 self.Parameters().SetNbSegPerRadius(theVal)
4618 ## Sets number of segments overriding value set by SetLocalLength()
4619 # Only for algoType == NETGEN_FULL
4620 # @ingroup l3_hypos_netgen
4621 def SetNumberOfSegments(self, theVal):
4622 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4624 ## Sets number of segments overriding value set by SetNumberOfSegments()
4625 # Only for algoType == NETGEN_FULL
4626 # @ingroup l3_hypos_netgen
4627 def SetLocalLength(self, theVal):
4628 self.Parameters(SIMPLE).SetLocalLength(theVal)
4630 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4631 # Overrides value set by LengthFromEdges()
4632 # Only for algoType == NETGEN_FULL
4633 # @ingroup l3_hypos_netgen
4634 def MaxElementArea(self, area):
4635 self.Parameters(SIMPLE).SetMaxElementArea(area)
4637 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4638 # Overrides value set by MaxElementArea()
4639 # Only for algoType == NETGEN_FULL
4640 # @ingroup l3_hypos_netgen
4641 def LengthFromEdges(self):
4642 self.Parameters(SIMPLE).LengthFromEdges()
4644 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4645 # Overrides value set by MaxElementVolume()
4646 # Only for algoType == NETGEN_FULL
4647 # @ingroup l3_hypos_netgen
4648 def LengthFromFaces(self):
4649 self.Parameters(SIMPLE).LengthFromFaces()
4651 ## To mesh "holes" in a solid or not. Default is to mesh.
4652 # @ingroup l3_hypos_ghs3dh
4653 def SetToMeshHoles(self, toMesh):
4654 # Parameter of GHS3D
4655 self.Parameters().SetToMeshHoles(toMesh)
4657 ## Set Optimization level:
4658 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4659 # Strong_Optimization.
4660 # Default is Standard_Optimization
4661 # @ingroup l3_hypos_ghs3dh
4662 def SetOptimizationLevel(self, level):
4663 # Parameter of GHS3D
4664 self.Parameters().SetOptimizationLevel(level)
4666 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4667 # @ingroup l3_hypos_ghs3dh
4668 def SetMaximumMemory(self, MB):
4669 # Advanced parameter of GHS3D
4670 self.Parameters().SetMaximumMemory(MB)
4672 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4673 # automatic memory adjustment mode.
4674 # @ingroup l3_hypos_ghs3dh
4675 def SetInitialMemory(self, MB):
4676 # Advanced parameter of GHS3D
4677 self.Parameters().SetInitialMemory(MB)
4679 ## Path to working directory.
4680 # @ingroup l3_hypos_ghs3dh
4681 def SetWorkingDirectory(self, path):
4682 # Advanced parameter of GHS3D
4683 self.Parameters().SetWorkingDirectory(path)
4685 ## To keep working files or remove them. Log file remains in case of errors anyway.
4686 # @ingroup l3_hypos_ghs3dh
4687 def SetKeepFiles(self, toKeep):
4688 # Advanced parameter of GHS3D and GHS3DPRL
4689 self.Parameters().SetKeepFiles(toKeep)
4691 ## To set verbose level [0-10]. <ul>
4692 #<li> 0 - no standard output,
4693 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4694 # indicates when the final mesh is being saved. In addition the software
4695 # gives indication regarding the CPU time.
4696 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4697 # histogram of the skin mesh, quality statistics histogram together with
4698 # the characteristics of the final mesh.</ul>
4699 # @ingroup l3_hypos_ghs3dh
4700 def SetVerboseLevel(self, level):
4701 # Advanced parameter of GHS3D
4702 self.Parameters().SetVerboseLevel(level)
4704 ## To create new nodes.
4705 # @ingroup l3_hypos_ghs3dh
4706 def SetToCreateNewNodes(self, toCreate):
4707 # Advanced parameter of GHS3D
4708 self.Parameters().SetToCreateNewNodes(toCreate)
4710 ## To use boundary recovery version which tries to create mesh on a very poor
4711 # quality surface mesh.
4712 # @ingroup l3_hypos_ghs3dh
4713 def SetToUseBoundaryRecoveryVersion(self, toUse):
4714 # Advanced parameter of GHS3D
4715 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4717 ## Sets command line option as text.
4718 # @ingroup l3_hypos_ghs3dh
4719 def SetTextOption(self, option):
4720 # Advanced parameter of GHS3D
4721 self.Parameters().SetTextOption(option)
4723 ## Sets MED files name and path.
4724 def SetMEDName(self, value):
4725 self.Parameters().SetMEDName(value)
4727 ## Sets the number of partition of the initial mesh
4728 def SetNbPart(self, value):
4729 self.Parameters().SetNbPart(value)
4731 ## When big mesh, start tepal in background
4732 def SetBackground(self, value):
4733 self.Parameters().SetBackground(value)
4735 # Public class: Mesh_Hexahedron
4736 # ------------------------------
4738 ## Defines a hexahedron 3D algorithm
4740 # @ingroup l3_algos_basic
4741 class Mesh_Hexahedron(Mesh_Algorithm):
4746 ## Private constructor.
4747 def __init__(self, mesh, algoType=Hexa, geom=0):
4748 Mesh_Algorithm.__init__(self)
4750 self.algoType = algoType
4752 if algoType == Hexa:
4753 self.Create(mesh, geom, "Hexa_3D")
4756 elif algoType == Hexotic:
4757 CheckPlugin(Hexotic)
4758 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4761 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4762 # @ingroup l3_hypos_hexotic
4763 def MinMaxQuad(self, min=3, max=8, quad=True):
4764 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4766 self.params.SetHexesMinLevel(min)
4767 self.params.SetHexesMaxLevel(max)
4768 self.params.SetHexoticQuadrangles(quad)
4771 # Deprecated, only for compatibility!
4772 # Public class: Mesh_Netgen
4773 # ------------------------------
4775 ## Defines a NETGEN-based 2D or 3D algorithm
4776 # that needs no discrete boundary (i.e. independent)
4778 # This class is deprecated, only for compatibility!
4781 # @ingroup l3_algos_basic
4782 class Mesh_Netgen(Mesh_Algorithm):
4786 ## Private constructor.
4787 def __init__(self, mesh, is3D, geom=0):
4788 Mesh_Algorithm.__init__(self)
4794 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4798 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4801 ## Defines the hypothesis containing parameters of the algorithm
4802 def Parameters(self):
4804 hyp = self.Hypothesis("NETGEN_Parameters", [],
4805 "libNETGENEngine.so", UseExisting=0)
4807 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4808 "libNETGENEngine.so", UseExisting=0)
4811 # Public class: Mesh_Projection1D
4812 # ------------------------------
4814 ## Defines a projection 1D algorithm
4815 # @ingroup l3_algos_proj
4817 class Mesh_Projection1D(Mesh_Algorithm):
4819 ## Private constructor.
4820 def __init__(self, mesh, geom=0):
4821 Mesh_Algorithm.__init__(self)
4822 self.Create(mesh, geom, "Projection_1D")
4824 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4825 # a mesh pattern is taken, and, optionally, the association of vertices
4826 # between the source edge and a target edge (to which a hypothesis is assigned)
4827 # @param edge from which nodes distribution is taken
4828 # @param mesh from which nodes distribution is taken (optional)
4829 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4830 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4831 # to associate with \a srcV (optional)
4832 # @param UseExisting if ==true - searches for the existing hypothesis created with
4833 # the same parameters, else (default) - creates a new one
4834 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4835 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4837 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4838 hyp.SetSourceEdge( edge )
4839 if not mesh is None and isinstance(mesh, Mesh):
4840 mesh = mesh.GetMesh()
4841 hyp.SetSourceMesh( mesh )
4842 hyp.SetVertexAssociation( srcV, tgtV )
4845 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4846 #def CompareSourceEdge(self, hyp, args):
4847 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4851 # Public class: Mesh_Projection2D
4852 # ------------------------------
4854 ## Defines a projection 2D algorithm
4855 # @ingroup l3_algos_proj
4857 class Mesh_Projection2D(Mesh_Algorithm):
4859 ## Private constructor.
4860 def __init__(self, mesh, geom=0):
4861 Mesh_Algorithm.__init__(self)
4862 self.Create(mesh, geom, "Projection_2D")
4864 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4865 # a mesh pattern is taken, and, optionally, the association of vertices
4866 # between the source face and the target face (to which a hypothesis is assigned)
4867 # @param face from which the mesh pattern is taken
4868 # @param mesh from which the mesh pattern is taken (optional)
4869 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4870 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4871 # to associate with \a srcV1 (optional)
4872 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4873 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4874 # to associate with \a srcV2 (optional)
4875 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4876 # the same parameters, else (default) - forces the creation a new one
4878 # Note: all association vertices must belong to one edge of a face
4879 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4880 srcV2=None, tgtV2=None, UseExisting=0):
4881 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4883 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4884 hyp.SetSourceFace( face )
4885 if not mesh is None and isinstance(mesh, Mesh):
4886 mesh = mesh.GetMesh()
4887 hyp.SetSourceMesh( mesh )
4888 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4891 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4892 #def CompareSourceFace(self, hyp, args):
4893 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4896 # Public class: Mesh_Projection3D
4897 # ------------------------------
4899 ## Defines a projection 3D algorithm
4900 # @ingroup l3_algos_proj
4902 class Mesh_Projection3D(Mesh_Algorithm):
4904 ## Private constructor.
4905 def __init__(self, mesh, geom=0):
4906 Mesh_Algorithm.__init__(self)
4907 self.Create(mesh, geom, "Projection_3D")
4909 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4910 # the mesh pattern is taken, and, optionally, the association of vertices
4911 # between the source and the target solid (to which a hipothesis is assigned)
4912 # @param solid from where the mesh pattern is taken
4913 # @param mesh from where the mesh pattern is taken (optional)
4914 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4915 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4916 # to associate with \a srcV1 (optional)
4917 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4918 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4919 # to associate with \a srcV2 (optional)
4920 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4921 # the same parameters, else (default) - creates a new one
4923 # Note: association vertices must belong to one edge of a solid
4924 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4925 srcV2=0, tgtV2=0, UseExisting=0):
4926 hyp = self.Hypothesis("ProjectionSource3D",
4927 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4929 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4930 hyp.SetSource3DShape( solid )
4931 if not mesh is None and isinstance(mesh, Mesh):
4932 mesh = mesh.GetMesh()
4933 hyp.SetSourceMesh( mesh )
4934 if srcV1 and srcV2 and tgtV1 and tgtV2:
4935 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4936 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4939 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4940 #def CompareSourceShape3D(self, hyp, args):
4941 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4945 # Public class: Mesh_Prism
4946 # ------------------------
4948 ## Defines a 3D extrusion algorithm
4949 # @ingroup l3_algos_3dextr
4951 class Mesh_Prism3D(Mesh_Algorithm):
4953 ## Private constructor.
4954 def __init__(self, mesh, geom=0):
4955 Mesh_Algorithm.__init__(self)
4956 self.Create(mesh, geom, "Prism_3D")
4958 # Public class: Mesh_RadialPrism
4959 # -------------------------------
4961 ## Defines a Radial Prism 3D algorithm
4962 # @ingroup l3_algos_radialp
4964 class Mesh_RadialPrism3D(Mesh_Algorithm):
4966 ## Private constructor.
4967 def __init__(self, mesh, geom=0):
4968 Mesh_Algorithm.__init__(self)
4969 self.Create(mesh, geom, "RadialPrism_3D")
4971 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4972 self.nbLayers = None
4974 ## Return 3D hypothesis holding the 1D one
4975 def Get3DHypothesis(self):
4976 return self.distribHyp
4978 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4979 # hypothesis. Returns the created hypothesis
4980 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4981 #print "OwnHypothesis",hypType
4982 if not self.nbLayers is None:
4983 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4984 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4985 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4986 self.mesh.smeshpyD.SetCurrentStudy( None )
4987 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4988 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4989 self.distribHyp.SetLayerDistribution( hyp )
4992 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4993 # prisms to build between the inner and outer shells
4994 # @param n number of layers
4995 # @param UseExisting if ==true - searches for the existing hypothesis created with
4996 # the same parameters, else (default) - creates a new one
4997 def NumberOfLayers(self, n, UseExisting=0):
4998 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4999 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5000 CompareMethod=self.CompareNumberOfLayers)
5001 self.nbLayers.SetNumberOfLayers( n )
5002 return self.nbLayers
5004 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5005 def CompareNumberOfLayers(self, hyp, args):
5006 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5008 ## Defines "LocalLength" hypothesis, specifying the segment length
5009 # to build between the inner and the outer shells
5010 # @param l the length of segments
5011 # @param p the precision of rounding
5012 def LocalLength(self, l, p=1e-07):
5013 hyp = self.OwnHypothesis("LocalLength", [l,p])
5018 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5019 # prisms to build between the inner and the outer shells.
5020 # @param n the number of layers
5021 # @param s the scale factor (optional)
5022 def NumberOfSegments(self, n, s=[]):
5024 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5026 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5027 hyp.SetDistrType( 1 )
5028 hyp.SetScaleFactor(s)
5029 hyp.SetNumberOfSegments(n)
5032 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5033 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5034 # @param start the length of the first segment
5035 # @param end the length of the last segment
5036 def Arithmetic1D(self, start, end ):
5037 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5038 hyp.SetLength(start, 1)
5039 hyp.SetLength(end , 0)
5042 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5043 # to build between the inner and the outer shells as geometric length increasing
5044 # @param start for the length of the first segment
5045 # @param end for the length of the last segment
5046 def StartEndLength(self, start, end):
5047 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5048 hyp.SetLength(start, 1)
5049 hyp.SetLength(end , 0)
5052 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5053 # to build between the inner and outer shells
5054 # @param fineness defines the quality of the mesh within the range [0-1]
5055 def AutomaticLength(self, fineness=0):
5056 hyp = self.OwnHypothesis("AutomaticLength")
5057 hyp.SetFineness( fineness )
5060 # Public class: Mesh_RadialQuadrangle1D2D
5061 # -------------------------------
5063 ## Defines a Radial Quadrangle 1D2D algorithm
5064 # @ingroup l2_algos_radialq
5066 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5068 ## Private constructor.
5069 def __init__(self, mesh, geom=0):
5070 Mesh_Algorithm.__init__(self)
5071 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5073 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5074 self.nbLayers = None
5076 ## Return 2D hypothesis holding the 1D one
5077 def Get2DHypothesis(self):
5078 return self.distribHyp
5080 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5081 # hypothesis. Returns the created hypothesis
5082 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5083 #print "OwnHypothesis",hypType
5085 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5086 if self.distribHyp is None:
5087 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5089 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5090 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5091 self.mesh.smeshpyD.SetCurrentStudy( None )
5092 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5093 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5094 self.distribHyp.SetLayerDistribution( hyp )
5097 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5098 # @param n number of layers
5099 # @param UseExisting if ==true - searches for the existing hypothesis created with
5100 # the same parameters, else (default) - creates a new one
5101 def NumberOfLayers(self, n, UseExisting=0):
5103 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5104 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5105 CompareMethod=self.CompareNumberOfLayers)
5106 self.nbLayers.SetNumberOfLayers( n )
5107 return self.nbLayers
5109 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5110 def CompareNumberOfLayers(self, hyp, args):
5111 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5113 ## Defines "LocalLength" hypothesis, specifying the segment length
5114 # @param l the length of segments
5115 # @param p the precision of rounding
5116 def LocalLength(self, l, p=1e-07):
5117 hyp = self.OwnHypothesis("LocalLength", [l,p])
5122 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5123 # @param n the number of layers
5124 # @param s the scale factor (optional)
5125 def NumberOfSegments(self, n, s=[]):
5127 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5129 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5130 hyp.SetDistrType( 1 )
5131 hyp.SetScaleFactor(s)
5132 hyp.SetNumberOfSegments(n)
5135 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5136 # with a length that changes in arithmetic progression
5137 # @param start the length of the first segment
5138 # @param end the length of the last segment
5139 def Arithmetic1D(self, start, end ):
5140 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5141 hyp.SetLength(start, 1)
5142 hyp.SetLength(end , 0)
5145 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5146 # as geometric length increasing
5147 # @param start for the length of the first segment
5148 # @param end for the length of the last segment
5149 def StartEndLength(self, start, end):
5150 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5151 hyp.SetLength(start, 1)
5152 hyp.SetLength(end , 0)
5155 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5156 # @param fineness defines the quality of the mesh within the range [0-1]
5157 def AutomaticLength(self, fineness=0):
5158 hyp = self.OwnHypothesis("AutomaticLength")
5159 hyp.SetFineness( fineness )
5163 # Private class: Mesh_UseExisting
5164 # -------------------------------
5165 class Mesh_UseExisting(Mesh_Algorithm):
5167 def __init__(self, dim, mesh, geom=0):
5169 self.Create(mesh, geom, "UseExisting_1D")
5171 self.Create(mesh, geom, "UseExisting_2D")
5174 import salome_notebook
5175 notebook = salome_notebook.notebook
5177 ##Return values of the notebook variables
5178 def ParseParameters(last, nbParams,nbParam, value):
5182 listSize = len(last)
5183 for n in range(0,nbParams):
5185 if counter < listSize:
5186 strResult = strResult + last[counter]
5188 strResult = strResult + ""
5190 if isinstance(value, str):
5191 if notebook.isVariable(value):
5192 result = notebook.get(value)
5193 strResult=strResult+value
5195 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5197 strResult=strResult+str(value)
5199 if nbParams - 1 != counter:
5200 strResult=strResult+var_separator #":"
5202 return result, strResult
5204 #Wrapper class for StdMeshers_LocalLength hypothesis
5205 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5207 ## Set Length parameter value
5208 # @param length numerical value or name of variable from notebook
5209 def SetLength(self, length):
5210 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5211 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5212 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5214 ## Set Precision parameter value
5215 # @param precision numerical value or name of variable from notebook
5216 def SetPrecision(self, precision):
5217 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5218 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5219 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5221 #Registering the new proxy for LocalLength
5222 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5225 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5226 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5228 def SetLayerDistribution(self, hypo):
5229 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5230 hypo.ClearParameters();
5231 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5233 #Registering the new proxy for LayerDistribution
5234 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5236 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5237 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5239 ## Set Length parameter value
5240 # @param length numerical value or name of variable from notebook
5241 def SetLength(self, length):
5242 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5243 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5244 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5246 #Registering the new proxy for SegmentLengthAroundVertex
5247 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5250 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5251 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5253 ## Set Length parameter value
5254 # @param length numerical value or name of variable from notebook
5255 # @param isStart true is length is Start Length, otherwise false
5256 def SetLength(self, length, isStart):
5260 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5261 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5262 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5264 #Registering the new proxy for Arithmetic1D
5265 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5267 #Wrapper class for StdMeshers_Deflection1D hypothesis
5268 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5270 ## Set Deflection parameter value
5271 # @param deflection numerical value or name of variable from notebook
5272 def SetDeflection(self, deflection):
5273 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5274 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5275 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5277 #Registering the new proxy for Deflection1D
5278 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5280 #Wrapper class for StdMeshers_StartEndLength hypothesis
5281 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5283 ## Set Length parameter value
5284 # @param length numerical value or name of variable from notebook
5285 # @param isStart true is length is Start Length, otherwise false
5286 def SetLength(self, length, isStart):
5290 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5291 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5292 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5294 #Registering the new proxy for StartEndLength
5295 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5297 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5298 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5300 ## Set Max Element Area parameter value
5301 # @param area numerical value or name of variable from notebook
5302 def SetMaxElementArea(self, area):
5303 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5304 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5305 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5307 #Registering the new proxy for MaxElementArea
5308 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5311 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5312 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5314 ## Set Max Element Volume parameter value
5315 # @param volume numerical value or name of variable from notebook
5316 def SetMaxElementVolume(self, volume):
5317 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5318 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5319 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5321 #Registering the new proxy for MaxElementVolume
5322 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5325 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5326 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5328 ## Set Number Of Layers parameter value
5329 # @param nbLayers numerical value or name of variable from notebook
5330 def SetNumberOfLayers(self, nbLayers):
5331 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5332 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5333 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5335 #Registering the new proxy for NumberOfLayers
5336 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5338 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5339 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5341 ## Set Number Of Segments parameter value
5342 # @param nbSeg numerical value or name of variable from notebook
5343 def SetNumberOfSegments(self, nbSeg):
5344 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5345 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5346 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5347 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5349 ## Set Scale Factor parameter value
5350 # @param factor numerical value or name of variable from notebook
5351 def SetScaleFactor(self, factor):
5352 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5353 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5354 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5356 #Registering the new proxy for NumberOfSegments
5357 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5359 if not noNETGENPlugin:
5360 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5361 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5363 ## Set Max Size parameter value
5364 # @param maxsize numerical value or name of variable from notebook
5365 def SetMaxSize(self, maxsize):
5366 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5367 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5368 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5369 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5371 ## Set Growth Rate parameter value
5372 # @param value numerical value or name of variable from notebook
5373 def SetGrowthRate(self, value):
5374 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5375 value, parameters = ParseParameters(lastParameters,4,2,value)
5376 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5377 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5379 ## Set Number of Segments per Edge parameter value
5380 # @param value numerical value or name of variable from notebook
5381 def SetNbSegPerEdge(self, value):
5382 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5383 value, parameters = ParseParameters(lastParameters,4,3,value)
5384 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5385 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5387 ## Set Number of Segments per Radius parameter value
5388 # @param value numerical value or name of variable from notebook
5389 def SetNbSegPerRadius(self, value):
5390 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5391 value, parameters = ParseParameters(lastParameters,4,4,value)
5392 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5393 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5395 #Registering the new proxy for NETGENPlugin_Hypothesis
5396 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5399 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5400 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5403 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5404 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5406 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5407 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5409 ## Set Number of Segments parameter value
5410 # @param nbSeg numerical value or name of variable from notebook
5411 def SetNumberOfSegments(self, nbSeg):
5412 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5413 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5414 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5415 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5417 ## Set Local Length parameter value
5418 # @param length numerical value or name of variable from notebook
5419 def SetLocalLength(self, length):
5420 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5421 length, parameters = ParseParameters(lastParameters,2,1,length)
5422 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5423 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5425 ## Set Max Element Area parameter value
5426 # @param area numerical value or name of variable from notebook
5427 def SetMaxElementArea(self, area):
5428 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5429 area, parameters = ParseParameters(lastParameters,2,2,area)
5430 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5431 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5433 def LengthFromEdges(self):
5434 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5436 value, parameters = ParseParameters(lastParameters,2,2,value)
5437 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5438 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5440 #Registering the new proxy for NETGEN_SimpleParameters_2D
5441 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5444 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5445 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5446 ## Set Max Element Volume parameter value
5447 # @param volume numerical value or name of variable from notebook
5448 def SetMaxElementVolume(self, volume):
5449 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5450 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5451 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5452 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5454 def LengthFromFaces(self):
5455 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5457 value, parameters = ParseParameters(lastParameters,3,3,value)
5458 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5459 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5461 #Registering the new proxy for NETGEN_SimpleParameters_3D
5462 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5464 pass # if not noNETGENPlugin:
5466 class Pattern(SMESH._objref_SMESH_Pattern):
5468 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5470 if isinstance(theNodeIndexOnKeyPoint1,str):
5472 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5474 theNodeIndexOnKeyPoint1 -= 1
5475 theMesh.SetParameters(Parameters)
5476 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5478 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5481 if isinstance(theNode000Index,str):
5483 if isinstance(theNode001Index,str):
5485 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5487 theNode000Index -= 1
5489 theNode001Index -= 1
5490 theMesh.SetParameters(Parameters)
5491 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5493 #Registering the new proxy for Pattern
5494 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)