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 ExportToMEDX() method instead.
1426 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1427 ## allowing to overwrite the file if it exists or add the exported data to its contents
1428 # @param f the file name
1429 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1430 # @param opt boolean parameter for creating/not creating
1431 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1432 # @param overwrite boolean parameter for overwriting/not overwriting the file
1433 # @ingroup l2_impexp
1434 def ExportToMED(self, f, version, opt=0, overwrite=1):
1435 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1437 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1438 ## allowing to overwrite the file if it exists or add the exported data to its contents
1439 # @param f is the file name
1440 # @param auto_groups boolean parameter for creating/not creating
1441 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1442 # the typical use is auto_groups=false.
1443 # @param version MED format version(MED_V2_1 or MED_V2_2)
1444 # @param overwrite boolean parameter for overwriting/not overwriting the file
1445 # @ingroup l2_impexp
1446 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1447 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1449 ## Exports the mesh in a file in DAT format
1450 # @param f the file name
1451 # @ingroup l2_impexp
1452 def ExportDAT(self, f):
1453 self.mesh.ExportDAT(f)
1455 ## Exports the mesh in a file in UNV format
1456 # @param f the file name
1457 # @ingroup l2_impexp
1458 def ExportUNV(self, f):
1459 self.mesh.ExportUNV(f)
1461 ## Export the mesh in a file in STL format
1462 # @param f the file name
1463 # @param ascii defines the file encoding
1464 # @ingroup l2_impexp
1465 def ExportSTL(self, f, ascii=1):
1466 self.mesh.ExportSTL(f, ascii)
1469 # Operations with groups:
1470 # ----------------------
1472 ## Creates an empty mesh group
1473 # @param elementType the type of elements in the group
1474 # @param name the name of the mesh group
1475 # @return SMESH_Group
1476 # @ingroup l2_grps_create
1477 def CreateEmptyGroup(self, elementType, name):
1478 return self.mesh.CreateGroup(elementType, name)
1480 ## Creates a mesh group based on the geometrical object \a grp
1481 # and gives a \a name, \n if this parameter is not defined
1482 # the name is the same as the geometrical group name
1483 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1484 # @param name the name of the mesh group
1485 # @param typ the type of elements in the group. If not set, it is
1486 # automatically detected by the type of the geometry
1487 # @return SMESH_GroupOnGeom
1488 # @ingroup l2_grps_create
1489 def GroupOnGeom(self, grp, name="", typ=None):
1491 name = grp.GetName()
1494 tgeo = str(grp.GetShapeType())
1495 if tgeo == "VERTEX":
1497 elif tgeo == "EDGE":
1499 elif tgeo == "FACE":
1501 elif tgeo == "SOLID":
1503 elif tgeo == "SHELL":
1505 elif tgeo == "COMPOUND":
1506 try: # it raises on a compound of compounds
1507 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1508 print "Mesh.Group: empty geometric group", GetName( grp )
1513 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1515 tgeo = self.geompyD.GetType(grp)
1516 if tgeo == geompyDC.ShapeType["VERTEX"]:
1518 elif tgeo == geompyDC.ShapeType["EDGE"]:
1520 elif tgeo == geompyDC.ShapeType["FACE"]:
1522 elif tgeo == geompyDC.ShapeType["SOLID"]:
1528 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1529 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1530 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1538 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1541 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1543 ## Creates a mesh group by the given ids of elements
1544 # @param groupName the name of the mesh group
1545 # @param elementType the type of elements in the group
1546 # @param elemIDs the list of ids
1547 # @return SMESH_Group
1548 # @ingroup l2_grps_create
1549 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1550 group = self.mesh.CreateGroup(elementType, groupName)
1554 ## Creates a mesh group by the given conditions
1555 # @param groupName the name of the mesh group
1556 # @param elementType the type of elements in the group
1557 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1558 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1559 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1560 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1561 # @return SMESH_Group
1562 # @ingroup l2_grps_create
1566 CritType=FT_Undefined,
1569 UnaryOp=FT_Undefined):
1570 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1571 group = self.MakeGroupByCriterion(groupName, aCriterion)
1574 ## Creates a mesh group by the given criterion
1575 # @param groupName the name of the mesh group
1576 # @param Criterion the instance of Criterion class
1577 # @return SMESH_Group
1578 # @ingroup l2_grps_create
1579 def MakeGroupByCriterion(self, groupName, Criterion):
1580 aFilterMgr = self.smeshpyD.CreateFilterManager()
1581 aFilter = aFilterMgr.CreateFilter()
1583 aCriteria.append(Criterion)
1584 aFilter.SetCriteria(aCriteria)
1585 group = self.MakeGroupByFilter(groupName, aFilter)
1588 ## Creates a mesh group by the given criteria (list of criteria)
1589 # @param groupName the name of the mesh group
1590 # @param theCriteria the list of criteria
1591 # @return SMESH_Group
1592 # @ingroup l2_grps_create
1593 def MakeGroupByCriteria(self, groupName, theCriteria):
1594 aFilterMgr = self.smeshpyD.CreateFilterManager()
1595 aFilter = aFilterMgr.CreateFilter()
1596 aFilter.SetCriteria(theCriteria)
1597 group = self.MakeGroupByFilter(groupName, aFilter)
1600 ## Creates a mesh group by the given filter
1601 # @param groupName the name of the mesh group
1602 # @param theFilter the instance of Filter class
1603 # @return SMESH_Group
1604 # @ingroup l2_grps_create
1605 def MakeGroupByFilter(self, groupName, theFilter):
1606 anIds = theFilter.GetElementsId(self.mesh)
1607 anElemType = theFilter.GetElementType()
1608 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1611 ## Passes mesh elements through the given filter and return IDs of fitting elements
1612 # @param theFilter SMESH_Filter
1613 # @return a list of ids
1614 # @ingroup l1_controls
1615 def GetIdsFromFilter(self, theFilter):
1616 return theFilter.GetElementsId(self.mesh)
1618 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1619 # Returns a list of special structures (borders).
1620 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1621 # @ingroup l1_controls
1622 def GetFreeBorders(self):
1623 aFilterMgr = self.smeshpyD.CreateFilterManager()
1624 aPredicate = aFilterMgr.CreateFreeEdges()
1625 aPredicate.SetMesh(self.mesh)
1626 aBorders = aPredicate.GetBorders()
1630 # @ingroup l2_grps_delete
1631 def RemoveGroup(self, group):
1632 self.mesh.RemoveGroup(group)
1634 ## Removes a group with its contents
1635 # @ingroup l2_grps_delete
1636 def RemoveGroupWithContents(self, group):
1637 self.mesh.RemoveGroupWithContents(group)
1639 ## Gets the list of groups existing in the mesh
1640 # @return a sequence of SMESH_GroupBase
1641 # @ingroup l2_grps_create
1642 def GetGroups(self):
1643 return self.mesh.GetGroups()
1645 ## Gets the number of groups existing in the mesh
1646 # @return the quantity of groups as an integer value
1647 # @ingroup l2_grps_create
1649 return self.mesh.NbGroups()
1651 ## Gets the list of names of groups existing in the mesh
1652 # @return list of strings
1653 # @ingroup l2_grps_create
1654 def GetGroupNames(self):
1655 groups = self.GetGroups()
1657 for group in groups:
1658 names.append(group.GetName())
1661 ## Produces a union of two groups
1662 # A new group is created. All mesh elements that are
1663 # present in the initial groups are added to the new one
1664 # @return an instance of SMESH_Group
1665 # @ingroup l2_grps_operon
1666 def UnionGroups(self, group1, group2, name):
1667 return self.mesh.UnionGroups(group1, group2, name)
1669 ## Produces a union list of groups
1670 # New group is created. All mesh elements that are present in
1671 # initial groups are added to the new one
1672 # @return an instance of SMESH_Group
1673 # @ingroup l2_grps_operon
1674 def UnionListOfGroups(self, groups, name):
1675 return self.mesh.UnionListOfGroups(groups, name)
1677 ## Prodices an intersection of two groups
1678 # A new group is created. All mesh elements that are common
1679 # for the two initial groups are added to the new one.
1680 # @return an instance of SMESH_Group
1681 # @ingroup l2_grps_operon
1682 def IntersectGroups(self, group1, group2, name):
1683 return self.mesh.IntersectGroups(group1, group2, name)
1685 ## Produces an intersection of groups
1686 # New group is created. All mesh elements that are present in all
1687 # initial groups simultaneously are added to the new one
1688 # @return an instance of SMESH_Group
1689 # @ingroup l2_grps_operon
1690 def IntersectListOfGroups(self, groups, name):
1691 return self.mesh.IntersectListOfGroups(groups, name)
1693 ## Produces a cut of two groups
1694 # A new group is created. All mesh elements that are present in
1695 # the main group but are not present in the tool group are added to the new one
1696 # @return an instance of SMESH_Group
1697 # @ingroup l2_grps_operon
1698 def CutGroups(self, main_group, tool_group, name):
1699 return self.mesh.CutGroups(main_group, tool_group, name)
1701 ## Produces a cut of groups
1702 # A new group is created. All mesh elements that are present in main groups
1703 # but do not present in tool groups are added to the new one
1704 # @return an instance of SMESH_Group
1705 # @ingroup l2_grps_operon
1706 def CutListOfGroups(self, main_groups, tool_groups, name):
1707 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1709 ## Produces a group of elements with specified element type using list of existing groups
1710 # A new group is created. System
1711 # 1) extract all nodes on which groups elements are built
1712 # 2) combine all elements of specified dimension laying on these nodes
1713 # @return an instance of SMESH_Group
1714 # @ingroup l2_grps_operon
1715 def CreateDimGroup(self, groups, elem_type, name):
1716 return self.mesh.CreateDimGroup(groups, elem_type, name)
1719 ## Convert group on geom into standalone group
1720 # @ingroup l2_grps_delete
1721 def ConvertToStandalone(self, group):
1722 return self.mesh.ConvertToStandalone(group)
1724 # Get some info about mesh:
1725 # ------------------------
1727 ## Returns the log of nodes and elements added or removed
1728 # since the previous clear of the log.
1729 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1730 # @return list of log_block structures:
1735 # @ingroup l1_auxiliary
1736 def GetLog(self, clearAfterGet):
1737 return self.mesh.GetLog(clearAfterGet)
1739 ## Clears the log of nodes and elements added or removed since the previous
1740 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1741 # @ingroup l1_auxiliary
1743 self.mesh.ClearLog()
1745 ## Toggles auto color mode on the object.
1746 # @param theAutoColor the flag which toggles auto color mode.
1747 # @ingroup l1_auxiliary
1748 def SetAutoColor(self, theAutoColor):
1749 self.mesh.SetAutoColor(theAutoColor)
1751 ## Gets flag of object auto color mode.
1752 # @return True or False
1753 # @ingroup l1_auxiliary
1754 def GetAutoColor(self):
1755 return self.mesh.GetAutoColor()
1757 ## Gets the internal ID
1758 # @return integer value, which is the internal Id of the mesh
1759 # @ingroup l1_auxiliary
1761 return self.mesh.GetId()
1764 # @return integer value, which is the study Id of the mesh
1765 # @ingroup l1_auxiliary
1766 def GetStudyId(self):
1767 return self.mesh.GetStudyId()
1769 ## Checks the group names for duplications.
1770 # Consider the maximum group name length stored in MED file.
1771 # @return True or False
1772 # @ingroup l1_auxiliary
1773 def HasDuplicatedGroupNamesMED(self):
1774 return self.mesh.HasDuplicatedGroupNamesMED()
1776 ## Obtains the mesh editor tool
1777 # @return an instance of SMESH_MeshEditor
1778 # @ingroup l1_modifying
1779 def GetMeshEditor(self):
1780 return self.mesh.GetMeshEditor()
1783 # @return an instance of SALOME_MED::MESH
1784 # @ingroup l1_auxiliary
1785 def GetMEDMesh(self):
1786 return self.mesh.GetMEDMesh()
1789 # Get informations about mesh contents:
1790 # ------------------------------------
1792 ## Gets the mesh stattistic
1793 # @return dictionary type element - count of elements
1794 # @ingroup l1_meshinfo
1795 def GetMeshInfo(self, obj = None):
1796 if not obj: obj = self.mesh
1797 return self.smeshpyD.GetMeshInfo(obj)
1799 ## Returns the number of nodes in the mesh
1800 # @return an integer value
1801 # @ingroup l1_meshinfo
1803 return self.mesh.NbNodes()
1805 ## Returns the number of elements in the mesh
1806 # @return an integer value
1807 # @ingroup l1_meshinfo
1808 def NbElements(self):
1809 return self.mesh.NbElements()
1811 ## Returns the number of 0d elements in the mesh
1812 # @return an integer value
1813 # @ingroup l1_meshinfo
1814 def Nb0DElements(self):
1815 return self.mesh.Nb0DElements()
1817 ## Returns the number of edges in the mesh
1818 # @return an integer value
1819 # @ingroup l1_meshinfo
1821 return self.mesh.NbEdges()
1823 ## Returns the number of edges with the given order in the mesh
1824 # @param elementOrder the order of elements:
1825 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1826 # @return an integer value
1827 # @ingroup l1_meshinfo
1828 def NbEdgesOfOrder(self, elementOrder):
1829 return self.mesh.NbEdgesOfOrder(elementOrder)
1831 ## Returns the number of faces in the mesh
1832 # @return an integer value
1833 # @ingroup l1_meshinfo
1835 return self.mesh.NbFaces()
1837 ## Returns the number of faces with the given order in the mesh
1838 # @param elementOrder the order of elements:
1839 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1840 # @return an integer value
1841 # @ingroup l1_meshinfo
1842 def NbFacesOfOrder(self, elementOrder):
1843 return self.mesh.NbFacesOfOrder(elementOrder)
1845 ## Returns the number of triangles in the mesh
1846 # @return an integer value
1847 # @ingroup l1_meshinfo
1848 def NbTriangles(self):
1849 return self.mesh.NbTriangles()
1851 ## Returns the number of triangles with the given order in the mesh
1852 # @param elementOrder is the order of elements:
1853 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1854 # @return an integer value
1855 # @ingroup l1_meshinfo
1856 def NbTrianglesOfOrder(self, elementOrder):
1857 return self.mesh.NbTrianglesOfOrder(elementOrder)
1859 ## Returns the number of quadrangles in the mesh
1860 # @return an integer value
1861 # @ingroup l1_meshinfo
1862 def NbQuadrangles(self):
1863 return self.mesh.NbQuadrangles()
1865 ## Returns the number of quadrangles with the given order in the mesh
1866 # @param elementOrder the order of elements:
1867 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1868 # @return an integer value
1869 # @ingroup l1_meshinfo
1870 def NbQuadranglesOfOrder(self, elementOrder):
1871 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1873 ## Returns the number of polygons in the mesh
1874 # @return an integer value
1875 # @ingroup l1_meshinfo
1876 def NbPolygons(self):
1877 return self.mesh.NbPolygons()
1879 ## Returns the number of volumes in the mesh
1880 # @return an integer value
1881 # @ingroup l1_meshinfo
1882 def NbVolumes(self):
1883 return self.mesh.NbVolumes()
1885 ## Returns the number of volumes with the given order in the mesh
1886 # @param elementOrder the order of elements:
1887 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1888 # @return an integer value
1889 # @ingroup l1_meshinfo
1890 def NbVolumesOfOrder(self, elementOrder):
1891 return self.mesh.NbVolumesOfOrder(elementOrder)
1893 ## Returns the number of tetrahedrons in the mesh
1894 # @return an integer value
1895 # @ingroup l1_meshinfo
1897 return self.mesh.NbTetras()
1899 ## Returns the number of tetrahedrons with the given order in the mesh
1900 # @param elementOrder the order of elements:
1901 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1902 # @return an integer value
1903 # @ingroup l1_meshinfo
1904 def NbTetrasOfOrder(self, elementOrder):
1905 return self.mesh.NbTetrasOfOrder(elementOrder)
1907 ## Returns the number of hexahedrons in the mesh
1908 # @return an integer value
1909 # @ingroup l1_meshinfo
1911 return self.mesh.NbHexas()
1913 ## Returns the number of hexahedrons with the given order in the mesh
1914 # @param elementOrder the order of elements:
1915 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1916 # @return an integer value
1917 # @ingroup l1_meshinfo
1918 def NbHexasOfOrder(self, elementOrder):
1919 return self.mesh.NbHexasOfOrder(elementOrder)
1921 ## Returns the number of pyramids in the mesh
1922 # @return an integer value
1923 # @ingroup l1_meshinfo
1924 def NbPyramids(self):
1925 return self.mesh.NbPyramids()
1927 ## Returns the number of pyramids with the given order in the mesh
1928 # @param elementOrder the order of elements:
1929 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1930 # @return an integer value
1931 # @ingroup l1_meshinfo
1932 def NbPyramidsOfOrder(self, elementOrder):
1933 return self.mesh.NbPyramidsOfOrder(elementOrder)
1935 ## Returns the number of prisms in the mesh
1936 # @return an integer value
1937 # @ingroup l1_meshinfo
1939 return self.mesh.NbPrisms()
1941 ## Returns the number of prisms with the given order in the mesh
1942 # @param elementOrder the order of elements:
1943 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1944 # @return an integer value
1945 # @ingroup l1_meshinfo
1946 def NbPrismsOfOrder(self, elementOrder):
1947 return self.mesh.NbPrismsOfOrder(elementOrder)
1949 ## Returns the number of polyhedrons in the mesh
1950 # @return an integer value
1951 # @ingroup l1_meshinfo
1952 def NbPolyhedrons(self):
1953 return self.mesh.NbPolyhedrons()
1955 ## Returns the number of submeshes in the mesh
1956 # @return an integer value
1957 # @ingroup l1_meshinfo
1958 def NbSubMesh(self):
1959 return self.mesh.NbSubMesh()
1961 ## Returns the list of mesh elements IDs
1962 # @return the list of integer values
1963 # @ingroup l1_meshinfo
1964 def GetElementsId(self):
1965 return self.mesh.GetElementsId()
1967 ## Returns the list of IDs of mesh elements with the given type
1968 # @param elementType the required type of elements
1969 # @return list of integer values
1970 # @ingroup l1_meshinfo
1971 def GetElementsByType(self, elementType):
1972 return self.mesh.GetElementsByType(elementType)
1974 ## Returns the list of mesh nodes IDs
1975 # @return the list of integer values
1976 # @ingroup l1_meshinfo
1977 def GetNodesId(self):
1978 return self.mesh.GetNodesId()
1980 # Get the information about mesh elements:
1981 # ------------------------------------
1983 ## Returns the type of mesh element
1984 # @return the value from SMESH::ElementType enumeration
1985 # @ingroup l1_meshinfo
1986 def GetElementType(self, id, iselem):
1987 return self.mesh.GetElementType(id, iselem)
1989 ## Returns the geometric type of mesh element
1990 # @return the value from SMESH::EntityType enumeration
1991 # @ingroup l1_meshinfo
1992 def GetElementGeomType(self, id):
1993 return self.mesh.GetElementGeomType(id)
1995 ## Returns the list of submesh elements IDs
1996 # @param Shape a geom object(subshape) IOR
1997 # Shape must be the subshape of a ShapeToMesh()
1998 # @return the list of integer values
1999 # @ingroup l1_meshinfo
2000 def GetSubMeshElementsId(self, Shape):
2001 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2002 ShapeID = Shape.GetSubShapeIndices()[0]
2005 return self.mesh.GetSubMeshElementsId(ShapeID)
2007 ## Returns the list of submesh nodes IDs
2008 # @param Shape a geom object(subshape) IOR
2009 # Shape must be the subshape of a ShapeToMesh()
2010 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2011 # @return the list of integer values
2012 # @ingroup l1_meshinfo
2013 def GetSubMeshNodesId(self, Shape, all):
2014 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2015 ShapeID = Shape.GetSubShapeIndices()[0]
2018 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2020 ## Returns type of elements on given shape
2021 # @param Shape a geom object(subshape) IOR
2022 # Shape must be a subshape of a ShapeToMesh()
2023 # @return element type
2024 # @ingroup l1_meshinfo
2025 def GetSubMeshElementType(self, Shape):
2026 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2027 ShapeID = Shape.GetSubShapeIndices()[0]
2030 return self.mesh.GetSubMeshElementType(ShapeID)
2032 ## Gets the mesh description
2033 # @return string value
2034 # @ingroup l1_meshinfo
2036 return self.mesh.Dump()
2039 # Get the information about nodes and elements of a mesh by its IDs:
2040 # -----------------------------------------------------------
2042 ## Gets XYZ coordinates of a node
2043 # \n If there is no nodes for the given ID - returns an empty list
2044 # @return a list of double precision values
2045 # @ingroup l1_meshinfo
2046 def GetNodeXYZ(self, id):
2047 return self.mesh.GetNodeXYZ(id)
2049 ## Returns list of IDs of inverse elements for the given node
2050 # \n If there is no node for the given ID - returns an empty list
2051 # @return a list of integer values
2052 # @ingroup l1_meshinfo
2053 def GetNodeInverseElements(self, id):
2054 return self.mesh.GetNodeInverseElements(id)
2056 ## @brief Returns the position of a node on the shape
2057 # @return SMESH::NodePosition
2058 # @ingroup l1_meshinfo
2059 def GetNodePosition(self,NodeID):
2060 return self.mesh.GetNodePosition(NodeID)
2062 ## If the given element is a node, returns the ID of shape
2063 # \n If there is no node for the given ID - returns -1
2064 # @return an integer value
2065 # @ingroup l1_meshinfo
2066 def GetShapeID(self, id):
2067 return self.mesh.GetShapeID(id)
2069 ## Returns the ID of the result shape after
2070 # FindShape() from SMESH_MeshEditor for the given element
2071 # \n If there is no element for the given ID - returns -1
2072 # @return an integer value
2073 # @ingroup l1_meshinfo
2074 def GetShapeIDForElem(self,id):
2075 return self.mesh.GetShapeIDForElem(id)
2077 ## Returns the number of nodes for the given element
2078 # \n If there is no element for the given ID - returns -1
2079 # @return an integer value
2080 # @ingroup l1_meshinfo
2081 def GetElemNbNodes(self, id):
2082 return self.mesh.GetElemNbNodes(id)
2084 ## Returns the node ID the given index for the given element
2085 # \n If there is no element for the given ID - returns -1
2086 # \n If there is no node for the given index - returns -2
2087 # @return an integer value
2088 # @ingroup l1_meshinfo
2089 def GetElemNode(self, id, index):
2090 return self.mesh.GetElemNode(id, index)
2092 ## Returns the IDs of nodes of the given element
2093 # @return a list of integer values
2094 # @ingroup l1_meshinfo
2095 def GetElemNodes(self, id):
2096 return self.mesh.GetElemNodes(id)
2098 ## Returns true if the given node is the medium node in the given quadratic element
2099 # @ingroup l1_meshinfo
2100 def IsMediumNode(self, elementID, nodeID):
2101 return self.mesh.IsMediumNode(elementID, nodeID)
2103 ## Returns true if the given node is the medium node in one of quadratic elements
2104 # @ingroup l1_meshinfo
2105 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2106 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2108 ## Returns the number of edges for the given element
2109 # @ingroup l1_meshinfo
2110 def ElemNbEdges(self, id):
2111 return self.mesh.ElemNbEdges(id)
2113 ## Returns the number of faces for the given element
2114 # @ingroup l1_meshinfo
2115 def ElemNbFaces(self, id):
2116 return self.mesh.ElemNbFaces(id)
2118 ## Returns nodes of given face (counted from zero) for given volumic element.
2119 # @ingroup l1_meshinfo
2120 def GetElemFaceNodes(self,elemId, faceIndex):
2121 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2123 ## Returns an element based on all given nodes.
2124 # @ingroup l1_meshinfo
2125 def FindElementByNodes(self,nodes):
2126 return self.mesh.FindElementByNodes(nodes)
2128 ## Returns true if the given element is a polygon
2129 # @ingroup l1_meshinfo
2130 def IsPoly(self, id):
2131 return self.mesh.IsPoly(id)
2133 ## Returns true if the given element is quadratic
2134 # @ingroup l1_meshinfo
2135 def IsQuadratic(self, id):
2136 return self.mesh.IsQuadratic(id)
2138 ## Returns XYZ coordinates of the barycenter of the given element
2139 # \n If there is no element for the given ID - returns an empty list
2140 # @return a list of three double values
2141 # @ingroup l1_meshinfo
2142 def BaryCenter(self, id):
2143 return self.mesh.BaryCenter(id)
2146 # Mesh edition (SMESH_MeshEditor functionality):
2147 # ---------------------------------------------
2149 ## Removes the elements from the mesh by ids
2150 # @param IDsOfElements is a list of ids of elements to remove
2151 # @return True or False
2152 # @ingroup l2_modif_del
2153 def RemoveElements(self, IDsOfElements):
2154 return self.editor.RemoveElements(IDsOfElements)
2156 ## Removes nodes from mesh by ids
2157 # @param IDsOfNodes is a list of ids of nodes to remove
2158 # @return True or False
2159 # @ingroup l2_modif_del
2160 def RemoveNodes(self, IDsOfNodes):
2161 return self.editor.RemoveNodes(IDsOfNodes)
2163 ## Add a node to the mesh by coordinates
2164 # @return Id of the new node
2165 # @ingroup l2_modif_add
2166 def AddNode(self, x, y, z):
2167 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2168 self.mesh.SetParameters(Parameters)
2169 return self.editor.AddNode( x, y, z)
2171 ## Creates a 0D element on a node with given number.
2172 # @param IDOfNode the ID of node for creation of the element.
2173 # @return the Id of the new 0D element
2174 # @ingroup l2_modif_add
2175 def Add0DElement(self, IDOfNode):
2176 return self.editor.Add0DElement(IDOfNode)
2178 ## Creates a linear or quadratic edge (this is determined
2179 # by the number of given nodes).
2180 # @param IDsOfNodes the list of node IDs for creation of the element.
2181 # The order of nodes in this list should correspond to the description
2182 # of MED. \n This description is located by the following link:
2183 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2184 # @return the Id of the new edge
2185 # @ingroup l2_modif_add
2186 def AddEdge(self, IDsOfNodes):
2187 return self.editor.AddEdge(IDsOfNodes)
2189 ## Creates a linear or quadratic face (this is determined
2190 # by the number of given nodes).
2191 # @param IDsOfNodes the list of node IDs for creation of the element.
2192 # The order of nodes in this list should correspond to the description
2193 # of MED. \n This description is located by the following link:
2194 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2195 # @return the Id of the new face
2196 # @ingroup l2_modif_add
2197 def AddFace(self, IDsOfNodes):
2198 return self.editor.AddFace(IDsOfNodes)
2200 ## Adds a polygonal face to the mesh by the list of node IDs
2201 # @param IdsOfNodes the list of node IDs for creation of the element.
2202 # @return the Id of the new face
2203 # @ingroup l2_modif_add
2204 def AddPolygonalFace(self, IdsOfNodes):
2205 return self.editor.AddPolygonalFace(IdsOfNodes)
2207 ## Creates both simple and quadratic volume (this is determined
2208 # by the number of given nodes).
2209 # @param IDsOfNodes the list of node IDs for creation of the element.
2210 # The order of nodes in this list should correspond to the description
2211 # of MED. \n This description is located by the following link:
2212 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2213 # @return the Id of the new volumic element
2214 # @ingroup l2_modif_add
2215 def AddVolume(self, IDsOfNodes):
2216 return self.editor.AddVolume(IDsOfNodes)
2218 ## Creates a volume of many faces, giving nodes for each face.
2219 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2220 # @param Quantities the list of integer values, Quantities[i]
2221 # gives the quantity of nodes in face number i.
2222 # @return the Id of the new volumic element
2223 # @ingroup l2_modif_add
2224 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2225 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2227 ## Creates a volume of many faces, giving the IDs of the existing faces.
2228 # @param IdsOfFaces the list of face IDs for volume creation.
2230 # Note: The created volume will refer only to the nodes
2231 # of the given faces, not to the faces themselves.
2232 # @return the Id of the new volumic element
2233 # @ingroup l2_modif_add
2234 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2235 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2238 ## @brief Binds a node to a vertex
2239 # @param NodeID a node ID
2240 # @param Vertex a vertex or vertex ID
2241 # @return True if succeed else raises an exception
2242 # @ingroup l2_modif_add
2243 def SetNodeOnVertex(self, NodeID, Vertex):
2244 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2245 VertexID = Vertex.GetSubShapeIndices()[0]
2249 self.editor.SetNodeOnVertex(NodeID, VertexID)
2250 except SALOME.SALOME_Exception, inst:
2251 raise ValueError, inst.details.text
2255 ## @brief Stores the node position on an edge
2256 # @param NodeID a node ID
2257 # @param Edge an edge or edge ID
2258 # @param paramOnEdge a parameter on the edge where the node is located
2259 # @return True if succeed else raises an exception
2260 # @ingroup l2_modif_add
2261 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2262 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2263 EdgeID = Edge.GetSubShapeIndices()[0]
2267 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2268 except SALOME.SALOME_Exception, inst:
2269 raise ValueError, inst.details.text
2272 ## @brief Stores node position on a face
2273 # @param NodeID a node ID
2274 # @param Face a face or face ID
2275 # @param u U parameter on the face where the node is located
2276 # @param v V parameter on the face where the node is located
2277 # @return True if succeed else raises an exception
2278 # @ingroup l2_modif_add
2279 def SetNodeOnFace(self, NodeID, Face, u, v):
2280 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2281 FaceID = Face.GetSubShapeIndices()[0]
2285 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2286 except SALOME.SALOME_Exception, inst:
2287 raise ValueError, inst.details.text
2290 ## @brief Binds a node to a solid
2291 # @param NodeID a node ID
2292 # @param Solid a solid or solid ID
2293 # @return True if succeed else raises an exception
2294 # @ingroup l2_modif_add
2295 def SetNodeInVolume(self, NodeID, Solid):
2296 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2297 SolidID = Solid.GetSubShapeIndices()[0]
2301 self.editor.SetNodeInVolume(NodeID, SolidID)
2302 except SALOME.SALOME_Exception, inst:
2303 raise ValueError, inst.details.text
2306 ## @brief Bind an element to a shape
2307 # @param ElementID an element ID
2308 # @param Shape a shape or shape ID
2309 # @return True if succeed else raises an exception
2310 # @ingroup l2_modif_add
2311 def SetMeshElementOnShape(self, ElementID, Shape):
2312 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2313 ShapeID = Shape.GetSubShapeIndices()[0]
2317 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2318 except SALOME.SALOME_Exception, inst:
2319 raise ValueError, inst.details.text
2323 ## Moves the node with the given id
2324 # @param NodeID the id of the node
2325 # @param x a new X coordinate
2326 # @param y a new Y coordinate
2327 # @param z a new Z coordinate
2328 # @return True if succeed else False
2329 # @ingroup l2_modif_movenode
2330 def MoveNode(self, NodeID, x, y, z):
2331 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2332 self.mesh.SetParameters(Parameters)
2333 return self.editor.MoveNode(NodeID, x, y, z)
2335 ## Finds the node closest to a point and moves it to a point location
2336 # @param x the X coordinate of a point
2337 # @param y the Y coordinate of a point
2338 # @param z the Z coordinate of a point
2339 # @param NodeID if specified (>0), the node with this ID is moved,
2340 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2341 # @return the ID of a node
2342 # @ingroup l2_modif_throughp
2343 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2344 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2345 self.mesh.SetParameters(Parameters)
2346 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2348 ## Finds the node closest to a point
2349 # @param x the X coordinate of a point
2350 # @param y the Y coordinate of a point
2351 # @param z the Z coordinate of a point
2352 # @return the ID of a node
2353 # @ingroup l2_modif_throughp
2354 def FindNodeClosestTo(self, x, y, z):
2355 #preview = self.mesh.GetMeshEditPreviewer()
2356 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2357 return self.editor.FindNodeClosestTo(x, y, z)
2359 ## Finds the elements where a point lays IN or ON
2360 # @param x the X coordinate of a point
2361 # @param y the Y coordinate of a point
2362 # @param z the Z coordinate of a point
2363 # @param elementType type of elements to find (SMESH.ALL type
2364 # means elements of any type excluding nodes and 0D elements)
2365 # @return list of IDs of found elements
2366 # @ingroup l2_modif_throughp
2367 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2368 return self.editor.FindElementsByPoint(x, y, z, elementType)
2370 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2371 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2373 def GetPointState(self, x, y, z):
2374 return self.editor.GetPointState(x, y, z)
2376 ## Finds the node closest to a point and moves it to a point location
2377 # @param x the X coordinate of a point
2378 # @param y the Y coordinate of a point
2379 # @param z the Z coordinate of a point
2380 # @return the ID of a moved node
2381 # @ingroup l2_modif_throughp
2382 def MeshToPassThroughAPoint(self, x, y, z):
2383 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2385 ## Replaces two neighbour triangles sharing Node1-Node2 link
2386 # with the triangles built on the same 4 nodes but having other common link.
2387 # @param NodeID1 the ID of the first node
2388 # @param NodeID2 the ID of the second node
2389 # @return false if proper faces were not found
2390 # @ingroup l2_modif_invdiag
2391 def InverseDiag(self, NodeID1, NodeID2):
2392 return self.editor.InverseDiag(NodeID1, NodeID2)
2394 ## Replaces two neighbour triangles sharing Node1-Node2 link
2395 # with a quadrangle built on the same 4 nodes.
2396 # @param NodeID1 the ID of the first node
2397 # @param NodeID2 the ID of the second node
2398 # @return false if proper faces were not found
2399 # @ingroup l2_modif_unitetri
2400 def DeleteDiag(self, NodeID1, NodeID2):
2401 return self.editor.DeleteDiag(NodeID1, NodeID2)
2403 ## Reorients elements by ids
2404 # @param IDsOfElements if undefined reorients all mesh elements
2405 # @return True if succeed else False
2406 # @ingroup l2_modif_changori
2407 def Reorient(self, IDsOfElements=None):
2408 if IDsOfElements == None:
2409 IDsOfElements = self.GetElementsId()
2410 return self.editor.Reorient(IDsOfElements)
2412 ## Reorients all elements of the object
2413 # @param theObject mesh, submesh or group
2414 # @return True if succeed else False
2415 # @ingroup l2_modif_changori
2416 def ReorientObject(self, theObject):
2417 if ( isinstance( theObject, Mesh )):
2418 theObject = theObject.GetMesh()
2419 return self.editor.ReorientObject(theObject)
2421 ## Fuses the neighbouring triangles into quadrangles.
2422 # @param IDsOfElements The triangles to be fused,
2423 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2424 # @param MaxAngle is the maximum angle between element normals at which the fusion
2425 # is still performed; theMaxAngle is mesured in radians.
2426 # Also it could be a name of variable which defines angle in degrees.
2427 # @return TRUE in case of success, FALSE otherwise.
2428 # @ingroup l2_modif_unitetri
2429 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2431 if isinstance(MaxAngle,str):
2433 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2435 MaxAngle = DegreesToRadians(MaxAngle)
2436 if IDsOfElements == []:
2437 IDsOfElements = self.GetElementsId()
2438 self.mesh.SetParameters(Parameters)
2440 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2441 Functor = theCriterion
2443 Functor = self.smeshpyD.GetFunctor(theCriterion)
2444 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2446 ## Fuses the neighbouring triangles of the object into quadrangles
2447 # @param theObject is mesh, submesh or group
2448 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2449 # @param MaxAngle a max angle between element normals at which the fusion
2450 # is still performed; theMaxAngle is mesured in radians.
2451 # @return TRUE in case of success, FALSE otherwise.
2452 # @ingroup l2_modif_unitetri
2453 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2454 if ( isinstance( theObject, Mesh )):
2455 theObject = theObject.GetMesh()
2456 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2458 ## Splits quadrangles into triangles.
2459 # @param IDsOfElements the faces to be splitted.
2460 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2461 # @return TRUE in case of success, FALSE otherwise.
2462 # @ingroup l2_modif_cutquadr
2463 def QuadToTri (self, IDsOfElements, theCriterion):
2464 if IDsOfElements == []:
2465 IDsOfElements = self.GetElementsId()
2466 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2468 ## Splits quadrangles into triangles.
2469 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2470 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2471 # @return TRUE in case of success, FALSE otherwise.
2472 # @ingroup l2_modif_cutquadr
2473 def QuadToTriObject (self, theObject, theCriterion):
2474 if ( isinstance( theObject, Mesh )):
2475 theObject = theObject.GetMesh()
2476 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2478 ## Splits quadrangles into triangles.
2479 # @param IDsOfElements the faces to be splitted
2480 # @param Diag13 is used to choose a diagonal for splitting.
2481 # @return TRUE in case of success, FALSE otherwise.
2482 # @ingroup l2_modif_cutquadr
2483 def SplitQuad (self, IDsOfElements, Diag13):
2484 if IDsOfElements == []:
2485 IDsOfElements = self.GetElementsId()
2486 return self.editor.SplitQuad(IDsOfElements, Diag13)
2488 ## Splits quadrangles into triangles.
2489 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2490 # @param Diag13 is used to choose a diagonal for splitting.
2491 # @return TRUE in case of success, FALSE otherwise.
2492 # @ingroup l2_modif_cutquadr
2493 def SplitQuadObject (self, theObject, Diag13):
2494 if ( isinstance( theObject, Mesh )):
2495 theObject = theObject.GetMesh()
2496 return self.editor.SplitQuadObject(theObject, Diag13)
2498 ## Finds a better splitting of the given quadrangle.
2499 # @param IDOfQuad the ID of the quadrangle to be splitted.
2500 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2501 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2502 # diagonal is better, 0 if error occurs.
2503 # @ingroup l2_modif_cutquadr
2504 def BestSplit (self, IDOfQuad, theCriterion):
2505 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2507 ## Splits volumic elements into tetrahedrons
2508 # @param elemIDs either list of elements or mesh or group or submesh
2509 # @param method flags passing splitting method:
2510 # 1 - split the hexahedron into 5 tetrahedrons
2511 # 2 - split the hexahedron into 6 tetrahedrons
2512 # @ingroup l2_modif_cutquadr
2513 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2514 if isinstance( elemIDs, Mesh ):
2515 elemIDs = elemIDs.GetMesh()
2516 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2518 ## Splits quadrangle faces near triangular facets of volumes
2520 # @ingroup l1_auxiliary
2521 def SplitQuadsNearTriangularFacets(self):
2522 faces_array = self.GetElementsByType(SMESH.FACE)
2523 for face_id in faces_array:
2524 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2525 quad_nodes = self.mesh.GetElemNodes(face_id)
2526 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2527 isVolumeFound = False
2528 for node1_elem in node1_elems:
2529 if not isVolumeFound:
2530 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2531 nb_nodes = self.GetElemNbNodes(node1_elem)
2532 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2533 volume_elem = node1_elem
2534 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2535 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2536 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2537 isVolumeFound = True
2538 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2539 self.SplitQuad([face_id], False) # diagonal 2-4
2540 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2541 isVolumeFound = True
2542 self.SplitQuad([face_id], True) # diagonal 1-3
2543 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2544 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2545 isVolumeFound = True
2546 self.SplitQuad([face_id], True) # diagonal 1-3
2548 ## @brief Splits hexahedrons into tetrahedrons.
2550 # This operation uses pattern mapping functionality for splitting.
2551 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2552 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2553 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2554 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2555 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2556 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2557 # @return TRUE in case of success, FALSE otherwise.
2558 # @ingroup l1_auxiliary
2559 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2560 # Pattern: 5.---------.6
2565 # (0,0,1) 4.---------.7 * |
2572 # (0,0,0) 0.---------.3
2573 pattern_tetra = "!!! Nb of points: \n 8 \n\
2583 !!! Indices of points of 6 tetras: \n\
2591 pattern = self.smeshpyD.GetPattern()
2592 isDone = pattern.LoadFromFile(pattern_tetra)
2594 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2597 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2598 isDone = pattern.MakeMesh(self.mesh, False, False)
2599 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2601 # split quafrangle faces near triangular facets of volumes
2602 self.SplitQuadsNearTriangularFacets()
2606 ## @brief Split hexahedrons into prisms.
2608 # Uses the pattern mapping functionality for splitting.
2609 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2610 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2611 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2612 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2613 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2614 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2615 # @return TRUE in case of success, FALSE otherwise.
2616 # @ingroup l1_auxiliary
2617 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2618 # Pattern: 5.---------.6
2623 # (0,0,1) 4.---------.7 |
2630 # (0,0,0) 0.---------.3
2631 pattern_prism = "!!! Nb of points: \n 8 \n\
2641 !!! Indices of points of 2 prisms: \n\
2645 pattern = self.smeshpyD.GetPattern()
2646 isDone = pattern.LoadFromFile(pattern_prism)
2648 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2651 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2652 isDone = pattern.MakeMesh(self.mesh, False, False)
2653 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2655 # Splits quafrangle faces near triangular facets of volumes
2656 self.SplitQuadsNearTriangularFacets()
2660 ## Smoothes elements
2661 # @param IDsOfElements the list if ids of elements to smooth
2662 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2663 # Note that nodes built on edges and boundary nodes are always fixed.
2664 # @param MaxNbOfIterations the maximum number of iterations
2665 # @param MaxAspectRatio varies in range [1.0, inf]
2666 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2667 # @return TRUE in case of success, FALSE otherwise.
2668 # @ingroup l2_modif_smooth
2669 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2670 MaxNbOfIterations, MaxAspectRatio, Method):
2671 if IDsOfElements == []:
2672 IDsOfElements = self.GetElementsId()
2673 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2674 self.mesh.SetParameters(Parameters)
2675 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2676 MaxNbOfIterations, MaxAspectRatio, Method)
2678 ## Smoothes elements which belong to the given object
2679 # @param theObject the object to smooth
2680 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2681 # Note that nodes built on edges and boundary nodes are always fixed.
2682 # @param MaxNbOfIterations the maximum number of iterations
2683 # @param MaxAspectRatio varies in range [1.0, inf]
2684 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2685 # @return TRUE in case of success, FALSE otherwise.
2686 # @ingroup l2_modif_smooth
2687 def SmoothObject(self, theObject, IDsOfFixedNodes,
2688 MaxNbOfIterations, MaxAspectRatio, Method):
2689 if ( isinstance( theObject, Mesh )):
2690 theObject = theObject.GetMesh()
2691 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2692 MaxNbOfIterations, MaxAspectRatio, Method)
2694 ## Parametrically smoothes the given elements
2695 # @param IDsOfElements the list if ids of elements to smooth
2696 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2697 # Note that nodes built on edges and boundary nodes are always fixed.
2698 # @param MaxNbOfIterations the maximum number of iterations
2699 # @param MaxAspectRatio varies in range [1.0, inf]
2700 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2701 # @return TRUE in case of success, FALSE otherwise.
2702 # @ingroup l2_modif_smooth
2703 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2704 MaxNbOfIterations, MaxAspectRatio, Method):
2705 if IDsOfElements == []:
2706 IDsOfElements = self.GetElementsId()
2707 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2708 self.mesh.SetParameters(Parameters)
2709 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2710 MaxNbOfIterations, MaxAspectRatio, Method)
2712 ## Parametrically smoothes the elements which belong to the given object
2713 # @param theObject the object to smooth
2714 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2715 # Note that nodes built on edges and boundary nodes are always fixed.
2716 # @param MaxNbOfIterations the maximum number of iterations
2717 # @param MaxAspectRatio varies in range [1.0, inf]
2718 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2719 # @return TRUE in case of success, FALSE otherwise.
2720 # @ingroup l2_modif_smooth
2721 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2722 MaxNbOfIterations, MaxAspectRatio, Method):
2723 if ( isinstance( theObject, Mesh )):
2724 theObject = theObject.GetMesh()
2725 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2726 MaxNbOfIterations, MaxAspectRatio, Method)
2728 ## Converts the mesh to quadratic, deletes old elements, replacing
2729 # them with quadratic with the same id.
2730 # @ingroup l2_modif_tofromqu
2731 def ConvertToQuadratic(self, theForce3d):
2732 self.editor.ConvertToQuadratic(theForce3d)
2734 ## Converts the mesh from quadratic to ordinary,
2735 # deletes old quadratic elements, \n replacing
2736 # them with ordinary mesh elements with the same id.
2737 # @return TRUE in case of success, FALSE otherwise.
2738 # @ingroup l2_modif_tofromqu
2739 def ConvertFromQuadratic(self):
2740 return self.editor.ConvertFromQuadratic()
2742 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2743 # @return TRUE if operation has been completed successfully, FALSE otherwise
2744 # @ingroup l2_modif_edit
2745 def Make2DMeshFrom3D(self):
2746 return self.editor. Make2DMeshFrom3D()
2748 ## Renumber mesh nodes
2749 # @ingroup l2_modif_renumber
2750 def RenumberNodes(self):
2751 self.editor.RenumberNodes()
2753 ## Renumber mesh elements
2754 # @ingroup l2_modif_renumber
2755 def RenumberElements(self):
2756 self.editor.RenumberElements()
2758 ## Generates new elements by rotation of the elements around the axis
2759 # @param IDsOfElements the list of ids of elements to sweep
2760 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2761 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2762 # @param NbOfSteps the number of steps
2763 # @param Tolerance tolerance
2764 # @param MakeGroups forces the generation of new groups from existing ones
2765 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2766 # of all steps, else - size of each step
2767 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2768 # @ingroup l2_modif_extrurev
2769 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2770 MakeGroups=False, TotalAngle=False):
2772 if isinstance(AngleInRadians,str):
2774 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2776 AngleInRadians = DegreesToRadians(AngleInRadians)
2777 if IDsOfElements == []:
2778 IDsOfElements = self.GetElementsId()
2779 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2780 Axis = self.smeshpyD.GetAxisStruct(Axis)
2781 Axis,AxisParameters = ParseAxisStruct(Axis)
2782 if TotalAngle and NbOfSteps:
2783 AngleInRadians /= NbOfSteps
2784 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2785 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2786 self.mesh.SetParameters(Parameters)
2788 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2789 AngleInRadians, NbOfSteps, Tolerance)
2790 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2793 ## Generates new elements by rotation of the elements of object around the axis
2794 # @param theObject object which elements should be sweeped
2795 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2796 # @param AngleInRadians the angle of Rotation
2797 # @param NbOfSteps number of steps
2798 # @param Tolerance tolerance
2799 # @param MakeGroups forces the generation of new groups from existing ones
2800 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2801 # of all steps, else - size of each step
2802 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2803 # @ingroup l2_modif_extrurev
2804 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2805 MakeGroups=False, TotalAngle=False):
2807 if isinstance(AngleInRadians,str):
2809 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2811 AngleInRadians = DegreesToRadians(AngleInRadians)
2812 if ( isinstance( theObject, Mesh )):
2813 theObject = theObject.GetMesh()
2814 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2815 Axis = self.smeshpyD.GetAxisStruct(Axis)
2816 Axis,AxisParameters = ParseAxisStruct(Axis)
2817 if TotalAngle and NbOfSteps:
2818 AngleInRadians /= NbOfSteps
2819 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2820 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2821 self.mesh.SetParameters(Parameters)
2823 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2824 NbOfSteps, Tolerance)
2825 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2828 ## Generates new elements by rotation of the elements of object around the axis
2829 # @param theObject object which elements should be sweeped
2830 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2831 # @param AngleInRadians the angle of Rotation
2832 # @param NbOfSteps number of steps
2833 # @param Tolerance tolerance
2834 # @param MakeGroups forces the generation of new groups from existing ones
2835 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2836 # of all steps, else - size of each step
2837 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2838 # @ingroup l2_modif_extrurev
2839 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2840 MakeGroups=False, TotalAngle=False):
2842 if isinstance(AngleInRadians,str):
2844 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2846 AngleInRadians = DegreesToRadians(AngleInRadians)
2847 if ( isinstance( theObject, Mesh )):
2848 theObject = theObject.GetMesh()
2849 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2850 Axis = self.smeshpyD.GetAxisStruct(Axis)
2851 Axis,AxisParameters = ParseAxisStruct(Axis)
2852 if TotalAngle and NbOfSteps:
2853 AngleInRadians /= NbOfSteps
2854 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2855 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2856 self.mesh.SetParameters(Parameters)
2858 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2859 NbOfSteps, Tolerance)
2860 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2863 ## Generates new elements by rotation of the elements of object around the axis
2864 # @param theObject object which elements should be sweeped
2865 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2866 # @param AngleInRadians the angle of Rotation
2867 # @param NbOfSteps number of steps
2868 # @param Tolerance tolerance
2869 # @param MakeGroups forces the generation of new groups from existing ones
2870 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2871 # of all steps, else - size of each step
2872 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2873 # @ingroup l2_modif_extrurev
2874 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2875 MakeGroups=False, TotalAngle=False):
2877 if isinstance(AngleInRadians,str):
2879 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2881 AngleInRadians = DegreesToRadians(AngleInRadians)
2882 if ( isinstance( theObject, Mesh )):
2883 theObject = theObject.GetMesh()
2884 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2885 Axis = self.smeshpyD.GetAxisStruct(Axis)
2886 Axis,AxisParameters = ParseAxisStruct(Axis)
2887 if TotalAngle and NbOfSteps:
2888 AngleInRadians /= NbOfSteps
2889 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2890 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2891 self.mesh.SetParameters(Parameters)
2893 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2894 NbOfSteps, Tolerance)
2895 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2898 ## Generates new elements by extrusion of the elements with given ids
2899 # @param IDsOfElements the list of elements ids for extrusion
2900 # @param StepVector vector, defining the direction and value of extrusion
2901 # @param NbOfSteps the number of steps
2902 # @param MakeGroups forces the generation of new groups from existing ones
2903 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2904 # @ingroup l2_modif_extrurev
2905 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2906 if IDsOfElements == []:
2907 IDsOfElements = self.GetElementsId()
2908 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2909 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2910 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2911 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2912 Parameters = StepVectorParameters + var_separator + Parameters
2913 self.mesh.SetParameters(Parameters)
2915 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2916 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2919 ## Generates new elements by extrusion of the elements with given ids
2920 # @param IDsOfElements is ids of elements
2921 # @param StepVector vector, defining the direction and value of extrusion
2922 # @param NbOfSteps the number of steps
2923 # @param ExtrFlags sets flags for extrusion
2924 # @param SewTolerance uses for comparing locations of nodes if flag
2925 # EXTRUSION_FLAG_SEW is set
2926 # @param MakeGroups forces the generation of new groups from existing ones
2927 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2928 # @ingroup l2_modif_extrurev
2929 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2930 ExtrFlags, SewTolerance, MakeGroups=False):
2931 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2932 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2934 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2935 ExtrFlags, SewTolerance)
2936 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2937 ExtrFlags, SewTolerance)
2940 ## Generates new elements by extrusion of the elements which belong to the object
2941 # @param theObject the object which elements should be processed
2942 # @param StepVector vector, defining the direction and value of extrusion
2943 # @param NbOfSteps the number of steps
2944 # @param MakeGroups forces the generation of new groups from existing ones
2945 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2946 # @ingroup l2_modif_extrurev
2947 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2948 if ( isinstance( theObject, Mesh )):
2949 theObject = theObject.GetMesh()
2950 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2951 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2952 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2953 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2954 Parameters = StepVectorParameters + var_separator + Parameters
2955 self.mesh.SetParameters(Parameters)
2957 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2958 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2961 ## Generates new elements by extrusion of the elements which belong to the object
2962 # @param theObject object which elements should be processed
2963 # @param StepVector vector, defining the direction and value of extrusion
2964 # @param NbOfSteps the number of steps
2965 # @param MakeGroups to generate new groups from existing ones
2966 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2967 # @ingroup l2_modif_extrurev
2968 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2969 if ( isinstance( theObject, Mesh )):
2970 theObject = theObject.GetMesh()
2971 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2972 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2973 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2974 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2975 Parameters = StepVectorParameters + var_separator + Parameters
2976 self.mesh.SetParameters(Parameters)
2978 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2979 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2982 ## Generates new elements by extrusion of the elements which belong to the object
2983 # @param theObject object which elements should be processed
2984 # @param StepVector vector, defining the direction and value of extrusion
2985 # @param NbOfSteps the number of steps
2986 # @param MakeGroups forces the generation of new groups from existing ones
2987 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2988 # @ingroup l2_modif_extrurev
2989 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2990 if ( isinstance( theObject, Mesh )):
2991 theObject = theObject.GetMesh()
2992 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2993 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2994 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2995 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2996 Parameters = StepVectorParameters + var_separator + Parameters
2997 self.mesh.SetParameters(Parameters)
2999 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3000 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3005 ## Generates new elements by extrusion of the given elements
3006 # The path of extrusion must be a meshed edge.
3007 # @param Base mesh or list of ids of elements for extrusion
3008 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3009 # @param NodeStart the start node from Path. Defines the direction of extrusion
3010 # @param HasAngles allows the shape to be rotated around the path
3011 # to get the resulting mesh in a helical fashion
3012 # @param Angles list of angles in radians
3013 # @param LinearVariation forces the computation of rotation angles as linear
3014 # variation of the given Angles along path steps
3015 # @param HasRefPoint allows using the reference point
3016 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3017 # The User can specify any point as the Reference Point.
3018 # @param MakeGroups forces the generation of new groups from existing ones
3019 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3020 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3021 # only SMESH::Extrusion_Error otherwise
3022 # @ingroup l2_modif_extrurev
3023 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3024 HasAngles, Angles, LinearVariation,
3025 HasRefPoint, RefPoint, MakeGroups, ElemType):
3026 Angles,AnglesParameters = ParseAngles(Angles)
3027 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3028 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3029 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3031 Parameters = AnglesParameters + var_separator + RefPointParameters
3032 self.mesh.SetParameters(Parameters)
3034 if isinstance(Base,list):
3036 if Base == []: IDsOfElements = self.GetElementsId()
3037 else: IDsOfElements = Base
3038 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3039 HasAngles, Angles, LinearVariation,
3040 HasRefPoint, RefPoint, MakeGroups, ElemType)
3042 if isinstance(Base,Mesh):
3043 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3044 HasAngles, Angles, LinearVariation,
3045 HasRefPoint, RefPoint, MakeGroups, ElemType)
3047 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3050 ## Generates new elements by extrusion of the given elements
3051 # The path of extrusion must be a meshed edge.
3052 # @param IDsOfElements ids of elements
3053 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3054 # @param PathShape shape(edge) defines the sub-mesh for the path
3055 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3056 # @param HasAngles allows the shape to be rotated around the path
3057 # to get the resulting mesh in a helical fashion
3058 # @param Angles list of angles in radians
3059 # @param HasRefPoint allows using the reference point
3060 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3061 # The User can specify any point as the Reference Point.
3062 # @param MakeGroups forces the generation of new groups from existing ones
3063 # @param LinearVariation forces the computation of rotation angles as linear
3064 # variation of the given Angles along path steps
3065 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3066 # only SMESH::Extrusion_Error otherwise
3067 # @ingroup l2_modif_extrurev
3068 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3069 HasAngles, Angles, HasRefPoint, RefPoint,
3070 MakeGroups=False, LinearVariation=False):
3071 Angles,AnglesParameters = ParseAngles(Angles)
3072 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3073 if IDsOfElements == []:
3074 IDsOfElements = self.GetElementsId()
3075 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3076 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3078 if ( isinstance( PathMesh, Mesh )):
3079 PathMesh = PathMesh.GetMesh()
3080 if HasAngles and Angles and LinearVariation:
3081 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3083 Parameters = AnglesParameters + var_separator + RefPointParameters
3084 self.mesh.SetParameters(Parameters)
3086 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3087 PathShape, NodeStart, HasAngles,
3088 Angles, HasRefPoint, RefPoint)
3089 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3090 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3092 ## Generates new elements by extrusion of the elements which belong to the object
3093 # The path of extrusion must be a meshed edge.
3094 # @param theObject the object which elements should be processed
3095 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3096 # @param PathShape shape(edge) defines the sub-mesh for the path
3097 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3098 # @param HasAngles allows the shape to be rotated around the path
3099 # to get the resulting mesh in a helical fashion
3100 # @param Angles list of angles
3101 # @param HasRefPoint allows using the reference point
3102 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3103 # The User can specify any point as the Reference Point.
3104 # @param MakeGroups forces the generation of new groups from existing ones
3105 # @param LinearVariation forces the computation of rotation angles as linear
3106 # variation of the given Angles along path steps
3107 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3108 # only SMESH::Extrusion_Error otherwise
3109 # @ingroup l2_modif_extrurev
3110 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3111 HasAngles, Angles, HasRefPoint, RefPoint,
3112 MakeGroups=False, LinearVariation=False):
3113 Angles,AnglesParameters = ParseAngles(Angles)
3114 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3115 if ( isinstance( theObject, Mesh )):
3116 theObject = theObject.GetMesh()
3117 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3118 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3119 if ( isinstance( PathMesh, Mesh )):
3120 PathMesh = PathMesh.GetMesh()
3121 if HasAngles and Angles and LinearVariation:
3122 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3124 Parameters = AnglesParameters + var_separator + RefPointParameters
3125 self.mesh.SetParameters(Parameters)
3127 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3128 PathShape, NodeStart, HasAngles,
3129 Angles, HasRefPoint, RefPoint)
3130 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3131 NodeStart, HasAngles, Angles, HasRefPoint,
3134 ## Generates new elements by extrusion of the elements which belong to the object
3135 # The path of extrusion must be a meshed edge.
3136 # @param theObject the object which elements should be processed
3137 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3138 # @param PathShape shape(edge) defines the sub-mesh for the path
3139 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3140 # @param HasAngles allows the shape to be rotated around the path
3141 # to get the resulting mesh in a helical fashion
3142 # @param Angles list of angles
3143 # @param HasRefPoint allows using the reference point
3144 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3145 # The User can specify any point as the Reference Point.
3146 # @param MakeGroups forces the generation of new groups from existing ones
3147 # @param LinearVariation forces the computation of rotation angles as linear
3148 # variation of the given Angles along path steps
3149 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3150 # only SMESH::Extrusion_Error otherwise
3151 # @ingroup l2_modif_extrurev
3152 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3153 HasAngles, Angles, HasRefPoint, RefPoint,
3154 MakeGroups=False, LinearVariation=False):
3155 Angles,AnglesParameters = ParseAngles(Angles)
3156 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3157 if ( isinstance( theObject, Mesh )):
3158 theObject = theObject.GetMesh()
3159 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3160 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3161 if ( isinstance( PathMesh, Mesh )):
3162 PathMesh = PathMesh.GetMesh()
3163 if HasAngles and Angles and LinearVariation:
3164 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3166 Parameters = AnglesParameters + var_separator + RefPointParameters
3167 self.mesh.SetParameters(Parameters)
3169 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3170 PathShape, NodeStart, HasAngles,
3171 Angles, HasRefPoint, RefPoint)
3172 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3173 NodeStart, HasAngles, Angles, HasRefPoint,
3176 ## Generates new elements by extrusion of the elements which belong to the object
3177 # The path of extrusion must be a meshed edge.
3178 # @param theObject the object which elements should be processed
3179 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3180 # @param PathShape shape(edge) defines the sub-mesh for the path
3181 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3182 # @param HasAngles allows the shape to be rotated around the path
3183 # to get the resulting mesh in a helical fashion
3184 # @param Angles list of angles
3185 # @param HasRefPoint allows using the reference point
3186 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3187 # The User can specify any point as the Reference Point.
3188 # @param MakeGroups forces the generation of new groups from existing ones
3189 # @param LinearVariation forces the computation of rotation angles as linear
3190 # variation of the given Angles along path steps
3191 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3192 # only SMESH::Extrusion_Error otherwise
3193 # @ingroup l2_modif_extrurev
3194 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3195 HasAngles, Angles, HasRefPoint, RefPoint,
3196 MakeGroups=False, LinearVariation=False):
3197 Angles,AnglesParameters = ParseAngles(Angles)
3198 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3199 if ( isinstance( theObject, Mesh )):
3200 theObject = theObject.GetMesh()
3201 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3202 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3203 if ( isinstance( PathMesh, Mesh )):
3204 PathMesh = PathMesh.GetMesh()
3205 if HasAngles and Angles and LinearVariation:
3206 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3208 Parameters = AnglesParameters + var_separator + RefPointParameters
3209 self.mesh.SetParameters(Parameters)
3211 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3212 PathShape, NodeStart, HasAngles,
3213 Angles, HasRefPoint, RefPoint)
3214 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3215 NodeStart, HasAngles, Angles, HasRefPoint,
3218 ## Creates a symmetrical copy of mesh elements
3219 # @param IDsOfElements list of elements ids
3220 # @param Mirror is AxisStruct or geom object(point, line, plane)
3221 # @param theMirrorType is POINT, AXIS or PLANE
3222 # If the Mirror is a geom object this parameter is unnecessary
3223 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3224 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3225 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3226 # @ingroup l2_modif_trsf
3227 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3228 if IDsOfElements == []:
3229 IDsOfElements = self.GetElementsId()
3230 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3231 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3232 Mirror,Parameters = ParseAxisStruct(Mirror)
3233 self.mesh.SetParameters(Parameters)
3234 if Copy and MakeGroups:
3235 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3236 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3239 ## Creates a new mesh by a symmetrical copy of mesh elements
3240 # @param IDsOfElements the list of elements ids
3241 # @param Mirror is AxisStruct or geom object (point, line, plane)
3242 # @param theMirrorType is POINT, AXIS or PLANE
3243 # If the Mirror is a geom object this parameter is unnecessary
3244 # @param MakeGroups to generate new groups from existing ones
3245 # @param NewMeshName a name of the new mesh to create
3246 # @return instance of Mesh class
3247 # @ingroup l2_modif_trsf
3248 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3249 if IDsOfElements == []:
3250 IDsOfElements = self.GetElementsId()
3251 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3252 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3253 Mirror,Parameters = ParseAxisStruct(Mirror)
3254 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3255 MakeGroups, NewMeshName)
3256 mesh.SetParameters(Parameters)
3257 return Mesh(self.smeshpyD,self.geompyD,mesh)
3259 ## Creates a symmetrical copy of the object
3260 # @param theObject mesh, submesh or group
3261 # @param Mirror AxisStruct or geom object (point, line, plane)
3262 # @param theMirrorType is POINT, AXIS or PLANE
3263 # If the Mirror is a geom object this parameter is unnecessary
3264 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3265 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3266 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3267 # @ingroup l2_modif_trsf
3268 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3269 if ( isinstance( theObject, Mesh )):
3270 theObject = theObject.GetMesh()
3271 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3272 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3273 Mirror,Parameters = ParseAxisStruct(Mirror)
3274 self.mesh.SetParameters(Parameters)
3275 if Copy and MakeGroups:
3276 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3277 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3280 ## Creates a new mesh by a symmetrical copy of the object
3281 # @param theObject mesh, submesh or group
3282 # @param Mirror AxisStruct or geom object (point, line, plane)
3283 # @param theMirrorType POINT, AXIS or PLANE
3284 # If the Mirror is a geom object this parameter is unnecessary
3285 # @param MakeGroups forces the generation of new groups from existing ones
3286 # @param NewMeshName the name of the new mesh to create
3287 # @return instance of Mesh class
3288 # @ingroup l2_modif_trsf
3289 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3290 if ( isinstance( theObject, Mesh )):
3291 theObject = theObject.GetMesh()
3292 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3293 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3294 Mirror,Parameters = ParseAxisStruct(Mirror)
3295 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3296 MakeGroups, NewMeshName)
3297 mesh.SetParameters(Parameters)
3298 return Mesh( self.smeshpyD,self.geompyD,mesh )
3300 ## Translates the elements
3301 # @param IDsOfElements list of elements ids
3302 # @param Vector the direction of translation (DirStruct or vector)
3303 # @param Copy allows copying the translated elements
3304 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3305 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3306 # @ingroup l2_modif_trsf
3307 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3308 if IDsOfElements == []:
3309 IDsOfElements = self.GetElementsId()
3310 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3311 Vector = self.smeshpyD.GetDirStruct(Vector)
3312 Vector,Parameters = ParseDirStruct(Vector)
3313 self.mesh.SetParameters(Parameters)
3314 if Copy and MakeGroups:
3315 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3316 self.editor.Translate(IDsOfElements, Vector, Copy)
3319 ## Creates a new mesh of translated elements
3320 # @param IDsOfElements list of elements ids
3321 # @param Vector the direction of translation (DirStruct or vector)
3322 # @param MakeGroups forces the generation of new groups from existing ones
3323 # @param NewMeshName the name of the newly created mesh
3324 # @return instance of Mesh class
3325 # @ingroup l2_modif_trsf
3326 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3327 if IDsOfElements == []:
3328 IDsOfElements = self.GetElementsId()
3329 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3330 Vector = self.smeshpyD.GetDirStruct(Vector)
3331 Vector,Parameters = ParseDirStruct(Vector)
3332 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3333 mesh.SetParameters(Parameters)
3334 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3336 ## Translates the object
3337 # @param theObject the object to translate (mesh, submesh, or group)
3338 # @param Vector direction of translation (DirStruct or geom vector)
3339 # @param Copy allows copying the translated elements
3340 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3341 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3342 # @ingroup l2_modif_trsf
3343 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3344 if ( isinstance( theObject, Mesh )):
3345 theObject = theObject.GetMesh()
3346 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3347 Vector = self.smeshpyD.GetDirStruct(Vector)
3348 Vector,Parameters = ParseDirStruct(Vector)
3349 self.mesh.SetParameters(Parameters)
3350 if Copy and MakeGroups:
3351 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3352 self.editor.TranslateObject(theObject, Vector, Copy)
3355 ## Creates a new mesh from the translated object
3356 # @param theObject the object to translate (mesh, submesh, or group)
3357 # @param Vector the direction of translation (DirStruct or geom vector)
3358 # @param MakeGroups forces the generation of new groups from existing ones
3359 # @param NewMeshName the name of the newly created mesh
3360 # @return instance of Mesh class
3361 # @ingroup l2_modif_trsf
3362 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3363 if (isinstance(theObject, Mesh)):
3364 theObject = theObject.GetMesh()
3365 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3366 Vector = self.smeshpyD.GetDirStruct(Vector)
3367 Vector,Parameters = ParseDirStruct(Vector)
3368 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3369 mesh.SetParameters(Parameters)
3370 return Mesh( self.smeshpyD, self.geompyD, mesh )
3374 ## Scales the object
3375 # @param theObject - the object to translate (mesh, submesh, or group)
3376 # @param thePoint - base point for scale
3377 # @param theScaleFact - scale factors for axises
3378 # @param Copy - allows copying the translated elements
3379 # @param MakeGroups - forces the generation of new groups from existing
3381 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3382 # empty list otherwise
3383 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3384 if ( isinstance( theObject, Mesh )):
3385 theObject = theObject.GetMesh()
3386 if ( isinstance( theObject, list )):
3387 theObject = self.editor.MakeIDSource(theObject)
3389 thePoint, Parameters = ParsePointStruct(thePoint)
3390 self.mesh.SetParameters(Parameters)
3392 if Copy and MakeGroups:
3393 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3394 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3397 ## Creates a new mesh from the translated object
3398 # @param theObject - the object to translate (mesh, submesh, or group)
3399 # @param thePoint - base point for scale
3400 # @param theScaleFact - scale factors for axises
3401 # @param MakeGroups - forces the generation of new groups from existing ones
3402 # @param NewMeshName - the name of the newly created mesh
3403 # @return instance of Mesh class
3404 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3405 if (isinstance(theObject, Mesh)):
3406 theObject = theObject.GetMesh()
3407 if ( isinstance( theObject, list )):
3408 theObject = self.editor.MakeIDSource(theObject)
3410 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3411 MakeGroups, NewMeshName)
3412 #mesh.SetParameters(Parameters)
3413 return Mesh( self.smeshpyD, self.geompyD, mesh )
3417 ## Rotates the elements
3418 # @param IDsOfElements list of elements ids
3419 # @param Axis the axis of rotation (AxisStruct or geom line)
3420 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3421 # @param Copy allows copying the rotated elements
3422 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3423 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3424 # @ingroup l2_modif_trsf
3425 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3427 if isinstance(AngleInRadians,str):
3429 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3431 AngleInRadians = DegreesToRadians(AngleInRadians)
3432 if IDsOfElements == []:
3433 IDsOfElements = self.GetElementsId()
3434 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3435 Axis = self.smeshpyD.GetAxisStruct(Axis)
3436 Axis,AxisParameters = ParseAxisStruct(Axis)
3437 Parameters = AxisParameters + var_separator + Parameters
3438 self.mesh.SetParameters(Parameters)
3439 if Copy and MakeGroups:
3440 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3441 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3444 ## Creates a new mesh of rotated elements
3445 # @param IDsOfElements list of element ids
3446 # @param Axis the axis of rotation (AxisStruct or geom line)
3447 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3448 # @param MakeGroups forces the generation of new groups from existing ones
3449 # @param NewMeshName the name of the newly created mesh
3450 # @return instance of Mesh class
3451 # @ingroup l2_modif_trsf
3452 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3454 if isinstance(AngleInRadians,str):
3456 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3458 AngleInRadians = DegreesToRadians(AngleInRadians)
3459 if IDsOfElements == []:
3460 IDsOfElements = self.GetElementsId()
3461 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3462 Axis = self.smeshpyD.GetAxisStruct(Axis)
3463 Axis,AxisParameters = ParseAxisStruct(Axis)
3464 Parameters = AxisParameters + var_separator + Parameters
3465 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3466 MakeGroups, NewMeshName)
3467 mesh.SetParameters(Parameters)
3468 return Mesh( self.smeshpyD, self.geompyD, mesh )
3470 ## Rotates the object
3471 # @param theObject the object to rotate( mesh, submesh, or group)
3472 # @param Axis the axis of rotation (AxisStruct or geom line)
3473 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3474 # @param Copy allows copying the rotated elements
3475 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3476 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3477 # @ingroup l2_modif_trsf
3478 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3480 if isinstance(AngleInRadians,str):
3482 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3484 AngleInRadians = DegreesToRadians(AngleInRadians)
3485 if (isinstance(theObject, Mesh)):
3486 theObject = theObject.GetMesh()
3487 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3488 Axis = self.smeshpyD.GetAxisStruct(Axis)
3489 Axis,AxisParameters = ParseAxisStruct(Axis)
3490 Parameters = AxisParameters + ":" + Parameters
3491 self.mesh.SetParameters(Parameters)
3492 if Copy and MakeGroups:
3493 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3494 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3497 ## Creates a new mesh from the rotated object
3498 # @param theObject the object to rotate (mesh, submesh, or group)
3499 # @param Axis the axis of rotation (AxisStruct or geom line)
3500 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3501 # @param MakeGroups forces the generation of new groups from existing ones
3502 # @param NewMeshName the name of the newly created mesh
3503 # @return instance of Mesh class
3504 # @ingroup l2_modif_trsf
3505 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3507 if isinstance(AngleInRadians,str):
3509 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3511 AngleInRadians = DegreesToRadians(AngleInRadians)
3512 if (isinstance( theObject, Mesh )):
3513 theObject = theObject.GetMesh()
3514 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3515 Axis = self.smeshpyD.GetAxisStruct(Axis)
3516 Axis,AxisParameters = ParseAxisStruct(Axis)
3517 Parameters = AxisParameters + ":" + Parameters
3518 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3519 MakeGroups, NewMeshName)
3520 mesh.SetParameters(Parameters)
3521 return Mesh( self.smeshpyD, self.geompyD, mesh )
3523 ## Finds groups of ajacent nodes within Tolerance.
3524 # @param Tolerance the value of tolerance
3525 # @return the list of groups of nodes
3526 # @ingroup l2_modif_trsf
3527 def FindCoincidentNodes (self, Tolerance):
3528 return self.editor.FindCoincidentNodes(Tolerance)
3530 ## Finds groups of ajacent nodes within Tolerance.
3531 # @param Tolerance the value of tolerance
3532 # @param SubMeshOrGroup SubMesh or Group
3533 # @return the list of groups of nodes
3534 # @ingroup l2_modif_trsf
3535 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3536 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3539 # @param GroupsOfNodes the list of groups of nodes
3540 # @ingroup l2_modif_trsf
3541 def MergeNodes (self, GroupsOfNodes):
3542 self.editor.MergeNodes(GroupsOfNodes)
3544 ## Finds the elements built on the same nodes.
3545 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3546 # @return a list of groups of equal elements
3547 # @ingroup l2_modif_trsf
3548 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3549 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3550 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3551 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3553 ## Merges elements in each given group.
3554 # @param GroupsOfElementsID groups of elements for merging
3555 # @ingroup l2_modif_trsf
3556 def MergeElements(self, GroupsOfElementsID):
3557 self.editor.MergeElements(GroupsOfElementsID)
3559 ## Leaves one element and removes all other elements built on the same nodes.
3560 # @ingroup l2_modif_trsf
3561 def MergeEqualElements(self):
3562 self.editor.MergeEqualElements()
3564 ## Sews free borders
3565 # @return SMESH::Sew_Error
3566 # @ingroup l2_modif_trsf
3567 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3568 FirstNodeID2, SecondNodeID2, LastNodeID2,
3569 CreatePolygons, CreatePolyedrs):
3570 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3571 FirstNodeID2, SecondNodeID2, LastNodeID2,
3572 CreatePolygons, CreatePolyedrs)
3574 ## Sews conform free borders
3575 # @return SMESH::Sew_Error
3576 # @ingroup l2_modif_trsf
3577 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3578 FirstNodeID2, SecondNodeID2):
3579 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3580 FirstNodeID2, SecondNodeID2)
3582 ## Sews border to side
3583 # @return SMESH::Sew_Error
3584 # @ingroup l2_modif_trsf
3585 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3586 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3587 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3588 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3590 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3591 # merged with the nodes of elements of Side2.
3592 # The number of elements in theSide1 and in theSide2 must be
3593 # equal and they should have similar nodal connectivity.
3594 # The nodes to merge should belong to side borders and
3595 # the first node should be linked to the second.
3596 # @return SMESH::Sew_Error
3597 # @ingroup l2_modif_trsf
3598 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3599 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3600 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3601 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3602 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3603 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3605 ## Sets new nodes for the given element.
3606 # @param ide the element id
3607 # @param newIDs nodes ids
3608 # @return If the number of nodes does not correspond to the type of element - returns false
3609 # @ingroup l2_modif_edit
3610 def ChangeElemNodes(self, ide, newIDs):
3611 return self.editor.ChangeElemNodes(ide, newIDs)
3613 ## If during the last operation of MeshEditor some nodes were
3614 # created, this method returns the list of their IDs, \n
3615 # if new nodes were not created - returns empty list
3616 # @return the list of integer values (can be empty)
3617 # @ingroup l1_auxiliary
3618 def GetLastCreatedNodes(self):
3619 return self.editor.GetLastCreatedNodes()
3621 ## If during the last operation of MeshEditor some elements were
3622 # created this method returns the list of their IDs, \n
3623 # if new elements were not created - returns empty list
3624 # @return the list of integer values (can be empty)
3625 # @ingroup l1_auxiliary
3626 def GetLastCreatedElems(self):
3627 return self.editor.GetLastCreatedElems()
3629 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3630 # @param theNodes identifiers of nodes to be doubled
3631 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3632 # nodes. If list of element identifiers is empty then nodes are doubled but
3633 # they not assigned to elements
3634 # @return TRUE if operation has been completed successfully, FALSE otherwise
3635 # @ingroup l2_modif_edit
3636 def DoubleNodes(self, theNodes, theModifiedElems):
3637 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3639 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3640 # This method provided for convenience works as DoubleNodes() described above.
3641 # @param theNodeId identifiers of node to be doubled
3642 # @param theModifiedElems identifiers of elements to be updated
3643 # @return TRUE if operation has been completed successfully, FALSE otherwise
3644 # @ingroup l2_modif_edit
3645 def DoubleNode(self, theNodeId, theModifiedElems):
3646 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3648 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3649 # This method provided for convenience works as DoubleNodes() described above.
3650 # @param theNodes group of nodes to be doubled
3651 # @param theModifiedElems group of elements to be updated.
3652 # @return TRUE if operation has been completed successfully, FALSE otherwise
3653 # @ingroup l2_modif_edit
3654 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3655 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3657 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3658 # This method provided for convenience works as DoubleNodes() described above.
3659 # @param theNodes list of groups of nodes to be doubled
3660 # @param theModifiedElems list of groups of elements to be updated.
3661 # @return TRUE if operation has been completed successfully, FALSE otherwise
3662 # @ingroup l2_modif_edit
3663 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3664 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3666 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3667 # @param theElems - the list of elements (edges or faces) to be replicated
3668 # The nodes for duplication could be found from these elements
3669 # @param theNodesNot - list of nodes to NOT replicate
3670 # @param theAffectedElems - the list of elements (cells and edges) to which the
3671 # replicated nodes should be associated to.
3672 # @return TRUE if operation has been completed successfully, FALSE otherwise
3673 # @ingroup l2_modif_edit
3674 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3675 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3677 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3678 # @param theElems - the list of elements (edges or faces) to be replicated
3679 # The nodes for duplication could be found from these elements
3680 # @param theNodesNot - list of nodes to NOT replicate
3681 # @param theShape - shape to detect affected elements (element which geometric center
3682 # located on or inside shape).
3683 # The replicated nodes should be associated to affected elements.
3684 # @return TRUE if operation has been completed successfully, FALSE otherwise
3685 # @ingroup l2_modif_edit
3686 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3687 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3689 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3690 # This method provided for convenience works as DoubleNodes() described above.
3691 # @param theElems - group of of elements (edges or faces) to be replicated
3692 # @param theNodesNot - group of nodes not to replicated
3693 # @param theAffectedElems - group of elements to which the replicated nodes
3694 # should be associated to.
3695 # @ingroup l2_modif_edit
3696 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3697 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3699 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3700 # This method provided for convenience works as DoubleNodes() described above.
3701 # @param theElems - group of of elements (edges or faces) to be replicated
3702 # @param theNodesNot - group of nodes not to replicated
3703 # @param theShape - shape to detect affected elements (element which geometric center
3704 # located on or inside shape).
3705 # The replicated nodes should be associated to affected elements.
3706 # @ingroup l2_modif_edit
3707 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3708 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3710 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3711 # This method provided for convenience works as DoubleNodes() described above.
3712 # @param theElems - list of groups of elements (edges or faces) to be replicated
3713 # @param theNodesNot - list of groups of nodes not to replicated
3714 # @param theAffectedElems - group of elements to which the replicated nodes
3715 # should be associated to.
3716 # @return TRUE if operation has been completed successfully, FALSE otherwise
3717 # @ingroup l2_modif_edit
3718 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3719 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3721 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3722 # This method provided for convenience works as DoubleNodes() described above.
3723 # @param theElems - list of groups of elements (edges or faces) to be replicated
3724 # @param theNodesNot - list of groups of nodes not to replicated
3725 # @param theShape - shape to detect affected elements (element which geometric center
3726 # located on or inside shape).
3727 # The replicated nodes should be associated to affected elements.
3728 # @return TRUE if operation has been completed successfully, FALSE otherwise
3729 # @ingroup l2_modif_edit
3730 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3731 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3733 ## The mother class to define algorithm, it is not recommended to use it directly.
3736 # @ingroup l2_algorithms
3737 class Mesh_Algorithm:
3738 # @class Mesh_Algorithm
3739 # @brief Class Mesh_Algorithm
3741 #def __init__(self,smesh):
3749 ## Finds a hypothesis in the study by its type name and parameters.
3750 # Finds only the hypotheses created in smeshpyD engine.
3751 # @return SMESH.SMESH_Hypothesis
3752 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3753 study = smeshpyD.GetCurrentStudy()
3754 #to do: find component by smeshpyD object, not by its data type
3755 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3756 if scomp is not None:
3757 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3758 # Check if the root label of the hypotheses exists
3759 if res and hypRoot is not None:
3760 iter = study.NewChildIterator(hypRoot)
3761 # Check all published hypotheses
3763 hypo_so_i = iter.Value()
3764 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3765 if attr is not None:
3766 anIOR = attr.Value()
3767 hypo_o_i = salome.orb.string_to_object(anIOR)
3768 if hypo_o_i is not None:
3769 # Check if this is a hypothesis
3770 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3771 if hypo_i is not None:
3772 # Check if the hypothesis belongs to current engine
3773 if smeshpyD.GetObjectId(hypo_i) > 0:
3774 # Check if this is the required hypothesis
3775 if hypo_i.GetName() == hypname:
3777 if CompareMethod(hypo_i, args):
3791 ## Finds the algorithm in the study by its type name.
3792 # Finds only the algorithms, which have been created in smeshpyD engine.
3793 # @return SMESH.SMESH_Algo
3794 def FindAlgorithm (self, algoname, smeshpyD):
3795 study = smeshpyD.GetCurrentStudy()
3796 #to do: find component by smeshpyD object, not by its data type
3797 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3798 if scomp is not None:
3799 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3800 # Check if the root label of the algorithms exists
3801 if res and hypRoot is not None:
3802 iter = study.NewChildIterator(hypRoot)
3803 # Check all published algorithms
3805 algo_so_i = iter.Value()
3806 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3807 if attr is not None:
3808 anIOR = attr.Value()
3809 algo_o_i = salome.orb.string_to_object(anIOR)
3810 if algo_o_i is not None:
3811 # Check if this is an algorithm
3812 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3813 if algo_i is not None:
3814 # Checks if the algorithm belongs to the current engine
3815 if smeshpyD.GetObjectId(algo_i) > 0:
3816 # Check if this is the required algorithm
3817 if algo_i.GetName() == algoname:
3830 ## If the algorithm is global, returns 0; \n
3831 # else returns the submesh associated to this algorithm.
3832 def GetSubMesh(self):
3835 ## Returns the wrapped mesher.
3836 def GetAlgorithm(self):
3839 ## Gets the list of hypothesis that can be used with this algorithm
3840 def GetCompatibleHypothesis(self):
3843 mylist = self.algo.GetCompatibleHypothesis()
3846 ## Gets the name of the algorithm
3850 ## Sets the name to the algorithm
3851 def SetName(self, name):
3852 self.mesh.smeshpyD.SetName(self.algo, name)
3854 ## Gets the id of the algorithm
3856 return self.algo.GetId()
3859 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3861 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3862 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3864 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3866 self.Assign(algo, mesh, geom)
3870 def Assign(self, algo, mesh, geom):
3872 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3881 name = GetName(geom)
3884 name = mesh.geompyD.SubShapeName(geom, piece)
3885 mesh.geompyD.addToStudyInFather(piece, geom, name)
3887 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3890 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3891 TreatHypoStatus( status, algo.GetName(), name, True )
3893 def CompareHyp (self, hyp, args):
3894 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3897 def CompareEqualHyp (self, hyp, args):
3901 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3902 UseExisting=0, CompareMethod=""):
3905 if CompareMethod == "": CompareMethod = self.CompareHyp
3906 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3909 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3915 a = a + s + str(args[i])
3919 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3921 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3922 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3925 ## Returns entry of the shape to mesh in the study
3926 def MainShapeEntry(self):
3928 if not self.mesh or not self.mesh.GetMesh(): return entry
3929 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3930 study = self.mesh.smeshpyD.GetCurrentStudy()
3931 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3932 sobj = study.FindObjectIOR(ior)
3933 if sobj: entry = sobj.GetID()
3934 if not entry: return ""
3937 # Public class: Mesh_Segment
3938 # --------------------------
3940 ## Class to define a segment 1D algorithm for discretization
3943 # @ingroup l3_algos_basic
3944 class Mesh_Segment(Mesh_Algorithm):
3946 ## Private constructor.
3947 def __init__(self, mesh, geom=0):
3948 Mesh_Algorithm.__init__(self)
3949 self.Create(mesh, geom, "Regular_1D")
3951 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3952 # @param l for the length of segments that cut an edge
3953 # @param UseExisting if ==true - searches for an existing hypothesis created with
3954 # the same parameters, else (default) - creates a new one
3955 # @param p precision, used for calculation of the number of segments.
3956 # The precision should be a positive, meaningful value within the range [0,1].
3957 # In general, the number of segments is calculated with the formula:
3958 # nb = ceil((edge_length / l) - p)
3959 # Function ceil rounds its argument to the higher integer.
3960 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3961 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3962 # p=1 means rounding of (edge_length / l) to the lower integer.
3963 # Default value is 1e-07.
3964 # @return an instance of StdMeshers_LocalLength hypothesis
3965 # @ingroup l3_hypos_1dhyps
3966 def LocalLength(self, l, UseExisting=0, p=1e-07):
3967 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3968 CompareMethod=self.CompareLocalLength)
3974 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3975 def CompareLocalLength(self, hyp, args):
3976 if IsEqual(hyp.GetLength(), args[0]):
3977 return IsEqual(hyp.GetPrecision(), args[1])
3980 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3981 # @param length is optional maximal allowed length of segment, if it is omitted
3982 # the preestimated length is used that depends on geometry size
3983 # @param UseExisting if ==true - searches for an existing hypothesis created with
3984 # the same parameters, else (default) - create a new one
3985 # @return an instance of StdMeshers_MaxLength hypothesis
3986 # @ingroup l3_hypos_1dhyps
3987 def MaxSize(self, length=0.0, UseExisting=0):
3988 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3991 hyp.SetLength(length)
3993 # set preestimated length
3994 gen = self.mesh.smeshpyD
3995 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3996 self.mesh.GetMesh(), self.mesh.GetShape(),
3998 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4000 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4003 hyp.SetUsePreestimatedLength( length == 0.0 )
4006 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4007 # @param n for the number of segments that cut an edge
4008 # @param s for the scale factor (optional)
4009 # @param reversedEdges is a list of edges to mesh using reversed orientation
4010 # @param UseExisting if ==true - searches for an existing hypothesis created with
4011 # the same parameters, else (default) - create a new one
4012 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4013 # @ingroup l3_hypos_1dhyps
4014 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4015 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4016 reversedEdges, UseExisting = [], reversedEdges
4017 entry = self.MainShapeEntry()
4019 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4020 UseExisting=UseExisting,
4021 CompareMethod=self.CompareNumberOfSegments)
4023 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4024 UseExisting=UseExisting,
4025 CompareMethod=self.CompareNumberOfSegments)
4026 hyp.SetDistrType( 1 )
4027 hyp.SetScaleFactor(s)
4028 hyp.SetNumberOfSegments(n)
4029 hyp.SetReversedEdges( reversedEdges )
4030 hyp.SetObjectEntry( entry )
4034 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4035 def CompareNumberOfSegments(self, hyp, args):
4036 if hyp.GetNumberOfSegments() == args[0]:
4038 if hyp.GetReversedEdges() == args[1]:
4039 if not args[1] or hyp.GetObjectEntry() == args[2]:
4042 if hyp.GetReversedEdges() == args[2]:
4043 if not args[2] or hyp.GetObjectEntry() == args[3]:
4044 if hyp.GetDistrType() == 1:
4045 if IsEqual(hyp.GetScaleFactor(), args[1]):
4049 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4050 # @param start defines the length of the first segment
4051 # @param end defines the length of the last segment
4052 # @param reversedEdges is a list of edges to mesh using reversed orientation
4053 # @param UseExisting if ==true - searches for an existing hypothesis created with
4054 # the same parameters, else (default) - creates a new one
4055 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4056 # @ingroup l3_hypos_1dhyps
4057 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4058 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4059 reversedEdges, UseExisting = [], reversedEdges
4060 entry = self.MainShapeEntry()
4061 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4062 UseExisting=UseExisting,
4063 CompareMethod=self.CompareArithmetic1D)
4064 hyp.SetStartLength(start)
4065 hyp.SetEndLength(end)
4066 hyp.SetReversedEdges( reversedEdges )
4067 hyp.SetObjectEntry( entry )
4071 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4072 def CompareArithmetic1D(self, hyp, args):
4073 if IsEqual(hyp.GetLength(1), args[0]):
4074 if IsEqual(hyp.GetLength(0), args[1]):
4075 if hyp.GetReversedEdges() == args[2]:
4076 if not args[2] or hyp.GetObjectEntry() == args[3]:
4081 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4082 # on curve from 0 to 1 (additionally it is neecessary to check
4083 # orientation of edges and create list of reversed edges if it is
4084 # needed) and sets numbers of segments between given points (default
4085 # values are equals 1
4086 # @param points defines the list of parameters on curve
4087 # @param nbSegs defines the list of numbers of segments
4088 # @param reversedEdges is a list of edges to mesh using reversed orientation
4089 # @param UseExisting if ==true - searches for an existing hypothesis created with
4090 # the same parameters, else (default) - creates a new one
4091 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4092 # @ingroup l3_hypos_1dhyps
4093 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4094 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4095 reversedEdges, UseExisting = [], reversedEdges
4096 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4097 for i in range( len( reversedEdges )):
4098 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4099 entry = self.MainShapeEntry()
4100 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4101 UseExisting=UseExisting,
4102 CompareMethod=self.CompareFixedPoints1D)
4103 hyp.SetPoints(points)
4104 hyp.SetNbSegments(nbSegs)
4105 hyp.SetReversedEdges(reversedEdges)
4106 hyp.SetObjectEntry(entry)
4110 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4111 ## as the given arguments
4112 def CompareFixedPoints1D(self, hyp, args):
4113 if hyp.GetPoints() == args[0]:
4114 if hyp.GetNbSegments() == args[1]:
4115 if hyp.GetReversedEdges() == args[2]:
4116 if not args[2] or hyp.GetObjectEntry() == args[3]:
4122 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4123 # @param start defines the length of the first segment
4124 # @param end defines the length of the last segment
4125 # @param reversedEdges is a list of edges to mesh using reversed orientation
4126 # @param UseExisting if ==true - searches for an existing hypothesis created with
4127 # the same parameters, else (default) - creates a new one
4128 # @return an instance of StdMeshers_StartEndLength hypothesis
4129 # @ingroup l3_hypos_1dhyps
4130 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4131 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4132 reversedEdges, UseExisting = [], reversedEdges
4133 entry = self.MainShapeEntry()
4134 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4135 UseExisting=UseExisting,
4136 CompareMethod=self.CompareStartEndLength)
4137 hyp.SetStartLength(start)
4138 hyp.SetEndLength(end)
4139 hyp.SetReversedEdges( reversedEdges )
4140 hyp.SetObjectEntry( entry )
4143 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4144 def CompareStartEndLength(self, hyp, args):
4145 if IsEqual(hyp.GetLength(1), args[0]):
4146 if IsEqual(hyp.GetLength(0), args[1]):
4147 if hyp.GetReversedEdges() == args[2]:
4148 if not args[2] or hyp.GetObjectEntry() == args[3]:
4152 ## Defines "Deflection1D" hypothesis
4153 # @param d for the deflection
4154 # @param UseExisting if ==true - searches for an existing hypothesis created with
4155 # the same parameters, else (default) - create a new one
4156 # @ingroup l3_hypos_1dhyps
4157 def Deflection1D(self, d, UseExisting=0):
4158 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4159 CompareMethod=self.CompareDeflection1D)
4160 hyp.SetDeflection(d)
4163 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4164 def CompareDeflection1D(self, hyp, args):
4165 return IsEqual(hyp.GetDeflection(), args[0])
4167 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4168 # the opposite side in case of quadrangular faces
4169 # @ingroup l3_hypos_additi
4170 def Propagation(self):
4171 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4173 ## Defines "AutomaticLength" hypothesis
4174 # @param fineness for the fineness [0-1]
4175 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4176 # same parameters, else (default) - create a new one
4177 # @ingroup l3_hypos_1dhyps
4178 def AutomaticLength(self, fineness=0, UseExisting=0):
4179 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4180 CompareMethod=self.CompareAutomaticLength)
4181 hyp.SetFineness( fineness )
4184 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4185 def CompareAutomaticLength(self, hyp, args):
4186 return IsEqual(hyp.GetFineness(), args[0])
4188 ## Defines "SegmentLengthAroundVertex" hypothesis
4189 # @param length for the segment length
4190 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4191 # Any other integer value means that the hypothesis will be set on the
4192 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4193 # @param UseExisting if ==true - searches for an existing hypothesis created with
4194 # the same parameters, else (default) - creates a new one
4195 # @ingroup l3_algos_segmarv
4196 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4198 store_geom = self.geom
4199 if type(vertex) is types.IntType:
4200 if vertex == 0 or vertex == 1:
4201 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4209 if self.geom is None:
4210 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4212 name = GetName(self.geom)
4215 piece = self.mesh.geom
4216 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4217 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4219 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4221 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4223 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4224 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4226 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4227 CompareMethod=self.CompareLengthNearVertex)
4228 self.geom = store_geom
4229 hyp.SetLength( length )
4232 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4233 # @ingroup l3_algos_segmarv
4234 def CompareLengthNearVertex(self, hyp, args):
4235 return IsEqual(hyp.GetLength(), args[0])
4237 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4238 # If the 2D mesher sees that all boundary edges are quadratic,
4239 # it generates quadratic faces, else it generates linear faces using
4240 # medium nodes as if they are vertices.
4241 # The 3D mesher generates quadratic volumes only if all boundary faces
4242 # are quadratic, else it fails.
4244 # @ingroup l3_hypos_additi
4245 def QuadraticMesh(self):
4246 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4249 # Public class: Mesh_CompositeSegment
4250 # --------------------------
4252 ## Defines a segment 1D algorithm for discretization
4254 # @ingroup l3_algos_basic
4255 class Mesh_CompositeSegment(Mesh_Segment):
4257 ## Private constructor.
4258 def __init__(self, mesh, geom=0):
4259 self.Create(mesh, geom, "CompositeSegment_1D")
4262 # Public class: Mesh_Segment_Python
4263 # ---------------------------------
4265 ## Defines a segment 1D algorithm for discretization with python function
4267 # @ingroup l3_algos_basic
4268 class Mesh_Segment_Python(Mesh_Segment):
4270 ## Private constructor.
4271 def __init__(self, mesh, geom=0):
4272 import Python1dPlugin
4273 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4275 ## Defines "PythonSplit1D" hypothesis
4276 # @param n for the number of segments that cut an edge
4277 # @param func for the python function that calculates the length of all segments
4278 # @param UseExisting if ==true - searches for the existing hypothesis created with
4279 # the same parameters, else (default) - creates a new one
4280 # @ingroup l3_hypos_1dhyps
4281 def PythonSplit1D(self, n, func, UseExisting=0):
4282 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4283 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4284 hyp.SetNumberOfSegments(n)
4285 hyp.SetPythonLog10RatioFunction(func)
4288 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4289 def ComparePythonSplit1D(self, hyp, args):
4290 #if hyp.GetNumberOfSegments() == args[0]:
4291 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4295 # Public class: Mesh_Triangle
4296 # ---------------------------
4298 ## Defines a triangle 2D algorithm
4300 # @ingroup l3_algos_basic
4301 class Mesh_Triangle(Mesh_Algorithm):
4310 ## Private constructor.
4311 def __init__(self, mesh, algoType, geom=0):
4312 Mesh_Algorithm.__init__(self)
4314 self.algoType = algoType
4315 if algoType == MEFISTO:
4316 self.Create(mesh, geom, "MEFISTO_2D")
4318 elif algoType == BLSURF:
4320 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4321 #self.SetPhysicalMesh() - PAL19680
4322 elif algoType == NETGEN:
4324 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4326 elif algoType == NETGEN_2D:
4328 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4331 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4332 # @param area for the maximum area of each triangle
4333 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4334 # same parameters, else (default) - creates a new one
4336 # Only for algoType == MEFISTO || NETGEN_2D
4337 # @ingroup l3_hypos_2dhyps
4338 def MaxElementArea(self, area, UseExisting=0):
4339 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4340 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4341 CompareMethod=self.CompareMaxElementArea)
4342 elif self.algoType == NETGEN:
4343 hyp = self.Parameters(SIMPLE)
4344 hyp.SetMaxElementArea(area)
4347 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4348 def CompareMaxElementArea(self, hyp, args):
4349 return IsEqual(hyp.GetMaxElementArea(), args[0])
4351 ## Defines "LengthFromEdges" hypothesis to build triangles
4352 # based on the length of the edges taken from the wire
4354 # Only for algoType == MEFISTO || NETGEN_2D
4355 # @ingroup l3_hypos_2dhyps
4356 def LengthFromEdges(self):
4357 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4358 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4360 elif self.algoType == NETGEN:
4361 hyp = self.Parameters(SIMPLE)
4362 hyp.LengthFromEdges()
4365 ## Sets a way to define size of mesh elements to generate.
4366 # @param thePhysicalMesh is: DefaultSize or Custom.
4367 # @ingroup l3_hypos_blsurf
4368 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4369 # Parameter of BLSURF algo
4370 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4372 ## Sets size of mesh elements to generate.
4373 # @ingroup l3_hypos_blsurf
4374 def SetPhySize(self, theVal):
4375 # Parameter of BLSURF algo
4376 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4377 self.Parameters().SetPhySize(theVal)
4379 ## Sets lower boundary of mesh element size (PhySize).
4380 # @ingroup l3_hypos_blsurf
4381 def SetPhyMin(self, theVal=-1):
4382 # Parameter of BLSURF algo
4383 self.Parameters().SetPhyMin(theVal)
4385 ## Sets upper boundary of mesh element size (PhySize).
4386 # @ingroup l3_hypos_blsurf
4387 def SetPhyMax(self, theVal=-1):
4388 # Parameter of BLSURF algo
4389 self.Parameters().SetPhyMax(theVal)
4391 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4392 # @param theGeometricMesh is: DefaultGeom or Custom
4393 # @ingroup l3_hypos_blsurf
4394 def SetGeometricMesh(self, theGeometricMesh=0):
4395 # Parameter of BLSURF algo
4396 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4397 self.params.SetGeometricMesh(theGeometricMesh)
4399 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4400 # @ingroup l3_hypos_blsurf
4401 def SetAngleMeshS(self, theVal=_angleMeshS):
4402 # Parameter of BLSURF algo
4403 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4404 self.params.SetAngleMeshS(theVal)
4406 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4407 # @ingroup l3_hypos_blsurf
4408 def SetAngleMeshC(self, theVal=_angleMeshS):
4409 # Parameter of BLSURF algo
4410 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4411 self.params.SetAngleMeshC(theVal)
4413 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4414 # @ingroup l3_hypos_blsurf
4415 def SetGeoMin(self, theVal=-1):
4416 # Parameter of BLSURF algo
4417 self.Parameters().SetGeoMin(theVal)
4419 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4420 # @ingroup l3_hypos_blsurf
4421 def SetGeoMax(self, theVal=-1):
4422 # Parameter of BLSURF algo
4423 self.Parameters().SetGeoMax(theVal)
4425 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4426 # @ingroup l3_hypos_blsurf
4427 def SetGradation(self, theVal=_gradation):
4428 # Parameter of BLSURF algo
4429 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4430 self.params.SetGradation(theVal)
4432 ## Sets topology usage way.
4433 # @param way defines how mesh conformity is assured <ul>
4434 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4435 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4436 # @ingroup l3_hypos_blsurf
4437 def SetTopology(self, way):
4438 # Parameter of BLSURF algo
4439 self.Parameters().SetTopology(way)
4441 ## To respect geometrical edges or not.
4442 # @ingroup l3_hypos_blsurf
4443 def SetDecimesh(self, toIgnoreEdges=False):
4444 # Parameter of BLSURF algo
4445 self.Parameters().SetDecimesh(toIgnoreEdges)
4447 ## Sets verbosity level in the range 0 to 100.
4448 # @ingroup l3_hypos_blsurf
4449 def SetVerbosity(self, level):
4450 # Parameter of BLSURF algo
4451 self.Parameters().SetVerbosity(level)
4453 ## Sets advanced option value.
4454 # @ingroup l3_hypos_blsurf
4455 def SetOptionValue(self, optionName, level):
4456 # Parameter of BLSURF algo
4457 self.Parameters().SetOptionValue(optionName,level)
4459 ## Sets QuadAllowed flag.
4460 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4461 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4462 def SetQuadAllowed(self, toAllow=True):
4463 if self.algoType == NETGEN_2D:
4464 if toAllow: # add QuadranglePreference
4465 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4466 else: # remove QuadranglePreference
4467 for hyp in self.mesh.GetHypothesisList( self.geom ):
4468 if hyp.GetName() == "QuadranglePreference":
4469 self.mesh.RemoveHypothesis( self.geom, hyp )
4474 if self.Parameters():
4475 self.params.SetQuadAllowed(toAllow)
4478 ## Defines hypothesis having several parameters
4480 # @ingroup l3_hypos_netgen
4481 def Parameters(self, which=SOLE):
4484 if self.algoType == NETGEN:
4486 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4487 "libNETGENEngine.so", UseExisting=0)
4489 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4490 "libNETGENEngine.so", UseExisting=0)
4492 elif self.algoType == MEFISTO:
4493 print "Mefisto algo support no multi-parameter hypothesis"
4495 elif self.algoType == NETGEN_2D:
4496 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4497 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4499 elif self.algoType == BLSURF:
4500 self.params = self.Hypothesis("BLSURF_Parameters", [],
4501 "libBLSURFEngine.so", UseExisting=0)
4504 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4509 # Only for algoType == NETGEN
4510 # @ingroup l3_hypos_netgen
4511 def SetMaxSize(self, theSize):
4512 if self.Parameters():
4513 self.params.SetMaxSize(theSize)
4515 ## Sets SecondOrder flag
4517 # Only for algoType == NETGEN
4518 # @ingroup l3_hypos_netgen
4519 def SetSecondOrder(self, theVal):
4520 if self.Parameters():
4521 self.params.SetSecondOrder(theVal)
4523 ## Sets Optimize flag
4525 # Only for algoType == NETGEN
4526 # @ingroup l3_hypos_netgen
4527 def SetOptimize(self, theVal):
4528 if self.Parameters():
4529 self.params.SetOptimize(theVal)
4532 # @param theFineness is:
4533 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4535 # Only for algoType == NETGEN
4536 # @ingroup l3_hypos_netgen
4537 def SetFineness(self, theFineness):
4538 if self.Parameters():
4539 self.params.SetFineness(theFineness)
4543 # Only for algoType == NETGEN
4544 # @ingroup l3_hypos_netgen
4545 def SetGrowthRate(self, theRate):
4546 if self.Parameters():
4547 self.params.SetGrowthRate(theRate)
4549 ## Sets NbSegPerEdge
4551 # Only for algoType == NETGEN
4552 # @ingroup l3_hypos_netgen
4553 def SetNbSegPerEdge(self, theVal):
4554 if self.Parameters():
4555 self.params.SetNbSegPerEdge(theVal)
4557 ## Sets NbSegPerRadius
4559 # Only for algoType == NETGEN
4560 # @ingroup l3_hypos_netgen
4561 def SetNbSegPerRadius(self, theVal):
4562 if self.Parameters():
4563 self.params.SetNbSegPerRadius(theVal)
4565 ## Sets number of segments overriding value set by SetLocalLength()
4567 # Only for algoType == NETGEN
4568 # @ingroup l3_hypos_netgen
4569 def SetNumberOfSegments(self, theVal):
4570 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4572 ## Sets number of segments overriding value set by SetNumberOfSegments()
4574 # Only for algoType == NETGEN
4575 # @ingroup l3_hypos_netgen
4576 def SetLocalLength(self, theVal):
4577 self.Parameters(SIMPLE).SetLocalLength(theVal)
4582 # Public class: Mesh_Quadrangle
4583 # -----------------------------
4585 ## Defines a quadrangle 2D algorithm
4587 # @ingroup l3_algos_basic
4588 class Mesh_Quadrangle(Mesh_Algorithm):
4590 ## Private constructor.
4591 def __init__(self, mesh, geom=0):
4592 Mesh_Algorithm.__init__(self)
4593 self.Create(mesh, geom, "Quadrangle_2D")
4595 ## Defines "QuadranglePreference" hypothesis, forcing construction
4596 # of quadrangles if the number of nodes on the opposite edges is not the same
4597 # while the total number of nodes on edges is even
4599 # @ingroup l3_hypos_additi
4600 def QuadranglePreference(self):
4601 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4602 CompareMethod=self.CompareEqualHyp)
4605 ## Defines "TrianglePreference" hypothesis, forcing construction
4606 # of triangles in the refinement area if the number of nodes
4607 # on the opposite edges is not the same
4609 # @ingroup l3_hypos_additi
4610 def TrianglePreference(self):
4611 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4612 CompareMethod=self.CompareEqualHyp)
4615 ## Defines "QuadrangleParams" hypothesis
4616 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4617 # will be created while other elements will be quadrangles.
4618 # Vertex can be either a GEOM_Object or a vertex ID within the
4620 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4621 # the same parameters, else (default) - creates a new one
4623 # @ingroup l3_hypos_additi
4624 def TriangleVertex(self, vertex, UseExisting=0):
4626 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4627 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4628 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4629 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4630 hyp.SetTriaVertex( vertexID )
4634 # Public class: Mesh_Tetrahedron
4635 # ------------------------------
4637 ## Defines a tetrahedron 3D algorithm
4639 # @ingroup l3_algos_basic
4640 class Mesh_Tetrahedron(Mesh_Algorithm):
4645 ## Private constructor.
4646 def __init__(self, mesh, algoType, geom=0):
4647 Mesh_Algorithm.__init__(self)
4649 if algoType == NETGEN:
4651 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4654 elif algoType == FULL_NETGEN:
4656 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4659 elif algoType == GHS3D:
4661 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4664 elif algoType == GHS3DPRL:
4665 CheckPlugin(GHS3DPRL)
4666 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4669 self.algoType = algoType
4671 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4672 # @param vol for the maximum volume of each tetrahedron
4673 # @param UseExisting if ==true - searches for the existing hypothesis created with
4674 # the same parameters, else (default) - creates a new one
4675 # @ingroup l3_hypos_maxvol
4676 def MaxElementVolume(self, vol, UseExisting=0):
4677 if self.algoType == NETGEN:
4678 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4679 CompareMethod=self.CompareMaxElementVolume)
4680 hyp.SetMaxElementVolume(vol)
4682 elif self.algoType == FULL_NETGEN:
4683 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4686 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4687 def CompareMaxElementVolume(self, hyp, args):
4688 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4690 ## Defines hypothesis having several parameters
4692 # @ingroup l3_hypos_netgen
4693 def Parameters(self, which=SOLE):
4697 if self.algoType == FULL_NETGEN:
4699 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4700 "libNETGENEngine.so", UseExisting=0)
4702 self.params = self.Hypothesis("NETGEN_Parameters", [],
4703 "libNETGENEngine.so", UseExisting=0)
4706 if self.algoType == GHS3D:
4707 self.params = self.Hypothesis("GHS3D_Parameters", [],
4708 "libGHS3DEngine.so", UseExisting=0)
4711 if self.algoType == GHS3DPRL:
4712 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4713 "libGHS3DPRLEngine.so", UseExisting=0)
4716 print "Algo supports no multi-parameter hypothesis"
4720 # Parameter of FULL_NETGEN
4721 # @ingroup l3_hypos_netgen
4722 def SetMaxSize(self, theSize):
4723 self.Parameters().SetMaxSize(theSize)
4725 ## Sets SecondOrder flag
4726 # Parameter of FULL_NETGEN
4727 # @ingroup l3_hypos_netgen
4728 def SetSecondOrder(self, theVal):
4729 self.Parameters().SetSecondOrder(theVal)
4731 ## Sets Optimize flag
4732 # Parameter of FULL_NETGEN
4733 # @ingroup l3_hypos_netgen
4734 def SetOptimize(self, theVal):
4735 self.Parameters().SetOptimize(theVal)
4738 # @param theFineness is:
4739 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4740 # Parameter of FULL_NETGEN
4741 # @ingroup l3_hypos_netgen
4742 def SetFineness(self, theFineness):
4743 self.Parameters().SetFineness(theFineness)
4746 # Parameter of FULL_NETGEN
4747 # @ingroup l3_hypos_netgen
4748 def SetGrowthRate(self, theRate):
4749 self.Parameters().SetGrowthRate(theRate)
4751 ## Sets NbSegPerEdge
4752 # Parameter of FULL_NETGEN
4753 # @ingroup l3_hypos_netgen
4754 def SetNbSegPerEdge(self, theVal):
4755 self.Parameters().SetNbSegPerEdge(theVal)
4757 ## Sets NbSegPerRadius
4758 # Parameter of FULL_NETGEN
4759 # @ingroup l3_hypos_netgen
4760 def SetNbSegPerRadius(self, theVal):
4761 self.Parameters().SetNbSegPerRadius(theVal)
4763 ## Sets number of segments overriding value set by SetLocalLength()
4764 # Only for algoType == NETGEN_FULL
4765 # @ingroup l3_hypos_netgen
4766 def SetNumberOfSegments(self, theVal):
4767 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4769 ## Sets number of segments overriding value set by SetNumberOfSegments()
4770 # Only for algoType == NETGEN_FULL
4771 # @ingroup l3_hypos_netgen
4772 def SetLocalLength(self, theVal):
4773 self.Parameters(SIMPLE).SetLocalLength(theVal)
4775 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4776 # Overrides value set by LengthFromEdges()
4777 # Only for algoType == NETGEN_FULL
4778 # @ingroup l3_hypos_netgen
4779 def MaxElementArea(self, area):
4780 self.Parameters(SIMPLE).SetMaxElementArea(area)
4782 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4783 # Overrides value set by MaxElementArea()
4784 # Only for algoType == NETGEN_FULL
4785 # @ingroup l3_hypos_netgen
4786 def LengthFromEdges(self):
4787 self.Parameters(SIMPLE).LengthFromEdges()
4789 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4790 # Overrides value set by MaxElementVolume()
4791 # Only for algoType == NETGEN_FULL
4792 # @ingroup l3_hypos_netgen
4793 def LengthFromFaces(self):
4794 self.Parameters(SIMPLE).LengthFromFaces()
4796 ## To mesh "holes" in a solid or not. Default is to mesh.
4797 # @ingroup l3_hypos_ghs3dh
4798 def SetToMeshHoles(self, toMesh):
4799 # Parameter of GHS3D
4800 self.Parameters().SetToMeshHoles(toMesh)
4802 ## Set Optimization level:
4803 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4804 # Strong_Optimization.
4805 # Default is Standard_Optimization
4806 # @ingroup l3_hypos_ghs3dh
4807 def SetOptimizationLevel(self, level):
4808 # Parameter of GHS3D
4809 self.Parameters().SetOptimizationLevel(level)
4811 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4812 # @ingroup l3_hypos_ghs3dh
4813 def SetMaximumMemory(self, MB):
4814 # Advanced parameter of GHS3D
4815 self.Parameters().SetMaximumMemory(MB)
4817 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4818 # automatic memory adjustment mode.
4819 # @ingroup l3_hypos_ghs3dh
4820 def SetInitialMemory(self, MB):
4821 # Advanced parameter of GHS3D
4822 self.Parameters().SetInitialMemory(MB)
4824 ## Path to working directory.
4825 # @ingroup l3_hypos_ghs3dh
4826 def SetWorkingDirectory(self, path):
4827 # Advanced parameter of GHS3D
4828 self.Parameters().SetWorkingDirectory(path)
4830 ## To keep working files or remove them. Log file remains in case of errors anyway.
4831 # @ingroup l3_hypos_ghs3dh
4832 def SetKeepFiles(self, toKeep):
4833 # Advanced parameter of GHS3D and GHS3DPRL
4834 self.Parameters().SetKeepFiles(toKeep)
4836 ## To set verbose level [0-10]. <ul>
4837 #<li> 0 - no standard output,
4838 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4839 # indicates when the final mesh is being saved. In addition the software
4840 # gives indication regarding the CPU time.
4841 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4842 # histogram of the skin mesh, quality statistics histogram together with
4843 # the characteristics of the final mesh.</ul>
4844 # @ingroup l3_hypos_ghs3dh
4845 def SetVerboseLevel(self, level):
4846 # Advanced parameter of GHS3D
4847 self.Parameters().SetVerboseLevel(level)
4849 ## To create new nodes.
4850 # @ingroup l3_hypos_ghs3dh
4851 def SetToCreateNewNodes(self, toCreate):
4852 # Advanced parameter of GHS3D
4853 self.Parameters().SetToCreateNewNodes(toCreate)
4855 ## To use boundary recovery version which tries to create mesh on a very poor
4856 # quality surface mesh.
4857 # @ingroup l3_hypos_ghs3dh
4858 def SetToUseBoundaryRecoveryVersion(self, toUse):
4859 # Advanced parameter of GHS3D
4860 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4862 ## Sets command line option as text.
4863 # @ingroup l3_hypos_ghs3dh
4864 def SetTextOption(self, option):
4865 # Advanced parameter of GHS3D
4866 self.Parameters().SetTextOption(option)
4868 ## Sets MED files name and path.
4869 def SetMEDName(self, value):
4870 self.Parameters().SetMEDName(value)
4872 ## Sets the number of partition of the initial mesh
4873 def SetNbPart(self, value):
4874 self.Parameters().SetNbPart(value)
4876 ## When big mesh, start tepal in background
4877 def SetBackground(self, value):
4878 self.Parameters().SetBackground(value)
4880 # Public class: Mesh_Hexahedron
4881 # ------------------------------
4883 ## Defines a hexahedron 3D algorithm
4885 # @ingroup l3_algos_basic
4886 class Mesh_Hexahedron(Mesh_Algorithm):
4891 ## Private constructor.
4892 def __init__(self, mesh, algoType=Hexa, geom=0):
4893 Mesh_Algorithm.__init__(self)
4895 self.algoType = algoType
4897 if algoType == Hexa:
4898 self.Create(mesh, geom, "Hexa_3D")
4901 elif algoType == Hexotic:
4902 CheckPlugin(Hexotic)
4903 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4906 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4907 # @ingroup l3_hypos_hexotic
4908 def MinMaxQuad(self, min=3, max=8, quad=True):
4909 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4911 self.params.SetHexesMinLevel(min)
4912 self.params.SetHexesMaxLevel(max)
4913 self.params.SetHexoticQuadrangles(quad)
4916 # Deprecated, only for compatibility!
4917 # Public class: Mesh_Netgen
4918 # ------------------------------
4920 ## Defines a NETGEN-based 2D or 3D algorithm
4921 # that needs no discrete boundary (i.e. independent)
4923 # This class is deprecated, only for compatibility!
4926 # @ingroup l3_algos_basic
4927 class Mesh_Netgen(Mesh_Algorithm):
4931 ## Private constructor.
4932 def __init__(self, mesh, is3D, geom=0):
4933 Mesh_Algorithm.__init__(self)
4939 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4943 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4946 ## Defines the hypothesis containing parameters of the algorithm
4947 def Parameters(self):
4949 hyp = self.Hypothesis("NETGEN_Parameters", [],
4950 "libNETGENEngine.so", UseExisting=0)
4952 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4953 "libNETGENEngine.so", UseExisting=0)
4956 # Public class: Mesh_Projection1D
4957 # ------------------------------
4959 ## Defines a projection 1D algorithm
4960 # @ingroup l3_algos_proj
4962 class Mesh_Projection1D(Mesh_Algorithm):
4964 ## Private constructor.
4965 def __init__(self, mesh, geom=0):
4966 Mesh_Algorithm.__init__(self)
4967 self.Create(mesh, geom, "Projection_1D")
4969 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4970 # a mesh pattern is taken, and, optionally, the association of vertices
4971 # between the source edge and a target edge (to which a hypothesis is assigned)
4972 # @param edge from which nodes distribution is taken
4973 # @param mesh from which nodes distribution is taken (optional)
4974 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4975 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4976 # to associate with \a srcV (optional)
4977 # @param UseExisting if ==true - searches for the existing hypothesis created with
4978 # the same parameters, else (default) - creates a new one
4979 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4980 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4982 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4983 hyp.SetSourceEdge( edge )
4984 if not mesh is None and isinstance(mesh, Mesh):
4985 mesh = mesh.GetMesh()
4986 hyp.SetSourceMesh( mesh )
4987 hyp.SetVertexAssociation( srcV, tgtV )
4990 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4991 #def CompareSourceEdge(self, hyp, args):
4992 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4996 # Public class: Mesh_Projection2D
4997 # ------------------------------
4999 ## Defines a projection 2D algorithm
5000 # @ingroup l3_algos_proj
5002 class Mesh_Projection2D(Mesh_Algorithm):
5004 ## Private constructor.
5005 def __init__(self, mesh, geom=0):
5006 Mesh_Algorithm.__init__(self)
5007 self.Create(mesh, geom, "Projection_2D")
5009 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5010 # a mesh pattern is taken, and, optionally, the association of vertices
5011 # between the source face and the target face (to which a hypothesis is assigned)
5012 # @param face from which the mesh pattern is taken
5013 # @param mesh from which the mesh pattern is taken (optional)
5014 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5015 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5016 # to associate with \a srcV1 (optional)
5017 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5018 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5019 # to associate with \a srcV2 (optional)
5020 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5021 # the same parameters, else (default) - forces the creation a new one
5023 # Note: all association vertices must belong to one edge of a face
5024 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5025 srcV2=None, tgtV2=None, UseExisting=0):
5026 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5028 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5029 hyp.SetSourceFace( face )
5030 if not mesh is None and isinstance(mesh, Mesh):
5031 mesh = mesh.GetMesh()
5032 hyp.SetSourceMesh( mesh )
5033 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5036 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5037 #def CompareSourceFace(self, hyp, args):
5038 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5041 # Public class: Mesh_Projection3D
5042 # ------------------------------
5044 ## Defines a projection 3D algorithm
5045 # @ingroup l3_algos_proj
5047 class Mesh_Projection3D(Mesh_Algorithm):
5049 ## Private constructor.
5050 def __init__(self, mesh, geom=0):
5051 Mesh_Algorithm.__init__(self)
5052 self.Create(mesh, geom, "Projection_3D")
5054 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5055 # the mesh pattern is taken, and, optionally, the association of vertices
5056 # between the source and the target solid (to which a hipothesis is assigned)
5057 # @param solid from where the mesh pattern is taken
5058 # @param mesh from where the mesh pattern is taken (optional)
5059 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5060 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5061 # to associate with \a srcV1 (optional)
5062 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5063 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5064 # to associate with \a srcV2 (optional)
5065 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5066 # the same parameters, else (default) - creates a new one
5068 # Note: association vertices must belong to one edge of a solid
5069 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5070 srcV2=0, tgtV2=0, UseExisting=0):
5071 hyp = self.Hypothesis("ProjectionSource3D",
5072 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5074 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5075 hyp.SetSource3DShape( solid )
5076 if not mesh is None and isinstance(mesh, Mesh):
5077 mesh = mesh.GetMesh()
5078 hyp.SetSourceMesh( mesh )
5079 if srcV1 and srcV2 and tgtV1 and tgtV2:
5080 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5081 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5084 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5085 #def CompareSourceShape3D(self, hyp, args):
5086 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5090 # Public class: Mesh_Prism
5091 # ------------------------
5093 ## Defines a 3D extrusion algorithm
5094 # @ingroup l3_algos_3dextr
5096 class Mesh_Prism3D(Mesh_Algorithm):
5098 ## Private constructor.
5099 def __init__(self, mesh, geom=0):
5100 Mesh_Algorithm.__init__(self)
5101 self.Create(mesh, geom, "Prism_3D")
5103 # Public class: Mesh_RadialPrism
5104 # -------------------------------
5106 ## Defines a Radial Prism 3D algorithm
5107 # @ingroup l3_algos_radialp
5109 class Mesh_RadialPrism3D(Mesh_Algorithm):
5111 ## Private constructor.
5112 def __init__(self, mesh, geom=0):
5113 Mesh_Algorithm.__init__(self)
5114 self.Create(mesh, geom, "RadialPrism_3D")
5116 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5117 self.nbLayers = None
5119 ## Return 3D hypothesis holding the 1D one
5120 def Get3DHypothesis(self):
5121 return self.distribHyp
5123 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5124 # hypothesis. Returns the created hypothesis
5125 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5126 #print "OwnHypothesis",hypType
5127 if not self.nbLayers is None:
5128 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5129 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5130 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5131 self.mesh.smeshpyD.SetCurrentStudy( None )
5132 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5133 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5134 self.distribHyp.SetLayerDistribution( hyp )
5137 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5138 # prisms to build between the inner and outer shells
5139 # @param n number of layers
5140 # @param UseExisting if ==true - searches for the existing hypothesis created with
5141 # the same parameters, else (default) - creates a new one
5142 def NumberOfLayers(self, n, UseExisting=0):
5143 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5144 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5145 CompareMethod=self.CompareNumberOfLayers)
5146 self.nbLayers.SetNumberOfLayers( n )
5147 return self.nbLayers
5149 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5150 def CompareNumberOfLayers(self, hyp, args):
5151 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5153 ## Defines "LocalLength" hypothesis, specifying the segment length
5154 # to build between the inner and the outer shells
5155 # @param l the length of segments
5156 # @param p the precision of rounding
5157 def LocalLength(self, l, p=1e-07):
5158 hyp = self.OwnHypothesis("LocalLength", [l,p])
5163 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5164 # prisms to build between the inner and the outer shells.
5165 # @param n the number of layers
5166 # @param s the scale factor (optional)
5167 def NumberOfSegments(self, n, s=[]):
5169 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5171 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5172 hyp.SetDistrType( 1 )
5173 hyp.SetScaleFactor(s)
5174 hyp.SetNumberOfSegments(n)
5177 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5178 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5179 # @param start the length of the first segment
5180 # @param end the length of the last segment
5181 def Arithmetic1D(self, start, end ):
5182 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5183 hyp.SetLength(start, 1)
5184 hyp.SetLength(end , 0)
5187 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5188 # to build between the inner and the outer shells as geometric length increasing
5189 # @param start for the length of the first segment
5190 # @param end for the length of the last segment
5191 def StartEndLength(self, start, end):
5192 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5193 hyp.SetLength(start, 1)
5194 hyp.SetLength(end , 0)
5197 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5198 # to build between the inner and outer shells
5199 # @param fineness defines the quality of the mesh within the range [0-1]
5200 def AutomaticLength(self, fineness=0):
5201 hyp = self.OwnHypothesis("AutomaticLength")
5202 hyp.SetFineness( fineness )
5205 # Public class: Mesh_RadialQuadrangle1D2D
5206 # -------------------------------
5208 ## Defines a Radial Quadrangle 1D2D algorithm
5209 # @ingroup l2_algos_radialq
5211 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5213 ## Private constructor.
5214 def __init__(self, mesh, geom=0):
5215 Mesh_Algorithm.__init__(self)
5216 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5218 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5219 self.nbLayers = None
5221 ## Return 2D hypothesis holding the 1D one
5222 def Get2DHypothesis(self):
5223 return self.distribHyp
5225 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5226 # hypothesis. Returns the created hypothesis
5227 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5228 #print "OwnHypothesis",hypType
5230 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5231 if self.distribHyp is None:
5232 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5234 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5235 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5236 self.mesh.smeshpyD.SetCurrentStudy( None )
5237 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5238 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5239 self.distribHyp.SetLayerDistribution( hyp )
5242 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5243 # @param n number of layers
5244 # @param UseExisting if ==true - searches for the existing hypothesis created with
5245 # the same parameters, else (default) - creates a new one
5246 def NumberOfLayers(self, n, UseExisting=0):
5248 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5249 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5250 CompareMethod=self.CompareNumberOfLayers)
5251 self.nbLayers.SetNumberOfLayers( n )
5252 return self.nbLayers
5254 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5255 def CompareNumberOfLayers(self, hyp, args):
5256 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5258 ## Defines "LocalLength" hypothesis, specifying the segment length
5259 # @param l the length of segments
5260 # @param p the precision of rounding
5261 def LocalLength(self, l, p=1e-07):
5262 hyp = self.OwnHypothesis("LocalLength", [l,p])
5267 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5268 # @param n the number of layers
5269 # @param s the scale factor (optional)
5270 def NumberOfSegments(self, n, s=[]):
5272 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5274 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5275 hyp.SetDistrType( 1 )
5276 hyp.SetScaleFactor(s)
5277 hyp.SetNumberOfSegments(n)
5280 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5281 # with a length that changes in arithmetic progression
5282 # @param start the length of the first segment
5283 # @param end the length of the last segment
5284 def Arithmetic1D(self, start, end ):
5285 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5286 hyp.SetLength(start, 1)
5287 hyp.SetLength(end , 0)
5290 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5291 # as geometric length increasing
5292 # @param start for the length of the first segment
5293 # @param end for the length of the last segment
5294 def StartEndLength(self, start, end):
5295 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5296 hyp.SetLength(start, 1)
5297 hyp.SetLength(end , 0)
5300 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5301 # @param fineness defines the quality of the mesh within the range [0-1]
5302 def AutomaticLength(self, fineness=0):
5303 hyp = self.OwnHypothesis("AutomaticLength")
5304 hyp.SetFineness( fineness )
5308 # Private class: Mesh_UseExisting
5309 # -------------------------------
5310 class Mesh_UseExisting(Mesh_Algorithm):
5312 def __init__(self, dim, mesh, geom=0):
5314 self.Create(mesh, geom, "UseExisting_1D")
5316 self.Create(mesh, geom, "UseExisting_2D")
5319 import salome_notebook
5320 notebook = salome_notebook.notebook
5322 ##Return values of the notebook variables
5323 def ParseParameters(last, nbParams,nbParam, value):
5327 listSize = len(last)
5328 for n in range(0,nbParams):
5330 if counter < listSize:
5331 strResult = strResult + last[counter]
5333 strResult = strResult + ""
5335 if isinstance(value, str):
5336 if notebook.isVariable(value):
5337 result = notebook.get(value)
5338 strResult=strResult+value
5340 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5342 strResult=strResult+str(value)
5344 if nbParams - 1 != counter:
5345 strResult=strResult+var_separator #":"
5347 return result, strResult
5349 #Wrapper class for StdMeshers_LocalLength hypothesis
5350 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5352 ## Set Length parameter value
5353 # @param length numerical value or name of variable from notebook
5354 def SetLength(self, length):
5355 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5356 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5357 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5359 ## Set Precision parameter value
5360 # @param precision numerical value or name of variable from notebook
5361 def SetPrecision(self, precision):
5362 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5363 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5364 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5366 #Registering the new proxy for LocalLength
5367 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5370 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5371 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5373 def SetLayerDistribution(self, hypo):
5374 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5375 hypo.ClearParameters();
5376 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5378 #Registering the new proxy for LayerDistribution
5379 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5381 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5382 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5384 ## Set Length parameter value
5385 # @param length numerical value or name of variable from notebook
5386 def SetLength(self, length):
5387 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5388 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5389 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5391 #Registering the new proxy for SegmentLengthAroundVertex
5392 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5395 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5396 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5398 ## Set Length parameter value
5399 # @param length numerical value or name of variable from notebook
5400 # @param isStart true is length is Start Length, otherwise false
5401 def SetLength(self, length, isStart):
5405 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5406 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5407 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5409 #Registering the new proxy for Arithmetic1D
5410 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5412 #Wrapper class for StdMeshers_Deflection1D hypothesis
5413 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5415 ## Set Deflection parameter value
5416 # @param deflection numerical value or name of variable from notebook
5417 def SetDeflection(self, deflection):
5418 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5419 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5420 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5422 #Registering the new proxy for Deflection1D
5423 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5425 #Wrapper class for StdMeshers_StartEndLength hypothesis
5426 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5428 ## Set Length parameter value
5429 # @param length numerical value or name of variable from notebook
5430 # @param isStart true is length is Start Length, otherwise false
5431 def SetLength(self, length, isStart):
5435 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5436 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5437 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5439 #Registering the new proxy for StartEndLength
5440 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5442 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5443 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5445 ## Set Max Element Area parameter value
5446 # @param area numerical value or name of variable from notebook
5447 def SetMaxElementArea(self, area):
5448 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5449 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5450 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5452 #Registering the new proxy for MaxElementArea
5453 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5456 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5457 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5459 ## Set Max Element Volume parameter value
5460 # @param volume numerical value or name of variable from notebook
5461 def SetMaxElementVolume(self, volume):
5462 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5463 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5464 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5466 #Registering the new proxy for MaxElementVolume
5467 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5470 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5471 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5473 ## Set Number Of Layers parameter value
5474 # @param nbLayers numerical value or name of variable from notebook
5475 def SetNumberOfLayers(self, nbLayers):
5476 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5477 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5478 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5480 #Registering the new proxy for NumberOfLayers
5481 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5483 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5484 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5486 ## Set Number Of Segments parameter value
5487 # @param nbSeg numerical value or name of variable from notebook
5488 def SetNumberOfSegments(self, nbSeg):
5489 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5490 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5491 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5492 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5494 ## Set Scale Factor parameter value
5495 # @param factor numerical value or name of variable from notebook
5496 def SetScaleFactor(self, factor):
5497 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5498 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5499 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5501 #Registering the new proxy for NumberOfSegments
5502 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5504 if not noNETGENPlugin:
5505 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5506 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5508 ## Set Max Size parameter value
5509 # @param maxsize numerical value or name of variable from notebook
5510 def SetMaxSize(self, maxsize):
5511 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5512 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5513 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5514 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5516 ## Set Growth Rate parameter value
5517 # @param value numerical value or name of variable from notebook
5518 def SetGrowthRate(self, value):
5519 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5520 value, parameters = ParseParameters(lastParameters,4,2,value)
5521 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5522 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5524 ## Set Number of Segments per Edge parameter value
5525 # @param value numerical value or name of variable from notebook
5526 def SetNbSegPerEdge(self, value):
5527 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5528 value, parameters = ParseParameters(lastParameters,4,3,value)
5529 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5530 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5532 ## Set Number of Segments per Radius parameter value
5533 # @param value numerical value or name of variable from notebook
5534 def SetNbSegPerRadius(self, value):
5535 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5536 value, parameters = ParseParameters(lastParameters,4,4,value)
5537 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5538 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5540 #Registering the new proxy for NETGENPlugin_Hypothesis
5541 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5544 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5545 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5548 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5549 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5551 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5552 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5554 ## Set Number of Segments parameter value
5555 # @param nbSeg numerical value or name of variable from notebook
5556 def SetNumberOfSegments(self, nbSeg):
5557 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5558 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5559 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5560 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5562 ## Set Local Length parameter value
5563 # @param length numerical value or name of variable from notebook
5564 def SetLocalLength(self, length):
5565 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5566 length, parameters = ParseParameters(lastParameters,2,1,length)
5567 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5568 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5570 ## Set Max Element Area parameter value
5571 # @param area numerical value or name of variable from notebook
5572 def SetMaxElementArea(self, area):
5573 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5574 area, parameters = ParseParameters(lastParameters,2,2,area)
5575 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5576 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5578 def LengthFromEdges(self):
5579 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5581 value, parameters = ParseParameters(lastParameters,2,2,value)
5582 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5583 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5585 #Registering the new proxy for NETGEN_SimpleParameters_2D
5586 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5589 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5590 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5591 ## Set Max Element Volume parameter value
5592 # @param volume numerical value or name of variable from notebook
5593 def SetMaxElementVolume(self, volume):
5594 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5595 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5596 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5597 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5599 def LengthFromFaces(self):
5600 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5602 value, parameters = ParseParameters(lastParameters,3,3,value)
5603 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5604 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5606 #Registering the new proxy for NETGEN_SimpleParameters_3D
5607 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5609 pass # if not noNETGENPlugin:
5611 class Pattern(SMESH._objref_SMESH_Pattern):
5613 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5615 if isinstance(theNodeIndexOnKeyPoint1,str):
5617 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5619 theNodeIndexOnKeyPoint1 -= 1
5620 theMesh.SetParameters(Parameters)
5621 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5623 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5626 if isinstance(theNode000Index,str):
5628 if isinstance(theNode001Index,str):
5630 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5632 theNode000Index -= 1
5634 theNode001Index -= 1
5635 theMesh.SetParameters(Parameters)
5636 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5638 #Registering the new proxy for Pattern
5639 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)