1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
168 # MirrorType enumeration
169 POINT = SMESH_MeshEditor.POINT
170 AXIS = SMESH_MeshEditor.AXIS
171 PLANE = SMESH_MeshEditor.PLANE
173 # Smooth_Method enumeration
174 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
175 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
177 # Fineness enumeration (for NETGEN)
185 # Optimization level of GHS3D
187 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
188 # V4.1 (partialy redefines V3.1). Issue 0020574
189 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
191 # Topology treatment way of BLSURF
192 FromCAD, PreProcess, PreProcessPlus = 0,1,2
194 # Element size flag of BLSURF
195 DefaultSize, DefaultGeom, Custom = 0,0,1
197 PrecisionConfusion = 1e-07
199 ## Converts an angle from degrees to radians
200 def DegreesToRadians(AngleInDegrees):
202 return AngleInDegrees * pi / 180.0
204 # Salome notebook variable separator
207 # Parametrized substitute for PointStruct
208 class PointStructStr:
217 def __init__(self, xStr, yStr, zStr):
221 if isinstance(xStr, str) and notebook.isVariable(xStr):
222 self.x = notebook.get(xStr)
225 if isinstance(yStr, str) and notebook.isVariable(yStr):
226 self.y = notebook.get(yStr)
229 if isinstance(zStr, str) and notebook.isVariable(zStr):
230 self.z = notebook.get(zStr)
234 # Parametrized substitute for PointStruct (with 6 parameters)
235 class PointStructStr6:
250 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
257 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
258 self.x1 = notebook.get(x1Str)
261 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
262 self.x2 = notebook.get(x2Str)
265 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
266 self.y1 = notebook.get(y1Str)
269 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
270 self.y2 = notebook.get(y2Str)
273 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
274 self.z1 = notebook.get(z1Str)
277 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
278 self.z2 = notebook.get(z2Str)
282 # Parametrized substitute for AxisStruct
298 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
305 if isinstance(xStr, str) and notebook.isVariable(xStr):
306 self.x = notebook.get(xStr)
309 if isinstance(yStr, str) and notebook.isVariable(yStr):
310 self.y = notebook.get(yStr)
313 if isinstance(zStr, str) and notebook.isVariable(zStr):
314 self.z = notebook.get(zStr)
317 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
318 self.dx = notebook.get(dxStr)
321 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
322 self.dy = notebook.get(dyStr)
325 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
326 self.dz = notebook.get(dzStr)
330 # Parametrized substitute for DirStruct
333 def __init__(self, pointStruct):
334 self.pointStruct = pointStruct
336 # Returns list of variable values from salome notebook
337 def ParsePointStruct(Point):
338 Parameters = 2*var_separator
339 if isinstance(Point, PointStructStr):
340 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
341 Point = PointStruct(Point.x, Point.y, Point.z)
342 return Point, Parameters
344 # Returns list of variable values from salome notebook
345 def ParseDirStruct(Dir):
346 Parameters = 2*var_separator
347 if isinstance(Dir, DirStructStr):
348 pntStr = Dir.pointStruct
349 if isinstance(pntStr, PointStructStr6):
350 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
351 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
352 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
353 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
355 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
356 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
357 Dir = DirStruct(Point)
358 return Dir, Parameters
360 # Returns list of variable values from salome notebook
361 def ParseAxisStruct(Axis):
362 Parameters = 5*var_separator
363 if isinstance(Axis, AxisStructStr):
364 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
365 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
366 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
367 return Axis, Parameters
369 ## Return list of variable values from salome notebook
370 def ParseAngles(list):
373 for parameter in list:
374 if isinstance(parameter,str) and notebook.isVariable(parameter):
375 Result.append(DegreesToRadians(notebook.get(parameter)))
378 Result.append(parameter)
381 Parameters = Parameters + str(parameter)
382 Parameters = Parameters + var_separator
384 Parameters = Parameters[:len(Parameters)-1]
385 return Result, Parameters
387 def IsEqual(val1, val2, tol=PrecisionConfusion):
388 if abs(val1 - val2) < tol:
396 ior = salome.orb.object_to_string(obj)
397 sobj = salome.myStudy.FindObjectIOR(ior)
401 attr = sobj.FindAttribute("AttributeName")[1]
404 ## Prints error message if a hypothesis was not assigned.
405 def TreatHypoStatus(status, hypName, geomName, isAlgo):
407 hypType = "algorithm"
409 hypType = "hypothesis"
411 if status == HYP_UNKNOWN_FATAL :
412 reason = "for unknown reason"
413 elif status == HYP_INCOMPATIBLE :
414 reason = "this hypothesis mismatches the algorithm"
415 elif status == HYP_NOTCONFORM :
416 reason = "a non-conform mesh would be built"
417 elif status == HYP_ALREADY_EXIST :
418 reason = hypType + " of the same dimension is already assigned to this shape"
419 elif status == HYP_BAD_DIM :
420 reason = hypType + " mismatches the shape"
421 elif status == HYP_CONCURENT :
422 reason = "there are concurrent hypotheses on sub-shapes"
423 elif status == HYP_BAD_SUBSHAPE :
424 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
425 elif status == HYP_BAD_GEOMETRY:
426 reason = "geometry mismatches the expectation of the algorithm"
427 elif status == HYP_HIDDEN_ALGO:
428 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
429 elif status == HYP_HIDING_ALGO:
430 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
431 elif status == HYP_NEED_SHAPE:
432 reason = "Algorithm can't work without shape"
435 hypName = '"' + hypName + '"'
436 geomName= '"' + geomName+ '"'
437 if status < HYP_UNKNOWN_FATAL:
438 print hypName, "was assigned to", geomName,"but", reason
440 print hypName, "was not assigned to",geomName,":", reason
443 ## Check meshing plugin availability
444 def CheckPlugin(plugin):
445 if plugin == NETGEN and noNETGENPlugin:
446 print "Warning: NETGENPlugin module unavailable"
448 elif plugin == GHS3D and noGHS3DPlugin:
449 print "Warning: GHS3DPlugin module unavailable"
451 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
452 print "Warning: GHS3DPRLPlugin module unavailable"
454 elif plugin == Hexotic and noHexoticPlugin:
455 print "Warning: HexoticPlugin module unavailable"
457 elif plugin == BLSURF and noBLSURFPlugin:
458 print "Warning: BLSURFPlugin module unavailable"
462 # end of l1_auxiliary
465 # All methods of this class are accessible directly from the smesh.py package.
466 class smeshDC(SMESH._objref_SMESH_Gen):
468 ## Sets the current study and Geometry component
469 # @ingroup l1_auxiliary
470 def init_smesh(self,theStudy,geompyD):
471 self.SetCurrentStudy(theStudy,geompyD)
473 ## Creates an empty Mesh. This mesh can have an underlying geometry.
474 # @param obj the Geometrical object on which the mesh is built. If not defined,
475 # the mesh will have no underlying geometry.
476 # @param name the name for the new mesh.
477 # @return an instance of Mesh class.
478 # @ingroup l2_construct
479 def Mesh(self, obj=0, name=0):
480 if isinstance(obj,str):
482 return Mesh(self,self.geompyD,obj,name)
484 ## Returns a long value from enumeration
485 # Should be used for SMESH.FunctorType enumeration
486 # @ingroup l1_controls
487 def EnumToLong(self,theItem):
490 ## Gets PointStruct from vertex
491 # @param theVertex a GEOM object(vertex)
492 # @return SMESH.PointStruct
493 # @ingroup l1_auxiliary
494 def GetPointStruct(self,theVertex):
495 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
496 return PointStruct(x,y,z)
498 ## Gets DirStruct from vector
499 # @param theVector a GEOM object(vector)
500 # @return SMESH.DirStruct
501 # @ingroup l1_auxiliary
502 def GetDirStruct(self,theVector):
503 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
504 if(len(vertices) != 2):
505 print "Error: vector object is incorrect."
507 p1 = self.geompyD.PointCoordinates(vertices[0])
508 p2 = self.geompyD.PointCoordinates(vertices[1])
509 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
510 dirst = DirStruct(pnt)
513 ## Makes DirStruct from a triplet
514 # @param x,y,z vector components
515 # @return SMESH.DirStruct
516 # @ingroup l1_auxiliary
517 def MakeDirStruct(self,x,y,z):
518 pnt = PointStruct(x,y,z)
519 return DirStruct(pnt)
521 ## Get AxisStruct from object
522 # @param theObj a GEOM object (line or plane)
523 # @return SMESH.AxisStruct
524 # @ingroup l1_auxiliary
525 def GetAxisStruct(self,theObj):
526 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
528 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
529 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
530 vertex1 = self.geompyD.PointCoordinates(vertex1)
531 vertex2 = self.geompyD.PointCoordinates(vertex2)
532 vertex3 = self.geompyD.PointCoordinates(vertex3)
533 vertex4 = self.geompyD.PointCoordinates(vertex4)
534 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
535 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
536 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] ]
537 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
539 elif len(edges) == 1:
540 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
541 p1 = self.geompyD.PointCoordinates( vertex1 )
542 p2 = self.geompyD.PointCoordinates( vertex2 )
543 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
547 # From SMESH_Gen interface:
548 # ------------------------
550 ## Sets the given name to the object
551 # @param obj the object to rename
552 # @param name a new object name
553 # @ingroup l1_auxiliary
554 def SetName(self, obj, name):
555 if isinstance( obj, Mesh ):
557 elif isinstance( obj, Mesh_Algorithm ):
558 obj = obj.GetAlgorithm()
559 ior = salome.orb.object_to_string(obj)
560 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
562 ## Sets the current mode
563 # @ingroup l1_auxiliary
564 def SetEmbeddedMode( self,theMode ):
565 #self.SetEmbeddedMode(theMode)
566 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
568 ## Gets the current mode
569 # @ingroup l1_auxiliary
570 def IsEmbeddedMode(self):
571 #return self.IsEmbeddedMode()
572 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
574 ## Sets the current study
575 # @ingroup l1_auxiliary
576 def SetCurrentStudy( self, theStudy, geompyD = None ):
577 #self.SetCurrentStudy(theStudy)
580 geompyD = geompy.geom
583 self.SetGeomEngine(geompyD)
584 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
586 ## Gets the current study
587 # @ingroup l1_auxiliary
588 def GetCurrentStudy(self):
589 #return self.GetCurrentStudy()
590 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
592 ## Creates a Mesh object importing data from the given UNV file
593 # @return an instance of Mesh class
595 def CreateMeshesFromUNV( self,theFileName ):
596 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
597 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
600 ## Creates a Mesh object(s) importing data from the given MED file
601 # @return a list of Mesh class instances
603 def CreateMeshesFromMED( self,theFileName ):
604 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
606 for iMesh in range(len(aSmeshMeshes)) :
607 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
608 aMeshes.append(aMesh)
609 return aMeshes, aStatus
611 ## Creates a Mesh object importing data from the given STL file
612 # @return an instance of Mesh class
614 def CreateMeshesFromSTL( self, theFileName ):
615 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
616 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
619 ## From SMESH_Gen interface
620 # @return the list of integer values
621 # @ingroup l1_auxiliary
622 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
623 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
625 ## From SMESH_Gen interface. Creates a pattern
626 # @return an instance of SMESH_Pattern
628 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
629 # @ingroup l2_modif_patterns
630 def GetPattern(self):
631 return SMESH._objref_SMESH_Gen.GetPattern(self)
633 ## Sets number of segments per diagonal of boundary box of geometry by which
634 # default segment length of appropriate 1D hypotheses is defined.
635 # Default value is 10
636 # @ingroup l1_auxiliary
637 def SetBoundaryBoxSegmentation(self, nbSegments):
638 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
640 ## Concatenate the given meshes into one mesh.
641 # @return an instance of Mesh class
642 # @param meshes the meshes to combine into one mesh
643 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
644 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
645 # @param mergeTolerance tolerance for merging nodes
646 # @param allGroups forces creation of groups of all elements
647 def Concatenate( self, meshes, uniteIdenticalGroups,
648 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
649 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
651 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
652 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
654 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
655 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
656 aSmeshMesh.SetParameters(Parameters)
657 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
660 # Filtering. Auxiliary functions:
661 # ------------------------------
663 ## Creates an empty criterion
664 # @return SMESH.Filter.Criterion
665 # @ingroup l1_controls
666 def GetEmptyCriterion(self):
667 Type = self.EnumToLong(FT_Undefined)
668 Compare = self.EnumToLong(FT_Undefined)
672 UnaryOp = self.EnumToLong(FT_Undefined)
673 BinaryOp = self.EnumToLong(FT_Undefined)
676 Precision = -1 ##@1e-07
677 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
678 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
680 ## Creates a criterion by the given parameters
681 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
682 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
683 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
684 # @param Treshold the threshold value (range of ids as string, shape, numeric)
685 # @param UnaryOp FT_LogicalNOT or FT_Undefined
686 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
687 # FT_Undefined (must be for the last criterion of all criteria)
688 # @return SMESH.Filter.Criterion
689 # @ingroup l1_controls
690 def GetCriterion(self,elementType,
692 Compare = FT_EqualTo,
694 UnaryOp=FT_Undefined,
695 BinaryOp=FT_Undefined):
696 aCriterion = self.GetEmptyCriterion()
697 aCriterion.TypeOfElement = elementType
698 aCriterion.Type = self.EnumToLong(CritType)
702 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
703 aCriterion.Compare = self.EnumToLong(Compare)
704 elif Compare == "=" or Compare == "==":
705 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
707 aCriterion.Compare = self.EnumToLong(FT_LessThan)
709 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
711 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
714 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
715 FT_BelongToCylinder, FT_LyingOnGeom]:
716 # Checks the treshold
717 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
718 aCriterion.ThresholdStr = GetName(aTreshold)
719 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
721 print "Error: The treshold should be a shape."
723 elif CritType == FT_RangeOfIds:
724 # Checks the treshold
725 if isinstance(aTreshold, str):
726 aCriterion.ThresholdStr = aTreshold
728 print "Error: The treshold should be a string."
730 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
731 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
732 # At this point the treshold is unnecessary
733 if aTreshold == FT_LogicalNOT:
734 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
735 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
736 aCriterion.BinaryOp = aTreshold
740 aTreshold = float(aTreshold)
741 aCriterion.Threshold = aTreshold
743 print "Error: The treshold should be a number."
746 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
747 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
749 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
750 aCriterion.BinaryOp = self.EnumToLong(Treshold)
752 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
753 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
755 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
756 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
760 ## Creates a filter with the given parameters
761 # @param elementType the type of elements in the group
762 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
763 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
764 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
765 # @param UnaryOp FT_LogicalNOT or FT_Undefined
766 # @return SMESH_Filter
767 # @ingroup l1_controls
768 def GetFilter(self,elementType,
769 CritType=FT_Undefined,
772 UnaryOp=FT_Undefined):
773 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
774 aFilterMgr = self.CreateFilterManager()
775 aFilter = aFilterMgr.CreateFilter()
777 aCriteria.append(aCriterion)
778 aFilter.SetCriteria(aCriteria)
781 ## Creates a numerical functor by its type
782 # @param theCriterion FT_...; functor type
783 # @return SMESH_NumericalFunctor
784 # @ingroup l1_controls
785 def GetFunctor(self,theCriterion):
786 aFilterMgr = self.CreateFilterManager()
787 if theCriterion == FT_AspectRatio:
788 return aFilterMgr.CreateAspectRatio()
789 elif theCriterion == FT_AspectRatio3D:
790 return aFilterMgr.CreateAspectRatio3D()
791 elif theCriterion == FT_Warping:
792 return aFilterMgr.CreateWarping()
793 elif theCriterion == FT_MinimumAngle:
794 return aFilterMgr.CreateMinimumAngle()
795 elif theCriterion == FT_Taper:
796 return aFilterMgr.CreateTaper()
797 elif theCriterion == FT_Skew:
798 return aFilterMgr.CreateSkew()
799 elif theCriterion == FT_Area:
800 return aFilterMgr.CreateArea()
801 elif theCriterion == FT_Volume3D:
802 return aFilterMgr.CreateVolume3D()
803 elif theCriterion == FT_MultiConnection:
804 return aFilterMgr.CreateMultiConnection()
805 elif theCriterion == FT_MultiConnection2D:
806 return aFilterMgr.CreateMultiConnection2D()
807 elif theCriterion == FT_Length:
808 return aFilterMgr.CreateLength()
809 elif theCriterion == FT_Length2D:
810 return aFilterMgr.CreateLength2D()
812 print "Error: given parameter is not numerucal functor type."
814 ## Creates hypothesis
815 # @param theHType mesh hypothesis type (string)
816 # @param theLibName mesh plug-in library name
817 # @return created hypothesis instance
818 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
819 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
821 ## Gets the mesh stattistic
822 # @return dictionary type element - count of elements
823 # @ingroup l1_meshinfo
824 def GetMeshInfo(self, obj):
825 if isinstance( obj, Mesh ):
828 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
829 values = obj.GetMeshInfo()
830 for i in range(SMESH.Entity_Last._v):
831 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
836 #Registering the new proxy for SMESH_Gen
837 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
843 ## This class allows defining and managing a mesh.
844 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
845 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
846 # new nodes and elements and by changing the existing entities), to get information
847 # about a mesh and to export a mesh into different formats.
856 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
857 # sets the GUI name of this mesh to \a name.
858 # @param smeshpyD an instance of smeshDC class
859 # @param geompyD an instance of geompyDC class
860 # @param obj Shape to be meshed or SMESH_Mesh object
861 # @param name Study name of the mesh
862 # @ingroup l2_construct
863 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
864 self.smeshpyD=smeshpyD
869 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
871 self.mesh = self.smeshpyD.CreateMesh(self.geom)
872 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
875 self.mesh = self.smeshpyD.CreateEmptyMesh()
877 self.smeshpyD.SetName(self.mesh, name)
879 self.smeshpyD.SetName(self.mesh, GetName(obj))
882 self.geom = self.mesh.GetShapeToMesh()
884 self.editor = self.mesh.GetMeshEditor()
886 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
887 # @param theMesh a SMESH_Mesh object
888 # @ingroup l2_construct
889 def SetMesh(self, theMesh):
891 self.geom = self.mesh.GetShapeToMesh()
893 ## Returns the mesh, that is an instance of SMESH_Mesh interface
894 # @return a SMESH_Mesh object
895 # @ingroup l2_construct
899 ## Gets the name of the mesh
900 # @return the name of the mesh as a string
901 # @ingroup l2_construct
903 name = GetName(self.GetMesh())
906 ## Sets a name to the mesh
907 # @param name a new name of the mesh
908 # @ingroup l2_construct
909 def SetName(self, name):
910 self.smeshpyD.SetName(self.GetMesh(), name)
912 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
913 # The subMesh object gives access to the IDs of nodes and elements.
914 # @param theSubObject a geometrical object (shape)
915 # @param theName a name for the submesh
916 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
917 # @ingroup l2_submeshes
918 def GetSubMesh(self, theSubObject, theName):
919 submesh = self.mesh.GetSubMesh(theSubObject, theName)
922 ## Returns the shape associated to the mesh
923 # @return a GEOM_Object
924 # @ingroup l2_construct
928 ## Associates the given shape to the mesh (entails the recreation of the mesh)
929 # @param geom the shape to be meshed (GEOM_Object)
930 # @ingroup l2_construct
931 def SetShape(self, geom):
932 self.mesh = self.smeshpyD.CreateMesh(geom)
934 ## Returns true if the hypotheses are defined well
935 # @param theSubObject a subshape of a mesh shape
936 # @return True or False
937 # @ingroup l2_construct
938 def IsReadyToCompute(self, theSubObject):
939 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
941 ## Returns errors of hypotheses definition.
942 # The list of errors is empty if everything is OK.
943 # @param theSubObject a subshape of a mesh shape
944 # @return a list of errors
945 # @ingroup l2_construct
946 def GetAlgoState(self, theSubObject):
947 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
949 ## Returns a geometrical object on which the given element was built.
950 # The returned geometrical object, if not nil, is either found in the
951 # study or published by this method with the given name
952 # @param theElementID the id of the mesh element
953 # @param theGeomName the user-defined name of the geometrical object
954 # @return GEOM::GEOM_Object instance
955 # @ingroup l2_construct
956 def GetGeometryByMeshElement(self, theElementID, theGeomName):
957 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
959 ## Returns the mesh dimension depending on the dimension of the underlying shape
960 # @return mesh dimension as an integer value [0,3]
961 # @ingroup l1_auxiliary
962 def MeshDimension(self):
963 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
964 if len( shells ) > 0 :
966 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
968 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
974 ## Creates a segment discretization 1D algorithm.
975 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
976 # \n If the optional \a geom parameter is not set, this algorithm is global.
977 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
978 # @param algo the type of the required algorithm. Possible values are:
980 # - smesh.PYTHON for discretization via a python function,
981 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
982 # @param geom If defined is the subshape to be meshed
983 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
984 # @ingroup l3_algos_basic
985 def Segment(self, algo=REGULAR, geom=0):
986 ## if Segment(geom) is called by mistake
987 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
988 algo, geom = geom, algo
989 if not algo: algo = REGULAR
992 return Mesh_Segment(self, geom)
994 return Mesh_Segment_Python(self, geom)
995 elif algo == COMPOSITE:
996 return Mesh_CompositeSegment(self, geom)
998 return Mesh_Segment(self, geom)
1000 ## Enables creation of nodes and segments usable by 2D algoritms.
1001 # The added nodes and segments must be bound to edges and vertices by
1002 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1003 # If the optional \a geom parameter is not set, this algorithm is global.
1004 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1005 # @param geom the subshape to be manually meshed
1006 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1007 # @ingroup l3_algos_basic
1008 def UseExistingSegments(self, geom=0):
1009 algo = Mesh_UseExisting(1,self,geom)
1010 return algo.GetAlgorithm()
1012 ## Enables creation of nodes and faces usable by 3D algoritms.
1013 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1014 # and SetMeshElementOnShape()
1015 # If the optional \a geom parameter is not set, this algorithm is global.
1016 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1017 # @param geom the subshape to be manually meshed
1018 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1019 # @ingroup l3_algos_basic
1020 def UseExistingFaces(self, geom=0):
1021 algo = Mesh_UseExisting(2,self,geom)
1022 return algo.GetAlgorithm()
1024 ## Creates a triangle 2D algorithm for faces.
1025 # If the optional \a geom parameter is not set, this algorithm is global.
1026 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1027 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1028 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1029 # @return an instance of Mesh_Triangle algorithm
1030 # @ingroup l3_algos_basic
1031 def Triangle(self, algo=MEFISTO, geom=0):
1032 ## if Triangle(geom) is called by mistake
1033 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1036 return Mesh_Triangle(self, algo, geom)
1038 ## Creates a quadrangle 2D algorithm for faces.
1039 # If the optional \a geom parameter is not set, this algorithm is global.
1040 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1041 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1042 # @param algo values are: smesh.QUARDANGLE || smesh.RADIAL_QUAD
1043 # @return an instance of Mesh_Quadrangle algorithm
1044 # @ingroup l3_algos_basic
1045 def Quadrangle(self, geom=0, algo=QUARDANGLE):
1046 if algo==RADIAL_QUAD:
1047 return Mesh_RadialQuadrangle1D2D(self,geom)
1049 return Mesh_Quadrangle(self, geom)
1051 ## Creates a tetrahedron 3D algorithm for solids.
1052 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1053 # If the optional \a geom parameter is not set, this algorithm is global.
1054 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1055 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1056 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1057 # @return an instance of Mesh_Tetrahedron algorithm
1058 # @ingroup l3_algos_basic
1059 def Tetrahedron(self, algo=NETGEN, geom=0):
1060 ## if Tetrahedron(geom) is called by mistake
1061 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1062 algo, geom = geom, algo
1063 if not algo: algo = NETGEN
1065 return Mesh_Tetrahedron(self, algo, geom)
1067 ## Creates a hexahedron 3D algorithm for solids.
1068 # If the optional \a geom parameter is not set, this algorithm is global.
1069 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1070 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1071 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1072 # @return an instance of Mesh_Hexahedron algorithm
1073 # @ingroup l3_algos_basic
1074 def Hexahedron(self, algo=Hexa, geom=0):
1075 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1076 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1077 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1078 elif geom == 0: algo, geom = Hexa, algo
1079 return Mesh_Hexahedron(self, algo, geom)
1081 ## Deprecated, used only for compatibility!
1082 # @return an instance of Mesh_Netgen algorithm
1083 # @ingroup l3_algos_basic
1084 def Netgen(self, is3D, geom=0):
1085 return Mesh_Netgen(self, is3D, geom)
1087 ## Creates a projection 1D algorithm for edges.
1088 # If the optional \a geom parameter is not set, this algorithm is global.
1089 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1090 # @param geom If defined, the subshape to be meshed
1091 # @return an instance of Mesh_Projection1D algorithm
1092 # @ingroup l3_algos_proj
1093 def Projection1D(self, geom=0):
1094 return Mesh_Projection1D(self, geom)
1096 ## Creates a projection 2D algorithm for faces.
1097 # If the optional \a geom parameter is not set, this algorithm is global.
1098 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1099 # @param geom If defined, the subshape to be meshed
1100 # @return an instance of Mesh_Projection2D algorithm
1101 # @ingroup l3_algos_proj
1102 def Projection2D(self, geom=0):
1103 return Mesh_Projection2D(self, geom)
1105 ## Creates a projection 3D algorithm for solids.
1106 # If the optional \a geom parameter is not set, this algorithm is global.
1107 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1108 # @param geom If defined, the subshape to be meshed
1109 # @return an instance of Mesh_Projection3D algorithm
1110 # @ingroup l3_algos_proj
1111 def Projection3D(self, geom=0):
1112 return Mesh_Projection3D(self, geom)
1114 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1115 # If the optional \a geom parameter is not set, this algorithm is global.
1116 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1117 # @param geom If defined, the subshape to be meshed
1118 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1119 # @ingroup l3_algos_radialp l3_algos_3dextr
1120 def Prism(self, geom=0):
1124 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1125 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1126 if nbSolids == 0 or nbSolids == nbShells:
1127 return Mesh_Prism3D(self, geom)
1128 return Mesh_RadialPrism3D(self, geom)
1130 ## Evaluates size of prospective mesh on a shape
1131 # @return True or False
1132 def Evaluate(self, geom=0):
1133 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1135 geom = self.mesh.GetShapeToMesh()
1138 return self.smeshpyD.Evaluate(self.mesh, geom)
1141 ## Computes the mesh and returns the status of the computation
1142 # @return True or False
1143 # @ingroup l2_construct
1144 def Compute(self, geom=0):
1145 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1147 geom = self.mesh.GetShapeToMesh()
1152 ok = self.smeshpyD.Compute(self.mesh, geom)
1153 except SALOME.SALOME_Exception, ex:
1154 print "Mesh computation failed, exception caught:"
1155 print " ", ex.details.text
1158 print "Mesh computation failed, exception caught:"
1159 traceback.print_exc()
1161 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1164 if err.isGlobalAlgo:
1172 reason = '%s %sD algorithm is missing' % (glob, dim)
1173 elif err.state == HYP_MISSING:
1174 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1175 % (glob, dim, name, dim))
1176 elif err.state == HYP_NOTCONFORM:
1177 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1178 elif err.state == HYP_BAD_PARAMETER:
1179 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1180 % ( glob, dim, name ))
1181 elif err.state == HYP_BAD_GEOMETRY:
1182 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1183 'geometry' % ( glob, dim, name ))
1185 reason = "For unknown reason."+\
1186 " Revise Mesh.Compute() implementation in smeshDC.py!"
1188 if allReasons != "":
1191 allReasons += reason
1193 if allReasons != "":
1194 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1198 print '"' + GetName(self.mesh) + '"',"has not been computed."
1201 if salome.sg.hasDesktop():
1202 smeshgui = salome.ImportComponentGUI("SMESH")
1203 smeshgui.Init(self.mesh.GetStudyId())
1204 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1205 salome.sg.updateObjBrowser(1)
1209 ## Return submesh objects list in meshing order
1210 # @return list of list of submesh objects
1211 # @ingroup l2_construct
1212 def GetMeshOrder(self):
1213 return self.mesh.GetMeshOrder()
1215 ## Return submesh objects list in meshing order
1216 # @return list of list of submesh objects
1217 # @ingroup l2_construct
1218 def SetMeshOrder(self, submeshes):
1219 return self.mesh.SetMeshOrder(submeshes)
1221 ## Removes all nodes and elements
1222 # @ingroup l2_construct
1225 if salome.sg.hasDesktop():
1226 smeshgui = salome.ImportComponentGUI("SMESH")
1227 smeshgui.Init(self.mesh.GetStudyId())
1228 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1229 salome.sg.updateObjBrowser(1)
1231 ## Removes all nodes and elements of indicated shape
1232 # @ingroup l2_construct
1233 def ClearSubMesh(self, geomId):
1234 self.mesh.ClearSubMesh(geomId)
1235 if salome.sg.hasDesktop():
1236 smeshgui = salome.ImportComponentGUI("SMESH")
1237 smeshgui.Init(self.mesh.GetStudyId())
1238 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1239 salome.sg.updateObjBrowser(1)
1241 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1242 # @param fineness [0,-1] defines mesh fineness
1243 # @return True or False
1244 # @ingroup l3_algos_basic
1245 def AutomaticTetrahedralization(self, fineness=0):
1246 dim = self.MeshDimension()
1248 self.RemoveGlobalHypotheses()
1249 self.Segment().AutomaticLength(fineness)
1251 self.Triangle().LengthFromEdges()
1254 self.Tetrahedron(NETGEN)
1256 return self.Compute()
1258 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1259 # @param fineness [0,-1] defines mesh fineness
1260 # @return True or False
1261 # @ingroup l3_algos_basic
1262 def AutomaticHexahedralization(self, fineness=0):
1263 dim = self.MeshDimension()
1264 # assign the hypotheses
1265 self.RemoveGlobalHypotheses()
1266 self.Segment().AutomaticLength(fineness)
1273 return self.Compute()
1275 ## Assigns a hypothesis
1276 # @param hyp a hypothesis to assign
1277 # @param geom a subhape of mesh geometry
1278 # @return SMESH.Hypothesis_Status
1279 # @ingroup l2_hypotheses
1280 def AddHypothesis(self, hyp, geom=0):
1281 if isinstance( hyp, Mesh_Algorithm ):
1282 hyp = hyp.GetAlgorithm()
1287 geom = self.mesh.GetShapeToMesh()
1289 status = self.mesh.AddHypothesis(geom, hyp)
1290 isAlgo = hyp._narrow( SMESH_Algo )
1291 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1294 ## Unassigns a hypothesis
1295 # @param hyp a hypothesis to unassign
1296 # @param geom a subshape of mesh geometry
1297 # @return SMESH.Hypothesis_Status
1298 # @ingroup l2_hypotheses
1299 def RemoveHypothesis(self, hyp, geom=0):
1300 if isinstance( hyp, Mesh_Algorithm ):
1301 hyp = hyp.GetAlgorithm()
1306 status = self.mesh.RemoveHypothesis(geom, hyp)
1309 ## Gets the list of hypotheses added on a geometry
1310 # @param geom a subshape of mesh geometry
1311 # @return the sequence of SMESH_Hypothesis
1312 # @ingroup l2_hypotheses
1313 def GetHypothesisList(self, geom):
1314 return self.mesh.GetHypothesisList( geom )
1316 ## Removes all global hypotheses
1317 # @ingroup l2_hypotheses
1318 def RemoveGlobalHypotheses(self):
1319 current_hyps = self.mesh.GetHypothesisList( self.geom )
1320 for hyp in current_hyps:
1321 self.mesh.RemoveHypothesis( self.geom, hyp )
1325 ## Creates a mesh group based on the geometric object \a grp
1326 # and gives a \a name, \n if this parameter is not defined
1327 # the name is the same as the geometric group name \n
1328 # Note: Works like GroupOnGeom().
1329 # @param grp a geometric group, a vertex, an edge, a face or a solid
1330 # @param name the name of the mesh group
1331 # @return SMESH_GroupOnGeom
1332 # @ingroup l2_grps_create
1333 def Group(self, grp, name=""):
1334 return self.GroupOnGeom(grp, name)
1336 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1337 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1338 # @param f the file name
1339 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1340 # @param opt boolean parameter for creating/not creating
1341 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1342 # @ingroup l2_impexp
1343 def ExportToMED(self, f, version, opt=0):
1344 self.mesh.ExportToMED(f, opt, version)
1346 ## Exports the mesh in a file in MED format
1347 # @param f is the file name
1348 # @param auto_groups boolean parameter for creating/not creating
1349 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1350 # the typical use is auto_groups=false.
1351 # @param version MED format version(MED_V2_1 or MED_V2_2)
1352 # @ingroup l2_impexp
1353 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1354 self.mesh.ExportToMED(f, auto_groups, version)
1356 ## Exports the mesh in a file in DAT format
1357 # @param f the file name
1358 # @ingroup l2_impexp
1359 def ExportDAT(self, f):
1360 self.mesh.ExportDAT(f)
1362 ## Exports the mesh in a file in UNV format
1363 # @param f the file name
1364 # @ingroup l2_impexp
1365 def ExportUNV(self, f):
1366 self.mesh.ExportUNV(f)
1368 ## Export the mesh in a file in STL format
1369 # @param f the file name
1370 # @param ascii defines the file encoding
1371 # @ingroup l2_impexp
1372 def ExportSTL(self, f, ascii=1):
1373 self.mesh.ExportSTL(f, ascii)
1376 # Operations with groups:
1377 # ----------------------
1379 ## Creates an empty mesh group
1380 # @param elementType the type of elements in the group
1381 # @param name the name of the mesh group
1382 # @return SMESH_Group
1383 # @ingroup l2_grps_create
1384 def CreateEmptyGroup(self, elementType, name):
1385 return self.mesh.CreateGroup(elementType, name)
1387 ## Creates a mesh group based on the geometrical object \a grp
1388 # and gives a \a name, \n if this parameter is not defined
1389 # the name is the same as the geometrical group name
1390 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1391 # @param name the name of the mesh group
1392 # @param typ the type of elements in the group. If not set, it is
1393 # automatically detected by the type of the geometry
1394 # @return SMESH_GroupOnGeom
1395 # @ingroup l2_grps_create
1396 def GroupOnGeom(self, grp, name="", typ=None):
1398 name = grp.GetName()
1401 tgeo = str(grp.GetShapeType())
1402 if tgeo == "VERTEX":
1404 elif tgeo == "EDGE":
1406 elif tgeo == "FACE":
1408 elif tgeo == "SOLID":
1410 elif tgeo == "SHELL":
1412 elif tgeo == "COMPOUND":
1413 try: # it raises on a compound of compounds
1414 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1415 print "Mesh.Group: empty geometric group", GetName( grp )
1420 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1422 tgeo = self.geompyD.GetType(grp)
1423 if tgeo == geompyDC.ShapeType["VERTEX"]:
1425 elif tgeo == geompyDC.ShapeType["EDGE"]:
1427 elif tgeo == geompyDC.ShapeType["FACE"]:
1429 elif tgeo == geompyDC.ShapeType["SOLID"]:
1435 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1436 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1437 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1445 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1448 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1450 ## Creates a mesh group by the given ids of elements
1451 # @param groupName the name of the mesh group
1452 # @param elementType the type of elements in the group
1453 # @param elemIDs the list of ids
1454 # @return SMESH_Group
1455 # @ingroup l2_grps_create
1456 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1457 group = self.mesh.CreateGroup(elementType, groupName)
1461 ## Creates a mesh group by the given conditions
1462 # @param groupName the name of the mesh group
1463 # @param elementType the type of elements in the group
1464 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1465 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1466 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1467 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1468 # @return SMESH_Group
1469 # @ingroup l2_grps_create
1473 CritType=FT_Undefined,
1476 UnaryOp=FT_Undefined):
1477 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1478 group = self.MakeGroupByCriterion(groupName, aCriterion)
1481 ## Creates a mesh group by the given criterion
1482 # @param groupName the name of the mesh group
1483 # @param Criterion the instance of Criterion class
1484 # @return SMESH_Group
1485 # @ingroup l2_grps_create
1486 def MakeGroupByCriterion(self, groupName, Criterion):
1487 aFilterMgr = self.smeshpyD.CreateFilterManager()
1488 aFilter = aFilterMgr.CreateFilter()
1490 aCriteria.append(Criterion)
1491 aFilter.SetCriteria(aCriteria)
1492 group = self.MakeGroupByFilter(groupName, aFilter)
1495 ## Creates a mesh group by the given criteria (list of criteria)
1496 # @param groupName the name of the mesh group
1497 # @param theCriteria the list of criteria
1498 # @return SMESH_Group
1499 # @ingroup l2_grps_create
1500 def MakeGroupByCriteria(self, groupName, theCriteria):
1501 aFilterMgr = self.smeshpyD.CreateFilterManager()
1502 aFilter = aFilterMgr.CreateFilter()
1503 aFilter.SetCriteria(theCriteria)
1504 group = self.MakeGroupByFilter(groupName, aFilter)
1507 ## Creates a mesh group by the given filter
1508 # @param groupName the name of the mesh group
1509 # @param theFilter the instance of Filter class
1510 # @return SMESH_Group
1511 # @ingroup l2_grps_create
1512 def MakeGroupByFilter(self, groupName, theFilter):
1513 anIds = theFilter.GetElementsId(self.mesh)
1514 anElemType = theFilter.GetElementType()
1515 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1518 ## Passes mesh elements through the given filter and return IDs of fitting elements
1519 # @param theFilter SMESH_Filter
1520 # @return a list of ids
1521 # @ingroup l1_controls
1522 def GetIdsFromFilter(self, theFilter):
1523 return theFilter.GetElementsId(self.mesh)
1525 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1526 # Returns a list of special structures (borders).
1527 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1528 # @ingroup l1_controls
1529 def GetFreeBorders(self):
1530 aFilterMgr = self.smeshpyD.CreateFilterManager()
1531 aPredicate = aFilterMgr.CreateFreeEdges()
1532 aPredicate.SetMesh(self.mesh)
1533 aBorders = aPredicate.GetBorders()
1537 # @ingroup l2_grps_delete
1538 def RemoveGroup(self, group):
1539 self.mesh.RemoveGroup(group)
1541 ## Removes a group with its contents
1542 # @ingroup l2_grps_delete
1543 def RemoveGroupWithContents(self, group):
1544 self.mesh.RemoveGroupWithContents(group)
1546 ## Gets the list of groups existing in the mesh
1547 # @return a sequence of SMESH_GroupBase
1548 # @ingroup l2_grps_create
1549 def GetGroups(self):
1550 return self.mesh.GetGroups()
1552 ## Gets the number of groups existing in the mesh
1553 # @return the quantity of groups as an integer value
1554 # @ingroup l2_grps_create
1556 return self.mesh.NbGroups()
1558 ## Gets the list of names of groups existing in the mesh
1559 # @return list of strings
1560 # @ingroup l2_grps_create
1561 def GetGroupNames(self):
1562 groups = self.GetGroups()
1564 for group in groups:
1565 names.append(group.GetName())
1568 ## Produces a union of two groups
1569 # A new group is created. All mesh elements that are
1570 # present in the initial groups are added to the new one
1571 # @return an instance of SMESH_Group
1572 # @ingroup l2_grps_operon
1573 def UnionGroups(self, group1, group2, name):
1574 return self.mesh.UnionGroups(group1, group2, name)
1576 ## Produces a union list of groups
1577 # New group is created. All mesh elements that are present in
1578 # initial groups are added to the new one
1579 # @return an instance of SMESH_Group
1580 # @ingroup l2_grps_operon
1581 def UnionListOfGroups(self, groups, name):
1582 return self.mesh.UnionListOfGroups(groups, name)
1584 ## Prodices an intersection of two groups
1585 # A new group is created. All mesh elements that are common
1586 # for the two initial groups are added to the new one.
1587 # @return an instance of SMESH_Group
1588 # @ingroup l2_grps_operon
1589 def IntersectGroups(self, group1, group2, name):
1590 return self.mesh.IntersectGroups(group1, group2, name)
1592 ## Produces an intersection of groups
1593 # New group is created. All mesh elements that are present in all
1594 # initial groups simultaneously are added to the new one
1595 # @return an instance of SMESH_Group
1596 # @ingroup l2_grps_operon
1597 def IntersectListOfGroups(self, groups, name):
1598 return self.mesh.IntersectListOfGroups(groups, name)
1600 ## Produces a cut of two groups
1601 # A new group is created. All mesh elements that are present in
1602 # the main group but are not present in the tool group are added to the new one
1603 # @return an instance of SMESH_Group
1604 # @ingroup l2_grps_operon
1605 def CutGroups(self, main_group, tool_group, name):
1606 return self.mesh.CutGroups(main_group, tool_group, name)
1608 ## Produces a cut of groups
1609 # A new group is created. All mesh elements that are present in main groups
1610 # but do not present in tool groups are added to the new one
1611 # @return an instance of SMESH_Group
1612 # @ingroup l2_grps_operon
1613 def CutListOfGroups(self, main_groups, tool_groups, name):
1614 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1616 ## Produces a group of elements with specified element type using list of existing groups
1617 # A new group is created. System
1618 # 1) extract all nodes on which groups elements are built
1619 # 2) combine all elements of specified dimension laying on these nodes
1620 # @return an instance of SMESH_Group
1621 # @ingroup l2_grps_operon
1622 def CreateDimGroup(self, groups, elem_type, name):
1623 return self.mesh.CreateDimGroup(groups, elem_type, name)
1626 ## Convert group on geom into standalone group
1627 # @ingroup l2_grps_delete
1628 def ConvertToStandalone(self, group):
1629 return self.mesh.ConvertToStandalone(group)
1631 # Get some info about mesh:
1632 # ------------------------
1634 ## Returns the log of nodes and elements added or removed
1635 # since the previous clear of the log.
1636 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1637 # @return list of log_block structures:
1642 # @ingroup l1_auxiliary
1643 def GetLog(self, clearAfterGet):
1644 return self.mesh.GetLog(clearAfterGet)
1646 ## Clears the log of nodes and elements added or removed since the previous
1647 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1648 # @ingroup l1_auxiliary
1650 self.mesh.ClearLog()
1652 ## Toggles auto color mode on the object.
1653 # @param theAutoColor the flag which toggles auto color mode.
1654 # @ingroup l1_auxiliary
1655 def SetAutoColor(self, theAutoColor):
1656 self.mesh.SetAutoColor(theAutoColor)
1658 ## Gets flag of object auto color mode.
1659 # @return True or False
1660 # @ingroup l1_auxiliary
1661 def GetAutoColor(self):
1662 return self.mesh.GetAutoColor()
1664 ## Gets the internal ID
1665 # @return integer value, which is the internal Id of the mesh
1666 # @ingroup l1_auxiliary
1668 return self.mesh.GetId()
1671 # @return integer value, which is the study Id of the mesh
1672 # @ingroup l1_auxiliary
1673 def GetStudyId(self):
1674 return self.mesh.GetStudyId()
1676 ## Checks the group names for duplications.
1677 # Consider the maximum group name length stored in MED file.
1678 # @return True or False
1679 # @ingroup l1_auxiliary
1680 def HasDuplicatedGroupNamesMED(self):
1681 return self.mesh.HasDuplicatedGroupNamesMED()
1683 ## Obtains the mesh editor tool
1684 # @return an instance of SMESH_MeshEditor
1685 # @ingroup l1_modifying
1686 def GetMeshEditor(self):
1687 return self.mesh.GetMeshEditor()
1690 # @return an instance of SALOME_MED::MESH
1691 # @ingroup l1_auxiliary
1692 def GetMEDMesh(self):
1693 return self.mesh.GetMEDMesh()
1696 # Get informations about mesh contents:
1697 # ------------------------------------
1699 ## Gets the mesh stattistic
1700 # @return dictionary type element - count of elements
1701 # @ingroup l1_meshinfo
1702 def GetMeshInfo(self, obj = None):
1703 if not obj: obj = self.mesh
1704 return self.smeshpyD.GetMeshInfo(obj)
1706 ## Returns the number of nodes in the mesh
1707 # @return an integer value
1708 # @ingroup l1_meshinfo
1710 return self.mesh.NbNodes()
1712 ## Returns the number of elements in the mesh
1713 # @return an integer value
1714 # @ingroup l1_meshinfo
1715 def NbElements(self):
1716 return self.mesh.NbElements()
1718 ## Returns the number of 0d elements in the mesh
1719 # @return an integer value
1720 # @ingroup l1_meshinfo
1721 def Nb0DElements(self):
1722 return self.mesh.Nb0DElements()
1724 ## Returns the number of edges in the mesh
1725 # @return an integer value
1726 # @ingroup l1_meshinfo
1728 return self.mesh.NbEdges()
1730 ## Returns the number of edges with the given order in the mesh
1731 # @param elementOrder the order of elements:
1732 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1733 # @return an integer value
1734 # @ingroup l1_meshinfo
1735 def NbEdgesOfOrder(self, elementOrder):
1736 return self.mesh.NbEdgesOfOrder(elementOrder)
1738 ## Returns the number of faces in the mesh
1739 # @return an integer value
1740 # @ingroup l1_meshinfo
1742 return self.mesh.NbFaces()
1744 ## Returns the number of faces with the given order in the mesh
1745 # @param elementOrder the order of elements:
1746 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1747 # @return an integer value
1748 # @ingroup l1_meshinfo
1749 def NbFacesOfOrder(self, elementOrder):
1750 return self.mesh.NbFacesOfOrder(elementOrder)
1752 ## Returns the number of triangles in the mesh
1753 # @return an integer value
1754 # @ingroup l1_meshinfo
1755 def NbTriangles(self):
1756 return self.mesh.NbTriangles()
1758 ## Returns the number of triangles with the given order in the mesh
1759 # @param elementOrder is the order of elements:
1760 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1761 # @return an integer value
1762 # @ingroup l1_meshinfo
1763 def NbTrianglesOfOrder(self, elementOrder):
1764 return self.mesh.NbTrianglesOfOrder(elementOrder)
1766 ## Returns the number of quadrangles in the mesh
1767 # @return an integer value
1768 # @ingroup l1_meshinfo
1769 def NbQuadrangles(self):
1770 return self.mesh.NbQuadrangles()
1772 ## Returns the number of quadrangles with the given order in the mesh
1773 # @param elementOrder the order of elements:
1774 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1775 # @return an integer value
1776 # @ingroup l1_meshinfo
1777 def NbQuadranglesOfOrder(self, elementOrder):
1778 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1780 ## Returns the number of polygons in the mesh
1781 # @return an integer value
1782 # @ingroup l1_meshinfo
1783 def NbPolygons(self):
1784 return self.mesh.NbPolygons()
1786 ## Returns the number of volumes in the mesh
1787 # @return an integer value
1788 # @ingroup l1_meshinfo
1789 def NbVolumes(self):
1790 return self.mesh.NbVolumes()
1792 ## Returns the number of volumes with the given order in the mesh
1793 # @param elementOrder the order of elements:
1794 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1795 # @return an integer value
1796 # @ingroup l1_meshinfo
1797 def NbVolumesOfOrder(self, elementOrder):
1798 return self.mesh.NbVolumesOfOrder(elementOrder)
1800 ## Returns the number of tetrahedrons in the mesh
1801 # @return an integer value
1802 # @ingroup l1_meshinfo
1804 return self.mesh.NbTetras()
1806 ## Returns the number of tetrahedrons with the given order in the mesh
1807 # @param elementOrder the order of elements:
1808 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1809 # @return an integer value
1810 # @ingroup l1_meshinfo
1811 def NbTetrasOfOrder(self, elementOrder):
1812 return self.mesh.NbTetrasOfOrder(elementOrder)
1814 ## Returns the number of hexahedrons in the mesh
1815 # @return an integer value
1816 # @ingroup l1_meshinfo
1818 return self.mesh.NbHexas()
1820 ## Returns the number of hexahedrons with the given order in the mesh
1821 # @param elementOrder the order of elements:
1822 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1823 # @return an integer value
1824 # @ingroup l1_meshinfo
1825 def NbHexasOfOrder(self, elementOrder):
1826 return self.mesh.NbHexasOfOrder(elementOrder)
1828 ## Returns the number of pyramids in the mesh
1829 # @return an integer value
1830 # @ingroup l1_meshinfo
1831 def NbPyramids(self):
1832 return self.mesh.NbPyramids()
1834 ## Returns the number of pyramids with the given order in the mesh
1835 # @param elementOrder the order of elements:
1836 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1837 # @return an integer value
1838 # @ingroup l1_meshinfo
1839 def NbPyramidsOfOrder(self, elementOrder):
1840 return self.mesh.NbPyramidsOfOrder(elementOrder)
1842 ## Returns the number of prisms in the mesh
1843 # @return an integer value
1844 # @ingroup l1_meshinfo
1846 return self.mesh.NbPrisms()
1848 ## Returns the number of prisms with the given order in the mesh
1849 # @param elementOrder the order of elements:
1850 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1851 # @return an integer value
1852 # @ingroup l1_meshinfo
1853 def NbPrismsOfOrder(self, elementOrder):
1854 return self.mesh.NbPrismsOfOrder(elementOrder)
1856 ## Returns the number of polyhedrons in the mesh
1857 # @return an integer value
1858 # @ingroup l1_meshinfo
1859 def NbPolyhedrons(self):
1860 return self.mesh.NbPolyhedrons()
1862 ## Returns the number of submeshes in the mesh
1863 # @return an integer value
1864 # @ingroup l1_meshinfo
1865 def NbSubMesh(self):
1866 return self.mesh.NbSubMesh()
1868 ## Returns the list of mesh elements IDs
1869 # @return the list of integer values
1870 # @ingroup l1_meshinfo
1871 def GetElementsId(self):
1872 return self.mesh.GetElementsId()
1874 ## Returns the list of IDs of mesh elements with the given type
1875 # @param elementType the required type of elements
1876 # @return list of integer values
1877 # @ingroup l1_meshinfo
1878 def GetElementsByType(self, elementType):
1879 return self.mesh.GetElementsByType(elementType)
1881 ## Returns the list of mesh nodes IDs
1882 # @return the list of integer values
1883 # @ingroup l1_meshinfo
1884 def GetNodesId(self):
1885 return self.mesh.GetNodesId()
1887 # Get the information about mesh elements:
1888 # ------------------------------------
1890 ## Returns the type of mesh element
1891 # @return the value from SMESH::ElementType enumeration
1892 # @ingroup l1_meshinfo
1893 def GetElementType(self, id, iselem):
1894 return self.mesh.GetElementType(id, iselem)
1896 ## Returns the list of submesh elements IDs
1897 # @param Shape a geom object(subshape) IOR
1898 # Shape must be the subshape of a ShapeToMesh()
1899 # @return the list of integer values
1900 # @ingroup l1_meshinfo
1901 def GetSubMeshElementsId(self, Shape):
1902 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1903 ShapeID = Shape.GetSubShapeIndices()[0]
1906 return self.mesh.GetSubMeshElementsId(ShapeID)
1908 ## Returns the list of submesh nodes IDs
1909 # @param Shape a geom object(subshape) IOR
1910 # Shape must be the subshape of a ShapeToMesh()
1911 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1912 # @return the list of integer values
1913 # @ingroup l1_meshinfo
1914 def GetSubMeshNodesId(self, Shape, all):
1915 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1916 ShapeID = Shape.GetSubShapeIndices()[0]
1919 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1921 ## Returns type of elements on given shape
1922 # @param Shape a geom object(subshape) IOR
1923 # Shape must be a subshape of a ShapeToMesh()
1924 # @return element type
1925 # @ingroup l1_meshinfo
1926 def GetSubMeshElementType(self, Shape):
1927 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1928 ShapeID = Shape.GetSubShapeIndices()[0]
1931 return self.mesh.GetSubMeshElementType(ShapeID)
1933 ## Gets the mesh description
1934 # @return string value
1935 # @ingroup l1_meshinfo
1937 return self.mesh.Dump()
1940 # Get the information about nodes and elements of a mesh by its IDs:
1941 # -----------------------------------------------------------
1943 ## Gets XYZ coordinates of a node
1944 # \n If there is no nodes for the given ID - returns an empty list
1945 # @return a list of double precision values
1946 # @ingroup l1_meshinfo
1947 def GetNodeXYZ(self, id):
1948 return self.mesh.GetNodeXYZ(id)
1950 ## Returns list of IDs of inverse elements for the given node
1951 # \n If there is no node for the given ID - returns an empty list
1952 # @return a list of integer values
1953 # @ingroup l1_meshinfo
1954 def GetNodeInverseElements(self, id):
1955 return self.mesh.GetNodeInverseElements(id)
1957 ## @brief Returns the position of a node on the shape
1958 # @return SMESH::NodePosition
1959 # @ingroup l1_meshinfo
1960 def GetNodePosition(self,NodeID):
1961 return self.mesh.GetNodePosition(NodeID)
1963 ## If the given element is a node, returns the ID of shape
1964 # \n If there is no node for the given ID - returns -1
1965 # @return an integer value
1966 # @ingroup l1_meshinfo
1967 def GetShapeID(self, id):
1968 return self.mesh.GetShapeID(id)
1970 ## Returns the ID of the result shape after
1971 # FindShape() from SMESH_MeshEditor for the given element
1972 # \n If there is no element for the given ID - returns -1
1973 # @return an integer value
1974 # @ingroup l1_meshinfo
1975 def GetShapeIDForElem(self,id):
1976 return self.mesh.GetShapeIDForElem(id)
1978 ## Returns the number of nodes for the given element
1979 # \n If there is no element for the given ID - returns -1
1980 # @return an integer value
1981 # @ingroup l1_meshinfo
1982 def GetElemNbNodes(self, id):
1983 return self.mesh.GetElemNbNodes(id)
1985 ## Returns the node ID the given index for the given element
1986 # \n If there is no element for the given ID - returns -1
1987 # \n If there is no node for the given index - returns -2
1988 # @return an integer value
1989 # @ingroup l1_meshinfo
1990 def GetElemNode(self, id, index):
1991 return self.mesh.GetElemNode(id, index)
1993 ## Returns the IDs of nodes of the given element
1994 # @return a list of integer values
1995 # @ingroup l1_meshinfo
1996 def GetElemNodes(self, id):
1997 return self.mesh.GetElemNodes(id)
1999 ## Returns true if the given node is the medium node in the given quadratic element
2000 # @ingroup l1_meshinfo
2001 def IsMediumNode(self, elementID, nodeID):
2002 return self.mesh.IsMediumNode(elementID, nodeID)
2004 ## Returns true if the given node is the medium node in one of quadratic elements
2005 # @ingroup l1_meshinfo
2006 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2007 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2009 ## Returns the number of edges for the given element
2010 # @ingroup l1_meshinfo
2011 def ElemNbEdges(self, id):
2012 return self.mesh.ElemNbEdges(id)
2014 ## Returns the number of faces for the given element
2015 # @ingroup l1_meshinfo
2016 def ElemNbFaces(self, id):
2017 return self.mesh.ElemNbFaces(id)
2019 ## Returns true if the given element is a polygon
2020 # @ingroup l1_meshinfo
2021 def IsPoly(self, id):
2022 return self.mesh.IsPoly(id)
2024 ## Returns true if the given element is quadratic
2025 # @ingroup l1_meshinfo
2026 def IsQuadratic(self, id):
2027 return self.mesh.IsQuadratic(id)
2029 ## Returns XYZ coordinates of the barycenter of the given element
2030 # \n If there is no element for the given ID - returns an empty list
2031 # @return a list of three double values
2032 # @ingroup l1_meshinfo
2033 def BaryCenter(self, id):
2034 return self.mesh.BaryCenter(id)
2037 # Mesh edition (SMESH_MeshEditor functionality):
2038 # ---------------------------------------------
2040 ## Removes the elements from the mesh by ids
2041 # @param IDsOfElements is a list of ids of elements to remove
2042 # @return True or False
2043 # @ingroup l2_modif_del
2044 def RemoveElements(self, IDsOfElements):
2045 return self.editor.RemoveElements(IDsOfElements)
2047 ## Removes nodes from mesh by ids
2048 # @param IDsOfNodes is a list of ids of nodes to remove
2049 # @return True or False
2050 # @ingroup l2_modif_del
2051 def RemoveNodes(self, IDsOfNodes):
2052 return self.editor.RemoveNodes(IDsOfNodes)
2054 ## Add a node to the mesh by coordinates
2055 # @return Id of the new node
2056 # @ingroup l2_modif_add
2057 def AddNode(self, x, y, z):
2058 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2059 self.mesh.SetParameters(Parameters)
2060 return self.editor.AddNode( x, y, z)
2062 ## Creates a 0D element on a node with given number.
2063 # @param IDOfNode the ID of node for creation of the element.
2064 # @return the Id of the new 0D element
2065 # @ingroup l2_modif_add
2066 def Add0DElement(self, IDOfNode):
2067 return self.editor.Add0DElement(IDOfNode)
2069 ## Creates a linear or quadratic edge (this is determined
2070 # by the number of given nodes).
2071 # @param IDsOfNodes the list of node IDs for creation of the element.
2072 # The order of nodes in this list should correspond to the description
2073 # of MED. \n This description is located by the following link:
2074 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2075 # @return the Id of the new edge
2076 # @ingroup l2_modif_add
2077 def AddEdge(self, IDsOfNodes):
2078 return self.editor.AddEdge(IDsOfNodes)
2080 ## Creates a linear or quadratic face (this is determined
2081 # by the number of given nodes).
2082 # @param IDsOfNodes the list of node IDs for creation of the element.
2083 # The order of nodes in this list should correspond to the description
2084 # of MED. \n This description is located by the following link:
2085 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2086 # @return the Id of the new face
2087 # @ingroup l2_modif_add
2088 def AddFace(self, IDsOfNodes):
2089 return self.editor.AddFace(IDsOfNodes)
2091 ## Adds a polygonal face to the mesh by the list of node IDs
2092 # @param IdsOfNodes the list of node IDs for creation of the element.
2093 # @return the Id of the new face
2094 # @ingroup l2_modif_add
2095 def AddPolygonalFace(self, IdsOfNodes):
2096 return self.editor.AddPolygonalFace(IdsOfNodes)
2098 ## Creates both simple and quadratic volume (this is determined
2099 # by the number of given nodes).
2100 # @param IDsOfNodes the list of node IDs for creation of the element.
2101 # The order of nodes in this list should correspond to the description
2102 # of MED. \n This description is located by the following link:
2103 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2104 # @return the Id of the new volumic element
2105 # @ingroup l2_modif_add
2106 def AddVolume(self, IDsOfNodes):
2107 return self.editor.AddVolume(IDsOfNodes)
2109 ## Creates a volume of many faces, giving nodes for each face.
2110 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2111 # @param Quantities the list of integer values, Quantities[i]
2112 # gives the quantity of nodes in face number i.
2113 # @return the Id of the new volumic element
2114 # @ingroup l2_modif_add
2115 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2116 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2118 ## Creates a volume of many faces, giving the IDs of the existing faces.
2119 # @param IdsOfFaces the list of face IDs for volume creation.
2121 # Note: The created volume will refer only to the nodes
2122 # of the given faces, not to the faces themselves.
2123 # @return the Id of the new volumic element
2124 # @ingroup l2_modif_add
2125 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2126 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2129 ## @brief Binds a node to a vertex
2130 # @param NodeID a node ID
2131 # @param Vertex a vertex or vertex ID
2132 # @return True if succeed else raises an exception
2133 # @ingroup l2_modif_add
2134 def SetNodeOnVertex(self, NodeID, Vertex):
2135 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2136 VertexID = Vertex.GetSubShapeIndices()[0]
2140 self.editor.SetNodeOnVertex(NodeID, VertexID)
2141 except SALOME.SALOME_Exception, inst:
2142 raise ValueError, inst.details.text
2146 ## @brief Stores the node position on an edge
2147 # @param NodeID a node ID
2148 # @param Edge an edge or edge ID
2149 # @param paramOnEdge a parameter on the edge where the node is located
2150 # @return True if succeed else raises an exception
2151 # @ingroup l2_modif_add
2152 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2153 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2154 EdgeID = Edge.GetSubShapeIndices()[0]
2158 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2159 except SALOME.SALOME_Exception, inst:
2160 raise ValueError, inst.details.text
2163 ## @brief Stores node position on a face
2164 # @param NodeID a node ID
2165 # @param Face a face or face ID
2166 # @param u U parameter on the face where the node is located
2167 # @param v V parameter on the face where the node is located
2168 # @return True if succeed else raises an exception
2169 # @ingroup l2_modif_add
2170 def SetNodeOnFace(self, NodeID, Face, u, v):
2171 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2172 FaceID = Face.GetSubShapeIndices()[0]
2176 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2177 except SALOME.SALOME_Exception, inst:
2178 raise ValueError, inst.details.text
2181 ## @brief Binds a node to a solid
2182 # @param NodeID a node ID
2183 # @param Solid a solid or solid ID
2184 # @return True if succeed else raises an exception
2185 # @ingroup l2_modif_add
2186 def SetNodeInVolume(self, NodeID, Solid):
2187 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2188 SolidID = Solid.GetSubShapeIndices()[0]
2192 self.editor.SetNodeInVolume(NodeID, SolidID)
2193 except SALOME.SALOME_Exception, inst:
2194 raise ValueError, inst.details.text
2197 ## @brief Bind an element to a shape
2198 # @param ElementID an element ID
2199 # @param Shape a shape or shape ID
2200 # @return True if succeed else raises an exception
2201 # @ingroup l2_modif_add
2202 def SetMeshElementOnShape(self, ElementID, Shape):
2203 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2204 ShapeID = Shape.GetSubShapeIndices()[0]
2208 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2209 except SALOME.SALOME_Exception, inst:
2210 raise ValueError, inst.details.text
2214 ## Moves the node with the given id
2215 # @param NodeID the id of the node
2216 # @param x a new X coordinate
2217 # @param y a new Y coordinate
2218 # @param z a new Z coordinate
2219 # @return True if succeed else False
2220 # @ingroup l2_modif_movenode
2221 def MoveNode(self, NodeID, x, y, z):
2222 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2223 self.mesh.SetParameters(Parameters)
2224 return self.editor.MoveNode(NodeID, x, y, z)
2226 ## Finds the node closest to a point and moves it to a point location
2227 # @param x the X coordinate of a point
2228 # @param y the Y coordinate of a point
2229 # @param z the Z coordinate of a point
2230 # @param NodeID if specified (>0), the node with this ID is moved,
2231 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2232 # @return the ID of a node
2233 # @ingroup l2_modif_throughp
2234 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2235 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2236 self.mesh.SetParameters(Parameters)
2237 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2239 ## Finds the node closest to a point
2240 # @param x the X coordinate of a point
2241 # @param y the Y coordinate of a point
2242 # @param z the Z coordinate of a point
2243 # @return the ID of a node
2244 # @ingroup l2_modif_throughp
2245 def FindNodeClosestTo(self, x, y, z):
2246 #preview = self.mesh.GetMeshEditPreviewer()
2247 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2248 return self.editor.FindNodeClosestTo(x, y, z)
2250 ## Finds the elements where a point lays IN or ON
2251 # @param x the X coordinate of a point
2252 # @param y the Y coordinate of a point
2253 # @param z the Z coordinate of a point
2254 # @param elementType type of elements to find (SMESH.ALL type
2255 # means elements of any type excluding nodes and 0D elements)
2256 # @return list of IDs of found elements
2257 # @ingroup l2_modif_throughp
2258 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2259 return self.editor.FindElementsByPoint(x, y, z, elementType)
2262 ## Finds the node closest to a point and moves it to a point location
2263 # @param x the X coordinate of a point
2264 # @param y the Y coordinate of a point
2265 # @param z the Z coordinate of a point
2266 # @return the ID of a moved node
2267 # @ingroup l2_modif_throughp
2268 def MeshToPassThroughAPoint(self, x, y, z):
2269 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2271 ## Replaces two neighbour triangles sharing Node1-Node2 link
2272 # with the triangles built on the same 4 nodes but having other common link.
2273 # @param NodeID1 the ID of the first node
2274 # @param NodeID2 the ID of the second node
2275 # @return false if proper faces were not found
2276 # @ingroup l2_modif_invdiag
2277 def InverseDiag(self, NodeID1, NodeID2):
2278 return self.editor.InverseDiag(NodeID1, NodeID2)
2280 ## Replaces two neighbour triangles sharing Node1-Node2 link
2281 # with a quadrangle built on the same 4 nodes.
2282 # @param NodeID1 the ID of the first node
2283 # @param NodeID2 the ID of the second node
2284 # @return false if proper faces were not found
2285 # @ingroup l2_modif_unitetri
2286 def DeleteDiag(self, NodeID1, NodeID2):
2287 return self.editor.DeleteDiag(NodeID1, NodeID2)
2289 ## Reorients elements by ids
2290 # @param IDsOfElements if undefined reorients all mesh elements
2291 # @return True if succeed else False
2292 # @ingroup l2_modif_changori
2293 def Reorient(self, IDsOfElements=None):
2294 if IDsOfElements == None:
2295 IDsOfElements = self.GetElementsId()
2296 return self.editor.Reorient(IDsOfElements)
2298 ## Reorients all elements of the object
2299 # @param theObject mesh, submesh or group
2300 # @return True if succeed else False
2301 # @ingroup l2_modif_changori
2302 def ReorientObject(self, theObject):
2303 if ( isinstance( theObject, Mesh )):
2304 theObject = theObject.GetMesh()
2305 return self.editor.ReorientObject(theObject)
2307 ## Fuses the neighbouring triangles into quadrangles.
2308 # @param IDsOfElements The triangles to be fused,
2309 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2310 # @param MaxAngle is the maximum angle between element normals at which the fusion
2311 # is still performed; theMaxAngle is mesured in radians.
2312 # Also it could be a name of variable which defines angle in degrees.
2313 # @return TRUE in case of success, FALSE otherwise.
2314 # @ingroup l2_modif_unitetri
2315 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2317 if isinstance(MaxAngle,str):
2319 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2321 MaxAngle = DegreesToRadians(MaxAngle)
2322 if IDsOfElements == []:
2323 IDsOfElements = self.GetElementsId()
2324 self.mesh.SetParameters(Parameters)
2326 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2327 Functor = theCriterion
2329 Functor = self.smeshpyD.GetFunctor(theCriterion)
2330 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2332 ## Fuses the neighbouring triangles of the object into quadrangles
2333 # @param theObject is mesh, submesh or group
2334 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2335 # @param MaxAngle a max angle between element normals at which the fusion
2336 # is still performed; theMaxAngle is mesured in radians.
2337 # @return TRUE in case of success, FALSE otherwise.
2338 # @ingroup l2_modif_unitetri
2339 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2340 if ( isinstance( theObject, Mesh )):
2341 theObject = theObject.GetMesh()
2342 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2344 ## Splits quadrangles into triangles.
2345 # @param IDsOfElements the faces to be splitted.
2346 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2347 # @return TRUE in case of success, FALSE otherwise.
2348 # @ingroup l2_modif_cutquadr
2349 def QuadToTri (self, IDsOfElements, theCriterion):
2350 if IDsOfElements == []:
2351 IDsOfElements = self.GetElementsId()
2352 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2354 ## Splits quadrangles into triangles.
2355 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2356 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2357 # @return TRUE in case of success, FALSE otherwise.
2358 # @ingroup l2_modif_cutquadr
2359 def QuadToTriObject (self, theObject, theCriterion):
2360 if ( isinstance( theObject, Mesh )):
2361 theObject = theObject.GetMesh()
2362 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2364 ## Splits quadrangles into triangles.
2365 # @param IDsOfElements the faces to be splitted
2366 # @param Diag13 is used to choose a diagonal for splitting.
2367 # @return TRUE in case of success, FALSE otherwise.
2368 # @ingroup l2_modif_cutquadr
2369 def SplitQuad (self, IDsOfElements, Diag13):
2370 if IDsOfElements == []:
2371 IDsOfElements = self.GetElementsId()
2372 return self.editor.SplitQuad(IDsOfElements, Diag13)
2374 ## Splits quadrangles into triangles.
2375 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2376 # @param Diag13 is used to choose a diagonal for splitting.
2377 # @return TRUE in case of success, FALSE otherwise.
2378 # @ingroup l2_modif_cutquadr
2379 def SplitQuadObject (self, theObject, Diag13):
2380 if ( isinstance( theObject, Mesh )):
2381 theObject = theObject.GetMesh()
2382 return self.editor.SplitQuadObject(theObject, Diag13)
2384 ## Finds a better splitting of the given quadrangle.
2385 # @param IDOfQuad the ID of the quadrangle to be splitted.
2386 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2387 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2388 # diagonal is better, 0 if error occurs.
2389 # @ingroup l2_modif_cutquadr
2390 def BestSplit (self, IDOfQuad, theCriterion):
2391 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2393 ## Splits quadrangle faces near triangular facets of volumes
2395 # @ingroup l1_auxiliary
2396 def SplitQuadsNearTriangularFacets(self):
2397 faces_array = self.GetElementsByType(SMESH.FACE)
2398 for face_id in faces_array:
2399 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2400 quad_nodes = self.mesh.GetElemNodes(face_id)
2401 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2402 isVolumeFound = False
2403 for node1_elem in node1_elems:
2404 if not isVolumeFound:
2405 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2406 nb_nodes = self.GetElemNbNodes(node1_elem)
2407 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2408 volume_elem = node1_elem
2409 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2410 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2411 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2412 isVolumeFound = True
2413 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2414 self.SplitQuad([face_id], False) # diagonal 2-4
2415 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2416 isVolumeFound = True
2417 self.SplitQuad([face_id], True) # diagonal 1-3
2418 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2419 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2420 isVolumeFound = True
2421 self.SplitQuad([face_id], True) # diagonal 1-3
2423 ## @brief Splits hexahedrons into tetrahedrons.
2425 # This operation uses pattern mapping functionality for splitting.
2426 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2427 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2428 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2429 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2430 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2431 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2432 # @return TRUE in case of success, FALSE otherwise.
2433 # @ingroup l1_auxiliary
2434 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2435 # Pattern: 5.---------.6
2440 # (0,0,1) 4.---------.7 * |
2447 # (0,0,0) 0.---------.3
2448 pattern_tetra = "!!! Nb of points: \n 8 \n\
2458 !!! Indices of points of 6 tetras: \n\
2466 pattern = self.smeshpyD.GetPattern()
2467 isDone = pattern.LoadFromFile(pattern_tetra)
2469 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2472 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2473 isDone = pattern.MakeMesh(self.mesh, False, False)
2474 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2476 # split quafrangle faces near triangular facets of volumes
2477 self.SplitQuadsNearTriangularFacets()
2481 ## @brief Split hexahedrons into prisms.
2483 # Uses the pattern mapping functionality for splitting.
2484 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2485 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2486 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2487 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2488 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2489 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2490 # @return TRUE in case of success, FALSE otherwise.
2491 # @ingroup l1_auxiliary
2492 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2493 # Pattern: 5.---------.6
2498 # (0,0,1) 4.---------.7 |
2505 # (0,0,0) 0.---------.3
2506 pattern_prism = "!!! Nb of points: \n 8 \n\
2516 !!! Indices of points of 2 prisms: \n\
2520 pattern = self.smeshpyD.GetPattern()
2521 isDone = pattern.LoadFromFile(pattern_prism)
2523 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2526 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2527 isDone = pattern.MakeMesh(self.mesh, False, False)
2528 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2530 # Splits quafrangle faces near triangular facets of volumes
2531 self.SplitQuadsNearTriangularFacets()
2535 ## Smoothes elements
2536 # @param IDsOfElements the list if ids of elements to smooth
2537 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2538 # Note that nodes built on edges and boundary nodes are always fixed.
2539 # @param MaxNbOfIterations the maximum number of iterations
2540 # @param MaxAspectRatio varies in range [1.0, inf]
2541 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2542 # @return TRUE in case of success, FALSE otherwise.
2543 # @ingroup l2_modif_smooth
2544 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2545 MaxNbOfIterations, MaxAspectRatio, Method):
2546 if IDsOfElements == []:
2547 IDsOfElements = self.GetElementsId()
2548 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2549 self.mesh.SetParameters(Parameters)
2550 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2551 MaxNbOfIterations, MaxAspectRatio, Method)
2553 ## Smoothes elements which belong to the given object
2554 # @param theObject the object to smooth
2555 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2556 # Note that nodes built on edges and boundary nodes are always fixed.
2557 # @param MaxNbOfIterations the maximum number of iterations
2558 # @param MaxAspectRatio varies in range [1.0, inf]
2559 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2560 # @return TRUE in case of success, FALSE otherwise.
2561 # @ingroup l2_modif_smooth
2562 def SmoothObject(self, theObject, IDsOfFixedNodes,
2563 MaxNbOfIterations, MaxAspectRatio, Method):
2564 if ( isinstance( theObject, Mesh )):
2565 theObject = theObject.GetMesh()
2566 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2567 MaxNbOfIterations, MaxAspectRatio, Method)
2569 ## Parametrically smoothes the given elements
2570 # @param IDsOfElements the list if ids of elements to smooth
2571 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2572 # Note that nodes built on edges and boundary nodes are always fixed.
2573 # @param MaxNbOfIterations the maximum number of iterations
2574 # @param MaxAspectRatio varies in range [1.0, inf]
2575 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2576 # @return TRUE in case of success, FALSE otherwise.
2577 # @ingroup l2_modif_smooth
2578 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2579 MaxNbOfIterations, MaxAspectRatio, Method):
2580 if IDsOfElements == []:
2581 IDsOfElements = self.GetElementsId()
2582 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2583 self.mesh.SetParameters(Parameters)
2584 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2585 MaxNbOfIterations, MaxAspectRatio, Method)
2587 ## Parametrically smoothes the elements which belong to the given object
2588 # @param theObject the object to smooth
2589 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2590 # Note that nodes built on edges and boundary nodes are always fixed.
2591 # @param MaxNbOfIterations the maximum number of iterations
2592 # @param MaxAspectRatio varies in range [1.0, inf]
2593 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2594 # @return TRUE in case of success, FALSE otherwise.
2595 # @ingroup l2_modif_smooth
2596 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2597 MaxNbOfIterations, MaxAspectRatio, Method):
2598 if ( isinstance( theObject, Mesh )):
2599 theObject = theObject.GetMesh()
2600 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2601 MaxNbOfIterations, MaxAspectRatio, Method)
2603 ## Converts the mesh to quadratic, deletes old elements, replacing
2604 # them with quadratic with the same id.
2605 # @ingroup l2_modif_tofromqu
2606 def ConvertToQuadratic(self, theForce3d):
2607 self.editor.ConvertToQuadratic(theForce3d)
2609 ## Converts the mesh from quadratic to ordinary,
2610 # deletes old quadratic elements, \n replacing
2611 # them with ordinary mesh elements with the same id.
2612 # @return TRUE in case of success, FALSE otherwise.
2613 # @ingroup l2_modif_tofromqu
2614 def ConvertFromQuadratic(self):
2615 return self.editor.ConvertFromQuadratic()
2617 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2618 # @return TRUE if operation has been completed successfully, FALSE otherwise
2619 # @ingroup l2_modif_edit
2620 def Make2DMeshFrom3D(self):
2621 return self.editor. Make2DMeshFrom3D()
2623 ## Renumber mesh nodes
2624 # @ingroup l2_modif_renumber
2625 def RenumberNodes(self):
2626 self.editor.RenumberNodes()
2628 ## Renumber mesh elements
2629 # @ingroup l2_modif_renumber
2630 def RenumberElements(self):
2631 self.editor.RenumberElements()
2633 ## Generates new elements by rotation of the elements around the axis
2634 # @param IDsOfElements the list of ids of elements to sweep
2635 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2636 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2637 # @param NbOfSteps the number of steps
2638 # @param Tolerance tolerance
2639 # @param MakeGroups forces the generation of new groups from existing ones
2640 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2641 # of all steps, else - size of each step
2642 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2643 # @ingroup l2_modif_extrurev
2644 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2645 MakeGroups=False, TotalAngle=False):
2647 if isinstance(AngleInRadians,str):
2649 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2651 AngleInRadians = DegreesToRadians(AngleInRadians)
2652 if IDsOfElements == []:
2653 IDsOfElements = self.GetElementsId()
2654 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2655 Axis = self.smeshpyD.GetAxisStruct(Axis)
2656 Axis,AxisParameters = ParseAxisStruct(Axis)
2657 if TotalAngle and NbOfSteps:
2658 AngleInRadians /= NbOfSteps
2659 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2660 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2661 self.mesh.SetParameters(Parameters)
2663 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2664 AngleInRadians, NbOfSteps, Tolerance)
2665 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2668 ## Generates new elements by rotation of the elements of object around the axis
2669 # @param theObject object which elements should be sweeped
2670 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2671 # @param AngleInRadians the angle of Rotation
2672 # @param NbOfSteps number of steps
2673 # @param Tolerance tolerance
2674 # @param MakeGroups forces the generation of new groups from existing ones
2675 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2676 # of all steps, else - size of each step
2677 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2678 # @ingroup l2_modif_extrurev
2679 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2680 MakeGroups=False, TotalAngle=False):
2682 if isinstance(AngleInRadians,str):
2684 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2686 AngleInRadians = DegreesToRadians(AngleInRadians)
2687 if ( isinstance( theObject, Mesh )):
2688 theObject = theObject.GetMesh()
2689 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2690 Axis = self.smeshpyD.GetAxisStruct(Axis)
2691 Axis,AxisParameters = ParseAxisStruct(Axis)
2692 if TotalAngle and NbOfSteps:
2693 AngleInRadians /= NbOfSteps
2694 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2695 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2696 self.mesh.SetParameters(Parameters)
2698 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2699 NbOfSteps, Tolerance)
2700 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2703 ## Generates new elements by rotation of the elements of object around the axis
2704 # @param theObject object which elements should be sweeped
2705 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2706 # @param AngleInRadians the angle of Rotation
2707 # @param NbOfSteps number of steps
2708 # @param Tolerance tolerance
2709 # @param MakeGroups forces the generation of new groups from existing ones
2710 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2711 # of all steps, else - size of each step
2712 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2713 # @ingroup l2_modif_extrurev
2714 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2715 MakeGroups=False, TotalAngle=False):
2717 if isinstance(AngleInRadians,str):
2719 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2721 AngleInRadians = DegreesToRadians(AngleInRadians)
2722 if ( isinstance( theObject, Mesh )):
2723 theObject = theObject.GetMesh()
2724 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2725 Axis = self.smeshpyD.GetAxisStruct(Axis)
2726 Axis,AxisParameters = ParseAxisStruct(Axis)
2727 if TotalAngle and NbOfSteps:
2728 AngleInRadians /= NbOfSteps
2729 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2730 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2731 self.mesh.SetParameters(Parameters)
2733 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2734 NbOfSteps, Tolerance)
2735 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2738 ## Generates new elements by rotation of the elements of object around the axis
2739 # @param theObject object which elements should be sweeped
2740 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2741 # @param AngleInRadians the angle of Rotation
2742 # @param NbOfSteps number of steps
2743 # @param Tolerance tolerance
2744 # @param MakeGroups forces the generation of new groups from existing ones
2745 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2746 # of all steps, else - size of each step
2747 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2748 # @ingroup l2_modif_extrurev
2749 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2750 MakeGroups=False, TotalAngle=False):
2752 if isinstance(AngleInRadians,str):
2754 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2756 AngleInRadians = DegreesToRadians(AngleInRadians)
2757 if ( isinstance( theObject, Mesh )):
2758 theObject = theObject.GetMesh()
2759 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2760 Axis = self.smeshpyD.GetAxisStruct(Axis)
2761 Axis,AxisParameters = ParseAxisStruct(Axis)
2762 if TotalAngle and NbOfSteps:
2763 AngleInRadians /= NbOfSteps
2764 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2765 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2766 self.mesh.SetParameters(Parameters)
2768 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2769 NbOfSteps, Tolerance)
2770 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2773 ## Generates new elements by extrusion of the elements with given ids
2774 # @param IDsOfElements the list of elements ids for extrusion
2775 # @param StepVector vector, defining the direction and value of extrusion
2776 # @param NbOfSteps the number of steps
2777 # @param MakeGroups forces the generation of new groups from existing ones
2778 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2779 # @ingroup l2_modif_extrurev
2780 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2781 if IDsOfElements == []:
2782 IDsOfElements = self.GetElementsId()
2783 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2784 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2785 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2786 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2787 Parameters = StepVectorParameters + var_separator + Parameters
2788 self.mesh.SetParameters(Parameters)
2790 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2791 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2794 ## Generates new elements by extrusion of the elements with given ids
2795 # @param IDsOfElements is ids of elements
2796 # @param StepVector vector, defining the direction and value of extrusion
2797 # @param NbOfSteps the number of steps
2798 # @param ExtrFlags sets flags for extrusion
2799 # @param SewTolerance uses for comparing locations of nodes if flag
2800 # EXTRUSION_FLAG_SEW is set
2801 # @param MakeGroups forces the generation of new groups from existing ones
2802 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2803 # @ingroup l2_modif_extrurev
2804 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2805 ExtrFlags, SewTolerance, MakeGroups=False):
2806 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2807 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2809 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2810 ExtrFlags, SewTolerance)
2811 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2812 ExtrFlags, SewTolerance)
2815 ## Generates new elements by extrusion of the elements which belong to the object
2816 # @param theObject the object which elements should be processed
2817 # @param StepVector vector, defining the direction and value of extrusion
2818 # @param NbOfSteps the number of steps
2819 # @param MakeGroups forces the generation of new groups from existing ones
2820 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2821 # @ingroup l2_modif_extrurev
2822 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2823 if ( isinstance( theObject, Mesh )):
2824 theObject = theObject.GetMesh()
2825 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2826 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2827 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2828 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2829 Parameters = StepVectorParameters + var_separator + Parameters
2830 self.mesh.SetParameters(Parameters)
2832 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2833 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2836 ## Generates new elements by extrusion of the elements which belong to the object
2837 # @param theObject 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 to generate 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 ExtrusionSweepObject1D(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.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2854 self.editor.ExtrusionSweepObject1D(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 forces the generation of 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 ExtrusionSweepObject2D(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.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2875 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2880 ## Generates new elements by extrusion of the given elements
2881 # The path of extrusion must be a meshed edge.
2882 # @param Base mesh or list of ids of elements for extrusion
2883 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2884 # @param NodeStart the start node from Path. Defines the direction of extrusion
2885 # @param HasAngles allows the shape to be rotated around the path
2886 # to get the resulting mesh in a helical fashion
2887 # @param Angles list of angles in radians
2888 # @param LinearVariation forces the computation of rotation angles as linear
2889 # variation of the given Angles along path steps
2890 # @param HasRefPoint allows using the reference point
2891 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2892 # The User can specify any point as the Reference Point.
2893 # @param MakeGroups forces the generation of new groups from existing ones
2894 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2895 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2896 # only SMESH::Extrusion_Error otherwise
2897 # @ingroup l2_modif_extrurev
2898 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2899 HasAngles, Angles, LinearVariation,
2900 HasRefPoint, RefPoint, MakeGroups, ElemType):
2901 Angles,AnglesParameters = ParseAngles(Angles)
2902 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2903 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2904 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2906 Parameters = AnglesParameters + var_separator + RefPointParameters
2907 self.mesh.SetParameters(Parameters)
2909 if isinstance(Base,list):
2911 if Base == []: IDsOfElements = self.GetElementsId()
2912 else: IDsOfElements = Base
2913 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2914 HasAngles, Angles, LinearVariation,
2915 HasRefPoint, RefPoint, MakeGroups, ElemType)
2917 if isinstance(Base,Mesh):
2918 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2919 HasAngles, Angles, LinearVariation,
2920 HasRefPoint, RefPoint, MakeGroups, ElemType)
2922 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2925 ## Generates new elements by extrusion of the given elements
2926 # The path of extrusion must be a meshed edge.
2927 # @param IDsOfElements ids of elements
2928 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2929 # @param PathShape shape(edge) defines the sub-mesh for the path
2930 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2931 # @param HasAngles allows the shape to be rotated around the path
2932 # to get the resulting mesh in a helical fashion
2933 # @param Angles list of angles in radians
2934 # @param HasRefPoint allows using the reference point
2935 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2936 # The User can specify any point as the Reference Point.
2937 # @param MakeGroups forces the generation of new groups from existing ones
2938 # @param LinearVariation forces the computation of rotation angles as linear
2939 # variation of the given Angles along path steps
2940 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2941 # only SMESH::Extrusion_Error otherwise
2942 # @ingroup l2_modif_extrurev
2943 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2944 HasAngles, Angles, HasRefPoint, RefPoint,
2945 MakeGroups=False, LinearVariation=False):
2946 Angles,AnglesParameters = ParseAngles(Angles)
2947 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2948 if IDsOfElements == []:
2949 IDsOfElements = self.GetElementsId()
2950 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2951 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2953 if ( isinstance( PathMesh, Mesh )):
2954 PathMesh = PathMesh.GetMesh()
2955 if HasAngles and Angles and LinearVariation:
2956 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2958 Parameters = AnglesParameters + var_separator + RefPointParameters
2959 self.mesh.SetParameters(Parameters)
2961 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2962 PathShape, NodeStart, HasAngles,
2963 Angles, HasRefPoint, RefPoint)
2964 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2965 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2967 ## Generates new elements by extrusion of the elements which belong to the object
2968 # The path of extrusion must be a meshed edge.
2969 # @param theObject the object which elements should be processed
2970 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2971 # @param PathShape shape(edge) defines the sub-mesh for the path
2972 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2973 # @param HasAngles allows the shape to be rotated around the path
2974 # to get the resulting mesh in a helical fashion
2975 # @param Angles list of angles
2976 # @param HasRefPoint allows using the reference point
2977 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2978 # The User can specify any point as the Reference Point.
2979 # @param MakeGroups forces the generation of new groups from existing ones
2980 # @param LinearVariation forces the computation of rotation angles as linear
2981 # variation of the given Angles along path steps
2982 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2983 # only SMESH::Extrusion_Error otherwise
2984 # @ingroup l2_modif_extrurev
2985 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2986 HasAngles, Angles, HasRefPoint, RefPoint,
2987 MakeGroups=False, LinearVariation=False):
2988 Angles,AnglesParameters = ParseAngles(Angles)
2989 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2990 if ( isinstance( theObject, Mesh )):
2991 theObject = theObject.GetMesh()
2992 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2993 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2994 if ( isinstance( PathMesh, Mesh )):
2995 PathMesh = PathMesh.GetMesh()
2996 if HasAngles and Angles and LinearVariation:
2997 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2999 Parameters = AnglesParameters + var_separator + RefPointParameters
3000 self.mesh.SetParameters(Parameters)
3002 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3003 PathShape, NodeStart, HasAngles,
3004 Angles, HasRefPoint, RefPoint)
3005 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3006 NodeStart, HasAngles, Angles, HasRefPoint,
3009 ## Generates new elements by extrusion of the elements which belong to the object
3010 # The path of extrusion must be a meshed edge.
3011 # @param theObject the object which elements should be processed
3012 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3013 # @param PathShape shape(edge) defines the sub-mesh for the path
3014 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3015 # @param HasAngles allows the shape to be rotated around the path
3016 # to get the resulting mesh in a helical fashion
3017 # @param Angles list of angles
3018 # @param HasRefPoint allows using the reference point
3019 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3020 # The User can specify any point as the Reference Point.
3021 # @param MakeGroups forces the generation of new groups from existing ones
3022 # @param LinearVariation forces the computation of rotation angles as linear
3023 # variation of the given Angles along path steps
3024 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3025 # only SMESH::Extrusion_Error otherwise
3026 # @ingroup l2_modif_extrurev
3027 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3028 HasAngles, Angles, HasRefPoint, RefPoint,
3029 MakeGroups=False, LinearVariation=False):
3030 Angles,AnglesParameters = ParseAngles(Angles)
3031 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3032 if ( isinstance( theObject, Mesh )):
3033 theObject = theObject.GetMesh()
3034 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3035 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3036 if ( isinstance( PathMesh, Mesh )):
3037 PathMesh = PathMesh.GetMesh()
3038 if HasAngles and Angles and LinearVariation:
3039 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3041 Parameters = AnglesParameters + var_separator + RefPointParameters
3042 self.mesh.SetParameters(Parameters)
3044 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3045 PathShape, NodeStart, HasAngles,
3046 Angles, HasRefPoint, RefPoint)
3047 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3048 NodeStart, HasAngles, Angles, HasRefPoint,
3051 ## Generates new elements by extrusion of the elements which belong to the object
3052 # The path of extrusion must be a meshed edge.
3053 # @param theObject the object which elements should be processed
3054 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3055 # @param PathShape shape(edge) defines the sub-mesh for the path
3056 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3057 # @param HasAngles allows the shape to be rotated around the path
3058 # to get the resulting mesh in a helical fashion
3059 # @param Angles list of angles
3060 # @param HasRefPoint allows using the reference point
3061 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3062 # The User can specify any point as the Reference Point.
3063 # @param MakeGroups forces the generation of new groups from existing ones
3064 # @param LinearVariation forces the computation of rotation angles as linear
3065 # variation of the given Angles along path steps
3066 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3067 # only SMESH::Extrusion_Error otherwise
3068 # @ingroup l2_modif_extrurev
3069 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3070 HasAngles, Angles, HasRefPoint, RefPoint,
3071 MakeGroups=False, LinearVariation=False):
3072 Angles,AnglesParameters = ParseAngles(Angles)
3073 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3074 if ( isinstance( theObject, Mesh )):
3075 theObject = theObject.GetMesh()
3076 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3077 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3078 if ( isinstance( PathMesh, Mesh )):
3079 PathMesh = PathMesh.GetMesh()
3080 if HasAngles and Angles and LinearVariation:
3081 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3083 Parameters = AnglesParameters + var_separator + RefPointParameters
3084 self.mesh.SetParameters(Parameters)
3086 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3087 PathShape, NodeStart, HasAngles,
3088 Angles, HasRefPoint, RefPoint)
3089 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3090 NodeStart, HasAngles, Angles, HasRefPoint,
3093 ## Creates a symmetrical copy of mesh elements
3094 # @param IDsOfElements list of elements ids
3095 # @param Mirror is AxisStruct or geom object(point, line, plane)
3096 # @param theMirrorType is POINT, AXIS or PLANE
3097 # If the Mirror is a geom object this parameter is unnecessary
3098 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3099 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3100 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3101 # @ingroup l2_modif_trsf
3102 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3103 if IDsOfElements == []:
3104 IDsOfElements = self.GetElementsId()
3105 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3106 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3107 Mirror,Parameters = ParseAxisStruct(Mirror)
3108 self.mesh.SetParameters(Parameters)
3109 if Copy and MakeGroups:
3110 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3111 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3114 ## Creates a new mesh by a symmetrical copy of mesh elements
3115 # @param IDsOfElements the 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 MakeGroups to generate new groups from existing ones
3120 # @param NewMeshName a name of the new mesh to create
3121 # @return instance of Mesh class
3122 # @ingroup l2_modif_trsf
3123 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
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 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3130 MakeGroups, NewMeshName)
3131 mesh.SetParameters(Parameters)
3132 return Mesh(self.smeshpyD,self.geompyD,mesh)
3134 ## Creates a symmetrical copy of the object
3135 # @param theObject mesh, submesh or group
3136 # @param Mirror AxisStruct or geom object (point, line, plane)
3137 # @param theMirrorType is POINT, AXIS or PLANE
3138 # If the Mirror is a geom object this parameter is unnecessary
3139 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3140 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3141 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3142 # @ingroup l2_modif_trsf
3143 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3144 if ( isinstance( theObject, Mesh )):
3145 theObject = theObject.GetMesh()
3146 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3147 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3148 Mirror,Parameters = ParseAxisStruct(Mirror)
3149 self.mesh.SetParameters(Parameters)
3150 if Copy and MakeGroups:
3151 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3152 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3155 ## Creates a new mesh by 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 POINT, AXIS or PLANE
3159 # If the Mirror is a geom object this parameter is unnecessary
3160 # @param MakeGroups forces the generation of new groups from existing ones
3161 # @param NewMeshName the name of the new mesh to create
3162 # @return instance of Mesh class
3163 # @ingroup l2_modif_trsf
3164 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
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 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3171 MakeGroups, NewMeshName)
3172 mesh.SetParameters(Parameters)
3173 return Mesh( self.smeshpyD,self.geompyD,mesh )
3175 ## Translates the elements
3176 # @param IDsOfElements list of elements ids
3177 # @param Vector the direction of translation (DirStruct or vector)
3178 # @param Copy allows copying the translated elements
3179 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3180 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3181 # @ingroup l2_modif_trsf
3182 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3183 if IDsOfElements == []:
3184 IDsOfElements = self.GetElementsId()
3185 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3186 Vector = self.smeshpyD.GetDirStruct(Vector)
3187 Vector,Parameters = ParseDirStruct(Vector)
3188 self.mesh.SetParameters(Parameters)
3189 if Copy and MakeGroups:
3190 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3191 self.editor.Translate(IDsOfElements, Vector, Copy)
3194 ## Creates a new mesh of translated elements
3195 # @param IDsOfElements list of elements ids
3196 # @param Vector the direction of translation (DirStruct or vector)
3197 # @param MakeGroups forces the generation of new groups from existing ones
3198 # @param NewMeshName the name of the newly created mesh
3199 # @return instance of Mesh class
3200 # @ingroup l2_modif_trsf
3201 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3202 if IDsOfElements == []:
3203 IDsOfElements = self.GetElementsId()
3204 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3205 Vector = self.smeshpyD.GetDirStruct(Vector)
3206 Vector,Parameters = ParseDirStruct(Vector)
3207 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3208 mesh.SetParameters(Parameters)
3209 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3211 ## Translates the object
3212 # @param theObject the object to translate (mesh, submesh, or group)
3213 # @param Vector direction of translation (DirStruct or geom vector)
3214 # @param Copy allows copying the translated elements
3215 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3216 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3217 # @ingroup l2_modif_trsf
3218 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3219 if ( isinstance( theObject, Mesh )):
3220 theObject = theObject.GetMesh()
3221 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3222 Vector = self.smeshpyD.GetDirStruct(Vector)
3223 Vector,Parameters = ParseDirStruct(Vector)
3224 self.mesh.SetParameters(Parameters)
3225 if Copy and MakeGroups:
3226 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3227 self.editor.TranslateObject(theObject, Vector, Copy)
3230 ## Creates a new mesh from the translated object
3231 # @param theObject the object to translate (mesh, submesh, or group)
3232 # @param Vector the direction of translation (DirStruct or geom vector)
3233 # @param MakeGroups forces the generation of new groups from existing ones
3234 # @param NewMeshName the name of the newly created mesh
3235 # @return instance of Mesh class
3236 # @ingroup l2_modif_trsf
3237 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3238 if (isinstance(theObject, Mesh)):
3239 theObject = theObject.GetMesh()
3240 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3241 Vector = self.smeshpyD.GetDirStruct(Vector)
3242 Vector,Parameters = ParseDirStruct(Vector)
3243 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3244 mesh.SetParameters(Parameters)
3245 return Mesh( self.smeshpyD, self.geompyD, mesh )
3247 ## Rotates the elements
3248 # @param IDsOfElements list of elements ids
3249 # @param Axis the axis of rotation (AxisStruct or geom line)
3250 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3251 # @param Copy allows copying the rotated elements
3252 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3253 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3254 # @ingroup l2_modif_trsf
3255 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3257 if isinstance(AngleInRadians,str):
3259 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3261 AngleInRadians = DegreesToRadians(AngleInRadians)
3262 if IDsOfElements == []:
3263 IDsOfElements = self.GetElementsId()
3264 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3265 Axis = self.smeshpyD.GetAxisStruct(Axis)
3266 Axis,AxisParameters = ParseAxisStruct(Axis)
3267 Parameters = AxisParameters + var_separator + Parameters
3268 self.mesh.SetParameters(Parameters)
3269 if Copy and MakeGroups:
3270 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3271 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3274 ## Creates a new mesh of rotated elements
3275 # @param IDsOfElements list of element ids
3276 # @param Axis the axis of rotation (AxisStruct or geom line)
3277 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3278 # @param MakeGroups forces the generation of new groups from existing ones
3279 # @param NewMeshName the name of the newly created mesh
3280 # @return instance of Mesh class
3281 # @ingroup l2_modif_trsf
3282 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3284 if isinstance(AngleInRadians,str):
3286 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3288 AngleInRadians = DegreesToRadians(AngleInRadians)
3289 if IDsOfElements == []:
3290 IDsOfElements = self.GetElementsId()
3291 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3292 Axis = self.smeshpyD.GetAxisStruct(Axis)
3293 Axis,AxisParameters = ParseAxisStruct(Axis)
3294 Parameters = AxisParameters + var_separator + Parameters
3295 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3296 MakeGroups, NewMeshName)
3297 mesh.SetParameters(Parameters)
3298 return Mesh( self.smeshpyD, self.geompyD, mesh )
3300 ## Rotates the object
3301 # @param theObject the object to rotate( mesh, submesh, or group)
3302 # @param Axis the axis of rotation (AxisStruct or geom line)
3303 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3304 # @param Copy allows copying the rotated elements
3305 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3306 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3307 # @ingroup l2_modif_trsf
3308 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3310 if isinstance(AngleInRadians,str):
3312 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3314 AngleInRadians = DegreesToRadians(AngleInRadians)
3315 if (isinstance(theObject, Mesh)):
3316 theObject = theObject.GetMesh()
3317 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3318 Axis = self.smeshpyD.GetAxisStruct(Axis)
3319 Axis,AxisParameters = ParseAxisStruct(Axis)
3320 Parameters = AxisParameters + ":" + Parameters
3321 self.mesh.SetParameters(Parameters)
3322 if Copy and MakeGroups:
3323 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3324 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3327 ## Creates a new mesh from the rotated object
3328 # @param theObject the object to rotate (mesh, submesh, or group)
3329 # @param Axis the axis of rotation (AxisStruct or geom line)
3330 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3331 # @param MakeGroups forces the generation of new groups from existing ones
3332 # @param NewMeshName the name of the newly created mesh
3333 # @return instance of Mesh class
3334 # @ingroup l2_modif_trsf
3335 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3337 if isinstance(AngleInRadians,str):
3339 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3341 AngleInRadians = DegreesToRadians(AngleInRadians)
3342 if (isinstance( theObject, Mesh )):
3343 theObject = theObject.GetMesh()
3344 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3345 Axis = self.smeshpyD.GetAxisStruct(Axis)
3346 Axis,AxisParameters = ParseAxisStruct(Axis)
3347 Parameters = AxisParameters + ":" + Parameters
3348 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3349 MakeGroups, NewMeshName)
3350 mesh.SetParameters(Parameters)
3351 return Mesh( self.smeshpyD, self.geompyD, mesh )
3353 ## Finds groups of ajacent nodes within Tolerance.
3354 # @param Tolerance the value of tolerance
3355 # @return the list of groups of nodes
3356 # @ingroup l2_modif_trsf
3357 def FindCoincidentNodes (self, Tolerance):
3358 return self.editor.FindCoincidentNodes(Tolerance)
3360 ## Finds groups of ajacent nodes within Tolerance.
3361 # @param Tolerance the value of tolerance
3362 # @param SubMeshOrGroup SubMesh or Group
3363 # @return the list of groups of nodes
3364 # @ingroup l2_modif_trsf
3365 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3366 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3369 # @param GroupsOfNodes the list of groups of nodes
3370 # @ingroup l2_modif_trsf
3371 def MergeNodes (self, GroupsOfNodes):
3372 self.editor.MergeNodes(GroupsOfNodes)
3374 ## Finds the elements built on the same nodes.
3375 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3376 # @return a list of groups of equal elements
3377 # @ingroup l2_modif_trsf
3378 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3379 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3380 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3381 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3383 ## Merges elements in each given group.
3384 # @param GroupsOfElementsID groups of elements for merging
3385 # @ingroup l2_modif_trsf
3386 def MergeElements(self, GroupsOfElementsID):
3387 self.editor.MergeElements(GroupsOfElementsID)
3389 ## Leaves one element and removes all other elements built on the same nodes.
3390 # @ingroup l2_modif_trsf
3391 def MergeEqualElements(self):
3392 self.editor.MergeEqualElements()
3394 ## Sews free borders
3395 # @return SMESH::Sew_Error
3396 # @ingroup l2_modif_trsf
3397 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3398 FirstNodeID2, SecondNodeID2, LastNodeID2,
3399 CreatePolygons, CreatePolyedrs):
3400 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3401 FirstNodeID2, SecondNodeID2, LastNodeID2,
3402 CreatePolygons, CreatePolyedrs)
3404 ## Sews conform free borders
3405 # @return SMESH::Sew_Error
3406 # @ingroup l2_modif_trsf
3407 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3408 FirstNodeID2, SecondNodeID2):
3409 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3410 FirstNodeID2, SecondNodeID2)
3412 ## Sews border to side
3413 # @return SMESH::Sew_Error
3414 # @ingroup l2_modif_trsf
3415 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3416 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3417 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3418 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3420 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3421 # merged with the nodes of elements of Side2.
3422 # The number of elements in theSide1 and in theSide2 must be
3423 # equal and they should have similar nodal connectivity.
3424 # The nodes to merge should belong to side borders and
3425 # the first node should be linked to the second.
3426 # @return SMESH::Sew_Error
3427 # @ingroup l2_modif_trsf
3428 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3429 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3430 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3431 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3432 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3433 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3435 ## Sets new nodes for the given element.
3436 # @param ide the element id
3437 # @param newIDs nodes ids
3438 # @return If the number of nodes does not correspond to the type of element - returns false
3439 # @ingroup l2_modif_edit
3440 def ChangeElemNodes(self, ide, newIDs):
3441 return self.editor.ChangeElemNodes(ide, newIDs)
3443 ## If during the last operation of MeshEditor some nodes were
3444 # created, this method returns the list of their IDs, \n
3445 # if new nodes were not created - returns empty list
3446 # @return the list of integer values (can be empty)
3447 # @ingroup l1_auxiliary
3448 def GetLastCreatedNodes(self):
3449 return self.editor.GetLastCreatedNodes()
3451 ## If during the last operation of MeshEditor some elements were
3452 # created this method returns the list of their IDs, \n
3453 # if new elements were not created - returns empty list
3454 # @return the list of integer values (can be empty)
3455 # @ingroup l1_auxiliary
3456 def GetLastCreatedElems(self):
3457 return self.editor.GetLastCreatedElems()
3459 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3460 # @param theNodes identifiers of nodes to be doubled
3461 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3462 # nodes. If list of element identifiers is empty then nodes are doubled but
3463 # they not assigned to elements
3464 # @return TRUE if operation has been completed successfully, FALSE otherwise
3465 # @ingroup l2_modif_edit
3466 def DoubleNodes(self, theNodes, theModifiedElems):
3467 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3469 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3470 # This method provided for convenience works as DoubleNodes() described above.
3471 # @param theNodes identifiers of node to be doubled
3472 # @param theModifiedElems identifiers of elements to be updated
3473 # @return TRUE if operation has been completed successfully, FALSE otherwise
3474 # @ingroup l2_modif_edit
3475 def DoubleNode(self, theNodeId, theModifiedElems):
3476 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3478 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3479 # This method provided for convenience works as DoubleNodes() described above.
3480 # @param theNodes group of nodes to be doubled
3481 # @param theModifiedElems group of elements to be updated.
3482 # @return TRUE if operation has been completed successfully, FALSE otherwise
3483 # @ingroup l2_modif_edit
3484 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3485 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3487 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3488 # This method provided for convenience works as DoubleNodes() described above.
3489 # @param theNodes list of groups of nodes to be doubled
3490 # @param theModifiedElems list of groups of elements to be updated.
3491 # @return TRUE if operation has been completed successfully, FALSE otherwise
3492 # @ingroup l2_modif_edit
3493 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3494 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3496 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3497 # @param theElems - the list of elements (edges or faces) to be replicated
3498 # The nodes for duplication could be found from these elements
3499 # @param theNodesNot - list of nodes to NOT replicate
3500 # @param theAffectedElems - the list of elements (cells and edges) to which the
3501 # replicated nodes should be associated to.
3502 # @return TRUE if operation has been completed successfully, FALSE otherwise
3503 # @ingroup l2_modif_edit
3504 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3505 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3507 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3508 # @param theElems - the list of elements (edges or faces) to be replicated
3509 # The nodes for duplication could be found from these elements
3510 # @param theNodesNot - list of nodes to NOT replicate
3511 # @param theShape - shape to detect affected elements (element which geometric center
3512 # located on or inside shape).
3513 # The replicated nodes should be associated to affected elements.
3514 # @return TRUE if operation has been completed successfully, FALSE otherwise
3515 # @ingroup l2_modif_edit
3516 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3517 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3519 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3520 # This method provided for convenience works as DoubleNodes() described above.
3521 # @param theElems - group of of elements (edges or faces) to be replicated
3522 # @param theNodesNot - group of nodes not to replicated
3523 # @param theAffectedElems - group of elements to which the replicated nodes
3524 # should be associated to.
3525 # @ingroup l2_modif_edit
3526 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3527 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3529 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3530 # This method provided for convenience works as DoubleNodes() described above.
3531 # @param theElems - group of of elements (edges or faces) to be replicated
3532 # @param theNodesNot - group of nodes not to replicated
3533 # @param theShape - shape to detect affected elements (element which geometric center
3534 # located on or inside shape).
3535 # The replicated nodes should be associated to affected elements.
3536 # @ingroup l2_modif_edit
3537 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3538 return self.editor.DoubleNodeElemGroupInRegion(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 - list of groups of elements (edges or faces) to be replicated
3543 # @param theNodesNot - list of groups of nodes not to replicated
3544 # @param theAffectedElems - group of elements to which the replicated nodes
3545 # should be associated to.
3546 # @return TRUE if operation has been completed successfully, FALSE otherwise
3547 # @ingroup l2_modif_edit
3548 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3549 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3551 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3552 # This method provided for convenience works as DoubleNodes() described above.
3553 # @param theElems - list of groups of elements (edges or faces) to be replicated
3554 # @param theNodesNot - list of groups of nodes not to replicated
3555 # @param theShape - shape to detect affected elements (element which geometric center
3556 # located on or inside shape).
3557 # The replicated nodes should be associated to affected elements.
3558 # @return TRUE if operation has been completed successfully, FALSE otherwise
3559 # @ingroup l2_modif_edit
3560 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3561 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3563 ## The mother class to define algorithm, it is not recommended to use it directly.
3566 # @ingroup l2_algorithms
3567 class Mesh_Algorithm:
3568 # @class Mesh_Algorithm
3569 # @brief Class Mesh_Algorithm
3571 #def __init__(self,smesh):
3579 ## Finds a hypothesis in the study by its type name and parameters.
3580 # Finds only the hypotheses created in smeshpyD engine.
3581 # @return SMESH.SMESH_Hypothesis
3582 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3583 study = smeshpyD.GetCurrentStudy()
3584 #to do: find component by smeshpyD object, not by its data type
3585 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3586 if scomp is not None:
3587 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3588 # Check if the root label of the hypotheses exists
3589 if res and hypRoot is not None:
3590 iter = study.NewChildIterator(hypRoot)
3591 # Check all published hypotheses
3593 hypo_so_i = iter.Value()
3594 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3595 if attr is not None:
3596 anIOR = attr.Value()
3597 hypo_o_i = salome.orb.string_to_object(anIOR)
3598 if hypo_o_i is not None:
3599 # Check if this is a hypothesis
3600 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3601 if hypo_i is not None:
3602 # Check if the hypothesis belongs to current engine
3603 if smeshpyD.GetObjectId(hypo_i) > 0:
3604 # Check if this is the required hypothesis
3605 if hypo_i.GetName() == hypname:
3607 if CompareMethod(hypo_i, args):
3621 ## Finds the algorithm in the study by its type name.
3622 # Finds only the algorithms, which have been created in smeshpyD engine.
3623 # @return SMESH.SMESH_Algo
3624 def FindAlgorithm (self, algoname, smeshpyD):
3625 study = smeshpyD.GetCurrentStudy()
3626 #to do: find component by smeshpyD object, not by its data type
3627 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3628 if scomp is not None:
3629 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3630 # Check if the root label of the algorithms exists
3631 if res and hypRoot is not None:
3632 iter = study.NewChildIterator(hypRoot)
3633 # Check all published algorithms
3635 algo_so_i = iter.Value()
3636 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3637 if attr is not None:
3638 anIOR = attr.Value()
3639 algo_o_i = salome.orb.string_to_object(anIOR)
3640 if algo_o_i is not None:
3641 # Check if this is an algorithm
3642 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3643 if algo_i is not None:
3644 # Checks if the algorithm belongs to the current engine
3645 if smeshpyD.GetObjectId(algo_i) > 0:
3646 # Check if this is the required algorithm
3647 if algo_i.GetName() == algoname:
3660 ## If the algorithm is global, returns 0; \n
3661 # else returns the submesh associated to this algorithm.
3662 def GetSubMesh(self):
3665 ## Returns the wrapped mesher.
3666 def GetAlgorithm(self):
3669 ## Gets the list of hypothesis that can be used with this algorithm
3670 def GetCompatibleHypothesis(self):
3673 mylist = self.algo.GetCompatibleHypothesis()
3676 ## Gets the name of the algorithm
3680 ## Sets the name to the algorithm
3681 def SetName(self, name):
3682 self.mesh.smeshpyD.SetName(self.algo, name)
3684 ## Gets the id of the algorithm
3686 return self.algo.GetId()
3689 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3691 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3692 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3694 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3696 self.Assign(algo, mesh, geom)
3700 def Assign(self, algo, mesh, geom):
3702 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3709 name = GetName(geom)
3711 name = mesh.geompyD.SubShapeName(geom, piece)
3712 mesh.geompyD.addToStudyInFather(piece, geom, name)
3713 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3716 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3717 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3719 def CompareHyp (self, hyp, args):
3720 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3723 def CompareEqualHyp (self, hyp, args):
3727 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3728 UseExisting=0, CompareMethod=""):
3731 if CompareMethod == "": CompareMethod = self.CompareHyp
3732 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3735 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3741 a = a + s + str(args[i])
3745 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3747 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3748 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3751 ## Returns entry of the shape to mesh in the study
3752 def MainShapeEntry(self):
3754 if not self.mesh or not self.mesh.GetMesh(): return entry
3755 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3756 study = self.mesh.smeshpyD.GetCurrentStudy()
3757 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3758 sobj = study.FindObjectIOR(ior)
3759 if sobj: entry = sobj.GetID()
3760 if not entry: return ""
3763 # Public class: Mesh_Segment
3764 # --------------------------
3766 ## Class to define a segment 1D algorithm for discretization
3769 # @ingroup l3_algos_basic
3770 class Mesh_Segment(Mesh_Algorithm):
3772 ## Private constructor.
3773 def __init__(self, mesh, geom=0):
3774 Mesh_Algorithm.__init__(self)
3775 self.Create(mesh, geom, "Regular_1D")
3777 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3778 # @param l for the length of segments that cut an edge
3779 # @param UseExisting if ==true - searches for an existing hypothesis created with
3780 # the same parameters, else (default) - creates a new one
3781 # @param p precision, used for calculation of the number of segments.
3782 # The precision should be a positive, meaningful value within the range [0,1].
3783 # In general, the number of segments is calculated with the formula:
3784 # nb = ceil((edge_length / l) - p)
3785 # Function ceil rounds its argument to the higher integer.
3786 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3787 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3788 # p=1 means rounding of (edge_length / l) to the lower integer.
3789 # Default value is 1e-07.
3790 # @return an instance of StdMeshers_LocalLength hypothesis
3791 # @ingroup l3_hypos_1dhyps
3792 def LocalLength(self, l, UseExisting=0, p=1e-07):
3793 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3794 CompareMethod=self.CompareLocalLength)
3800 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3801 def CompareLocalLength(self, hyp, args):
3802 if IsEqual(hyp.GetLength(), args[0]):
3803 return IsEqual(hyp.GetPrecision(), args[1])
3806 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3807 # @param length is optional maximal allowed length of segment, if it is omitted
3808 # the preestimated length is used that depends on geometry size
3809 # @param UseExisting if ==true - searches for an existing hypothesis created with
3810 # the same parameters, else (default) - create a new one
3811 # @return an instance of StdMeshers_MaxLength hypothesis
3812 # @ingroup l3_hypos_1dhyps
3813 def MaxSize(self, length=0.0, UseExisting=0):
3814 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3817 hyp.SetLength(length)
3819 # set preestimated length
3820 gen = self.mesh.smeshpyD
3821 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3822 self.mesh.GetMesh(), self.mesh.GetShape(),
3824 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3826 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3829 hyp.SetUsePreestimatedLength( length == 0.0 )
3832 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3833 # @param n for the number of segments that cut an edge
3834 # @param s for the scale factor (optional)
3835 # @param reversedEdges is a list of edges to mesh using reversed orientation
3836 # @param UseExisting if ==true - searches for an existing hypothesis created with
3837 # the same parameters, else (default) - create a new one
3838 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3839 # @ingroup l3_hypos_1dhyps
3840 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3841 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3842 reversedEdges, UseExisting = [], reversedEdges
3843 entry = self.MainShapeEntry()
3845 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3846 UseExisting=UseExisting,
3847 CompareMethod=self.CompareNumberOfSegments)
3849 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3850 UseExisting=UseExisting,
3851 CompareMethod=self.CompareNumberOfSegments)
3852 hyp.SetDistrType( 1 )
3853 hyp.SetScaleFactor(s)
3854 hyp.SetNumberOfSegments(n)
3855 hyp.SetReversedEdges( reversedEdges )
3856 hyp.SetObjectEntry( entry )
3860 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3861 def CompareNumberOfSegments(self, hyp, args):
3862 if hyp.GetNumberOfSegments() == args[0]:
3864 if hyp.GetReversedEdges() == args[1]:
3865 if not args[1] or hyp.GetObjectEntry() == args[2]:
3868 if hyp.GetReversedEdges() == args[2]:
3869 if not args[2] or hyp.GetObjectEntry() == args[3]:
3870 if hyp.GetDistrType() == 1:
3871 if IsEqual(hyp.GetScaleFactor(), args[1]):
3875 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3876 # @param start defines the length of the first segment
3877 # @param end defines the length of the last segment
3878 # @param reversedEdges is a list of edges to mesh using reversed orientation
3879 # @param UseExisting if ==true - searches for an existing hypothesis created with
3880 # the same parameters, else (default) - creates a new one
3881 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3882 # @ingroup l3_hypos_1dhyps
3883 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3884 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3885 reversedEdges, UseExisting = [], reversedEdges
3886 entry = self.MainShapeEntry()
3887 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3888 UseExisting=UseExisting,
3889 CompareMethod=self.CompareArithmetic1D)
3890 hyp.SetStartLength(start)
3891 hyp.SetEndLength(end)
3892 hyp.SetReversedEdges( reversedEdges )
3893 hyp.SetObjectEntry( entry )
3897 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3898 def CompareArithmetic1D(self, hyp, args):
3899 if IsEqual(hyp.GetLength(1), args[0]):
3900 if IsEqual(hyp.GetLength(0), args[1]):
3901 if hyp.GetReversedEdges() == args[2]:
3902 if not args[2] or hyp.GetObjectEntry() == args[3]:
3907 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3908 # on curve from 0 to 1 (additionally it is neecessary to check
3909 # orientation of edges and create list of reversed edges if it is
3910 # needed) and sets numbers of segments between given points (default
3911 # values are equals 1
3912 # @param points defines the list of parameters on curve
3913 # @param nbSegs defines the list of numbers of segments
3914 # @param reversedEdges is a list of edges to mesh using reversed orientation
3915 # @param UseExisting if ==true - searches for an existing hypothesis created with
3916 # the same parameters, else (default) - creates a new one
3917 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3918 # @ingroup l3_hypos_1dhyps
3919 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3920 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3921 reversedEdges, UseExisting = [], reversedEdges
3922 entry = self.MainShapeEntry()
3923 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3924 UseExisting=UseExisting,
3925 CompareMethod=self.CompareArithmetic1D)
3926 hyp.SetPoints(points)
3927 hyp.SetNbSegments(nbSegs)
3928 hyp.SetReversedEdges(reversedEdges)
3929 hyp.SetObjectEntry(entry)
3933 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3934 ## as the given arguments
3935 def CompareFixedPoints1D(self, hyp, args):
3936 if hyp.GetPoints() == args[0]:
3937 if hyp.GetNbSegments() == args[1]:
3938 if hyp.GetReversedEdges() == args[2]:
3939 if not args[2] or hyp.GetObjectEntry() == args[3]:
3945 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3946 # @param start defines the length of the first segment
3947 # @param end defines the length of the last segment
3948 # @param reversedEdges is a list of edges to mesh using reversed orientation
3949 # @param UseExisting if ==true - searches for an existing hypothesis created with
3950 # the same parameters, else (default) - creates a new one
3951 # @return an instance of StdMeshers_StartEndLength hypothesis
3952 # @ingroup l3_hypos_1dhyps
3953 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3954 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3955 reversedEdges, UseExisting = [], reversedEdges
3956 entry = self.MainShapeEntry()
3957 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3958 UseExisting=UseExisting,
3959 CompareMethod=self.CompareStartEndLength)
3960 hyp.SetStartLength(start)
3961 hyp.SetEndLength(end)
3962 hyp.SetReversedEdges( reversedEdges )
3963 hyp.SetObjectEntry( entry )
3966 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3967 def CompareStartEndLength(self, hyp, args):
3968 if IsEqual(hyp.GetLength(1), args[0]):
3969 if IsEqual(hyp.GetLength(0), args[1]):
3970 if hyp.GetReversedEdges() == args[2]:
3971 if not args[2] or hyp.GetObjectEntry() == args[3]:
3975 ## Defines "Deflection1D" hypothesis
3976 # @param d for the deflection
3977 # @param UseExisting if ==true - searches for an existing hypothesis created with
3978 # the same parameters, else (default) - create a new one
3979 # @ingroup l3_hypos_1dhyps
3980 def Deflection1D(self, d, UseExisting=0):
3981 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3982 CompareMethod=self.CompareDeflection1D)
3983 hyp.SetDeflection(d)
3986 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3987 def CompareDeflection1D(self, hyp, args):
3988 return IsEqual(hyp.GetDeflection(), args[0])
3990 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3991 # the opposite side in case of quadrangular faces
3992 # @ingroup l3_hypos_additi
3993 def Propagation(self):
3994 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3996 ## Defines "AutomaticLength" hypothesis
3997 # @param fineness for the fineness [0-1]
3998 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3999 # same parameters, else (default) - create a new one
4000 # @ingroup l3_hypos_1dhyps
4001 def AutomaticLength(self, fineness=0, UseExisting=0):
4002 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4003 CompareMethod=self.CompareAutomaticLength)
4004 hyp.SetFineness( fineness )
4007 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4008 def CompareAutomaticLength(self, hyp, args):
4009 return IsEqual(hyp.GetFineness(), args[0])
4011 ## Defines "SegmentLengthAroundVertex" hypothesis
4012 # @param length for the segment length
4013 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4014 # Any other integer value means that the hypothesis will be set on the
4015 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4016 # @param UseExisting if ==true - searches for an existing hypothesis created with
4017 # the same parameters, else (default) - creates a new one
4018 # @ingroup l3_algos_segmarv
4019 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4021 store_geom = self.geom
4022 if type(vertex) is types.IntType:
4023 if vertex == 0 or vertex == 1:
4024 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4032 if self.geom is None:
4033 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4034 name = GetName(self.geom)
4036 piece = self.mesh.geom
4037 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4038 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4039 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4041 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4043 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4044 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4046 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4047 CompareMethod=self.CompareLengthNearVertex)
4048 self.geom = store_geom
4049 hyp.SetLength( length )
4052 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4053 # @ingroup l3_algos_segmarv
4054 def CompareLengthNearVertex(self, hyp, args):
4055 return IsEqual(hyp.GetLength(), args[0])
4057 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4058 # If the 2D mesher sees that all boundary edges are quadratic,
4059 # it generates quadratic faces, else it generates linear faces using
4060 # medium nodes as if they are vertices.
4061 # The 3D mesher generates quadratic volumes only if all boundary faces
4062 # are quadratic, else it fails.
4064 # @ingroup l3_hypos_additi
4065 def QuadraticMesh(self):
4066 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4069 # Public class: Mesh_CompositeSegment
4070 # --------------------------
4072 ## Defines a segment 1D algorithm for discretization
4074 # @ingroup l3_algos_basic
4075 class Mesh_CompositeSegment(Mesh_Segment):
4077 ## Private constructor.
4078 def __init__(self, mesh, geom=0):
4079 self.Create(mesh, geom, "CompositeSegment_1D")
4082 # Public class: Mesh_Segment_Python
4083 # ---------------------------------
4085 ## Defines a segment 1D algorithm for discretization with python function
4087 # @ingroup l3_algos_basic
4088 class Mesh_Segment_Python(Mesh_Segment):
4090 ## Private constructor.
4091 def __init__(self, mesh, geom=0):
4092 import Python1dPlugin
4093 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4095 ## Defines "PythonSplit1D" hypothesis
4096 # @param n for the number of segments that cut an edge
4097 # @param func for the python function that calculates the length of all segments
4098 # @param UseExisting if ==true - searches for the existing hypothesis created with
4099 # the same parameters, else (default) - creates a new one
4100 # @ingroup l3_hypos_1dhyps
4101 def PythonSplit1D(self, n, func, UseExisting=0):
4102 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4103 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4104 hyp.SetNumberOfSegments(n)
4105 hyp.SetPythonLog10RatioFunction(func)
4108 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4109 def ComparePythonSplit1D(self, hyp, args):
4110 #if hyp.GetNumberOfSegments() == args[0]:
4111 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4115 # Public class: Mesh_Triangle
4116 # ---------------------------
4118 ## Defines a triangle 2D algorithm
4120 # @ingroup l3_algos_basic
4121 class Mesh_Triangle(Mesh_Algorithm):
4130 ## Private constructor.
4131 def __init__(self, mesh, algoType, geom=0):
4132 Mesh_Algorithm.__init__(self)
4134 self.algoType = algoType
4135 if algoType == MEFISTO:
4136 self.Create(mesh, geom, "MEFISTO_2D")
4138 elif algoType == BLSURF:
4140 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4141 #self.SetPhysicalMesh() - PAL19680
4142 elif algoType == NETGEN:
4144 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4146 elif algoType == NETGEN_2D:
4148 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4151 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4152 # @param area for the maximum area of each triangle
4153 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4154 # same parameters, else (default) - creates a new one
4156 # Only for algoType == MEFISTO || NETGEN_2D
4157 # @ingroup l3_hypos_2dhyps
4158 def MaxElementArea(self, area, UseExisting=0):
4159 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4160 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4161 CompareMethod=self.CompareMaxElementArea)
4162 elif self.algoType == NETGEN:
4163 hyp = self.Parameters(SIMPLE)
4164 hyp.SetMaxElementArea(area)
4167 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4168 def CompareMaxElementArea(self, hyp, args):
4169 return IsEqual(hyp.GetMaxElementArea(), args[0])
4171 ## Defines "LengthFromEdges" hypothesis to build triangles
4172 # based on the length of the edges taken from the wire
4174 # Only for algoType == MEFISTO || NETGEN_2D
4175 # @ingroup l3_hypos_2dhyps
4176 def LengthFromEdges(self):
4177 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4178 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4180 elif self.algoType == NETGEN:
4181 hyp = self.Parameters(SIMPLE)
4182 hyp.LengthFromEdges()
4185 ## Sets a way to define size of mesh elements to generate.
4186 # @param thePhysicalMesh is: DefaultSize or Custom.
4187 # @ingroup l3_hypos_blsurf
4188 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4189 # Parameter of BLSURF algo
4190 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4192 ## Sets size of mesh elements to generate.
4193 # @ingroup l3_hypos_blsurf
4194 def SetPhySize(self, theVal):
4195 # Parameter of BLSURF algo
4196 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4197 self.Parameters().SetPhySize(theVal)
4199 ## Sets lower boundary of mesh element size (PhySize).
4200 # @ingroup l3_hypos_blsurf
4201 def SetPhyMin(self, theVal=-1):
4202 # Parameter of BLSURF algo
4203 self.Parameters().SetPhyMin(theVal)
4205 ## Sets upper boundary of mesh element size (PhySize).
4206 # @ingroup l3_hypos_blsurf
4207 def SetPhyMax(self, theVal=-1):
4208 # Parameter of BLSURF algo
4209 self.Parameters().SetPhyMax(theVal)
4211 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4212 # @param theGeometricMesh is: DefaultGeom or Custom
4213 # @ingroup l3_hypos_blsurf
4214 def SetGeometricMesh(self, theGeometricMesh=0):
4215 # Parameter of BLSURF algo
4216 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4217 self.params.SetGeometricMesh(theGeometricMesh)
4219 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4220 # @ingroup l3_hypos_blsurf
4221 def SetAngleMeshS(self, theVal=_angleMeshS):
4222 # Parameter of BLSURF algo
4223 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4224 self.params.SetAngleMeshS(theVal)
4226 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4227 # @ingroup l3_hypos_blsurf
4228 def SetAngleMeshC(self, theVal=_angleMeshS):
4229 # Parameter of BLSURF algo
4230 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4231 self.params.SetAngleMeshC(theVal)
4233 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4234 # @ingroup l3_hypos_blsurf
4235 def SetGeoMin(self, theVal=-1):
4236 # Parameter of BLSURF algo
4237 self.Parameters().SetGeoMin(theVal)
4239 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4240 # @ingroup l3_hypos_blsurf
4241 def SetGeoMax(self, theVal=-1):
4242 # Parameter of BLSURF algo
4243 self.Parameters().SetGeoMax(theVal)
4245 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4246 # @ingroup l3_hypos_blsurf
4247 def SetGradation(self, theVal=_gradation):
4248 # Parameter of BLSURF algo
4249 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4250 self.params.SetGradation(theVal)
4252 ## Sets topology usage way.
4253 # @param way defines how mesh conformity is assured <ul>
4254 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4255 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4256 # @ingroup l3_hypos_blsurf
4257 def SetTopology(self, way):
4258 # Parameter of BLSURF algo
4259 self.Parameters().SetTopology(way)
4261 ## To respect geometrical edges or not.
4262 # @ingroup l3_hypos_blsurf
4263 def SetDecimesh(self, toIgnoreEdges=False):
4264 # Parameter of BLSURF algo
4265 self.Parameters().SetDecimesh(toIgnoreEdges)
4267 ## Sets verbosity level in the range 0 to 100.
4268 # @ingroup l3_hypos_blsurf
4269 def SetVerbosity(self, level):
4270 # Parameter of BLSURF algo
4271 self.Parameters().SetVerbosity(level)
4273 ## Sets advanced option value.
4274 # @ingroup l3_hypos_blsurf
4275 def SetOptionValue(self, optionName, level):
4276 # Parameter of BLSURF algo
4277 self.Parameters().SetOptionValue(optionName,level)
4279 ## Sets QuadAllowed flag.
4280 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4281 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4282 def SetQuadAllowed(self, toAllow=True):
4283 if self.algoType == NETGEN_2D:
4284 if toAllow: # add QuadranglePreference
4285 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4286 else: # remove QuadranglePreference
4287 for hyp in self.mesh.GetHypothesisList( self.geom ):
4288 if hyp.GetName() == "QuadranglePreference":
4289 self.mesh.RemoveHypothesis( self.geom, hyp )
4294 if self.Parameters():
4295 self.params.SetQuadAllowed(toAllow)
4298 ## Defines hypothesis having several parameters
4300 # @ingroup l3_hypos_netgen
4301 def Parameters(self, which=SOLE):
4304 if self.algoType == NETGEN:
4306 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4307 "libNETGENEngine.so", UseExisting=0)
4309 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4310 "libNETGENEngine.so", UseExisting=0)
4312 elif self.algoType == MEFISTO:
4313 print "Mefisto algo support no multi-parameter hypothesis"
4315 elif self.algoType == NETGEN_2D:
4316 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4317 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4319 elif self.algoType == BLSURF:
4320 self.params = self.Hypothesis("BLSURF_Parameters", [],
4321 "libBLSURFEngine.so", UseExisting=0)
4324 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4329 # Only for algoType == NETGEN
4330 # @ingroup l3_hypos_netgen
4331 def SetMaxSize(self, theSize):
4332 if self.Parameters():
4333 self.params.SetMaxSize(theSize)
4335 ## Sets SecondOrder flag
4337 # Only for algoType == NETGEN
4338 # @ingroup l3_hypos_netgen
4339 def SetSecondOrder(self, theVal):
4340 if self.Parameters():
4341 self.params.SetSecondOrder(theVal)
4343 ## Sets Optimize flag
4345 # Only for algoType == NETGEN
4346 # @ingroup l3_hypos_netgen
4347 def SetOptimize(self, theVal):
4348 if self.Parameters():
4349 self.params.SetOptimize(theVal)
4352 # @param theFineness is:
4353 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4355 # Only for algoType == NETGEN
4356 # @ingroup l3_hypos_netgen
4357 def SetFineness(self, theFineness):
4358 if self.Parameters():
4359 self.params.SetFineness(theFineness)
4363 # Only for algoType == NETGEN
4364 # @ingroup l3_hypos_netgen
4365 def SetGrowthRate(self, theRate):
4366 if self.Parameters():
4367 self.params.SetGrowthRate(theRate)
4369 ## Sets NbSegPerEdge
4371 # Only for algoType == NETGEN
4372 # @ingroup l3_hypos_netgen
4373 def SetNbSegPerEdge(self, theVal):
4374 if self.Parameters():
4375 self.params.SetNbSegPerEdge(theVal)
4377 ## Sets NbSegPerRadius
4379 # Only for algoType == NETGEN
4380 # @ingroup l3_hypos_netgen
4381 def SetNbSegPerRadius(self, theVal):
4382 if self.Parameters():
4383 self.params.SetNbSegPerRadius(theVal)
4385 ## Sets number of segments overriding value set by SetLocalLength()
4387 # Only for algoType == NETGEN
4388 # @ingroup l3_hypos_netgen
4389 def SetNumberOfSegments(self, theVal):
4390 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4392 ## Sets number of segments overriding value set by SetNumberOfSegments()
4394 # Only for algoType == NETGEN
4395 # @ingroup l3_hypos_netgen
4396 def SetLocalLength(self, theVal):
4397 self.Parameters(SIMPLE).SetLocalLength(theVal)
4402 # Public class: Mesh_Quadrangle
4403 # -----------------------------
4405 ## Defines a quadrangle 2D algorithm
4407 # @ingroup l3_algos_basic
4408 class Mesh_Quadrangle(Mesh_Algorithm):
4410 ## Private constructor.
4411 def __init__(self, mesh, geom=0):
4412 Mesh_Algorithm.__init__(self)
4413 self.Create(mesh, geom, "Quadrangle_2D")
4415 ## Defines "QuadranglePreference" hypothesis, forcing construction
4416 # of quadrangles if the number of nodes on the opposite edges is not the same
4417 # while the total number of nodes on edges is even
4419 # @ingroup l3_hypos_additi
4420 def QuadranglePreference(self):
4421 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4422 CompareMethod=self.CompareEqualHyp)
4425 ## Defines "TrianglePreference" hypothesis, forcing construction
4426 # of triangles in the refinement area if the number of nodes
4427 # on the opposite edges is not the same
4429 # @ingroup l3_hypos_additi
4430 def TrianglePreference(self):
4431 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4432 CompareMethod=self.CompareEqualHyp)
4435 # Public class: Mesh_Tetrahedron
4436 # ------------------------------
4438 ## Defines a tetrahedron 3D algorithm
4440 # @ingroup l3_algos_basic
4441 class Mesh_Tetrahedron(Mesh_Algorithm):
4446 ## Private constructor.
4447 def __init__(self, mesh, algoType, geom=0):
4448 Mesh_Algorithm.__init__(self)
4450 if algoType == NETGEN:
4452 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4455 elif algoType == FULL_NETGEN:
4457 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4460 elif algoType == GHS3D:
4462 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4465 elif algoType == GHS3DPRL:
4466 CheckPlugin(GHS3DPRL)
4467 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4470 self.algoType = algoType
4472 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4473 # @param vol for the maximum volume of each tetrahedron
4474 # @param UseExisting if ==true - searches for the existing hypothesis created with
4475 # the same parameters, else (default) - creates a new one
4476 # @ingroup l3_hypos_maxvol
4477 def MaxElementVolume(self, vol, UseExisting=0):
4478 if self.algoType == NETGEN:
4479 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4480 CompareMethod=self.CompareMaxElementVolume)
4481 hyp.SetMaxElementVolume(vol)
4483 elif self.algoType == FULL_NETGEN:
4484 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4487 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4488 def CompareMaxElementVolume(self, hyp, args):
4489 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4491 ## Defines hypothesis having several parameters
4493 # @ingroup l3_hypos_netgen
4494 def Parameters(self, which=SOLE):
4498 if self.algoType == FULL_NETGEN:
4500 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4501 "libNETGENEngine.so", UseExisting=0)
4503 self.params = self.Hypothesis("NETGEN_Parameters", [],
4504 "libNETGENEngine.so", UseExisting=0)
4507 if self.algoType == GHS3D:
4508 self.params = self.Hypothesis("GHS3D_Parameters", [],
4509 "libGHS3DEngine.so", UseExisting=0)
4512 if self.algoType == GHS3DPRL:
4513 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4514 "libGHS3DPRLEngine.so", UseExisting=0)
4517 print "Algo supports no multi-parameter hypothesis"
4521 # Parameter of FULL_NETGEN
4522 # @ingroup l3_hypos_netgen
4523 def SetMaxSize(self, theSize):
4524 self.Parameters().SetMaxSize(theSize)
4526 ## Sets SecondOrder flag
4527 # Parameter of FULL_NETGEN
4528 # @ingroup l3_hypos_netgen
4529 def SetSecondOrder(self, theVal):
4530 self.Parameters().SetSecondOrder(theVal)
4532 ## Sets Optimize flag
4533 # Parameter of FULL_NETGEN
4534 # @ingroup l3_hypos_netgen
4535 def SetOptimize(self, theVal):
4536 self.Parameters().SetOptimize(theVal)
4539 # @param theFineness is:
4540 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4541 # Parameter of FULL_NETGEN
4542 # @ingroup l3_hypos_netgen
4543 def SetFineness(self, theFineness):
4544 self.Parameters().SetFineness(theFineness)
4547 # Parameter of FULL_NETGEN
4548 # @ingroup l3_hypos_netgen
4549 def SetGrowthRate(self, theRate):
4550 self.Parameters().SetGrowthRate(theRate)
4552 ## Sets NbSegPerEdge
4553 # Parameter of FULL_NETGEN
4554 # @ingroup l3_hypos_netgen
4555 def SetNbSegPerEdge(self, theVal):
4556 self.Parameters().SetNbSegPerEdge(theVal)
4558 ## Sets NbSegPerRadius
4559 # Parameter of FULL_NETGEN
4560 # @ingroup l3_hypos_netgen
4561 def SetNbSegPerRadius(self, theVal):
4562 self.Parameters().SetNbSegPerRadius(theVal)
4564 ## Sets number of segments overriding value set by SetLocalLength()
4565 # Only for algoType == NETGEN_FULL
4566 # @ingroup l3_hypos_netgen
4567 def SetNumberOfSegments(self, theVal):
4568 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4570 ## Sets number of segments overriding value set by SetNumberOfSegments()
4571 # Only for algoType == NETGEN_FULL
4572 # @ingroup l3_hypos_netgen
4573 def SetLocalLength(self, theVal):
4574 self.Parameters(SIMPLE).SetLocalLength(theVal)
4576 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4577 # Overrides value set by LengthFromEdges()
4578 # Only for algoType == NETGEN_FULL
4579 # @ingroup l3_hypos_netgen
4580 def MaxElementArea(self, area):
4581 self.Parameters(SIMPLE).SetMaxElementArea(area)
4583 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4584 # Overrides value set by MaxElementArea()
4585 # Only for algoType == NETGEN_FULL
4586 # @ingroup l3_hypos_netgen
4587 def LengthFromEdges(self):
4588 self.Parameters(SIMPLE).LengthFromEdges()
4590 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4591 # Overrides value set by MaxElementVolume()
4592 # Only for algoType == NETGEN_FULL
4593 # @ingroup l3_hypos_netgen
4594 def LengthFromFaces(self):
4595 self.Parameters(SIMPLE).LengthFromFaces()
4597 ## To mesh "holes" in a solid or not. Default is to mesh.
4598 # @ingroup l3_hypos_ghs3dh
4599 def SetToMeshHoles(self, toMesh):
4600 # Parameter of GHS3D
4601 self.Parameters().SetToMeshHoles(toMesh)
4603 ## Set Optimization level:
4604 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4605 # Strong_Optimization.
4606 # Default is Standard_Optimization
4607 # @ingroup l3_hypos_ghs3dh
4608 def SetOptimizationLevel(self, level):
4609 # Parameter of GHS3D
4610 self.Parameters().SetOptimizationLevel(level)
4612 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4613 # @ingroup l3_hypos_ghs3dh
4614 def SetMaximumMemory(self, MB):
4615 # Advanced parameter of GHS3D
4616 self.Parameters().SetMaximumMemory(MB)
4618 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4619 # automatic memory adjustment mode.
4620 # @ingroup l3_hypos_ghs3dh
4621 def SetInitialMemory(self, MB):
4622 # Advanced parameter of GHS3D
4623 self.Parameters().SetInitialMemory(MB)
4625 ## Path to working directory.
4626 # @ingroup l3_hypos_ghs3dh
4627 def SetWorkingDirectory(self, path):
4628 # Advanced parameter of GHS3D
4629 self.Parameters().SetWorkingDirectory(path)
4631 ## To keep working files or remove them. Log file remains in case of errors anyway.
4632 # @ingroup l3_hypos_ghs3dh
4633 def SetKeepFiles(self, toKeep):
4634 # Advanced parameter of GHS3D and GHS3DPRL
4635 self.Parameters().SetKeepFiles(toKeep)
4637 ## To set verbose level [0-10]. <ul>
4638 #<li> 0 - no standard output,
4639 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4640 # indicates when the final mesh is being saved. In addition the software
4641 # gives indication regarding the CPU time.
4642 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4643 # histogram of the skin mesh, quality statistics histogram together with
4644 # the characteristics of the final mesh.</ul>
4645 # @ingroup l3_hypos_ghs3dh
4646 def SetVerboseLevel(self, level):
4647 # Advanced parameter of GHS3D
4648 self.Parameters().SetVerboseLevel(level)
4650 ## To create new nodes.
4651 # @ingroup l3_hypos_ghs3dh
4652 def SetToCreateNewNodes(self, toCreate):
4653 # Advanced parameter of GHS3D
4654 self.Parameters().SetToCreateNewNodes(toCreate)
4656 ## To use boundary recovery version which tries to create mesh on a very poor
4657 # quality surface mesh.
4658 # @ingroup l3_hypos_ghs3dh
4659 def SetToUseBoundaryRecoveryVersion(self, toUse):
4660 # Advanced parameter of GHS3D
4661 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4663 ## Sets command line option as text.
4664 # @ingroup l3_hypos_ghs3dh
4665 def SetTextOption(self, option):
4666 # Advanced parameter of GHS3D
4667 self.Parameters().SetTextOption(option)
4669 ## Sets MED files name and path.
4670 def SetMEDName(self, value):
4671 self.Parameters().SetMEDName(value)
4673 ## Sets the number of partition of the initial mesh
4674 def SetNbPart(self, value):
4675 self.Parameters().SetNbPart(value)
4677 ## When big mesh, start tepal in background
4678 def SetBackground(self, value):
4679 self.Parameters().SetBackground(value)
4681 # Public class: Mesh_Hexahedron
4682 # ------------------------------
4684 ## Defines a hexahedron 3D algorithm
4686 # @ingroup l3_algos_basic
4687 class Mesh_Hexahedron(Mesh_Algorithm):
4692 ## Private constructor.
4693 def __init__(self, mesh, algoType=Hexa, geom=0):
4694 Mesh_Algorithm.__init__(self)
4696 self.algoType = algoType
4698 if algoType == Hexa:
4699 self.Create(mesh, geom, "Hexa_3D")
4702 elif algoType == Hexotic:
4703 CheckPlugin(Hexotic)
4704 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4707 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4708 # @ingroup l3_hypos_hexotic
4709 def MinMaxQuad(self, min=3, max=8, quad=True):
4710 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4712 self.params.SetHexesMinLevel(min)
4713 self.params.SetHexesMaxLevel(max)
4714 self.params.SetHexoticQuadrangles(quad)
4717 # Deprecated, only for compatibility!
4718 # Public class: Mesh_Netgen
4719 # ------------------------------
4721 ## Defines a NETGEN-based 2D or 3D algorithm
4722 # that needs no discrete boundary (i.e. independent)
4724 # This class is deprecated, only for compatibility!
4727 # @ingroup l3_algos_basic
4728 class Mesh_Netgen(Mesh_Algorithm):
4732 ## Private constructor.
4733 def __init__(self, mesh, is3D, geom=0):
4734 Mesh_Algorithm.__init__(self)
4740 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4744 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4747 ## Defines the hypothesis containing parameters of the algorithm
4748 def Parameters(self):
4750 hyp = self.Hypothesis("NETGEN_Parameters", [],
4751 "libNETGENEngine.so", UseExisting=0)
4753 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4754 "libNETGENEngine.so", UseExisting=0)
4757 # Public class: Mesh_Projection1D
4758 # ------------------------------
4760 ## Defines a projection 1D algorithm
4761 # @ingroup l3_algos_proj
4763 class Mesh_Projection1D(Mesh_Algorithm):
4765 ## Private constructor.
4766 def __init__(self, mesh, geom=0):
4767 Mesh_Algorithm.__init__(self)
4768 self.Create(mesh, geom, "Projection_1D")
4770 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4771 # a mesh pattern is taken, and, optionally, the association of vertices
4772 # between the source edge and a target edge (to which a hypothesis is assigned)
4773 # @param edge from which nodes distribution is taken
4774 # @param mesh from which nodes distribution is taken (optional)
4775 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4776 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4777 # to associate with \a srcV (optional)
4778 # @param UseExisting if ==true - searches for the existing hypothesis created with
4779 # the same parameters, else (default) - creates a new one
4780 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4781 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4783 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4784 hyp.SetSourceEdge( edge )
4785 if not mesh is None and isinstance(mesh, Mesh):
4786 mesh = mesh.GetMesh()
4787 hyp.SetSourceMesh( mesh )
4788 hyp.SetVertexAssociation( srcV, tgtV )
4791 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4792 #def CompareSourceEdge(self, hyp, args):
4793 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4797 # Public class: Mesh_Projection2D
4798 # ------------------------------
4800 ## Defines a projection 2D algorithm
4801 # @ingroup l3_algos_proj
4803 class Mesh_Projection2D(Mesh_Algorithm):
4805 ## Private constructor.
4806 def __init__(self, mesh, geom=0):
4807 Mesh_Algorithm.__init__(self)
4808 self.Create(mesh, geom, "Projection_2D")
4810 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4811 # a mesh pattern is taken, and, optionally, the association of vertices
4812 # between the source face and the target face (to which a hypothesis is assigned)
4813 # @param face from which the mesh pattern is taken
4814 # @param mesh from which the mesh pattern is taken (optional)
4815 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4816 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4817 # to associate with \a srcV1 (optional)
4818 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4819 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4820 # to associate with \a srcV2 (optional)
4821 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4822 # the same parameters, else (default) - forces the creation a new one
4824 # Note: all association vertices must belong to one edge of a face
4825 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4826 srcV2=None, tgtV2=None, UseExisting=0):
4827 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4829 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4830 hyp.SetSourceFace( face )
4831 if not mesh is None and isinstance(mesh, Mesh):
4832 mesh = mesh.GetMesh()
4833 hyp.SetSourceMesh( mesh )
4834 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4837 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4838 #def CompareSourceFace(self, hyp, args):
4839 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4842 # Public class: Mesh_Projection3D
4843 # ------------------------------
4845 ## Defines a projection 3D algorithm
4846 # @ingroup l3_algos_proj
4848 class Mesh_Projection3D(Mesh_Algorithm):
4850 ## Private constructor.
4851 def __init__(self, mesh, geom=0):
4852 Mesh_Algorithm.__init__(self)
4853 self.Create(mesh, geom, "Projection_3D")
4855 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4856 # the mesh pattern is taken, and, optionally, the association of vertices
4857 # between the source and the target solid (to which a hipothesis is assigned)
4858 # @param solid from where the mesh pattern is taken
4859 # @param mesh from where the mesh pattern is taken (optional)
4860 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4861 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4862 # to associate with \a srcV1 (optional)
4863 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4864 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4865 # to associate with \a srcV2 (optional)
4866 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4867 # the same parameters, else (default) - creates a new one
4869 # Note: association vertices must belong to one edge of a solid
4870 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4871 srcV2=0, tgtV2=0, UseExisting=0):
4872 hyp = self.Hypothesis("ProjectionSource3D",
4873 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4875 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4876 hyp.SetSource3DShape( solid )
4877 if not mesh is None and isinstance(mesh, Mesh):
4878 mesh = mesh.GetMesh()
4879 hyp.SetSourceMesh( mesh )
4880 if srcV1 and srcV2 and tgtV1 and tgtV2:
4881 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4882 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4885 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4886 #def CompareSourceShape3D(self, hyp, args):
4887 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4891 # Public class: Mesh_Prism
4892 # ------------------------
4894 ## Defines a 3D extrusion algorithm
4895 # @ingroup l3_algos_3dextr
4897 class Mesh_Prism3D(Mesh_Algorithm):
4899 ## Private constructor.
4900 def __init__(self, mesh, geom=0):
4901 Mesh_Algorithm.__init__(self)
4902 self.Create(mesh, geom, "Prism_3D")
4904 # Public class: Mesh_RadialPrism
4905 # -------------------------------
4907 ## Defines a Radial Prism 3D algorithm
4908 # @ingroup l3_algos_radialp
4910 class Mesh_RadialPrism3D(Mesh_Algorithm):
4912 ## Private constructor.
4913 def __init__(self, mesh, geom=0):
4914 Mesh_Algorithm.__init__(self)
4915 self.Create(mesh, geom, "RadialPrism_3D")
4917 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4918 self.nbLayers = None
4920 ## Return 3D hypothesis holding the 1D one
4921 def Get3DHypothesis(self):
4922 return self.distribHyp
4924 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4925 # hypothesis. Returns the created hypothesis
4926 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4927 #print "OwnHypothesis",hypType
4928 if not self.nbLayers is None:
4929 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4930 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4931 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4932 self.mesh.smeshpyD.SetCurrentStudy( None )
4933 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4934 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4935 self.distribHyp.SetLayerDistribution( hyp )
4938 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4939 # prisms to build between the inner and outer shells
4940 # @param n number of layers
4941 # @param UseExisting if ==true - searches for the existing hypothesis created with
4942 # the same parameters, else (default) - creates a new one
4943 def NumberOfLayers(self, n, UseExisting=0):
4944 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4945 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4946 CompareMethod=self.CompareNumberOfLayers)
4947 self.nbLayers.SetNumberOfLayers( n )
4948 return self.nbLayers
4950 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4951 def CompareNumberOfLayers(self, hyp, args):
4952 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4954 ## Defines "LocalLength" hypothesis, specifying the segment length
4955 # to build between the inner and the outer shells
4956 # @param l the length of segments
4957 # @param p the precision of rounding
4958 def LocalLength(self, l, p=1e-07):
4959 hyp = self.OwnHypothesis("LocalLength", [l,p])
4964 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4965 # prisms to build between the inner and the outer shells.
4966 # @param n the number of layers
4967 # @param s the scale factor (optional)
4968 def NumberOfSegments(self, n, s=[]):
4970 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4972 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4973 hyp.SetDistrType( 1 )
4974 hyp.SetScaleFactor(s)
4975 hyp.SetNumberOfSegments(n)
4978 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4979 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4980 # @param start the length of the first segment
4981 # @param end the length of the last segment
4982 def Arithmetic1D(self, start, end ):
4983 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4984 hyp.SetLength(start, 1)
4985 hyp.SetLength(end , 0)
4988 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4989 # to build between the inner and the outer shells as geometric length increasing
4990 # @param start for the length of the first segment
4991 # @param end for the length of the last segment
4992 def StartEndLength(self, start, end):
4993 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4994 hyp.SetLength(start, 1)
4995 hyp.SetLength(end , 0)
4998 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4999 # to build between the inner and outer shells
5000 # @param fineness defines the quality of the mesh within the range [0-1]
5001 def AutomaticLength(self, fineness=0):
5002 hyp = self.OwnHypothesis("AutomaticLength")
5003 hyp.SetFineness( fineness )
5006 # Public class: Mesh_RadialQuadrangle1D2D
5007 # -------------------------------
5009 ## Defines a Radial Quadrangle 1D2D algorithm
5010 # @ingroup l2_algos_radialq
5012 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5014 ## Private constructor.
5015 def __init__(self, mesh, geom=0):
5016 Mesh_Algorithm.__init__(self)
5017 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5019 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5020 self.nbLayers = None
5022 ## Return 2D hypothesis holding the 1D one
5023 def Get2DHypothesis(self):
5024 return self.distribHyp
5026 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5027 # hypothesis. Returns the created hypothesis
5028 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5029 #print "OwnHypothesis",hypType
5031 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5032 if self.distribHyp is None:
5033 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5035 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5036 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5037 self.mesh.smeshpyD.SetCurrentStudy( None )
5038 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5039 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5040 self.distribHyp.SetLayerDistribution( hyp )
5043 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5044 # @param n number of layers
5045 # @param UseExisting if ==true - searches for the existing hypothesis created with
5046 # the same parameters, else (default) - creates a new one
5047 def NumberOfLayers(self, n, UseExisting=0):
5049 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5050 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5051 CompareMethod=self.CompareNumberOfLayers)
5052 self.nbLayers.SetNumberOfLayers( n )
5053 return self.nbLayers
5055 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5056 def CompareNumberOfLayers(self, hyp, args):
5057 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5059 ## Defines "LocalLength" hypothesis, specifying the segment length
5060 # @param l the length of segments
5061 # @param p the precision of rounding
5062 def LocalLength(self, l, p=1e-07):
5063 hyp = self.OwnHypothesis("LocalLength", [l,p])
5068 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5069 # @param n the number of layers
5070 # @param s the scale factor (optional)
5071 def NumberOfSegments(self, n, s=[]):
5073 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5075 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5076 hyp.SetDistrType( 1 )
5077 hyp.SetScaleFactor(s)
5078 hyp.SetNumberOfSegments(n)
5081 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5082 # with a length that changes in arithmetic progression
5083 # @param start the length of the first segment
5084 # @param end the length of the last segment
5085 def Arithmetic1D(self, start, end ):
5086 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5087 hyp.SetLength(start, 1)
5088 hyp.SetLength(end , 0)
5091 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5092 # as geometric length increasing
5093 # @param start for the length of the first segment
5094 # @param end for the length of the last segment
5095 def StartEndLength(self, start, end):
5096 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5097 hyp.SetLength(start, 1)
5098 hyp.SetLength(end , 0)
5101 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5102 # @param fineness defines the quality of the mesh within the range [0-1]
5103 def AutomaticLength(self, fineness=0):
5104 hyp = self.OwnHypothesis("AutomaticLength")
5105 hyp.SetFineness( fineness )
5109 # Private class: Mesh_UseExisting
5110 # -------------------------------
5111 class Mesh_UseExisting(Mesh_Algorithm):
5113 def __init__(self, dim, mesh, geom=0):
5115 self.Create(mesh, geom, "UseExisting_1D")
5117 self.Create(mesh, geom, "UseExisting_2D")
5120 import salome_notebook
5121 notebook = salome_notebook.notebook
5123 ##Return values of the notebook variables
5124 def ParseParameters(last, nbParams,nbParam, value):
5128 listSize = len(last)
5129 for n in range(0,nbParams):
5131 if counter < listSize:
5132 strResult = strResult + last[counter]
5134 strResult = strResult + ""
5136 if isinstance(value, str):
5137 if notebook.isVariable(value):
5138 result = notebook.get(value)
5139 strResult=strResult+value
5141 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5143 strResult=strResult+str(value)
5145 if nbParams - 1 != counter:
5146 strResult=strResult+var_separator #":"
5148 return result, strResult
5150 #Wrapper class for StdMeshers_LocalLength hypothesis
5151 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5153 ## Set Length parameter value
5154 # @param length numerical value or name of variable from notebook
5155 def SetLength(self, length):
5156 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5157 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5158 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5160 ## Set Precision parameter value
5161 # @param precision numerical value or name of variable from notebook
5162 def SetPrecision(self, precision):
5163 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5164 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5165 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5167 #Registering the new proxy for LocalLength
5168 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5171 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5172 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5174 def SetLayerDistribution(self, hypo):
5175 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5176 hypo.ClearParameters();
5177 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5179 #Registering the new proxy for LayerDistribution
5180 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5182 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5183 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5185 ## Set Length parameter value
5186 # @param length numerical value or name of variable from notebook
5187 def SetLength(self, length):
5188 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5189 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5190 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5192 #Registering the new proxy for SegmentLengthAroundVertex
5193 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5196 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5197 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5199 ## Set Length parameter value
5200 # @param length numerical value or name of variable from notebook
5201 # @param isStart true is length is Start Length, otherwise false
5202 def SetLength(self, length, isStart):
5206 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5207 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5208 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5210 #Registering the new proxy for Arithmetic1D
5211 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5213 #Wrapper class for StdMeshers_Deflection1D hypothesis
5214 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5216 ## Set Deflection parameter value
5217 # @param deflection numerical value or name of variable from notebook
5218 def SetDeflection(self, deflection):
5219 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5220 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5221 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5223 #Registering the new proxy for Deflection1D
5224 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5226 #Wrapper class for StdMeshers_StartEndLength hypothesis
5227 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5229 ## Set Length parameter value
5230 # @param length numerical value or name of variable from notebook
5231 # @param isStart true is length is Start Length, otherwise false
5232 def SetLength(self, length, isStart):
5236 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5237 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5238 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5240 #Registering the new proxy for StartEndLength
5241 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5243 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5244 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5246 ## Set Max Element Area parameter value
5247 # @param area numerical value or name of variable from notebook
5248 def SetMaxElementArea(self, area):
5249 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5250 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5251 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5253 #Registering the new proxy for MaxElementArea
5254 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5257 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5258 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5260 ## Set Max Element Volume parameter value
5261 # @param volume numerical value or name of variable from notebook
5262 def SetMaxElementVolume(self, volume):
5263 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5264 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5265 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5267 #Registering the new proxy for MaxElementVolume
5268 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5271 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5272 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5274 ## Set Number Of Layers parameter value
5275 # @param nbLayers numerical value or name of variable from notebook
5276 def SetNumberOfLayers(self, nbLayers):
5277 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5278 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5279 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5281 #Registering the new proxy for NumberOfLayers
5282 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5284 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5285 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5287 ## Set Number Of Segments parameter value
5288 # @param nbSeg numerical value or name of variable from notebook
5289 def SetNumberOfSegments(self, nbSeg):
5290 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5291 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5292 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5293 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5295 ## Set Scale Factor parameter value
5296 # @param factor numerical value or name of variable from notebook
5297 def SetScaleFactor(self, factor):
5298 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5299 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5300 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5302 #Registering the new proxy for NumberOfSegments
5303 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5305 if not noNETGENPlugin:
5306 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5307 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5309 ## Set Max Size parameter value
5310 # @param maxsize numerical value or name of variable from notebook
5311 def SetMaxSize(self, maxsize):
5312 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5313 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5314 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5315 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5317 ## Set Growth Rate parameter value
5318 # @param value numerical value or name of variable from notebook
5319 def SetGrowthRate(self, value):
5320 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5321 value, parameters = ParseParameters(lastParameters,4,2,value)
5322 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5323 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5325 ## Set Number of Segments per Edge parameter value
5326 # @param value numerical value or name of variable from notebook
5327 def SetNbSegPerEdge(self, value):
5328 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5329 value, parameters = ParseParameters(lastParameters,4,3,value)
5330 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5331 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5333 ## Set Number of Segments per Radius parameter value
5334 # @param value numerical value or name of variable from notebook
5335 def SetNbSegPerRadius(self, value):
5336 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5337 value, parameters = ParseParameters(lastParameters,4,4,value)
5338 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5339 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5341 #Registering the new proxy for NETGENPlugin_Hypothesis
5342 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5345 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5346 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5349 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5350 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5352 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5353 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5355 ## Set Number of Segments parameter value
5356 # @param nbSeg numerical value or name of variable from notebook
5357 def SetNumberOfSegments(self, nbSeg):
5358 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5359 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5360 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5361 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5363 ## Set Local Length parameter value
5364 # @param length numerical value or name of variable from notebook
5365 def SetLocalLength(self, length):
5366 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5367 length, parameters = ParseParameters(lastParameters,2,1,length)
5368 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5369 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5371 ## Set Max Element Area parameter value
5372 # @param area numerical value or name of variable from notebook
5373 def SetMaxElementArea(self, area):
5374 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5375 area, parameters = ParseParameters(lastParameters,2,2,area)
5376 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5377 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5379 def LengthFromEdges(self):
5380 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5382 value, parameters = ParseParameters(lastParameters,2,2,value)
5383 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5384 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5386 #Registering the new proxy for NETGEN_SimpleParameters_2D
5387 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5390 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5391 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5392 ## Set Max Element Volume parameter value
5393 # @param volume numerical value or name of variable from notebook
5394 def SetMaxElementVolume(self, volume):
5395 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5396 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5397 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5398 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5400 def LengthFromFaces(self):
5401 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5403 value, parameters = ParseParameters(lastParameters,3,3,value)
5404 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5405 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5407 #Registering the new proxy for NETGEN_SimpleParameters_3D
5408 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5410 pass # if not noNETGENPlugin:
5412 class Pattern(SMESH._objref_SMESH_Pattern):
5414 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5416 if isinstance(theNodeIndexOnKeyPoint1,str):
5418 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5420 theNodeIndexOnKeyPoint1 -= 1
5421 theMesh.SetParameters(Parameters)
5422 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5424 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5427 if isinstance(theNode000Index,str):
5429 if isinstance(theNode001Index,str):
5431 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5433 theNode000Index -= 1
5435 theNode001Index -= 1
5436 theMesh.SetParameters(Parameters)
5437 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5439 #Registering the new proxy for Pattern
5440 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)