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:
459 print hypName, "was assigned to", geomName,"but", reason
461 print hypName, "was not assigned to",geomName,":", reason
464 ## Check meshing plugin availability
465 def CheckPlugin(plugin):
466 if plugin == NETGEN and noNETGENPlugin:
467 print "Warning: NETGENPlugin module unavailable"
469 elif plugin == GHS3D and noGHS3DPlugin:
470 print "Warning: GHS3DPlugin module unavailable"
472 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
473 print "Warning: GHS3DPRLPlugin module unavailable"
475 elif plugin == Hexotic and noHexoticPlugin:
476 print "Warning: HexoticPlugin module unavailable"
478 elif plugin == BLSURF and noBLSURFPlugin:
479 print "Warning: BLSURFPlugin module unavailable"
483 # end of l1_auxiliary
486 # All methods of this class are accessible directly from the smesh.py package.
487 class smeshDC(SMESH._objref_SMESH_Gen):
489 ## Sets the current study and Geometry component
490 # @ingroup l1_auxiliary
491 def init_smesh(self,theStudy,geompyD):
492 self.SetCurrentStudy(theStudy,geompyD)
494 ## Creates an empty Mesh. This mesh can have an underlying geometry.
495 # @param obj the Geometrical object on which the mesh is built. If not defined,
496 # the mesh will have no underlying geometry.
497 # @param name the name for the new mesh.
498 # @return an instance of Mesh class.
499 # @ingroup l2_construct
500 def Mesh(self, obj=0, name=0):
501 if isinstance(obj,str):
503 return Mesh(self,self.geompyD,obj,name)
505 ## Returns a long value from enumeration
506 # Should be used for SMESH.FunctorType enumeration
507 # @ingroup l1_controls
508 def EnumToLong(self,theItem):
511 ## Gets PointStruct from vertex
512 # @param theVertex a GEOM object(vertex)
513 # @return SMESH.PointStruct
514 # @ingroup l1_auxiliary
515 def GetPointStruct(self,theVertex):
516 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
517 return PointStruct(x,y,z)
519 ## Gets DirStruct from vector
520 # @param theVector a GEOM object(vector)
521 # @return SMESH.DirStruct
522 # @ingroup l1_auxiliary
523 def GetDirStruct(self,theVector):
524 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
525 if(len(vertices) != 2):
526 print "Error: vector object is incorrect."
528 p1 = self.geompyD.PointCoordinates(vertices[0])
529 p2 = self.geompyD.PointCoordinates(vertices[1])
530 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
531 dirst = DirStruct(pnt)
534 ## Makes DirStruct from a triplet
535 # @param x,y,z vector components
536 # @return SMESH.DirStruct
537 # @ingroup l1_auxiliary
538 def MakeDirStruct(self,x,y,z):
539 pnt = PointStruct(x,y,z)
540 return DirStruct(pnt)
542 ## Get AxisStruct from object
543 # @param theObj a GEOM object (line or plane)
544 # @return SMESH.AxisStruct
545 # @ingroup l1_auxiliary
546 def GetAxisStruct(self,theObj):
547 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
549 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
550 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
551 vertex1 = self.geompyD.PointCoordinates(vertex1)
552 vertex2 = self.geompyD.PointCoordinates(vertex2)
553 vertex3 = self.geompyD.PointCoordinates(vertex3)
554 vertex4 = self.geompyD.PointCoordinates(vertex4)
555 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
556 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
557 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] ]
558 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
560 elif len(edges) == 1:
561 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
562 p1 = self.geompyD.PointCoordinates( vertex1 )
563 p2 = self.geompyD.PointCoordinates( vertex2 )
564 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
568 # From SMESH_Gen interface:
569 # ------------------------
571 ## Sets the given name to the object
572 # @param obj the object to rename
573 # @param name a new object name
574 # @ingroup l1_auxiliary
575 def SetName(self, obj, name):
576 if isinstance( obj, Mesh ):
578 elif isinstance( obj, Mesh_Algorithm ):
579 obj = obj.GetAlgorithm()
580 ior = salome.orb.object_to_string(obj)
581 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
583 ## Sets the current mode
584 # @ingroup l1_auxiliary
585 def SetEmbeddedMode( self,theMode ):
586 #self.SetEmbeddedMode(theMode)
587 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
589 ## Gets the current mode
590 # @ingroup l1_auxiliary
591 def IsEmbeddedMode(self):
592 #return self.IsEmbeddedMode()
593 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
595 ## Sets the current study
596 # @ingroup l1_auxiliary
597 def SetCurrentStudy( self, theStudy, geompyD = None ):
598 #self.SetCurrentStudy(theStudy)
601 geompyD = geompy.geom
604 self.SetGeomEngine(geompyD)
605 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
607 ## Gets the current study
608 # @ingroup l1_auxiliary
609 def GetCurrentStudy(self):
610 #return self.GetCurrentStudy()
611 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
613 ## Creates a Mesh object importing data from the given UNV file
614 # @return an instance of Mesh class
616 def CreateMeshesFromUNV( self,theFileName ):
617 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
618 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
621 ## Creates a Mesh object(s) importing data from the given MED file
622 # @return a list of Mesh class instances
624 def CreateMeshesFromMED( self,theFileName ):
625 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
627 for iMesh in range(len(aSmeshMeshes)) :
628 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
629 aMeshes.append(aMesh)
630 return aMeshes, aStatus
632 ## Creates a Mesh object importing data from the given STL file
633 # @return an instance of Mesh class
635 def CreateMeshesFromSTL( self, theFileName ):
636 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
637 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
640 ## From SMESH_Gen interface
641 # @return the list of integer values
642 # @ingroup l1_auxiliary
643 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
644 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
646 ## From SMESH_Gen interface. Creates a pattern
647 # @return an instance of SMESH_Pattern
649 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
650 # @ingroup l2_modif_patterns
651 def GetPattern(self):
652 return SMESH._objref_SMESH_Gen.GetPattern(self)
654 ## Sets number of segments per diagonal of boundary box of geometry by which
655 # default segment length of appropriate 1D hypotheses is defined.
656 # Default value is 10
657 # @ingroup l1_auxiliary
658 def SetBoundaryBoxSegmentation(self, nbSegments):
659 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
661 ## Concatenate the given meshes into one mesh.
662 # @return an instance of Mesh class
663 # @param meshes the meshes to combine into one mesh
664 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
665 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
666 # @param mergeTolerance tolerance for merging nodes
667 # @param allGroups forces creation of groups of all elements
668 def Concatenate( self, meshes, uniteIdenticalGroups,
669 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
670 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
672 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
673 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
675 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
676 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
677 aSmeshMesh.SetParameters(Parameters)
678 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
681 # Filtering. Auxiliary functions:
682 # ------------------------------
684 ## Creates an empty criterion
685 # @return SMESH.Filter.Criterion
686 # @ingroup l1_controls
687 def GetEmptyCriterion(self):
688 Type = self.EnumToLong(FT_Undefined)
689 Compare = self.EnumToLong(FT_Undefined)
693 UnaryOp = self.EnumToLong(FT_Undefined)
694 BinaryOp = self.EnumToLong(FT_Undefined)
697 Precision = -1 ##@1e-07
698 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
699 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
701 ## Creates a criterion by the given parameters
702 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
703 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
704 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
705 # @param Treshold the threshold value (range of ids as string, shape, numeric)
706 # @param UnaryOp FT_LogicalNOT or FT_Undefined
707 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
708 # FT_Undefined (must be for the last criterion of all criteria)
709 # @return SMESH.Filter.Criterion
710 # @ingroup l1_controls
711 def GetCriterion(self,elementType,
713 Compare = FT_EqualTo,
715 UnaryOp=FT_Undefined,
716 BinaryOp=FT_Undefined):
717 aCriterion = self.GetEmptyCriterion()
718 aCriterion.TypeOfElement = elementType
719 aCriterion.Type = self.EnumToLong(CritType)
723 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
724 aCriterion.Compare = self.EnumToLong(Compare)
725 elif Compare == "=" or Compare == "==":
726 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
728 aCriterion.Compare = self.EnumToLong(FT_LessThan)
730 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
732 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
735 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
736 FT_BelongToCylinder, FT_LyingOnGeom]:
737 # Checks the treshold
738 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
739 aCriterion.ThresholdStr = GetName(aTreshold)
740 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
742 print "Error: The treshold should be a shape."
744 elif CritType == FT_RangeOfIds:
745 # Checks the treshold
746 if isinstance(aTreshold, str):
747 aCriterion.ThresholdStr = aTreshold
749 print "Error: The treshold should be a string."
751 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
752 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
753 # At this point the treshold is unnecessary
754 if aTreshold == FT_LogicalNOT:
755 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
756 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
757 aCriterion.BinaryOp = aTreshold
761 aTreshold = float(aTreshold)
762 aCriterion.Threshold = aTreshold
764 print "Error: The treshold should be a number."
767 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
768 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
770 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
771 aCriterion.BinaryOp = self.EnumToLong(Treshold)
773 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
774 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
776 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
777 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
781 ## Creates a filter with the given parameters
782 # @param elementType the type of elements in the group
783 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
784 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
785 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
786 # @param UnaryOp FT_LogicalNOT or FT_Undefined
787 # @return SMESH_Filter
788 # @ingroup l1_controls
789 def GetFilter(self,elementType,
790 CritType=FT_Undefined,
793 UnaryOp=FT_Undefined):
794 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
795 aFilterMgr = self.CreateFilterManager()
796 aFilter = aFilterMgr.CreateFilter()
798 aCriteria.append(aCriterion)
799 aFilter.SetCriteria(aCriteria)
802 ## Creates a numerical functor by its type
803 # @param theCriterion FT_...; functor type
804 # @return SMESH_NumericalFunctor
805 # @ingroup l1_controls
806 def GetFunctor(self,theCriterion):
807 aFilterMgr = self.CreateFilterManager()
808 if theCriterion == FT_AspectRatio:
809 return aFilterMgr.CreateAspectRatio()
810 elif theCriterion == FT_AspectRatio3D:
811 return aFilterMgr.CreateAspectRatio3D()
812 elif theCriterion == FT_Warping:
813 return aFilterMgr.CreateWarping()
814 elif theCriterion == FT_MinimumAngle:
815 return aFilterMgr.CreateMinimumAngle()
816 elif theCriterion == FT_Taper:
817 return aFilterMgr.CreateTaper()
818 elif theCriterion == FT_Skew:
819 return aFilterMgr.CreateSkew()
820 elif theCriterion == FT_Area:
821 return aFilterMgr.CreateArea()
822 elif theCriterion == FT_Volume3D:
823 return aFilterMgr.CreateVolume3D()
824 elif theCriterion == FT_MultiConnection:
825 return aFilterMgr.CreateMultiConnection()
826 elif theCriterion == FT_MultiConnection2D:
827 return aFilterMgr.CreateMultiConnection2D()
828 elif theCriterion == FT_Length:
829 return aFilterMgr.CreateLength()
830 elif theCriterion == FT_Length2D:
831 return aFilterMgr.CreateLength2D()
833 print "Error: given parameter is not numerucal functor type."
835 ## Creates hypothesis
836 # @param theHType mesh hypothesis type (string)
837 # @param theLibName mesh plug-in library name
838 # @return created hypothesis instance
839 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
840 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
842 ## Gets the mesh stattistic
843 # @return dictionary type element - count of elements
844 # @ingroup l1_meshinfo
845 def GetMeshInfo(self, obj):
846 if isinstance( obj, Mesh ):
849 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
850 values = obj.GetMeshInfo()
851 for i in range(SMESH.Entity_Last._v):
852 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
857 #Registering the new proxy for SMESH_Gen
858 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
864 ## This class allows defining and managing a mesh.
865 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
866 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
867 # new nodes and elements and by changing the existing entities), to get information
868 # about a mesh and to export a mesh into different formats.
877 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
878 # sets the GUI name of this mesh to \a name.
879 # @param smeshpyD an instance of smeshDC class
880 # @param geompyD an instance of geompyDC class
881 # @param obj Shape to be meshed or SMESH_Mesh object
882 # @param name Study name of the mesh
883 # @ingroup l2_construct
884 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
885 self.smeshpyD=smeshpyD
890 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
892 self.mesh = self.smeshpyD.CreateMesh(self.geom)
893 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
896 self.mesh = self.smeshpyD.CreateEmptyMesh()
898 self.smeshpyD.SetName(self.mesh, name)
900 self.smeshpyD.SetName(self.mesh, GetName(obj))
903 self.geom = self.mesh.GetShapeToMesh()
905 self.editor = self.mesh.GetMeshEditor()
907 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
908 # @param theMesh a SMESH_Mesh object
909 # @ingroup l2_construct
910 def SetMesh(self, theMesh):
912 self.geom = self.mesh.GetShapeToMesh()
914 ## Returns the mesh, that is an instance of SMESH_Mesh interface
915 # @return a SMESH_Mesh object
916 # @ingroup l2_construct
920 ## Gets the name of the mesh
921 # @return the name of the mesh as a string
922 # @ingroup l2_construct
924 name = GetName(self.GetMesh())
927 ## Sets a name to the mesh
928 # @param name a new name of the mesh
929 # @ingroup l2_construct
930 def SetName(self, name):
931 self.smeshpyD.SetName(self.GetMesh(), name)
933 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
934 # The subMesh object gives access to the IDs of nodes and elements.
935 # @param theSubObject a geometrical object (shape)
936 # @param theName a name for the submesh
937 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
938 # @ingroup l2_submeshes
939 def GetSubMesh(self, theSubObject, theName):
940 submesh = self.mesh.GetSubMesh(theSubObject, theName)
943 ## Returns the shape associated to the mesh
944 # @return a GEOM_Object
945 # @ingroup l2_construct
949 ## Associates the given shape to the mesh (entails the recreation of the mesh)
950 # @param geom the shape to be meshed (GEOM_Object)
951 # @ingroup l2_construct
952 def SetShape(self, geom):
953 self.mesh = self.smeshpyD.CreateMesh(geom)
955 ## Returns true if the hypotheses are defined well
956 # @param theSubObject a subshape of a mesh shape
957 # @return True or False
958 # @ingroup l2_construct
959 def IsReadyToCompute(self, theSubObject):
960 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
962 ## Returns errors of hypotheses definition.
963 # The list of errors is empty if everything is OK.
964 # @param theSubObject a subshape of a mesh shape
965 # @return a list of errors
966 # @ingroup l2_construct
967 def GetAlgoState(self, theSubObject):
968 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
970 ## Returns a geometrical object on which the given element was built.
971 # The returned geometrical object, if not nil, is either found in the
972 # study or published by this method with the given name
973 # @param theElementID the id of the mesh element
974 # @param theGeomName the user-defined name of the geometrical object
975 # @return GEOM::GEOM_Object instance
976 # @ingroup l2_construct
977 def GetGeometryByMeshElement(self, theElementID, theGeomName):
978 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
980 ## Returns the mesh dimension depending on the dimension of the underlying shape
981 # @return mesh dimension as an integer value [0,3]
982 # @ingroup l1_auxiliary
983 def MeshDimension(self):
984 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
985 if len( shells ) > 0 :
987 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
989 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
995 ## Creates a segment discretization 1D algorithm.
996 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
997 # \n If the optional \a geom parameter is not set, this algorithm is global.
998 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
999 # @param algo the type of the required algorithm. Possible values are:
1001 # - smesh.PYTHON for discretization via a python function,
1002 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1003 # @param geom If defined is the subshape to be meshed
1004 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1005 # @ingroup l3_algos_basic
1006 def Segment(self, algo=REGULAR, geom=0):
1007 ## if Segment(geom) is called by mistake
1008 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1009 algo, geom = geom, algo
1010 if not algo: algo = REGULAR
1013 return Mesh_Segment(self, geom)
1014 elif algo == PYTHON:
1015 return Mesh_Segment_Python(self, geom)
1016 elif algo == COMPOSITE:
1017 return Mesh_CompositeSegment(self, geom)
1019 return Mesh_Segment(self, geom)
1021 ## Enables creation of nodes and segments usable by 2D algoritms.
1022 # The added nodes and segments must be bound to edges and vertices by
1023 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1024 # If the optional \a geom parameter is not set, this algorithm is global.
1025 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1026 # @param geom the subshape to be manually meshed
1027 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1028 # @ingroup l3_algos_basic
1029 def UseExistingSegments(self, geom=0):
1030 algo = Mesh_UseExisting(1,self,geom)
1031 return algo.GetAlgorithm()
1033 ## Enables creation of nodes and faces usable by 3D algoritms.
1034 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1035 # and SetMeshElementOnShape()
1036 # If the optional \a geom parameter is not set, this algorithm is global.
1037 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1038 # @param geom the subshape to be manually meshed
1039 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1040 # @ingroup l3_algos_basic
1041 def UseExistingFaces(self, geom=0):
1042 algo = Mesh_UseExisting(2,self,geom)
1043 return algo.GetAlgorithm()
1045 ## Creates a triangle 2D algorithm for faces.
1046 # If the optional \a geom parameter is not set, this algorithm is global.
1047 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1048 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1049 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1050 # @return an instance of Mesh_Triangle algorithm
1051 # @ingroup l3_algos_basic
1052 def Triangle(self, algo=MEFISTO, geom=0):
1053 ## if Triangle(geom) is called by mistake
1054 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1057 return Mesh_Triangle(self, algo, geom)
1059 ## Creates a quadrangle 2D algorithm for faces.
1060 # If the optional \a geom parameter is not set, this algorithm is global.
1061 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1062 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1063 # @param algo values are: smesh.QUARDANGLE || smesh.RADIAL_QUAD
1064 # @return an instance of Mesh_Quadrangle algorithm
1065 # @ingroup l3_algos_basic
1066 def Quadrangle(self, geom=0, algo=QUARDANGLE):
1067 if algo==RADIAL_QUAD:
1068 return Mesh_RadialQuadrangle1D2D(self,geom)
1070 return Mesh_Quadrangle(self, geom)
1072 ## Creates a tetrahedron 3D algorithm for solids.
1073 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1074 # If the optional \a geom parameter is not set, this algorithm is global.
1075 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1076 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1077 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1078 # @return an instance of Mesh_Tetrahedron algorithm
1079 # @ingroup l3_algos_basic
1080 def Tetrahedron(self, algo=NETGEN, geom=0):
1081 ## if Tetrahedron(geom) is called by mistake
1082 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1083 algo, geom = geom, algo
1084 if not algo: algo = NETGEN
1086 return Mesh_Tetrahedron(self, algo, geom)
1088 ## Creates a hexahedron 3D algorithm for solids.
1089 # If the optional \a geom parameter is not set, this algorithm is global.
1090 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1091 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1092 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1093 # @return an instance of Mesh_Hexahedron algorithm
1094 # @ingroup l3_algos_basic
1095 def Hexahedron(self, algo=Hexa, geom=0):
1096 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1097 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1098 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1099 elif geom == 0: algo, geom = Hexa, algo
1100 return Mesh_Hexahedron(self, algo, geom)
1102 ## Deprecated, used only for compatibility!
1103 # @return an instance of Mesh_Netgen algorithm
1104 # @ingroup l3_algos_basic
1105 def Netgen(self, is3D, geom=0):
1106 return Mesh_Netgen(self, is3D, geom)
1108 ## Creates a projection 1D algorithm for edges.
1109 # If the optional \a geom parameter is not set, this algorithm is global.
1110 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1111 # @param geom If defined, the subshape to be meshed
1112 # @return an instance of Mesh_Projection1D algorithm
1113 # @ingroup l3_algos_proj
1114 def Projection1D(self, geom=0):
1115 return Mesh_Projection1D(self, geom)
1117 ## Creates a projection 2D algorithm for faces.
1118 # If the optional \a geom parameter is not set, this algorithm is global.
1119 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1120 # @param geom If defined, the subshape to be meshed
1121 # @return an instance of Mesh_Projection2D algorithm
1122 # @ingroup l3_algos_proj
1123 def Projection2D(self, geom=0):
1124 return Mesh_Projection2D(self, geom)
1126 ## Creates a projection 3D algorithm for solids.
1127 # If the optional \a geom parameter is not set, this algorithm is global.
1128 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1129 # @param geom If defined, the subshape to be meshed
1130 # @return an instance of Mesh_Projection3D algorithm
1131 # @ingroup l3_algos_proj
1132 def Projection3D(self, geom=0):
1133 return Mesh_Projection3D(self, geom)
1135 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1136 # If the optional \a geom parameter is not set, this algorithm is global.
1137 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1138 # @param geom If defined, the subshape to be meshed
1139 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1140 # @ingroup l3_algos_radialp l3_algos_3dextr
1141 def Prism(self, geom=0):
1145 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1146 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1147 if nbSolids == 0 or nbSolids == nbShells:
1148 return Mesh_Prism3D(self, geom)
1149 return Mesh_RadialPrism3D(self, geom)
1151 ## Evaluates size of prospective mesh on a shape
1152 # @return True or False
1153 def Evaluate(self, geom=0):
1154 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1156 geom = self.mesh.GetShapeToMesh()
1159 return self.smeshpyD.Evaluate(self.mesh, geom)
1162 ## Computes the mesh and returns the status of the computation
1163 # @return True or False
1164 # @ingroup l2_construct
1165 def Compute(self, geom=0):
1166 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1168 geom = self.mesh.GetShapeToMesh()
1173 ok = self.smeshpyD.Compute(self.mesh, geom)
1174 except SALOME.SALOME_Exception, ex:
1175 print "Mesh computation failed, exception caught:"
1176 print " ", ex.details.text
1179 print "Mesh computation failed, exception caught:"
1180 traceback.print_exc()
1182 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1185 if err.isGlobalAlgo:
1193 reason = '%s %sD algorithm is missing' % (glob, dim)
1194 elif err.state == HYP_MISSING:
1195 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1196 % (glob, dim, name, dim))
1197 elif err.state == HYP_NOTCONFORM:
1198 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1199 elif err.state == HYP_BAD_PARAMETER:
1200 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1201 % ( glob, dim, name ))
1202 elif err.state == HYP_BAD_GEOMETRY:
1203 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1204 'geometry' % ( glob, dim, name ))
1206 reason = "For unknown reason."+\
1207 " Revise Mesh.Compute() implementation in smeshDC.py!"
1209 if allReasons != "":
1212 allReasons += reason
1214 if allReasons != "":
1215 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1219 print '"' + GetName(self.mesh) + '"',"has not been computed."
1222 if salome.sg.hasDesktop():
1223 smeshgui = salome.ImportComponentGUI("SMESH")
1224 smeshgui.Init(self.mesh.GetStudyId())
1225 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1226 salome.sg.updateObjBrowser(1)
1230 ## Return submesh objects list in meshing order
1231 # @return list of list of submesh objects
1232 # @ingroup l2_construct
1233 def GetMeshOrder(self):
1234 return self.mesh.GetMeshOrder()
1236 ## Return submesh objects list in meshing order
1237 # @return list of list of submesh objects
1238 # @ingroup l2_construct
1239 def SetMeshOrder(self, submeshes):
1240 return self.mesh.SetMeshOrder(submeshes)
1242 ## Removes all nodes and elements
1243 # @ingroup l2_construct
1246 if salome.sg.hasDesktop():
1247 smeshgui = salome.ImportComponentGUI("SMESH")
1248 smeshgui.Init(self.mesh.GetStudyId())
1249 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1250 salome.sg.updateObjBrowser(1)
1252 ## Removes all nodes and elements of indicated shape
1253 # @ingroup l2_construct
1254 def ClearSubMesh(self, geomId):
1255 self.mesh.ClearSubMesh(geomId)
1256 if salome.sg.hasDesktop():
1257 smeshgui = salome.ImportComponentGUI("SMESH")
1258 smeshgui.Init(self.mesh.GetStudyId())
1259 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1260 salome.sg.updateObjBrowser(1)
1262 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1263 # @param fineness [0,-1] defines mesh fineness
1264 # @return True or False
1265 # @ingroup l3_algos_basic
1266 def AutomaticTetrahedralization(self, fineness=0):
1267 dim = self.MeshDimension()
1269 self.RemoveGlobalHypotheses()
1270 self.Segment().AutomaticLength(fineness)
1272 self.Triangle().LengthFromEdges()
1275 self.Tetrahedron(NETGEN)
1277 return self.Compute()
1279 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1280 # @param fineness [0,-1] defines mesh fineness
1281 # @return True or False
1282 # @ingroup l3_algos_basic
1283 def AutomaticHexahedralization(self, fineness=0):
1284 dim = self.MeshDimension()
1285 # assign the hypotheses
1286 self.RemoveGlobalHypotheses()
1287 self.Segment().AutomaticLength(fineness)
1294 return self.Compute()
1296 ## Assigns a hypothesis
1297 # @param hyp a hypothesis to assign
1298 # @param geom a subhape of mesh geometry
1299 # @return SMESH.Hypothesis_Status
1300 # @ingroup l2_hypotheses
1301 def AddHypothesis(self, hyp, geom=0):
1302 if isinstance( hyp, Mesh_Algorithm ):
1303 hyp = hyp.GetAlgorithm()
1308 geom = self.mesh.GetShapeToMesh()
1310 status = self.mesh.AddHypothesis(geom, hyp)
1311 isAlgo = hyp._narrow( SMESH_Algo )
1312 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1315 ## Unassigns a hypothesis
1316 # @param hyp a hypothesis to unassign
1317 # @param geom a subshape of mesh geometry
1318 # @return SMESH.Hypothesis_Status
1319 # @ingroup l2_hypotheses
1320 def RemoveHypothesis(self, hyp, geom=0):
1321 if isinstance( hyp, Mesh_Algorithm ):
1322 hyp = hyp.GetAlgorithm()
1327 status = self.mesh.RemoveHypothesis(geom, hyp)
1330 ## Gets the list of hypotheses added on a geometry
1331 # @param geom a subshape of mesh geometry
1332 # @return the sequence of SMESH_Hypothesis
1333 # @ingroup l2_hypotheses
1334 def GetHypothesisList(self, geom):
1335 return self.mesh.GetHypothesisList( geom )
1337 ## Removes all global hypotheses
1338 # @ingroup l2_hypotheses
1339 def RemoveGlobalHypotheses(self):
1340 current_hyps = self.mesh.GetHypothesisList( self.geom )
1341 for hyp in current_hyps:
1342 self.mesh.RemoveHypothesis( self.geom, hyp )
1346 ## Creates a mesh group based on the geometric object \a grp
1347 # and gives a \a name, \n if this parameter is not defined
1348 # the name is the same as the geometric group name \n
1349 # Note: Works like GroupOnGeom().
1350 # @param grp a geometric group, a vertex, an edge, a face or a solid
1351 # @param name the name of the mesh group
1352 # @return SMESH_GroupOnGeom
1353 # @ingroup l2_grps_create
1354 def Group(self, grp, name=""):
1355 return self.GroupOnGeom(grp, name)
1357 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1358 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1359 # @param f the file name
1360 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1361 # @param opt boolean parameter for creating/not creating
1362 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1363 # @ingroup l2_impexp
1364 def ExportToMED(self, f, version, opt=0):
1365 self.mesh.ExportToMED(f, opt, version)
1367 ## Exports the mesh in a file in MED format
1368 # @param f is the file name
1369 # @param auto_groups boolean parameter for creating/not creating
1370 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1371 # the typical use is auto_groups=false.
1372 # @param version MED format version(MED_V2_1 or MED_V2_2)
1373 # @ingroup l2_impexp
1374 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1375 self.mesh.ExportToMED(f, auto_groups, version)
1377 ## Exports the mesh in a file in DAT format
1378 # @param f the file name
1379 # @ingroup l2_impexp
1380 def ExportDAT(self, f):
1381 self.mesh.ExportDAT(f)
1383 ## Exports the mesh in a file in UNV format
1384 # @param f the file name
1385 # @ingroup l2_impexp
1386 def ExportUNV(self, f):
1387 self.mesh.ExportUNV(f)
1389 ## Export the mesh in a file in STL format
1390 # @param f the file name
1391 # @param ascii defines the file encoding
1392 # @ingroup l2_impexp
1393 def ExportSTL(self, f, ascii=1):
1394 self.mesh.ExportSTL(f, ascii)
1397 # Operations with groups:
1398 # ----------------------
1400 ## Creates an empty mesh group
1401 # @param elementType the type of elements in the group
1402 # @param name the name of the mesh group
1403 # @return SMESH_Group
1404 # @ingroup l2_grps_create
1405 def CreateEmptyGroup(self, elementType, name):
1406 return self.mesh.CreateGroup(elementType, name)
1408 ## Creates a mesh group based on the geometrical object \a grp
1409 # and gives a \a name, \n if this parameter is not defined
1410 # the name is the same as the geometrical group name
1411 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1412 # @param name the name of the mesh group
1413 # @param typ the type of elements in the group. If not set, it is
1414 # automatically detected by the type of the geometry
1415 # @return SMESH_GroupOnGeom
1416 # @ingroup l2_grps_create
1417 def GroupOnGeom(self, grp, name="", typ=None):
1419 name = grp.GetName()
1422 tgeo = str(grp.GetShapeType())
1423 if tgeo == "VERTEX":
1425 elif tgeo == "EDGE":
1427 elif tgeo == "FACE":
1429 elif tgeo == "SOLID":
1431 elif tgeo == "SHELL":
1433 elif tgeo == "COMPOUND":
1434 try: # it raises on a compound of compounds
1435 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1436 print "Mesh.Group: empty geometric group", GetName( grp )
1441 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1443 tgeo = self.geompyD.GetType(grp)
1444 if tgeo == geompyDC.ShapeType["VERTEX"]:
1446 elif tgeo == geompyDC.ShapeType["EDGE"]:
1448 elif tgeo == geompyDC.ShapeType["FACE"]:
1450 elif tgeo == geompyDC.ShapeType["SOLID"]:
1456 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1457 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1458 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1466 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1469 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1471 ## Creates a mesh group by the given ids of elements
1472 # @param groupName the name of the mesh group
1473 # @param elementType the type of elements in the group
1474 # @param elemIDs the list of ids
1475 # @return SMESH_Group
1476 # @ingroup l2_grps_create
1477 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1478 group = self.mesh.CreateGroup(elementType, groupName)
1482 ## Creates a mesh group by the given conditions
1483 # @param groupName the name of the mesh group
1484 # @param elementType the type of elements in the group
1485 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1486 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1487 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1488 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1489 # @return SMESH_Group
1490 # @ingroup l2_grps_create
1494 CritType=FT_Undefined,
1497 UnaryOp=FT_Undefined):
1498 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1499 group = self.MakeGroupByCriterion(groupName, aCriterion)
1502 ## Creates a mesh group by the given criterion
1503 # @param groupName the name of the mesh group
1504 # @param Criterion the instance of Criterion class
1505 # @return SMESH_Group
1506 # @ingroup l2_grps_create
1507 def MakeGroupByCriterion(self, groupName, Criterion):
1508 aFilterMgr = self.smeshpyD.CreateFilterManager()
1509 aFilter = aFilterMgr.CreateFilter()
1511 aCriteria.append(Criterion)
1512 aFilter.SetCriteria(aCriteria)
1513 group = self.MakeGroupByFilter(groupName, aFilter)
1516 ## Creates a mesh group by the given criteria (list of criteria)
1517 # @param groupName the name of the mesh group
1518 # @param theCriteria the list of criteria
1519 # @return SMESH_Group
1520 # @ingroup l2_grps_create
1521 def MakeGroupByCriteria(self, groupName, theCriteria):
1522 aFilterMgr = self.smeshpyD.CreateFilterManager()
1523 aFilter = aFilterMgr.CreateFilter()
1524 aFilter.SetCriteria(theCriteria)
1525 group = self.MakeGroupByFilter(groupName, aFilter)
1528 ## Creates a mesh group by the given filter
1529 # @param groupName the name of the mesh group
1530 # @param theFilter the instance of Filter class
1531 # @return SMESH_Group
1532 # @ingroup l2_grps_create
1533 def MakeGroupByFilter(self, groupName, theFilter):
1534 anIds = theFilter.GetElementsId(self.mesh)
1535 anElemType = theFilter.GetElementType()
1536 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1539 ## Passes mesh elements through the given filter and return IDs of fitting elements
1540 # @param theFilter SMESH_Filter
1541 # @return a list of ids
1542 # @ingroup l1_controls
1543 def GetIdsFromFilter(self, theFilter):
1544 return theFilter.GetElementsId(self.mesh)
1546 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1547 # Returns a list of special structures (borders).
1548 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1549 # @ingroup l1_controls
1550 def GetFreeBorders(self):
1551 aFilterMgr = self.smeshpyD.CreateFilterManager()
1552 aPredicate = aFilterMgr.CreateFreeEdges()
1553 aPredicate.SetMesh(self.mesh)
1554 aBorders = aPredicate.GetBorders()
1558 # @ingroup l2_grps_delete
1559 def RemoveGroup(self, group):
1560 self.mesh.RemoveGroup(group)
1562 ## Removes a group with its contents
1563 # @ingroup l2_grps_delete
1564 def RemoveGroupWithContents(self, group):
1565 self.mesh.RemoveGroupWithContents(group)
1567 ## Gets the list of groups existing in the mesh
1568 # @return a sequence of SMESH_GroupBase
1569 # @ingroup l2_grps_create
1570 def GetGroups(self):
1571 return self.mesh.GetGroups()
1573 ## Gets the number of groups existing in the mesh
1574 # @return the quantity of groups as an integer value
1575 # @ingroup l2_grps_create
1577 return self.mesh.NbGroups()
1579 ## Gets the list of names of groups existing in the mesh
1580 # @return list of strings
1581 # @ingroup l2_grps_create
1582 def GetGroupNames(self):
1583 groups = self.GetGroups()
1585 for group in groups:
1586 names.append(group.GetName())
1589 ## Produces a union of two groups
1590 # A new group is created. All mesh elements that are
1591 # present in the initial groups are added to the new one
1592 # @return an instance of SMESH_Group
1593 # @ingroup l2_grps_operon
1594 def UnionGroups(self, group1, group2, name):
1595 return self.mesh.UnionGroups(group1, group2, name)
1597 ## Produces a union list of groups
1598 # New group is created. All mesh elements that are present in
1599 # initial groups are added to the new one
1600 # @return an instance of SMESH_Group
1601 # @ingroup l2_grps_operon
1602 def UnionListOfGroups(self, groups, name):
1603 return self.mesh.UnionListOfGroups(groups, name)
1605 ## Prodices an intersection of two groups
1606 # A new group is created. All mesh elements that are common
1607 # for the two initial groups are added to the new one.
1608 # @return an instance of SMESH_Group
1609 # @ingroup l2_grps_operon
1610 def IntersectGroups(self, group1, group2, name):
1611 return self.mesh.IntersectGroups(group1, group2, name)
1613 ## Produces an intersection of groups
1614 # New group is created. All mesh elements that are present in all
1615 # initial groups simultaneously are added to the new one
1616 # @return an instance of SMESH_Group
1617 # @ingroup l2_grps_operon
1618 def IntersectListOfGroups(self, groups, name):
1619 return self.mesh.IntersectListOfGroups(groups, name)
1621 ## Produces a cut of two groups
1622 # A new group is created. All mesh elements that are present in
1623 # the main group but are not present in the tool group are added to the new one
1624 # @return an instance of SMESH_Group
1625 # @ingroup l2_grps_operon
1626 def CutGroups(self, main_group, tool_group, name):
1627 return self.mesh.CutGroups(main_group, tool_group, name)
1629 ## Produces a cut of groups
1630 # A new group is created. All mesh elements that are present in main groups
1631 # but do not present in tool groups are added to the new one
1632 # @return an instance of SMESH_Group
1633 # @ingroup l2_grps_operon
1634 def CutListOfGroups(self, main_groups, tool_groups, name):
1635 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1637 ## Produces a group of elements with specified element type using list of existing groups
1638 # A new group is created. System
1639 # 1) extract all nodes on which groups elements are built
1640 # 2) combine all elements of specified dimension laying on these nodes
1641 # @return an instance of SMESH_Group
1642 # @ingroup l2_grps_operon
1643 def CreateDimGroup(self, groups, elem_type, name):
1644 return self.mesh.CreateDimGroup(groups, elem_type, name)
1647 ## Convert group on geom into standalone group
1648 # @ingroup l2_grps_delete
1649 def ConvertToStandalone(self, group):
1650 return self.mesh.ConvertToStandalone(group)
1652 # Get some info about mesh:
1653 # ------------------------
1655 ## Returns the log of nodes and elements added or removed
1656 # since the previous clear of the log.
1657 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1658 # @return list of log_block structures:
1663 # @ingroup l1_auxiliary
1664 def GetLog(self, clearAfterGet):
1665 return self.mesh.GetLog(clearAfterGet)
1667 ## Clears the log of nodes and elements added or removed since the previous
1668 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1669 # @ingroup l1_auxiliary
1671 self.mesh.ClearLog()
1673 ## Toggles auto color mode on the object.
1674 # @param theAutoColor the flag which toggles auto color mode.
1675 # @ingroup l1_auxiliary
1676 def SetAutoColor(self, theAutoColor):
1677 self.mesh.SetAutoColor(theAutoColor)
1679 ## Gets flag of object auto color mode.
1680 # @return True or False
1681 # @ingroup l1_auxiliary
1682 def GetAutoColor(self):
1683 return self.mesh.GetAutoColor()
1685 ## Gets the internal ID
1686 # @return integer value, which is the internal Id of the mesh
1687 # @ingroup l1_auxiliary
1689 return self.mesh.GetId()
1692 # @return integer value, which is the study Id of the mesh
1693 # @ingroup l1_auxiliary
1694 def GetStudyId(self):
1695 return self.mesh.GetStudyId()
1697 ## Checks the group names for duplications.
1698 # Consider the maximum group name length stored in MED file.
1699 # @return True or False
1700 # @ingroup l1_auxiliary
1701 def HasDuplicatedGroupNamesMED(self):
1702 return self.mesh.HasDuplicatedGroupNamesMED()
1704 ## Obtains the mesh editor tool
1705 # @return an instance of SMESH_MeshEditor
1706 # @ingroup l1_modifying
1707 def GetMeshEditor(self):
1708 return self.mesh.GetMeshEditor()
1711 # @return an instance of SALOME_MED::MESH
1712 # @ingroup l1_auxiliary
1713 def GetMEDMesh(self):
1714 return self.mesh.GetMEDMesh()
1717 # Get informations about mesh contents:
1718 # ------------------------------------
1720 ## Gets the mesh stattistic
1721 # @return dictionary type element - count of elements
1722 # @ingroup l1_meshinfo
1723 def GetMeshInfo(self, obj = None):
1724 if not obj: obj = self.mesh
1725 return self.smeshpyD.GetMeshInfo(obj)
1727 ## Returns the number of nodes in the mesh
1728 # @return an integer value
1729 # @ingroup l1_meshinfo
1731 return self.mesh.NbNodes()
1733 ## Returns the number of elements in the mesh
1734 # @return an integer value
1735 # @ingroup l1_meshinfo
1736 def NbElements(self):
1737 return self.mesh.NbElements()
1739 ## Returns the number of 0d elements in the mesh
1740 # @return an integer value
1741 # @ingroup l1_meshinfo
1742 def Nb0DElements(self):
1743 return self.mesh.Nb0DElements()
1745 ## Returns the number of edges in the mesh
1746 # @return an integer value
1747 # @ingroup l1_meshinfo
1749 return self.mesh.NbEdges()
1751 ## Returns the number of edges with the given order in the mesh
1752 # @param elementOrder the order of elements:
1753 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1754 # @return an integer value
1755 # @ingroup l1_meshinfo
1756 def NbEdgesOfOrder(self, elementOrder):
1757 return self.mesh.NbEdgesOfOrder(elementOrder)
1759 ## Returns the number of faces in the mesh
1760 # @return an integer value
1761 # @ingroup l1_meshinfo
1763 return self.mesh.NbFaces()
1765 ## Returns the number of faces with the given order in the mesh
1766 # @param elementOrder the order of elements:
1767 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1768 # @return an integer value
1769 # @ingroup l1_meshinfo
1770 def NbFacesOfOrder(self, elementOrder):
1771 return self.mesh.NbFacesOfOrder(elementOrder)
1773 ## Returns the number of triangles in the mesh
1774 # @return an integer value
1775 # @ingroup l1_meshinfo
1776 def NbTriangles(self):
1777 return self.mesh.NbTriangles()
1779 ## Returns the number of triangles with the given order in the mesh
1780 # @param elementOrder is the order of elements:
1781 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1782 # @return an integer value
1783 # @ingroup l1_meshinfo
1784 def NbTrianglesOfOrder(self, elementOrder):
1785 return self.mesh.NbTrianglesOfOrder(elementOrder)
1787 ## Returns the number of quadrangles in the mesh
1788 # @return an integer value
1789 # @ingroup l1_meshinfo
1790 def NbQuadrangles(self):
1791 return self.mesh.NbQuadrangles()
1793 ## Returns the number of quadrangles with the given order in the mesh
1794 # @param elementOrder the order of elements:
1795 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1796 # @return an integer value
1797 # @ingroup l1_meshinfo
1798 def NbQuadranglesOfOrder(self, elementOrder):
1799 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1801 ## Returns the number of polygons in the mesh
1802 # @return an integer value
1803 # @ingroup l1_meshinfo
1804 def NbPolygons(self):
1805 return self.mesh.NbPolygons()
1807 ## Returns the number of volumes in the mesh
1808 # @return an integer value
1809 # @ingroup l1_meshinfo
1810 def NbVolumes(self):
1811 return self.mesh.NbVolumes()
1813 ## Returns the number of volumes with the given order in the mesh
1814 # @param elementOrder the order of elements:
1815 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1816 # @return an integer value
1817 # @ingroup l1_meshinfo
1818 def NbVolumesOfOrder(self, elementOrder):
1819 return self.mesh.NbVolumesOfOrder(elementOrder)
1821 ## Returns the number of tetrahedrons in the mesh
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1825 return self.mesh.NbTetras()
1827 ## Returns the number of tetrahedrons with the given order in the mesh
1828 # @param elementOrder the order of elements:
1829 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1830 # @return an integer value
1831 # @ingroup l1_meshinfo
1832 def NbTetrasOfOrder(self, elementOrder):
1833 return self.mesh.NbTetrasOfOrder(elementOrder)
1835 ## Returns the number of hexahedrons in the mesh
1836 # @return an integer value
1837 # @ingroup l1_meshinfo
1839 return self.mesh.NbHexas()
1841 ## Returns the number of hexahedrons with the given order in the mesh
1842 # @param elementOrder the order of elements:
1843 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1844 # @return an integer value
1845 # @ingroup l1_meshinfo
1846 def NbHexasOfOrder(self, elementOrder):
1847 return self.mesh.NbHexasOfOrder(elementOrder)
1849 ## Returns the number of pyramids in the mesh
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def NbPyramids(self):
1853 return self.mesh.NbPyramids()
1855 ## Returns the number of pyramids with the given order in the mesh
1856 # @param elementOrder the order of elements:
1857 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1858 # @return an integer value
1859 # @ingroup l1_meshinfo
1860 def NbPyramidsOfOrder(self, elementOrder):
1861 return self.mesh.NbPyramidsOfOrder(elementOrder)
1863 ## Returns the number of prisms in the mesh
1864 # @return an integer value
1865 # @ingroup l1_meshinfo
1867 return self.mesh.NbPrisms()
1869 ## Returns the number of prisms with the given order in the mesh
1870 # @param elementOrder the order of elements:
1871 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1872 # @return an integer value
1873 # @ingroup l1_meshinfo
1874 def NbPrismsOfOrder(self, elementOrder):
1875 return self.mesh.NbPrismsOfOrder(elementOrder)
1877 ## Returns the number of polyhedrons in the mesh
1878 # @return an integer value
1879 # @ingroup l1_meshinfo
1880 def NbPolyhedrons(self):
1881 return self.mesh.NbPolyhedrons()
1883 ## Returns the number of submeshes in the mesh
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1886 def NbSubMesh(self):
1887 return self.mesh.NbSubMesh()
1889 ## Returns the list of mesh elements IDs
1890 # @return the list of integer values
1891 # @ingroup l1_meshinfo
1892 def GetElementsId(self):
1893 return self.mesh.GetElementsId()
1895 ## Returns the list of IDs of mesh elements with the given type
1896 # @param elementType the required type of elements
1897 # @return list of integer values
1898 # @ingroup l1_meshinfo
1899 def GetElementsByType(self, elementType):
1900 return self.mesh.GetElementsByType(elementType)
1902 ## Returns the list of mesh nodes IDs
1903 # @return the list of integer values
1904 # @ingroup l1_meshinfo
1905 def GetNodesId(self):
1906 return self.mesh.GetNodesId()
1908 # Get the information about mesh elements:
1909 # ------------------------------------
1911 ## Returns the type of mesh element
1912 # @return the value from SMESH::ElementType enumeration
1913 # @ingroup l1_meshinfo
1914 def GetElementType(self, id, iselem):
1915 return self.mesh.GetElementType(id, iselem)
1917 ## Returns the list of submesh elements IDs
1918 # @param Shape a geom object(subshape) IOR
1919 # Shape must be the subshape of a ShapeToMesh()
1920 # @return the list of integer values
1921 # @ingroup l1_meshinfo
1922 def GetSubMeshElementsId(self, Shape):
1923 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1924 ShapeID = Shape.GetSubShapeIndices()[0]
1927 return self.mesh.GetSubMeshElementsId(ShapeID)
1929 ## Returns the list of submesh nodes IDs
1930 # @param Shape a geom object(subshape) IOR
1931 # Shape must be the subshape of a ShapeToMesh()
1932 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1933 # @return the list of integer values
1934 # @ingroup l1_meshinfo
1935 def GetSubMeshNodesId(self, Shape, all):
1936 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1937 ShapeID = Shape.GetSubShapeIndices()[0]
1940 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1942 ## Returns type of elements on given shape
1943 # @param Shape a geom object(subshape) IOR
1944 # Shape must be a subshape of a ShapeToMesh()
1945 # @return element type
1946 # @ingroup l1_meshinfo
1947 def GetSubMeshElementType(self, Shape):
1948 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1949 ShapeID = Shape.GetSubShapeIndices()[0]
1952 return self.mesh.GetSubMeshElementType(ShapeID)
1954 ## Gets the mesh description
1955 # @return string value
1956 # @ingroup l1_meshinfo
1958 return self.mesh.Dump()
1961 # Get the information about nodes and elements of a mesh by its IDs:
1962 # -----------------------------------------------------------
1964 ## Gets XYZ coordinates of a node
1965 # \n If there is no nodes for the given ID - returns an empty list
1966 # @return a list of double precision values
1967 # @ingroup l1_meshinfo
1968 def GetNodeXYZ(self, id):
1969 return self.mesh.GetNodeXYZ(id)
1971 ## Returns list of IDs of inverse elements for the given node
1972 # \n If there is no node for the given ID - returns an empty list
1973 # @return a list of integer values
1974 # @ingroup l1_meshinfo
1975 def GetNodeInverseElements(self, id):
1976 return self.mesh.GetNodeInverseElements(id)
1978 ## @brief Returns the position of a node on the shape
1979 # @return SMESH::NodePosition
1980 # @ingroup l1_meshinfo
1981 def GetNodePosition(self,NodeID):
1982 return self.mesh.GetNodePosition(NodeID)
1984 ## If the given element is a node, returns the ID of shape
1985 # \n If there is no node for the given ID - returns -1
1986 # @return an integer value
1987 # @ingroup l1_meshinfo
1988 def GetShapeID(self, id):
1989 return self.mesh.GetShapeID(id)
1991 ## Returns the ID of the result shape after
1992 # FindShape() from SMESH_MeshEditor for the given element
1993 # \n If there is no element for the given ID - returns -1
1994 # @return an integer value
1995 # @ingroup l1_meshinfo
1996 def GetShapeIDForElem(self,id):
1997 return self.mesh.GetShapeIDForElem(id)
1999 ## Returns the number of nodes for the given element
2000 # \n If there is no element for the given ID - returns -1
2001 # @return an integer value
2002 # @ingroup l1_meshinfo
2003 def GetElemNbNodes(self, id):
2004 return self.mesh.GetElemNbNodes(id)
2006 ## Returns the node ID the given index for the given element
2007 # \n If there is no element for the given ID - returns -1
2008 # \n If there is no node for the given index - returns -2
2009 # @return an integer value
2010 # @ingroup l1_meshinfo
2011 def GetElemNode(self, id, index):
2012 return self.mesh.GetElemNode(id, index)
2014 ## Returns the IDs of nodes of the given element
2015 # @return a list of integer values
2016 # @ingroup l1_meshinfo
2017 def GetElemNodes(self, id):
2018 return self.mesh.GetElemNodes(id)
2020 ## Returns true if the given node is the medium node in the given quadratic element
2021 # @ingroup l1_meshinfo
2022 def IsMediumNode(self, elementID, nodeID):
2023 return self.mesh.IsMediumNode(elementID, nodeID)
2025 ## Returns true if the given node is the medium node in one of quadratic elements
2026 # @ingroup l1_meshinfo
2027 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2028 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2030 ## Returns the number of edges for the given element
2031 # @ingroup l1_meshinfo
2032 def ElemNbEdges(self, id):
2033 return self.mesh.ElemNbEdges(id)
2035 ## Returns the number of faces for the given element
2036 # @ingroup l1_meshinfo
2037 def ElemNbFaces(self, id):
2038 return self.mesh.ElemNbFaces(id)
2040 ## Returns true if the given element is a polygon
2041 # @ingroup l1_meshinfo
2042 def IsPoly(self, id):
2043 return self.mesh.IsPoly(id)
2045 ## Returns true if the given element is quadratic
2046 # @ingroup l1_meshinfo
2047 def IsQuadratic(self, id):
2048 return self.mesh.IsQuadratic(id)
2050 ## Returns XYZ coordinates of the barycenter of the given element
2051 # \n If there is no element for the given ID - returns an empty list
2052 # @return a list of three double values
2053 # @ingroup l1_meshinfo
2054 def BaryCenter(self, id):
2055 return self.mesh.BaryCenter(id)
2058 # Mesh edition (SMESH_MeshEditor functionality):
2059 # ---------------------------------------------
2061 ## Removes the elements from the mesh by ids
2062 # @param IDsOfElements is a list of ids of elements to remove
2063 # @return True or False
2064 # @ingroup l2_modif_del
2065 def RemoveElements(self, IDsOfElements):
2066 return self.editor.RemoveElements(IDsOfElements)
2068 ## Removes nodes from mesh by ids
2069 # @param IDsOfNodes is a list of ids of nodes to remove
2070 # @return True or False
2071 # @ingroup l2_modif_del
2072 def RemoveNodes(self, IDsOfNodes):
2073 return self.editor.RemoveNodes(IDsOfNodes)
2075 ## Add a node to the mesh by coordinates
2076 # @return Id of the new node
2077 # @ingroup l2_modif_add
2078 def AddNode(self, x, y, z):
2079 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2080 self.mesh.SetParameters(Parameters)
2081 return self.editor.AddNode( x, y, z)
2083 ## Creates a 0D element on a node with given number.
2084 # @param IDOfNode the ID of node for creation of the element.
2085 # @return the Id of the new 0D element
2086 # @ingroup l2_modif_add
2087 def Add0DElement(self, IDOfNode):
2088 return self.editor.Add0DElement(IDOfNode)
2090 ## Creates a linear or quadratic edge (this is determined
2091 # by the number of given nodes).
2092 # @param IDsOfNodes the list of node IDs for creation of the element.
2093 # The order of nodes in this list should correspond to the description
2094 # of MED. \n This description is located by the following link:
2095 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2096 # @return the Id of the new edge
2097 # @ingroup l2_modif_add
2098 def AddEdge(self, IDsOfNodes):
2099 return self.editor.AddEdge(IDsOfNodes)
2101 ## Creates a linear or quadratic face (this is determined
2102 # by the number of given nodes).
2103 # @param IDsOfNodes the list of node IDs for creation of the element.
2104 # The order of nodes in this list should correspond to the description
2105 # of MED. \n This description is located by the following link:
2106 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2107 # @return the Id of the new face
2108 # @ingroup l2_modif_add
2109 def AddFace(self, IDsOfNodes):
2110 return self.editor.AddFace(IDsOfNodes)
2112 ## Adds a polygonal face to the mesh by the list of node IDs
2113 # @param IdsOfNodes the list of node IDs for creation of the element.
2114 # @return the Id of the new face
2115 # @ingroup l2_modif_add
2116 def AddPolygonalFace(self, IdsOfNodes):
2117 return self.editor.AddPolygonalFace(IdsOfNodes)
2119 ## Creates both simple and quadratic volume (this is determined
2120 # by the number of given nodes).
2121 # @param IDsOfNodes the list of node IDs for creation of the element.
2122 # The order of nodes in this list should correspond to the description
2123 # of MED. \n This description is located by the following link:
2124 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2125 # @return the Id of the new volumic element
2126 # @ingroup l2_modif_add
2127 def AddVolume(self, IDsOfNodes):
2128 return self.editor.AddVolume(IDsOfNodes)
2130 ## Creates a volume of many faces, giving nodes for each face.
2131 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2132 # @param Quantities the list of integer values, Quantities[i]
2133 # gives the quantity of nodes in face number i.
2134 # @return the Id of the new volumic element
2135 # @ingroup l2_modif_add
2136 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2137 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2139 ## Creates a volume of many faces, giving the IDs of the existing faces.
2140 # @param IdsOfFaces the list of face IDs for volume creation.
2142 # Note: The created volume will refer only to the nodes
2143 # of the given faces, not to the faces themselves.
2144 # @return the Id of the new volumic element
2145 # @ingroup l2_modif_add
2146 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2147 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2150 ## @brief Binds a node to a vertex
2151 # @param NodeID a node ID
2152 # @param Vertex a vertex or vertex ID
2153 # @return True if succeed else raises an exception
2154 # @ingroup l2_modif_add
2155 def SetNodeOnVertex(self, NodeID, Vertex):
2156 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2157 VertexID = Vertex.GetSubShapeIndices()[0]
2161 self.editor.SetNodeOnVertex(NodeID, VertexID)
2162 except SALOME.SALOME_Exception, inst:
2163 raise ValueError, inst.details.text
2167 ## @brief Stores the node position on an edge
2168 # @param NodeID a node ID
2169 # @param Edge an edge or edge ID
2170 # @param paramOnEdge a parameter on the edge where the node is located
2171 # @return True if succeed else raises an exception
2172 # @ingroup l2_modif_add
2173 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2174 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2175 EdgeID = Edge.GetSubShapeIndices()[0]
2179 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2180 except SALOME.SALOME_Exception, inst:
2181 raise ValueError, inst.details.text
2184 ## @brief Stores node position on a face
2185 # @param NodeID a node ID
2186 # @param Face a face or face ID
2187 # @param u U parameter on the face where the node is located
2188 # @param v V parameter on the face where the node is located
2189 # @return True if succeed else raises an exception
2190 # @ingroup l2_modif_add
2191 def SetNodeOnFace(self, NodeID, Face, u, v):
2192 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2193 FaceID = Face.GetSubShapeIndices()[0]
2197 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2198 except SALOME.SALOME_Exception, inst:
2199 raise ValueError, inst.details.text
2202 ## @brief Binds a node to a solid
2203 # @param NodeID a node ID
2204 # @param Solid a solid or solid ID
2205 # @return True if succeed else raises an exception
2206 # @ingroup l2_modif_add
2207 def SetNodeInVolume(self, NodeID, Solid):
2208 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2209 SolidID = Solid.GetSubShapeIndices()[0]
2213 self.editor.SetNodeInVolume(NodeID, SolidID)
2214 except SALOME.SALOME_Exception, inst:
2215 raise ValueError, inst.details.text
2218 ## @brief Bind an element to a shape
2219 # @param ElementID an element ID
2220 # @param Shape a shape or shape ID
2221 # @return True if succeed else raises an exception
2222 # @ingroup l2_modif_add
2223 def SetMeshElementOnShape(self, ElementID, Shape):
2224 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2225 ShapeID = Shape.GetSubShapeIndices()[0]
2229 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2230 except SALOME.SALOME_Exception, inst:
2231 raise ValueError, inst.details.text
2235 ## Moves the node with the given id
2236 # @param NodeID the id of the node
2237 # @param x a new X coordinate
2238 # @param y a new Y coordinate
2239 # @param z a new Z coordinate
2240 # @return True if succeed else False
2241 # @ingroup l2_modif_movenode
2242 def MoveNode(self, NodeID, x, y, z):
2243 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2244 self.mesh.SetParameters(Parameters)
2245 return self.editor.MoveNode(NodeID, x, y, z)
2247 ## Finds the node closest to a point and moves it to a point location
2248 # @param x the X coordinate of a point
2249 # @param y the Y coordinate of a point
2250 # @param z the Z coordinate of a point
2251 # @param NodeID if specified (>0), the node with this ID is moved,
2252 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2253 # @return the ID of a node
2254 # @ingroup l2_modif_throughp
2255 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2256 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2257 self.mesh.SetParameters(Parameters)
2258 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2260 ## Finds the node closest to a point
2261 # @param x the X coordinate of a point
2262 # @param y the Y coordinate of a point
2263 # @param z the Z coordinate of a point
2264 # @return the ID of a node
2265 # @ingroup l2_modif_throughp
2266 def FindNodeClosestTo(self, x, y, z):
2267 #preview = self.mesh.GetMeshEditPreviewer()
2268 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2269 return self.editor.FindNodeClosestTo(x, y, z)
2271 ## Finds the elements where a point lays IN or ON
2272 # @param x the X coordinate of a point
2273 # @param y the Y coordinate of a point
2274 # @param z the Z coordinate of a point
2275 # @param elementType type of elements to find (SMESH.ALL type
2276 # means elements of any type excluding nodes and 0D elements)
2277 # @return list of IDs of found elements
2278 # @ingroup l2_modif_throughp
2279 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2280 return self.editor.FindElementsByPoint(x, y, z, elementType)
2283 ## Finds the node closest to a point and moves it to a point location
2284 # @param x the X coordinate of a point
2285 # @param y the Y coordinate of a point
2286 # @param z the Z coordinate of a point
2287 # @return the ID of a moved node
2288 # @ingroup l2_modif_throughp
2289 def MeshToPassThroughAPoint(self, x, y, z):
2290 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2292 ## Replaces two neighbour triangles sharing Node1-Node2 link
2293 # with the triangles built on the same 4 nodes but having other common link.
2294 # @param NodeID1 the ID of the first node
2295 # @param NodeID2 the ID of the second node
2296 # @return false if proper faces were not found
2297 # @ingroup l2_modif_invdiag
2298 def InverseDiag(self, NodeID1, NodeID2):
2299 return self.editor.InverseDiag(NodeID1, NodeID2)
2301 ## Replaces two neighbour triangles sharing Node1-Node2 link
2302 # with a quadrangle built on the same 4 nodes.
2303 # @param NodeID1 the ID of the first node
2304 # @param NodeID2 the ID of the second node
2305 # @return false if proper faces were not found
2306 # @ingroup l2_modif_unitetri
2307 def DeleteDiag(self, NodeID1, NodeID2):
2308 return self.editor.DeleteDiag(NodeID1, NodeID2)
2310 ## Reorients elements by ids
2311 # @param IDsOfElements if undefined reorients all mesh elements
2312 # @return True if succeed else False
2313 # @ingroup l2_modif_changori
2314 def Reorient(self, IDsOfElements=None):
2315 if IDsOfElements == None:
2316 IDsOfElements = self.GetElementsId()
2317 return self.editor.Reorient(IDsOfElements)
2319 ## Reorients all elements of the object
2320 # @param theObject mesh, submesh or group
2321 # @return True if succeed else False
2322 # @ingroup l2_modif_changori
2323 def ReorientObject(self, theObject):
2324 if ( isinstance( theObject, Mesh )):
2325 theObject = theObject.GetMesh()
2326 return self.editor.ReorientObject(theObject)
2328 ## Fuses the neighbouring triangles into quadrangles.
2329 # @param IDsOfElements The triangles to be fused,
2330 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2331 # @param MaxAngle is the maximum angle between element normals at which the fusion
2332 # is still performed; theMaxAngle is mesured in radians.
2333 # Also it could be a name of variable which defines angle in degrees.
2334 # @return TRUE in case of success, FALSE otherwise.
2335 # @ingroup l2_modif_unitetri
2336 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2338 if isinstance(MaxAngle,str):
2340 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2342 MaxAngle = DegreesToRadians(MaxAngle)
2343 if IDsOfElements == []:
2344 IDsOfElements = self.GetElementsId()
2345 self.mesh.SetParameters(Parameters)
2347 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2348 Functor = theCriterion
2350 Functor = self.smeshpyD.GetFunctor(theCriterion)
2351 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2353 ## Fuses the neighbouring triangles of the object into quadrangles
2354 # @param theObject is mesh, submesh or group
2355 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2356 # @param MaxAngle a max angle between element normals at which the fusion
2357 # is still performed; theMaxAngle is mesured in radians.
2358 # @return TRUE in case of success, FALSE otherwise.
2359 # @ingroup l2_modif_unitetri
2360 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2361 if ( isinstance( theObject, Mesh )):
2362 theObject = theObject.GetMesh()
2363 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2365 ## Splits quadrangles into triangles.
2366 # @param IDsOfElements the faces to be splitted.
2367 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2368 # @return TRUE in case of success, FALSE otherwise.
2369 # @ingroup l2_modif_cutquadr
2370 def QuadToTri (self, IDsOfElements, theCriterion):
2371 if IDsOfElements == []:
2372 IDsOfElements = self.GetElementsId()
2373 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2375 ## Splits quadrangles into triangles.
2376 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2377 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2378 # @return TRUE in case of success, FALSE otherwise.
2379 # @ingroup l2_modif_cutquadr
2380 def QuadToTriObject (self, theObject, theCriterion):
2381 if ( isinstance( theObject, Mesh )):
2382 theObject = theObject.GetMesh()
2383 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2385 ## Splits quadrangles into triangles.
2386 # @param IDsOfElements the faces to be splitted
2387 # @param Diag13 is used to choose a diagonal for splitting.
2388 # @return TRUE in case of success, FALSE otherwise.
2389 # @ingroup l2_modif_cutquadr
2390 def SplitQuad (self, IDsOfElements, Diag13):
2391 if IDsOfElements == []:
2392 IDsOfElements = self.GetElementsId()
2393 return self.editor.SplitQuad(IDsOfElements, Diag13)
2395 ## Splits quadrangles into triangles.
2396 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2397 # @param Diag13 is used to choose a diagonal for splitting.
2398 # @return TRUE in case of success, FALSE otherwise.
2399 # @ingroup l2_modif_cutquadr
2400 def SplitQuadObject (self, theObject, Diag13):
2401 if ( isinstance( theObject, Mesh )):
2402 theObject = theObject.GetMesh()
2403 return self.editor.SplitQuadObject(theObject, Diag13)
2405 ## Finds a better splitting of the given quadrangle.
2406 # @param IDOfQuad the ID of the quadrangle to be splitted.
2407 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2408 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2409 # diagonal is better, 0 if error occurs.
2410 # @ingroup l2_modif_cutquadr
2411 def BestSplit (self, IDOfQuad, theCriterion):
2412 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2414 ## Splits quadrangle faces near triangular facets of volumes
2416 # @ingroup l1_auxiliary
2417 def SplitQuadsNearTriangularFacets(self):
2418 faces_array = self.GetElementsByType(SMESH.FACE)
2419 for face_id in faces_array:
2420 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2421 quad_nodes = self.mesh.GetElemNodes(face_id)
2422 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2423 isVolumeFound = False
2424 for node1_elem in node1_elems:
2425 if not isVolumeFound:
2426 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2427 nb_nodes = self.GetElemNbNodes(node1_elem)
2428 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2429 volume_elem = node1_elem
2430 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2431 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2432 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2433 isVolumeFound = True
2434 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2435 self.SplitQuad([face_id], False) # diagonal 2-4
2436 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2437 isVolumeFound = True
2438 self.SplitQuad([face_id], True) # diagonal 1-3
2439 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2440 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2441 isVolumeFound = True
2442 self.SplitQuad([face_id], True) # diagonal 1-3
2444 ## @brief Splits hexahedrons into tetrahedrons.
2446 # This operation uses pattern mapping functionality for splitting.
2447 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2448 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2449 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2450 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2451 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2452 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2453 # @return TRUE in case of success, FALSE otherwise.
2454 # @ingroup l1_auxiliary
2455 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2456 # Pattern: 5.---------.6
2461 # (0,0,1) 4.---------.7 * |
2468 # (0,0,0) 0.---------.3
2469 pattern_tetra = "!!! Nb of points: \n 8 \n\
2479 !!! Indices of points of 6 tetras: \n\
2487 pattern = self.smeshpyD.GetPattern()
2488 isDone = pattern.LoadFromFile(pattern_tetra)
2490 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2493 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2494 isDone = pattern.MakeMesh(self.mesh, False, False)
2495 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2497 # split quafrangle faces near triangular facets of volumes
2498 self.SplitQuadsNearTriangularFacets()
2502 ## @brief Split hexahedrons into prisms.
2504 # Uses the pattern mapping functionality for splitting.
2505 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2506 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2507 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2508 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2509 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2510 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2511 # @return TRUE in case of success, FALSE otherwise.
2512 # @ingroup l1_auxiliary
2513 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2514 # Pattern: 5.---------.6
2519 # (0,0,1) 4.---------.7 |
2526 # (0,0,0) 0.---------.3
2527 pattern_prism = "!!! Nb of points: \n 8 \n\
2537 !!! Indices of points of 2 prisms: \n\
2541 pattern = self.smeshpyD.GetPattern()
2542 isDone = pattern.LoadFromFile(pattern_prism)
2544 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2547 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2548 isDone = pattern.MakeMesh(self.mesh, False, False)
2549 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2551 # Splits quafrangle faces near triangular facets of volumes
2552 self.SplitQuadsNearTriangularFacets()
2556 ## Smoothes elements
2557 # @param IDsOfElements the list if ids of elements to smooth
2558 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2559 # Note that nodes built on edges and boundary nodes are always fixed.
2560 # @param MaxNbOfIterations the maximum number of iterations
2561 # @param MaxAspectRatio varies in range [1.0, inf]
2562 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2563 # @return TRUE in case of success, FALSE otherwise.
2564 # @ingroup l2_modif_smooth
2565 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2566 MaxNbOfIterations, MaxAspectRatio, Method):
2567 if IDsOfElements == []:
2568 IDsOfElements = self.GetElementsId()
2569 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2570 self.mesh.SetParameters(Parameters)
2571 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2572 MaxNbOfIterations, MaxAspectRatio, Method)
2574 ## Smoothes elements which belong to the given object
2575 # @param theObject the object to smooth
2576 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2577 # Note that nodes built on edges and boundary nodes are always fixed.
2578 # @param MaxNbOfIterations the maximum number of iterations
2579 # @param MaxAspectRatio varies in range [1.0, inf]
2580 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2581 # @return TRUE in case of success, FALSE otherwise.
2582 # @ingroup l2_modif_smooth
2583 def SmoothObject(self, theObject, IDsOfFixedNodes,
2584 MaxNbOfIterations, MaxAspectRatio, Method):
2585 if ( isinstance( theObject, Mesh )):
2586 theObject = theObject.GetMesh()
2587 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2588 MaxNbOfIterations, MaxAspectRatio, Method)
2590 ## Parametrically smoothes the given elements
2591 # @param IDsOfElements the list if ids of elements to smooth
2592 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2593 # Note that nodes built on edges and boundary nodes are always fixed.
2594 # @param MaxNbOfIterations the maximum number of iterations
2595 # @param MaxAspectRatio varies in range [1.0, inf]
2596 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2597 # @return TRUE in case of success, FALSE otherwise.
2598 # @ingroup l2_modif_smooth
2599 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2600 MaxNbOfIterations, MaxAspectRatio, Method):
2601 if IDsOfElements == []:
2602 IDsOfElements = self.GetElementsId()
2603 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2604 self.mesh.SetParameters(Parameters)
2605 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2606 MaxNbOfIterations, MaxAspectRatio, Method)
2608 ## Parametrically smoothes the elements which belong to the given object
2609 # @param theObject the object to smooth
2610 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2611 # Note that nodes built on edges and boundary nodes are always fixed.
2612 # @param MaxNbOfIterations the maximum number of iterations
2613 # @param MaxAspectRatio varies in range [1.0, inf]
2614 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2615 # @return TRUE in case of success, FALSE otherwise.
2616 # @ingroup l2_modif_smooth
2617 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2618 MaxNbOfIterations, MaxAspectRatio, Method):
2619 if ( isinstance( theObject, Mesh )):
2620 theObject = theObject.GetMesh()
2621 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2622 MaxNbOfIterations, MaxAspectRatio, Method)
2624 ## Converts the mesh to quadratic, deletes old elements, replacing
2625 # them with quadratic with the same id.
2626 # @ingroup l2_modif_tofromqu
2627 def ConvertToQuadratic(self, theForce3d):
2628 self.editor.ConvertToQuadratic(theForce3d)
2630 ## Converts the mesh from quadratic to ordinary,
2631 # deletes old quadratic elements, \n replacing
2632 # them with ordinary mesh elements with the same id.
2633 # @return TRUE in case of success, FALSE otherwise.
2634 # @ingroup l2_modif_tofromqu
2635 def ConvertFromQuadratic(self):
2636 return self.editor.ConvertFromQuadratic()
2638 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2639 # @return TRUE if operation has been completed successfully, FALSE otherwise
2640 # @ingroup l2_modif_edit
2641 def Make2DMeshFrom3D(self):
2642 return self.editor. Make2DMeshFrom3D()
2644 ## Renumber mesh nodes
2645 # @ingroup l2_modif_renumber
2646 def RenumberNodes(self):
2647 self.editor.RenumberNodes()
2649 ## Renumber mesh elements
2650 # @ingroup l2_modif_renumber
2651 def RenumberElements(self):
2652 self.editor.RenumberElements()
2654 ## Generates new elements by rotation of the elements around the axis
2655 # @param IDsOfElements the list of ids of elements to sweep
2656 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2657 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2658 # @param NbOfSteps the number of steps
2659 # @param Tolerance tolerance
2660 # @param MakeGroups forces the generation of new groups from existing ones
2661 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2662 # of all steps, else - size of each step
2663 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2664 # @ingroup l2_modif_extrurev
2665 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2666 MakeGroups=False, TotalAngle=False):
2668 if isinstance(AngleInRadians,str):
2670 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2672 AngleInRadians = DegreesToRadians(AngleInRadians)
2673 if IDsOfElements == []:
2674 IDsOfElements = self.GetElementsId()
2675 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2676 Axis = self.smeshpyD.GetAxisStruct(Axis)
2677 Axis,AxisParameters = ParseAxisStruct(Axis)
2678 if TotalAngle and NbOfSteps:
2679 AngleInRadians /= NbOfSteps
2680 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2681 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2682 self.mesh.SetParameters(Parameters)
2684 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2685 AngleInRadians, NbOfSteps, Tolerance)
2686 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2689 ## Generates new elements by rotation of the elements of object around the axis
2690 # @param theObject object which elements should be sweeped
2691 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2692 # @param AngleInRadians the angle of Rotation
2693 # @param NbOfSteps number of steps
2694 # @param Tolerance tolerance
2695 # @param MakeGroups forces the generation of new groups from existing ones
2696 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2697 # of all steps, else - size of each step
2698 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2699 # @ingroup l2_modif_extrurev
2700 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2701 MakeGroups=False, TotalAngle=False):
2703 if isinstance(AngleInRadians,str):
2705 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2707 AngleInRadians = DegreesToRadians(AngleInRadians)
2708 if ( isinstance( theObject, Mesh )):
2709 theObject = theObject.GetMesh()
2710 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2711 Axis = self.smeshpyD.GetAxisStruct(Axis)
2712 Axis,AxisParameters = ParseAxisStruct(Axis)
2713 if TotalAngle and NbOfSteps:
2714 AngleInRadians /= NbOfSteps
2715 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2716 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2717 self.mesh.SetParameters(Parameters)
2719 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2720 NbOfSteps, Tolerance)
2721 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2724 ## Generates new elements by rotation of the elements of object around the axis
2725 # @param theObject object which elements should be sweeped
2726 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2727 # @param AngleInRadians the angle of Rotation
2728 # @param NbOfSteps number of steps
2729 # @param Tolerance tolerance
2730 # @param MakeGroups forces the generation of new groups from existing ones
2731 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2732 # of all steps, else - size of each step
2733 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2734 # @ingroup l2_modif_extrurev
2735 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2736 MakeGroups=False, TotalAngle=False):
2738 if isinstance(AngleInRadians,str):
2740 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2742 AngleInRadians = DegreesToRadians(AngleInRadians)
2743 if ( isinstance( theObject, Mesh )):
2744 theObject = theObject.GetMesh()
2745 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2746 Axis = self.smeshpyD.GetAxisStruct(Axis)
2747 Axis,AxisParameters = ParseAxisStruct(Axis)
2748 if TotalAngle and NbOfSteps:
2749 AngleInRadians /= NbOfSteps
2750 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2751 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2752 self.mesh.SetParameters(Parameters)
2754 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2755 NbOfSteps, Tolerance)
2756 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2759 ## Generates new elements by rotation of the elements of object around the axis
2760 # @param theObject object which elements should be sweeped
2761 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2762 # @param AngleInRadians the angle of Rotation
2763 # @param NbOfSteps number of steps
2764 # @param Tolerance tolerance
2765 # @param MakeGroups forces the generation of new groups from existing ones
2766 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2767 # of all steps, else - size of each step
2768 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2769 # @ingroup l2_modif_extrurev
2770 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2771 MakeGroups=False, TotalAngle=False):
2773 if isinstance(AngleInRadians,str):
2775 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2777 AngleInRadians = DegreesToRadians(AngleInRadians)
2778 if ( isinstance( theObject, Mesh )):
2779 theObject = theObject.GetMesh()
2780 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2781 Axis = self.smeshpyD.GetAxisStruct(Axis)
2782 Axis,AxisParameters = ParseAxisStruct(Axis)
2783 if TotalAngle and NbOfSteps:
2784 AngleInRadians /= NbOfSteps
2785 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2786 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2787 self.mesh.SetParameters(Parameters)
2789 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2790 NbOfSteps, Tolerance)
2791 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2794 ## Generates new elements by extrusion of the elements with given ids
2795 # @param IDsOfElements the list of elements ids for extrusion
2796 # @param StepVector vector, defining the direction and value of extrusion
2797 # @param NbOfSteps the number of steps
2798 # @param MakeGroups forces the generation of new groups from existing ones
2799 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2800 # @ingroup l2_modif_extrurev
2801 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2802 if IDsOfElements == []:
2803 IDsOfElements = self.GetElementsId()
2804 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2805 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2806 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2807 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2808 Parameters = StepVectorParameters + var_separator + Parameters
2809 self.mesh.SetParameters(Parameters)
2811 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2812 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2815 ## Generates new elements by extrusion of the elements with given ids
2816 # @param IDsOfElements is ids of elements
2817 # @param StepVector vector, defining the direction and value of extrusion
2818 # @param NbOfSteps the number of steps
2819 # @param ExtrFlags sets flags for extrusion
2820 # @param SewTolerance uses for comparing locations of nodes if flag
2821 # EXTRUSION_FLAG_SEW is set
2822 # @param MakeGroups forces the generation of new groups from existing ones
2823 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2824 # @ingroup l2_modif_extrurev
2825 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2826 ExtrFlags, SewTolerance, MakeGroups=False):
2827 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2828 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2830 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2831 ExtrFlags, SewTolerance)
2832 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2833 ExtrFlags, SewTolerance)
2836 ## Generates new elements by extrusion of the elements which belong to the object
2837 # @param theObject the object which elements should be processed
2838 # @param StepVector vector, defining the direction and value of extrusion
2839 # @param NbOfSteps the number of steps
2840 # @param MakeGroups forces the generation of new groups from existing ones
2841 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2842 # @ingroup l2_modif_extrurev
2843 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2844 if ( isinstance( theObject, Mesh )):
2845 theObject = theObject.GetMesh()
2846 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2847 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2848 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2849 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2850 Parameters = StepVectorParameters + var_separator + Parameters
2851 self.mesh.SetParameters(Parameters)
2853 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2854 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2857 ## Generates new elements by extrusion of the elements which belong to the object
2858 # @param theObject object which elements should be processed
2859 # @param StepVector vector, defining the direction and value of extrusion
2860 # @param NbOfSteps the number of steps
2861 # @param MakeGroups to generate new groups from existing ones
2862 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2863 # @ingroup l2_modif_extrurev
2864 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2865 if ( isinstance( theObject, Mesh )):
2866 theObject = theObject.GetMesh()
2867 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2868 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2869 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2870 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2871 Parameters = StepVectorParameters + var_separator + Parameters
2872 self.mesh.SetParameters(Parameters)
2874 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2875 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2878 ## Generates new elements by extrusion of the elements which belong to the object
2879 # @param theObject object which elements should be processed
2880 # @param StepVector vector, defining the direction and value of extrusion
2881 # @param NbOfSteps the number of steps
2882 # @param MakeGroups forces the generation of new groups from existing ones
2883 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2884 # @ingroup l2_modif_extrurev
2885 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2886 if ( isinstance( theObject, Mesh )):
2887 theObject = theObject.GetMesh()
2888 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2889 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2890 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2891 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2892 Parameters = StepVectorParameters + var_separator + Parameters
2893 self.mesh.SetParameters(Parameters)
2895 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2896 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2901 ## Generates new elements by extrusion of the given elements
2902 # The path of extrusion must be a meshed edge.
2903 # @param Base mesh or list of ids of elements for extrusion
2904 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2905 # @param NodeStart the start node from Path. Defines the direction of extrusion
2906 # @param HasAngles allows the shape to be rotated around the path
2907 # to get the resulting mesh in a helical fashion
2908 # @param Angles list of angles in radians
2909 # @param LinearVariation forces the computation of rotation angles as linear
2910 # variation of the given Angles along path steps
2911 # @param HasRefPoint allows using the reference point
2912 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2913 # The User can specify any point as the Reference Point.
2914 # @param MakeGroups forces the generation of new groups from existing ones
2915 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2916 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2917 # only SMESH::Extrusion_Error otherwise
2918 # @ingroup l2_modif_extrurev
2919 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2920 HasAngles, Angles, LinearVariation,
2921 HasRefPoint, RefPoint, MakeGroups, ElemType):
2922 Angles,AnglesParameters = ParseAngles(Angles)
2923 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2924 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2925 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2927 Parameters = AnglesParameters + var_separator + RefPointParameters
2928 self.mesh.SetParameters(Parameters)
2930 if isinstance(Base,list):
2932 if Base == []: IDsOfElements = self.GetElementsId()
2933 else: IDsOfElements = Base
2934 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2935 HasAngles, Angles, LinearVariation,
2936 HasRefPoint, RefPoint, MakeGroups, ElemType)
2938 if isinstance(Base,Mesh):
2939 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2940 HasAngles, Angles, LinearVariation,
2941 HasRefPoint, RefPoint, MakeGroups, ElemType)
2943 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2946 ## Generates new elements by extrusion of the given elements
2947 # The path of extrusion must be a meshed edge.
2948 # @param IDsOfElements ids of elements
2949 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2950 # @param PathShape shape(edge) defines the sub-mesh for the path
2951 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2952 # @param HasAngles allows the shape to be rotated around the path
2953 # to get the resulting mesh in a helical fashion
2954 # @param Angles list of angles in radians
2955 # @param HasRefPoint allows using the reference point
2956 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2957 # The User can specify any point as the Reference Point.
2958 # @param MakeGroups forces the generation of new groups from existing ones
2959 # @param LinearVariation forces the computation of rotation angles as linear
2960 # variation of the given Angles along path steps
2961 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2962 # only SMESH::Extrusion_Error otherwise
2963 # @ingroup l2_modif_extrurev
2964 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2965 HasAngles, Angles, HasRefPoint, RefPoint,
2966 MakeGroups=False, LinearVariation=False):
2967 Angles,AnglesParameters = ParseAngles(Angles)
2968 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2969 if IDsOfElements == []:
2970 IDsOfElements = self.GetElementsId()
2971 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2972 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2974 if ( isinstance( PathMesh, Mesh )):
2975 PathMesh = PathMesh.GetMesh()
2976 if HasAngles and Angles and LinearVariation:
2977 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2979 Parameters = AnglesParameters + var_separator + RefPointParameters
2980 self.mesh.SetParameters(Parameters)
2982 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2983 PathShape, NodeStart, HasAngles,
2984 Angles, HasRefPoint, RefPoint)
2985 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2986 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2988 ## Generates new elements by extrusion of the elements which belong to the object
2989 # The path of extrusion must be a meshed edge.
2990 # @param theObject the object which elements should be processed
2991 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2992 # @param PathShape shape(edge) defines the sub-mesh for the path
2993 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2994 # @param HasAngles allows the shape to be rotated around the path
2995 # to get the resulting mesh in a helical fashion
2996 # @param Angles list of angles
2997 # @param HasRefPoint allows using the reference point
2998 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2999 # The User can specify any point as the Reference Point.
3000 # @param MakeGroups forces the generation of new groups from existing ones
3001 # @param LinearVariation forces the computation of rotation angles as linear
3002 # variation of the given Angles along path steps
3003 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3004 # only SMESH::Extrusion_Error otherwise
3005 # @ingroup l2_modif_extrurev
3006 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3007 HasAngles, Angles, HasRefPoint, RefPoint,
3008 MakeGroups=False, LinearVariation=False):
3009 Angles,AnglesParameters = ParseAngles(Angles)
3010 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3011 if ( isinstance( theObject, Mesh )):
3012 theObject = theObject.GetMesh()
3013 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3014 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3015 if ( isinstance( PathMesh, Mesh )):
3016 PathMesh = PathMesh.GetMesh()
3017 if HasAngles and Angles and LinearVariation:
3018 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3020 Parameters = AnglesParameters + var_separator + RefPointParameters
3021 self.mesh.SetParameters(Parameters)
3023 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3024 PathShape, NodeStart, HasAngles,
3025 Angles, HasRefPoint, RefPoint)
3026 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3027 NodeStart, HasAngles, Angles, HasRefPoint,
3030 ## Generates new elements by extrusion of the elements which belong to the object
3031 # The path of extrusion must be a meshed edge.
3032 # @param theObject the object which elements should be processed
3033 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3034 # @param PathShape shape(edge) defines the sub-mesh for the path
3035 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3036 # @param HasAngles allows the shape to be rotated around the path
3037 # to get the resulting mesh in a helical fashion
3038 # @param Angles list of angles
3039 # @param HasRefPoint allows using the reference point
3040 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3041 # The User can specify any point as the Reference Point.
3042 # @param MakeGroups forces the generation of new groups from existing ones
3043 # @param LinearVariation forces the computation of rotation angles as linear
3044 # variation of the given Angles along path steps
3045 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3046 # only SMESH::Extrusion_Error otherwise
3047 # @ingroup l2_modif_extrurev
3048 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3049 HasAngles, Angles, HasRefPoint, RefPoint,
3050 MakeGroups=False, LinearVariation=False):
3051 Angles,AnglesParameters = ParseAngles(Angles)
3052 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3053 if ( isinstance( theObject, Mesh )):
3054 theObject = theObject.GetMesh()
3055 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3056 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3057 if ( isinstance( PathMesh, Mesh )):
3058 PathMesh = PathMesh.GetMesh()
3059 if HasAngles and Angles and LinearVariation:
3060 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3062 Parameters = AnglesParameters + var_separator + RefPointParameters
3063 self.mesh.SetParameters(Parameters)
3065 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3066 PathShape, NodeStart, HasAngles,
3067 Angles, HasRefPoint, RefPoint)
3068 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3069 NodeStart, HasAngles, Angles, HasRefPoint,
3072 ## Generates new elements by extrusion of the elements which belong to the object
3073 # The path of extrusion must be a meshed edge.
3074 # @param theObject the object which elements should be processed
3075 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3076 # @param PathShape shape(edge) defines the sub-mesh for the path
3077 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3078 # @param HasAngles allows the shape to be rotated around the path
3079 # to get the resulting mesh in a helical fashion
3080 # @param Angles list of angles
3081 # @param HasRefPoint allows using the reference point
3082 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3083 # The User can specify any point as the Reference Point.
3084 # @param MakeGroups forces the generation of new groups from existing ones
3085 # @param LinearVariation forces the computation of rotation angles as linear
3086 # variation of the given Angles along path steps
3087 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3088 # only SMESH::Extrusion_Error otherwise
3089 # @ingroup l2_modif_extrurev
3090 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3091 HasAngles, Angles, HasRefPoint, RefPoint,
3092 MakeGroups=False, LinearVariation=False):
3093 Angles,AnglesParameters = ParseAngles(Angles)
3094 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3095 if ( isinstance( theObject, Mesh )):
3096 theObject = theObject.GetMesh()
3097 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3098 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3099 if ( isinstance( PathMesh, Mesh )):
3100 PathMesh = PathMesh.GetMesh()
3101 if HasAngles and Angles and LinearVariation:
3102 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3104 Parameters = AnglesParameters + var_separator + RefPointParameters
3105 self.mesh.SetParameters(Parameters)
3107 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3108 PathShape, NodeStart, HasAngles,
3109 Angles, HasRefPoint, RefPoint)
3110 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3111 NodeStart, HasAngles, Angles, HasRefPoint,
3114 ## Creates a symmetrical copy of mesh elements
3115 # @param IDsOfElements list of elements ids
3116 # @param Mirror is AxisStruct or geom object(point, line, plane)
3117 # @param theMirrorType is POINT, AXIS or PLANE
3118 # If the Mirror is a geom object this parameter is unnecessary
3119 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3120 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3121 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3122 # @ingroup l2_modif_trsf
3123 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3124 if IDsOfElements == []:
3125 IDsOfElements = self.GetElementsId()
3126 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3127 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3128 Mirror,Parameters = ParseAxisStruct(Mirror)
3129 self.mesh.SetParameters(Parameters)
3130 if Copy and MakeGroups:
3131 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3132 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3135 ## Creates a new mesh by a symmetrical copy of mesh elements
3136 # @param IDsOfElements the list of elements ids
3137 # @param Mirror is AxisStruct or geom object (point, line, plane)
3138 # @param theMirrorType is POINT, AXIS or PLANE
3139 # If the Mirror is a geom object this parameter is unnecessary
3140 # @param MakeGroups to generate new groups from existing ones
3141 # @param NewMeshName a name of the new mesh to create
3142 # @return instance of Mesh class
3143 # @ingroup l2_modif_trsf
3144 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3145 if IDsOfElements == []:
3146 IDsOfElements = self.GetElementsId()
3147 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3148 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3149 Mirror,Parameters = ParseAxisStruct(Mirror)
3150 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3151 MakeGroups, NewMeshName)
3152 mesh.SetParameters(Parameters)
3153 return Mesh(self.smeshpyD,self.geompyD,mesh)
3155 ## Creates a symmetrical copy of the object
3156 # @param theObject mesh, submesh or group
3157 # @param Mirror AxisStruct or geom object (point, line, plane)
3158 # @param theMirrorType is POINT, AXIS or PLANE
3159 # If the Mirror is a geom object this parameter is unnecessary
3160 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3161 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3162 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3163 # @ingroup l2_modif_trsf
3164 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3165 if ( isinstance( theObject, Mesh )):
3166 theObject = theObject.GetMesh()
3167 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3168 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3169 Mirror,Parameters = ParseAxisStruct(Mirror)
3170 self.mesh.SetParameters(Parameters)
3171 if Copy and MakeGroups:
3172 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3173 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3176 ## Creates a new mesh by a symmetrical copy of the object
3177 # @param theObject mesh, submesh or group
3178 # @param Mirror AxisStruct or geom object (point, line, plane)
3179 # @param theMirrorType POINT, AXIS or PLANE
3180 # If the Mirror is a geom object this parameter is unnecessary
3181 # @param MakeGroups forces the generation of new groups from existing ones
3182 # @param NewMeshName the name of the new mesh to create
3183 # @return instance of Mesh class
3184 # @ingroup l2_modif_trsf
3185 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3186 if ( isinstance( theObject, Mesh )):
3187 theObject = theObject.GetMesh()
3188 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3189 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3190 Mirror,Parameters = ParseAxisStruct(Mirror)
3191 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3192 MakeGroups, NewMeshName)
3193 mesh.SetParameters(Parameters)
3194 return Mesh( self.smeshpyD,self.geompyD,mesh )
3196 ## Translates the elements
3197 # @param IDsOfElements list of elements ids
3198 # @param Vector the direction of translation (DirStruct or vector)
3199 # @param Copy allows copying the translated elements
3200 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3201 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3202 # @ingroup l2_modif_trsf
3203 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3204 if IDsOfElements == []:
3205 IDsOfElements = self.GetElementsId()
3206 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3207 Vector = self.smeshpyD.GetDirStruct(Vector)
3208 Vector,Parameters = ParseDirStruct(Vector)
3209 self.mesh.SetParameters(Parameters)
3210 if Copy and MakeGroups:
3211 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3212 self.editor.Translate(IDsOfElements, Vector, Copy)
3215 ## Creates a new mesh of translated elements
3216 # @param IDsOfElements list of elements ids
3217 # @param Vector the direction of translation (DirStruct or vector)
3218 # @param MakeGroups forces the generation of new groups from existing ones
3219 # @param NewMeshName the name of the newly created mesh
3220 # @return instance of Mesh class
3221 # @ingroup l2_modif_trsf
3222 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3223 if IDsOfElements == []:
3224 IDsOfElements = self.GetElementsId()
3225 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3226 Vector = self.smeshpyD.GetDirStruct(Vector)
3227 Vector,Parameters = ParseDirStruct(Vector)
3228 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3229 mesh.SetParameters(Parameters)
3230 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3232 ## Translates the object
3233 # @param theObject the object to translate (mesh, submesh, or group)
3234 # @param Vector direction of translation (DirStruct or geom vector)
3235 # @param Copy allows copying the translated elements
3236 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3237 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3238 # @ingroup l2_modif_trsf
3239 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3240 if ( isinstance( theObject, Mesh )):
3241 theObject = theObject.GetMesh()
3242 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3243 Vector = self.smeshpyD.GetDirStruct(Vector)
3244 Vector,Parameters = ParseDirStruct(Vector)
3245 self.mesh.SetParameters(Parameters)
3246 if Copy and MakeGroups:
3247 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3248 self.editor.TranslateObject(theObject, Vector, Copy)
3251 ## Creates a new mesh from the translated object
3252 # @param theObject the object to translate (mesh, submesh, or group)
3253 # @param Vector the direction of translation (DirStruct or geom vector)
3254 # @param MakeGroups forces the generation of new groups from existing ones
3255 # @param NewMeshName the name of the newly created mesh
3256 # @return instance of Mesh class
3257 # @ingroup l2_modif_trsf
3258 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3259 if (isinstance(theObject, Mesh)):
3260 theObject = theObject.GetMesh()
3261 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3262 Vector = self.smeshpyD.GetDirStruct(Vector)
3263 Vector,Parameters = ParseDirStruct(Vector)
3264 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3265 mesh.SetParameters(Parameters)
3266 return Mesh( self.smeshpyD, self.geompyD, mesh )
3268 ## Rotates the elements
3269 # @param IDsOfElements list of elements ids
3270 # @param Axis the axis of rotation (AxisStruct or geom line)
3271 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3272 # @param Copy allows copying the rotated elements
3273 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3274 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3275 # @ingroup l2_modif_trsf
3276 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3278 if isinstance(AngleInRadians,str):
3280 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3282 AngleInRadians = DegreesToRadians(AngleInRadians)
3283 if IDsOfElements == []:
3284 IDsOfElements = self.GetElementsId()
3285 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3286 Axis = self.smeshpyD.GetAxisStruct(Axis)
3287 Axis,AxisParameters = ParseAxisStruct(Axis)
3288 Parameters = AxisParameters + var_separator + Parameters
3289 self.mesh.SetParameters(Parameters)
3290 if Copy and MakeGroups:
3291 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3292 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3295 ## Creates a new mesh of rotated elements
3296 # @param IDsOfElements list of element ids
3297 # @param Axis the axis of rotation (AxisStruct or geom line)
3298 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3299 # @param MakeGroups forces the generation of new groups from existing ones
3300 # @param NewMeshName the name of the newly created mesh
3301 # @return instance of Mesh class
3302 # @ingroup l2_modif_trsf
3303 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3305 if isinstance(AngleInRadians,str):
3307 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3309 AngleInRadians = DegreesToRadians(AngleInRadians)
3310 if IDsOfElements == []:
3311 IDsOfElements = self.GetElementsId()
3312 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3313 Axis = self.smeshpyD.GetAxisStruct(Axis)
3314 Axis,AxisParameters = ParseAxisStruct(Axis)
3315 Parameters = AxisParameters + var_separator + Parameters
3316 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3317 MakeGroups, NewMeshName)
3318 mesh.SetParameters(Parameters)
3319 return Mesh( self.smeshpyD, self.geompyD, mesh )
3321 ## Rotates the object
3322 # @param theObject the object to rotate( mesh, submesh, or group)
3323 # @param Axis the axis of rotation (AxisStruct or geom line)
3324 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3325 # @param Copy allows copying the rotated elements
3326 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3327 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3328 # @ingroup l2_modif_trsf
3329 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3331 if isinstance(AngleInRadians,str):
3333 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3335 AngleInRadians = DegreesToRadians(AngleInRadians)
3336 if (isinstance(theObject, Mesh)):
3337 theObject = theObject.GetMesh()
3338 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3339 Axis = self.smeshpyD.GetAxisStruct(Axis)
3340 Axis,AxisParameters = ParseAxisStruct(Axis)
3341 Parameters = AxisParameters + ":" + Parameters
3342 self.mesh.SetParameters(Parameters)
3343 if Copy and MakeGroups:
3344 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3345 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3348 ## Creates a new mesh from the rotated object
3349 # @param theObject the object to rotate (mesh, submesh, or group)
3350 # @param Axis the axis of rotation (AxisStruct or geom line)
3351 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3352 # @param MakeGroups forces the generation of new groups from existing ones
3353 # @param NewMeshName the name of the newly created mesh
3354 # @return instance of Mesh class
3355 # @ingroup l2_modif_trsf
3356 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3358 if isinstance(AngleInRadians,str):
3360 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3362 AngleInRadians = DegreesToRadians(AngleInRadians)
3363 if (isinstance( theObject, Mesh )):
3364 theObject = theObject.GetMesh()
3365 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3366 Axis = self.smeshpyD.GetAxisStruct(Axis)
3367 Axis,AxisParameters = ParseAxisStruct(Axis)
3368 Parameters = AxisParameters + ":" + Parameters
3369 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3370 MakeGroups, NewMeshName)
3371 mesh.SetParameters(Parameters)
3372 return Mesh( self.smeshpyD, self.geompyD, mesh )
3374 ## Finds groups of ajacent nodes within Tolerance.
3375 # @param Tolerance the value of tolerance
3376 # @return the list of groups of nodes
3377 # @ingroup l2_modif_trsf
3378 def FindCoincidentNodes (self, Tolerance):
3379 return self.editor.FindCoincidentNodes(Tolerance)
3381 ## Finds groups of ajacent nodes within Tolerance.
3382 # @param Tolerance the value of tolerance
3383 # @param SubMeshOrGroup SubMesh or Group
3384 # @return the list of groups of nodes
3385 # @ingroup l2_modif_trsf
3386 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3387 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3390 # @param GroupsOfNodes the list of groups of nodes
3391 # @ingroup l2_modif_trsf
3392 def MergeNodes (self, GroupsOfNodes):
3393 self.editor.MergeNodes(GroupsOfNodes)
3395 ## Finds the elements built on the same nodes.
3396 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3397 # @return a list of groups of equal elements
3398 # @ingroup l2_modif_trsf
3399 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3400 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3401 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3402 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3404 ## Merges elements in each given group.
3405 # @param GroupsOfElementsID groups of elements for merging
3406 # @ingroup l2_modif_trsf
3407 def MergeElements(self, GroupsOfElementsID):
3408 self.editor.MergeElements(GroupsOfElementsID)
3410 ## Leaves one element and removes all other elements built on the same nodes.
3411 # @ingroup l2_modif_trsf
3412 def MergeEqualElements(self):
3413 self.editor.MergeEqualElements()
3415 ## Sews free borders
3416 # @return SMESH::Sew_Error
3417 # @ingroup l2_modif_trsf
3418 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3419 FirstNodeID2, SecondNodeID2, LastNodeID2,
3420 CreatePolygons, CreatePolyedrs):
3421 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3422 FirstNodeID2, SecondNodeID2, LastNodeID2,
3423 CreatePolygons, CreatePolyedrs)
3425 ## Sews conform free borders
3426 # @return SMESH::Sew_Error
3427 # @ingroup l2_modif_trsf
3428 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3429 FirstNodeID2, SecondNodeID2):
3430 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3431 FirstNodeID2, SecondNodeID2)
3433 ## Sews border to side
3434 # @return SMESH::Sew_Error
3435 # @ingroup l2_modif_trsf
3436 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3437 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3438 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3439 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3441 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3442 # merged with the nodes of elements of Side2.
3443 # The number of elements in theSide1 and in theSide2 must be
3444 # equal and they should have similar nodal connectivity.
3445 # The nodes to merge should belong to side borders and
3446 # the first node should be linked to the second.
3447 # @return SMESH::Sew_Error
3448 # @ingroup l2_modif_trsf
3449 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3450 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3451 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3452 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3453 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3454 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3456 ## Sets new nodes for the given element.
3457 # @param ide the element id
3458 # @param newIDs nodes ids
3459 # @return If the number of nodes does not correspond to the type of element - returns false
3460 # @ingroup l2_modif_edit
3461 def ChangeElemNodes(self, ide, newIDs):
3462 return self.editor.ChangeElemNodes(ide, newIDs)
3464 ## If during the last operation of MeshEditor some nodes were
3465 # created, this method returns the list of their IDs, \n
3466 # if new nodes were not created - returns empty list
3467 # @return the list of integer values (can be empty)
3468 # @ingroup l1_auxiliary
3469 def GetLastCreatedNodes(self):
3470 return self.editor.GetLastCreatedNodes()
3472 ## If during the last operation of MeshEditor some elements were
3473 # created this method returns the list of their IDs, \n
3474 # if new elements were not created - returns empty list
3475 # @return the list of integer values (can be empty)
3476 # @ingroup l1_auxiliary
3477 def GetLastCreatedElems(self):
3478 return self.editor.GetLastCreatedElems()
3480 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3481 # @param theNodes identifiers of nodes to be doubled
3482 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3483 # nodes. If list of element identifiers is empty then nodes are doubled but
3484 # they not assigned to elements
3485 # @return TRUE if operation has been completed successfully, FALSE otherwise
3486 # @ingroup l2_modif_edit
3487 def DoubleNodes(self, theNodes, theModifiedElems):
3488 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3490 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3491 # This method provided for convenience works as DoubleNodes() described above.
3492 # @param theNodes identifiers of node to be doubled
3493 # @param theModifiedElems identifiers of elements to be updated
3494 # @return TRUE if operation has been completed successfully, FALSE otherwise
3495 # @ingroup l2_modif_edit
3496 def DoubleNode(self, theNodeId, theModifiedElems):
3497 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3499 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3500 # This method provided for convenience works as DoubleNodes() described above.
3501 # @param theNodes group of nodes to be doubled
3502 # @param theModifiedElems group of elements to be updated.
3503 # @return TRUE if operation has been completed successfully, FALSE otherwise
3504 # @ingroup l2_modif_edit
3505 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3506 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3508 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3509 # This method provided for convenience works as DoubleNodes() described above.
3510 # @param theNodes list of groups of nodes to be doubled
3511 # @param theModifiedElems list of groups of elements to be updated.
3512 # @return TRUE if operation has been completed successfully, FALSE otherwise
3513 # @ingroup l2_modif_edit
3514 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3515 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3517 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3518 # @param theElems - the list of elements (edges or faces) to be replicated
3519 # The nodes for duplication could be found from these elements
3520 # @param theNodesNot - list of nodes to NOT replicate
3521 # @param theAffectedElems - the list of elements (cells and edges) to which the
3522 # replicated nodes should be associated to.
3523 # @return TRUE if operation has been completed successfully, FALSE otherwise
3524 # @ingroup l2_modif_edit
3525 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3526 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3528 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3529 # @param theElems - the list of elements (edges or faces) to be replicated
3530 # The nodes for duplication could be found from these elements
3531 # @param theNodesNot - list of nodes to NOT replicate
3532 # @param theShape - shape to detect affected elements (element which geometric center
3533 # located on or inside shape).
3534 # The replicated nodes should be associated to affected elements.
3535 # @return TRUE if operation has been completed successfully, FALSE otherwise
3536 # @ingroup l2_modif_edit
3537 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3538 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3540 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3541 # This method provided for convenience works as DoubleNodes() described above.
3542 # @param theElems - group of of elements (edges or faces) to be replicated
3543 # @param theNodesNot - group of nodes not to replicated
3544 # @param theAffectedElems - group of elements to which the replicated nodes
3545 # should be associated to.
3546 # @ingroup l2_modif_edit
3547 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3548 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3550 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3551 # This method provided for convenience works as DoubleNodes() described above.
3552 # @param theElems - group of of elements (edges or faces) to be replicated
3553 # @param theNodesNot - group of nodes not to replicated
3554 # @param theShape - shape to detect affected elements (element which geometric center
3555 # located on or inside shape).
3556 # The replicated nodes should be associated to affected elements.
3557 # @ingroup l2_modif_edit
3558 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3559 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3561 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3562 # This method provided for convenience works as DoubleNodes() described above.
3563 # @param theElems - list of groups of elements (edges or faces) to be replicated
3564 # @param theNodesNot - list of groups of nodes not to replicated
3565 # @param theAffectedElems - group of elements to which the replicated nodes
3566 # should be associated to.
3567 # @return TRUE if operation has been completed successfully, FALSE otherwise
3568 # @ingroup l2_modif_edit
3569 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3570 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3572 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3573 # This method provided for convenience works as DoubleNodes() described above.
3574 # @param theElems - list of groups of elements (edges or faces) to be replicated
3575 # @param theNodesNot - list of groups of nodes not to replicated
3576 # @param theShape - shape to detect affected elements (element which geometric center
3577 # located on or inside shape).
3578 # The replicated nodes should be associated to affected elements.
3579 # @return TRUE if operation has been completed successfully, FALSE otherwise
3580 # @ingroup l2_modif_edit
3581 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3582 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3584 ## The mother class to define algorithm, it is not recommended to use it directly.
3587 # @ingroup l2_algorithms
3588 class Mesh_Algorithm:
3589 # @class Mesh_Algorithm
3590 # @brief Class Mesh_Algorithm
3592 #def __init__(self,smesh):
3600 ## Finds a hypothesis in the study by its type name and parameters.
3601 # Finds only the hypotheses created in smeshpyD engine.
3602 # @return SMESH.SMESH_Hypothesis
3603 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3604 study = smeshpyD.GetCurrentStudy()
3605 #to do: find component by smeshpyD object, not by its data type
3606 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3607 if scomp is not None:
3608 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3609 # Check if the root label of the hypotheses exists
3610 if res and hypRoot is not None:
3611 iter = study.NewChildIterator(hypRoot)
3612 # Check all published hypotheses
3614 hypo_so_i = iter.Value()
3615 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3616 if attr is not None:
3617 anIOR = attr.Value()
3618 hypo_o_i = salome.orb.string_to_object(anIOR)
3619 if hypo_o_i is not None:
3620 # Check if this is a hypothesis
3621 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3622 if hypo_i is not None:
3623 # Check if the hypothesis belongs to current engine
3624 if smeshpyD.GetObjectId(hypo_i) > 0:
3625 # Check if this is the required hypothesis
3626 if hypo_i.GetName() == hypname:
3628 if CompareMethod(hypo_i, args):
3642 ## Finds the algorithm in the study by its type name.
3643 # Finds only the algorithms, which have been created in smeshpyD engine.
3644 # @return SMESH.SMESH_Algo
3645 def FindAlgorithm (self, algoname, smeshpyD):
3646 study = smeshpyD.GetCurrentStudy()
3647 #to do: find component by smeshpyD object, not by its data type
3648 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3649 if scomp is not None:
3650 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3651 # Check if the root label of the algorithms exists
3652 if res and hypRoot is not None:
3653 iter = study.NewChildIterator(hypRoot)
3654 # Check all published algorithms
3656 algo_so_i = iter.Value()
3657 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3658 if attr is not None:
3659 anIOR = attr.Value()
3660 algo_o_i = salome.orb.string_to_object(anIOR)
3661 if algo_o_i is not None:
3662 # Check if this is an algorithm
3663 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3664 if algo_i is not None:
3665 # Checks if the algorithm belongs to the current engine
3666 if smeshpyD.GetObjectId(algo_i) > 0:
3667 # Check if this is the required algorithm
3668 if algo_i.GetName() == algoname:
3681 ## If the algorithm is global, returns 0; \n
3682 # else returns the submesh associated to this algorithm.
3683 def GetSubMesh(self):
3686 ## Returns the wrapped mesher.
3687 def GetAlgorithm(self):
3690 ## Gets the list of hypothesis that can be used with this algorithm
3691 def GetCompatibleHypothesis(self):
3694 mylist = self.algo.GetCompatibleHypothesis()
3697 ## Gets the name of the algorithm
3701 ## Sets the name to the algorithm
3702 def SetName(self, name):
3703 self.mesh.smeshpyD.SetName(self.algo, name)
3705 ## Gets the id of the algorithm
3707 return self.algo.GetId()
3710 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3712 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3713 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3715 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3717 self.Assign(algo, mesh, geom)
3721 def Assign(self, algo, mesh, geom):
3723 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3731 name = GetName(geom)
3734 name = mesh.geompyD.SubShapeName(geom, piece)
3735 mesh.geompyD.addToStudyInFather(piece, geom, name)
3737 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3740 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3741 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3743 def CompareHyp (self, hyp, args):
3744 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3747 def CompareEqualHyp (self, hyp, args):
3751 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3752 UseExisting=0, CompareMethod=""):
3755 if CompareMethod == "": CompareMethod = self.CompareHyp
3756 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3759 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3765 a = a + s + str(args[i])
3769 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3771 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3772 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3775 ## Returns entry of the shape to mesh in the study
3776 def MainShapeEntry(self):
3778 if not self.mesh or not self.mesh.GetMesh(): return entry
3779 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3780 study = self.mesh.smeshpyD.GetCurrentStudy()
3781 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3782 sobj = study.FindObjectIOR(ior)
3783 if sobj: entry = sobj.GetID()
3784 if not entry: return ""
3787 # Public class: Mesh_Segment
3788 # --------------------------
3790 ## Class to define a segment 1D algorithm for discretization
3793 # @ingroup l3_algos_basic
3794 class Mesh_Segment(Mesh_Algorithm):
3796 ## Private constructor.
3797 def __init__(self, mesh, geom=0):
3798 Mesh_Algorithm.__init__(self)
3799 self.Create(mesh, geom, "Regular_1D")
3801 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3802 # @param l for the length of segments that cut an edge
3803 # @param UseExisting if ==true - searches for an existing hypothesis created with
3804 # the same parameters, else (default) - creates a new one
3805 # @param p precision, used for calculation of the number of segments.
3806 # The precision should be a positive, meaningful value within the range [0,1].
3807 # In general, the number of segments is calculated with the formula:
3808 # nb = ceil((edge_length / l) - p)
3809 # Function ceil rounds its argument to the higher integer.
3810 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3811 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3812 # p=1 means rounding of (edge_length / l) to the lower integer.
3813 # Default value is 1e-07.
3814 # @return an instance of StdMeshers_LocalLength hypothesis
3815 # @ingroup l3_hypos_1dhyps
3816 def LocalLength(self, l, UseExisting=0, p=1e-07):
3817 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3818 CompareMethod=self.CompareLocalLength)
3824 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3825 def CompareLocalLength(self, hyp, args):
3826 if IsEqual(hyp.GetLength(), args[0]):
3827 return IsEqual(hyp.GetPrecision(), args[1])
3830 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3831 # @param length is optional maximal allowed length of segment, if it is omitted
3832 # the preestimated length is used that depends on geometry size
3833 # @param UseExisting if ==true - searches for an existing hypothesis created with
3834 # the same parameters, else (default) - create a new one
3835 # @return an instance of StdMeshers_MaxLength hypothesis
3836 # @ingroup l3_hypos_1dhyps
3837 def MaxSize(self, length=0.0, UseExisting=0):
3838 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3841 hyp.SetLength(length)
3843 # set preestimated length
3844 gen = self.mesh.smeshpyD
3845 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3846 self.mesh.GetMesh(), self.mesh.GetShape(),
3848 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3850 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3853 hyp.SetUsePreestimatedLength( length == 0.0 )
3856 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3857 # @param n for the number of segments that cut an edge
3858 # @param s for the scale factor (optional)
3859 # @param reversedEdges is a list of edges to mesh using reversed orientation
3860 # @param UseExisting if ==true - searches for an existing hypothesis created with
3861 # the same parameters, else (default) - create a new one
3862 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3863 # @ingroup l3_hypos_1dhyps
3864 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3865 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3866 reversedEdges, UseExisting = [], reversedEdges
3867 entry = self.MainShapeEntry()
3869 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3870 UseExisting=UseExisting,
3871 CompareMethod=self.CompareNumberOfSegments)
3873 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3874 UseExisting=UseExisting,
3875 CompareMethod=self.CompareNumberOfSegments)
3876 hyp.SetDistrType( 1 )
3877 hyp.SetScaleFactor(s)
3878 hyp.SetNumberOfSegments(n)
3879 hyp.SetReversedEdges( reversedEdges )
3880 hyp.SetObjectEntry( entry )
3884 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3885 def CompareNumberOfSegments(self, hyp, args):
3886 if hyp.GetNumberOfSegments() == args[0]:
3888 if hyp.GetReversedEdges() == args[1]:
3889 if not args[1] or hyp.GetObjectEntry() == args[2]:
3892 if hyp.GetReversedEdges() == args[2]:
3893 if not args[2] or hyp.GetObjectEntry() == args[3]:
3894 if hyp.GetDistrType() == 1:
3895 if IsEqual(hyp.GetScaleFactor(), args[1]):
3899 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3900 # @param start defines the length of the first segment
3901 # @param end defines the length of the last segment
3902 # @param reversedEdges is a list of edges to mesh using reversed orientation
3903 # @param UseExisting if ==true - searches for an existing hypothesis created with
3904 # the same parameters, else (default) - creates a new one
3905 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3906 # @ingroup l3_hypos_1dhyps
3907 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3908 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3909 reversedEdges, UseExisting = [], reversedEdges
3910 entry = self.MainShapeEntry()
3911 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3912 UseExisting=UseExisting,
3913 CompareMethod=self.CompareArithmetic1D)
3914 hyp.SetStartLength(start)
3915 hyp.SetEndLength(end)
3916 hyp.SetReversedEdges( reversedEdges )
3917 hyp.SetObjectEntry( entry )
3921 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3922 def CompareArithmetic1D(self, hyp, args):
3923 if IsEqual(hyp.GetLength(1), args[0]):
3924 if IsEqual(hyp.GetLength(0), args[1]):
3925 if hyp.GetReversedEdges() == args[2]:
3926 if not args[2] or hyp.GetObjectEntry() == args[3]:
3931 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3932 # on curve from 0 to 1 (additionally it is neecessary to check
3933 # orientation of edges and create list of reversed edges if it is
3934 # needed) and sets numbers of segments between given points (default
3935 # values are equals 1
3936 # @param points defines the list of parameters on curve
3937 # @param nbSegs defines the list of numbers of segments
3938 # @param reversedEdges is a list of edges to mesh using reversed orientation
3939 # @param UseExisting if ==true - searches for an existing hypothesis created with
3940 # the same parameters, else (default) - creates a new one
3941 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3942 # @ingroup l3_hypos_1dhyps
3943 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3944 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3945 reversedEdges, UseExisting = [], reversedEdges
3946 entry = self.MainShapeEntry()
3947 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3948 UseExisting=UseExisting,
3949 CompareMethod=self.CompareArithmetic1D)
3950 hyp.SetPoints(points)
3951 hyp.SetNbSegments(nbSegs)
3952 hyp.SetReversedEdges(reversedEdges)
3953 hyp.SetObjectEntry(entry)
3957 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3958 ## as the given arguments
3959 def CompareFixedPoints1D(self, hyp, args):
3960 if hyp.GetPoints() == args[0]:
3961 if hyp.GetNbSegments() == args[1]:
3962 if hyp.GetReversedEdges() == args[2]:
3963 if not args[2] or hyp.GetObjectEntry() == args[3]:
3969 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3970 # @param start defines the length of the first segment
3971 # @param end defines the length of the last segment
3972 # @param reversedEdges is a list of edges to mesh using reversed orientation
3973 # @param UseExisting if ==true - searches for an existing hypothesis created with
3974 # the same parameters, else (default) - creates a new one
3975 # @return an instance of StdMeshers_StartEndLength hypothesis
3976 # @ingroup l3_hypos_1dhyps
3977 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3978 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3979 reversedEdges, UseExisting = [], reversedEdges
3980 entry = self.MainShapeEntry()
3981 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3982 UseExisting=UseExisting,
3983 CompareMethod=self.CompareStartEndLength)
3984 hyp.SetStartLength(start)
3985 hyp.SetEndLength(end)
3986 hyp.SetReversedEdges( reversedEdges )
3987 hyp.SetObjectEntry( entry )
3990 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3991 def CompareStartEndLength(self, hyp, args):
3992 if IsEqual(hyp.GetLength(1), args[0]):
3993 if IsEqual(hyp.GetLength(0), args[1]):
3994 if hyp.GetReversedEdges() == args[2]:
3995 if not args[2] or hyp.GetObjectEntry() == args[3]:
3999 ## Defines "Deflection1D" hypothesis
4000 # @param d for the deflection
4001 # @param UseExisting if ==true - searches for an existing hypothesis created with
4002 # the same parameters, else (default) - create a new one
4003 # @ingroup l3_hypos_1dhyps
4004 def Deflection1D(self, d, UseExisting=0):
4005 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4006 CompareMethod=self.CompareDeflection1D)
4007 hyp.SetDeflection(d)
4010 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4011 def CompareDeflection1D(self, hyp, args):
4012 return IsEqual(hyp.GetDeflection(), args[0])
4014 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4015 # the opposite side in case of quadrangular faces
4016 # @ingroup l3_hypos_additi
4017 def Propagation(self):
4018 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4020 ## Defines "AutomaticLength" hypothesis
4021 # @param fineness for the fineness [0-1]
4022 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4023 # same parameters, else (default) - create a new one
4024 # @ingroup l3_hypos_1dhyps
4025 def AutomaticLength(self, fineness=0, UseExisting=0):
4026 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4027 CompareMethod=self.CompareAutomaticLength)
4028 hyp.SetFineness( fineness )
4031 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4032 def CompareAutomaticLength(self, hyp, args):
4033 return IsEqual(hyp.GetFineness(), args[0])
4035 ## Defines "SegmentLengthAroundVertex" hypothesis
4036 # @param length for the segment length
4037 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4038 # Any other integer value means that the hypothesis will be set on the
4039 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4040 # @param UseExisting if ==true - searches for an existing hypothesis created with
4041 # the same parameters, else (default) - creates a new one
4042 # @ingroup l3_algos_segmarv
4043 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4045 store_geom = self.geom
4046 if type(vertex) is types.IntType:
4047 if vertex == 0 or vertex == 1:
4048 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4056 if self.geom is None:
4057 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4059 name = GetName(self.geom)
4062 piece = self.mesh.geom
4063 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4064 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4066 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4068 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4070 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4071 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4073 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4074 CompareMethod=self.CompareLengthNearVertex)
4075 self.geom = store_geom
4076 hyp.SetLength( length )
4079 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4080 # @ingroup l3_algos_segmarv
4081 def CompareLengthNearVertex(self, hyp, args):
4082 return IsEqual(hyp.GetLength(), args[0])
4084 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4085 # If the 2D mesher sees that all boundary edges are quadratic,
4086 # it generates quadratic faces, else it generates linear faces using
4087 # medium nodes as if they are vertices.
4088 # The 3D mesher generates quadratic volumes only if all boundary faces
4089 # are quadratic, else it fails.
4091 # @ingroup l3_hypos_additi
4092 def QuadraticMesh(self):
4093 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4096 # Public class: Mesh_CompositeSegment
4097 # --------------------------
4099 ## Defines a segment 1D algorithm for discretization
4101 # @ingroup l3_algos_basic
4102 class Mesh_CompositeSegment(Mesh_Segment):
4104 ## Private constructor.
4105 def __init__(self, mesh, geom=0):
4106 self.Create(mesh, geom, "CompositeSegment_1D")
4109 # Public class: Mesh_Segment_Python
4110 # ---------------------------------
4112 ## Defines a segment 1D algorithm for discretization with python function
4114 # @ingroup l3_algos_basic
4115 class Mesh_Segment_Python(Mesh_Segment):
4117 ## Private constructor.
4118 def __init__(self, mesh, geom=0):
4119 import Python1dPlugin
4120 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4122 ## Defines "PythonSplit1D" hypothesis
4123 # @param n for the number of segments that cut an edge
4124 # @param func for the python function that calculates the length of all segments
4125 # @param UseExisting if ==true - searches for the existing hypothesis created with
4126 # the same parameters, else (default) - creates a new one
4127 # @ingroup l3_hypos_1dhyps
4128 def PythonSplit1D(self, n, func, UseExisting=0):
4129 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4130 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4131 hyp.SetNumberOfSegments(n)
4132 hyp.SetPythonLog10RatioFunction(func)
4135 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4136 def ComparePythonSplit1D(self, hyp, args):
4137 #if hyp.GetNumberOfSegments() == args[0]:
4138 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4142 # Public class: Mesh_Triangle
4143 # ---------------------------
4145 ## Defines a triangle 2D algorithm
4147 # @ingroup l3_algos_basic
4148 class Mesh_Triangle(Mesh_Algorithm):
4157 ## Private constructor.
4158 def __init__(self, mesh, algoType, geom=0):
4159 Mesh_Algorithm.__init__(self)
4161 self.algoType = algoType
4162 if algoType == MEFISTO:
4163 self.Create(mesh, geom, "MEFISTO_2D")
4165 elif algoType == BLSURF:
4167 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4168 #self.SetPhysicalMesh() - PAL19680
4169 elif algoType == NETGEN:
4171 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4173 elif algoType == NETGEN_2D:
4175 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4178 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4179 # @param area for the maximum area of each triangle
4180 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4181 # same parameters, else (default) - creates a new one
4183 # Only for algoType == MEFISTO || NETGEN_2D
4184 # @ingroup l3_hypos_2dhyps
4185 def MaxElementArea(self, area, UseExisting=0):
4186 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4187 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4188 CompareMethod=self.CompareMaxElementArea)
4189 elif self.algoType == NETGEN:
4190 hyp = self.Parameters(SIMPLE)
4191 hyp.SetMaxElementArea(area)
4194 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4195 def CompareMaxElementArea(self, hyp, args):
4196 return IsEqual(hyp.GetMaxElementArea(), args[0])
4198 ## Defines "LengthFromEdges" hypothesis to build triangles
4199 # based on the length of the edges taken from the wire
4201 # Only for algoType == MEFISTO || NETGEN_2D
4202 # @ingroup l3_hypos_2dhyps
4203 def LengthFromEdges(self):
4204 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4205 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4207 elif self.algoType == NETGEN:
4208 hyp = self.Parameters(SIMPLE)
4209 hyp.LengthFromEdges()
4212 ## Sets a way to define size of mesh elements to generate.
4213 # @param thePhysicalMesh is: DefaultSize or Custom.
4214 # @ingroup l3_hypos_blsurf
4215 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4216 # Parameter of BLSURF algo
4217 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4219 ## Sets size of mesh elements to generate.
4220 # @ingroup l3_hypos_blsurf
4221 def SetPhySize(self, theVal):
4222 # Parameter of BLSURF algo
4223 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4224 self.Parameters().SetPhySize(theVal)
4226 ## Sets lower boundary of mesh element size (PhySize).
4227 # @ingroup l3_hypos_blsurf
4228 def SetPhyMin(self, theVal=-1):
4229 # Parameter of BLSURF algo
4230 self.Parameters().SetPhyMin(theVal)
4232 ## Sets upper boundary of mesh element size (PhySize).
4233 # @ingroup l3_hypos_blsurf
4234 def SetPhyMax(self, theVal=-1):
4235 # Parameter of BLSURF algo
4236 self.Parameters().SetPhyMax(theVal)
4238 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4239 # @param theGeometricMesh is: DefaultGeom or Custom
4240 # @ingroup l3_hypos_blsurf
4241 def SetGeometricMesh(self, theGeometricMesh=0):
4242 # Parameter of BLSURF algo
4243 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4244 self.params.SetGeometricMesh(theGeometricMesh)
4246 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4247 # @ingroup l3_hypos_blsurf
4248 def SetAngleMeshS(self, theVal=_angleMeshS):
4249 # Parameter of BLSURF algo
4250 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4251 self.params.SetAngleMeshS(theVal)
4253 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4254 # @ingroup l3_hypos_blsurf
4255 def SetAngleMeshC(self, theVal=_angleMeshS):
4256 # Parameter of BLSURF algo
4257 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4258 self.params.SetAngleMeshC(theVal)
4260 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4261 # @ingroup l3_hypos_blsurf
4262 def SetGeoMin(self, theVal=-1):
4263 # Parameter of BLSURF algo
4264 self.Parameters().SetGeoMin(theVal)
4266 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4267 # @ingroup l3_hypos_blsurf
4268 def SetGeoMax(self, theVal=-1):
4269 # Parameter of BLSURF algo
4270 self.Parameters().SetGeoMax(theVal)
4272 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4273 # @ingroup l3_hypos_blsurf
4274 def SetGradation(self, theVal=_gradation):
4275 # Parameter of BLSURF algo
4276 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4277 self.params.SetGradation(theVal)
4279 ## Sets topology usage way.
4280 # @param way defines how mesh conformity is assured <ul>
4281 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4282 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4283 # @ingroup l3_hypos_blsurf
4284 def SetTopology(self, way):
4285 # Parameter of BLSURF algo
4286 self.Parameters().SetTopology(way)
4288 ## To respect geometrical edges or not.
4289 # @ingroup l3_hypos_blsurf
4290 def SetDecimesh(self, toIgnoreEdges=False):
4291 # Parameter of BLSURF algo
4292 self.Parameters().SetDecimesh(toIgnoreEdges)
4294 ## Sets verbosity level in the range 0 to 100.
4295 # @ingroup l3_hypos_blsurf
4296 def SetVerbosity(self, level):
4297 # Parameter of BLSURF algo
4298 self.Parameters().SetVerbosity(level)
4300 ## Sets advanced option value.
4301 # @ingroup l3_hypos_blsurf
4302 def SetOptionValue(self, optionName, level):
4303 # Parameter of BLSURF algo
4304 self.Parameters().SetOptionValue(optionName,level)
4306 ## Sets QuadAllowed flag.
4307 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4308 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4309 def SetQuadAllowed(self, toAllow=True):
4310 if self.algoType == NETGEN_2D:
4311 if toAllow: # add QuadranglePreference
4312 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4313 else: # remove QuadranglePreference
4314 for hyp in self.mesh.GetHypothesisList( self.geom ):
4315 if hyp.GetName() == "QuadranglePreference":
4316 self.mesh.RemoveHypothesis( self.geom, hyp )
4321 if self.Parameters():
4322 self.params.SetQuadAllowed(toAllow)
4325 ## Defines hypothesis having several parameters
4327 # @ingroup l3_hypos_netgen
4328 def Parameters(self, which=SOLE):
4331 if self.algoType == NETGEN:
4333 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4334 "libNETGENEngine.so", UseExisting=0)
4336 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4337 "libNETGENEngine.so", UseExisting=0)
4339 elif self.algoType == MEFISTO:
4340 print "Mefisto algo support no multi-parameter hypothesis"
4342 elif self.algoType == NETGEN_2D:
4343 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4344 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4346 elif self.algoType == BLSURF:
4347 self.params = self.Hypothesis("BLSURF_Parameters", [],
4348 "libBLSURFEngine.so", UseExisting=0)
4351 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4356 # Only for algoType == NETGEN
4357 # @ingroup l3_hypos_netgen
4358 def SetMaxSize(self, theSize):
4359 if self.Parameters():
4360 self.params.SetMaxSize(theSize)
4362 ## Sets SecondOrder flag
4364 # Only for algoType == NETGEN
4365 # @ingroup l3_hypos_netgen
4366 def SetSecondOrder(self, theVal):
4367 if self.Parameters():
4368 self.params.SetSecondOrder(theVal)
4370 ## Sets Optimize flag
4372 # Only for algoType == NETGEN
4373 # @ingroup l3_hypos_netgen
4374 def SetOptimize(self, theVal):
4375 if self.Parameters():
4376 self.params.SetOptimize(theVal)
4379 # @param theFineness is:
4380 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4382 # Only for algoType == NETGEN
4383 # @ingroup l3_hypos_netgen
4384 def SetFineness(self, theFineness):
4385 if self.Parameters():
4386 self.params.SetFineness(theFineness)
4390 # Only for algoType == NETGEN
4391 # @ingroup l3_hypos_netgen
4392 def SetGrowthRate(self, theRate):
4393 if self.Parameters():
4394 self.params.SetGrowthRate(theRate)
4396 ## Sets NbSegPerEdge
4398 # Only for algoType == NETGEN
4399 # @ingroup l3_hypos_netgen
4400 def SetNbSegPerEdge(self, theVal):
4401 if self.Parameters():
4402 self.params.SetNbSegPerEdge(theVal)
4404 ## Sets NbSegPerRadius
4406 # Only for algoType == NETGEN
4407 # @ingroup l3_hypos_netgen
4408 def SetNbSegPerRadius(self, theVal):
4409 if self.Parameters():
4410 self.params.SetNbSegPerRadius(theVal)
4412 ## Sets number of segments overriding value set by SetLocalLength()
4414 # Only for algoType == NETGEN
4415 # @ingroup l3_hypos_netgen
4416 def SetNumberOfSegments(self, theVal):
4417 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4419 ## Sets number of segments overriding value set by SetNumberOfSegments()
4421 # Only for algoType == NETGEN
4422 # @ingroup l3_hypos_netgen
4423 def SetLocalLength(self, theVal):
4424 self.Parameters(SIMPLE).SetLocalLength(theVal)
4429 # Public class: Mesh_Quadrangle
4430 # -----------------------------
4432 ## Defines a quadrangle 2D algorithm
4434 # @ingroup l3_algos_basic
4435 class Mesh_Quadrangle(Mesh_Algorithm):
4437 ## Private constructor.
4438 def __init__(self, mesh, geom=0):
4439 Mesh_Algorithm.__init__(self)
4440 self.Create(mesh, geom, "Quadrangle_2D")
4442 ## Defines "QuadranglePreference" hypothesis, forcing construction
4443 # of quadrangles if the number of nodes on the opposite edges is not the same
4444 # while the total number of nodes on edges is even
4446 # @ingroup l3_hypos_additi
4447 def QuadranglePreference(self):
4448 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4449 CompareMethod=self.CompareEqualHyp)
4452 ## Defines "TrianglePreference" hypothesis, forcing construction
4453 # of triangles in the refinement area if the number of nodes
4454 # on the opposite edges is not the same
4456 # @ingroup l3_hypos_additi
4457 def TrianglePreference(self):
4458 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4459 CompareMethod=self.CompareEqualHyp)
4462 # Public class: Mesh_Tetrahedron
4463 # ------------------------------
4465 ## Defines a tetrahedron 3D algorithm
4467 # @ingroup l3_algos_basic
4468 class Mesh_Tetrahedron(Mesh_Algorithm):
4473 ## Private constructor.
4474 def __init__(self, mesh, algoType, geom=0):
4475 Mesh_Algorithm.__init__(self)
4477 if algoType == NETGEN:
4479 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4482 elif algoType == FULL_NETGEN:
4484 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4487 elif algoType == GHS3D:
4489 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4492 elif algoType == GHS3DPRL:
4493 CheckPlugin(GHS3DPRL)
4494 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4497 self.algoType = algoType
4499 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4500 # @param vol for the maximum volume of each tetrahedron
4501 # @param UseExisting if ==true - searches for the existing hypothesis created with
4502 # the same parameters, else (default) - creates a new one
4503 # @ingroup l3_hypos_maxvol
4504 def MaxElementVolume(self, vol, UseExisting=0):
4505 if self.algoType == NETGEN:
4506 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4507 CompareMethod=self.CompareMaxElementVolume)
4508 hyp.SetMaxElementVolume(vol)
4510 elif self.algoType == FULL_NETGEN:
4511 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4514 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4515 def CompareMaxElementVolume(self, hyp, args):
4516 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4518 ## Defines hypothesis having several parameters
4520 # @ingroup l3_hypos_netgen
4521 def Parameters(self, which=SOLE):
4525 if self.algoType == FULL_NETGEN:
4527 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4528 "libNETGENEngine.so", UseExisting=0)
4530 self.params = self.Hypothesis("NETGEN_Parameters", [],
4531 "libNETGENEngine.so", UseExisting=0)
4534 if self.algoType == GHS3D:
4535 self.params = self.Hypothesis("GHS3D_Parameters", [],
4536 "libGHS3DEngine.so", UseExisting=0)
4539 if self.algoType == GHS3DPRL:
4540 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4541 "libGHS3DPRLEngine.so", UseExisting=0)
4544 print "Algo supports no multi-parameter hypothesis"
4548 # Parameter of FULL_NETGEN
4549 # @ingroup l3_hypos_netgen
4550 def SetMaxSize(self, theSize):
4551 self.Parameters().SetMaxSize(theSize)
4553 ## Sets SecondOrder flag
4554 # Parameter of FULL_NETGEN
4555 # @ingroup l3_hypos_netgen
4556 def SetSecondOrder(self, theVal):
4557 self.Parameters().SetSecondOrder(theVal)
4559 ## Sets Optimize flag
4560 # Parameter of FULL_NETGEN
4561 # @ingroup l3_hypos_netgen
4562 def SetOptimize(self, theVal):
4563 self.Parameters().SetOptimize(theVal)
4566 # @param theFineness is:
4567 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4568 # Parameter of FULL_NETGEN
4569 # @ingroup l3_hypos_netgen
4570 def SetFineness(self, theFineness):
4571 self.Parameters().SetFineness(theFineness)
4574 # Parameter of FULL_NETGEN
4575 # @ingroup l3_hypos_netgen
4576 def SetGrowthRate(self, theRate):
4577 self.Parameters().SetGrowthRate(theRate)
4579 ## Sets NbSegPerEdge
4580 # Parameter of FULL_NETGEN
4581 # @ingroup l3_hypos_netgen
4582 def SetNbSegPerEdge(self, theVal):
4583 self.Parameters().SetNbSegPerEdge(theVal)
4585 ## Sets NbSegPerRadius
4586 # Parameter of FULL_NETGEN
4587 # @ingroup l3_hypos_netgen
4588 def SetNbSegPerRadius(self, theVal):
4589 self.Parameters().SetNbSegPerRadius(theVal)
4591 ## Sets number of segments overriding value set by SetLocalLength()
4592 # Only for algoType == NETGEN_FULL
4593 # @ingroup l3_hypos_netgen
4594 def SetNumberOfSegments(self, theVal):
4595 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4597 ## Sets number of segments overriding value set by SetNumberOfSegments()
4598 # Only for algoType == NETGEN_FULL
4599 # @ingroup l3_hypos_netgen
4600 def SetLocalLength(self, theVal):
4601 self.Parameters(SIMPLE).SetLocalLength(theVal)
4603 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4604 # Overrides value set by LengthFromEdges()
4605 # Only for algoType == NETGEN_FULL
4606 # @ingroup l3_hypos_netgen
4607 def MaxElementArea(self, area):
4608 self.Parameters(SIMPLE).SetMaxElementArea(area)
4610 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4611 # Overrides value set by MaxElementArea()
4612 # Only for algoType == NETGEN_FULL
4613 # @ingroup l3_hypos_netgen
4614 def LengthFromEdges(self):
4615 self.Parameters(SIMPLE).LengthFromEdges()
4617 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4618 # Overrides value set by MaxElementVolume()
4619 # Only for algoType == NETGEN_FULL
4620 # @ingroup l3_hypos_netgen
4621 def LengthFromFaces(self):
4622 self.Parameters(SIMPLE).LengthFromFaces()
4624 ## To mesh "holes" in a solid or not. Default is to mesh.
4625 # @ingroup l3_hypos_ghs3dh
4626 def SetToMeshHoles(self, toMesh):
4627 # Parameter of GHS3D
4628 self.Parameters().SetToMeshHoles(toMesh)
4630 ## Set Optimization level:
4631 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4632 # Strong_Optimization.
4633 # Default is Standard_Optimization
4634 # @ingroup l3_hypos_ghs3dh
4635 def SetOptimizationLevel(self, level):
4636 # Parameter of GHS3D
4637 self.Parameters().SetOptimizationLevel(level)
4639 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4640 # @ingroup l3_hypos_ghs3dh
4641 def SetMaximumMemory(self, MB):
4642 # Advanced parameter of GHS3D
4643 self.Parameters().SetMaximumMemory(MB)
4645 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4646 # automatic memory adjustment mode.
4647 # @ingroup l3_hypos_ghs3dh
4648 def SetInitialMemory(self, MB):
4649 # Advanced parameter of GHS3D
4650 self.Parameters().SetInitialMemory(MB)
4652 ## Path to working directory.
4653 # @ingroup l3_hypos_ghs3dh
4654 def SetWorkingDirectory(self, path):
4655 # Advanced parameter of GHS3D
4656 self.Parameters().SetWorkingDirectory(path)
4658 ## To keep working files or remove them. Log file remains in case of errors anyway.
4659 # @ingroup l3_hypos_ghs3dh
4660 def SetKeepFiles(self, toKeep):
4661 # Advanced parameter of GHS3D and GHS3DPRL
4662 self.Parameters().SetKeepFiles(toKeep)
4664 ## To set verbose level [0-10]. <ul>
4665 #<li> 0 - no standard output,
4666 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4667 # indicates when the final mesh is being saved. In addition the software
4668 # gives indication regarding the CPU time.
4669 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4670 # histogram of the skin mesh, quality statistics histogram together with
4671 # the characteristics of the final mesh.</ul>
4672 # @ingroup l3_hypos_ghs3dh
4673 def SetVerboseLevel(self, level):
4674 # Advanced parameter of GHS3D
4675 self.Parameters().SetVerboseLevel(level)
4677 ## To create new nodes.
4678 # @ingroup l3_hypos_ghs3dh
4679 def SetToCreateNewNodes(self, toCreate):
4680 # Advanced parameter of GHS3D
4681 self.Parameters().SetToCreateNewNodes(toCreate)
4683 ## To use boundary recovery version which tries to create mesh on a very poor
4684 # quality surface mesh.
4685 # @ingroup l3_hypos_ghs3dh
4686 def SetToUseBoundaryRecoveryVersion(self, toUse):
4687 # Advanced parameter of GHS3D
4688 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4690 ## Sets command line option as text.
4691 # @ingroup l3_hypos_ghs3dh
4692 def SetTextOption(self, option):
4693 # Advanced parameter of GHS3D
4694 self.Parameters().SetTextOption(option)
4696 ## Sets MED files name and path.
4697 def SetMEDName(self, value):
4698 self.Parameters().SetMEDName(value)
4700 ## Sets the number of partition of the initial mesh
4701 def SetNbPart(self, value):
4702 self.Parameters().SetNbPart(value)
4704 ## When big mesh, start tepal in background
4705 def SetBackground(self, value):
4706 self.Parameters().SetBackground(value)
4708 # Public class: Mesh_Hexahedron
4709 # ------------------------------
4711 ## Defines a hexahedron 3D algorithm
4713 # @ingroup l3_algos_basic
4714 class Mesh_Hexahedron(Mesh_Algorithm):
4719 ## Private constructor.
4720 def __init__(self, mesh, algoType=Hexa, geom=0):
4721 Mesh_Algorithm.__init__(self)
4723 self.algoType = algoType
4725 if algoType == Hexa:
4726 self.Create(mesh, geom, "Hexa_3D")
4729 elif algoType == Hexotic:
4730 CheckPlugin(Hexotic)
4731 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4734 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4735 # @ingroup l3_hypos_hexotic
4736 def MinMaxQuad(self, min=3, max=8, quad=True):
4737 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4739 self.params.SetHexesMinLevel(min)
4740 self.params.SetHexesMaxLevel(max)
4741 self.params.SetHexoticQuadrangles(quad)
4744 # Deprecated, only for compatibility!
4745 # Public class: Mesh_Netgen
4746 # ------------------------------
4748 ## Defines a NETGEN-based 2D or 3D algorithm
4749 # that needs no discrete boundary (i.e. independent)
4751 # This class is deprecated, only for compatibility!
4754 # @ingroup l3_algos_basic
4755 class Mesh_Netgen(Mesh_Algorithm):
4759 ## Private constructor.
4760 def __init__(self, mesh, is3D, geom=0):
4761 Mesh_Algorithm.__init__(self)
4767 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4771 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4774 ## Defines the hypothesis containing parameters of the algorithm
4775 def Parameters(self):
4777 hyp = self.Hypothesis("NETGEN_Parameters", [],
4778 "libNETGENEngine.so", UseExisting=0)
4780 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4781 "libNETGENEngine.so", UseExisting=0)
4784 # Public class: Mesh_Projection1D
4785 # ------------------------------
4787 ## Defines a projection 1D algorithm
4788 # @ingroup l3_algos_proj
4790 class Mesh_Projection1D(Mesh_Algorithm):
4792 ## Private constructor.
4793 def __init__(self, mesh, geom=0):
4794 Mesh_Algorithm.__init__(self)
4795 self.Create(mesh, geom, "Projection_1D")
4797 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4798 # a mesh pattern is taken, and, optionally, the association of vertices
4799 # between the source edge and a target edge (to which a hypothesis is assigned)
4800 # @param edge from which nodes distribution is taken
4801 # @param mesh from which nodes distribution is taken (optional)
4802 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4803 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4804 # to associate with \a srcV (optional)
4805 # @param UseExisting if ==true - searches for the existing hypothesis created with
4806 # the same parameters, else (default) - creates a new one
4807 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4808 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4810 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4811 hyp.SetSourceEdge( edge )
4812 if not mesh is None and isinstance(mesh, Mesh):
4813 mesh = mesh.GetMesh()
4814 hyp.SetSourceMesh( mesh )
4815 hyp.SetVertexAssociation( srcV, tgtV )
4818 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4819 #def CompareSourceEdge(self, hyp, args):
4820 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4824 # Public class: Mesh_Projection2D
4825 # ------------------------------
4827 ## Defines a projection 2D algorithm
4828 # @ingroup l3_algos_proj
4830 class Mesh_Projection2D(Mesh_Algorithm):
4832 ## Private constructor.
4833 def __init__(self, mesh, geom=0):
4834 Mesh_Algorithm.__init__(self)
4835 self.Create(mesh, geom, "Projection_2D")
4837 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4838 # a mesh pattern is taken, and, optionally, the association of vertices
4839 # between the source face and the target face (to which a hypothesis is assigned)
4840 # @param face from which the mesh pattern is taken
4841 # @param mesh from which the mesh pattern is taken (optional)
4842 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4843 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4844 # to associate with \a srcV1 (optional)
4845 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4846 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4847 # to associate with \a srcV2 (optional)
4848 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4849 # the same parameters, else (default) - forces the creation a new one
4851 # Note: all association vertices must belong to one edge of a face
4852 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4853 srcV2=None, tgtV2=None, UseExisting=0):
4854 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4856 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4857 hyp.SetSourceFace( face )
4858 if not mesh is None and isinstance(mesh, Mesh):
4859 mesh = mesh.GetMesh()
4860 hyp.SetSourceMesh( mesh )
4861 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4864 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4865 #def CompareSourceFace(self, hyp, args):
4866 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4869 # Public class: Mesh_Projection3D
4870 # ------------------------------
4872 ## Defines a projection 3D algorithm
4873 # @ingroup l3_algos_proj
4875 class Mesh_Projection3D(Mesh_Algorithm):
4877 ## Private constructor.
4878 def __init__(self, mesh, geom=0):
4879 Mesh_Algorithm.__init__(self)
4880 self.Create(mesh, geom, "Projection_3D")
4882 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4883 # the mesh pattern is taken, and, optionally, the association of vertices
4884 # between the source and the target solid (to which a hipothesis is assigned)
4885 # @param solid from where the mesh pattern is taken
4886 # @param mesh from where the mesh pattern is taken (optional)
4887 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4888 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4889 # to associate with \a srcV1 (optional)
4890 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4891 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4892 # to associate with \a srcV2 (optional)
4893 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4894 # the same parameters, else (default) - creates a new one
4896 # Note: association vertices must belong to one edge of a solid
4897 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4898 srcV2=0, tgtV2=0, UseExisting=0):
4899 hyp = self.Hypothesis("ProjectionSource3D",
4900 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4902 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4903 hyp.SetSource3DShape( solid )
4904 if not mesh is None and isinstance(mesh, Mesh):
4905 mesh = mesh.GetMesh()
4906 hyp.SetSourceMesh( mesh )
4907 if srcV1 and srcV2 and tgtV1 and tgtV2:
4908 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4909 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4912 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4913 #def CompareSourceShape3D(self, hyp, args):
4914 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4918 # Public class: Mesh_Prism
4919 # ------------------------
4921 ## Defines a 3D extrusion algorithm
4922 # @ingroup l3_algos_3dextr
4924 class Mesh_Prism3D(Mesh_Algorithm):
4926 ## Private constructor.
4927 def __init__(self, mesh, geom=0):
4928 Mesh_Algorithm.__init__(self)
4929 self.Create(mesh, geom, "Prism_3D")
4931 # Public class: Mesh_RadialPrism
4932 # -------------------------------
4934 ## Defines a Radial Prism 3D algorithm
4935 # @ingroup l3_algos_radialp
4937 class Mesh_RadialPrism3D(Mesh_Algorithm):
4939 ## Private constructor.
4940 def __init__(self, mesh, geom=0):
4941 Mesh_Algorithm.__init__(self)
4942 self.Create(mesh, geom, "RadialPrism_3D")
4944 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4945 self.nbLayers = None
4947 ## Return 3D hypothesis holding the 1D one
4948 def Get3DHypothesis(self):
4949 return self.distribHyp
4951 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4952 # hypothesis. Returns the created hypothesis
4953 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4954 #print "OwnHypothesis",hypType
4955 if not self.nbLayers is None:
4956 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4957 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4958 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4959 self.mesh.smeshpyD.SetCurrentStudy( None )
4960 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4961 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4962 self.distribHyp.SetLayerDistribution( hyp )
4965 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4966 # prisms to build between the inner and outer shells
4967 # @param n number of layers
4968 # @param UseExisting if ==true - searches for the existing hypothesis created with
4969 # the same parameters, else (default) - creates a new one
4970 def NumberOfLayers(self, n, UseExisting=0):
4971 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4972 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4973 CompareMethod=self.CompareNumberOfLayers)
4974 self.nbLayers.SetNumberOfLayers( n )
4975 return self.nbLayers
4977 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4978 def CompareNumberOfLayers(self, hyp, args):
4979 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4981 ## Defines "LocalLength" hypothesis, specifying the segment length
4982 # to build between the inner and the outer shells
4983 # @param l the length of segments
4984 # @param p the precision of rounding
4985 def LocalLength(self, l, p=1e-07):
4986 hyp = self.OwnHypothesis("LocalLength", [l,p])
4991 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4992 # prisms to build between the inner and the outer shells.
4993 # @param n the number of layers
4994 # @param s the scale factor (optional)
4995 def NumberOfSegments(self, n, s=[]):
4997 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4999 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5000 hyp.SetDistrType( 1 )
5001 hyp.SetScaleFactor(s)
5002 hyp.SetNumberOfSegments(n)
5005 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5006 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5007 # @param start the length of the first segment
5008 # @param end the length of the last segment
5009 def Arithmetic1D(self, start, end ):
5010 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5011 hyp.SetLength(start, 1)
5012 hyp.SetLength(end , 0)
5015 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5016 # to build between the inner and the outer shells as geometric length increasing
5017 # @param start for the length of the first segment
5018 # @param end for the length of the last segment
5019 def StartEndLength(self, start, end):
5020 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5021 hyp.SetLength(start, 1)
5022 hyp.SetLength(end , 0)
5025 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5026 # to build between the inner and outer shells
5027 # @param fineness defines the quality of the mesh within the range [0-1]
5028 def AutomaticLength(self, fineness=0):
5029 hyp = self.OwnHypothesis("AutomaticLength")
5030 hyp.SetFineness( fineness )
5033 # Public class: Mesh_RadialQuadrangle1D2D
5034 # -------------------------------
5036 ## Defines a Radial Quadrangle 1D2D algorithm
5037 # @ingroup l2_algos_radialq
5039 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5041 ## Private constructor.
5042 def __init__(self, mesh, geom=0):
5043 Mesh_Algorithm.__init__(self)
5044 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5046 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5047 self.nbLayers = None
5049 ## Return 2D hypothesis holding the 1D one
5050 def Get2DHypothesis(self):
5051 return self.distribHyp
5053 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5054 # hypothesis. Returns the created hypothesis
5055 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5056 #print "OwnHypothesis",hypType
5058 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5059 if self.distribHyp is None:
5060 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5062 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5063 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5064 self.mesh.smeshpyD.SetCurrentStudy( None )
5065 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5066 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5067 self.distribHyp.SetLayerDistribution( hyp )
5070 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5071 # @param n number of layers
5072 # @param UseExisting if ==true - searches for the existing hypothesis created with
5073 # the same parameters, else (default) - creates a new one
5074 def NumberOfLayers(self, n, UseExisting=0):
5076 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5077 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5078 CompareMethod=self.CompareNumberOfLayers)
5079 self.nbLayers.SetNumberOfLayers( n )
5080 return self.nbLayers
5082 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5083 def CompareNumberOfLayers(self, hyp, args):
5084 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5086 ## Defines "LocalLength" hypothesis, specifying the segment length
5087 # @param l the length of segments
5088 # @param p the precision of rounding
5089 def LocalLength(self, l, p=1e-07):
5090 hyp = self.OwnHypothesis("LocalLength", [l,p])
5095 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5096 # @param n the number of layers
5097 # @param s the scale factor (optional)
5098 def NumberOfSegments(self, n, s=[]):
5100 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5102 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5103 hyp.SetDistrType( 1 )
5104 hyp.SetScaleFactor(s)
5105 hyp.SetNumberOfSegments(n)
5108 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5109 # with a length that changes in arithmetic progression
5110 # @param start the length of the first segment
5111 # @param end the length of the last segment
5112 def Arithmetic1D(self, start, end ):
5113 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5114 hyp.SetLength(start, 1)
5115 hyp.SetLength(end , 0)
5118 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5119 # as geometric length increasing
5120 # @param start for the length of the first segment
5121 # @param end for the length of the last segment
5122 def StartEndLength(self, start, end):
5123 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5124 hyp.SetLength(start, 1)
5125 hyp.SetLength(end , 0)
5128 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5129 # @param fineness defines the quality of the mesh within the range [0-1]
5130 def AutomaticLength(self, fineness=0):
5131 hyp = self.OwnHypothesis("AutomaticLength")
5132 hyp.SetFineness( fineness )
5136 # Private class: Mesh_UseExisting
5137 # -------------------------------
5138 class Mesh_UseExisting(Mesh_Algorithm):
5140 def __init__(self, dim, mesh, geom=0):
5142 self.Create(mesh, geom, "UseExisting_1D")
5144 self.Create(mesh, geom, "UseExisting_2D")
5147 import salome_notebook
5148 notebook = salome_notebook.notebook
5150 ##Return values of the notebook variables
5151 def ParseParameters(last, nbParams,nbParam, value):
5155 listSize = len(last)
5156 for n in range(0,nbParams):
5158 if counter < listSize:
5159 strResult = strResult + last[counter]
5161 strResult = strResult + ""
5163 if isinstance(value, str):
5164 if notebook.isVariable(value):
5165 result = notebook.get(value)
5166 strResult=strResult+value
5168 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5170 strResult=strResult+str(value)
5172 if nbParams - 1 != counter:
5173 strResult=strResult+var_separator #":"
5175 return result, strResult
5177 #Wrapper class for StdMeshers_LocalLength hypothesis
5178 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5180 ## Set Length parameter value
5181 # @param length numerical value or name of variable from notebook
5182 def SetLength(self, length):
5183 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5184 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5185 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5187 ## Set Precision parameter value
5188 # @param precision numerical value or name of variable from notebook
5189 def SetPrecision(self, precision):
5190 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5191 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5192 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5194 #Registering the new proxy for LocalLength
5195 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5198 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5199 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5201 def SetLayerDistribution(self, hypo):
5202 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5203 hypo.ClearParameters();
5204 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5206 #Registering the new proxy for LayerDistribution
5207 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5209 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5210 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5212 ## Set Length parameter value
5213 # @param length numerical value or name of variable from notebook
5214 def SetLength(self, length):
5215 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5216 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5217 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5219 #Registering the new proxy for SegmentLengthAroundVertex
5220 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5223 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5224 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5226 ## Set Length parameter value
5227 # @param length numerical value or name of variable from notebook
5228 # @param isStart true is length is Start Length, otherwise false
5229 def SetLength(self, length, isStart):
5233 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5234 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5235 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5237 #Registering the new proxy for Arithmetic1D
5238 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5240 #Wrapper class for StdMeshers_Deflection1D hypothesis
5241 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5243 ## Set Deflection parameter value
5244 # @param deflection numerical value or name of variable from notebook
5245 def SetDeflection(self, deflection):
5246 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5247 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5248 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5250 #Registering the new proxy for Deflection1D
5251 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5253 #Wrapper class for StdMeshers_StartEndLength hypothesis
5254 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5256 ## Set Length parameter value
5257 # @param length numerical value or name of variable from notebook
5258 # @param isStart true is length is Start Length, otherwise false
5259 def SetLength(self, length, isStart):
5263 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5264 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5265 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5267 #Registering the new proxy for StartEndLength
5268 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5270 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5271 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5273 ## Set Max Element Area parameter value
5274 # @param area numerical value or name of variable from notebook
5275 def SetMaxElementArea(self, area):
5276 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5277 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5278 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5280 #Registering the new proxy for MaxElementArea
5281 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5284 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5285 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5287 ## Set Max Element Volume parameter value
5288 # @param volume numerical value or name of variable from notebook
5289 def SetMaxElementVolume(self, volume):
5290 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5291 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5292 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5294 #Registering the new proxy for MaxElementVolume
5295 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5298 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5299 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5301 ## Set Number Of Layers parameter value
5302 # @param nbLayers numerical value or name of variable from notebook
5303 def SetNumberOfLayers(self, nbLayers):
5304 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5305 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5306 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5308 #Registering the new proxy for NumberOfLayers
5309 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5311 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5312 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5314 ## Set Number Of Segments parameter value
5315 # @param nbSeg numerical value or name of variable from notebook
5316 def SetNumberOfSegments(self, nbSeg):
5317 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5318 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5319 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5320 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5322 ## Set Scale Factor parameter value
5323 # @param factor numerical value or name of variable from notebook
5324 def SetScaleFactor(self, factor):
5325 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5326 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5327 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5329 #Registering the new proxy for NumberOfSegments
5330 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5332 if not noNETGENPlugin:
5333 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5334 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5336 ## Set Max Size parameter value
5337 # @param maxsize numerical value or name of variable from notebook
5338 def SetMaxSize(self, maxsize):
5339 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5340 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5341 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5342 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5344 ## Set Growth Rate parameter value
5345 # @param value numerical value or name of variable from notebook
5346 def SetGrowthRate(self, value):
5347 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5348 value, parameters = ParseParameters(lastParameters,4,2,value)
5349 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5350 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5352 ## Set Number of Segments per Edge parameter value
5353 # @param value numerical value or name of variable from notebook
5354 def SetNbSegPerEdge(self, value):
5355 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5356 value, parameters = ParseParameters(lastParameters,4,3,value)
5357 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5358 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5360 ## Set Number of Segments per Radius parameter value
5361 # @param value numerical value or name of variable from notebook
5362 def SetNbSegPerRadius(self, value):
5363 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5364 value, parameters = ParseParameters(lastParameters,4,4,value)
5365 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5366 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5368 #Registering the new proxy for NETGENPlugin_Hypothesis
5369 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5372 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5373 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5376 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5377 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5379 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5380 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5382 ## Set Number of Segments parameter value
5383 # @param nbSeg numerical value or name of variable from notebook
5384 def SetNumberOfSegments(self, nbSeg):
5385 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5386 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5387 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5388 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5390 ## Set Local Length parameter value
5391 # @param length numerical value or name of variable from notebook
5392 def SetLocalLength(self, length):
5393 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5394 length, parameters = ParseParameters(lastParameters,2,1,length)
5395 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5396 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5398 ## Set Max Element Area parameter value
5399 # @param area numerical value or name of variable from notebook
5400 def SetMaxElementArea(self, area):
5401 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5402 area, parameters = ParseParameters(lastParameters,2,2,area)
5403 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5404 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5406 def LengthFromEdges(self):
5407 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5409 value, parameters = ParseParameters(lastParameters,2,2,value)
5410 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5411 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5413 #Registering the new proxy for NETGEN_SimpleParameters_2D
5414 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5417 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5418 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5419 ## Set Max Element Volume parameter value
5420 # @param volume numerical value or name of variable from notebook
5421 def SetMaxElementVolume(self, volume):
5422 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5423 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5424 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5425 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5427 def LengthFromFaces(self):
5428 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5430 value, parameters = ParseParameters(lastParameters,3,3,value)
5431 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5432 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5434 #Registering the new proxy for NETGEN_SimpleParameters_3D
5435 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5437 pass # if not noNETGENPlugin:
5439 class Pattern(SMESH._objref_SMESH_Pattern):
5441 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5443 if isinstance(theNodeIndexOnKeyPoint1,str):
5445 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5447 theNodeIndexOnKeyPoint1 -= 1
5448 theMesh.SetParameters(Parameters)
5449 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5451 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5454 if isinstance(theNode000Index,str):
5456 if isinstance(theNode001Index,str):
5458 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5460 theNode000Index -= 1
5462 theNode001Index -= 1
5463 theMesh.SetParameters(Parameters)
5464 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5466 #Registering the new proxy for Pattern
5467 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)