1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 ## Converts an angle from degrees to radians
203 def DegreesToRadians(AngleInDegrees):
205 return AngleInDegrees * pi / 180.0
207 # Salome notebook variable separator
210 # Parametrized substitute for PointStruct
211 class PointStructStr:
220 def __init__(self, xStr, yStr, zStr):
224 if isinstance(xStr, str) and notebook.isVariable(xStr):
225 self.x = notebook.get(xStr)
228 if isinstance(yStr, str) and notebook.isVariable(yStr):
229 self.y = notebook.get(yStr)
232 if isinstance(zStr, str) and notebook.isVariable(zStr):
233 self.z = notebook.get(zStr)
237 # Parametrized substitute for PointStruct (with 6 parameters)
238 class PointStructStr6:
253 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
260 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
261 self.x1 = notebook.get(x1Str)
264 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
265 self.x2 = notebook.get(x2Str)
268 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
269 self.y1 = notebook.get(y1Str)
272 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
273 self.y2 = notebook.get(y2Str)
276 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
277 self.z1 = notebook.get(z1Str)
280 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
281 self.z2 = notebook.get(z2Str)
285 # Parametrized substitute for AxisStruct
301 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
308 if isinstance(xStr, str) and notebook.isVariable(xStr):
309 self.x = notebook.get(xStr)
312 if isinstance(yStr, str) and notebook.isVariable(yStr):
313 self.y = notebook.get(yStr)
316 if isinstance(zStr, str) and notebook.isVariable(zStr):
317 self.z = notebook.get(zStr)
320 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
321 self.dx = notebook.get(dxStr)
324 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
325 self.dy = notebook.get(dyStr)
328 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
329 self.dz = notebook.get(dzStr)
333 # Parametrized substitute for DirStruct
336 def __init__(self, pointStruct):
337 self.pointStruct = pointStruct
339 # Returns list of variable values from salome notebook
340 def ParsePointStruct(Point):
341 Parameters = 2*var_separator
342 if isinstance(Point, PointStructStr):
343 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
344 Point = PointStruct(Point.x, Point.y, Point.z)
345 return Point, Parameters
347 # Returns list of variable values from salome notebook
348 def ParseDirStruct(Dir):
349 Parameters = 2*var_separator
350 if isinstance(Dir, DirStructStr):
351 pntStr = Dir.pointStruct
352 if isinstance(pntStr, PointStructStr6):
353 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
354 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
355 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
356 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
358 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
359 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
360 Dir = DirStruct(Point)
361 return Dir, Parameters
363 # Returns list of variable values from salome notebook
364 def ParseAxisStruct(Axis):
365 Parameters = 5*var_separator
366 if isinstance(Axis, AxisStructStr):
367 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
368 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
369 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
370 return Axis, Parameters
372 ## Return list of variable values from salome notebook
373 def ParseAngles(list):
376 for parameter in list:
377 if isinstance(parameter,str) and notebook.isVariable(parameter):
378 Result.append(DegreesToRadians(notebook.get(parameter)))
381 Result.append(parameter)
384 Parameters = Parameters + str(parameter)
385 Parameters = Parameters + var_separator
387 Parameters = Parameters[:len(Parameters)-1]
388 return Result, Parameters
390 def IsEqual(val1, val2, tol=PrecisionConfusion):
391 if abs(val1 - val2) < tol:
401 if isinstance(obj, SALOMEDS._objref_SObject):
404 ior = salome.orb.object_to_string(obj)
407 studies = salome.myStudyManager.GetOpenStudies()
408 for sname in studies:
409 s = salome.myStudyManager.GetStudyByName(sname)
411 sobj = s.FindObjectIOR(ior)
412 if not sobj: continue
413 return sobj.GetName()
414 if hasattr(obj, "GetName"):
415 # unknown CORBA object, having GetName() method
418 # unknown CORBA object, no GetName() method
421 if hasattr(obj, "GetName"):
422 # unknown non-CORBA object, having GetName() method
425 raise RuntimeError, "Null or invalid object"
427 ## Prints error message if a hypothesis was not assigned.
428 def TreatHypoStatus(status, hypName, geomName, isAlgo):
430 hypType = "algorithm"
432 hypType = "hypothesis"
434 if status == HYP_UNKNOWN_FATAL :
435 reason = "for unknown reason"
436 elif status == HYP_INCOMPATIBLE :
437 reason = "this hypothesis mismatches the algorithm"
438 elif status == HYP_NOTCONFORM :
439 reason = "a non-conform mesh would be built"
440 elif status == HYP_ALREADY_EXIST :
441 if isAlgo: return # it does not influence anything
442 reason = hypType + " of the same dimension is already assigned to this shape"
443 elif status == HYP_BAD_DIM :
444 reason = hypType + " mismatches the shape"
445 elif status == HYP_CONCURENT :
446 reason = "there are concurrent hypotheses on sub-shapes"
447 elif status == HYP_BAD_SUBSHAPE :
448 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
449 elif status == HYP_BAD_GEOMETRY:
450 reason = "geometry mismatches the expectation of the algorithm"
451 elif status == HYP_HIDDEN_ALGO:
452 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
453 elif status == HYP_HIDING_ALGO:
454 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
455 elif status == HYP_NEED_SHAPE:
456 reason = "Algorithm can't work without shape"
459 hypName = '"' + hypName + '"'
460 geomName= '"' + geomName+ '"'
461 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
462 print hypName, "was assigned to", geomName,"but", reason
463 elif not geomName == '""':
464 print hypName, "was not assigned to",geomName,":", reason
466 print hypName, "was not assigned:", reason
469 ## Check meshing plugin availability
470 def CheckPlugin(plugin):
471 if plugin == NETGEN and noNETGENPlugin:
472 print "Warning: NETGENPlugin module unavailable"
474 elif plugin == GHS3D and noGHS3DPlugin:
475 print "Warning: GHS3DPlugin module unavailable"
477 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
478 print "Warning: GHS3DPRLPlugin module unavailable"
480 elif plugin == Hexotic and noHexoticPlugin:
481 print "Warning: HexoticPlugin module unavailable"
483 elif plugin == BLSURF and noBLSURFPlugin:
484 print "Warning: BLSURFPlugin module unavailable"
488 # end of l1_auxiliary
491 # All methods of this class are accessible directly from the smesh.py package.
492 class smeshDC(SMESH._objref_SMESH_Gen):
494 ## Sets the current study and Geometry component
495 # @ingroup l1_auxiliary
496 def init_smesh(self,theStudy,geompyD):
497 self.SetCurrentStudy(theStudy,geompyD)
499 ## Creates an empty Mesh. This mesh can have an underlying geometry.
500 # @param obj the Geometrical object on which the mesh is built. If not defined,
501 # the mesh will have no underlying geometry.
502 # @param name the name for the new mesh.
503 # @return an instance of Mesh class.
504 # @ingroup l2_construct
505 def Mesh(self, obj=0, name=0):
506 if isinstance(obj,str):
508 return Mesh(self,self.geompyD,obj,name)
510 ## Returns a long value from enumeration
511 # Should be used for SMESH.FunctorType enumeration
512 # @ingroup l1_controls
513 def EnumToLong(self,theItem):
516 ## Gets PointStruct from vertex
517 # @param theVertex a GEOM object(vertex)
518 # @return SMESH.PointStruct
519 # @ingroup l1_auxiliary
520 def GetPointStruct(self,theVertex):
521 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
522 return PointStruct(x,y,z)
524 ## Gets DirStruct from vector
525 # @param theVector a GEOM object(vector)
526 # @return SMESH.DirStruct
527 # @ingroup l1_auxiliary
528 def GetDirStruct(self,theVector):
529 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
530 if(len(vertices) != 2):
531 print "Error: vector object is incorrect."
533 p1 = self.geompyD.PointCoordinates(vertices[0])
534 p2 = self.geompyD.PointCoordinates(vertices[1])
535 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
536 dirst = DirStruct(pnt)
539 ## Makes DirStruct from a triplet
540 # @param x,y,z vector components
541 # @return SMESH.DirStruct
542 # @ingroup l1_auxiliary
543 def MakeDirStruct(self,x,y,z):
544 pnt = PointStruct(x,y,z)
545 return DirStruct(pnt)
547 ## Get AxisStruct from object
548 # @param theObj a GEOM object (line or plane)
549 # @return SMESH.AxisStruct
550 # @ingroup l1_auxiliary
551 def GetAxisStruct(self,theObj):
552 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
554 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
555 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
556 vertex1 = self.geompyD.PointCoordinates(vertex1)
557 vertex2 = self.geompyD.PointCoordinates(vertex2)
558 vertex3 = self.geompyD.PointCoordinates(vertex3)
559 vertex4 = self.geompyD.PointCoordinates(vertex4)
560 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
561 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
562 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] ]
563 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
565 elif len(edges) == 1:
566 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
567 p1 = self.geompyD.PointCoordinates( vertex1 )
568 p2 = self.geompyD.PointCoordinates( vertex2 )
569 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
573 # From SMESH_Gen interface:
574 # ------------------------
576 ## Sets the given name to the object
577 # @param obj the object to rename
578 # @param name a new object name
579 # @ingroup l1_auxiliary
580 def SetName(self, obj, name):
581 if isinstance( obj, Mesh ):
583 elif isinstance( obj, Mesh_Algorithm ):
584 obj = obj.GetAlgorithm()
585 ior = salome.orb.object_to_string(obj)
586 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
588 ## Sets the current mode
589 # @ingroup l1_auxiliary
590 def SetEmbeddedMode( self,theMode ):
591 #self.SetEmbeddedMode(theMode)
592 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
594 ## Gets the current mode
595 # @ingroup l1_auxiliary
596 def IsEmbeddedMode(self):
597 #return self.IsEmbeddedMode()
598 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
600 ## Sets the current study
601 # @ingroup l1_auxiliary
602 def SetCurrentStudy( self, theStudy, geompyD = None ):
603 #self.SetCurrentStudy(theStudy)
606 geompyD = geompy.geom
609 self.SetGeomEngine(geompyD)
610 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
612 ## Gets the current study
613 # @ingroup l1_auxiliary
614 def GetCurrentStudy(self):
615 #return self.GetCurrentStudy()
616 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
618 ## Creates a Mesh object importing data from the given UNV file
619 # @return an instance of Mesh class
621 def CreateMeshesFromUNV( self,theFileName ):
622 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
623 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
626 ## Creates a Mesh object(s) importing data from the given MED file
627 # @return a list of Mesh class instances
629 def CreateMeshesFromMED( self,theFileName ):
630 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
632 for iMesh in range(len(aSmeshMeshes)) :
633 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
634 aMeshes.append(aMesh)
635 return aMeshes, aStatus
637 ## Creates a Mesh object importing data from the given STL file
638 # @return an instance of Mesh class
640 def CreateMeshesFromSTL( self, theFileName ):
641 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
642 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
645 ## From SMESH_Gen interface
646 # @return the list of integer values
647 # @ingroup l1_auxiliary
648 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
649 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
651 ## From SMESH_Gen interface. Creates a pattern
652 # @return an instance of SMESH_Pattern
654 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
655 # @ingroup l2_modif_patterns
656 def GetPattern(self):
657 return SMESH._objref_SMESH_Gen.GetPattern(self)
659 ## Sets number of segments per diagonal of boundary box of geometry by which
660 # default segment length of appropriate 1D hypotheses is defined.
661 # Default value is 10
662 # @ingroup l1_auxiliary
663 def SetBoundaryBoxSegmentation(self, nbSegments):
664 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
666 ## Concatenate the given meshes into one mesh.
667 # @return an instance of Mesh class
668 # @param meshes the meshes to combine into one mesh
669 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
670 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
671 # @param mergeTolerance tolerance for merging nodes
672 # @param allGroups forces creation of groups of all elements
673 def Concatenate( self, meshes, uniteIdenticalGroups,
674 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
675 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
677 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
678 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
680 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
681 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
682 aSmeshMesh.SetParameters(Parameters)
683 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
686 # Filtering. Auxiliary functions:
687 # ------------------------------
689 ## Creates an empty criterion
690 # @return SMESH.Filter.Criterion
691 # @ingroup l1_controls
692 def GetEmptyCriterion(self):
693 Type = self.EnumToLong(FT_Undefined)
694 Compare = self.EnumToLong(FT_Undefined)
698 UnaryOp = self.EnumToLong(FT_Undefined)
699 BinaryOp = self.EnumToLong(FT_Undefined)
702 Precision = -1 ##@1e-07
703 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
704 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
706 ## Creates a criterion by the given parameters
707 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
708 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
709 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
710 # @param Treshold the threshold value (range of ids as string, shape, numeric)
711 # @param UnaryOp FT_LogicalNOT or FT_Undefined
712 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
713 # FT_Undefined (must be for the last criterion of all criteria)
714 # @return SMESH.Filter.Criterion
715 # @ingroup l1_controls
716 def GetCriterion(self,elementType,
718 Compare = FT_EqualTo,
720 UnaryOp=FT_Undefined,
721 BinaryOp=FT_Undefined):
722 aCriterion = self.GetEmptyCriterion()
723 aCriterion.TypeOfElement = elementType
724 aCriterion.Type = self.EnumToLong(CritType)
728 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
729 aCriterion.Compare = self.EnumToLong(Compare)
730 elif Compare == "=" or Compare == "==":
731 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
733 aCriterion.Compare = self.EnumToLong(FT_LessThan)
735 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
737 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
740 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
741 FT_BelongToCylinder, FT_LyingOnGeom]:
742 # Checks the treshold
743 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
744 aCriterion.ThresholdStr = GetName(aTreshold)
745 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
747 print "Error: The treshold should be a shape."
749 elif CritType == FT_RangeOfIds:
750 # Checks the treshold
751 if isinstance(aTreshold, str):
752 aCriterion.ThresholdStr = aTreshold
754 print "Error: The treshold should be a string."
756 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
757 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
758 # At this point the treshold is unnecessary
759 if aTreshold == FT_LogicalNOT:
760 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
761 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
762 aCriterion.BinaryOp = aTreshold
766 aTreshold = float(aTreshold)
767 aCriterion.Threshold = aTreshold
769 print "Error: The treshold should be a number."
772 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
773 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
775 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
776 aCriterion.BinaryOp = self.EnumToLong(Treshold)
778 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
779 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
781 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
782 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
786 ## Creates a filter with the given parameters
787 # @param elementType the type of elements in the group
788 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
789 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
790 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
791 # @param UnaryOp FT_LogicalNOT or FT_Undefined
792 # @return SMESH_Filter
793 # @ingroup l1_controls
794 def GetFilter(self,elementType,
795 CritType=FT_Undefined,
798 UnaryOp=FT_Undefined):
799 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
800 aFilterMgr = self.CreateFilterManager()
801 aFilter = aFilterMgr.CreateFilter()
803 aCriteria.append(aCriterion)
804 aFilter.SetCriteria(aCriteria)
807 ## Creates a numerical functor by its type
808 # @param theCriterion FT_...; functor type
809 # @return SMESH_NumericalFunctor
810 # @ingroup l1_controls
811 def GetFunctor(self,theCriterion):
812 aFilterMgr = self.CreateFilterManager()
813 if theCriterion == FT_AspectRatio:
814 return aFilterMgr.CreateAspectRatio()
815 elif theCriterion == FT_AspectRatio3D:
816 return aFilterMgr.CreateAspectRatio3D()
817 elif theCriterion == FT_Warping:
818 return aFilterMgr.CreateWarping()
819 elif theCriterion == FT_MinimumAngle:
820 return aFilterMgr.CreateMinimumAngle()
821 elif theCriterion == FT_Taper:
822 return aFilterMgr.CreateTaper()
823 elif theCriterion == FT_Skew:
824 return aFilterMgr.CreateSkew()
825 elif theCriterion == FT_Area:
826 return aFilterMgr.CreateArea()
827 elif theCriterion == FT_Volume3D:
828 return aFilterMgr.CreateVolume3D()
829 elif theCriterion == FT_MultiConnection:
830 return aFilterMgr.CreateMultiConnection()
831 elif theCriterion == FT_MultiConnection2D:
832 return aFilterMgr.CreateMultiConnection2D()
833 elif theCriterion == FT_Length:
834 return aFilterMgr.CreateLength()
835 elif theCriterion == FT_Length2D:
836 return aFilterMgr.CreateLength2D()
838 print "Error: given parameter is not numerucal functor type."
840 ## Creates hypothesis
841 # @param theHType mesh hypothesis type (string)
842 # @param theLibName mesh plug-in library name
843 # @return created hypothesis instance
844 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
845 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
847 ## Gets the mesh stattistic
848 # @return dictionary type element - count of elements
849 # @ingroup l1_meshinfo
850 def GetMeshInfo(self, obj):
851 if isinstance( obj, Mesh ):
854 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
855 values = obj.GetMeshInfo()
856 for i in range(SMESH.Entity_Last._v):
857 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
862 #Registering the new proxy for SMESH_Gen
863 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
869 ## This class allows defining and managing a mesh.
870 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
871 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
872 # new nodes and elements and by changing the existing entities), to get information
873 # about a mesh and to export a mesh into different formats.
882 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
883 # sets the GUI name of this mesh to \a name.
884 # @param smeshpyD an instance of smeshDC class
885 # @param geompyD an instance of geompyDC class
886 # @param obj Shape to be meshed or SMESH_Mesh object
887 # @param name Study name of the mesh
888 # @ingroup l2_construct
889 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
890 self.smeshpyD=smeshpyD
895 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
897 self.mesh = self.smeshpyD.CreateMesh(self.geom)
898 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
901 self.mesh = self.smeshpyD.CreateEmptyMesh()
903 self.smeshpyD.SetName(self.mesh, name)
905 self.smeshpyD.SetName(self.mesh, GetName(obj))
908 self.geom = self.mesh.GetShapeToMesh()
910 self.editor = self.mesh.GetMeshEditor()
912 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
913 # @param theMesh a SMESH_Mesh object
914 # @ingroup l2_construct
915 def SetMesh(self, theMesh):
917 self.geom = self.mesh.GetShapeToMesh()
919 ## Returns the mesh, that is an instance of SMESH_Mesh interface
920 # @return a SMESH_Mesh object
921 # @ingroup l2_construct
925 ## Gets the name of the mesh
926 # @return the name of the mesh as a string
927 # @ingroup l2_construct
929 name = GetName(self.GetMesh())
932 ## Sets a name to the mesh
933 # @param name a new name of the mesh
934 # @ingroup l2_construct
935 def SetName(self, name):
936 self.smeshpyD.SetName(self.GetMesh(), name)
938 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
939 # The subMesh object gives access to the IDs of nodes and elements.
940 # @param theSubObject a geometrical object (shape)
941 # @param theName a name for the submesh
942 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
943 # @ingroup l2_submeshes
944 def GetSubMesh(self, theSubObject, theName):
945 submesh = self.mesh.GetSubMesh(theSubObject, theName)
948 ## Returns the shape associated to the mesh
949 # @return a GEOM_Object
950 # @ingroup l2_construct
954 ## Associates the given shape to the mesh (entails the recreation of the mesh)
955 # @param geom the shape to be meshed (GEOM_Object)
956 # @ingroup l2_construct
957 def SetShape(self, geom):
958 self.mesh = self.smeshpyD.CreateMesh(geom)
960 ## Returns true if the hypotheses are defined well
961 # @param theSubObject a subshape of a mesh shape
962 # @return True or False
963 # @ingroup l2_construct
964 def IsReadyToCompute(self, theSubObject):
965 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
967 ## Returns errors of hypotheses definition.
968 # The list of errors is empty if everything is OK.
969 # @param theSubObject a subshape of a mesh shape
970 # @return a list of errors
971 # @ingroup l2_construct
972 def GetAlgoState(self, theSubObject):
973 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
975 ## Returns a geometrical object on which the given element was built.
976 # The returned geometrical object, if not nil, is either found in the
977 # study or published by this method with the given name
978 # @param theElementID the id of the mesh element
979 # @param theGeomName the user-defined name of the geometrical object
980 # @return GEOM::GEOM_Object instance
981 # @ingroup l2_construct
982 def GetGeometryByMeshElement(self, theElementID, theGeomName):
983 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
985 ## Returns the mesh dimension depending on the dimension of the underlying shape
986 # @return mesh dimension as an integer value [0,3]
987 # @ingroup l1_auxiliary
988 def MeshDimension(self):
989 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
990 if len( shells ) > 0 :
992 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
994 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1000 ## Creates a segment discretization 1D algorithm.
1001 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1002 # \n If the optional \a geom parameter is not set, this algorithm is global.
1003 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1004 # @param algo the type of the required algorithm. Possible values are:
1006 # - smesh.PYTHON for discretization via a python function,
1007 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1008 # @param geom If defined is the subshape to be meshed
1009 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1010 # @ingroup l3_algos_basic
1011 def Segment(self, algo=REGULAR, geom=0):
1012 ## if Segment(geom) is called by mistake
1013 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1014 algo, geom = geom, algo
1015 if not algo: algo = REGULAR
1018 return Mesh_Segment(self, geom)
1019 elif algo == PYTHON:
1020 return Mesh_Segment_Python(self, geom)
1021 elif algo == COMPOSITE:
1022 return Mesh_CompositeSegment(self, geom)
1024 return Mesh_Segment(self, geom)
1026 ## Enables creation of nodes and segments usable by 2D algoritms.
1027 # The added nodes and segments must be bound to edges and vertices by
1028 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1029 # If the optional \a geom parameter is not set, this algorithm is global.
1030 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1031 # @param geom the subshape to be manually meshed
1032 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1033 # @ingroup l3_algos_basic
1034 def UseExistingSegments(self, geom=0):
1035 algo = Mesh_UseExisting(1,self,geom)
1036 return algo.GetAlgorithm()
1038 ## Enables creation of nodes and faces usable by 3D algoritms.
1039 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1040 # and SetMeshElementOnShape()
1041 # If the optional \a geom parameter is not set, this algorithm is global.
1042 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1043 # @param geom the subshape to be manually meshed
1044 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1045 # @ingroup l3_algos_basic
1046 def UseExistingFaces(self, geom=0):
1047 algo = Mesh_UseExisting(2,self,geom)
1048 return algo.GetAlgorithm()
1050 ## Creates a triangle 2D algorithm for faces.
1051 # If the optional \a geom parameter is not set, this algorithm is global.
1052 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1053 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1054 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1055 # @return an instance of Mesh_Triangle algorithm
1056 # @ingroup l3_algos_basic
1057 def Triangle(self, algo=MEFISTO, geom=0):
1058 ## if Triangle(geom) is called by mistake
1059 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1062 return Mesh_Triangle(self, algo, geom)
1064 ## Creates a quadrangle 2D algorithm for faces.
1065 # If the optional \a geom parameter is not set, this algorithm is global.
1066 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1067 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1068 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1069 # @return an instance of Mesh_Quadrangle algorithm
1070 # @ingroup l3_algos_basic
1071 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1072 if algo==RADIAL_QUAD:
1073 return Mesh_RadialQuadrangle1D2D(self,geom)
1075 return Mesh_Quadrangle(self, geom)
1077 ## Creates a tetrahedron 3D algorithm for solids.
1078 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1079 # If the optional \a geom parameter is not set, this algorithm is global.
1080 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1081 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1082 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1083 # @return an instance of Mesh_Tetrahedron algorithm
1084 # @ingroup l3_algos_basic
1085 def Tetrahedron(self, algo=NETGEN, geom=0):
1086 ## if Tetrahedron(geom) is called by mistake
1087 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1088 algo, geom = geom, algo
1089 if not algo: algo = NETGEN
1091 return Mesh_Tetrahedron(self, algo, geom)
1093 ## Creates a hexahedron 3D algorithm for solids.
1094 # If the optional \a geom parameter is not set, this algorithm is global.
1095 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1096 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1097 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1098 # @return an instance of Mesh_Hexahedron algorithm
1099 # @ingroup l3_algos_basic
1100 def Hexahedron(self, algo=Hexa, geom=0):
1101 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1102 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1103 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1104 elif geom == 0: algo, geom = Hexa, algo
1105 return Mesh_Hexahedron(self, algo, geom)
1107 ## Deprecated, used only for compatibility!
1108 # @return an instance of Mesh_Netgen algorithm
1109 # @ingroup l3_algos_basic
1110 def Netgen(self, is3D, geom=0):
1111 return Mesh_Netgen(self, is3D, geom)
1113 ## Creates a projection 1D algorithm for edges.
1114 # If the optional \a geom parameter is not set, this algorithm is global.
1115 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1116 # @param geom If defined, the subshape to be meshed
1117 # @return an instance of Mesh_Projection1D algorithm
1118 # @ingroup l3_algos_proj
1119 def Projection1D(self, geom=0):
1120 return Mesh_Projection1D(self, geom)
1122 ## Creates a projection 2D algorithm for faces.
1123 # If the optional \a geom parameter is not set, this algorithm is global.
1124 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1125 # @param geom If defined, the subshape to be meshed
1126 # @return an instance of Mesh_Projection2D algorithm
1127 # @ingroup l3_algos_proj
1128 def Projection2D(self, geom=0):
1129 return Mesh_Projection2D(self, geom)
1131 ## Creates a projection 3D algorithm for solids.
1132 # If the optional \a geom parameter is not set, this algorithm is global.
1133 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1134 # @param geom If defined, the subshape to be meshed
1135 # @return an instance of Mesh_Projection3D algorithm
1136 # @ingroup l3_algos_proj
1137 def Projection3D(self, geom=0):
1138 return Mesh_Projection3D(self, geom)
1140 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1141 # If the optional \a geom parameter is not set, this algorithm is global.
1142 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1143 # @param geom If defined, the subshape to be meshed
1144 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1145 # @ingroup l3_algos_radialp l3_algos_3dextr
1146 def Prism(self, geom=0):
1150 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1151 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1152 if nbSolids == 0 or nbSolids == nbShells:
1153 return Mesh_Prism3D(self, geom)
1154 return Mesh_RadialPrism3D(self, geom)
1156 ## Evaluates size of prospective mesh on a shape
1157 # @return True or False
1158 def Evaluate(self, geom=0):
1159 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1161 geom = self.mesh.GetShapeToMesh()
1164 return self.smeshpyD.Evaluate(self.mesh, geom)
1167 ## Computes the mesh and returns the status of the computation
1168 # @param discardModifs if True and the mesh has been edited since
1169 # a last total re-compute and that may prevent successful partial re-compute,
1170 # then the mesh is cleaned before Compute()
1171 # @return True or False
1172 # @ingroup l2_construct
1173 def Compute(self, geom=0, discardModifs=False):
1174 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1176 geom = self.mesh.GetShapeToMesh()
1181 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1183 ok = self.smeshpyD.Compute(self.mesh, geom)
1184 except SALOME.SALOME_Exception, ex:
1185 print "Mesh computation failed, exception caught:"
1186 print " ", ex.details.text
1189 print "Mesh computation failed, exception caught:"
1190 traceback.print_exc()
1194 # Treat compute errors
1195 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1196 for err in computeErrors:
1198 if self.mesh.HasShapeToMesh():
1200 mainIOR = salome.orb.object_to_string(geom)
1201 for sname in salome.myStudyManager.GetOpenStudies():
1202 s = salome.myStudyManager.GetStudyByName(sname)
1204 mainSO = s.FindObjectIOR(mainIOR)
1205 if not mainSO: continue
1206 if err.subShapeID == 1:
1207 shapeText = ' on "%s"' % mainSO.GetName()
1208 subIt = s.NewChildIterator(mainSO)
1210 subSO = subIt.Value()
1212 obj = subSO.GetObject()
1213 if not obj: continue
1214 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1216 ids = go.GetSubShapeIndices()
1217 if len(ids) == 1 and ids[0] == err.subShapeID:
1218 shapeText = ' on "%s"' % subSO.GetName()
1221 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1223 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1225 shapeText = " on subshape #%s" % (err.subShapeID)
1227 shapeText = " on subshape #%s" % (err.subShapeID)
1229 stdErrors = ["OK", #COMPERR_OK
1230 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1231 "std::exception", #COMPERR_STD_EXCEPTION
1232 "OCC exception", #COMPERR_OCC_EXCEPTION
1233 "SALOME exception", #COMPERR_SLM_EXCEPTION
1234 "Unknown exception", #COMPERR_EXCEPTION
1235 "Memory allocation problem", #COMPERR_MEMORY_PB
1236 "Algorithm failed", #COMPERR_ALGO_FAILED
1237 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1239 if err.code < len(stdErrors): errText = stdErrors[err.code]
1241 errText = "code %s" % -err.code
1242 if errText: errText += ". "
1243 errText += err.comment
1244 if allReasons != "":allReasons += "\n"
1245 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1249 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1251 if err.isGlobalAlgo:
1259 reason = '%s %sD algorithm is missing' % (glob, dim)
1260 elif err.state == HYP_MISSING:
1261 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1262 % (glob, dim, name, dim))
1263 elif err.state == HYP_NOTCONFORM:
1264 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1265 elif err.state == HYP_BAD_PARAMETER:
1266 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1267 % ( glob, dim, name ))
1268 elif err.state == HYP_BAD_GEOMETRY:
1269 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1270 'geometry' % ( glob, dim, name ))
1272 reason = "For unknown reason."+\
1273 " Revise Mesh.Compute() implementation in smeshDC.py!"
1275 if allReasons != "":allReasons += "\n"
1276 allReasons += reason
1278 if allReasons != "":
1279 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1283 print '"' + GetName(self.mesh) + '"',"has not been computed."
1286 if salome.sg.hasDesktop():
1287 smeshgui = salome.ImportComponentGUI("SMESH")
1288 smeshgui.Init(self.mesh.GetStudyId())
1289 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1290 salome.sg.updateObjBrowser(1)
1294 ## Return submesh objects list in meshing order
1295 # @return list of list of submesh objects
1296 # @ingroup l2_construct
1297 def GetMeshOrder(self):
1298 return self.mesh.GetMeshOrder()
1300 ## Return submesh objects list in meshing order
1301 # @return list of list of submesh objects
1302 # @ingroup l2_construct
1303 def SetMeshOrder(self, submeshes):
1304 return self.mesh.SetMeshOrder(submeshes)
1306 ## Removes all nodes and elements
1307 # @ingroup l2_construct
1310 if salome.sg.hasDesktop():
1311 smeshgui = salome.ImportComponentGUI("SMESH")
1312 smeshgui.Init(self.mesh.GetStudyId())
1313 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1314 salome.sg.updateObjBrowser(1)
1316 ## Removes all nodes and elements of indicated shape
1317 # @ingroup l2_construct
1318 def ClearSubMesh(self, geomId):
1319 self.mesh.ClearSubMesh(geomId)
1320 if salome.sg.hasDesktop():
1321 smeshgui = salome.ImportComponentGUI("SMESH")
1322 smeshgui.Init(self.mesh.GetStudyId())
1323 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1324 salome.sg.updateObjBrowser(1)
1326 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1327 # @param fineness [0,-1] defines mesh fineness
1328 # @return True or False
1329 # @ingroup l3_algos_basic
1330 def AutomaticTetrahedralization(self, fineness=0):
1331 dim = self.MeshDimension()
1333 self.RemoveGlobalHypotheses()
1334 self.Segment().AutomaticLength(fineness)
1336 self.Triangle().LengthFromEdges()
1339 self.Tetrahedron(NETGEN)
1341 return self.Compute()
1343 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1344 # @param fineness [0,-1] defines mesh fineness
1345 # @return True or False
1346 # @ingroup l3_algos_basic
1347 def AutomaticHexahedralization(self, fineness=0):
1348 dim = self.MeshDimension()
1349 # assign the hypotheses
1350 self.RemoveGlobalHypotheses()
1351 self.Segment().AutomaticLength(fineness)
1358 return self.Compute()
1360 ## Assigns a hypothesis
1361 # @param hyp a hypothesis to assign
1362 # @param geom a subhape of mesh geometry
1363 # @return SMESH.Hypothesis_Status
1364 # @ingroup l2_hypotheses
1365 def AddHypothesis(self, hyp, geom=0):
1366 if isinstance( hyp, Mesh_Algorithm ):
1367 hyp = hyp.GetAlgorithm()
1372 geom = self.mesh.GetShapeToMesh()
1374 status = self.mesh.AddHypothesis(geom, hyp)
1375 isAlgo = hyp._narrow( SMESH_Algo )
1376 hyp_name = GetName( hyp )
1379 geom_name = GetName( geom )
1380 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1383 ## Unassigns a hypothesis
1384 # @param hyp a hypothesis to unassign
1385 # @param geom a subshape of mesh geometry
1386 # @return SMESH.Hypothesis_Status
1387 # @ingroup l2_hypotheses
1388 def RemoveHypothesis(self, hyp, geom=0):
1389 if isinstance( hyp, Mesh_Algorithm ):
1390 hyp = hyp.GetAlgorithm()
1395 status = self.mesh.RemoveHypothesis(geom, hyp)
1398 ## Gets the list of hypotheses added on a geometry
1399 # @param geom a subshape of mesh geometry
1400 # @return the sequence of SMESH_Hypothesis
1401 # @ingroup l2_hypotheses
1402 def GetHypothesisList(self, geom):
1403 return self.mesh.GetHypothesisList( geom )
1405 ## Removes all global hypotheses
1406 # @ingroup l2_hypotheses
1407 def RemoveGlobalHypotheses(self):
1408 current_hyps = self.mesh.GetHypothesisList( self.geom )
1409 for hyp in current_hyps:
1410 self.mesh.RemoveHypothesis( self.geom, hyp )
1414 ## Creates a mesh group based on the geometric object \a grp
1415 # and gives a \a name, \n if this parameter is not defined
1416 # the name is the same as the geometric group name \n
1417 # Note: Works like GroupOnGeom().
1418 # @param grp a geometric group, a vertex, an edge, a face or a solid
1419 # @param name the name of the mesh group
1420 # @return SMESH_GroupOnGeom
1421 # @ingroup l2_grps_create
1422 def Group(self, grp, name=""):
1423 return self.GroupOnGeom(grp, name)
1425 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1426 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1427 # @param f the file name
1428 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1429 # @param opt boolean parameter for creating/not creating
1430 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1431 # @ingroup l2_impexp
1432 def ExportToMED(self, f, version, opt=0):
1433 self.mesh.ExportToMED(f, opt, version)
1435 ## Exports the mesh in a file in MED format
1436 # @param f is the file name
1437 # @param auto_groups boolean parameter for creating/not creating
1438 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1439 # the typical use is auto_groups=false.
1440 # @param version MED format version(MED_V2_1 or MED_V2_2)
1441 # @ingroup l2_impexp
1442 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1443 self.mesh.ExportToMED(f, auto_groups, version)
1445 ## Exports the mesh in a file in DAT format
1446 # @param f the file name
1447 # @ingroup l2_impexp
1448 def ExportDAT(self, f):
1449 self.mesh.ExportDAT(f)
1451 ## Exports the mesh in a file in UNV format
1452 # @param f the file name
1453 # @ingroup l2_impexp
1454 def ExportUNV(self, f):
1455 self.mesh.ExportUNV(f)
1457 ## Export the mesh in a file in STL format
1458 # @param f the file name
1459 # @param ascii defines the file encoding
1460 # @ingroup l2_impexp
1461 def ExportSTL(self, f, ascii=1):
1462 self.mesh.ExportSTL(f, ascii)
1465 # Operations with groups:
1466 # ----------------------
1468 ## Creates an empty mesh group
1469 # @param elementType the type of elements in the group
1470 # @param name the name of the mesh group
1471 # @return SMESH_Group
1472 # @ingroup l2_grps_create
1473 def CreateEmptyGroup(self, elementType, name):
1474 return self.mesh.CreateGroup(elementType, name)
1476 ## Creates a mesh group based on the geometrical object \a grp
1477 # and gives a \a name, \n if this parameter is not defined
1478 # the name is the same as the geometrical group name
1479 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1480 # @param name the name of the mesh group
1481 # @param typ the type of elements in the group. If not set, it is
1482 # automatically detected by the type of the geometry
1483 # @return SMESH_GroupOnGeom
1484 # @ingroup l2_grps_create
1485 def GroupOnGeom(self, grp, name="", typ=None):
1487 name = grp.GetName()
1490 tgeo = str(grp.GetShapeType())
1491 if tgeo == "VERTEX":
1493 elif tgeo == "EDGE":
1495 elif tgeo == "FACE":
1497 elif tgeo == "SOLID":
1499 elif tgeo == "SHELL":
1501 elif tgeo == "COMPOUND":
1502 try: # it raises on a compound of compounds
1503 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1504 print "Mesh.Group: empty geometric group", GetName( grp )
1509 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1511 tgeo = self.geompyD.GetType(grp)
1512 if tgeo == geompyDC.ShapeType["VERTEX"]:
1514 elif tgeo == geompyDC.ShapeType["EDGE"]:
1516 elif tgeo == geompyDC.ShapeType["FACE"]:
1518 elif tgeo == geompyDC.ShapeType["SOLID"]:
1524 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1525 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1526 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1534 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1537 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1539 ## Creates a mesh group by the given ids of elements
1540 # @param groupName the name of the mesh group
1541 # @param elementType the type of elements in the group
1542 # @param elemIDs the list of ids
1543 # @return SMESH_Group
1544 # @ingroup l2_grps_create
1545 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1546 group = self.mesh.CreateGroup(elementType, groupName)
1550 ## Creates a mesh group by the given conditions
1551 # @param groupName the name of the mesh group
1552 # @param elementType the type of elements in the group
1553 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1554 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1555 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1556 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1557 # @return SMESH_Group
1558 # @ingroup l2_grps_create
1562 CritType=FT_Undefined,
1565 UnaryOp=FT_Undefined):
1566 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1567 group = self.MakeGroupByCriterion(groupName, aCriterion)
1570 ## Creates a mesh group by the given criterion
1571 # @param groupName the name of the mesh group
1572 # @param Criterion the instance of Criterion class
1573 # @return SMESH_Group
1574 # @ingroup l2_grps_create
1575 def MakeGroupByCriterion(self, groupName, Criterion):
1576 aFilterMgr = self.smeshpyD.CreateFilterManager()
1577 aFilter = aFilterMgr.CreateFilter()
1579 aCriteria.append(Criterion)
1580 aFilter.SetCriteria(aCriteria)
1581 group = self.MakeGroupByFilter(groupName, aFilter)
1584 ## Creates a mesh group by the given criteria (list of criteria)
1585 # @param groupName the name of the mesh group
1586 # @param theCriteria the list of criteria
1587 # @return SMESH_Group
1588 # @ingroup l2_grps_create
1589 def MakeGroupByCriteria(self, groupName, theCriteria):
1590 aFilterMgr = self.smeshpyD.CreateFilterManager()
1591 aFilter = aFilterMgr.CreateFilter()
1592 aFilter.SetCriteria(theCriteria)
1593 group = self.MakeGroupByFilter(groupName, aFilter)
1596 ## Creates a mesh group by the given filter
1597 # @param groupName the name of the mesh group
1598 # @param theFilter the instance of Filter class
1599 # @return SMESH_Group
1600 # @ingroup l2_grps_create
1601 def MakeGroupByFilter(self, groupName, theFilter):
1602 anIds = theFilter.GetElementsId(self.mesh)
1603 anElemType = theFilter.GetElementType()
1604 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1607 ## Passes mesh elements through the given filter and return IDs of fitting elements
1608 # @param theFilter SMESH_Filter
1609 # @return a list of ids
1610 # @ingroup l1_controls
1611 def GetIdsFromFilter(self, theFilter):
1612 return theFilter.GetElementsId(self.mesh)
1614 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1615 # Returns a list of special structures (borders).
1616 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1617 # @ingroup l1_controls
1618 def GetFreeBorders(self):
1619 aFilterMgr = self.smeshpyD.CreateFilterManager()
1620 aPredicate = aFilterMgr.CreateFreeEdges()
1621 aPredicate.SetMesh(self.mesh)
1622 aBorders = aPredicate.GetBorders()
1626 # @ingroup l2_grps_delete
1627 def RemoveGroup(self, group):
1628 self.mesh.RemoveGroup(group)
1630 ## Removes a group with its contents
1631 # @ingroup l2_grps_delete
1632 def RemoveGroupWithContents(self, group):
1633 self.mesh.RemoveGroupWithContents(group)
1635 ## Gets the list of groups existing in the mesh
1636 # @return a sequence of SMESH_GroupBase
1637 # @ingroup l2_grps_create
1638 def GetGroups(self):
1639 return self.mesh.GetGroups()
1641 ## Gets the number of groups existing in the mesh
1642 # @return the quantity of groups as an integer value
1643 # @ingroup l2_grps_create
1645 return self.mesh.NbGroups()
1647 ## Gets the list of names of groups existing in the mesh
1648 # @return list of strings
1649 # @ingroup l2_grps_create
1650 def GetGroupNames(self):
1651 groups = self.GetGroups()
1653 for group in groups:
1654 names.append(group.GetName())
1657 ## Produces a union of two groups
1658 # A new group is created. All mesh elements that are
1659 # present in the initial groups are added to the new one
1660 # @return an instance of SMESH_Group
1661 # @ingroup l2_grps_operon
1662 def UnionGroups(self, group1, group2, name):
1663 return self.mesh.UnionGroups(group1, group2, name)
1665 ## Produces a union list of groups
1666 # New group is created. All mesh elements that are present in
1667 # initial groups are added to the new one
1668 # @return an instance of SMESH_Group
1669 # @ingroup l2_grps_operon
1670 def UnionListOfGroups(self, groups, name):
1671 return self.mesh.UnionListOfGroups(groups, name)
1673 ## Prodices an intersection of two groups
1674 # A new group is created. All mesh elements that are common
1675 # for the two initial groups are added to the new one.
1676 # @return an instance of SMESH_Group
1677 # @ingroup l2_grps_operon
1678 def IntersectGroups(self, group1, group2, name):
1679 return self.mesh.IntersectGroups(group1, group2, name)
1681 ## Produces an intersection of groups
1682 # New group is created. All mesh elements that are present in all
1683 # initial groups simultaneously are added to the new one
1684 # @return an instance of SMESH_Group
1685 # @ingroup l2_grps_operon
1686 def IntersectListOfGroups(self, groups, name):
1687 return self.mesh.IntersectListOfGroups(groups, name)
1689 ## Produces a cut of two groups
1690 # A new group is created. All mesh elements that are present in
1691 # the main group but are not present in the tool group are added to the new one
1692 # @return an instance of SMESH_Group
1693 # @ingroup l2_grps_operon
1694 def CutGroups(self, main_group, tool_group, name):
1695 return self.mesh.CutGroups(main_group, tool_group, name)
1697 ## Produces a cut of groups
1698 # A new group is created. All mesh elements that are present in main groups
1699 # but do not present in tool groups are added to the new one
1700 # @return an instance of SMESH_Group
1701 # @ingroup l2_grps_operon
1702 def CutListOfGroups(self, main_groups, tool_groups, name):
1703 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1705 ## Produces a group of elements with specified element type using list of existing groups
1706 # A new group is created. System
1707 # 1) extract all nodes on which groups elements are built
1708 # 2) combine all elements of specified dimension laying on these nodes
1709 # @return an instance of SMESH_Group
1710 # @ingroup l2_grps_operon
1711 def CreateDimGroup(self, groups, elem_type, name):
1712 return self.mesh.CreateDimGroup(groups, elem_type, name)
1715 ## Convert group on geom into standalone group
1716 # @ingroup l2_grps_delete
1717 def ConvertToStandalone(self, group):
1718 return self.mesh.ConvertToStandalone(group)
1720 # Get some info about mesh:
1721 # ------------------------
1723 ## Returns the log of nodes and elements added or removed
1724 # since the previous clear of the log.
1725 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1726 # @return list of log_block structures:
1731 # @ingroup l1_auxiliary
1732 def GetLog(self, clearAfterGet):
1733 return self.mesh.GetLog(clearAfterGet)
1735 ## Clears the log of nodes and elements added or removed since the previous
1736 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1737 # @ingroup l1_auxiliary
1739 self.mesh.ClearLog()
1741 ## Toggles auto color mode on the object.
1742 # @param theAutoColor the flag which toggles auto color mode.
1743 # @ingroup l1_auxiliary
1744 def SetAutoColor(self, theAutoColor):
1745 self.mesh.SetAutoColor(theAutoColor)
1747 ## Gets flag of object auto color mode.
1748 # @return True or False
1749 # @ingroup l1_auxiliary
1750 def GetAutoColor(self):
1751 return self.mesh.GetAutoColor()
1753 ## Gets the internal ID
1754 # @return integer value, which is the internal Id of the mesh
1755 # @ingroup l1_auxiliary
1757 return self.mesh.GetId()
1760 # @return integer value, which is the study Id of the mesh
1761 # @ingroup l1_auxiliary
1762 def GetStudyId(self):
1763 return self.mesh.GetStudyId()
1765 ## Checks the group names for duplications.
1766 # Consider the maximum group name length stored in MED file.
1767 # @return True or False
1768 # @ingroup l1_auxiliary
1769 def HasDuplicatedGroupNamesMED(self):
1770 return self.mesh.HasDuplicatedGroupNamesMED()
1772 ## Obtains the mesh editor tool
1773 # @return an instance of SMESH_MeshEditor
1774 # @ingroup l1_modifying
1775 def GetMeshEditor(self):
1776 return self.mesh.GetMeshEditor()
1779 # @return an instance of SALOME_MED::MESH
1780 # @ingroup l1_auxiliary
1781 def GetMEDMesh(self):
1782 return self.mesh.GetMEDMesh()
1785 # Get informations about mesh contents:
1786 # ------------------------------------
1788 ## Gets the mesh stattistic
1789 # @return dictionary type element - count of elements
1790 # @ingroup l1_meshinfo
1791 def GetMeshInfo(self, obj = None):
1792 if not obj: obj = self.mesh
1793 return self.smeshpyD.GetMeshInfo(obj)
1795 ## Returns the number of nodes in the mesh
1796 # @return an integer value
1797 # @ingroup l1_meshinfo
1799 return self.mesh.NbNodes()
1801 ## Returns the number of elements in the mesh
1802 # @return an integer value
1803 # @ingroup l1_meshinfo
1804 def NbElements(self):
1805 return self.mesh.NbElements()
1807 ## Returns the number of 0d elements in the mesh
1808 # @return an integer value
1809 # @ingroup l1_meshinfo
1810 def Nb0DElements(self):
1811 return self.mesh.Nb0DElements()
1813 ## Returns the number of edges in the mesh
1814 # @return an integer value
1815 # @ingroup l1_meshinfo
1817 return self.mesh.NbEdges()
1819 ## Returns the number of edges with the given order in the mesh
1820 # @param elementOrder the order of elements:
1821 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1822 # @return an integer value
1823 # @ingroup l1_meshinfo
1824 def NbEdgesOfOrder(self, elementOrder):
1825 return self.mesh.NbEdgesOfOrder(elementOrder)
1827 ## Returns the number of faces in the mesh
1828 # @return an integer value
1829 # @ingroup l1_meshinfo
1831 return self.mesh.NbFaces()
1833 ## Returns the number of faces with the given order in the mesh
1834 # @param elementOrder the order of elements:
1835 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1836 # @return an integer value
1837 # @ingroup l1_meshinfo
1838 def NbFacesOfOrder(self, elementOrder):
1839 return self.mesh.NbFacesOfOrder(elementOrder)
1841 ## Returns the number of triangles in the mesh
1842 # @return an integer value
1843 # @ingroup l1_meshinfo
1844 def NbTriangles(self):
1845 return self.mesh.NbTriangles()
1847 ## Returns the number of triangles with the given order in the mesh
1848 # @param elementOrder is the order of elements:
1849 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1850 # @return an integer value
1851 # @ingroup l1_meshinfo
1852 def NbTrianglesOfOrder(self, elementOrder):
1853 return self.mesh.NbTrianglesOfOrder(elementOrder)
1855 ## Returns the number of quadrangles in the mesh
1856 # @return an integer value
1857 # @ingroup l1_meshinfo
1858 def NbQuadrangles(self):
1859 return self.mesh.NbQuadrangles()
1861 ## Returns the number of quadrangles with the given order in the mesh
1862 # @param elementOrder the order of elements:
1863 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1864 # @return an integer value
1865 # @ingroup l1_meshinfo
1866 def NbQuadranglesOfOrder(self, elementOrder):
1867 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1869 ## Returns the number of polygons in the mesh
1870 # @return an integer value
1871 # @ingroup l1_meshinfo
1872 def NbPolygons(self):
1873 return self.mesh.NbPolygons()
1875 ## Returns the number of volumes in the mesh
1876 # @return an integer value
1877 # @ingroup l1_meshinfo
1878 def NbVolumes(self):
1879 return self.mesh.NbVolumes()
1881 ## Returns the number of volumes with the given order in the mesh
1882 # @param elementOrder the order of elements:
1883 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1884 # @return an integer value
1885 # @ingroup l1_meshinfo
1886 def NbVolumesOfOrder(self, elementOrder):
1887 return self.mesh.NbVolumesOfOrder(elementOrder)
1889 ## Returns the number of tetrahedrons in the mesh
1890 # @return an integer value
1891 # @ingroup l1_meshinfo
1893 return self.mesh.NbTetras()
1895 ## Returns the number of tetrahedrons with the given order in the mesh
1896 # @param elementOrder the order of elements:
1897 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1898 # @return an integer value
1899 # @ingroup l1_meshinfo
1900 def NbTetrasOfOrder(self, elementOrder):
1901 return self.mesh.NbTetrasOfOrder(elementOrder)
1903 ## Returns the number of hexahedrons in the mesh
1904 # @return an integer value
1905 # @ingroup l1_meshinfo
1907 return self.mesh.NbHexas()
1909 ## Returns the number of hexahedrons with the given order in the mesh
1910 # @param elementOrder the order of elements:
1911 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1912 # @return an integer value
1913 # @ingroup l1_meshinfo
1914 def NbHexasOfOrder(self, elementOrder):
1915 return self.mesh.NbHexasOfOrder(elementOrder)
1917 ## Returns the number of pyramids in the mesh
1918 # @return an integer value
1919 # @ingroup l1_meshinfo
1920 def NbPyramids(self):
1921 return self.mesh.NbPyramids()
1923 ## Returns the number of pyramids with the given order in the mesh
1924 # @param elementOrder the order of elements:
1925 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1926 # @return an integer value
1927 # @ingroup l1_meshinfo
1928 def NbPyramidsOfOrder(self, elementOrder):
1929 return self.mesh.NbPyramidsOfOrder(elementOrder)
1931 ## Returns the number of prisms in the mesh
1932 # @return an integer value
1933 # @ingroup l1_meshinfo
1935 return self.mesh.NbPrisms()
1937 ## Returns the number of prisms with the given order in the mesh
1938 # @param elementOrder the order of elements:
1939 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1940 # @return an integer value
1941 # @ingroup l1_meshinfo
1942 def NbPrismsOfOrder(self, elementOrder):
1943 return self.mesh.NbPrismsOfOrder(elementOrder)
1945 ## Returns the number of polyhedrons in the mesh
1946 # @return an integer value
1947 # @ingroup l1_meshinfo
1948 def NbPolyhedrons(self):
1949 return self.mesh.NbPolyhedrons()
1951 ## Returns the number of submeshes in the mesh
1952 # @return an integer value
1953 # @ingroup l1_meshinfo
1954 def NbSubMesh(self):
1955 return self.mesh.NbSubMesh()
1957 ## Returns the list of mesh elements IDs
1958 # @return the list of integer values
1959 # @ingroup l1_meshinfo
1960 def GetElementsId(self):
1961 return self.mesh.GetElementsId()
1963 ## Returns the list of IDs of mesh elements with the given type
1964 # @param elementType the required type of elements
1965 # @return list of integer values
1966 # @ingroup l1_meshinfo
1967 def GetElementsByType(self, elementType):
1968 return self.mesh.GetElementsByType(elementType)
1970 ## Returns the list of mesh nodes IDs
1971 # @return the list of integer values
1972 # @ingroup l1_meshinfo
1973 def GetNodesId(self):
1974 return self.mesh.GetNodesId()
1976 # Get the information about mesh elements:
1977 # ------------------------------------
1979 ## Returns the type of mesh element
1980 # @return the value from SMESH::ElementType enumeration
1981 # @ingroup l1_meshinfo
1982 def GetElementType(self, id, iselem):
1983 return self.mesh.GetElementType(id, iselem)
1985 ## Returns the geometric type of mesh element
1986 # @return the value from SMESH::EntityType enumeration
1987 # @ingroup l1_meshinfo
1988 def GetElementGeomType(self, id):
1989 return self.mesh.GetElementGeomType(id)
1991 ## Returns the list of submesh elements IDs
1992 # @param Shape a geom object(subshape) IOR
1993 # Shape must be the subshape of a ShapeToMesh()
1994 # @return the list of integer values
1995 # @ingroup l1_meshinfo
1996 def GetSubMeshElementsId(self, Shape):
1997 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1998 ShapeID = Shape.GetSubShapeIndices()[0]
2001 return self.mesh.GetSubMeshElementsId(ShapeID)
2003 ## Returns the list of submesh nodes IDs
2004 # @param Shape a geom object(subshape) IOR
2005 # Shape must be the subshape of a ShapeToMesh()
2006 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2007 # @return the list of integer values
2008 # @ingroup l1_meshinfo
2009 def GetSubMeshNodesId(self, Shape, all):
2010 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2011 ShapeID = Shape.GetSubShapeIndices()[0]
2014 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2016 ## Returns type of elements on given shape
2017 # @param Shape a geom object(subshape) IOR
2018 # Shape must be a subshape of a ShapeToMesh()
2019 # @return element type
2020 # @ingroup l1_meshinfo
2021 def GetSubMeshElementType(self, Shape):
2022 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2023 ShapeID = Shape.GetSubShapeIndices()[0]
2026 return self.mesh.GetSubMeshElementType(ShapeID)
2028 ## Gets the mesh description
2029 # @return string value
2030 # @ingroup l1_meshinfo
2032 return self.mesh.Dump()
2035 # Get the information about nodes and elements of a mesh by its IDs:
2036 # -----------------------------------------------------------
2038 ## Gets XYZ coordinates of a node
2039 # \n If there is no nodes for the given ID - returns an empty list
2040 # @return a list of double precision values
2041 # @ingroup l1_meshinfo
2042 def GetNodeXYZ(self, id):
2043 return self.mesh.GetNodeXYZ(id)
2045 ## Returns list of IDs of inverse elements for the given node
2046 # \n If there is no node for the given ID - returns an empty list
2047 # @return a list of integer values
2048 # @ingroup l1_meshinfo
2049 def GetNodeInverseElements(self, id):
2050 return self.mesh.GetNodeInverseElements(id)
2052 ## @brief Returns the position of a node on the shape
2053 # @return SMESH::NodePosition
2054 # @ingroup l1_meshinfo
2055 def GetNodePosition(self,NodeID):
2056 return self.mesh.GetNodePosition(NodeID)
2058 ## If the given element is a node, returns the ID of shape
2059 # \n If there is no node for the given ID - returns -1
2060 # @return an integer value
2061 # @ingroup l1_meshinfo
2062 def GetShapeID(self, id):
2063 return self.mesh.GetShapeID(id)
2065 ## Returns the ID of the result shape after
2066 # FindShape() from SMESH_MeshEditor for the given element
2067 # \n If there is no element for the given ID - returns -1
2068 # @return an integer value
2069 # @ingroup l1_meshinfo
2070 def GetShapeIDForElem(self,id):
2071 return self.mesh.GetShapeIDForElem(id)
2073 ## Returns the number of nodes for the given element
2074 # \n If there is no element for the given ID - returns -1
2075 # @return an integer value
2076 # @ingroup l1_meshinfo
2077 def GetElemNbNodes(self, id):
2078 return self.mesh.GetElemNbNodes(id)
2080 ## Returns the node ID the given index for the given element
2081 # \n If there is no element for the given ID - returns -1
2082 # \n If there is no node for the given index - returns -2
2083 # @return an integer value
2084 # @ingroup l1_meshinfo
2085 def GetElemNode(self, id, index):
2086 return self.mesh.GetElemNode(id, index)
2088 ## Returns the IDs of nodes of the given element
2089 # @return a list of integer values
2090 # @ingroup l1_meshinfo
2091 def GetElemNodes(self, id):
2092 return self.mesh.GetElemNodes(id)
2094 ## Returns true if the given node is the medium node in the given quadratic element
2095 # @ingroup l1_meshinfo
2096 def IsMediumNode(self, elementID, nodeID):
2097 return self.mesh.IsMediumNode(elementID, nodeID)
2099 ## Returns true if the given node is the medium node in one of quadratic elements
2100 # @ingroup l1_meshinfo
2101 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2102 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2104 ## Returns the number of edges for the given element
2105 # @ingroup l1_meshinfo
2106 def ElemNbEdges(self, id):
2107 return self.mesh.ElemNbEdges(id)
2109 ## Returns the number of faces for the given element
2110 # @ingroup l1_meshinfo
2111 def ElemNbFaces(self, id):
2112 return self.mesh.ElemNbFaces(id)
2114 ## Returns nodes of given face (counted from zero) for given volumic element.
2115 # @ingroup l1_meshinfo
2116 def GetElemFaceNodes(self,elemId, faceIndex):
2117 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2119 ## Returns an element based on all given nodes.
2120 # @ingroup l1_meshinfo
2121 def FindElementByNodes(self,nodes):
2122 return self.mesh.FindElementByNodes(nodes)
2124 ## Returns true if the given element is a polygon
2125 # @ingroup l1_meshinfo
2126 def IsPoly(self, id):
2127 return self.mesh.IsPoly(id)
2129 ## Returns true if the given element is quadratic
2130 # @ingroup l1_meshinfo
2131 def IsQuadratic(self, id):
2132 return self.mesh.IsQuadratic(id)
2134 ## Returns XYZ coordinates of the barycenter of the given element
2135 # \n If there is no element for the given ID - returns an empty list
2136 # @return a list of three double values
2137 # @ingroup l1_meshinfo
2138 def BaryCenter(self, id):
2139 return self.mesh.BaryCenter(id)
2142 # Mesh edition (SMESH_MeshEditor functionality):
2143 # ---------------------------------------------
2145 ## Removes the elements from the mesh by ids
2146 # @param IDsOfElements is a list of ids of elements to remove
2147 # @return True or False
2148 # @ingroup l2_modif_del
2149 def RemoveElements(self, IDsOfElements):
2150 return self.editor.RemoveElements(IDsOfElements)
2152 ## Removes nodes from mesh by ids
2153 # @param IDsOfNodes is a list of ids of nodes to remove
2154 # @return True or False
2155 # @ingroup l2_modif_del
2156 def RemoveNodes(self, IDsOfNodes):
2157 return self.editor.RemoveNodes(IDsOfNodes)
2159 ## Add a node to the mesh by coordinates
2160 # @return Id of the new node
2161 # @ingroup l2_modif_add
2162 def AddNode(self, x, y, z):
2163 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2164 self.mesh.SetParameters(Parameters)
2165 return self.editor.AddNode( x, y, z)
2167 ## Creates a 0D element on a node with given number.
2168 # @param IDOfNode the ID of node for creation of the element.
2169 # @return the Id of the new 0D element
2170 # @ingroup l2_modif_add
2171 def Add0DElement(self, IDOfNode):
2172 return self.editor.Add0DElement(IDOfNode)
2174 ## Creates a linear or quadratic edge (this is determined
2175 # by the number of given nodes).
2176 # @param IDsOfNodes the list of node IDs for creation of the element.
2177 # The order of nodes in this list should correspond to the description
2178 # of MED. \n This description is located by the following link:
2179 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2180 # @return the Id of the new edge
2181 # @ingroup l2_modif_add
2182 def AddEdge(self, IDsOfNodes):
2183 return self.editor.AddEdge(IDsOfNodes)
2185 ## Creates a linear or quadratic face (this is determined
2186 # by the number of given nodes).
2187 # @param IDsOfNodes the list of node IDs for creation of the element.
2188 # The order of nodes in this list should correspond to the description
2189 # of MED. \n This description is located by the following link:
2190 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2191 # @return the Id of the new face
2192 # @ingroup l2_modif_add
2193 def AddFace(self, IDsOfNodes):
2194 return self.editor.AddFace(IDsOfNodes)
2196 ## Adds a polygonal face to the mesh by the list of node IDs
2197 # @param IdsOfNodes the list of node IDs for creation of the element.
2198 # @return the Id of the new face
2199 # @ingroup l2_modif_add
2200 def AddPolygonalFace(self, IdsOfNodes):
2201 return self.editor.AddPolygonalFace(IdsOfNodes)
2203 ## Creates both simple and quadratic volume (this is determined
2204 # by the number of given nodes).
2205 # @param IDsOfNodes the list of node IDs for creation of the element.
2206 # The order of nodes in this list should correspond to the description
2207 # of MED. \n This description is located by the following link:
2208 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2209 # @return the Id of the new volumic element
2210 # @ingroup l2_modif_add
2211 def AddVolume(self, IDsOfNodes):
2212 return self.editor.AddVolume(IDsOfNodes)
2214 ## Creates a volume of many faces, giving nodes for each face.
2215 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2216 # @param Quantities the list of integer values, Quantities[i]
2217 # gives the quantity of nodes in face number i.
2218 # @return the Id of the new volumic element
2219 # @ingroup l2_modif_add
2220 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2221 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2223 ## Creates a volume of many faces, giving the IDs of the existing faces.
2224 # @param IdsOfFaces the list of face IDs for volume creation.
2226 # Note: The created volume will refer only to the nodes
2227 # of the given faces, not to the faces themselves.
2228 # @return the Id of the new volumic element
2229 # @ingroup l2_modif_add
2230 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2231 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2234 ## @brief Binds a node to a vertex
2235 # @param NodeID a node ID
2236 # @param Vertex a vertex or vertex ID
2237 # @return True if succeed else raises an exception
2238 # @ingroup l2_modif_add
2239 def SetNodeOnVertex(self, NodeID, Vertex):
2240 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2241 VertexID = Vertex.GetSubShapeIndices()[0]
2245 self.editor.SetNodeOnVertex(NodeID, VertexID)
2246 except SALOME.SALOME_Exception, inst:
2247 raise ValueError, inst.details.text
2251 ## @brief Stores the node position on an edge
2252 # @param NodeID a node ID
2253 # @param Edge an edge or edge ID
2254 # @param paramOnEdge a parameter on the edge where the node is located
2255 # @return True if succeed else raises an exception
2256 # @ingroup l2_modif_add
2257 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2258 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2259 EdgeID = Edge.GetSubShapeIndices()[0]
2263 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2264 except SALOME.SALOME_Exception, inst:
2265 raise ValueError, inst.details.text
2268 ## @brief Stores node position on a face
2269 # @param NodeID a node ID
2270 # @param Face a face or face ID
2271 # @param u U parameter on the face where the node is located
2272 # @param v V parameter on the face where the node is located
2273 # @return True if succeed else raises an exception
2274 # @ingroup l2_modif_add
2275 def SetNodeOnFace(self, NodeID, Face, u, v):
2276 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2277 FaceID = Face.GetSubShapeIndices()[0]
2281 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2282 except SALOME.SALOME_Exception, inst:
2283 raise ValueError, inst.details.text
2286 ## @brief Binds a node to a solid
2287 # @param NodeID a node ID
2288 # @param Solid a solid or solid ID
2289 # @return True if succeed else raises an exception
2290 # @ingroup l2_modif_add
2291 def SetNodeInVolume(self, NodeID, Solid):
2292 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2293 SolidID = Solid.GetSubShapeIndices()[0]
2297 self.editor.SetNodeInVolume(NodeID, SolidID)
2298 except SALOME.SALOME_Exception, inst:
2299 raise ValueError, inst.details.text
2302 ## @brief Bind an element to a shape
2303 # @param ElementID an element ID
2304 # @param Shape a shape or shape ID
2305 # @return True if succeed else raises an exception
2306 # @ingroup l2_modif_add
2307 def SetMeshElementOnShape(self, ElementID, Shape):
2308 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2309 ShapeID = Shape.GetSubShapeIndices()[0]
2313 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2314 except SALOME.SALOME_Exception, inst:
2315 raise ValueError, inst.details.text
2319 ## Moves the node with the given id
2320 # @param NodeID the id of the node
2321 # @param x a new X coordinate
2322 # @param y a new Y coordinate
2323 # @param z a new Z coordinate
2324 # @return True if succeed else False
2325 # @ingroup l2_modif_movenode
2326 def MoveNode(self, NodeID, x, y, z):
2327 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2328 self.mesh.SetParameters(Parameters)
2329 return self.editor.MoveNode(NodeID, x, y, z)
2331 ## Finds the node closest to a point and moves it to a point location
2332 # @param x the X coordinate of a point
2333 # @param y the Y coordinate of a point
2334 # @param z the Z coordinate of a point
2335 # @param NodeID if specified (>0), the node with this ID is moved,
2336 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2337 # @return the ID of a node
2338 # @ingroup l2_modif_throughp
2339 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2340 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2341 self.mesh.SetParameters(Parameters)
2342 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2344 ## Finds the node closest to a point
2345 # @param x the X coordinate of a point
2346 # @param y the Y coordinate of a point
2347 # @param z the Z coordinate of a point
2348 # @return the ID of a node
2349 # @ingroup l2_modif_throughp
2350 def FindNodeClosestTo(self, x, y, z):
2351 #preview = self.mesh.GetMeshEditPreviewer()
2352 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2353 return self.editor.FindNodeClosestTo(x, y, z)
2355 ## Finds the elements where a point lays IN or ON
2356 # @param x the X coordinate of a point
2357 # @param y the Y coordinate of a point
2358 # @param z the Z coordinate of a point
2359 # @param elementType type of elements to find (SMESH.ALL type
2360 # means elements of any type excluding nodes and 0D elements)
2361 # @return list of IDs of found elements
2362 # @ingroup l2_modif_throughp
2363 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2364 return self.editor.FindElementsByPoint(x, y, z, elementType)
2366 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2367 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2369 def GetPointState(self, x, y, z):
2370 return self.editor.GetPointState(x, y, z)
2372 ## Finds the node closest to a point and moves it to a point location
2373 # @param x the X coordinate of a point
2374 # @param y the Y coordinate of a point
2375 # @param z the Z coordinate of a point
2376 # @return the ID of a moved node
2377 # @ingroup l2_modif_throughp
2378 def MeshToPassThroughAPoint(self, x, y, z):
2379 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2381 ## Replaces two neighbour triangles sharing Node1-Node2 link
2382 # with the triangles built on the same 4 nodes but having other common link.
2383 # @param NodeID1 the ID of the first node
2384 # @param NodeID2 the ID of the second node
2385 # @return false if proper faces were not found
2386 # @ingroup l2_modif_invdiag
2387 def InverseDiag(self, NodeID1, NodeID2):
2388 return self.editor.InverseDiag(NodeID1, NodeID2)
2390 ## Replaces two neighbour triangles sharing Node1-Node2 link
2391 # with a quadrangle built on the same 4 nodes.
2392 # @param NodeID1 the ID of the first node
2393 # @param NodeID2 the ID of the second node
2394 # @return false if proper faces were not found
2395 # @ingroup l2_modif_unitetri
2396 def DeleteDiag(self, NodeID1, NodeID2):
2397 return self.editor.DeleteDiag(NodeID1, NodeID2)
2399 ## Reorients elements by ids
2400 # @param IDsOfElements if undefined reorients all mesh elements
2401 # @return True if succeed else False
2402 # @ingroup l2_modif_changori
2403 def Reorient(self, IDsOfElements=None):
2404 if IDsOfElements == None:
2405 IDsOfElements = self.GetElementsId()
2406 return self.editor.Reorient(IDsOfElements)
2408 ## Reorients all elements of the object
2409 # @param theObject mesh, submesh or group
2410 # @return True if succeed else False
2411 # @ingroup l2_modif_changori
2412 def ReorientObject(self, theObject):
2413 if ( isinstance( theObject, Mesh )):
2414 theObject = theObject.GetMesh()
2415 return self.editor.ReorientObject(theObject)
2417 ## Fuses the neighbouring triangles into quadrangles.
2418 # @param IDsOfElements The triangles to be fused,
2419 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2420 # @param MaxAngle is the maximum angle between element normals at which the fusion
2421 # is still performed; theMaxAngle is mesured in radians.
2422 # Also it could be a name of variable which defines angle in degrees.
2423 # @return TRUE in case of success, FALSE otherwise.
2424 # @ingroup l2_modif_unitetri
2425 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2427 if isinstance(MaxAngle,str):
2429 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2431 MaxAngle = DegreesToRadians(MaxAngle)
2432 if IDsOfElements == []:
2433 IDsOfElements = self.GetElementsId()
2434 self.mesh.SetParameters(Parameters)
2436 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2437 Functor = theCriterion
2439 Functor = self.smeshpyD.GetFunctor(theCriterion)
2440 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2442 ## Fuses the neighbouring triangles of the object into quadrangles
2443 # @param theObject is mesh, submesh or group
2444 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2445 # @param MaxAngle a max angle between element normals at which the fusion
2446 # is still performed; theMaxAngle is mesured in radians.
2447 # @return TRUE in case of success, FALSE otherwise.
2448 # @ingroup l2_modif_unitetri
2449 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2450 if ( isinstance( theObject, Mesh )):
2451 theObject = theObject.GetMesh()
2452 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2454 ## Splits quadrangles into triangles.
2455 # @param IDsOfElements the faces to be splitted.
2456 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2457 # @return TRUE in case of success, FALSE otherwise.
2458 # @ingroup l2_modif_cutquadr
2459 def QuadToTri (self, IDsOfElements, theCriterion):
2460 if IDsOfElements == []:
2461 IDsOfElements = self.GetElementsId()
2462 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2464 ## Splits quadrangles into triangles.
2465 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2466 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2467 # @return TRUE in case of success, FALSE otherwise.
2468 # @ingroup l2_modif_cutquadr
2469 def QuadToTriObject (self, theObject, theCriterion):
2470 if ( isinstance( theObject, Mesh )):
2471 theObject = theObject.GetMesh()
2472 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2474 ## Splits quadrangles into triangles.
2475 # @param IDsOfElements the faces to be splitted
2476 # @param Diag13 is used to choose a diagonal for splitting.
2477 # @return TRUE in case of success, FALSE otherwise.
2478 # @ingroup l2_modif_cutquadr
2479 def SplitQuad (self, IDsOfElements, Diag13):
2480 if IDsOfElements == []:
2481 IDsOfElements = self.GetElementsId()
2482 return self.editor.SplitQuad(IDsOfElements, Diag13)
2484 ## Splits quadrangles into triangles.
2485 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2486 # @param Diag13 is used to choose a diagonal for splitting.
2487 # @return TRUE in case of success, FALSE otherwise.
2488 # @ingroup l2_modif_cutquadr
2489 def SplitQuadObject (self, theObject, Diag13):
2490 if ( isinstance( theObject, Mesh )):
2491 theObject = theObject.GetMesh()
2492 return self.editor.SplitQuadObject(theObject, Diag13)
2494 ## Finds a better splitting of the given quadrangle.
2495 # @param IDOfQuad the ID of the quadrangle to be splitted.
2496 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2497 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2498 # diagonal is better, 0 if error occurs.
2499 # @ingroup l2_modif_cutquadr
2500 def BestSplit (self, IDOfQuad, theCriterion):
2501 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2503 ## Splits volumic elements into tetrahedrons
2504 # @param elemIDs either list of elements or mesh or group or submesh
2505 # @param method flags passing splitting method:
2506 # 1 - split the hexahedron into 5 tetrahedrons
2507 # 2 - split the hexahedron into 6 tetrahedrons
2508 # @ingroup l2_modif_cutquadr
2509 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2510 if isinstance( elemIDs, Mesh ):
2511 elemIDs = elemIDs.GetMesh()
2512 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2514 ## Splits quadrangle faces near triangular facets of volumes
2516 # @ingroup l1_auxiliary
2517 def SplitQuadsNearTriangularFacets(self):
2518 faces_array = self.GetElementsByType(SMESH.FACE)
2519 for face_id in faces_array:
2520 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2521 quad_nodes = self.mesh.GetElemNodes(face_id)
2522 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2523 isVolumeFound = False
2524 for node1_elem in node1_elems:
2525 if not isVolumeFound:
2526 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2527 nb_nodes = self.GetElemNbNodes(node1_elem)
2528 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2529 volume_elem = node1_elem
2530 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2531 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2532 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2533 isVolumeFound = True
2534 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2535 self.SplitQuad([face_id], False) # diagonal 2-4
2536 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2537 isVolumeFound = True
2538 self.SplitQuad([face_id], True) # diagonal 1-3
2539 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2540 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2541 isVolumeFound = True
2542 self.SplitQuad([face_id], True) # diagonal 1-3
2544 ## @brief Splits hexahedrons into tetrahedrons.
2546 # This operation uses pattern mapping functionality for splitting.
2547 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2548 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2549 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2550 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2551 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2552 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2553 # @return TRUE in case of success, FALSE otherwise.
2554 # @ingroup l1_auxiliary
2555 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2556 # Pattern: 5.---------.6
2561 # (0,0,1) 4.---------.7 * |
2568 # (0,0,0) 0.---------.3
2569 pattern_tetra = "!!! Nb of points: \n 8 \n\
2579 !!! Indices of points of 6 tetras: \n\
2587 pattern = self.smeshpyD.GetPattern()
2588 isDone = pattern.LoadFromFile(pattern_tetra)
2590 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2593 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2594 isDone = pattern.MakeMesh(self.mesh, False, False)
2595 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2597 # split quafrangle faces near triangular facets of volumes
2598 self.SplitQuadsNearTriangularFacets()
2602 ## @brief Split hexahedrons into prisms.
2604 # Uses the pattern mapping functionality for splitting.
2605 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2606 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2607 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2608 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2609 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2610 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2611 # @return TRUE in case of success, FALSE otherwise.
2612 # @ingroup l1_auxiliary
2613 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2614 # Pattern: 5.---------.6
2619 # (0,0,1) 4.---------.7 |
2626 # (0,0,0) 0.---------.3
2627 pattern_prism = "!!! Nb of points: \n 8 \n\
2637 !!! Indices of points of 2 prisms: \n\
2641 pattern = self.smeshpyD.GetPattern()
2642 isDone = pattern.LoadFromFile(pattern_prism)
2644 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2647 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2648 isDone = pattern.MakeMesh(self.mesh, False, False)
2649 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2651 # Splits quafrangle faces near triangular facets of volumes
2652 self.SplitQuadsNearTriangularFacets()
2656 ## Smoothes elements
2657 # @param IDsOfElements the list if ids of elements to smooth
2658 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2659 # Note that nodes built on edges and boundary nodes are always fixed.
2660 # @param MaxNbOfIterations the maximum number of iterations
2661 # @param MaxAspectRatio varies in range [1.0, inf]
2662 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2663 # @return TRUE in case of success, FALSE otherwise.
2664 # @ingroup l2_modif_smooth
2665 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2666 MaxNbOfIterations, MaxAspectRatio, Method):
2667 if IDsOfElements == []:
2668 IDsOfElements = self.GetElementsId()
2669 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2670 self.mesh.SetParameters(Parameters)
2671 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2672 MaxNbOfIterations, MaxAspectRatio, Method)
2674 ## Smoothes elements which belong to the given object
2675 # @param theObject the object to smooth
2676 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2677 # Note that nodes built on edges and boundary nodes are always fixed.
2678 # @param MaxNbOfIterations the maximum number of iterations
2679 # @param MaxAspectRatio varies in range [1.0, inf]
2680 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2681 # @return TRUE in case of success, FALSE otherwise.
2682 # @ingroup l2_modif_smooth
2683 def SmoothObject(self, theObject, IDsOfFixedNodes,
2684 MaxNbOfIterations, MaxAspectRatio, Method):
2685 if ( isinstance( theObject, Mesh )):
2686 theObject = theObject.GetMesh()
2687 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2688 MaxNbOfIterations, MaxAspectRatio, Method)
2690 ## Parametrically smoothes the given elements
2691 # @param IDsOfElements the list if ids of elements to smooth
2692 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2693 # Note that nodes built on edges and boundary nodes are always fixed.
2694 # @param MaxNbOfIterations the maximum number of iterations
2695 # @param MaxAspectRatio varies in range [1.0, inf]
2696 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2697 # @return TRUE in case of success, FALSE otherwise.
2698 # @ingroup l2_modif_smooth
2699 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2700 MaxNbOfIterations, MaxAspectRatio, Method):
2701 if IDsOfElements == []:
2702 IDsOfElements = self.GetElementsId()
2703 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2704 self.mesh.SetParameters(Parameters)
2705 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2706 MaxNbOfIterations, MaxAspectRatio, Method)
2708 ## Parametrically smoothes the elements which belong to the given object
2709 # @param theObject the object to smooth
2710 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2711 # Note that nodes built on edges and boundary nodes are always fixed.
2712 # @param MaxNbOfIterations the maximum number of iterations
2713 # @param MaxAspectRatio varies in range [1.0, inf]
2714 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2715 # @return TRUE in case of success, FALSE otherwise.
2716 # @ingroup l2_modif_smooth
2717 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2718 MaxNbOfIterations, MaxAspectRatio, Method):
2719 if ( isinstance( theObject, Mesh )):
2720 theObject = theObject.GetMesh()
2721 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2722 MaxNbOfIterations, MaxAspectRatio, Method)
2724 ## Converts the mesh to quadratic, deletes old elements, replacing
2725 # them with quadratic with the same id.
2726 # @ingroup l2_modif_tofromqu
2727 def ConvertToQuadratic(self, theForce3d):
2728 self.editor.ConvertToQuadratic(theForce3d)
2730 ## Converts the mesh from quadratic to ordinary,
2731 # deletes old quadratic elements, \n replacing
2732 # them with ordinary mesh elements with the same id.
2733 # @return TRUE in case of success, FALSE otherwise.
2734 # @ingroup l2_modif_tofromqu
2735 def ConvertFromQuadratic(self):
2736 return self.editor.ConvertFromQuadratic()
2738 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2739 # @return TRUE if operation has been completed successfully, FALSE otherwise
2740 # @ingroup l2_modif_edit
2741 def Make2DMeshFrom3D(self):
2742 return self.editor. Make2DMeshFrom3D()
2744 ## Renumber mesh nodes
2745 # @ingroup l2_modif_renumber
2746 def RenumberNodes(self):
2747 self.editor.RenumberNodes()
2749 ## Renumber mesh elements
2750 # @ingroup l2_modif_renumber
2751 def RenumberElements(self):
2752 self.editor.RenumberElements()
2754 ## Generates new elements by rotation of the elements around the axis
2755 # @param IDsOfElements the list of ids of elements to sweep
2756 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2757 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2758 # @param NbOfSteps the number of steps
2759 # @param Tolerance tolerance
2760 # @param MakeGroups forces the generation of new groups from existing ones
2761 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2762 # of all steps, else - size of each step
2763 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2764 # @ingroup l2_modif_extrurev
2765 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2766 MakeGroups=False, TotalAngle=False):
2768 if isinstance(AngleInRadians,str):
2770 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2772 AngleInRadians = DegreesToRadians(AngleInRadians)
2773 if IDsOfElements == []:
2774 IDsOfElements = self.GetElementsId()
2775 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2776 Axis = self.smeshpyD.GetAxisStruct(Axis)
2777 Axis,AxisParameters = ParseAxisStruct(Axis)
2778 if TotalAngle and NbOfSteps:
2779 AngleInRadians /= NbOfSteps
2780 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2781 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2782 self.mesh.SetParameters(Parameters)
2784 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2785 AngleInRadians, NbOfSteps, Tolerance)
2786 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2789 ## Generates new elements by rotation of the elements of object around the axis
2790 # @param theObject object which elements should be sweeped
2791 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2792 # @param AngleInRadians the angle of Rotation
2793 # @param NbOfSteps number of steps
2794 # @param Tolerance tolerance
2795 # @param MakeGroups forces the generation of new groups from existing ones
2796 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2797 # of all steps, else - size of each step
2798 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2799 # @ingroup l2_modif_extrurev
2800 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2801 MakeGroups=False, TotalAngle=False):
2803 if isinstance(AngleInRadians,str):
2805 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2807 AngleInRadians = DegreesToRadians(AngleInRadians)
2808 if ( isinstance( theObject, Mesh )):
2809 theObject = theObject.GetMesh()
2810 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2811 Axis = self.smeshpyD.GetAxisStruct(Axis)
2812 Axis,AxisParameters = ParseAxisStruct(Axis)
2813 if TotalAngle and NbOfSteps:
2814 AngleInRadians /= NbOfSteps
2815 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2816 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2817 self.mesh.SetParameters(Parameters)
2819 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2820 NbOfSteps, Tolerance)
2821 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2824 ## Generates new elements by rotation of the elements of object around the axis
2825 # @param theObject object which elements should be sweeped
2826 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2827 # @param AngleInRadians the angle of Rotation
2828 # @param NbOfSteps number of steps
2829 # @param Tolerance tolerance
2830 # @param MakeGroups forces the generation of new groups from existing ones
2831 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2832 # of all steps, else - size of each step
2833 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2834 # @ingroup l2_modif_extrurev
2835 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2836 MakeGroups=False, TotalAngle=False):
2838 if isinstance(AngleInRadians,str):
2840 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2842 AngleInRadians = DegreesToRadians(AngleInRadians)
2843 if ( isinstance( theObject, Mesh )):
2844 theObject = theObject.GetMesh()
2845 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2846 Axis = self.smeshpyD.GetAxisStruct(Axis)
2847 Axis,AxisParameters = ParseAxisStruct(Axis)
2848 if TotalAngle and NbOfSteps:
2849 AngleInRadians /= NbOfSteps
2850 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2851 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2852 self.mesh.SetParameters(Parameters)
2854 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2855 NbOfSteps, Tolerance)
2856 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2859 ## Generates new elements by rotation of the elements of object around the axis
2860 # @param theObject object which elements should be sweeped
2861 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2862 # @param AngleInRadians the angle of Rotation
2863 # @param NbOfSteps number of steps
2864 # @param Tolerance tolerance
2865 # @param MakeGroups forces the generation of new groups from existing ones
2866 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2867 # of all steps, else - size of each step
2868 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2869 # @ingroup l2_modif_extrurev
2870 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2871 MakeGroups=False, TotalAngle=False):
2873 if isinstance(AngleInRadians,str):
2875 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2877 AngleInRadians = DegreesToRadians(AngleInRadians)
2878 if ( isinstance( theObject, Mesh )):
2879 theObject = theObject.GetMesh()
2880 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2881 Axis = self.smeshpyD.GetAxisStruct(Axis)
2882 Axis,AxisParameters = ParseAxisStruct(Axis)
2883 if TotalAngle and NbOfSteps:
2884 AngleInRadians /= NbOfSteps
2885 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2886 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2887 self.mesh.SetParameters(Parameters)
2889 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2890 NbOfSteps, Tolerance)
2891 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2894 ## Generates new elements by extrusion of the elements with given ids
2895 # @param IDsOfElements the list of elements ids for extrusion
2896 # @param StepVector vector, defining the direction and value of extrusion
2897 # @param NbOfSteps the number of steps
2898 # @param MakeGroups forces the generation of new groups from existing ones
2899 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2900 # @ingroup l2_modif_extrurev
2901 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2902 if IDsOfElements == []:
2903 IDsOfElements = self.GetElementsId()
2904 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2905 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2906 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2907 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2908 Parameters = StepVectorParameters + var_separator + Parameters
2909 self.mesh.SetParameters(Parameters)
2911 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2912 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2915 ## Generates new elements by extrusion of the elements with given ids
2916 # @param IDsOfElements is ids of elements
2917 # @param StepVector vector, defining the direction and value of extrusion
2918 # @param NbOfSteps the number of steps
2919 # @param ExtrFlags sets flags for extrusion
2920 # @param SewTolerance uses for comparing locations of nodes if flag
2921 # EXTRUSION_FLAG_SEW is set
2922 # @param MakeGroups forces the generation of new groups from existing ones
2923 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2924 # @ingroup l2_modif_extrurev
2925 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2926 ExtrFlags, SewTolerance, MakeGroups=False):
2927 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2928 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2930 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2931 ExtrFlags, SewTolerance)
2932 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2933 ExtrFlags, SewTolerance)
2936 ## Generates new elements by extrusion of the elements which belong to the object
2937 # @param theObject the object which elements should be processed
2938 # @param StepVector vector, defining the direction and value of extrusion
2939 # @param NbOfSteps the number of steps
2940 # @param MakeGroups forces the generation of new groups from existing ones
2941 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2942 # @ingroup l2_modif_extrurev
2943 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2944 if ( isinstance( theObject, Mesh )):
2945 theObject = theObject.GetMesh()
2946 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2947 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2948 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2949 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2950 Parameters = StepVectorParameters + var_separator + Parameters
2951 self.mesh.SetParameters(Parameters)
2953 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2954 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2957 ## Generates new elements by extrusion of the elements which belong to the object
2958 # @param theObject object which elements should be processed
2959 # @param StepVector vector, defining the direction and value of extrusion
2960 # @param NbOfSteps the number of steps
2961 # @param MakeGroups to generate new groups from existing ones
2962 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2963 # @ingroup l2_modif_extrurev
2964 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2965 if ( isinstance( theObject, Mesh )):
2966 theObject = theObject.GetMesh()
2967 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2968 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2969 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2970 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2971 Parameters = StepVectorParameters + var_separator + Parameters
2972 self.mesh.SetParameters(Parameters)
2974 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2975 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2978 ## Generates new elements by extrusion of the elements which belong to the object
2979 # @param theObject object which elements should be processed
2980 # @param StepVector vector, defining the direction and value of extrusion
2981 # @param NbOfSteps the number of steps
2982 # @param MakeGroups forces the generation of new groups from existing ones
2983 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2984 # @ingroup l2_modif_extrurev
2985 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2986 if ( isinstance( theObject, Mesh )):
2987 theObject = theObject.GetMesh()
2988 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2989 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2990 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2991 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2992 Parameters = StepVectorParameters + var_separator + Parameters
2993 self.mesh.SetParameters(Parameters)
2995 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2996 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3001 ## Generates new elements by extrusion of the given elements
3002 # The path of extrusion must be a meshed edge.
3003 # @param Base mesh or list of ids of elements for extrusion
3004 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3005 # @param NodeStart the start node from Path. Defines the direction of extrusion
3006 # @param HasAngles allows the shape to be rotated around the path
3007 # to get the resulting mesh in a helical fashion
3008 # @param Angles list of angles in radians
3009 # @param LinearVariation forces the computation of rotation angles as linear
3010 # variation of the given Angles along path steps
3011 # @param HasRefPoint allows using the reference point
3012 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3013 # The User can specify any point as the Reference Point.
3014 # @param MakeGroups forces the generation of new groups from existing ones
3015 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3016 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3017 # only SMESH::Extrusion_Error otherwise
3018 # @ingroup l2_modif_extrurev
3019 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3020 HasAngles, Angles, LinearVariation,
3021 HasRefPoint, RefPoint, MakeGroups, ElemType):
3022 Angles,AnglesParameters = ParseAngles(Angles)
3023 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3024 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3025 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3027 Parameters = AnglesParameters + var_separator + RefPointParameters
3028 self.mesh.SetParameters(Parameters)
3030 if isinstance(Base,list):
3032 if Base == []: IDsOfElements = self.GetElementsId()
3033 else: IDsOfElements = Base
3034 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3035 HasAngles, Angles, LinearVariation,
3036 HasRefPoint, RefPoint, MakeGroups, ElemType)
3038 if isinstance(Base,Mesh):
3039 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3040 HasAngles, Angles, LinearVariation,
3041 HasRefPoint, RefPoint, MakeGroups, ElemType)
3043 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3046 ## Generates new elements by extrusion of the given elements
3047 # The path of extrusion must be a meshed edge.
3048 # @param IDsOfElements ids of elements
3049 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3050 # @param PathShape shape(edge) defines the sub-mesh for the path
3051 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3052 # @param HasAngles allows the shape to be rotated around the path
3053 # to get the resulting mesh in a helical fashion
3054 # @param Angles list of angles in radians
3055 # @param HasRefPoint allows using the reference point
3056 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3057 # The User can specify any point as the Reference Point.
3058 # @param MakeGroups forces the generation of new groups from existing ones
3059 # @param LinearVariation forces the computation of rotation angles as linear
3060 # variation of the given Angles along path steps
3061 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3062 # only SMESH::Extrusion_Error otherwise
3063 # @ingroup l2_modif_extrurev
3064 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3065 HasAngles, Angles, HasRefPoint, RefPoint,
3066 MakeGroups=False, LinearVariation=False):
3067 Angles,AnglesParameters = ParseAngles(Angles)
3068 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3069 if IDsOfElements == []:
3070 IDsOfElements = self.GetElementsId()
3071 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3072 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3074 if ( isinstance( PathMesh, Mesh )):
3075 PathMesh = PathMesh.GetMesh()
3076 if HasAngles and Angles and LinearVariation:
3077 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3079 Parameters = AnglesParameters + var_separator + RefPointParameters
3080 self.mesh.SetParameters(Parameters)
3082 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3083 PathShape, NodeStart, HasAngles,
3084 Angles, HasRefPoint, RefPoint)
3085 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3086 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3088 ## Generates new elements by extrusion of the elements which belong to the object
3089 # The path of extrusion must be a meshed edge.
3090 # @param theObject the object which elements should be processed
3091 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3092 # @param PathShape shape(edge) defines the sub-mesh for the path
3093 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3094 # @param HasAngles allows the shape to be rotated around the path
3095 # to get the resulting mesh in a helical fashion
3096 # @param Angles list of angles
3097 # @param HasRefPoint allows using the reference point
3098 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3099 # The User can specify any point as the Reference Point.
3100 # @param MakeGroups forces the generation of new groups from existing ones
3101 # @param LinearVariation forces the computation of rotation angles as linear
3102 # variation of the given Angles along path steps
3103 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3104 # only SMESH::Extrusion_Error otherwise
3105 # @ingroup l2_modif_extrurev
3106 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3107 HasAngles, Angles, HasRefPoint, RefPoint,
3108 MakeGroups=False, LinearVariation=False):
3109 Angles,AnglesParameters = ParseAngles(Angles)
3110 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3111 if ( isinstance( theObject, Mesh )):
3112 theObject = theObject.GetMesh()
3113 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3114 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3115 if ( isinstance( PathMesh, Mesh )):
3116 PathMesh = PathMesh.GetMesh()
3117 if HasAngles and Angles and LinearVariation:
3118 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3120 Parameters = AnglesParameters + var_separator + RefPointParameters
3121 self.mesh.SetParameters(Parameters)
3123 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3124 PathShape, NodeStart, HasAngles,
3125 Angles, HasRefPoint, RefPoint)
3126 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3127 NodeStart, HasAngles, Angles, HasRefPoint,
3130 ## Generates new elements by extrusion of the elements which belong to the object
3131 # The path of extrusion must be a meshed edge.
3132 # @param theObject the object which elements should be processed
3133 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3134 # @param PathShape shape(edge) defines the sub-mesh for the path
3135 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3136 # @param HasAngles allows the shape to be rotated around the path
3137 # to get the resulting mesh in a helical fashion
3138 # @param Angles list of angles
3139 # @param HasRefPoint allows using the reference point
3140 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3141 # The User can specify any point as the Reference Point.
3142 # @param MakeGroups forces the generation of new groups from existing ones
3143 # @param LinearVariation forces the computation of rotation angles as linear
3144 # variation of the given Angles along path steps
3145 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3146 # only SMESH::Extrusion_Error otherwise
3147 # @ingroup l2_modif_extrurev
3148 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3149 HasAngles, Angles, HasRefPoint, RefPoint,
3150 MakeGroups=False, LinearVariation=False):
3151 Angles,AnglesParameters = ParseAngles(Angles)
3152 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3153 if ( isinstance( theObject, Mesh )):
3154 theObject = theObject.GetMesh()
3155 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3156 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3157 if ( isinstance( PathMesh, Mesh )):
3158 PathMesh = PathMesh.GetMesh()
3159 if HasAngles and Angles and LinearVariation:
3160 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3162 Parameters = AnglesParameters + var_separator + RefPointParameters
3163 self.mesh.SetParameters(Parameters)
3165 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3166 PathShape, NodeStart, HasAngles,
3167 Angles, HasRefPoint, RefPoint)
3168 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3169 NodeStart, HasAngles, Angles, HasRefPoint,
3172 ## Generates new elements by extrusion of the elements which belong to the object
3173 # The path of extrusion must be a meshed edge.
3174 # @param theObject the object which elements should be processed
3175 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3176 # @param PathShape shape(edge) defines the sub-mesh for the path
3177 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3178 # @param HasAngles allows the shape to be rotated around the path
3179 # to get the resulting mesh in a helical fashion
3180 # @param Angles list of angles
3181 # @param HasRefPoint allows using the reference point
3182 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3183 # The User can specify any point as the Reference Point.
3184 # @param MakeGroups forces the generation of new groups from existing ones
3185 # @param LinearVariation forces the computation of rotation angles as linear
3186 # variation of the given Angles along path steps
3187 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3188 # only SMESH::Extrusion_Error otherwise
3189 # @ingroup l2_modif_extrurev
3190 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3191 HasAngles, Angles, HasRefPoint, RefPoint,
3192 MakeGroups=False, LinearVariation=False):
3193 Angles,AnglesParameters = ParseAngles(Angles)
3194 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3195 if ( isinstance( theObject, Mesh )):
3196 theObject = theObject.GetMesh()
3197 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3198 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3199 if ( isinstance( PathMesh, Mesh )):
3200 PathMesh = PathMesh.GetMesh()
3201 if HasAngles and Angles and LinearVariation:
3202 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3204 Parameters = AnglesParameters + var_separator + RefPointParameters
3205 self.mesh.SetParameters(Parameters)
3207 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3208 PathShape, NodeStart, HasAngles,
3209 Angles, HasRefPoint, RefPoint)
3210 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3211 NodeStart, HasAngles, Angles, HasRefPoint,
3214 ## Creates a symmetrical copy of mesh elements
3215 # @param IDsOfElements list of elements ids
3216 # @param Mirror is AxisStruct or geom object(point, line, plane)
3217 # @param theMirrorType is POINT, AXIS or PLANE
3218 # If the Mirror is a geom object this parameter is unnecessary
3219 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3220 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3221 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3222 # @ingroup l2_modif_trsf
3223 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3224 if IDsOfElements == []:
3225 IDsOfElements = self.GetElementsId()
3226 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3227 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3228 Mirror,Parameters = ParseAxisStruct(Mirror)
3229 self.mesh.SetParameters(Parameters)
3230 if Copy and MakeGroups:
3231 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3232 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3235 ## Creates a new mesh by a symmetrical copy of mesh elements
3236 # @param IDsOfElements the list of elements ids
3237 # @param Mirror is AxisStruct or geom object (point, line, plane)
3238 # @param theMirrorType is POINT, AXIS or PLANE
3239 # If the Mirror is a geom object this parameter is unnecessary
3240 # @param MakeGroups to generate new groups from existing ones
3241 # @param NewMeshName a name of the new mesh to create
3242 # @return instance of Mesh class
3243 # @ingroup l2_modif_trsf
3244 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3245 if IDsOfElements == []:
3246 IDsOfElements = self.GetElementsId()
3247 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3248 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3249 Mirror,Parameters = ParseAxisStruct(Mirror)
3250 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3251 MakeGroups, NewMeshName)
3252 mesh.SetParameters(Parameters)
3253 return Mesh(self.smeshpyD,self.geompyD,mesh)
3255 ## Creates a symmetrical copy of the object
3256 # @param theObject mesh, submesh or group
3257 # @param Mirror AxisStruct or geom object (point, line, plane)
3258 # @param theMirrorType is POINT, AXIS or PLANE
3259 # If the Mirror is a geom object this parameter is unnecessary
3260 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3261 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3262 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3263 # @ingroup l2_modif_trsf
3264 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3265 if ( isinstance( theObject, Mesh )):
3266 theObject = theObject.GetMesh()
3267 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3268 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3269 Mirror,Parameters = ParseAxisStruct(Mirror)
3270 self.mesh.SetParameters(Parameters)
3271 if Copy and MakeGroups:
3272 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3273 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3276 ## Creates a new mesh by a symmetrical copy of the object
3277 # @param theObject mesh, submesh or group
3278 # @param Mirror AxisStruct or geom object (point, line, plane)
3279 # @param theMirrorType POINT, AXIS or PLANE
3280 # If the Mirror is a geom object this parameter is unnecessary
3281 # @param MakeGroups forces the generation of new groups from existing ones
3282 # @param NewMeshName the name of the new mesh to create
3283 # @return instance of Mesh class
3284 # @ingroup l2_modif_trsf
3285 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3286 if ( isinstance( theObject, Mesh )):
3287 theObject = theObject.GetMesh()
3288 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3289 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3290 Mirror,Parameters = ParseAxisStruct(Mirror)
3291 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3292 MakeGroups, NewMeshName)
3293 mesh.SetParameters(Parameters)
3294 return Mesh( self.smeshpyD,self.geompyD,mesh )
3296 ## Translates the elements
3297 # @param IDsOfElements list of elements ids
3298 # @param Vector the direction of translation (DirStruct or vector)
3299 # @param Copy allows copying the translated elements
3300 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3301 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3302 # @ingroup l2_modif_trsf
3303 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3304 if IDsOfElements == []:
3305 IDsOfElements = self.GetElementsId()
3306 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3307 Vector = self.smeshpyD.GetDirStruct(Vector)
3308 Vector,Parameters = ParseDirStruct(Vector)
3309 self.mesh.SetParameters(Parameters)
3310 if Copy and MakeGroups:
3311 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3312 self.editor.Translate(IDsOfElements, Vector, Copy)
3315 ## Creates a new mesh of translated elements
3316 # @param IDsOfElements list of elements ids
3317 # @param Vector the direction of translation (DirStruct or vector)
3318 # @param MakeGroups forces the generation of new groups from existing ones
3319 # @param NewMeshName the name of the newly created mesh
3320 # @return instance of Mesh class
3321 # @ingroup l2_modif_trsf
3322 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3323 if IDsOfElements == []:
3324 IDsOfElements = self.GetElementsId()
3325 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3326 Vector = self.smeshpyD.GetDirStruct(Vector)
3327 Vector,Parameters = ParseDirStruct(Vector)
3328 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3329 mesh.SetParameters(Parameters)
3330 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3332 ## Translates the object
3333 # @param theObject the object to translate (mesh, submesh, or group)
3334 # @param Vector direction of translation (DirStruct or geom vector)
3335 # @param Copy allows copying the translated elements
3336 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3337 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3338 # @ingroup l2_modif_trsf
3339 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3340 if ( isinstance( theObject, Mesh )):
3341 theObject = theObject.GetMesh()
3342 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3343 Vector = self.smeshpyD.GetDirStruct(Vector)
3344 Vector,Parameters = ParseDirStruct(Vector)
3345 self.mesh.SetParameters(Parameters)
3346 if Copy and MakeGroups:
3347 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3348 self.editor.TranslateObject(theObject, Vector, Copy)
3351 ## Creates a new mesh from the translated object
3352 # @param theObject the object to translate (mesh, submesh, or group)
3353 # @param Vector the direction of translation (DirStruct or geom vector)
3354 # @param MakeGroups forces the generation of new groups from existing ones
3355 # @param NewMeshName the name of the newly created mesh
3356 # @return instance of Mesh class
3357 # @ingroup l2_modif_trsf
3358 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3359 if (isinstance(theObject, Mesh)):
3360 theObject = theObject.GetMesh()
3361 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3362 Vector = self.smeshpyD.GetDirStruct(Vector)
3363 Vector,Parameters = ParseDirStruct(Vector)
3364 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3365 mesh.SetParameters(Parameters)
3366 return Mesh( self.smeshpyD, self.geompyD, mesh )
3370 ## Scales the object
3371 # @param theObject - the object to translate (mesh, submesh, or group)
3372 # @param thePoint - base point for scale
3373 # @param theScaleFact - scale factors for axises
3374 # @param Copy - allows copying the translated elements
3375 # @param MakeGroups - forces the generation of new groups from existing
3377 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3378 # empty list otherwise
3379 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3380 if ( isinstance( theObject, Mesh )):
3381 theObject = theObject.GetMesh()
3382 if ( isinstance( theObject, list )):
3383 theObject = self.editor.MakeIDSource(theObject)
3385 thePoint, Parameters = ParsePointStruct(thePoint)
3386 self.mesh.SetParameters(Parameters)
3388 if Copy and MakeGroups:
3389 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3390 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3393 ## Creates a new mesh from the translated object
3394 # @param theObject - the object to translate (mesh, submesh, or group)
3395 # @param thePoint - base point for scale
3396 # @param theScaleFact - scale factors for axises
3397 # @param MakeGroups - forces the generation of new groups from existing ones
3398 # @param NewMeshName - the name of the newly created mesh
3399 # @return instance of Mesh class
3400 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3401 if (isinstance(theObject, Mesh)):
3402 theObject = theObject.GetMesh()
3403 if ( isinstance( theObject, list )):
3404 theObject = self.editor.MakeIDSource(theObject)
3406 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3407 MakeGroups, NewMeshName)
3408 #mesh.SetParameters(Parameters)
3409 return Mesh( self.smeshpyD, self.geompyD, mesh )
3413 ## Rotates the elements
3414 # @param IDsOfElements list of elements ids
3415 # @param Axis the axis of rotation (AxisStruct or geom line)
3416 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3417 # @param Copy allows copying the rotated elements
3418 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3419 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3420 # @ingroup l2_modif_trsf
3421 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3423 if isinstance(AngleInRadians,str):
3425 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3427 AngleInRadians = DegreesToRadians(AngleInRadians)
3428 if IDsOfElements == []:
3429 IDsOfElements = self.GetElementsId()
3430 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3431 Axis = self.smeshpyD.GetAxisStruct(Axis)
3432 Axis,AxisParameters = ParseAxisStruct(Axis)
3433 Parameters = AxisParameters + var_separator + Parameters
3434 self.mesh.SetParameters(Parameters)
3435 if Copy and MakeGroups:
3436 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3437 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3440 ## Creates a new mesh of rotated elements
3441 # @param IDsOfElements list of element ids
3442 # @param Axis the axis of rotation (AxisStruct or geom line)
3443 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3444 # @param MakeGroups forces the generation of new groups from existing ones
3445 # @param NewMeshName the name of the newly created mesh
3446 # @return instance of Mesh class
3447 # @ingroup l2_modif_trsf
3448 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3450 if isinstance(AngleInRadians,str):
3452 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3454 AngleInRadians = DegreesToRadians(AngleInRadians)
3455 if IDsOfElements == []:
3456 IDsOfElements = self.GetElementsId()
3457 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3458 Axis = self.smeshpyD.GetAxisStruct(Axis)
3459 Axis,AxisParameters = ParseAxisStruct(Axis)
3460 Parameters = AxisParameters + var_separator + Parameters
3461 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3462 MakeGroups, NewMeshName)
3463 mesh.SetParameters(Parameters)
3464 return Mesh( self.smeshpyD, self.geompyD, mesh )
3466 ## Rotates the object
3467 # @param theObject the object to rotate( mesh, submesh, or group)
3468 # @param Axis the axis of rotation (AxisStruct or geom line)
3469 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3470 # @param Copy allows copying the rotated elements
3471 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3472 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3473 # @ingroup l2_modif_trsf
3474 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3476 if isinstance(AngleInRadians,str):
3478 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3480 AngleInRadians = DegreesToRadians(AngleInRadians)
3481 if (isinstance(theObject, Mesh)):
3482 theObject = theObject.GetMesh()
3483 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3484 Axis = self.smeshpyD.GetAxisStruct(Axis)
3485 Axis,AxisParameters = ParseAxisStruct(Axis)
3486 Parameters = AxisParameters + ":" + Parameters
3487 self.mesh.SetParameters(Parameters)
3488 if Copy and MakeGroups:
3489 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3490 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3493 ## Creates a new mesh from the rotated object
3494 # @param theObject the object to rotate (mesh, submesh, or group)
3495 # @param Axis the axis of rotation (AxisStruct or geom line)
3496 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3497 # @param MakeGroups forces the generation of new groups from existing ones
3498 # @param NewMeshName the name of the newly created mesh
3499 # @return instance of Mesh class
3500 # @ingroup l2_modif_trsf
3501 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3503 if isinstance(AngleInRadians,str):
3505 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3507 AngleInRadians = DegreesToRadians(AngleInRadians)
3508 if (isinstance( theObject, Mesh )):
3509 theObject = theObject.GetMesh()
3510 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3511 Axis = self.smeshpyD.GetAxisStruct(Axis)
3512 Axis,AxisParameters = ParseAxisStruct(Axis)
3513 Parameters = AxisParameters + ":" + Parameters
3514 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3515 MakeGroups, NewMeshName)
3516 mesh.SetParameters(Parameters)
3517 return Mesh( self.smeshpyD, self.geompyD, mesh )
3519 ## Finds groups of ajacent nodes within Tolerance.
3520 # @param Tolerance the value of tolerance
3521 # @return the list of groups of nodes
3522 # @ingroup l2_modif_trsf
3523 def FindCoincidentNodes (self, Tolerance):
3524 return self.editor.FindCoincidentNodes(Tolerance)
3526 ## Finds groups of ajacent nodes within Tolerance.
3527 # @param Tolerance the value of tolerance
3528 # @param SubMeshOrGroup SubMesh or Group
3529 # @return the list of groups of nodes
3530 # @ingroup l2_modif_trsf
3531 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3532 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3535 # @param GroupsOfNodes the list of groups of nodes
3536 # @ingroup l2_modif_trsf
3537 def MergeNodes (self, GroupsOfNodes):
3538 self.editor.MergeNodes(GroupsOfNodes)
3540 ## Finds the elements built on the same nodes.
3541 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3542 # @return a list of groups of equal elements
3543 # @ingroup l2_modif_trsf
3544 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3545 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3546 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3547 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3549 ## Merges elements in each given group.
3550 # @param GroupsOfElementsID groups of elements for merging
3551 # @ingroup l2_modif_trsf
3552 def MergeElements(self, GroupsOfElementsID):
3553 self.editor.MergeElements(GroupsOfElementsID)
3555 ## Leaves one element and removes all other elements built on the same nodes.
3556 # @ingroup l2_modif_trsf
3557 def MergeEqualElements(self):
3558 self.editor.MergeEqualElements()
3560 ## Sews free borders
3561 # @return SMESH::Sew_Error
3562 # @ingroup l2_modif_trsf
3563 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3564 FirstNodeID2, SecondNodeID2, LastNodeID2,
3565 CreatePolygons, CreatePolyedrs):
3566 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3567 FirstNodeID2, SecondNodeID2, LastNodeID2,
3568 CreatePolygons, CreatePolyedrs)
3570 ## Sews conform free borders
3571 # @return SMESH::Sew_Error
3572 # @ingroup l2_modif_trsf
3573 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3574 FirstNodeID2, SecondNodeID2):
3575 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3576 FirstNodeID2, SecondNodeID2)
3578 ## Sews border to side
3579 # @return SMESH::Sew_Error
3580 # @ingroup l2_modif_trsf
3581 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3582 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3583 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3584 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3586 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3587 # merged with the nodes of elements of Side2.
3588 # The number of elements in theSide1 and in theSide2 must be
3589 # equal and they should have similar nodal connectivity.
3590 # The nodes to merge should belong to side borders and
3591 # the first node should be linked to the second.
3592 # @return SMESH::Sew_Error
3593 # @ingroup l2_modif_trsf
3594 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3595 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3596 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3597 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3598 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3599 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3601 ## Sets new nodes for the given element.
3602 # @param ide the element id
3603 # @param newIDs nodes ids
3604 # @return If the number of nodes does not correspond to the type of element - returns false
3605 # @ingroup l2_modif_edit
3606 def ChangeElemNodes(self, ide, newIDs):
3607 return self.editor.ChangeElemNodes(ide, newIDs)
3609 ## If during the last operation of MeshEditor some nodes were
3610 # created, this method returns the list of their IDs, \n
3611 # if new nodes were not created - returns empty list
3612 # @return the list of integer values (can be empty)
3613 # @ingroup l1_auxiliary
3614 def GetLastCreatedNodes(self):
3615 return self.editor.GetLastCreatedNodes()
3617 ## If during the last operation of MeshEditor some elements were
3618 # created this method returns the list of their IDs, \n
3619 # if new elements were not created - returns empty list
3620 # @return the list of integer values (can be empty)
3621 # @ingroup l1_auxiliary
3622 def GetLastCreatedElems(self):
3623 return self.editor.GetLastCreatedElems()
3625 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3626 # @param theNodes identifiers of nodes to be doubled
3627 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3628 # nodes. If list of element identifiers is empty then nodes are doubled but
3629 # they not assigned to elements
3630 # @return TRUE if operation has been completed successfully, FALSE otherwise
3631 # @ingroup l2_modif_edit
3632 def DoubleNodes(self, theNodes, theModifiedElems):
3633 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3635 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3636 # This method provided for convenience works as DoubleNodes() described above.
3637 # @param theNodeId identifiers of node to be doubled
3638 # @param theModifiedElems identifiers of elements to be updated
3639 # @return TRUE if operation has been completed successfully, FALSE otherwise
3640 # @ingroup l2_modif_edit
3641 def DoubleNode(self, theNodeId, theModifiedElems):
3642 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3644 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3645 # This method provided for convenience works as DoubleNodes() described above.
3646 # @param theNodes group of nodes to be doubled
3647 # @param theModifiedElems group of elements to be updated.
3648 # @return TRUE if operation has been completed successfully, FALSE otherwise
3649 # @ingroup l2_modif_edit
3650 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3651 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3653 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3654 # This method provided for convenience works as DoubleNodes() described above.
3655 # @param theNodes list of groups of nodes to be doubled
3656 # @param theModifiedElems list of groups of elements to be updated.
3657 # @return TRUE if operation has been completed successfully, FALSE otherwise
3658 # @ingroup l2_modif_edit
3659 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3660 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3662 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3663 # @param theElems - the list of elements (edges or faces) to be replicated
3664 # The nodes for duplication could be found from these elements
3665 # @param theNodesNot - list of nodes to NOT replicate
3666 # @param theAffectedElems - the list of elements (cells and edges) to which the
3667 # replicated nodes should be associated to.
3668 # @return TRUE if operation has been completed successfully, FALSE otherwise
3669 # @ingroup l2_modif_edit
3670 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3671 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3673 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3674 # @param theElems - the list of elements (edges or faces) to be replicated
3675 # The nodes for duplication could be found from these elements
3676 # @param theNodesNot - list of nodes to NOT replicate
3677 # @param theShape - shape to detect affected elements (element which geometric center
3678 # located on or inside shape).
3679 # The replicated nodes should be associated to affected elements.
3680 # @return TRUE if operation has been completed successfully, FALSE otherwise
3681 # @ingroup l2_modif_edit
3682 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3683 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3685 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3686 # This method provided for convenience works as DoubleNodes() described above.
3687 # @param theElems - group of of elements (edges or faces) to be replicated
3688 # @param theNodesNot - group of nodes not to replicated
3689 # @param theAffectedElems - group of elements to which the replicated nodes
3690 # should be associated to.
3691 # @ingroup l2_modif_edit
3692 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3693 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3695 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3696 # This method provided for convenience works as DoubleNodes() described above.
3697 # @param theElems - group of of elements (edges or faces) to be replicated
3698 # @param theNodesNot - group of nodes not to replicated
3699 # @param theShape - shape to detect affected elements (element which geometric center
3700 # located on or inside shape).
3701 # The replicated nodes should be associated to affected elements.
3702 # @ingroup l2_modif_edit
3703 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3704 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3706 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3707 # This method provided for convenience works as DoubleNodes() described above.
3708 # @param theElems - list of groups of elements (edges or faces) to be replicated
3709 # @param theNodesNot - list of groups of nodes not to replicated
3710 # @param theAffectedElems - group of elements to which the replicated nodes
3711 # should be associated to.
3712 # @return TRUE if operation has been completed successfully, FALSE otherwise
3713 # @ingroup l2_modif_edit
3714 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3715 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3717 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3718 # This method provided for convenience works as DoubleNodes() described above.
3719 # @param theElems - list of groups of elements (edges or faces) to be replicated
3720 # @param theNodesNot - list of groups of nodes not to replicated
3721 # @param theShape - shape to detect affected elements (element which geometric center
3722 # located on or inside shape).
3723 # The replicated nodes should be associated to affected elements.
3724 # @return TRUE if operation has been completed successfully, FALSE otherwise
3725 # @ingroup l2_modif_edit
3726 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3727 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3729 ## The mother class to define algorithm, it is not recommended to use it directly.
3732 # @ingroup l2_algorithms
3733 class Mesh_Algorithm:
3734 # @class Mesh_Algorithm
3735 # @brief Class Mesh_Algorithm
3737 #def __init__(self,smesh):
3745 ## Finds a hypothesis in the study by its type name and parameters.
3746 # Finds only the hypotheses created in smeshpyD engine.
3747 # @return SMESH.SMESH_Hypothesis
3748 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3749 study = smeshpyD.GetCurrentStudy()
3750 #to do: find component by smeshpyD object, not by its data type
3751 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3752 if scomp is not None:
3753 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3754 # Check if the root label of the hypotheses exists
3755 if res and hypRoot is not None:
3756 iter = study.NewChildIterator(hypRoot)
3757 # Check all published hypotheses
3759 hypo_so_i = iter.Value()
3760 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3761 if attr is not None:
3762 anIOR = attr.Value()
3763 hypo_o_i = salome.orb.string_to_object(anIOR)
3764 if hypo_o_i is not None:
3765 # Check if this is a hypothesis
3766 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3767 if hypo_i is not None:
3768 # Check if the hypothesis belongs to current engine
3769 if smeshpyD.GetObjectId(hypo_i) > 0:
3770 # Check if this is the required hypothesis
3771 if hypo_i.GetName() == hypname:
3773 if CompareMethod(hypo_i, args):
3787 ## Finds the algorithm in the study by its type name.
3788 # Finds only the algorithms, which have been created in smeshpyD engine.
3789 # @return SMESH.SMESH_Algo
3790 def FindAlgorithm (self, algoname, smeshpyD):
3791 study = smeshpyD.GetCurrentStudy()
3792 #to do: find component by smeshpyD object, not by its data type
3793 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3794 if scomp is not None:
3795 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3796 # Check if the root label of the algorithms exists
3797 if res and hypRoot is not None:
3798 iter = study.NewChildIterator(hypRoot)
3799 # Check all published algorithms
3801 algo_so_i = iter.Value()
3802 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3803 if attr is not None:
3804 anIOR = attr.Value()
3805 algo_o_i = salome.orb.string_to_object(anIOR)
3806 if algo_o_i is not None:
3807 # Check if this is an algorithm
3808 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3809 if algo_i is not None:
3810 # Checks if the algorithm belongs to the current engine
3811 if smeshpyD.GetObjectId(algo_i) > 0:
3812 # Check if this is the required algorithm
3813 if algo_i.GetName() == algoname:
3826 ## If the algorithm is global, returns 0; \n
3827 # else returns the submesh associated to this algorithm.
3828 def GetSubMesh(self):
3831 ## Returns the wrapped mesher.
3832 def GetAlgorithm(self):
3835 ## Gets the list of hypothesis that can be used with this algorithm
3836 def GetCompatibleHypothesis(self):
3839 mylist = self.algo.GetCompatibleHypothesis()
3842 ## Gets the name of the algorithm
3846 ## Sets the name to the algorithm
3847 def SetName(self, name):
3848 self.mesh.smeshpyD.SetName(self.algo, name)
3850 ## Gets the id of the algorithm
3852 return self.algo.GetId()
3855 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3857 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3858 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3860 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3862 self.Assign(algo, mesh, geom)
3866 def Assign(self, algo, mesh, geom):
3868 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3877 name = GetName(geom)
3880 name = mesh.geompyD.SubShapeName(geom, piece)
3881 mesh.geompyD.addToStudyInFather(piece, geom, name)
3883 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3886 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3887 TreatHypoStatus( status, algo.GetName(), name, True )
3889 def CompareHyp (self, hyp, args):
3890 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3893 def CompareEqualHyp (self, hyp, args):
3897 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3898 UseExisting=0, CompareMethod=""):
3901 if CompareMethod == "": CompareMethod = self.CompareHyp
3902 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3905 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3911 a = a + s + str(args[i])
3915 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3917 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3918 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3921 ## Returns entry of the shape to mesh in the study
3922 def MainShapeEntry(self):
3924 if not self.mesh or not self.mesh.GetMesh(): return entry
3925 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3926 study = self.mesh.smeshpyD.GetCurrentStudy()
3927 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3928 sobj = study.FindObjectIOR(ior)
3929 if sobj: entry = sobj.GetID()
3930 if not entry: return ""
3933 # Public class: Mesh_Segment
3934 # --------------------------
3936 ## Class to define a segment 1D algorithm for discretization
3939 # @ingroup l3_algos_basic
3940 class Mesh_Segment(Mesh_Algorithm):
3942 ## Private constructor.
3943 def __init__(self, mesh, geom=0):
3944 Mesh_Algorithm.__init__(self)
3945 self.Create(mesh, geom, "Regular_1D")
3947 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3948 # @param l for the length of segments that cut an edge
3949 # @param UseExisting if ==true - searches for an existing hypothesis created with
3950 # the same parameters, else (default) - creates a new one
3951 # @param p precision, used for calculation of the number of segments.
3952 # The precision should be a positive, meaningful value within the range [0,1].
3953 # In general, the number of segments is calculated with the formula:
3954 # nb = ceil((edge_length / l) - p)
3955 # Function ceil rounds its argument to the higher integer.
3956 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3957 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3958 # p=1 means rounding of (edge_length / l) to the lower integer.
3959 # Default value is 1e-07.
3960 # @return an instance of StdMeshers_LocalLength hypothesis
3961 # @ingroup l3_hypos_1dhyps
3962 def LocalLength(self, l, UseExisting=0, p=1e-07):
3963 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3964 CompareMethod=self.CompareLocalLength)
3970 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3971 def CompareLocalLength(self, hyp, args):
3972 if IsEqual(hyp.GetLength(), args[0]):
3973 return IsEqual(hyp.GetPrecision(), args[1])
3976 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3977 # @param length is optional maximal allowed length of segment, if it is omitted
3978 # the preestimated length is used that depends on geometry size
3979 # @param UseExisting if ==true - searches for an existing hypothesis created with
3980 # the same parameters, else (default) - create a new one
3981 # @return an instance of StdMeshers_MaxLength hypothesis
3982 # @ingroup l3_hypos_1dhyps
3983 def MaxSize(self, length=0.0, UseExisting=0):
3984 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3987 hyp.SetLength(length)
3989 # set preestimated length
3990 gen = self.mesh.smeshpyD
3991 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3992 self.mesh.GetMesh(), self.mesh.GetShape(),
3994 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3996 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3999 hyp.SetUsePreestimatedLength( length == 0.0 )
4002 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4003 # @param n for the number of segments that cut an edge
4004 # @param s for the scale factor (optional)
4005 # @param reversedEdges is a list of edges to mesh using reversed orientation
4006 # @param UseExisting if ==true - searches for an existing hypothesis created with
4007 # the same parameters, else (default) - create a new one
4008 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4009 # @ingroup l3_hypos_1dhyps
4010 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4011 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4012 reversedEdges, UseExisting = [], reversedEdges
4013 entry = self.MainShapeEntry()
4015 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4016 UseExisting=UseExisting,
4017 CompareMethod=self.CompareNumberOfSegments)
4019 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4020 UseExisting=UseExisting,
4021 CompareMethod=self.CompareNumberOfSegments)
4022 hyp.SetDistrType( 1 )
4023 hyp.SetScaleFactor(s)
4024 hyp.SetNumberOfSegments(n)
4025 hyp.SetReversedEdges( reversedEdges )
4026 hyp.SetObjectEntry( entry )
4030 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4031 def CompareNumberOfSegments(self, hyp, args):
4032 if hyp.GetNumberOfSegments() == args[0]:
4034 if hyp.GetReversedEdges() == args[1]:
4035 if not args[1] or hyp.GetObjectEntry() == args[2]:
4038 if hyp.GetReversedEdges() == args[2]:
4039 if not args[2] or hyp.GetObjectEntry() == args[3]:
4040 if hyp.GetDistrType() == 1:
4041 if IsEqual(hyp.GetScaleFactor(), args[1]):
4045 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4046 # @param start defines the length of the first segment
4047 # @param end defines the length of the last segment
4048 # @param reversedEdges is a list of edges to mesh using reversed orientation
4049 # @param UseExisting if ==true - searches for an existing hypothesis created with
4050 # the same parameters, else (default) - creates a new one
4051 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4052 # @ingroup l3_hypos_1dhyps
4053 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4054 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4055 reversedEdges, UseExisting = [], reversedEdges
4056 entry = self.MainShapeEntry()
4057 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4058 UseExisting=UseExisting,
4059 CompareMethod=self.CompareArithmetic1D)
4060 hyp.SetStartLength(start)
4061 hyp.SetEndLength(end)
4062 hyp.SetReversedEdges( reversedEdges )
4063 hyp.SetObjectEntry( entry )
4067 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4068 def CompareArithmetic1D(self, hyp, args):
4069 if IsEqual(hyp.GetLength(1), args[0]):
4070 if IsEqual(hyp.GetLength(0), args[1]):
4071 if hyp.GetReversedEdges() == args[2]:
4072 if not args[2] or hyp.GetObjectEntry() == args[3]:
4077 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4078 # on curve from 0 to 1 (additionally it is neecessary to check
4079 # orientation of edges and create list of reversed edges if it is
4080 # needed) and sets numbers of segments between given points (default
4081 # values are equals 1
4082 # @param points defines the list of parameters on curve
4083 # @param nbSegs defines the list of numbers of segments
4084 # @param reversedEdges is a list of edges to mesh using reversed orientation
4085 # @param UseExisting if ==true - searches for an existing hypothesis created with
4086 # the same parameters, else (default) - creates a new one
4087 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4088 # @ingroup l3_hypos_1dhyps
4089 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4090 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4091 reversedEdges, UseExisting = [], reversedEdges
4092 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4093 for i in range( len( reversedEdges )):
4094 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4095 entry = self.MainShapeEntry()
4096 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4097 UseExisting=UseExisting,
4098 CompareMethod=self.CompareFixedPoints1D)
4099 hyp.SetPoints(points)
4100 hyp.SetNbSegments(nbSegs)
4101 hyp.SetReversedEdges(reversedEdges)
4102 hyp.SetObjectEntry(entry)
4106 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4107 ## as the given arguments
4108 def CompareFixedPoints1D(self, hyp, args):
4109 if hyp.GetPoints() == args[0]:
4110 if hyp.GetNbSegments() == args[1]:
4111 if hyp.GetReversedEdges() == args[2]:
4112 if not args[2] or hyp.GetObjectEntry() == args[3]:
4118 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4119 # @param start defines the length of the first segment
4120 # @param end defines the length of the last segment
4121 # @param reversedEdges is a list of edges to mesh using reversed orientation
4122 # @param UseExisting if ==true - searches for an existing hypothesis created with
4123 # the same parameters, else (default) - creates a new one
4124 # @return an instance of StdMeshers_StartEndLength hypothesis
4125 # @ingroup l3_hypos_1dhyps
4126 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4127 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4128 reversedEdges, UseExisting = [], reversedEdges
4129 entry = self.MainShapeEntry()
4130 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4131 UseExisting=UseExisting,
4132 CompareMethod=self.CompareStartEndLength)
4133 hyp.SetStartLength(start)
4134 hyp.SetEndLength(end)
4135 hyp.SetReversedEdges( reversedEdges )
4136 hyp.SetObjectEntry( entry )
4139 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4140 def CompareStartEndLength(self, hyp, args):
4141 if IsEqual(hyp.GetLength(1), args[0]):
4142 if IsEqual(hyp.GetLength(0), args[1]):
4143 if hyp.GetReversedEdges() == args[2]:
4144 if not args[2] or hyp.GetObjectEntry() == args[3]:
4148 ## Defines "Deflection1D" hypothesis
4149 # @param d for the deflection
4150 # @param UseExisting if ==true - searches for an existing hypothesis created with
4151 # the same parameters, else (default) - create a new one
4152 # @ingroup l3_hypos_1dhyps
4153 def Deflection1D(self, d, UseExisting=0):
4154 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4155 CompareMethod=self.CompareDeflection1D)
4156 hyp.SetDeflection(d)
4159 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4160 def CompareDeflection1D(self, hyp, args):
4161 return IsEqual(hyp.GetDeflection(), args[0])
4163 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4164 # the opposite side in case of quadrangular faces
4165 # @ingroup l3_hypos_additi
4166 def Propagation(self):
4167 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4169 ## Defines "AutomaticLength" hypothesis
4170 # @param fineness for the fineness [0-1]
4171 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4172 # same parameters, else (default) - create a new one
4173 # @ingroup l3_hypos_1dhyps
4174 def AutomaticLength(self, fineness=0, UseExisting=0):
4175 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4176 CompareMethod=self.CompareAutomaticLength)
4177 hyp.SetFineness( fineness )
4180 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4181 def CompareAutomaticLength(self, hyp, args):
4182 return IsEqual(hyp.GetFineness(), args[0])
4184 ## Defines "SegmentLengthAroundVertex" hypothesis
4185 # @param length for the segment length
4186 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4187 # Any other integer value means that the hypothesis will be set on the
4188 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4189 # @param UseExisting if ==true - searches for an existing hypothesis created with
4190 # the same parameters, else (default) - creates a new one
4191 # @ingroup l3_algos_segmarv
4192 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4194 store_geom = self.geom
4195 if type(vertex) is types.IntType:
4196 if vertex == 0 or vertex == 1:
4197 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4205 if self.geom is None:
4206 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4208 name = GetName(self.geom)
4211 piece = self.mesh.geom
4212 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4213 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4215 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4217 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4219 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4220 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4222 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4223 CompareMethod=self.CompareLengthNearVertex)
4224 self.geom = store_geom
4225 hyp.SetLength( length )
4228 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4229 # @ingroup l3_algos_segmarv
4230 def CompareLengthNearVertex(self, hyp, args):
4231 return IsEqual(hyp.GetLength(), args[0])
4233 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4234 # If the 2D mesher sees that all boundary edges are quadratic,
4235 # it generates quadratic faces, else it generates linear faces using
4236 # medium nodes as if they are vertices.
4237 # The 3D mesher generates quadratic volumes only if all boundary faces
4238 # are quadratic, else it fails.
4240 # @ingroup l3_hypos_additi
4241 def QuadraticMesh(self):
4242 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4245 # Public class: Mesh_CompositeSegment
4246 # --------------------------
4248 ## Defines a segment 1D algorithm for discretization
4250 # @ingroup l3_algos_basic
4251 class Mesh_CompositeSegment(Mesh_Segment):
4253 ## Private constructor.
4254 def __init__(self, mesh, geom=0):
4255 self.Create(mesh, geom, "CompositeSegment_1D")
4258 # Public class: Mesh_Segment_Python
4259 # ---------------------------------
4261 ## Defines a segment 1D algorithm for discretization with python function
4263 # @ingroup l3_algos_basic
4264 class Mesh_Segment_Python(Mesh_Segment):
4266 ## Private constructor.
4267 def __init__(self, mesh, geom=0):
4268 import Python1dPlugin
4269 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4271 ## Defines "PythonSplit1D" hypothesis
4272 # @param n for the number of segments that cut an edge
4273 # @param func for the python function that calculates the length of all segments
4274 # @param UseExisting if ==true - searches for the existing hypothesis created with
4275 # the same parameters, else (default) - creates a new one
4276 # @ingroup l3_hypos_1dhyps
4277 def PythonSplit1D(self, n, func, UseExisting=0):
4278 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4279 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4280 hyp.SetNumberOfSegments(n)
4281 hyp.SetPythonLog10RatioFunction(func)
4284 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4285 def ComparePythonSplit1D(self, hyp, args):
4286 #if hyp.GetNumberOfSegments() == args[0]:
4287 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4291 # Public class: Mesh_Triangle
4292 # ---------------------------
4294 ## Defines a triangle 2D algorithm
4296 # @ingroup l3_algos_basic
4297 class Mesh_Triangle(Mesh_Algorithm):
4306 ## Private constructor.
4307 def __init__(self, mesh, algoType, geom=0):
4308 Mesh_Algorithm.__init__(self)
4310 self.algoType = algoType
4311 if algoType == MEFISTO:
4312 self.Create(mesh, geom, "MEFISTO_2D")
4314 elif algoType == BLSURF:
4316 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4317 #self.SetPhysicalMesh() - PAL19680
4318 elif algoType == NETGEN:
4320 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4322 elif algoType == NETGEN_2D:
4324 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4327 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4328 # @param area for the maximum area of each triangle
4329 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4330 # same parameters, else (default) - creates a new one
4332 # Only for algoType == MEFISTO || NETGEN_2D
4333 # @ingroup l3_hypos_2dhyps
4334 def MaxElementArea(self, area, UseExisting=0):
4335 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4336 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4337 CompareMethod=self.CompareMaxElementArea)
4338 elif self.algoType == NETGEN:
4339 hyp = self.Parameters(SIMPLE)
4340 hyp.SetMaxElementArea(area)
4343 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4344 def CompareMaxElementArea(self, hyp, args):
4345 return IsEqual(hyp.GetMaxElementArea(), args[0])
4347 ## Defines "LengthFromEdges" hypothesis to build triangles
4348 # based on the length of the edges taken from the wire
4350 # Only for algoType == MEFISTO || NETGEN_2D
4351 # @ingroup l3_hypos_2dhyps
4352 def LengthFromEdges(self):
4353 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4354 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4356 elif self.algoType == NETGEN:
4357 hyp = self.Parameters(SIMPLE)
4358 hyp.LengthFromEdges()
4361 ## Sets a way to define size of mesh elements to generate.
4362 # @param thePhysicalMesh is: DefaultSize or Custom.
4363 # @ingroup l3_hypos_blsurf
4364 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4365 # Parameter of BLSURF algo
4366 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4368 ## Sets size of mesh elements to generate.
4369 # @ingroup l3_hypos_blsurf
4370 def SetPhySize(self, theVal):
4371 # Parameter of BLSURF algo
4372 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4373 self.Parameters().SetPhySize(theVal)
4375 ## Sets lower boundary of mesh element size (PhySize).
4376 # @ingroup l3_hypos_blsurf
4377 def SetPhyMin(self, theVal=-1):
4378 # Parameter of BLSURF algo
4379 self.Parameters().SetPhyMin(theVal)
4381 ## Sets upper boundary of mesh element size (PhySize).
4382 # @ingroup l3_hypos_blsurf
4383 def SetPhyMax(self, theVal=-1):
4384 # Parameter of BLSURF algo
4385 self.Parameters().SetPhyMax(theVal)
4387 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4388 # @param theGeometricMesh is: DefaultGeom or Custom
4389 # @ingroup l3_hypos_blsurf
4390 def SetGeometricMesh(self, theGeometricMesh=0):
4391 # Parameter of BLSURF algo
4392 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4393 self.params.SetGeometricMesh(theGeometricMesh)
4395 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4396 # @ingroup l3_hypos_blsurf
4397 def SetAngleMeshS(self, theVal=_angleMeshS):
4398 # Parameter of BLSURF algo
4399 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4400 self.params.SetAngleMeshS(theVal)
4402 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4403 # @ingroup l3_hypos_blsurf
4404 def SetAngleMeshC(self, theVal=_angleMeshS):
4405 # Parameter of BLSURF algo
4406 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4407 self.params.SetAngleMeshC(theVal)
4409 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4410 # @ingroup l3_hypos_blsurf
4411 def SetGeoMin(self, theVal=-1):
4412 # Parameter of BLSURF algo
4413 self.Parameters().SetGeoMin(theVal)
4415 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4416 # @ingroup l3_hypos_blsurf
4417 def SetGeoMax(self, theVal=-1):
4418 # Parameter of BLSURF algo
4419 self.Parameters().SetGeoMax(theVal)
4421 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4422 # @ingroup l3_hypos_blsurf
4423 def SetGradation(self, theVal=_gradation):
4424 # Parameter of BLSURF algo
4425 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4426 self.params.SetGradation(theVal)
4428 ## Sets topology usage way.
4429 # @param way defines how mesh conformity is assured <ul>
4430 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4431 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4432 # @ingroup l3_hypos_blsurf
4433 def SetTopology(self, way):
4434 # Parameter of BLSURF algo
4435 self.Parameters().SetTopology(way)
4437 ## To respect geometrical edges or not.
4438 # @ingroup l3_hypos_blsurf
4439 def SetDecimesh(self, toIgnoreEdges=False):
4440 # Parameter of BLSURF algo
4441 self.Parameters().SetDecimesh(toIgnoreEdges)
4443 ## Sets verbosity level in the range 0 to 100.
4444 # @ingroup l3_hypos_blsurf
4445 def SetVerbosity(self, level):
4446 # Parameter of BLSURF algo
4447 self.Parameters().SetVerbosity(level)
4449 ## Sets advanced option value.
4450 # @ingroup l3_hypos_blsurf
4451 def SetOptionValue(self, optionName, level):
4452 # Parameter of BLSURF algo
4453 self.Parameters().SetOptionValue(optionName,level)
4455 ## Sets QuadAllowed flag.
4456 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4457 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4458 def SetQuadAllowed(self, toAllow=True):
4459 if self.algoType == NETGEN_2D:
4460 if toAllow: # add QuadranglePreference
4461 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4462 else: # remove QuadranglePreference
4463 for hyp in self.mesh.GetHypothesisList( self.geom ):
4464 if hyp.GetName() == "QuadranglePreference":
4465 self.mesh.RemoveHypothesis( self.geom, hyp )
4470 if self.Parameters():
4471 self.params.SetQuadAllowed(toAllow)
4474 ## Defines hypothesis having several parameters
4476 # @ingroup l3_hypos_netgen
4477 def Parameters(self, which=SOLE):
4480 if self.algoType == NETGEN:
4482 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4483 "libNETGENEngine.so", UseExisting=0)
4485 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4486 "libNETGENEngine.so", UseExisting=0)
4488 elif self.algoType == MEFISTO:
4489 print "Mefisto algo support no multi-parameter hypothesis"
4491 elif self.algoType == NETGEN_2D:
4492 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4493 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4495 elif self.algoType == BLSURF:
4496 self.params = self.Hypothesis("BLSURF_Parameters", [],
4497 "libBLSURFEngine.so", UseExisting=0)
4500 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4505 # Only for algoType == NETGEN
4506 # @ingroup l3_hypos_netgen
4507 def SetMaxSize(self, theSize):
4508 if self.Parameters():
4509 self.params.SetMaxSize(theSize)
4511 ## Sets SecondOrder flag
4513 # Only for algoType == NETGEN
4514 # @ingroup l3_hypos_netgen
4515 def SetSecondOrder(self, theVal):
4516 if self.Parameters():
4517 self.params.SetSecondOrder(theVal)
4519 ## Sets Optimize flag
4521 # Only for algoType == NETGEN
4522 # @ingroup l3_hypos_netgen
4523 def SetOptimize(self, theVal):
4524 if self.Parameters():
4525 self.params.SetOptimize(theVal)
4528 # @param theFineness is:
4529 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4531 # Only for algoType == NETGEN
4532 # @ingroup l3_hypos_netgen
4533 def SetFineness(self, theFineness):
4534 if self.Parameters():
4535 self.params.SetFineness(theFineness)
4539 # Only for algoType == NETGEN
4540 # @ingroup l3_hypos_netgen
4541 def SetGrowthRate(self, theRate):
4542 if self.Parameters():
4543 self.params.SetGrowthRate(theRate)
4545 ## Sets NbSegPerEdge
4547 # Only for algoType == NETGEN
4548 # @ingroup l3_hypos_netgen
4549 def SetNbSegPerEdge(self, theVal):
4550 if self.Parameters():
4551 self.params.SetNbSegPerEdge(theVal)
4553 ## Sets NbSegPerRadius
4555 # Only for algoType == NETGEN
4556 # @ingroup l3_hypos_netgen
4557 def SetNbSegPerRadius(self, theVal):
4558 if self.Parameters():
4559 self.params.SetNbSegPerRadius(theVal)
4561 ## Sets number of segments overriding value set by SetLocalLength()
4563 # Only for algoType == NETGEN
4564 # @ingroup l3_hypos_netgen
4565 def SetNumberOfSegments(self, theVal):
4566 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4568 ## Sets number of segments overriding value set by SetNumberOfSegments()
4570 # Only for algoType == NETGEN
4571 # @ingroup l3_hypos_netgen
4572 def SetLocalLength(self, theVal):
4573 self.Parameters(SIMPLE).SetLocalLength(theVal)
4578 # Public class: Mesh_Quadrangle
4579 # -----------------------------
4581 ## Defines a quadrangle 2D algorithm
4583 # @ingroup l3_algos_basic
4584 class Mesh_Quadrangle(Mesh_Algorithm):
4586 ## Private constructor.
4587 def __init__(self, mesh, geom=0):
4588 Mesh_Algorithm.__init__(self)
4589 self.Create(mesh, geom, "Quadrangle_2D")
4591 ## Defines "QuadranglePreference" hypothesis, forcing construction
4592 # of quadrangles if the number of nodes on the opposite edges is not the same
4593 # while the total number of nodes on edges is even
4595 # @ingroup l3_hypos_additi
4596 def QuadranglePreference(self):
4597 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4598 CompareMethod=self.CompareEqualHyp)
4601 ## Defines "TrianglePreference" hypothesis, forcing construction
4602 # of triangles in the refinement area if the number of nodes
4603 # on the opposite edges is not the same
4605 # @ingroup l3_hypos_additi
4606 def TrianglePreference(self):
4607 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4608 CompareMethod=self.CompareEqualHyp)
4611 ## Defines "QuadrangleParams" hypothesis
4612 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4613 # will be created while other elements will be quadrangles.
4614 # Vertex can be either a GEOM_Object or a vertex ID within the
4616 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4617 # the same parameters, else (default) - creates a new one
4619 # @ingroup l3_hypos_additi
4620 def TriangleVertex(self, vertex, UseExisting=0):
4622 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4623 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4624 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4625 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4626 hyp.SetTriaVertex( vertexID )
4630 # Public class: Mesh_Tetrahedron
4631 # ------------------------------
4633 ## Defines a tetrahedron 3D algorithm
4635 # @ingroup l3_algos_basic
4636 class Mesh_Tetrahedron(Mesh_Algorithm):
4641 ## Private constructor.
4642 def __init__(self, mesh, algoType, geom=0):
4643 Mesh_Algorithm.__init__(self)
4645 if algoType == NETGEN:
4647 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4650 elif algoType == FULL_NETGEN:
4652 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4655 elif algoType == GHS3D:
4657 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4660 elif algoType == GHS3DPRL:
4661 CheckPlugin(GHS3DPRL)
4662 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4665 self.algoType = algoType
4667 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4668 # @param vol for the maximum volume of each tetrahedron
4669 # @param UseExisting if ==true - searches for the existing hypothesis created with
4670 # the same parameters, else (default) - creates a new one
4671 # @ingroup l3_hypos_maxvol
4672 def MaxElementVolume(self, vol, UseExisting=0):
4673 if self.algoType == NETGEN:
4674 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4675 CompareMethod=self.CompareMaxElementVolume)
4676 hyp.SetMaxElementVolume(vol)
4678 elif self.algoType == FULL_NETGEN:
4679 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4682 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4683 def CompareMaxElementVolume(self, hyp, args):
4684 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4686 ## Defines hypothesis having several parameters
4688 # @ingroup l3_hypos_netgen
4689 def Parameters(self, which=SOLE):
4693 if self.algoType == FULL_NETGEN:
4695 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4696 "libNETGENEngine.so", UseExisting=0)
4698 self.params = self.Hypothesis("NETGEN_Parameters", [],
4699 "libNETGENEngine.so", UseExisting=0)
4702 if self.algoType == GHS3D:
4703 self.params = self.Hypothesis("GHS3D_Parameters", [],
4704 "libGHS3DEngine.so", UseExisting=0)
4707 if self.algoType == GHS3DPRL:
4708 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4709 "libGHS3DPRLEngine.so", UseExisting=0)
4712 print "Algo supports no multi-parameter hypothesis"
4716 # Parameter of FULL_NETGEN
4717 # @ingroup l3_hypos_netgen
4718 def SetMaxSize(self, theSize):
4719 self.Parameters().SetMaxSize(theSize)
4721 ## Sets SecondOrder flag
4722 # Parameter of FULL_NETGEN
4723 # @ingroup l3_hypos_netgen
4724 def SetSecondOrder(self, theVal):
4725 self.Parameters().SetSecondOrder(theVal)
4727 ## Sets Optimize flag
4728 # Parameter of FULL_NETGEN
4729 # @ingroup l3_hypos_netgen
4730 def SetOptimize(self, theVal):
4731 self.Parameters().SetOptimize(theVal)
4734 # @param theFineness is:
4735 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4736 # Parameter of FULL_NETGEN
4737 # @ingroup l3_hypos_netgen
4738 def SetFineness(self, theFineness):
4739 self.Parameters().SetFineness(theFineness)
4742 # Parameter of FULL_NETGEN
4743 # @ingroup l3_hypos_netgen
4744 def SetGrowthRate(self, theRate):
4745 self.Parameters().SetGrowthRate(theRate)
4747 ## Sets NbSegPerEdge
4748 # Parameter of FULL_NETGEN
4749 # @ingroup l3_hypos_netgen
4750 def SetNbSegPerEdge(self, theVal):
4751 self.Parameters().SetNbSegPerEdge(theVal)
4753 ## Sets NbSegPerRadius
4754 # Parameter of FULL_NETGEN
4755 # @ingroup l3_hypos_netgen
4756 def SetNbSegPerRadius(self, theVal):
4757 self.Parameters().SetNbSegPerRadius(theVal)
4759 ## Sets number of segments overriding value set by SetLocalLength()
4760 # Only for algoType == NETGEN_FULL
4761 # @ingroup l3_hypos_netgen
4762 def SetNumberOfSegments(self, theVal):
4763 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4765 ## Sets number of segments overriding value set by SetNumberOfSegments()
4766 # Only for algoType == NETGEN_FULL
4767 # @ingroup l3_hypos_netgen
4768 def SetLocalLength(self, theVal):
4769 self.Parameters(SIMPLE).SetLocalLength(theVal)
4771 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4772 # Overrides value set by LengthFromEdges()
4773 # Only for algoType == NETGEN_FULL
4774 # @ingroup l3_hypos_netgen
4775 def MaxElementArea(self, area):
4776 self.Parameters(SIMPLE).SetMaxElementArea(area)
4778 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4779 # Overrides value set by MaxElementArea()
4780 # Only for algoType == NETGEN_FULL
4781 # @ingroup l3_hypos_netgen
4782 def LengthFromEdges(self):
4783 self.Parameters(SIMPLE).LengthFromEdges()
4785 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4786 # Overrides value set by MaxElementVolume()
4787 # Only for algoType == NETGEN_FULL
4788 # @ingroup l3_hypos_netgen
4789 def LengthFromFaces(self):
4790 self.Parameters(SIMPLE).LengthFromFaces()
4792 ## To mesh "holes" in a solid or not. Default is to mesh.
4793 # @ingroup l3_hypos_ghs3dh
4794 def SetToMeshHoles(self, toMesh):
4795 # Parameter of GHS3D
4796 self.Parameters().SetToMeshHoles(toMesh)
4798 ## Set Optimization level:
4799 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4800 # Strong_Optimization.
4801 # Default is Standard_Optimization
4802 # @ingroup l3_hypos_ghs3dh
4803 def SetOptimizationLevel(self, level):
4804 # Parameter of GHS3D
4805 self.Parameters().SetOptimizationLevel(level)
4807 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4808 # @ingroup l3_hypos_ghs3dh
4809 def SetMaximumMemory(self, MB):
4810 # Advanced parameter of GHS3D
4811 self.Parameters().SetMaximumMemory(MB)
4813 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4814 # automatic memory adjustment mode.
4815 # @ingroup l3_hypos_ghs3dh
4816 def SetInitialMemory(self, MB):
4817 # Advanced parameter of GHS3D
4818 self.Parameters().SetInitialMemory(MB)
4820 ## Path to working directory.
4821 # @ingroup l3_hypos_ghs3dh
4822 def SetWorkingDirectory(self, path):
4823 # Advanced parameter of GHS3D
4824 self.Parameters().SetWorkingDirectory(path)
4826 ## To keep working files or remove them. Log file remains in case of errors anyway.
4827 # @ingroup l3_hypos_ghs3dh
4828 def SetKeepFiles(self, toKeep):
4829 # Advanced parameter of GHS3D and GHS3DPRL
4830 self.Parameters().SetKeepFiles(toKeep)
4832 ## To set verbose level [0-10]. <ul>
4833 #<li> 0 - no standard output,
4834 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4835 # indicates when the final mesh is being saved. In addition the software
4836 # gives indication regarding the CPU time.
4837 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4838 # histogram of the skin mesh, quality statistics histogram together with
4839 # the characteristics of the final mesh.</ul>
4840 # @ingroup l3_hypos_ghs3dh
4841 def SetVerboseLevel(self, level):
4842 # Advanced parameter of GHS3D
4843 self.Parameters().SetVerboseLevel(level)
4845 ## To create new nodes.
4846 # @ingroup l3_hypos_ghs3dh
4847 def SetToCreateNewNodes(self, toCreate):
4848 # Advanced parameter of GHS3D
4849 self.Parameters().SetToCreateNewNodes(toCreate)
4851 ## To use boundary recovery version which tries to create mesh on a very poor
4852 # quality surface mesh.
4853 # @ingroup l3_hypos_ghs3dh
4854 def SetToUseBoundaryRecoveryVersion(self, toUse):
4855 # Advanced parameter of GHS3D
4856 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4858 ## Sets command line option as text.
4859 # @ingroup l3_hypos_ghs3dh
4860 def SetTextOption(self, option):
4861 # Advanced parameter of GHS3D
4862 self.Parameters().SetTextOption(option)
4864 ## Sets MED files name and path.
4865 def SetMEDName(self, value):
4866 self.Parameters().SetMEDName(value)
4868 ## Sets the number of partition of the initial mesh
4869 def SetNbPart(self, value):
4870 self.Parameters().SetNbPart(value)
4872 ## When big mesh, start tepal in background
4873 def SetBackground(self, value):
4874 self.Parameters().SetBackground(value)
4876 # Public class: Mesh_Hexahedron
4877 # ------------------------------
4879 ## Defines a hexahedron 3D algorithm
4881 # @ingroup l3_algos_basic
4882 class Mesh_Hexahedron(Mesh_Algorithm):
4887 ## Private constructor.
4888 def __init__(self, mesh, algoType=Hexa, geom=0):
4889 Mesh_Algorithm.__init__(self)
4891 self.algoType = algoType
4893 if algoType == Hexa:
4894 self.Create(mesh, geom, "Hexa_3D")
4897 elif algoType == Hexotic:
4898 CheckPlugin(Hexotic)
4899 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4902 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4903 # @ingroup l3_hypos_hexotic
4904 def MinMaxQuad(self, min=3, max=8, quad=True):
4905 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4907 self.params.SetHexesMinLevel(min)
4908 self.params.SetHexesMaxLevel(max)
4909 self.params.SetHexoticQuadrangles(quad)
4912 # Deprecated, only for compatibility!
4913 # Public class: Mesh_Netgen
4914 # ------------------------------
4916 ## Defines a NETGEN-based 2D or 3D algorithm
4917 # that needs no discrete boundary (i.e. independent)
4919 # This class is deprecated, only for compatibility!
4922 # @ingroup l3_algos_basic
4923 class Mesh_Netgen(Mesh_Algorithm):
4927 ## Private constructor.
4928 def __init__(self, mesh, is3D, geom=0):
4929 Mesh_Algorithm.__init__(self)
4935 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4939 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4942 ## Defines the hypothesis containing parameters of the algorithm
4943 def Parameters(self):
4945 hyp = self.Hypothesis("NETGEN_Parameters", [],
4946 "libNETGENEngine.so", UseExisting=0)
4948 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4949 "libNETGENEngine.so", UseExisting=0)
4952 # Public class: Mesh_Projection1D
4953 # ------------------------------
4955 ## Defines a projection 1D algorithm
4956 # @ingroup l3_algos_proj
4958 class Mesh_Projection1D(Mesh_Algorithm):
4960 ## Private constructor.
4961 def __init__(self, mesh, geom=0):
4962 Mesh_Algorithm.__init__(self)
4963 self.Create(mesh, geom, "Projection_1D")
4965 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4966 # a mesh pattern is taken, and, optionally, the association of vertices
4967 # between the source edge and a target edge (to which a hypothesis is assigned)
4968 # @param edge from which nodes distribution is taken
4969 # @param mesh from which nodes distribution is taken (optional)
4970 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4971 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4972 # to associate with \a srcV (optional)
4973 # @param UseExisting if ==true - searches for the existing hypothesis created with
4974 # the same parameters, else (default) - creates a new one
4975 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4976 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4978 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4979 hyp.SetSourceEdge( edge )
4980 if not mesh is None and isinstance(mesh, Mesh):
4981 mesh = mesh.GetMesh()
4982 hyp.SetSourceMesh( mesh )
4983 hyp.SetVertexAssociation( srcV, tgtV )
4986 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4987 #def CompareSourceEdge(self, hyp, args):
4988 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4992 # Public class: Mesh_Projection2D
4993 # ------------------------------
4995 ## Defines a projection 2D algorithm
4996 # @ingroup l3_algos_proj
4998 class Mesh_Projection2D(Mesh_Algorithm):
5000 ## Private constructor.
5001 def __init__(self, mesh, geom=0):
5002 Mesh_Algorithm.__init__(self)
5003 self.Create(mesh, geom, "Projection_2D")
5005 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5006 # a mesh pattern is taken, and, optionally, the association of vertices
5007 # between the source face and the target face (to which a hypothesis is assigned)
5008 # @param face from which the mesh pattern is taken
5009 # @param mesh from which the mesh pattern is taken (optional)
5010 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5011 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5012 # to associate with \a srcV1 (optional)
5013 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5014 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5015 # to associate with \a srcV2 (optional)
5016 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5017 # the same parameters, else (default) - forces the creation a new one
5019 # Note: all association vertices must belong to one edge of a face
5020 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5021 srcV2=None, tgtV2=None, UseExisting=0):
5022 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5024 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5025 hyp.SetSourceFace( face )
5026 if not mesh is None and isinstance(mesh, Mesh):
5027 mesh = mesh.GetMesh()
5028 hyp.SetSourceMesh( mesh )
5029 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5032 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5033 #def CompareSourceFace(self, hyp, args):
5034 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5037 # Public class: Mesh_Projection3D
5038 # ------------------------------
5040 ## Defines a projection 3D algorithm
5041 # @ingroup l3_algos_proj
5043 class Mesh_Projection3D(Mesh_Algorithm):
5045 ## Private constructor.
5046 def __init__(self, mesh, geom=0):
5047 Mesh_Algorithm.__init__(self)
5048 self.Create(mesh, geom, "Projection_3D")
5050 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5051 # the mesh pattern is taken, and, optionally, the association of vertices
5052 # between the source and the target solid (to which a hipothesis is assigned)
5053 # @param solid from where the mesh pattern is taken
5054 # @param mesh from where the mesh pattern is taken (optional)
5055 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5056 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5057 # to associate with \a srcV1 (optional)
5058 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5059 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5060 # to associate with \a srcV2 (optional)
5061 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5062 # the same parameters, else (default) - creates a new one
5064 # Note: association vertices must belong to one edge of a solid
5065 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5066 srcV2=0, tgtV2=0, UseExisting=0):
5067 hyp = self.Hypothesis("ProjectionSource3D",
5068 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5070 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5071 hyp.SetSource3DShape( solid )
5072 if not mesh is None and isinstance(mesh, Mesh):
5073 mesh = mesh.GetMesh()
5074 hyp.SetSourceMesh( mesh )
5075 if srcV1 and srcV2 and tgtV1 and tgtV2:
5076 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5077 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5080 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5081 #def CompareSourceShape3D(self, hyp, args):
5082 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5086 # Public class: Mesh_Prism
5087 # ------------------------
5089 ## Defines a 3D extrusion algorithm
5090 # @ingroup l3_algos_3dextr
5092 class Mesh_Prism3D(Mesh_Algorithm):
5094 ## Private constructor.
5095 def __init__(self, mesh, geom=0):
5096 Mesh_Algorithm.__init__(self)
5097 self.Create(mesh, geom, "Prism_3D")
5099 # Public class: Mesh_RadialPrism
5100 # -------------------------------
5102 ## Defines a Radial Prism 3D algorithm
5103 # @ingroup l3_algos_radialp
5105 class Mesh_RadialPrism3D(Mesh_Algorithm):
5107 ## Private constructor.
5108 def __init__(self, mesh, geom=0):
5109 Mesh_Algorithm.__init__(self)
5110 self.Create(mesh, geom, "RadialPrism_3D")
5112 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5113 self.nbLayers = None
5115 ## Return 3D hypothesis holding the 1D one
5116 def Get3DHypothesis(self):
5117 return self.distribHyp
5119 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5120 # hypothesis. Returns the created hypothesis
5121 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5122 #print "OwnHypothesis",hypType
5123 if not self.nbLayers is None:
5124 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5125 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5126 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5127 self.mesh.smeshpyD.SetCurrentStudy( None )
5128 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5129 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5130 self.distribHyp.SetLayerDistribution( hyp )
5133 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5134 # prisms to build between the inner and outer shells
5135 # @param n number of layers
5136 # @param UseExisting if ==true - searches for the existing hypothesis created with
5137 # the same parameters, else (default) - creates a new one
5138 def NumberOfLayers(self, n, UseExisting=0):
5139 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5140 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5141 CompareMethod=self.CompareNumberOfLayers)
5142 self.nbLayers.SetNumberOfLayers( n )
5143 return self.nbLayers
5145 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5146 def CompareNumberOfLayers(self, hyp, args):
5147 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5149 ## Defines "LocalLength" hypothesis, specifying the segment length
5150 # to build between the inner and the outer shells
5151 # @param l the length of segments
5152 # @param p the precision of rounding
5153 def LocalLength(self, l, p=1e-07):
5154 hyp = self.OwnHypothesis("LocalLength", [l,p])
5159 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5160 # prisms to build between the inner and the outer shells.
5161 # @param n the number of layers
5162 # @param s the scale factor (optional)
5163 def NumberOfSegments(self, n, s=[]):
5165 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5167 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5168 hyp.SetDistrType( 1 )
5169 hyp.SetScaleFactor(s)
5170 hyp.SetNumberOfSegments(n)
5173 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5174 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5175 # @param start the length of the first segment
5176 # @param end the length of the last segment
5177 def Arithmetic1D(self, start, end ):
5178 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5179 hyp.SetLength(start, 1)
5180 hyp.SetLength(end , 0)
5183 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5184 # to build between the inner and the outer shells as geometric length increasing
5185 # @param start for the length of the first segment
5186 # @param end for the length of the last segment
5187 def StartEndLength(self, start, end):
5188 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5189 hyp.SetLength(start, 1)
5190 hyp.SetLength(end , 0)
5193 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5194 # to build between the inner and outer shells
5195 # @param fineness defines the quality of the mesh within the range [0-1]
5196 def AutomaticLength(self, fineness=0):
5197 hyp = self.OwnHypothesis("AutomaticLength")
5198 hyp.SetFineness( fineness )
5201 # Public class: Mesh_RadialQuadrangle1D2D
5202 # -------------------------------
5204 ## Defines a Radial Quadrangle 1D2D algorithm
5205 # @ingroup l2_algos_radialq
5207 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5209 ## Private constructor.
5210 def __init__(self, mesh, geom=0):
5211 Mesh_Algorithm.__init__(self)
5212 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5214 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5215 self.nbLayers = None
5217 ## Return 2D hypothesis holding the 1D one
5218 def Get2DHypothesis(self):
5219 return self.distribHyp
5221 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5222 # hypothesis. Returns the created hypothesis
5223 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5224 #print "OwnHypothesis",hypType
5226 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5227 if self.distribHyp is None:
5228 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5230 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5231 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5232 self.mesh.smeshpyD.SetCurrentStudy( None )
5233 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5234 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5235 self.distribHyp.SetLayerDistribution( hyp )
5238 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5239 # @param n number of layers
5240 # @param UseExisting if ==true - searches for the existing hypothesis created with
5241 # the same parameters, else (default) - creates a new one
5242 def NumberOfLayers(self, n, UseExisting=0):
5244 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5245 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5246 CompareMethod=self.CompareNumberOfLayers)
5247 self.nbLayers.SetNumberOfLayers( n )
5248 return self.nbLayers
5250 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5251 def CompareNumberOfLayers(self, hyp, args):
5252 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5254 ## Defines "LocalLength" hypothesis, specifying the segment length
5255 # @param l the length of segments
5256 # @param p the precision of rounding
5257 def LocalLength(self, l, p=1e-07):
5258 hyp = self.OwnHypothesis("LocalLength", [l,p])
5263 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5264 # @param n the number of layers
5265 # @param s the scale factor (optional)
5266 def NumberOfSegments(self, n, s=[]):
5268 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5270 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5271 hyp.SetDistrType( 1 )
5272 hyp.SetScaleFactor(s)
5273 hyp.SetNumberOfSegments(n)
5276 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5277 # with a length that changes in arithmetic progression
5278 # @param start the length of the first segment
5279 # @param end the length of the last segment
5280 def Arithmetic1D(self, start, end ):
5281 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5282 hyp.SetLength(start, 1)
5283 hyp.SetLength(end , 0)
5286 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5287 # as geometric length increasing
5288 # @param start for the length of the first segment
5289 # @param end for the length of the last segment
5290 def StartEndLength(self, start, end):
5291 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5292 hyp.SetLength(start, 1)
5293 hyp.SetLength(end , 0)
5296 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5297 # @param fineness defines the quality of the mesh within the range [0-1]
5298 def AutomaticLength(self, fineness=0):
5299 hyp = self.OwnHypothesis("AutomaticLength")
5300 hyp.SetFineness( fineness )
5304 # Private class: Mesh_UseExisting
5305 # -------------------------------
5306 class Mesh_UseExisting(Mesh_Algorithm):
5308 def __init__(self, dim, mesh, geom=0):
5310 self.Create(mesh, geom, "UseExisting_1D")
5312 self.Create(mesh, geom, "UseExisting_2D")
5315 import salome_notebook
5316 notebook = salome_notebook.notebook
5318 ##Return values of the notebook variables
5319 def ParseParameters(last, nbParams,nbParam, value):
5323 listSize = len(last)
5324 for n in range(0,nbParams):
5326 if counter < listSize:
5327 strResult = strResult + last[counter]
5329 strResult = strResult + ""
5331 if isinstance(value, str):
5332 if notebook.isVariable(value):
5333 result = notebook.get(value)
5334 strResult=strResult+value
5336 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5338 strResult=strResult+str(value)
5340 if nbParams - 1 != counter:
5341 strResult=strResult+var_separator #":"
5343 return result, strResult
5345 #Wrapper class for StdMeshers_LocalLength hypothesis
5346 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5348 ## Set Length parameter value
5349 # @param length numerical value or name of variable from notebook
5350 def SetLength(self, length):
5351 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5352 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5353 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5355 ## Set Precision parameter value
5356 # @param precision numerical value or name of variable from notebook
5357 def SetPrecision(self, precision):
5358 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5359 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5360 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5362 #Registering the new proxy for LocalLength
5363 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5366 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5367 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5369 def SetLayerDistribution(self, hypo):
5370 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5371 hypo.ClearParameters();
5372 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5374 #Registering the new proxy for LayerDistribution
5375 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5377 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5378 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5380 ## Set Length parameter value
5381 # @param length numerical value or name of variable from notebook
5382 def SetLength(self, length):
5383 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5384 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5385 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5387 #Registering the new proxy for SegmentLengthAroundVertex
5388 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5391 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5392 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5394 ## Set Length parameter value
5395 # @param length numerical value or name of variable from notebook
5396 # @param isStart true is length is Start Length, otherwise false
5397 def SetLength(self, length, isStart):
5401 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5402 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5403 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5405 #Registering the new proxy for Arithmetic1D
5406 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5408 #Wrapper class for StdMeshers_Deflection1D hypothesis
5409 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5411 ## Set Deflection parameter value
5412 # @param deflection numerical value or name of variable from notebook
5413 def SetDeflection(self, deflection):
5414 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5415 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5416 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5418 #Registering the new proxy for Deflection1D
5419 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5421 #Wrapper class for StdMeshers_StartEndLength hypothesis
5422 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5424 ## Set Length parameter value
5425 # @param length numerical value or name of variable from notebook
5426 # @param isStart true is length is Start Length, otherwise false
5427 def SetLength(self, length, isStart):
5431 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5432 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5433 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5435 #Registering the new proxy for StartEndLength
5436 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5438 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5439 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5441 ## Set Max Element Area parameter value
5442 # @param area numerical value or name of variable from notebook
5443 def SetMaxElementArea(self, area):
5444 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5445 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5446 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5448 #Registering the new proxy for MaxElementArea
5449 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5452 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5453 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5455 ## Set Max Element Volume parameter value
5456 # @param volume numerical value or name of variable from notebook
5457 def SetMaxElementVolume(self, volume):
5458 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5459 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5460 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5462 #Registering the new proxy for MaxElementVolume
5463 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5466 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5467 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5469 ## Set Number Of Layers parameter value
5470 # @param nbLayers numerical value or name of variable from notebook
5471 def SetNumberOfLayers(self, nbLayers):
5472 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5473 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5474 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5476 #Registering the new proxy for NumberOfLayers
5477 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5479 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5480 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5482 ## Set Number Of Segments parameter value
5483 # @param nbSeg numerical value or name of variable from notebook
5484 def SetNumberOfSegments(self, nbSeg):
5485 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5486 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5487 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5488 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5490 ## Set Scale Factor parameter value
5491 # @param factor numerical value or name of variable from notebook
5492 def SetScaleFactor(self, factor):
5493 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5494 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5495 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5497 #Registering the new proxy for NumberOfSegments
5498 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5500 if not noNETGENPlugin:
5501 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5502 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5504 ## Set Max Size parameter value
5505 # @param maxsize numerical value or name of variable from notebook
5506 def SetMaxSize(self, maxsize):
5507 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5508 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5509 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5510 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5512 ## Set Growth Rate parameter value
5513 # @param value numerical value or name of variable from notebook
5514 def SetGrowthRate(self, value):
5515 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5516 value, parameters = ParseParameters(lastParameters,4,2,value)
5517 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5518 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5520 ## Set Number of Segments per Edge parameter value
5521 # @param value numerical value or name of variable from notebook
5522 def SetNbSegPerEdge(self, value):
5523 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5524 value, parameters = ParseParameters(lastParameters,4,3,value)
5525 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5526 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5528 ## Set Number of Segments per Radius parameter value
5529 # @param value numerical value or name of variable from notebook
5530 def SetNbSegPerRadius(self, value):
5531 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5532 value, parameters = ParseParameters(lastParameters,4,4,value)
5533 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5534 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5536 #Registering the new proxy for NETGENPlugin_Hypothesis
5537 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5540 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5541 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5544 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5545 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5547 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5548 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5550 ## Set Number of Segments parameter value
5551 # @param nbSeg numerical value or name of variable from notebook
5552 def SetNumberOfSegments(self, nbSeg):
5553 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5554 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5555 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5556 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5558 ## Set Local Length parameter value
5559 # @param length numerical value or name of variable from notebook
5560 def SetLocalLength(self, length):
5561 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5562 length, parameters = ParseParameters(lastParameters,2,1,length)
5563 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5564 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5566 ## Set Max Element Area parameter value
5567 # @param area numerical value or name of variable from notebook
5568 def SetMaxElementArea(self, area):
5569 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5570 area, parameters = ParseParameters(lastParameters,2,2,area)
5571 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5572 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5574 def LengthFromEdges(self):
5575 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5577 value, parameters = ParseParameters(lastParameters,2,2,value)
5578 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5579 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5581 #Registering the new proxy for NETGEN_SimpleParameters_2D
5582 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5585 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5586 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5587 ## Set Max Element Volume parameter value
5588 # @param volume numerical value or name of variable from notebook
5589 def SetMaxElementVolume(self, volume):
5590 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5591 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5592 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5593 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5595 def LengthFromFaces(self):
5596 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5598 value, parameters = ParseParameters(lastParameters,3,3,value)
5599 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5600 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5602 #Registering the new proxy for NETGEN_SimpleParameters_3D
5603 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5605 pass # if not noNETGENPlugin:
5607 class Pattern(SMESH._objref_SMESH_Pattern):
5609 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5611 if isinstance(theNodeIndexOnKeyPoint1,str):
5613 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5615 theNodeIndexOnKeyPoint1 -= 1
5616 theMesh.SetParameters(Parameters)
5617 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5619 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5622 if isinstance(theNode000Index,str):
5624 if isinstance(theNode001Index,str):
5626 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5628 theNode000Index -= 1
5630 theNode001Index -= 1
5631 theMesh.SetParameters(Parameters)
5632 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5634 #Registering the new proxy for Pattern
5635 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)