1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
166 # MirrorType enumeration
167 POINT = SMESH_MeshEditor.POINT
168 AXIS = SMESH_MeshEditor.AXIS
169 PLANE = SMESH_MeshEditor.PLANE
171 # Smooth_Method enumeration
172 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
173 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
175 # Fineness enumeration (for NETGEN)
183 # Optimization level of GHS3D
184 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
186 # Topology treatment way of BLSURF
187 FromCAD, PreProcess, PreProcessPlus = 0,1,2
189 # Element size flag of BLSURF
190 DefaultSize, DefaultGeom, Custom = 0,0,1
192 PrecisionConfusion = 1e-07
194 ## Converts an angle from degrees to radians
195 def DegreesToRadians(AngleInDegrees):
197 return AngleInDegrees * pi / 180.0
199 # Salome notebook variable separator
202 # Parametrized substitute for PointStruct
203 class PointStructStr:
212 def __init__(self, xStr, yStr, zStr):
216 if isinstance(xStr, str) and notebook.isVariable(xStr):
217 self.x = notebook.get(xStr)
220 if isinstance(yStr, str) and notebook.isVariable(yStr):
221 self.y = notebook.get(yStr)
224 if isinstance(zStr, str) and notebook.isVariable(zStr):
225 self.z = notebook.get(zStr)
229 # Parametrized substitute for PointStruct (with 6 parameters)
230 class PointStructStr6:
245 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
252 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
253 self.x1 = notebook.get(x1Str)
256 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
257 self.x2 = notebook.get(x2Str)
260 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
261 self.y1 = notebook.get(y1Str)
264 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
265 self.y2 = notebook.get(y2Str)
268 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
269 self.z1 = notebook.get(z1Str)
272 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
273 self.z2 = notebook.get(z2Str)
277 # Parametrized substitute for AxisStruct
293 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
300 if isinstance(xStr, str) and notebook.isVariable(xStr):
301 self.x = notebook.get(xStr)
304 if isinstance(yStr, str) and notebook.isVariable(yStr):
305 self.y = notebook.get(yStr)
308 if isinstance(zStr, str) and notebook.isVariable(zStr):
309 self.z = notebook.get(zStr)
312 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
313 self.dx = notebook.get(dxStr)
316 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
317 self.dy = notebook.get(dyStr)
320 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
321 self.dz = notebook.get(dzStr)
325 # Parametrized substitute for DirStruct
328 def __init__(self, pointStruct):
329 self.pointStruct = pointStruct
331 # Returns list of variable values from salome notebook
332 def ParsePointStruct(Point):
333 Parameters = 2*var_separator
334 if isinstance(Point, PointStructStr):
335 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
336 Point = PointStruct(Point.x, Point.y, Point.z)
337 return Point, Parameters
339 # Returns list of variable values from salome notebook
340 def ParseDirStruct(Dir):
341 Parameters = 2*var_separator
342 if isinstance(Dir, DirStructStr):
343 pntStr = Dir.pointStruct
344 if isinstance(pntStr, PointStructStr6):
345 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
346 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
347 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
348 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
350 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
351 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
352 Dir = DirStruct(Point)
353 return Dir, Parameters
355 # Returns list of variable values from salome notebook
356 def ParseAxisStruct(Axis):
357 Parameters = 5*var_separator
358 if isinstance(Axis, AxisStructStr):
359 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
360 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
361 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
362 return Axis, Parameters
364 ## Return list of variable values from salome notebook
365 def ParseAngles(list):
368 for parameter in list:
369 if isinstance(parameter,str) and notebook.isVariable(parameter):
370 Result.append(DegreesToRadians(notebook.get(parameter)))
373 Result.append(parameter)
376 Parameters = Parameters + str(parameter)
377 Parameters = Parameters + var_separator
379 Parameters = Parameters[:len(Parameters)-1]
380 return Result, Parameters
382 def IsEqual(val1, val2, tol=PrecisionConfusion):
383 if abs(val1 - val2) < tol:
391 ior = salome.orb.object_to_string(obj)
392 sobj = salome.myStudy.FindObjectIOR(ior)
396 attr = sobj.FindAttribute("AttributeName")[1]
399 ## Prints error message if a hypothesis was not assigned.
400 def TreatHypoStatus(status, hypName, geomName, isAlgo):
402 hypType = "algorithm"
404 hypType = "hypothesis"
406 if status == HYP_UNKNOWN_FATAL :
407 reason = "for unknown reason"
408 elif status == HYP_INCOMPATIBLE :
409 reason = "this hypothesis mismatches the algorithm"
410 elif status == HYP_NOTCONFORM :
411 reason = "a non-conform mesh would be built"
412 elif status == HYP_ALREADY_EXIST :
413 reason = hypType + " of the same dimension is already assigned to this shape"
414 elif status == HYP_BAD_DIM :
415 reason = hypType + " mismatches the shape"
416 elif status == HYP_CONCURENT :
417 reason = "there are concurrent hypotheses on sub-shapes"
418 elif status == HYP_BAD_SUBSHAPE :
419 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
420 elif status == HYP_BAD_GEOMETRY:
421 reason = "geometry mismatches the expectation of the algorithm"
422 elif status == HYP_HIDDEN_ALGO:
423 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
424 elif status == HYP_HIDING_ALGO:
425 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
426 elif status == HYP_NEED_SHAPE:
427 reason = "Algorithm can't work without shape"
430 hypName = '"' + hypName + '"'
431 geomName= '"' + geomName+ '"'
432 if status < HYP_UNKNOWN_FATAL:
433 print hypName, "was assigned to", geomName,"but", reason
435 print hypName, "was not assigned to",geomName,":", reason
438 ## Check meshing plugin availability
439 def CheckPlugin(plugin):
440 if plugin == NETGEN and noNETGENPlugin:
441 print "Warning: NETGENPlugin module unavailable"
443 elif plugin == GHS3D and noGHS3DPlugin:
444 print "Warning: GHS3DPlugin module unavailable"
446 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
447 print "Warning: GHS3DPRLPlugin module unavailable"
449 elif plugin == Hexotic and noHexoticPlugin:
450 print "Warning: HexoticPlugin module unavailable"
452 elif plugin == BLSURF and noBLSURFPlugin:
453 print "Warning: BLSURFPlugin module unavailable"
457 # end of l1_auxiliary
460 # All methods of this class are accessible directly from the smesh.py package.
461 class smeshDC(SMESH._objref_SMESH_Gen):
463 ## Sets the current study and Geometry component
464 # @ingroup l1_auxiliary
465 def init_smesh(self,theStudy,geompyD):
466 self.SetCurrentStudy(theStudy,geompyD)
468 ## Creates an empty Mesh. This mesh can have an underlying geometry.
469 # @param obj the Geometrical object on which the mesh is built. If not defined,
470 # the mesh will have no underlying geometry.
471 # @param name the name for the new mesh.
472 # @return an instance of Mesh class.
473 # @ingroup l2_construct
474 def Mesh(self, obj=0, name=0):
475 if isinstance(obj,str):
477 return Mesh(self,self.geompyD,obj,name)
479 ## Returns a long value from enumeration
480 # Should be used for SMESH.FunctorType enumeration
481 # @ingroup l1_controls
482 def EnumToLong(self,theItem):
485 ## Gets PointStruct from vertex
486 # @param theVertex a GEOM object(vertex)
487 # @return SMESH.PointStruct
488 # @ingroup l1_auxiliary
489 def GetPointStruct(self,theVertex):
490 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
491 return PointStruct(x,y,z)
493 ## Gets DirStruct from vector
494 # @param theVector a GEOM object(vector)
495 # @return SMESH.DirStruct
496 # @ingroup l1_auxiliary
497 def GetDirStruct(self,theVector):
498 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
499 if(len(vertices) != 2):
500 print "Error: vector object is incorrect."
502 p1 = self.geompyD.PointCoordinates(vertices[0])
503 p2 = self.geompyD.PointCoordinates(vertices[1])
504 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
505 dirst = DirStruct(pnt)
508 ## Makes DirStruct from a triplet
509 # @param x,y,z vector components
510 # @return SMESH.DirStruct
511 # @ingroup l1_auxiliary
512 def MakeDirStruct(self,x,y,z):
513 pnt = PointStruct(x,y,z)
514 return DirStruct(pnt)
516 ## Get AxisStruct from object
517 # @param theObj a GEOM object (line or plane)
518 # @return SMESH.AxisStruct
519 # @ingroup l1_auxiliary
520 def GetAxisStruct(self,theObj):
521 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
523 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
524 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
525 vertex1 = self.geompyD.PointCoordinates(vertex1)
526 vertex2 = self.geompyD.PointCoordinates(vertex2)
527 vertex3 = self.geompyD.PointCoordinates(vertex3)
528 vertex4 = self.geompyD.PointCoordinates(vertex4)
529 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
530 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
531 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] ]
532 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
534 elif len(edges) == 1:
535 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
536 p1 = self.geompyD.PointCoordinates( vertex1 )
537 p2 = self.geompyD.PointCoordinates( vertex2 )
538 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
542 # From SMESH_Gen interface:
543 # ------------------------
545 ## Sets the given name to the object
546 # @param obj the object to rename
547 # @param name a new object name
548 # @ingroup l1_auxiliary
549 def SetName(self, obj, name):
550 if isinstance( obj, Mesh ):
552 elif isinstance( obj, Mesh_Algorithm ):
553 obj = obj.GetAlgorithm()
554 ior = salome.orb.object_to_string(obj)
555 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
557 ## Sets the current mode
558 # @ingroup l1_auxiliary
559 def SetEmbeddedMode( self,theMode ):
560 #self.SetEmbeddedMode(theMode)
561 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
563 ## Gets the current mode
564 # @ingroup l1_auxiliary
565 def IsEmbeddedMode(self):
566 #return self.IsEmbeddedMode()
567 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
569 ## Sets the current study
570 # @ingroup l1_auxiliary
571 def SetCurrentStudy( self, theStudy, geompyD = None ):
572 #self.SetCurrentStudy(theStudy)
575 geompyD = geompy.geom
578 self.SetGeomEngine(geompyD)
579 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
581 ## Gets the current study
582 # @ingroup l1_auxiliary
583 def GetCurrentStudy(self):
584 #return self.GetCurrentStudy()
585 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
587 ## Creates a Mesh object importing data from the given UNV file
588 # @return an instance of Mesh class
590 def CreateMeshesFromUNV( self,theFileName ):
591 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
592 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
595 ## Creates a Mesh object(s) importing data from the given MED file
596 # @return a list of Mesh class instances
598 def CreateMeshesFromMED( self,theFileName ):
599 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
601 for iMesh in range(len(aSmeshMeshes)) :
602 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
603 aMeshes.append(aMesh)
604 return aMeshes, aStatus
606 ## Creates a Mesh object importing data from the given STL file
607 # @return an instance of Mesh class
609 def CreateMeshesFromSTL( self, theFileName ):
610 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
611 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
614 ## From SMESH_Gen interface
615 # @return the list of integer values
616 # @ingroup l1_auxiliary
617 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
618 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
620 ## From SMESH_Gen interface. Creates a pattern
621 # @return an instance of SMESH_Pattern
623 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
624 # @ingroup l2_modif_patterns
625 def GetPattern(self):
626 return SMESH._objref_SMESH_Gen.GetPattern(self)
628 ## Sets number of segments per diagonal of boundary box of geometry by which
629 # default segment length of appropriate 1D hypotheses is defined.
630 # Default value is 10
631 # @ingroup l1_auxiliary
632 def SetBoundaryBoxSegmentation(self, nbSegments):
633 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
635 ## Concatenate the given meshes into one mesh.
636 # @return an instance of Mesh class
637 # @param meshes the meshes to combine into one mesh
638 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
639 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
640 # @param mergeTolerance tolerance for merging nodes
641 # @param allGroups forces creation of groups of all elements
642 def Concatenate( self, meshes, uniteIdenticalGroups,
643 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
644 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
646 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
647 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
649 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
650 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
651 aSmeshMesh.SetParameters(Parameters)
652 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
655 # Filtering. Auxiliary functions:
656 # ------------------------------
658 ## Creates an empty criterion
659 # @return SMESH.Filter.Criterion
660 # @ingroup l1_controls
661 def GetEmptyCriterion(self):
662 Type = self.EnumToLong(FT_Undefined)
663 Compare = self.EnumToLong(FT_Undefined)
667 UnaryOp = self.EnumToLong(FT_Undefined)
668 BinaryOp = self.EnumToLong(FT_Undefined)
671 Precision = -1 ##@1e-07
672 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
673 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
675 ## Creates a criterion by the given parameters
676 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
677 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
678 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
679 # @param Treshold the threshold value (range of ids as string, shape, numeric)
680 # @param UnaryOp FT_LogicalNOT or FT_Undefined
681 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
682 # FT_Undefined (must be for the last criterion of all criteria)
683 # @return SMESH.Filter.Criterion
684 # @ingroup l1_controls
685 def GetCriterion(self,elementType,
687 Compare = FT_EqualTo,
689 UnaryOp=FT_Undefined,
690 BinaryOp=FT_Undefined):
691 aCriterion = self.GetEmptyCriterion()
692 aCriterion.TypeOfElement = elementType
693 aCriterion.Type = self.EnumToLong(CritType)
697 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
698 aCriterion.Compare = self.EnumToLong(Compare)
699 elif Compare == "=" or Compare == "==":
700 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
702 aCriterion.Compare = self.EnumToLong(FT_LessThan)
704 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
706 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
709 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
710 FT_BelongToCylinder, FT_LyingOnGeom]:
711 # Checks the treshold
712 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
713 aCriterion.ThresholdStr = GetName(aTreshold)
714 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
716 print "Error: The treshold should be a shape."
718 elif CritType == FT_RangeOfIds:
719 # Checks the treshold
720 if isinstance(aTreshold, str):
721 aCriterion.ThresholdStr = aTreshold
723 print "Error: The treshold should be a string."
725 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
726 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
727 # At this point the treshold is unnecessary
728 if aTreshold == FT_LogicalNOT:
729 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
730 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
731 aCriterion.BinaryOp = aTreshold
735 aTreshold = float(aTreshold)
736 aCriterion.Threshold = aTreshold
738 print "Error: The treshold should be a number."
741 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
742 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
744 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
745 aCriterion.BinaryOp = self.EnumToLong(Treshold)
747 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
748 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
750 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
751 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
755 ## Creates a filter with the given parameters
756 # @param elementType the type of elements in the group
757 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
758 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
759 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
760 # @param UnaryOp FT_LogicalNOT or FT_Undefined
761 # @return SMESH_Filter
762 # @ingroup l1_controls
763 def GetFilter(self,elementType,
764 CritType=FT_Undefined,
767 UnaryOp=FT_Undefined):
768 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
769 aFilterMgr = self.CreateFilterManager()
770 aFilter = aFilterMgr.CreateFilter()
772 aCriteria.append(aCriterion)
773 aFilter.SetCriteria(aCriteria)
776 ## Creates a numerical functor by its type
777 # @param theCriterion FT_...; functor type
778 # @return SMESH_NumericalFunctor
779 # @ingroup l1_controls
780 def GetFunctor(self,theCriterion):
781 aFilterMgr = self.CreateFilterManager()
782 if theCriterion == FT_AspectRatio:
783 return aFilterMgr.CreateAspectRatio()
784 elif theCriterion == FT_AspectRatio3D:
785 return aFilterMgr.CreateAspectRatio3D()
786 elif theCriterion == FT_Warping:
787 return aFilterMgr.CreateWarping()
788 elif theCriterion == FT_MinimumAngle:
789 return aFilterMgr.CreateMinimumAngle()
790 elif theCriterion == FT_Taper:
791 return aFilterMgr.CreateTaper()
792 elif theCriterion == FT_Skew:
793 return aFilterMgr.CreateSkew()
794 elif theCriterion == FT_Area:
795 return aFilterMgr.CreateArea()
796 elif theCriterion == FT_Volume3D:
797 return aFilterMgr.CreateVolume3D()
798 elif theCriterion == FT_MultiConnection:
799 return aFilterMgr.CreateMultiConnection()
800 elif theCriterion == FT_MultiConnection2D:
801 return aFilterMgr.CreateMultiConnection2D()
802 elif theCriterion == FT_Length:
803 return aFilterMgr.CreateLength()
804 elif theCriterion == FT_Length2D:
805 return aFilterMgr.CreateLength2D()
807 print "Error: given parameter is not numerucal functor type."
809 ## Creates hypothesis
812 # @return created hypothesis instance
813 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
814 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
817 #Registering the new proxy for SMESH_Gen
818 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
824 ## This class allows defining and managing a mesh.
825 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
826 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
827 # new nodes and elements and by changing the existing entities), to get information
828 # about a mesh and to export a mesh into different formats.
837 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
838 # sets the GUI name of this mesh to \a name.
839 # @param smeshpyD an instance of smeshDC class
840 # @param geompyD an instance of geompyDC class
841 # @param obj Shape to be meshed or SMESH_Mesh object
842 # @param name Study name of the mesh
843 # @ingroup l2_construct
844 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
845 self.smeshpyD=smeshpyD
850 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
852 self.mesh = self.smeshpyD.CreateMesh(self.geom)
853 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
856 self.mesh = self.smeshpyD.CreateEmptyMesh()
858 self.smeshpyD.SetName(self.mesh, name)
860 self.smeshpyD.SetName(self.mesh, GetName(obj))
863 self.geom = self.mesh.GetShapeToMesh()
865 self.editor = self.mesh.GetMeshEditor()
867 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
868 # @param theMesh a SMESH_Mesh object
869 # @ingroup l2_construct
870 def SetMesh(self, theMesh):
872 self.geom = self.mesh.GetShapeToMesh()
874 ## Returns the mesh, that is an instance of SMESH_Mesh interface
875 # @return a SMESH_Mesh object
876 # @ingroup l2_construct
880 ## Gets the name of the mesh
881 # @return the name of the mesh as a string
882 # @ingroup l2_construct
884 name = GetName(self.GetMesh())
887 ## Sets a name to the mesh
888 # @param name a new name of the mesh
889 # @ingroup l2_construct
890 def SetName(self, name):
891 self.smeshpyD.SetName(self.GetMesh(), name)
893 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
894 # The subMesh object gives access to the IDs of nodes and elements.
895 # @param theSubObject a geometrical object (shape)
896 # @param theName a name for the submesh
897 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
898 # @ingroup l2_submeshes
899 def GetSubMesh(self, theSubObject, theName):
900 submesh = self.mesh.GetSubMesh(theSubObject, theName)
903 ## Returns the shape associated to the mesh
904 # @return a GEOM_Object
905 # @ingroup l2_construct
909 ## Associates the given shape to the mesh (entails the recreation of the mesh)
910 # @param geom the shape to be meshed (GEOM_Object)
911 # @ingroup l2_construct
912 def SetShape(self, geom):
913 self.mesh = self.smeshpyD.CreateMesh(geom)
915 ## Returns true if the hypotheses are defined well
916 # @param theSubObject a subshape of a mesh shape
917 # @return True or False
918 # @ingroup l2_construct
919 def IsReadyToCompute(self, theSubObject):
920 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
922 ## Returns errors of hypotheses definition.
923 # The list of errors is empty if everything is OK.
924 # @param theSubObject a subshape of a mesh shape
925 # @return a list of errors
926 # @ingroup l2_construct
927 def GetAlgoState(self, theSubObject):
928 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
930 ## Returns a geometrical object on which the given element was built.
931 # The returned geometrical object, if not nil, is either found in the
932 # study or published by this method with the given name
933 # @param theElementID the id of the mesh element
934 # @param theGeomName the user-defined name of the geometrical object
935 # @return GEOM::GEOM_Object instance
936 # @ingroup l2_construct
937 def GetGeometryByMeshElement(self, theElementID, theGeomName):
938 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
940 ## Returns the mesh dimension depending on the dimension of the underlying shape
941 # @return mesh dimension as an integer value [0,3]
942 # @ingroup l1_auxiliary
943 def MeshDimension(self):
944 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
945 if len( shells ) > 0 :
947 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
949 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
955 ## Creates a segment discretization 1D algorithm.
956 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
957 # \n If the optional \a geom parameter is not set, this algorithm is global.
958 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
959 # @param algo the type of the required algorithm. Possible values are:
961 # - smesh.PYTHON for discretization via a python function,
962 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
963 # @param geom If defined is the subshape to be meshed
964 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
965 # @ingroup l3_algos_basic
966 def Segment(self, algo=REGULAR, geom=0):
967 ## if Segment(geom) is called by mistake
968 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
969 algo, geom = geom, algo
970 if not algo: algo = REGULAR
973 return Mesh_Segment(self, geom)
975 return Mesh_Segment_Python(self, geom)
976 elif algo == COMPOSITE:
977 return Mesh_CompositeSegment(self, geom)
979 return Mesh_Segment(self, geom)
981 ## Enables creation of nodes and segments usable by 2D algoritms.
982 # The added nodes and segments must be bound to edges and vertices by
983 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
984 # If the optional \a geom parameter is not set, this algorithm is global.
985 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
986 # @param geom the subshape to be manually meshed
987 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
988 # @ingroup l3_algos_basic
989 def UseExistingSegments(self, geom=0):
990 algo = Mesh_UseExisting(1,self,geom)
991 return algo.GetAlgorithm()
993 ## Enables creation of nodes and faces usable by 3D algoritms.
994 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
995 # and SetMeshElementOnShape()
996 # If the optional \a geom parameter is not set, this algorithm is global.
997 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
998 # @param geom the subshape to be manually meshed
999 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1000 # @ingroup l3_algos_basic
1001 def UseExistingFaces(self, geom=0):
1002 algo = Mesh_UseExisting(2,self,geom)
1003 return algo.GetAlgorithm()
1005 ## Creates a triangle 2D algorithm for faces.
1006 # If the optional \a geom parameter is not set, this algorithm is global.
1007 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1008 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1009 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1010 # @return an instance of Mesh_Triangle algorithm
1011 # @ingroup l3_algos_basic
1012 def Triangle(self, algo=MEFISTO, geom=0):
1013 ## if Triangle(geom) is called by mistake
1014 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1018 return Mesh_Triangle(self, algo, geom)
1020 ## Creates a quadrangle 2D algorithm for faces.
1021 # If the optional \a geom parameter is not set, this algorithm is global.
1022 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1023 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1024 # @return an instance of Mesh_Quadrangle algorithm
1025 # @ingroup l3_algos_basic
1026 def Quadrangle(self, geom=0):
1027 return Mesh_Quadrangle(self, geom)
1029 ## Creates a tetrahedron 3D algorithm for solids.
1030 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1031 # If the optional \a geom parameter is not set, this algorithm is global.
1032 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1033 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1034 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1035 # @return an instance of Mesh_Tetrahedron algorithm
1036 # @ingroup l3_algos_basic
1037 def Tetrahedron(self, algo=NETGEN, geom=0):
1038 ## if Tetrahedron(geom) is called by mistake
1039 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1040 algo, geom = geom, algo
1041 if not algo: algo = NETGEN
1043 return Mesh_Tetrahedron(self, algo, geom)
1045 ## Creates a hexahedron 3D algorithm for solids.
1046 # If the optional \a geom parameter is not set, this algorithm is global.
1047 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1048 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1049 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1050 # @return an instance of Mesh_Hexahedron algorithm
1051 # @ingroup l3_algos_basic
1052 def Hexahedron(self, algo=Hexa, geom=0):
1053 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1054 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1055 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1056 elif geom == 0: algo, geom = Hexa, algo
1057 return Mesh_Hexahedron(self, algo, geom)
1059 ## Deprecated, used only for compatibility!
1060 # @return an instance of Mesh_Netgen algorithm
1061 # @ingroup l3_algos_basic
1062 def Netgen(self, is3D, geom=0):
1063 return Mesh_Netgen(self, is3D, geom)
1065 ## Creates a projection 1D algorithm for edges.
1066 # If the optional \a geom parameter is not set, this algorithm is global.
1067 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1068 # @param geom If defined, the subshape to be meshed
1069 # @return an instance of Mesh_Projection1D algorithm
1070 # @ingroup l3_algos_proj
1071 def Projection1D(self, geom=0):
1072 return Mesh_Projection1D(self, geom)
1074 ## Creates a projection 2D algorithm for faces.
1075 # If the optional \a geom parameter is not set, this algorithm is global.
1076 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1077 # @param geom If defined, the subshape to be meshed
1078 # @return an instance of Mesh_Projection2D algorithm
1079 # @ingroup l3_algos_proj
1080 def Projection2D(self, geom=0):
1081 return Mesh_Projection2D(self, geom)
1083 ## Creates a projection 3D algorithm for solids.
1084 # If the optional \a geom parameter is not set, this algorithm is global.
1085 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1086 # @param geom If defined, the subshape to be meshed
1087 # @return an instance of Mesh_Projection3D algorithm
1088 # @ingroup l3_algos_proj
1089 def Projection3D(self, geom=0):
1090 return Mesh_Projection3D(self, geom)
1092 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1093 # If the optional \a geom parameter is not set, this algorithm is global.
1094 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1095 # @param geom If defined, the subshape to be meshed
1096 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1097 # @ingroup l3_algos_radialp l3_algos_3dextr
1098 def Prism(self, geom=0):
1102 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1103 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1104 if nbSolids == 0 or nbSolids == nbShells:
1105 return Mesh_Prism3D(self, geom)
1106 return Mesh_RadialPrism3D(self, geom)
1108 ## Evaluates size of prospective mesh on a shape
1109 # @return True or False
1110 def Evaluate(self, geom=0):
1111 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1113 geom = self.mesh.GetShapeToMesh()
1116 return self.smeshpyD.Evaluate(self.mesh, geom)
1119 ## Computes the mesh and returns the status of the computation
1120 # @return True or False
1121 # @ingroup l2_construct
1122 def Compute(self, geom=0):
1123 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1125 geom = self.mesh.GetShapeToMesh()
1130 ok = self.smeshpyD.Compute(self.mesh, geom)
1131 except SALOME.SALOME_Exception, ex:
1132 print "Mesh computation failed, exception caught:"
1133 print " ", ex.details.text
1136 print "Mesh computation failed, exception caught:"
1137 traceback.print_exc()
1139 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1142 if err.isGlobalAlgo:
1150 reason = '%s %sD algorithm is missing' % (glob, dim)
1151 elif err.state == HYP_MISSING:
1152 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1153 % (glob, dim, name, dim))
1154 elif err.state == HYP_NOTCONFORM:
1155 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1156 elif err.state == HYP_BAD_PARAMETER:
1157 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1158 % ( glob, dim, name ))
1159 elif err.state == HYP_BAD_GEOMETRY:
1160 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1161 'geometry' % ( glob, dim, name ))
1163 reason = "For unknown reason."+\
1164 " Revise Mesh.Compute() implementation in smeshDC.py!"
1166 if allReasons != "":
1169 allReasons += reason
1171 if allReasons != "":
1172 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1176 print '"' + GetName(self.mesh) + '"',"has not been computed."
1179 if salome.sg.hasDesktop():
1180 smeshgui = salome.ImportComponentGUI("SMESH")
1181 smeshgui.Init(self.mesh.GetStudyId())
1182 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1183 salome.sg.updateObjBrowser(1)
1187 ## Removes all nodes and elements
1188 # @ingroup l2_construct
1191 if salome.sg.hasDesktop():
1192 smeshgui = salome.ImportComponentGUI("SMESH")
1193 smeshgui.Init(self.mesh.GetStudyId())
1194 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1195 salome.sg.updateObjBrowser(1)
1197 ## Removes all nodes and elements of indicated shape
1198 # @ingroup l2_construct
1199 def ClearSubMesh(self, geomId):
1200 self.mesh.ClearSubMesh(geomId)
1201 if salome.sg.hasDesktop():
1202 smeshgui = salome.ImportComponentGUI("SMESH")
1203 smeshgui.Init(self.mesh.GetStudyId())
1204 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1205 salome.sg.updateObjBrowser(1)
1207 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1208 # @param fineness [0,-1] defines mesh fineness
1209 # @return True or False
1210 # @ingroup l3_algos_basic
1211 def AutomaticTetrahedralization(self, fineness=0):
1212 dim = self.MeshDimension()
1214 self.RemoveGlobalHypotheses()
1215 self.Segment().AutomaticLength(fineness)
1217 self.Triangle().LengthFromEdges()
1220 self.Tetrahedron(NETGEN)
1222 return self.Compute()
1224 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1225 # @param fineness [0,-1] defines mesh fineness
1226 # @return True or False
1227 # @ingroup l3_algos_basic
1228 def AutomaticHexahedralization(self, fineness=0):
1229 dim = self.MeshDimension()
1230 # assign the hypotheses
1231 self.RemoveGlobalHypotheses()
1232 self.Segment().AutomaticLength(fineness)
1239 return self.Compute()
1241 ## Assigns a hypothesis
1242 # @param hyp a hypothesis to assign
1243 # @param geom a subhape of mesh geometry
1244 # @return SMESH.Hypothesis_Status
1245 # @ingroup l2_hypotheses
1246 def AddHypothesis(self, hyp, geom=0):
1247 if isinstance( hyp, Mesh_Algorithm ):
1248 hyp = hyp.GetAlgorithm()
1253 geom = self.mesh.GetShapeToMesh()
1255 status = self.mesh.AddHypothesis(geom, hyp)
1256 isAlgo = hyp._narrow( SMESH_Algo )
1257 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1260 ## Unassigns a hypothesis
1261 # @param hyp a hypothesis to unassign
1262 # @param geom a subshape of mesh geometry
1263 # @return SMESH.Hypothesis_Status
1264 # @ingroup l2_hypotheses
1265 def RemoveHypothesis(self, hyp, geom=0):
1266 if isinstance( hyp, Mesh_Algorithm ):
1267 hyp = hyp.GetAlgorithm()
1272 status = self.mesh.RemoveHypothesis(geom, hyp)
1275 ## Gets the list of hypotheses added on a geometry
1276 # @param geom a subshape of mesh geometry
1277 # @return the sequence of SMESH_Hypothesis
1278 # @ingroup l2_hypotheses
1279 def GetHypothesisList(self, geom):
1280 return self.mesh.GetHypothesisList( geom )
1282 ## Removes all global hypotheses
1283 # @ingroup l2_hypotheses
1284 def RemoveGlobalHypotheses(self):
1285 current_hyps = self.mesh.GetHypothesisList( self.geom )
1286 for hyp in current_hyps:
1287 self.mesh.RemoveHypothesis( self.geom, hyp )
1291 ## Creates a mesh group based on the geometric object \a grp
1292 # and gives a \a name, \n if this parameter is not defined
1293 # the name is the same as the geometric group name \n
1294 # Note: Works like GroupOnGeom().
1295 # @param grp a geometric group, a vertex, an edge, a face or a solid
1296 # @param name the name of the mesh group
1297 # @return SMESH_GroupOnGeom
1298 # @ingroup l2_grps_create
1299 def Group(self, grp, name=""):
1300 return self.GroupOnGeom(grp, name)
1302 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1303 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1304 # @param f the file name
1305 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1306 # @ingroup l2_impexp
1307 def ExportToMED(self, f, version, opt=0):
1308 self.mesh.ExportToMED(f, opt, version)
1310 ## Exports the mesh in a file in MED format
1311 # @param f is the file name
1312 # @param auto_groups boolean parameter for creating/not creating
1313 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1314 # the typical use is auto_groups=false.
1315 # @param version MED format version(MED_V2_1 or MED_V2_2)
1316 # @ingroup l2_impexp
1317 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1318 self.mesh.ExportToMED(f, auto_groups, version)
1320 ## Exports the mesh in a file in DAT format
1321 # @param f the file name
1322 # @ingroup l2_impexp
1323 def ExportDAT(self, f):
1324 self.mesh.ExportDAT(f)
1326 ## Exports the mesh in a file in UNV format
1327 # @param f the file name
1328 # @ingroup l2_impexp
1329 def ExportUNV(self, f):
1330 self.mesh.ExportUNV(f)
1332 ## Export the mesh in a file in STL format
1333 # @param f the file name
1334 # @param ascii defines the file encoding
1335 # @ingroup l2_impexp
1336 def ExportSTL(self, f, ascii=1):
1337 self.mesh.ExportSTL(f, ascii)
1340 # Operations with groups:
1341 # ----------------------
1343 ## Creates an empty mesh group
1344 # @param elementType the type of elements in the group
1345 # @param name the name of the mesh group
1346 # @return SMESH_Group
1347 # @ingroup l2_grps_create
1348 def CreateEmptyGroup(self, elementType, name):
1349 return self.mesh.CreateGroup(elementType, name)
1351 ## Creates a mesh group based on the geometrical object \a grp
1352 # and gives a \a name, \n if this parameter is not defined
1353 # the name is the same as the geometrical group name
1354 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1355 # @param name the name of the mesh group
1356 # @param typ the type of elements in the group. If not set, it is
1357 # automatically detected by the type of the geometry
1358 # @return SMESH_GroupOnGeom
1359 # @ingroup l2_grps_create
1360 def GroupOnGeom(self, grp, name="", typ=None):
1362 name = grp.GetName()
1365 tgeo = str(grp.GetShapeType())
1366 if tgeo == "VERTEX":
1368 elif tgeo == "EDGE":
1370 elif tgeo == "FACE":
1372 elif tgeo == "SOLID":
1374 elif tgeo == "SHELL":
1376 elif tgeo == "COMPOUND":
1377 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1378 print "Mesh.Group: empty geometric group", GetName( grp )
1380 tgeo = self.geompyD.GetType(grp)
1381 if tgeo == geompyDC.ShapeType["VERTEX"]:
1383 elif tgeo == geompyDC.ShapeType["EDGE"]:
1385 elif tgeo == geompyDC.ShapeType["FACE"]:
1387 elif tgeo == geompyDC.ShapeType["SOLID"]:
1391 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1394 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1396 ## Creates a mesh group by the given ids of elements
1397 # @param groupName the name of the mesh group
1398 # @param elementType the type of elements in the group
1399 # @param elemIDs the list of ids
1400 # @return SMESH_Group
1401 # @ingroup l2_grps_create
1402 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1403 group = self.mesh.CreateGroup(elementType, groupName)
1407 ## Creates a mesh group by the given conditions
1408 # @param groupName the name of the mesh group
1409 # @param elementType the type of elements in the group
1410 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1411 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1412 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1413 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1414 # @return SMESH_Group
1415 # @ingroup l2_grps_create
1419 CritType=FT_Undefined,
1422 UnaryOp=FT_Undefined):
1423 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1424 group = self.MakeGroupByCriterion(groupName, aCriterion)
1427 ## Creates a mesh group by the given criterion
1428 # @param groupName the name of the mesh group
1429 # @param Criterion the instance of Criterion class
1430 # @return SMESH_Group
1431 # @ingroup l2_grps_create
1432 def MakeGroupByCriterion(self, groupName, Criterion):
1433 aFilterMgr = self.smeshpyD.CreateFilterManager()
1434 aFilter = aFilterMgr.CreateFilter()
1436 aCriteria.append(Criterion)
1437 aFilter.SetCriteria(aCriteria)
1438 group = self.MakeGroupByFilter(groupName, aFilter)
1441 ## Creates a mesh group by the given criteria (list of criteria)
1442 # @param groupName the name of the mesh group
1443 # @param theCriteria the list of criteria
1444 # @return SMESH_Group
1445 # @ingroup l2_grps_create
1446 def MakeGroupByCriteria(self, groupName, theCriteria):
1447 aFilterMgr = self.smeshpyD.CreateFilterManager()
1448 aFilter = aFilterMgr.CreateFilter()
1449 aFilter.SetCriteria(theCriteria)
1450 group = self.MakeGroupByFilter(groupName, aFilter)
1453 ## Creates a mesh group by the given filter
1454 # @param groupName the name of the mesh group
1455 # @param theFilter the instance of Filter class
1456 # @return SMESH_Group
1457 # @ingroup l2_grps_create
1458 def MakeGroupByFilter(self, groupName, theFilter):
1459 anIds = theFilter.GetElementsId(self.mesh)
1460 anElemType = theFilter.GetElementType()
1461 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1464 ## Passes mesh elements through the given filter and return IDs of fitting elements
1465 # @param theFilter SMESH_Filter
1466 # @return a list of ids
1467 # @ingroup l1_controls
1468 def GetIdsFromFilter(self, theFilter):
1469 return theFilter.GetElementsId(self.mesh)
1471 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1472 # Returns a list of special structures (borders).
1473 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1474 # @ingroup l1_controls
1475 def GetFreeBorders(self):
1476 aFilterMgr = self.smeshpyD.CreateFilterManager()
1477 aPredicate = aFilterMgr.CreateFreeEdges()
1478 aPredicate.SetMesh(self.mesh)
1479 aBorders = aPredicate.GetBorders()
1483 # @ingroup l2_grps_delete
1484 def RemoveGroup(self, group):
1485 self.mesh.RemoveGroup(group)
1487 ## Removes a group with its contents
1488 # @ingroup l2_grps_delete
1489 def RemoveGroupWithContents(self, group):
1490 self.mesh.RemoveGroupWithContents(group)
1492 ## Gets the list of groups existing in the mesh
1493 # @return a sequence of SMESH_GroupBase
1494 # @ingroup l2_grps_create
1495 def GetGroups(self):
1496 return self.mesh.GetGroups()
1498 ## Gets the number of groups existing in the mesh
1499 # @return the quantity of groups as an integer value
1500 # @ingroup l2_grps_create
1502 return self.mesh.NbGroups()
1504 ## Gets the list of names of groups existing in the mesh
1505 # @return list of strings
1506 # @ingroup l2_grps_create
1507 def GetGroupNames(self):
1508 groups = self.GetGroups()
1510 for group in groups:
1511 names.append(group.GetName())
1514 ## Produces a union of two groups
1515 # A new group is created. All mesh elements that are
1516 # present in the initial groups are added to the new one
1517 # @return an instance of SMESH_Group
1518 # @ingroup l2_grps_operon
1519 def UnionGroups(self, group1, group2, name):
1520 return self.mesh.UnionGroups(group1, group2, name)
1522 ## Produces a union list of groups
1523 # New group is created. All mesh elements that are present in
1524 # initial groups are added to the new one
1525 # @return an instance of SMESH_Group
1526 # @ingroup l2_grps_operon
1527 def UnionListOfGroups(self, groups, name):
1528 return self.mesh.UnionListOfGroups(groups, name)
1530 ## Prodices an intersection of two groups
1531 # A new group is created. All mesh elements that are common
1532 # for the two initial groups are added to the new one.
1533 # @return an instance of SMESH_Group
1534 # @ingroup l2_grps_operon
1535 def IntersectGroups(self, group1, group2, name):
1536 return self.mesh.IntersectGroups(group1, group2, name)
1538 ## Produces an intersection of groups
1539 # New group is created. All mesh elements that are present in all
1540 # initial groups simultaneously are added to the new one
1541 # @return an instance of SMESH_Group
1542 # @ingroup l2_grps_operon
1543 def IntersectListOfGroups(self, groups, name):
1544 return self.mesh.IntersectListOfGroups(groups, name)
1546 ## Produces a cut of two groups
1547 # A new group is created. All mesh elements that are present in
1548 # the main group but are not present in the tool group are added to the new one
1549 # @return an instance of SMESH_Group
1550 # @ingroup l2_grps_operon
1551 def CutGroups(self, main_group, tool_group, name):
1552 return self.mesh.CutGroups(main_group, tool_group, name)
1554 ## Produces a cut of groups
1555 # A new group is created. All mesh elements that are present in main groups
1556 # but do not present in tool groups are added to the new one
1557 # @return an instance of SMESH_Group
1558 # @ingroup l2_grps_operon
1559 def CutListOfGroups(self, main_groups, tool_groups, name):
1560 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1562 ## Produces a group of elements with specified element type using list of existing groups
1563 # A new group is created. System
1564 # 1) extract all nodes on which groups elements are built
1565 # 2) combine all elements of specified dimension laying on these nodes
1566 # @return an instance of SMESH_Group
1567 # @ingroup l2_grps_operon
1568 def CreateDimGroup(self, groups, elem_type, name):
1569 return self.mesh.CreateDimGroup(groups, elem_type, name)
1572 ## Convert group on geom into standalone group
1573 # @ingroup l2_grps_delete
1574 def ConvertToStandalone(self, group):
1575 return self.mesh.ConvertToStandalone(group)
1577 # Get some info about mesh:
1578 # ------------------------
1580 ## Returns the log of nodes and elements added or removed
1581 # since the previous clear of the log.
1582 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1583 # @return list of log_block structures:
1588 # @ingroup l1_auxiliary
1589 def GetLog(self, clearAfterGet):
1590 return self.mesh.GetLog(clearAfterGet)
1592 ## Clears the log of nodes and elements added or removed since the previous
1593 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1594 # @ingroup l1_auxiliary
1596 self.mesh.ClearLog()
1598 ## Toggles auto color mode on the object.
1599 # @param theAutoColor the flag which toggles auto color mode.
1600 # @ingroup l1_auxiliary
1601 def SetAutoColor(self, theAutoColor):
1602 self.mesh.SetAutoColor(theAutoColor)
1604 ## Gets flag of object auto color mode.
1605 # @return True or False
1606 # @ingroup l1_auxiliary
1607 def GetAutoColor(self):
1608 return self.mesh.GetAutoColor()
1610 ## Gets the internal ID
1611 # @return integer value, which is the internal Id of the mesh
1612 # @ingroup l1_auxiliary
1614 return self.mesh.GetId()
1617 # @return integer value, which is the study Id of the mesh
1618 # @ingroup l1_auxiliary
1619 def GetStudyId(self):
1620 return self.mesh.GetStudyId()
1622 ## Checks the group names for duplications.
1623 # Consider the maximum group name length stored in MED file.
1624 # @return True or False
1625 # @ingroup l1_auxiliary
1626 def HasDuplicatedGroupNamesMED(self):
1627 return self.mesh.HasDuplicatedGroupNamesMED()
1629 ## Obtains the mesh editor tool
1630 # @return an instance of SMESH_MeshEditor
1631 # @ingroup l1_modifying
1632 def GetMeshEditor(self):
1633 return self.mesh.GetMeshEditor()
1636 # @return an instance of SALOME_MED::MESH
1637 # @ingroup l1_auxiliary
1638 def GetMEDMesh(self):
1639 return self.mesh.GetMEDMesh()
1642 # Get informations about mesh contents:
1643 # ------------------------------------
1645 ## Gets the mesh stattistic
1646 # @return dictionary type element - count of elements
1647 # @ingroup l1_meshinfo
1648 def GetMeshInfo(self, obj = None):
1649 if not obj: obj = self.mesh
1651 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1652 values = obj.GetMeshInfo()
1653 for i in range(SMESH.Entity_Last._v):
1654 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1658 ## Returns the number of nodes in the mesh
1659 # @return an integer value
1660 # @ingroup l1_meshinfo
1662 return self.mesh.NbNodes()
1664 ## Returns the number of elements in the mesh
1665 # @return an integer value
1666 # @ingroup l1_meshinfo
1667 def NbElements(self):
1668 return self.mesh.NbElements()
1670 ## Returns the number of 0d elements in the mesh
1671 # @return an integer value
1672 # @ingroup l1_meshinfo
1673 def Nb0DElements(self):
1674 return self.mesh.Nb0DElements()
1676 ## Returns the number of edges in the mesh
1677 # @return an integer value
1678 # @ingroup l1_meshinfo
1680 return self.mesh.NbEdges()
1682 ## Returns the number of edges with the given order in the mesh
1683 # @param elementOrder the order of elements:
1684 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1685 # @return an integer value
1686 # @ingroup l1_meshinfo
1687 def NbEdgesOfOrder(self, elementOrder):
1688 return self.mesh.NbEdgesOfOrder(elementOrder)
1690 ## Returns the number of faces in the mesh
1691 # @return an integer value
1692 # @ingroup l1_meshinfo
1694 return self.mesh.NbFaces()
1696 ## Returns the number of faces with the given order in the mesh
1697 # @param elementOrder the order of elements:
1698 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1699 # @return an integer value
1700 # @ingroup l1_meshinfo
1701 def NbFacesOfOrder(self, elementOrder):
1702 return self.mesh.NbFacesOfOrder(elementOrder)
1704 ## Returns the number of triangles in the mesh
1705 # @return an integer value
1706 # @ingroup l1_meshinfo
1707 def NbTriangles(self):
1708 return self.mesh.NbTriangles()
1710 ## Returns the number of triangles with the given order in the mesh
1711 # @param elementOrder is the order of elements:
1712 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1713 # @return an integer value
1714 # @ingroup l1_meshinfo
1715 def NbTrianglesOfOrder(self, elementOrder):
1716 return self.mesh.NbTrianglesOfOrder(elementOrder)
1718 ## Returns the number of quadrangles in the mesh
1719 # @return an integer value
1720 # @ingroup l1_meshinfo
1721 def NbQuadrangles(self):
1722 return self.mesh.NbQuadrangles()
1724 ## Returns the number of quadrangles with the given order in the mesh
1725 # @param elementOrder the order of elements:
1726 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1727 # @return an integer value
1728 # @ingroup l1_meshinfo
1729 def NbQuadranglesOfOrder(self, elementOrder):
1730 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1732 ## Returns the number of polygons in the mesh
1733 # @return an integer value
1734 # @ingroup l1_meshinfo
1735 def NbPolygons(self):
1736 return self.mesh.NbPolygons()
1738 ## Returns the number of volumes in the mesh
1739 # @return an integer value
1740 # @ingroup l1_meshinfo
1741 def NbVolumes(self):
1742 return self.mesh.NbVolumes()
1744 ## Returns the number of volumes with the given order in the mesh
1745 # @param elementOrder the order of elements:
1746 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1747 # @return an integer value
1748 # @ingroup l1_meshinfo
1749 def NbVolumesOfOrder(self, elementOrder):
1750 return self.mesh.NbVolumesOfOrder(elementOrder)
1752 ## Returns the number of tetrahedrons in the mesh
1753 # @return an integer value
1754 # @ingroup l1_meshinfo
1756 return self.mesh.NbTetras()
1758 ## Returns the number of tetrahedrons with the given order in the mesh
1759 # @param elementOrder the order of elements:
1760 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1761 # @return an integer value
1762 # @ingroup l1_meshinfo
1763 def NbTetrasOfOrder(self, elementOrder):
1764 return self.mesh.NbTetrasOfOrder(elementOrder)
1766 ## Returns the number of hexahedrons in the mesh
1767 # @return an integer value
1768 # @ingroup l1_meshinfo
1770 return self.mesh.NbHexas()
1772 ## Returns the number of hexahedrons with the given order in the mesh
1773 # @param elementOrder the order of elements:
1774 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1775 # @return an integer value
1776 # @ingroup l1_meshinfo
1777 def NbHexasOfOrder(self, elementOrder):
1778 return self.mesh.NbHexasOfOrder(elementOrder)
1780 ## Returns the number of pyramids in the mesh
1781 # @return an integer value
1782 # @ingroup l1_meshinfo
1783 def NbPyramids(self):
1784 return self.mesh.NbPyramids()
1786 ## Returns the number of pyramids with the given order in the mesh
1787 # @param elementOrder the order of elements:
1788 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1789 # @return an integer value
1790 # @ingroup l1_meshinfo
1791 def NbPyramidsOfOrder(self, elementOrder):
1792 return self.mesh.NbPyramidsOfOrder(elementOrder)
1794 ## Returns the number of prisms in the mesh
1795 # @return an integer value
1796 # @ingroup l1_meshinfo
1798 return self.mesh.NbPrisms()
1800 ## Returns the number of prisms with the given order in the mesh
1801 # @param elementOrder the order of elements:
1802 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1803 # @return an integer value
1804 # @ingroup l1_meshinfo
1805 def NbPrismsOfOrder(self, elementOrder):
1806 return self.mesh.NbPrismsOfOrder(elementOrder)
1808 ## Returns the number of polyhedrons in the mesh
1809 # @return an integer value
1810 # @ingroup l1_meshinfo
1811 def NbPolyhedrons(self):
1812 return self.mesh.NbPolyhedrons()
1814 ## Returns the number of submeshes in the mesh
1815 # @return an integer value
1816 # @ingroup l1_meshinfo
1817 def NbSubMesh(self):
1818 return self.mesh.NbSubMesh()
1820 ## Returns the list of mesh elements IDs
1821 # @return the list of integer values
1822 # @ingroup l1_meshinfo
1823 def GetElementsId(self):
1824 return self.mesh.GetElementsId()
1826 ## Returns the list of IDs of mesh elements with the given type
1827 # @param elementType the required type of elements
1828 # @return list of integer values
1829 # @ingroup l1_meshinfo
1830 def GetElementsByType(self, elementType):
1831 return self.mesh.GetElementsByType(elementType)
1833 ## Returns the list of mesh nodes IDs
1834 # @return the list of integer values
1835 # @ingroup l1_meshinfo
1836 def GetNodesId(self):
1837 return self.mesh.GetNodesId()
1839 # Get the information about mesh elements:
1840 # ------------------------------------
1842 ## Returns the type of mesh element
1843 # @return the value from SMESH::ElementType enumeration
1844 # @ingroup l1_meshinfo
1845 def GetElementType(self, id, iselem):
1846 return self.mesh.GetElementType(id, iselem)
1848 ## Returns the list of submesh elements IDs
1849 # @param Shape a geom object(subshape) IOR
1850 # Shape must be the subshape of a ShapeToMesh()
1851 # @return the list of integer values
1852 # @ingroup l1_meshinfo
1853 def GetSubMeshElementsId(self, Shape):
1854 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1855 ShapeID = Shape.GetSubShapeIndices()[0]
1858 return self.mesh.GetSubMeshElementsId(ShapeID)
1860 ## Returns the list of submesh nodes IDs
1861 # @param Shape a geom object(subshape) IOR
1862 # Shape must be the subshape of a ShapeToMesh()
1863 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1864 # @return the list of integer values
1865 # @ingroup l1_meshinfo
1866 def GetSubMeshNodesId(self, Shape, all):
1867 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1868 ShapeID = Shape.GetSubShapeIndices()[0]
1871 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1873 ## Returns type of elements on given shape
1874 # @param Shape a geom object(subshape) IOR
1875 # Shape must be a subshape of a ShapeToMesh()
1876 # @return element type
1877 # @ingroup l1_meshinfo
1878 def GetSubMeshElementType(self, Shape):
1879 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1880 ShapeID = Shape.GetSubShapeIndices()[0]
1883 return self.mesh.GetSubMeshElementType(ShapeID)
1885 ## Gets the mesh description
1886 # @return string value
1887 # @ingroup l1_meshinfo
1889 return self.mesh.Dump()
1892 # Get the information about nodes and elements of a mesh by its IDs:
1893 # -----------------------------------------------------------
1895 ## Gets XYZ coordinates of a node
1896 # \n If there is no nodes for the given ID - returns an empty list
1897 # @return a list of double precision values
1898 # @ingroup l1_meshinfo
1899 def GetNodeXYZ(self, id):
1900 return self.mesh.GetNodeXYZ(id)
1902 ## Returns list of IDs of inverse elements for the given node
1903 # \n If there is no node for the given ID - returns an empty list
1904 # @return a list of integer values
1905 # @ingroup l1_meshinfo
1906 def GetNodeInverseElements(self, id):
1907 return self.mesh.GetNodeInverseElements(id)
1909 ## @brief Returns the position of a node on the shape
1910 # @return SMESH::NodePosition
1911 # @ingroup l1_meshinfo
1912 def GetNodePosition(self,NodeID):
1913 return self.mesh.GetNodePosition(NodeID)
1915 ## If the given element is a node, returns the ID of shape
1916 # \n If there is no node for the given ID - returns -1
1917 # @return an integer value
1918 # @ingroup l1_meshinfo
1919 def GetShapeID(self, id):
1920 return self.mesh.GetShapeID(id)
1922 ## Returns the ID of the result shape after
1923 # FindShape() from SMESH_MeshEditor for the given element
1924 # \n If there is no element for the given ID - returns -1
1925 # @return an integer value
1926 # @ingroup l1_meshinfo
1927 def GetShapeIDForElem(self,id):
1928 return self.mesh.GetShapeIDForElem(id)
1930 ## Returns the number of nodes for the given element
1931 # \n If there is no element for the given ID - returns -1
1932 # @return an integer value
1933 # @ingroup l1_meshinfo
1934 def GetElemNbNodes(self, id):
1935 return self.mesh.GetElemNbNodes(id)
1937 ## Returns the node ID the given index for the given element
1938 # \n If there is no element for the given ID - returns -1
1939 # \n If there is no node for the given index - returns -2
1940 # @return an integer value
1941 # @ingroup l1_meshinfo
1942 def GetElemNode(self, id, index):
1943 return self.mesh.GetElemNode(id, index)
1945 ## Returns the IDs of nodes of the given element
1946 # @return a list of integer values
1947 # @ingroup l1_meshinfo
1948 def GetElemNodes(self, id):
1949 return self.mesh.GetElemNodes(id)
1951 ## Returns true if the given node is the medium node in the given quadratic element
1952 # @ingroup l1_meshinfo
1953 def IsMediumNode(self, elementID, nodeID):
1954 return self.mesh.IsMediumNode(elementID, nodeID)
1956 ## Returns true if the given node is the medium node in one of quadratic elements
1957 # @ingroup l1_meshinfo
1958 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1959 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1961 ## Returns the number of edges for the given element
1962 # @ingroup l1_meshinfo
1963 def ElemNbEdges(self, id):
1964 return self.mesh.ElemNbEdges(id)
1966 ## Returns the number of faces for the given element
1967 # @ingroup l1_meshinfo
1968 def ElemNbFaces(self, id):
1969 return self.mesh.ElemNbFaces(id)
1971 ## Returns true if the given element is a polygon
1972 # @ingroup l1_meshinfo
1973 def IsPoly(self, id):
1974 return self.mesh.IsPoly(id)
1976 ## Returns true if the given element is quadratic
1977 # @ingroup l1_meshinfo
1978 def IsQuadratic(self, id):
1979 return self.mesh.IsQuadratic(id)
1981 ## Returns XYZ coordinates of the barycenter of the given element
1982 # \n If there is no element for the given ID - returns an empty list
1983 # @return a list of three double values
1984 # @ingroup l1_meshinfo
1985 def BaryCenter(self, id):
1986 return self.mesh.BaryCenter(id)
1989 # Mesh edition (SMESH_MeshEditor functionality):
1990 # ---------------------------------------------
1992 ## Removes the elements from the mesh by ids
1993 # @param IDsOfElements is a list of ids of elements to remove
1994 # @return True or False
1995 # @ingroup l2_modif_del
1996 def RemoveElements(self, IDsOfElements):
1997 return self.editor.RemoveElements(IDsOfElements)
1999 ## Removes nodes from mesh by ids
2000 # @param IDsOfNodes is a list of ids of nodes to remove
2001 # @return True or False
2002 # @ingroup l2_modif_del
2003 def RemoveNodes(self, IDsOfNodes):
2004 return self.editor.RemoveNodes(IDsOfNodes)
2006 ## Add a node to the mesh by coordinates
2007 # @return Id of the new node
2008 # @ingroup l2_modif_add
2009 def AddNode(self, x, y, z):
2010 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2011 self.mesh.SetParameters(Parameters)
2012 return self.editor.AddNode( x, y, z)
2014 ## Creates a 0D element on a node with given number.
2015 # @param IDOfNode the ID of node for creation of the element.
2016 # @return the Id of the new 0D element
2017 # @ingroup l2_modif_add
2018 def Add0DElement(self, IDOfNode):
2019 return self.editor.Add0DElement(IDOfNode)
2021 ## Creates a linear or quadratic edge (this is determined
2022 # by the number of given nodes).
2023 # @param IDsOfNodes the list of node IDs for creation of the element.
2024 # The order of nodes in this list should correspond to the description
2025 # of MED. \n This description is located by the following link:
2026 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2027 # @return the Id of the new edge
2028 # @ingroup l2_modif_add
2029 def AddEdge(self, IDsOfNodes):
2030 return self.editor.AddEdge(IDsOfNodes)
2032 ## Creates a linear or quadratic face (this is determined
2033 # by the number of given nodes).
2034 # @param IDsOfNodes the list of node IDs for creation of the element.
2035 # The order of nodes in this list should correspond to the description
2036 # of MED. \n This description is located by the following link:
2037 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2038 # @return the Id of the new face
2039 # @ingroup l2_modif_add
2040 def AddFace(self, IDsOfNodes):
2041 return self.editor.AddFace(IDsOfNodes)
2043 ## Adds a polygonal face to the mesh by the list of node IDs
2044 # @param IdsOfNodes the list of node IDs for creation of the element.
2045 # @return the Id of the new face
2046 # @ingroup l2_modif_add
2047 def AddPolygonalFace(self, IdsOfNodes):
2048 return self.editor.AddPolygonalFace(IdsOfNodes)
2050 ## Creates both simple and quadratic volume (this is determined
2051 # by the number of given nodes).
2052 # @param IDsOfNodes the list of node IDs for creation of the element.
2053 # The order of nodes in this list should correspond to the description
2054 # of MED. \n This description is located by the following link:
2055 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2056 # @return the Id of the new volumic element
2057 # @ingroup l2_modif_add
2058 def AddVolume(self, IDsOfNodes):
2059 return self.editor.AddVolume(IDsOfNodes)
2061 ## Creates a volume of many faces, giving nodes for each face.
2062 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2063 # @param Quantities the list of integer values, Quantities[i]
2064 # gives the quantity of nodes in face number i.
2065 # @return the Id of the new volumic element
2066 # @ingroup l2_modif_add
2067 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2068 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2070 ## Creates a volume of many faces, giving the IDs of the existing faces.
2071 # @param IdsOfFaces the list of face IDs for volume creation.
2073 # Note: The created volume will refer only to the nodes
2074 # of the given faces, not to the faces themselves.
2075 # @return the Id of the new volumic element
2076 # @ingroup l2_modif_add
2077 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2078 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2081 ## @brief Binds a node to a vertex
2082 # @param NodeID a node ID
2083 # @param Vertex a vertex or vertex ID
2084 # @return True if succeed else raises an exception
2085 # @ingroup l2_modif_add
2086 def SetNodeOnVertex(self, NodeID, Vertex):
2087 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2088 VertexID = Vertex.GetSubShapeIndices()[0]
2092 self.editor.SetNodeOnVertex(NodeID, VertexID)
2093 except SALOME.SALOME_Exception, inst:
2094 raise ValueError, inst.details.text
2098 ## @brief Stores the node position on an edge
2099 # @param NodeID a node ID
2100 # @param Edge an edge or edge ID
2101 # @param paramOnEdge a parameter on the edge where the node is located
2102 # @return True if succeed else raises an exception
2103 # @ingroup l2_modif_add
2104 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2105 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2106 EdgeID = Edge.GetSubShapeIndices()[0]
2110 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2111 except SALOME.SALOME_Exception, inst:
2112 raise ValueError, inst.details.text
2115 ## @brief Stores node position on a face
2116 # @param NodeID a node ID
2117 # @param Face a face or face ID
2118 # @param u U parameter on the face where the node is located
2119 # @param v V parameter on the face where the node is located
2120 # @return True if succeed else raises an exception
2121 # @ingroup l2_modif_add
2122 def SetNodeOnFace(self, NodeID, Face, u, v):
2123 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2124 FaceID = Face.GetSubShapeIndices()[0]
2128 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2129 except SALOME.SALOME_Exception, inst:
2130 raise ValueError, inst.details.text
2133 ## @brief Binds a node to a solid
2134 # @param NodeID a node ID
2135 # @param Solid a solid or solid ID
2136 # @return True if succeed else raises an exception
2137 # @ingroup l2_modif_add
2138 def SetNodeInVolume(self, NodeID, Solid):
2139 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2140 SolidID = Solid.GetSubShapeIndices()[0]
2144 self.editor.SetNodeInVolume(NodeID, SolidID)
2145 except SALOME.SALOME_Exception, inst:
2146 raise ValueError, inst.details.text
2149 ## @brief Bind an element to a shape
2150 # @param ElementID an element ID
2151 # @param Shape a shape or shape ID
2152 # @return True if succeed else raises an exception
2153 # @ingroup l2_modif_add
2154 def SetMeshElementOnShape(self, ElementID, Shape):
2155 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2156 ShapeID = Shape.GetSubShapeIndices()[0]
2160 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2161 except SALOME.SALOME_Exception, inst:
2162 raise ValueError, inst.details.text
2166 ## Moves the node with the given id
2167 # @param NodeID the id of the node
2168 # @param x a new X coordinate
2169 # @param y a new Y coordinate
2170 # @param z a new Z coordinate
2171 # @return True if succeed else False
2172 # @ingroup l2_modif_movenode
2173 def MoveNode(self, NodeID, x, y, z):
2174 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2175 self.mesh.SetParameters(Parameters)
2176 return self.editor.MoveNode(NodeID, x, y, z)
2178 ## Finds the node closest to a point and moves it to a point location
2179 # @param x the X coordinate of a point
2180 # @param y the Y coordinate of a point
2181 # @param z the Z coordinate of a point
2182 # @return the ID of a node
2183 # @ingroup l2_modif_throughp
2184 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2185 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2186 self.mesh.SetParameters(Parameters)
2187 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2189 ## Finds the node closest to a point
2190 # @param x the X coordinate of a point
2191 # @param y the Y coordinate of a point
2192 # @param z the Z coordinate of a point
2193 # @return the ID of a node
2194 # @ingroup l2_modif_throughp
2195 def FindNodeClosestTo(self, x, y, z):
2196 #preview = self.mesh.GetMeshEditPreviewer()
2197 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2198 return self.editor.FindNodeClosestTo(x, y, z)
2200 ## Finds the elements where a point lays IN or ON
2201 # @param x the X coordinate of a point
2202 # @param y the Y coordinate of a point
2203 # @param z the Z coordinate of a point
2204 # @param elementType type of elements to find (SMESH.ALL type
2205 # means elements of any type excluding nodes and 0D elements)
2206 # @return list of IDs of found elements
2207 # @ingroup l2_modif_throughp
2208 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2209 return self.editor.FindElementsByPoint(x, y, z, elementType)
2212 ## Finds the node closest to a point and moves it to a point location
2213 # @param x the X coordinate of a point
2214 # @param y the Y coordinate of a point
2215 # @param z the Z coordinate of a point
2216 # @return the ID of a moved node
2217 # @ingroup l2_modif_throughp
2218 def MeshToPassThroughAPoint(self, x, y, z):
2219 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2221 ## Replaces two neighbour triangles sharing Node1-Node2 link
2222 # with the triangles built on the same 4 nodes but having other common link.
2223 # @param NodeID1 the ID of the first node
2224 # @param NodeID2 the ID of the second node
2225 # @return false if proper faces were not found
2226 # @ingroup l2_modif_invdiag
2227 def InverseDiag(self, NodeID1, NodeID2):
2228 return self.editor.InverseDiag(NodeID1, NodeID2)
2230 ## Replaces two neighbour triangles sharing Node1-Node2 link
2231 # with a quadrangle built on the same 4 nodes.
2232 # @param NodeID1 the ID of the first node
2233 # @param NodeID2 the ID of the second node
2234 # @return false if proper faces were not found
2235 # @ingroup l2_modif_unitetri
2236 def DeleteDiag(self, NodeID1, NodeID2):
2237 return self.editor.DeleteDiag(NodeID1, NodeID2)
2239 ## Reorients elements by ids
2240 # @param IDsOfElements if undefined reorients all mesh elements
2241 # @return True if succeed else False
2242 # @ingroup l2_modif_changori
2243 def Reorient(self, IDsOfElements=None):
2244 if IDsOfElements == None:
2245 IDsOfElements = self.GetElementsId()
2246 return self.editor.Reorient(IDsOfElements)
2248 ## Reorients all elements of the object
2249 # @param theObject mesh, submesh or group
2250 # @return True if succeed else False
2251 # @ingroup l2_modif_changori
2252 def ReorientObject(self, theObject):
2253 if ( isinstance( theObject, Mesh )):
2254 theObject = theObject.GetMesh()
2255 return self.editor.ReorientObject(theObject)
2257 ## Fuses the neighbouring triangles into quadrangles.
2258 # @param IDsOfElements The triangles to be fused,
2259 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2260 # @param MaxAngle is the maximum angle between element normals at which the fusion
2261 # is still performed; theMaxAngle is mesured in radians.
2262 # Also it could be a name of variable which defines angle in degrees.
2263 # @return TRUE in case of success, FALSE otherwise.
2264 # @ingroup l2_modif_unitetri
2265 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2267 if isinstance(MaxAngle,str):
2269 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2271 MaxAngle = DegreesToRadians(MaxAngle)
2272 if IDsOfElements == []:
2273 IDsOfElements = self.GetElementsId()
2274 self.mesh.SetParameters(Parameters)
2276 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2277 Functor = theCriterion
2279 Functor = self.smeshpyD.GetFunctor(theCriterion)
2280 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2282 ## Fuses the neighbouring triangles of the object into quadrangles
2283 # @param theObject is mesh, submesh or group
2284 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2285 # @param MaxAngle a max angle between element normals at which the fusion
2286 # is still performed; theMaxAngle is mesured in radians.
2287 # @return TRUE in case of success, FALSE otherwise.
2288 # @ingroup l2_modif_unitetri
2289 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2290 if ( isinstance( theObject, Mesh )):
2291 theObject = theObject.GetMesh()
2292 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2294 ## Splits quadrangles into triangles.
2295 # @param IDsOfElements the faces to be splitted.
2296 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2297 # @return TRUE in case of success, FALSE otherwise.
2298 # @ingroup l2_modif_cutquadr
2299 def QuadToTri (self, IDsOfElements, theCriterion):
2300 if IDsOfElements == []:
2301 IDsOfElements = self.GetElementsId()
2302 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2304 ## Splits quadrangles into triangles.
2305 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2306 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2307 # @return TRUE in case of success, FALSE otherwise.
2308 # @ingroup l2_modif_cutquadr
2309 def QuadToTriObject (self, theObject, theCriterion):
2310 if ( isinstance( theObject, Mesh )):
2311 theObject = theObject.GetMesh()
2312 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2314 ## Splits quadrangles into triangles.
2315 # @param IDsOfElements the faces to be splitted
2316 # @param Diag13 is used to choose a diagonal for splitting.
2317 # @return TRUE in case of success, FALSE otherwise.
2318 # @ingroup l2_modif_cutquadr
2319 def SplitQuad (self, IDsOfElements, Diag13):
2320 if IDsOfElements == []:
2321 IDsOfElements = self.GetElementsId()
2322 return self.editor.SplitQuad(IDsOfElements, Diag13)
2324 ## Splits quadrangles into triangles.
2325 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2326 # @param Diag13 is used to choose a diagonal for splitting.
2327 # @return TRUE in case of success, FALSE otherwise.
2328 # @ingroup l2_modif_cutquadr
2329 def SplitQuadObject (self, theObject, Diag13):
2330 if ( isinstance( theObject, Mesh )):
2331 theObject = theObject.GetMesh()
2332 return self.editor.SplitQuadObject(theObject, Diag13)
2334 ## Finds a better splitting of the given quadrangle.
2335 # @param IDOfQuad the ID of the quadrangle to be splitted.
2336 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2337 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2338 # diagonal is better, 0 if error occurs.
2339 # @ingroup l2_modif_cutquadr
2340 def BestSplit (self, IDOfQuad, theCriterion):
2341 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2343 ## Splits quadrangle faces near triangular facets of volumes
2345 # @ingroup l1_auxiliary
2346 def SplitQuadsNearTriangularFacets(self):
2347 faces_array = self.GetElementsByType(SMESH.FACE)
2348 for face_id in faces_array:
2349 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2350 quad_nodes = self.mesh.GetElemNodes(face_id)
2351 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2352 isVolumeFound = False
2353 for node1_elem in node1_elems:
2354 if not isVolumeFound:
2355 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2356 nb_nodes = self.GetElemNbNodes(node1_elem)
2357 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2358 volume_elem = node1_elem
2359 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2360 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2361 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2362 isVolumeFound = True
2363 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2364 self.SplitQuad([face_id], False) # diagonal 2-4
2365 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2366 isVolumeFound = True
2367 self.SplitQuad([face_id], True) # diagonal 1-3
2368 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2369 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2370 isVolumeFound = True
2371 self.SplitQuad([face_id], True) # diagonal 1-3
2373 ## @brief Splits hexahedrons into tetrahedrons.
2375 # This operation uses pattern mapping functionality for splitting.
2376 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2377 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2378 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2379 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2380 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2381 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2382 # @return TRUE in case of success, FALSE otherwise.
2383 # @ingroup l1_auxiliary
2384 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2385 # Pattern: 5.---------.6
2390 # (0,0,1) 4.---------.7 * |
2397 # (0,0,0) 0.---------.3
2398 pattern_tetra = "!!! Nb of points: \n 8 \n\
2408 !!! Indices of points of 6 tetras: \n\
2416 pattern = self.smeshpyD.GetPattern()
2417 isDone = pattern.LoadFromFile(pattern_tetra)
2419 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2422 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2423 isDone = pattern.MakeMesh(self.mesh, False, False)
2424 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2426 # split quafrangle faces near triangular facets of volumes
2427 self.SplitQuadsNearTriangularFacets()
2431 ## @brief Split hexahedrons into prisms.
2433 # Uses the pattern mapping functionality for splitting.
2434 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2435 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2436 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2437 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2438 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2439 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2440 # @return TRUE in case of success, FALSE otherwise.
2441 # @ingroup l1_auxiliary
2442 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2443 # Pattern: 5.---------.6
2448 # (0,0,1) 4.---------.7 |
2455 # (0,0,0) 0.---------.3
2456 pattern_prism = "!!! Nb of points: \n 8 \n\
2466 !!! Indices of points of 2 prisms: \n\
2470 pattern = self.smeshpyD.GetPattern()
2471 isDone = pattern.LoadFromFile(pattern_prism)
2473 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2476 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2477 isDone = pattern.MakeMesh(self.mesh, False, False)
2478 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2480 # Splits quafrangle faces near triangular facets of volumes
2481 self.SplitQuadsNearTriangularFacets()
2485 ## Smoothes elements
2486 # @param IDsOfElements the list if ids of elements to smooth
2487 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2488 # Note that nodes built on edges and boundary nodes are always fixed.
2489 # @param MaxNbOfIterations the maximum number of iterations
2490 # @param MaxAspectRatio varies in range [1.0, inf]
2491 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2492 # @return TRUE in case of success, FALSE otherwise.
2493 # @ingroup l2_modif_smooth
2494 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2495 MaxNbOfIterations, MaxAspectRatio, Method):
2496 if IDsOfElements == []:
2497 IDsOfElements = self.GetElementsId()
2498 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2499 self.mesh.SetParameters(Parameters)
2500 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2501 MaxNbOfIterations, MaxAspectRatio, Method)
2503 ## Smoothes elements which belong to the given object
2504 # @param theObject the object to smooth
2505 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2506 # Note that nodes built on edges and boundary nodes are always fixed.
2507 # @param MaxNbOfIterations the maximum number of iterations
2508 # @param MaxAspectRatio varies in range [1.0, inf]
2509 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2510 # @return TRUE in case of success, FALSE otherwise.
2511 # @ingroup l2_modif_smooth
2512 def SmoothObject(self, theObject, IDsOfFixedNodes,
2513 MaxNbOfIterations, MaxAspectRatio, Method):
2514 if ( isinstance( theObject, Mesh )):
2515 theObject = theObject.GetMesh()
2516 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2517 MaxNbOfIterations, MaxAspectRatio, Method)
2519 ## Parametrically smoothes the given elements
2520 # @param IDsOfElements the list if ids of elements to smooth
2521 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2522 # Note that nodes built on edges and boundary nodes are always fixed.
2523 # @param MaxNbOfIterations the maximum number of iterations
2524 # @param MaxAspectRatio varies in range [1.0, inf]
2525 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2526 # @return TRUE in case of success, FALSE otherwise.
2527 # @ingroup l2_modif_smooth
2528 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2529 MaxNbOfIterations, MaxAspectRatio, Method):
2530 if IDsOfElements == []:
2531 IDsOfElements = self.GetElementsId()
2532 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2533 self.mesh.SetParameters(Parameters)
2534 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2535 MaxNbOfIterations, MaxAspectRatio, Method)
2537 ## Parametrically smoothes the elements which belong to the given object
2538 # @param theObject the object to smooth
2539 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2540 # Note that nodes built on edges and boundary nodes are always fixed.
2541 # @param MaxNbOfIterations the maximum number of iterations
2542 # @param MaxAspectRatio varies in range [1.0, inf]
2543 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2544 # @return TRUE in case of success, FALSE otherwise.
2545 # @ingroup l2_modif_smooth
2546 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2547 MaxNbOfIterations, MaxAspectRatio, Method):
2548 if ( isinstance( theObject, Mesh )):
2549 theObject = theObject.GetMesh()
2550 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2551 MaxNbOfIterations, MaxAspectRatio, Method)
2553 ## Converts the mesh to quadratic, deletes old elements, replacing
2554 # them with quadratic with the same id.
2555 # @ingroup l2_modif_tofromqu
2556 def ConvertToQuadratic(self, theForce3d):
2557 self.editor.ConvertToQuadratic(theForce3d)
2559 ## Converts the mesh from quadratic to ordinary,
2560 # deletes old quadratic elements, \n replacing
2561 # them with ordinary mesh elements with the same id.
2562 # @return TRUE in case of success, FALSE otherwise.
2563 # @ingroup l2_modif_tofromqu
2564 def ConvertFromQuadratic(self):
2565 return self.editor.ConvertFromQuadratic()
2567 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2568 # @return TRUE if operation has been completed successfully, FALSE otherwise
2569 # @ingroup l2_modif_edit
2570 def Make2DMeshFrom3D(self):
2571 return self.editor. Make2DMeshFrom3D()
2573 ## Renumber mesh nodes
2574 # @ingroup l2_modif_renumber
2575 def RenumberNodes(self):
2576 self.editor.RenumberNodes()
2578 ## Renumber mesh elements
2579 # @ingroup l2_modif_renumber
2580 def RenumberElements(self):
2581 self.editor.RenumberElements()
2583 ## Generates new elements by rotation of the elements around the axis
2584 # @param IDsOfElements the list of ids of elements to sweep
2585 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2586 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2587 # @param NbOfSteps the number of steps
2588 # @param Tolerance tolerance
2589 # @param MakeGroups forces the generation of new groups from existing ones
2590 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2591 # of all steps, else - size of each step
2592 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2593 # @ingroup l2_modif_extrurev
2594 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2595 MakeGroups=False, TotalAngle=False):
2597 if isinstance(AngleInRadians,str):
2599 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2601 AngleInRadians = DegreesToRadians(AngleInRadians)
2602 if IDsOfElements == []:
2603 IDsOfElements = self.GetElementsId()
2604 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2605 Axis = self.smeshpyD.GetAxisStruct(Axis)
2606 Axis,AxisParameters = ParseAxisStruct(Axis)
2607 if TotalAngle and NbOfSteps:
2608 AngleInRadians /= NbOfSteps
2609 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2610 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2611 self.mesh.SetParameters(Parameters)
2613 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2614 AngleInRadians, NbOfSteps, Tolerance)
2615 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2618 ## Generates new elements by rotation of the elements of object around the axis
2619 # @param theObject object which elements should be sweeped
2620 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2621 # @param AngleInRadians the angle of Rotation
2622 # @param NbOfSteps number of steps
2623 # @param Tolerance tolerance
2624 # @param MakeGroups forces the generation of new groups from existing ones
2625 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2626 # of all steps, else - size of each step
2627 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2628 # @ingroup l2_modif_extrurev
2629 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2630 MakeGroups=False, TotalAngle=False):
2632 if isinstance(AngleInRadians,str):
2634 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2636 AngleInRadians = DegreesToRadians(AngleInRadians)
2637 if ( isinstance( theObject, Mesh )):
2638 theObject = theObject.GetMesh()
2639 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2640 Axis = self.smeshpyD.GetAxisStruct(Axis)
2641 Axis,AxisParameters = ParseAxisStruct(Axis)
2642 if TotalAngle and NbOfSteps:
2643 AngleInRadians /= NbOfSteps
2644 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2645 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2646 self.mesh.SetParameters(Parameters)
2648 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2649 NbOfSteps, Tolerance)
2650 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2653 ## Generates new elements by rotation of the elements of object around the axis
2654 # @param theObject object which elements should be sweeped
2655 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2656 # @param AngleInRadians the angle of Rotation
2657 # @param NbOfSteps number of steps
2658 # @param Tolerance tolerance
2659 # @param MakeGroups forces the generation of new groups from existing ones
2660 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2661 # of all steps, else - size of each step
2662 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2663 # @ingroup l2_modif_extrurev
2664 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2665 MakeGroups=False, TotalAngle=False):
2667 if isinstance(AngleInRadians,str):
2669 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2671 AngleInRadians = DegreesToRadians(AngleInRadians)
2672 if ( isinstance( theObject, Mesh )):
2673 theObject = theObject.GetMesh()
2674 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2675 Axis = self.smeshpyD.GetAxisStruct(Axis)
2676 Axis,AxisParameters = ParseAxisStruct(Axis)
2677 if TotalAngle and NbOfSteps:
2678 AngleInRadians /= NbOfSteps
2679 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2680 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2681 self.mesh.SetParameters(Parameters)
2683 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2684 NbOfSteps, Tolerance)
2685 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2688 ## Generates new elements by rotation of the elements of object around the axis
2689 # @param theObject object which elements should be sweeped
2690 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2691 # @param AngleInRadians the angle of Rotation
2692 # @param NbOfSteps number of steps
2693 # @param Tolerance tolerance
2694 # @param MakeGroups forces the generation of new groups from existing ones
2695 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2696 # of all steps, else - size of each step
2697 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2698 # @ingroup l2_modif_extrurev
2699 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2700 MakeGroups=False, TotalAngle=False):
2702 if isinstance(AngleInRadians,str):
2704 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2706 AngleInRadians = DegreesToRadians(AngleInRadians)
2707 if ( isinstance( theObject, Mesh )):
2708 theObject = theObject.GetMesh()
2709 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2710 Axis = self.smeshpyD.GetAxisStruct(Axis)
2711 Axis,AxisParameters = ParseAxisStruct(Axis)
2712 if TotalAngle and NbOfSteps:
2713 AngleInRadians /= NbOfSteps
2714 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2715 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2716 self.mesh.SetParameters(Parameters)
2718 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2719 NbOfSteps, Tolerance)
2720 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2723 ## Generates new elements by extrusion of the elements with given ids
2724 # @param IDsOfElements the list of elements ids for extrusion
2725 # @param StepVector vector, defining the direction and value of extrusion
2726 # @param NbOfSteps the number of steps
2727 # @param MakeGroups forces the generation of new groups from existing ones
2728 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2729 # @ingroup l2_modif_extrurev
2730 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2731 if IDsOfElements == []:
2732 IDsOfElements = self.GetElementsId()
2733 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2734 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2735 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2736 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2737 Parameters = StepVectorParameters + var_separator + Parameters
2738 self.mesh.SetParameters(Parameters)
2740 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2741 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2744 ## Generates new elements by extrusion of the elements with given ids
2745 # @param IDsOfElements is ids of elements
2746 # @param StepVector vector, defining the direction and value of extrusion
2747 # @param NbOfSteps the number of steps
2748 # @param ExtrFlags sets flags for extrusion
2749 # @param SewTolerance uses for comparing locations of nodes if flag
2750 # EXTRUSION_FLAG_SEW is set
2751 # @param MakeGroups forces the generation of new groups from existing ones
2752 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2753 # @ingroup l2_modif_extrurev
2754 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2755 ExtrFlags, SewTolerance, MakeGroups=False):
2756 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2757 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2759 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2760 ExtrFlags, SewTolerance)
2761 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2762 ExtrFlags, SewTolerance)
2765 ## Generates new elements by extrusion of the elements which belong to the object
2766 # @param theObject the object which elements should be processed
2767 # @param StepVector vector, defining the direction and value of extrusion
2768 # @param NbOfSteps the number of steps
2769 # @param MakeGroups forces the generation of new groups from existing ones
2770 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2771 # @ingroup l2_modif_extrurev
2772 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2773 if ( isinstance( theObject, Mesh )):
2774 theObject = theObject.GetMesh()
2775 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2776 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2777 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2778 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2779 Parameters = StepVectorParameters + var_separator + Parameters
2780 self.mesh.SetParameters(Parameters)
2782 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2783 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2786 ## Generates new elements by extrusion of the elements which belong to the object
2787 # @param theObject object which elements should be processed
2788 # @param StepVector vector, defining the direction and value of extrusion
2789 # @param NbOfSteps the number of steps
2790 # @param MakeGroups to generate new groups from existing ones
2791 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2792 # @ingroup l2_modif_extrurev
2793 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2794 if ( isinstance( theObject, Mesh )):
2795 theObject = theObject.GetMesh()
2796 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2797 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2798 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2799 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2800 Parameters = StepVectorParameters + var_separator + Parameters
2801 self.mesh.SetParameters(Parameters)
2803 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2804 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2807 ## Generates new elements by extrusion of the elements which belong to the object
2808 # @param theObject object which elements should be processed
2809 # @param StepVector vector, defining the direction and value of extrusion
2810 # @param NbOfSteps the number of steps
2811 # @param MakeGroups forces the generation of new groups from existing ones
2812 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2813 # @ingroup l2_modif_extrurev
2814 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2815 if ( isinstance( theObject, Mesh )):
2816 theObject = theObject.GetMesh()
2817 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2818 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2819 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2820 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2821 Parameters = StepVectorParameters + var_separator + Parameters
2822 self.mesh.SetParameters(Parameters)
2824 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2825 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2830 ## Generates new elements by extrusion of the given elements
2831 # The path of extrusion must be a meshed edge.
2832 # @param Base mesh or list of ids of elements for extrusion
2833 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2834 # @param NodeStart the start node from Path. Defines the direction of extrusion
2835 # @param HasAngles allows the shape to be rotated around the path
2836 # to get the resulting mesh in a helical fashion
2837 # @param Angles list of angles in radians
2838 # @param LinearVariation forces the computation of rotation angles as linear
2839 # variation of the given Angles along path steps
2840 # @param HasRefPoint allows using the reference point
2841 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2842 # The User can specify any point as the Reference Point.
2843 # @param MakeGroups forces the generation of new groups from existing ones
2844 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2845 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2846 # only SMESH::Extrusion_Error otherwise
2847 # @ingroup l2_modif_extrurev
2848 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2849 HasAngles, Angles, LinearVariation,
2850 HasRefPoint, RefPoint, MakeGroups, ElemType):
2851 Angles,AnglesParameters = ParseAngles(Angles)
2852 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2853 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2854 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2856 Parameters = AnglesParameters + var_separator + RefPointParameters
2857 self.mesh.SetParameters(Parameters)
2859 if isinstance(Base,list):
2861 if Base == []: IDsOfElements = self.GetElementsId()
2862 else: IDsOfElements = Base
2863 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2864 HasAngles, Angles, LinearVariation,
2865 HasRefPoint, RefPoint, MakeGroups, ElemType)
2867 if isinstance(Base,Mesh):
2868 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2869 HasAngles, Angles, LinearVariation,
2870 HasRefPoint, RefPoint, MakeGroups, ElemType)
2872 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2875 ## Generates new elements by extrusion of the given elements
2876 # The path of extrusion must be a meshed edge.
2877 # @param IDsOfElements ids of elements
2878 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2879 # @param PathShape shape(edge) defines the sub-mesh for the path
2880 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2881 # @param HasAngles allows the shape to be rotated around the path
2882 # to get the resulting mesh in a helical fashion
2883 # @param Angles list of angles in radians
2884 # @param HasRefPoint allows using the reference point
2885 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2886 # The User can specify any point as the Reference Point.
2887 # @param MakeGroups forces the generation of new groups from existing ones
2888 # @param LinearVariation forces the computation of rotation angles as linear
2889 # variation of the given Angles along path steps
2890 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2891 # only SMESH::Extrusion_Error otherwise
2892 # @ingroup l2_modif_extrurev
2893 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2894 HasAngles, Angles, HasRefPoint, RefPoint,
2895 MakeGroups=False, LinearVariation=False):
2896 Angles,AnglesParameters = ParseAngles(Angles)
2897 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2898 if IDsOfElements == []:
2899 IDsOfElements = self.GetElementsId()
2900 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2901 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2903 if ( isinstance( PathMesh, Mesh )):
2904 PathMesh = PathMesh.GetMesh()
2905 if HasAngles and Angles and LinearVariation:
2906 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2908 Parameters = AnglesParameters + var_separator + RefPointParameters
2909 self.mesh.SetParameters(Parameters)
2911 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2912 PathShape, NodeStart, HasAngles,
2913 Angles, HasRefPoint, RefPoint)
2914 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2915 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2917 ## Generates new elements by extrusion of the elements which belong to the object
2918 # The path of extrusion must be a meshed edge.
2919 # @param theObject the object which elements should be processed
2920 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2921 # @param PathShape shape(edge) defines the sub-mesh for the path
2922 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2923 # @param HasAngles allows the shape to be rotated around the path
2924 # to get the resulting mesh in a helical fashion
2925 # @param Angles list of angles
2926 # @param HasRefPoint allows using the reference point
2927 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2928 # The User can specify any point as the Reference Point.
2929 # @param MakeGroups forces the generation of new groups from existing ones
2930 # @param LinearVariation forces the computation of rotation angles as linear
2931 # variation of the given Angles along path steps
2932 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2933 # only SMESH::Extrusion_Error otherwise
2934 # @ingroup l2_modif_extrurev
2935 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2936 HasAngles, Angles, HasRefPoint, RefPoint,
2937 MakeGroups=False, LinearVariation=False):
2938 Angles,AnglesParameters = ParseAngles(Angles)
2939 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2940 if ( isinstance( theObject, Mesh )):
2941 theObject = theObject.GetMesh()
2942 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2943 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2944 if ( isinstance( PathMesh, Mesh )):
2945 PathMesh = PathMesh.GetMesh()
2946 if HasAngles and Angles and LinearVariation:
2947 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2949 Parameters = AnglesParameters + var_separator + RefPointParameters
2950 self.mesh.SetParameters(Parameters)
2952 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2953 PathShape, NodeStart, HasAngles,
2954 Angles, HasRefPoint, RefPoint)
2955 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2956 NodeStart, HasAngles, Angles, HasRefPoint,
2959 ## Generates new elements by extrusion of the elements which belong to the object
2960 # The path of extrusion must be a meshed edge.
2961 # @param theObject the object which elements should be processed
2962 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2963 # @param PathShape shape(edge) defines the sub-mesh for the path
2964 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2965 # @param HasAngles allows the shape to be rotated around the path
2966 # to get the resulting mesh in a helical fashion
2967 # @param Angles list of angles
2968 # @param HasRefPoint allows using the reference point
2969 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2970 # The User can specify any point as the Reference Point.
2971 # @param MakeGroups forces the generation of new groups from existing ones
2972 # @param LinearVariation forces the computation of rotation angles as linear
2973 # variation of the given Angles along path steps
2974 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2975 # only SMESH::Extrusion_Error otherwise
2976 # @ingroup l2_modif_extrurev
2977 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2978 HasAngles, Angles, HasRefPoint, RefPoint,
2979 MakeGroups=False, LinearVariation=False):
2980 Angles,AnglesParameters = ParseAngles(Angles)
2981 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2982 if ( isinstance( theObject, Mesh )):
2983 theObject = theObject.GetMesh()
2984 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2985 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2986 if ( isinstance( PathMesh, Mesh )):
2987 PathMesh = PathMesh.GetMesh()
2988 if HasAngles and Angles and LinearVariation:
2989 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2991 Parameters = AnglesParameters + var_separator + RefPointParameters
2992 self.mesh.SetParameters(Parameters)
2994 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2995 PathShape, NodeStart, HasAngles,
2996 Angles, HasRefPoint, RefPoint)
2997 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2998 NodeStart, HasAngles, Angles, HasRefPoint,
3001 ## Generates new elements by extrusion of the elements which belong to the object
3002 # The path of extrusion must be a meshed edge.
3003 # @param theObject the object which elements should be processed
3004 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3005 # @param PathShape shape(edge) defines the sub-mesh for the path
3006 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3007 # @param HasAngles allows the shape to be rotated around the path
3008 # to get the resulting mesh in a helical fashion
3009 # @param Angles list of angles
3010 # @param HasRefPoint allows using the reference point
3011 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3012 # The User can specify any point as the Reference Point.
3013 # @param MakeGroups forces the generation of new groups from existing ones
3014 # @param LinearVariation forces the computation of rotation angles as linear
3015 # variation of the given Angles along path steps
3016 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3017 # only SMESH::Extrusion_Error otherwise
3018 # @ingroup l2_modif_extrurev
3019 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3020 HasAngles, Angles, HasRefPoint, RefPoint,
3021 MakeGroups=False, LinearVariation=False):
3022 Angles,AnglesParameters = ParseAngles(Angles)
3023 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3024 if ( isinstance( theObject, Mesh )):
3025 theObject = theObject.GetMesh()
3026 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3027 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3028 if ( isinstance( PathMesh, Mesh )):
3029 PathMesh = PathMesh.GetMesh()
3030 if HasAngles and Angles and LinearVariation:
3031 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3033 Parameters = AnglesParameters + var_separator + RefPointParameters
3034 self.mesh.SetParameters(Parameters)
3036 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3037 PathShape, NodeStart, HasAngles,
3038 Angles, HasRefPoint, RefPoint)
3039 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3040 NodeStart, HasAngles, Angles, HasRefPoint,
3043 ## Creates a symmetrical copy of mesh elements
3044 # @param IDsOfElements list of elements ids
3045 # @param Mirror is AxisStruct or geom object(point, line, plane)
3046 # @param theMirrorType is POINT, AXIS or PLANE
3047 # If the Mirror is a geom object this parameter is unnecessary
3048 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3049 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3050 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3051 # @ingroup l2_modif_trsf
3052 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3053 if IDsOfElements == []:
3054 IDsOfElements = self.GetElementsId()
3055 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3056 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3057 Mirror,Parameters = ParseAxisStruct(Mirror)
3058 self.mesh.SetParameters(Parameters)
3059 if Copy and MakeGroups:
3060 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3061 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3064 ## Creates a new mesh by a symmetrical copy of mesh elements
3065 # @param IDsOfElements the list of elements ids
3066 # @param Mirror is AxisStruct or geom object (point, line, plane)
3067 # @param theMirrorType is POINT, AXIS or PLANE
3068 # If the Mirror is a geom object this parameter is unnecessary
3069 # @param MakeGroups to generate new groups from existing ones
3070 # @param NewMeshName a name of the new mesh to create
3071 # @return instance of Mesh class
3072 # @ingroup l2_modif_trsf
3073 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3074 if IDsOfElements == []:
3075 IDsOfElements = self.GetElementsId()
3076 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3077 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3078 Mirror,Parameters = ParseAxisStruct(Mirror)
3079 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3080 MakeGroups, NewMeshName)
3081 mesh.SetParameters(Parameters)
3082 return Mesh(self.smeshpyD,self.geompyD,mesh)
3084 ## Creates a symmetrical copy of the object
3085 # @param theObject mesh, submesh or group
3086 # @param Mirror AxisStruct or geom object (point, line, plane)
3087 # @param theMirrorType is POINT, AXIS or PLANE
3088 # If the Mirror is a geom object this parameter is unnecessary
3089 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3090 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3091 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3092 # @ingroup l2_modif_trsf
3093 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3094 if ( isinstance( theObject, Mesh )):
3095 theObject = theObject.GetMesh()
3096 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3097 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3098 Mirror,Parameters = ParseAxisStruct(Mirror)
3099 self.mesh.SetParameters(Parameters)
3100 if Copy and MakeGroups:
3101 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3102 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3105 ## Creates a new mesh by a symmetrical copy of the object
3106 # @param theObject mesh, submesh or group
3107 # @param Mirror AxisStruct or geom object (point, line, plane)
3108 # @param theMirrorType POINT, AXIS or PLANE
3109 # If the Mirror is a geom object this parameter is unnecessary
3110 # @param MakeGroups forces the generation of new groups from existing ones
3111 # @param NewMeshName the name of the new mesh to create
3112 # @return instance of Mesh class
3113 # @ingroup l2_modif_trsf
3114 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3115 if ( isinstance( theObject, Mesh )):
3116 theObject = theObject.GetMesh()
3117 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3118 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3119 Mirror,Parameters = ParseAxisStruct(Mirror)
3120 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3121 MakeGroups, NewMeshName)
3122 mesh.SetParameters(Parameters)
3123 return Mesh( self.smeshpyD,self.geompyD,mesh )
3125 ## Translates the elements
3126 # @param IDsOfElements list of elements ids
3127 # @param Vector the direction of translation (DirStruct or vector)
3128 # @param Copy allows copying the translated elements
3129 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3130 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3131 # @ingroup l2_modif_trsf
3132 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3133 if IDsOfElements == []:
3134 IDsOfElements = self.GetElementsId()
3135 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3136 Vector = self.smeshpyD.GetDirStruct(Vector)
3137 Vector,Parameters = ParseDirStruct(Vector)
3138 self.mesh.SetParameters(Parameters)
3139 if Copy and MakeGroups:
3140 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3141 self.editor.Translate(IDsOfElements, Vector, Copy)
3144 ## Creates a new mesh of translated elements
3145 # @param IDsOfElements list of elements ids
3146 # @param Vector the direction of translation (DirStruct or vector)
3147 # @param MakeGroups forces the generation of new groups from existing ones
3148 # @param NewMeshName the name of the newly created mesh
3149 # @return instance of Mesh class
3150 # @ingroup l2_modif_trsf
3151 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3152 if IDsOfElements == []:
3153 IDsOfElements = self.GetElementsId()
3154 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3155 Vector = self.smeshpyD.GetDirStruct(Vector)
3156 Vector,Parameters = ParseDirStruct(Vector)
3157 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3158 mesh.SetParameters(Parameters)
3159 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3161 ## Translates the object
3162 # @param theObject the object to translate (mesh, submesh, or group)
3163 # @param Vector direction of translation (DirStruct or geom vector)
3164 # @param Copy allows copying the translated elements
3165 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3166 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3167 # @ingroup l2_modif_trsf
3168 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3169 if ( isinstance( theObject, Mesh )):
3170 theObject = theObject.GetMesh()
3171 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3172 Vector = self.smeshpyD.GetDirStruct(Vector)
3173 Vector,Parameters = ParseDirStruct(Vector)
3174 self.mesh.SetParameters(Parameters)
3175 if Copy and MakeGroups:
3176 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3177 self.editor.TranslateObject(theObject, Vector, Copy)
3180 ## Creates a new mesh from the translated object
3181 # @param theObject the object to translate (mesh, submesh, or group)
3182 # @param Vector the direction of translation (DirStruct or geom vector)
3183 # @param MakeGroups forces the generation of new groups from existing ones
3184 # @param NewMeshName the name of the newly created mesh
3185 # @return instance of Mesh class
3186 # @ingroup l2_modif_trsf
3187 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3188 if (isinstance(theObject, Mesh)):
3189 theObject = theObject.GetMesh()
3190 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3191 Vector = self.smeshpyD.GetDirStruct(Vector)
3192 Vector,Parameters = ParseDirStruct(Vector)
3193 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3194 mesh.SetParameters(Parameters)
3195 return Mesh( self.smeshpyD, self.geompyD, mesh )
3197 ## Rotates the elements
3198 # @param IDsOfElements list of elements ids
3199 # @param Axis the axis of rotation (AxisStruct or geom line)
3200 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3201 # @param Copy allows copying the rotated elements
3202 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3203 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3204 # @ingroup l2_modif_trsf
3205 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3207 if isinstance(AngleInRadians,str):
3209 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3211 AngleInRadians = DegreesToRadians(AngleInRadians)
3212 if IDsOfElements == []:
3213 IDsOfElements = self.GetElementsId()
3214 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3215 Axis = self.smeshpyD.GetAxisStruct(Axis)
3216 Axis,AxisParameters = ParseAxisStruct(Axis)
3217 Parameters = AxisParameters + var_separator + Parameters
3218 self.mesh.SetParameters(Parameters)
3219 if Copy and MakeGroups:
3220 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3221 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3224 ## Creates a new mesh of rotated elements
3225 # @param IDsOfElements list of element ids
3226 # @param Axis the axis of rotation (AxisStruct or geom line)
3227 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3228 # @param MakeGroups forces the generation of new groups from existing ones
3229 # @param NewMeshName the name of the newly created mesh
3230 # @return instance of Mesh class
3231 # @ingroup l2_modif_trsf
3232 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3234 if isinstance(AngleInRadians,str):
3236 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3238 AngleInRadians = DegreesToRadians(AngleInRadians)
3239 if IDsOfElements == []:
3240 IDsOfElements = self.GetElementsId()
3241 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3242 Axis = self.smeshpyD.GetAxisStruct(Axis)
3243 Axis,AxisParameters = ParseAxisStruct(Axis)
3244 Parameters = AxisParameters + var_separator + Parameters
3245 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3246 MakeGroups, NewMeshName)
3247 mesh.SetParameters(Parameters)
3248 return Mesh( self.smeshpyD, self.geompyD, mesh )
3250 ## Rotates the object
3251 # @param theObject the object to rotate( mesh, submesh, or group)
3252 # @param Axis the axis of rotation (AxisStruct or geom line)
3253 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3254 # @param Copy allows copying the rotated elements
3255 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3256 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3257 # @ingroup l2_modif_trsf
3258 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3260 if isinstance(AngleInRadians,str):
3262 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3264 AngleInRadians = DegreesToRadians(AngleInRadians)
3265 if (isinstance(theObject, Mesh)):
3266 theObject = theObject.GetMesh()
3267 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3268 Axis = self.smeshpyD.GetAxisStruct(Axis)
3269 Axis,AxisParameters = ParseAxisStruct(Axis)
3270 Parameters = AxisParameters + ":" + Parameters
3271 self.mesh.SetParameters(Parameters)
3272 if Copy and MakeGroups:
3273 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3274 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3277 ## Creates a new mesh from the rotated object
3278 # @param theObject the object to rotate (mesh, submesh, or group)
3279 # @param Axis the axis of rotation (AxisStruct or geom line)
3280 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3281 # @param MakeGroups forces the generation of new groups from existing ones
3282 # @param NewMeshName the name of the newly created mesh
3283 # @return instance of Mesh class
3284 # @ingroup l2_modif_trsf
3285 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3287 if isinstance(AngleInRadians,str):
3289 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3291 AngleInRadians = DegreesToRadians(AngleInRadians)
3292 if (isinstance( theObject, Mesh )):
3293 theObject = theObject.GetMesh()
3294 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3295 Axis = self.smeshpyD.GetAxisStruct(Axis)
3296 Axis,AxisParameters = ParseAxisStruct(Axis)
3297 Parameters = AxisParameters + ":" + Parameters
3298 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3299 MakeGroups, NewMeshName)
3300 mesh.SetParameters(Parameters)
3301 return Mesh( self.smeshpyD, self.geompyD, mesh )
3303 ## Finds groups of ajacent nodes within Tolerance.
3304 # @param Tolerance the value of tolerance
3305 # @return the list of groups of nodes
3306 # @ingroup l2_modif_trsf
3307 def FindCoincidentNodes (self, Tolerance):
3308 return self.editor.FindCoincidentNodes(Tolerance)
3310 ## Finds groups of ajacent nodes within Tolerance.
3311 # @param Tolerance the value of tolerance
3312 # @param SubMeshOrGroup SubMesh or Group
3313 # @return the list of groups of nodes
3314 # @ingroup l2_modif_trsf
3315 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3316 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3319 # @param GroupsOfNodes the list of groups of nodes
3320 # @ingroup l2_modif_trsf
3321 def MergeNodes (self, GroupsOfNodes):
3322 self.editor.MergeNodes(GroupsOfNodes)
3324 ## Finds the elements built on the same nodes.
3325 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3326 # @return a list of groups of equal elements
3327 # @ingroup l2_modif_trsf
3328 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3329 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3330 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3331 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3333 ## Merges elements in each given group.
3334 # @param GroupsOfElementsID groups of elements for merging
3335 # @ingroup l2_modif_trsf
3336 def MergeElements(self, GroupsOfElementsID):
3337 self.editor.MergeElements(GroupsOfElementsID)
3339 ## Leaves one element and removes all other elements built on the same nodes.
3340 # @ingroup l2_modif_trsf
3341 def MergeEqualElements(self):
3342 self.editor.MergeEqualElements()
3344 ## Sews free borders
3345 # @return SMESH::Sew_Error
3346 # @ingroup l2_modif_trsf
3347 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3348 FirstNodeID2, SecondNodeID2, LastNodeID2,
3349 CreatePolygons, CreatePolyedrs):
3350 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3351 FirstNodeID2, SecondNodeID2, LastNodeID2,
3352 CreatePolygons, CreatePolyedrs)
3354 ## Sews conform free borders
3355 # @return SMESH::Sew_Error
3356 # @ingroup l2_modif_trsf
3357 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3358 FirstNodeID2, SecondNodeID2):
3359 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3360 FirstNodeID2, SecondNodeID2)
3362 ## Sews border to side
3363 # @return SMESH::Sew_Error
3364 # @ingroup l2_modif_trsf
3365 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3366 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3367 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3368 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3370 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3371 # merged with the nodes of elements of Side2.
3372 # The number of elements in theSide1 and in theSide2 must be
3373 # equal and they should have similar nodal connectivity.
3374 # The nodes to merge should belong to side borders and
3375 # the first node should be linked to the second.
3376 # @return SMESH::Sew_Error
3377 # @ingroup l2_modif_trsf
3378 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3379 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3380 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3381 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3382 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3383 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3385 ## Sets new nodes for the given element.
3386 # @param ide the element id
3387 # @param newIDs nodes ids
3388 # @return If the number of nodes does not correspond to the type of element - returns false
3389 # @ingroup l2_modif_edit
3390 def ChangeElemNodes(self, ide, newIDs):
3391 return self.editor.ChangeElemNodes(ide, newIDs)
3393 ## If during the last operation of MeshEditor some nodes were
3394 # created, this method returns the list of their IDs, \n
3395 # if new nodes were not created - returns empty list
3396 # @return the list of integer values (can be empty)
3397 # @ingroup l1_auxiliary
3398 def GetLastCreatedNodes(self):
3399 return self.editor.GetLastCreatedNodes()
3401 ## If during the last operation of MeshEditor some elements were
3402 # created this method returns the list of their IDs, \n
3403 # if new elements were not created - returns empty list
3404 # @return the list of integer values (can be empty)
3405 # @ingroup l1_auxiliary
3406 def GetLastCreatedElems(self):
3407 return self.editor.GetLastCreatedElems()
3409 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3410 # @param theElems - the list of elements (edges or faces) to be replicated
3411 # The nodes for duplication could be found from these elements
3412 # @param theNodesNot - list of nodes to NOT replicate
3413 # @param theAffectedElems - the list of elements (cells and edges) to which the
3414 # replicated nodes should be associated to.
3415 # @return TRUE if operation has been completed successfully, FALSE otherwise
3416 # @ingroup l2_modif_edit
3417 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3418 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3420 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3421 # @param theElems - the list of elements (edges or faces) to be replicated
3422 # The nodes for duplication could be found from these elements
3423 # @param theNodesNot - list of nodes to NOT replicate
3424 # @param theShape - shape to detect affected elements (element which geometric center
3425 # located on or inside shape).
3426 # The replicated nodes should be associated to affected elements.
3427 # @return TRUE if operation has been completed successfully, FALSE otherwise
3428 # @ingroup l2_modif_edit
3429 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3430 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3432 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3433 # This method provided for convenience works as DoubleNodes() described above.
3434 # @param theElems - group of of elements (edges or faces) to be replicated
3435 # @param theNodesNot - group of nodes not to replicated
3436 # @param theAffectedElems - group of elements to which the replicated nodes
3437 # should be associated to.
3438 # @ingroup l2_modif_edit
3439 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3440 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3442 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3443 # This method provided for convenience works as DoubleNodes() described above.
3444 # @param theElems - group of of elements (edges or faces) to be replicated
3445 # @param theNodesNot - group of nodes not to replicated
3446 # @param theShape - shape to detect affected elements (element which geometric center
3447 # located on or inside shape).
3448 # The replicated nodes should be associated to affected elements.
3449 # @ingroup l2_modif_edit
3450 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3451 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3453 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3454 # This method provided for convenience works as DoubleNodes() described above.
3455 # @param theElems - list of groups of elements (edges or faces) to be replicated
3456 # @param theNodesNot - list of groups of nodes not to replicated
3457 # @param theAffectedElems - group of elements to which the replicated nodes
3458 # should be associated to.
3459 # @return TRUE if operation has been completed successfully, FALSE otherwise
3460 # @ingroup l2_modif_edit
3461 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3462 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3464 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3465 # This method provided for convenience works as DoubleNodes() described above.
3466 # @param theElems - list of groups of elements (edges or faces) to be replicated
3467 # @param theNodesNot - list of groups of nodes not to replicated
3468 # @param theShape - shape to detect affected elements (element which geometric center
3469 # located on or inside shape).
3470 # The replicated nodes should be associated to affected elements.
3471 # @return TRUE if operation has been completed successfully, FALSE otherwise
3472 # @ingroup l2_modif_edit
3473 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3474 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3476 ## The mother class to define algorithm, it is not recommended to use it directly.
3479 # @ingroup l2_algorithms
3480 class Mesh_Algorithm:
3481 # @class Mesh_Algorithm
3482 # @brief Class Mesh_Algorithm
3484 #def __init__(self,smesh):
3492 ## Finds a hypothesis in the study by its type name and parameters.
3493 # Finds only the hypotheses created in smeshpyD engine.
3494 # @return SMESH.SMESH_Hypothesis
3495 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3496 study = smeshpyD.GetCurrentStudy()
3497 #to do: find component by smeshpyD object, not by its data type
3498 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3499 if scomp is not None:
3500 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3501 # Check if the root label of the hypotheses exists
3502 if res and hypRoot is not None:
3503 iter = study.NewChildIterator(hypRoot)
3504 # Check all published hypotheses
3506 hypo_so_i = iter.Value()
3507 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3508 if attr is not None:
3509 anIOR = attr.Value()
3510 hypo_o_i = salome.orb.string_to_object(anIOR)
3511 if hypo_o_i is not None:
3512 # Check if this is a hypothesis
3513 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3514 if hypo_i is not None:
3515 # Check if the hypothesis belongs to current engine
3516 if smeshpyD.GetObjectId(hypo_i) > 0:
3517 # Check if this is the required hypothesis
3518 if hypo_i.GetName() == hypname:
3520 if CompareMethod(hypo_i, args):
3534 ## Finds the algorithm in the study by its type name.
3535 # Finds only the algorithms, which have been created in smeshpyD engine.
3536 # @return SMESH.SMESH_Algo
3537 def FindAlgorithm (self, algoname, smeshpyD):
3538 study = smeshpyD.GetCurrentStudy()
3539 #to do: find component by smeshpyD object, not by its data type
3540 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3541 if scomp is not None:
3542 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3543 # Check if the root label of the algorithms exists
3544 if res and hypRoot is not None:
3545 iter = study.NewChildIterator(hypRoot)
3546 # Check all published algorithms
3548 algo_so_i = iter.Value()
3549 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3550 if attr is not None:
3551 anIOR = attr.Value()
3552 algo_o_i = salome.orb.string_to_object(anIOR)
3553 if algo_o_i is not None:
3554 # Check if this is an algorithm
3555 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3556 if algo_i is not None:
3557 # Checks if the algorithm belongs to the current engine
3558 if smeshpyD.GetObjectId(algo_i) > 0:
3559 # Check if this is the required algorithm
3560 if algo_i.GetName() == algoname:
3573 ## If the algorithm is global, returns 0; \n
3574 # else returns the submesh associated to this algorithm.
3575 def GetSubMesh(self):
3578 ## Returns the wrapped mesher.
3579 def GetAlgorithm(self):
3582 ## Gets the list of hypothesis that can be used with this algorithm
3583 def GetCompatibleHypothesis(self):
3586 mylist = self.algo.GetCompatibleHypothesis()
3589 ## Gets the name of the algorithm
3593 ## Sets the name to the algorithm
3594 def SetName(self, name):
3595 self.mesh.smeshpyD.SetName(self.algo, name)
3597 ## Gets the id of the algorithm
3599 return self.algo.GetId()
3602 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3604 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3605 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3607 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3609 self.Assign(algo, mesh, geom)
3613 def Assign(self, algo, mesh, geom):
3615 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3622 name = GetName(geom)
3624 name = mesh.geompyD.SubShapeName(geom, piece)
3625 mesh.geompyD.addToStudyInFather(piece, geom, name)
3626 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3629 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3630 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3632 def CompareHyp (self, hyp, args):
3633 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3636 def CompareEqualHyp (self, hyp, args):
3640 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3641 UseExisting=0, CompareMethod=""):
3644 if CompareMethod == "": CompareMethod = self.CompareHyp
3645 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3648 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3654 a = a + s + str(args[i])
3658 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3660 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3661 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3664 ## Returns entry of the shape to mesh in the study
3665 def MainShapeEntry(self):
3667 if not self.mesh or not self.mesh.GetMesh(): return entry
3668 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3669 study = self.mesh.smeshpyD.GetCurrentStudy()
3670 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3671 sobj = study.FindObjectIOR(ior)
3672 if sobj: entry = sobj.GetID()
3673 if not entry: return ""
3676 # Public class: Mesh_Segment
3677 # --------------------------
3679 ## Class to define a segment 1D algorithm for discretization
3682 # @ingroup l3_algos_basic
3683 class Mesh_Segment(Mesh_Algorithm):
3685 ## Private constructor.
3686 def __init__(self, mesh, geom=0):
3687 Mesh_Algorithm.__init__(self)
3688 self.Create(mesh, geom, "Regular_1D")
3690 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3691 # @param l for the length of segments that cut an edge
3692 # @param UseExisting if ==true - searches for an existing hypothesis created with
3693 # the same parameters, else (default) - creates a new one
3694 # @param p precision, used for calculation of the number of segments.
3695 # The precision should be a positive, meaningful value within the range [0,1].
3696 # In general, the number of segments is calculated with the formula:
3697 # nb = ceil((edge_length / l) - p)
3698 # Function ceil rounds its argument to the higher integer.
3699 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3700 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3701 # p=1 means rounding of (edge_length / l) to the lower integer.
3702 # Default value is 1e-07.
3703 # @return an instance of StdMeshers_LocalLength hypothesis
3704 # @ingroup l3_hypos_1dhyps
3705 def LocalLength(self, l, UseExisting=0, p=1e-07):
3706 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3707 CompareMethod=self.CompareLocalLength)
3713 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3714 def CompareLocalLength(self, hyp, args):
3715 if IsEqual(hyp.GetLength(), args[0]):
3716 return IsEqual(hyp.GetPrecision(), args[1])
3719 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3720 # @param length is optional maximal allowed length of segment, if it is omitted
3721 # the preestimated length is used that depends on geometry size
3722 # @param UseExisting if ==true - searches for an existing hypothesis created with
3723 # the same parameters, else (default) - create a new one
3724 # @return an instance of StdMeshers_MaxLength hypothesis
3725 # @ingroup l3_hypos_1dhyps
3726 def MaxSize(self, length=0.0, UseExisting=0):
3727 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3730 hyp.SetLength(length)
3732 # set preestimated length
3733 gen = self.mesh.smeshpyD
3734 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3735 self.mesh.GetMesh(), self.mesh.GetShape(),
3737 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3739 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3742 hyp.SetUsePreestimatedLength( length == 0.0 )
3745 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3746 # @param n for the number of segments that cut an edge
3747 # @param s for the scale factor (optional)
3748 # @param reversedEdges is a list of edges to mesh using reversed orientation
3749 # @param UseExisting if ==true - searches for an existing hypothesis created with
3750 # the same parameters, else (default) - create a new one
3751 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3752 # @ingroup l3_hypos_1dhyps
3753 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3754 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3755 reversedEdges, UseExisting = [], reversedEdges
3756 entry = self.MainShapeEntry()
3758 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3759 UseExisting=UseExisting,
3760 CompareMethod=self.CompareNumberOfSegments)
3762 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3763 UseExisting=UseExisting,
3764 CompareMethod=self.CompareNumberOfSegments)
3765 hyp.SetDistrType( 1 )
3766 hyp.SetScaleFactor(s)
3767 hyp.SetNumberOfSegments(n)
3768 hyp.SetReversedEdges( reversedEdges )
3769 hyp.SetObjectEntry( entry )
3773 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3774 def CompareNumberOfSegments(self, hyp, args):
3775 if hyp.GetNumberOfSegments() == args[0]:
3777 if hyp.GetReversedEdges() == args[1]:
3778 if not args[1] or hyp.GetObjectEntry() == args[2]:
3781 if hyp.GetReversedEdges() == args[2]:
3782 if not args[2] or hyp.GetObjectEntry() == args[3]:
3783 if hyp.GetDistrType() == 1:
3784 if IsEqual(hyp.GetScaleFactor(), args[1]):
3788 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3789 # @param start defines the length of the first segment
3790 # @param end defines the length of the last segment
3791 # @param reversedEdges is a list of edges to mesh using reversed orientation
3792 # @param UseExisting if ==true - searches for an existing hypothesis created with
3793 # the same parameters, else (default) - creates a new one
3794 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3795 # @ingroup l3_hypos_1dhyps
3796 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3797 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3798 reversedEdges, UseExisting = [], reversedEdges
3799 entry = self.MainShapeEntry()
3800 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3801 UseExisting=UseExisting,
3802 CompareMethod=self.CompareArithmetic1D)
3803 hyp.SetStartLength(start)
3804 hyp.SetEndLength(end)
3805 hyp.SetReversedEdges( reversedEdges )
3806 hyp.SetObjectEntry( entry )
3810 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3811 def CompareArithmetic1D(self, hyp, args):
3812 if IsEqual(hyp.GetLength(1), args[0]):
3813 if IsEqual(hyp.GetLength(0), args[1]):
3814 if hyp.GetReversedEdges() == args[2]:
3815 if not args[2] or hyp.GetObjectEntry() == args[3]:
3820 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3821 # on curve from 0 to 1 (additionally it is neecessary to check
3822 # orientation of edges and create list of reversed edges if it is
3823 # needed) and sets numbers of segments between given points (default
3824 # values are equals 1
3825 # @param points defines the list of parameters on curve
3826 # @param nbSegs defines the list of numbers of segments
3827 # @param reversedEdges is a list of edges to mesh using reversed orientation
3828 # @param UseExisting if ==true - searches for an existing hypothesis created with
3829 # the same parameters, else (default) - creates a new one
3830 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3831 # @ingroup l3_hypos_1dhyps
3832 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3833 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3834 reversedEdges, UseExisting = [], reversedEdges
3835 entry = self.MainShapeEntry()
3836 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3837 UseExisting=UseExisting,
3838 CompareMethod=self.CompareArithmetic1D)
3839 hyp.SetPoints(points)
3840 hyp.SetNbSegments(nbSegs)
3841 hyp.SetReversedEdges(reversedEdges)
3842 hyp.SetObjectEntry(entry)
3846 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3847 ## as the given arguments
3848 def CompareFixedPoints1D(self, hyp, args):
3849 if hyp.GetPoints() == args[0]:
3850 if hyp.GetNbSegments() == args[1]:
3851 if hyp.GetReversedEdges() == args[2]:
3852 if not args[2] or hyp.GetObjectEntry() == args[3]:
3858 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3859 # @param start defines the length of the first segment
3860 # @param end defines the length of the last segment
3861 # @param reversedEdges is a list of edges to mesh using reversed orientation
3862 # @param UseExisting if ==true - searches for an existing hypothesis created with
3863 # the same parameters, else (default) - creates a new one
3864 # @return an instance of StdMeshers_StartEndLength hypothesis
3865 # @ingroup l3_hypos_1dhyps
3866 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3867 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3868 reversedEdges, UseExisting = [], reversedEdges
3869 entry = self.MainShapeEntry()
3870 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3871 UseExisting=UseExisting,
3872 CompareMethod=self.CompareStartEndLength)
3873 hyp.SetStartLength(start)
3874 hyp.SetEndLength(end)
3875 hyp.SetReversedEdges( reversedEdges )
3876 hyp.SetObjectEntry( entry )
3879 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3880 def CompareStartEndLength(self, hyp, args):
3881 if IsEqual(hyp.GetLength(1), args[0]):
3882 if IsEqual(hyp.GetLength(0), args[1]):
3883 if hyp.GetReversedEdges() == args[2]:
3884 if not args[2] or hyp.GetObjectEntry() == args[3]:
3888 ## Defines "Deflection1D" hypothesis
3889 # @param d for the deflection
3890 # @param UseExisting if ==true - searches for an existing hypothesis created with
3891 # the same parameters, else (default) - create a new one
3892 # @ingroup l3_hypos_1dhyps
3893 def Deflection1D(self, d, UseExisting=0):
3894 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3895 CompareMethod=self.CompareDeflection1D)
3896 hyp.SetDeflection(d)
3899 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3900 def CompareDeflection1D(self, hyp, args):
3901 return IsEqual(hyp.GetDeflection(), args[0])
3903 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3904 # the opposite side in case of quadrangular faces
3905 # @ingroup l3_hypos_additi
3906 def Propagation(self):
3907 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3909 ## Defines "AutomaticLength" hypothesis
3910 # @param fineness for the fineness [0-1]
3911 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3912 # same parameters, else (default) - create a new one
3913 # @ingroup l3_hypos_1dhyps
3914 def AutomaticLength(self, fineness=0, UseExisting=0):
3915 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3916 CompareMethod=self.CompareAutomaticLength)
3917 hyp.SetFineness( fineness )
3920 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3921 def CompareAutomaticLength(self, hyp, args):
3922 return IsEqual(hyp.GetFineness(), args[0])
3924 ## Defines "SegmentLengthAroundVertex" hypothesis
3925 # @param length for the segment length
3926 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3927 # Any other integer value means that the hypothesis will be set on the
3928 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3929 # @param UseExisting if ==true - searches for an existing hypothesis created with
3930 # the same parameters, else (default) - creates a new one
3931 # @ingroup l3_algos_segmarv
3932 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3934 store_geom = self.geom
3935 if type(vertex) is types.IntType:
3936 if vertex == 0 or vertex == 1:
3937 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3945 if self.geom is None:
3946 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3947 name = GetName(self.geom)
3949 piece = self.mesh.geom
3950 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3951 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3952 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3954 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3956 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3957 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3959 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3960 CompareMethod=self.CompareLengthNearVertex)
3961 self.geom = store_geom
3962 hyp.SetLength( length )
3965 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3966 # @ingroup l3_algos_segmarv
3967 def CompareLengthNearVertex(self, hyp, args):
3968 return IsEqual(hyp.GetLength(), args[0])
3970 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3971 # If the 2D mesher sees that all boundary edges are quadratic,
3972 # it generates quadratic faces, else it generates linear faces using
3973 # medium nodes as if they are vertices.
3974 # The 3D mesher generates quadratic volumes only if all boundary faces
3975 # are quadratic, else it fails.
3977 # @ingroup l3_hypos_additi
3978 def QuadraticMesh(self):
3979 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3982 # Public class: Mesh_CompositeSegment
3983 # --------------------------
3985 ## Defines a segment 1D algorithm for discretization
3987 # @ingroup l3_algos_basic
3988 class Mesh_CompositeSegment(Mesh_Segment):
3990 ## Private constructor.
3991 def __init__(self, mesh, geom=0):
3992 self.Create(mesh, geom, "CompositeSegment_1D")
3995 # Public class: Mesh_Segment_Python
3996 # ---------------------------------
3998 ## Defines a segment 1D algorithm for discretization with python function
4000 # @ingroup l3_algos_basic
4001 class Mesh_Segment_Python(Mesh_Segment):
4003 ## Private constructor.
4004 def __init__(self, mesh, geom=0):
4005 import Python1dPlugin
4006 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4008 ## Defines "PythonSplit1D" hypothesis
4009 # @param n for the number of segments that cut an edge
4010 # @param func for the python function that calculates the length of all segments
4011 # @param UseExisting if ==true - searches for the existing hypothesis created with
4012 # the same parameters, else (default) - creates a new one
4013 # @ingroup l3_hypos_1dhyps
4014 def PythonSplit1D(self, n, func, UseExisting=0):
4015 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4016 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4017 hyp.SetNumberOfSegments(n)
4018 hyp.SetPythonLog10RatioFunction(func)
4021 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4022 def ComparePythonSplit1D(self, hyp, args):
4023 #if hyp.GetNumberOfSegments() == args[0]:
4024 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4028 # Public class: Mesh_Triangle
4029 # ---------------------------
4031 ## Defines a triangle 2D algorithm
4033 # @ingroup l3_algos_basic
4034 class Mesh_Triangle(Mesh_Algorithm):
4043 ## Private constructor.
4044 def __init__(self, mesh, algoType, geom=0):
4045 Mesh_Algorithm.__init__(self)
4047 self.algoType = algoType
4048 if algoType == MEFISTO:
4049 self.Create(mesh, geom, "MEFISTO_2D")
4051 elif algoType == BLSURF:
4053 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4054 #self.SetPhysicalMesh() - PAL19680
4055 elif algoType == NETGEN:
4057 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4059 elif algoType == NETGEN_2D:
4061 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4064 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4065 # @param area for the maximum area of each triangle
4066 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4067 # same parameters, else (default) - creates a new one
4069 # Only for algoType == MEFISTO || NETGEN_2D
4070 # @ingroup l3_hypos_2dhyps
4071 def MaxElementArea(self, area, UseExisting=0):
4072 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4073 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4074 CompareMethod=self.CompareMaxElementArea)
4075 elif self.algoType == NETGEN:
4076 hyp = self.Parameters(SIMPLE)
4077 hyp.SetMaxElementArea(area)
4080 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4081 def CompareMaxElementArea(self, hyp, args):
4082 return IsEqual(hyp.GetMaxElementArea(), args[0])
4084 ## Defines "LengthFromEdges" hypothesis to build triangles
4085 # based on the length of the edges taken from the wire
4087 # Only for algoType == MEFISTO || NETGEN_2D
4088 # @ingroup l3_hypos_2dhyps
4089 def LengthFromEdges(self):
4090 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4091 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4093 elif self.algoType == NETGEN:
4094 hyp = self.Parameters(SIMPLE)
4095 hyp.LengthFromEdges()
4098 ## Sets a way to define size of mesh elements to generate.
4099 # @param thePhysicalMesh is: DefaultSize or Custom.
4100 # @ingroup l3_hypos_blsurf
4101 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4102 # Parameter of BLSURF algo
4103 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4105 ## Sets size of mesh elements to generate.
4106 # @ingroup l3_hypos_blsurf
4107 def SetPhySize(self, theVal):
4108 # Parameter of BLSURF algo
4109 self.Parameters().SetPhySize(theVal)
4111 ## Sets lower boundary of mesh element size (PhySize).
4112 # @ingroup l3_hypos_blsurf
4113 def SetPhyMin(self, theVal=-1):
4114 # Parameter of BLSURF algo
4115 self.Parameters().SetPhyMin(theVal)
4117 ## Sets upper boundary of mesh element size (PhySize).
4118 # @ingroup l3_hypos_blsurf
4119 def SetPhyMax(self, theVal=-1):
4120 # Parameter of BLSURF algo
4121 self.Parameters().SetPhyMax(theVal)
4123 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4124 # @param theGeometricMesh is: DefaultGeom or Custom
4125 # @ingroup l3_hypos_blsurf
4126 def SetGeometricMesh(self, theGeometricMesh=0):
4127 # Parameter of BLSURF algo
4128 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4129 self.params.SetGeometricMesh(theGeometricMesh)
4131 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4132 # @ingroup l3_hypos_blsurf
4133 def SetAngleMeshS(self, theVal=_angleMeshS):
4134 # Parameter of BLSURF algo
4135 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4136 self.params.SetAngleMeshS(theVal)
4138 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4139 # @ingroup l3_hypos_blsurf
4140 def SetAngleMeshC(self, theVal=_angleMeshS):
4141 # Parameter of BLSURF algo
4142 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4143 self.params.SetAngleMeshC(theVal)
4145 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4146 # @ingroup l3_hypos_blsurf
4147 def SetGeoMin(self, theVal=-1):
4148 # Parameter of BLSURF algo
4149 self.Parameters().SetGeoMin(theVal)
4151 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4152 # @ingroup l3_hypos_blsurf
4153 def SetGeoMax(self, theVal=-1):
4154 # Parameter of BLSURF algo
4155 self.Parameters().SetGeoMax(theVal)
4157 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4158 # @ingroup l3_hypos_blsurf
4159 def SetGradation(self, theVal=_gradation):
4160 # Parameter of BLSURF algo
4161 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4162 self.params.SetGradation(theVal)
4164 ## Sets topology usage way.
4165 # @param way defines how mesh conformity is assured <ul>
4166 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4167 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4168 # @ingroup l3_hypos_blsurf
4169 def SetTopology(self, way):
4170 # Parameter of BLSURF algo
4171 self.Parameters().SetTopology(way)
4173 ## To respect geometrical edges or not.
4174 # @ingroup l3_hypos_blsurf
4175 def SetDecimesh(self, toIgnoreEdges=False):
4176 # Parameter of BLSURF algo
4177 self.Parameters().SetDecimesh(toIgnoreEdges)
4179 ## Sets verbosity level in the range 0 to 100.
4180 # @ingroup l3_hypos_blsurf
4181 def SetVerbosity(self, level):
4182 # Parameter of BLSURF algo
4183 self.Parameters().SetVerbosity(level)
4185 ## Sets advanced option value.
4186 # @ingroup l3_hypos_blsurf
4187 def SetOptionValue(self, optionName, level):
4188 # Parameter of BLSURF algo
4189 self.Parameters().SetOptionValue(optionName,level)
4191 ## Sets QuadAllowed flag.
4192 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4193 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4194 def SetQuadAllowed(self, toAllow=True):
4195 if self.algoType == NETGEN_2D:
4196 if toAllow: # add QuadranglePreference
4197 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4198 else: # remove QuadranglePreference
4199 for hyp in self.mesh.GetHypothesisList( self.geom ):
4200 if hyp.GetName() == "QuadranglePreference":
4201 self.mesh.RemoveHypothesis( self.geom, hyp )
4206 if self.Parameters():
4207 self.params.SetQuadAllowed(toAllow)
4210 ## Defines hypothesis having several parameters
4212 # @ingroup l3_hypos_netgen
4213 def Parameters(self, which=SOLE):
4216 if self.algoType == NETGEN:
4218 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4219 "libNETGENEngine.so", UseExisting=0)
4221 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4222 "libNETGENEngine.so", UseExisting=0)
4224 elif self.algoType == MEFISTO:
4225 print "Mefisto algo support no multi-parameter hypothesis"
4227 elif self.algoType == NETGEN_2D:
4228 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4229 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4231 elif self.algoType == BLSURF:
4232 self.params = self.Hypothesis("BLSURF_Parameters", [],
4233 "libBLSURFEngine.so", UseExisting=0)
4236 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4241 # Only for algoType == NETGEN
4242 # @ingroup l3_hypos_netgen
4243 def SetMaxSize(self, theSize):
4244 if self.Parameters():
4245 self.params.SetMaxSize(theSize)
4247 ## Sets SecondOrder flag
4249 # Only for algoType == NETGEN
4250 # @ingroup l3_hypos_netgen
4251 def SetSecondOrder(self, theVal):
4252 if self.Parameters():
4253 self.params.SetSecondOrder(theVal)
4255 ## Sets Optimize flag
4257 # Only for algoType == NETGEN
4258 # @ingroup l3_hypos_netgen
4259 def SetOptimize(self, theVal):
4260 if self.Parameters():
4261 self.params.SetOptimize(theVal)
4264 # @param theFineness is:
4265 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4267 # Only for algoType == NETGEN
4268 # @ingroup l3_hypos_netgen
4269 def SetFineness(self, theFineness):
4270 if self.Parameters():
4271 self.params.SetFineness(theFineness)
4275 # Only for algoType == NETGEN
4276 # @ingroup l3_hypos_netgen
4277 def SetGrowthRate(self, theRate):
4278 if self.Parameters():
4279 self.params.SetGrowthRate(theRate)
4281 ## Sets NbSegPerEdge
4283 # Only for algoType == NETGEN
4284 # @ingroup l3_hypos_netgen
4285 def SetNbSegPerEdge(self, theVal):
4286 if self.Parameters():
4287 self.params.SetNbSegPerEdge(theVal)
4289 ## Sets NbSegPerRadius
4291 # Only for algoType == NETGEN
4292 # @ingroup l3_hypos_netgen
4293 def SetNbSegPerRadius(self, theVal):
4294 if self.Parameters():
4295 self.params.SetNbSegPerRadius(theVal)
4297 ## Sets number of segments overriding value set by SetLocalLength()
4299 # Only for algoType == NETGEN
4300 # @ingroup l3_hypos_netgen
4301 def SetNumberOfSegments(self, theVal):
4302 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4304 ## Sets number of segments overriding value set by SetNumberOfSegments()
4306 # Only for algoType == NETGEN
4307 # @ingroup l3_hypos_netgen
4308 def SetLocalLength(self, theVal):
4309 self.Parameters(SIMPLE).SetLocalLength(theVal)
4314 # Public class: Mesh_Quadrangle
4315 # -----------------------------
4317 ## Defines a quadrangle 2D algorithm
4319 # @ingroup l3_algos_basic
4320 class Mesh_Quadrangle(Mesh_Algorithm):
4322 ## Private constructor.
4323 def __init__(self, mesh, geom=0):
4324 Mesh_Algorithm.__init__(self)
4325 self.Create(mesh, geom, "Quadrangle_2D")
4327 ## Defines "QuadranglePreference" hypothesis, forcing construction
4328 # of quadrangles if the number of nodes on the opposite edges is not the same
4329 # while the total number of nodes on edges is even
4331 # @ingroup l3_hypos_additi
4332 def QuadranglePreference(self):
4333 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4334 CompareMethod=self.CompareEqualHyp)
4337 ## Defines "TrianglePreference" hypothesis, forcing construction
4338 # of triangles in the refinement area if the number of nodes
4339 # on the opposite edges is not the same
4341 # @ingroup l3_hypos_additi
4342 def TrianglePreference(self):
4343 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4344 CompareMethod=self.CompareEqualHyp)
4347 # Public class: Mesh_Tetrahedron
4348 # ------------------------------
4350 ## Defines a tetrahedron 3D algorithm
4352 # @ingroup l3_algos_basic
4353 class Mesh_Tetrahedron(Mesh_Algorithm):
4358 ## Private constructor.
4359 def __init__(self, mesh, algoType, geom=0):
4360 Mesh_Algorithm.__init__(self)
4362 if algoType == NETGEN:
4364 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4367 elif algoType == FULL_NETGEN:
4369 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4372 elif algoType == GHS3D:
4374 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4377 elif algoType == GHS3DPRL:
4378 CheckPlugin(GHS3DPRL)
4379 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4382 self.algoType = algoType
4384 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4385 # @param vol for the maximum volume of each tetrahedron
4386 # @param UseExisting if ==true - searches for the existing hypothesis created with
4387 # the same parameters, else (default) - creates a new one
4388 # @ingroup l3_hypos_maxvol
4389 def MaxElementVolume(self, vol, UseExisting=0):
4390 if self.algoType == NETGEN:
4391 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4392 CompareMethod=self.CompareMaxElementVolume)
4393 hyp.SetMaxElementVolume(vol)
4395 elif self.algoType == FULL_NETGEN:
4396 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4399 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4400 def CompareMaxElementVolume(self, hyp, args):
4401 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4403 ## Defines hypothesis having several parameters
4405 # @ingroup l3_hypos_netgen
4406 def Parameters(self, which=SOLE):
4410 if self.algoType == FULL_NETGEN:
4412 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4413 "libNETGENEngine.so", UseExisting=0)
4415 self.params = self.Hypothesis("NETGEN_Parameters", [],
4416 "libNETGENEngine.so", UseExisting=0)
4419 if self.algoType == GHS3D:
4420 self.params = self.Hypothesis("GHS3D_Parameters", [],
4421 "libGHS3DEngine.so", UseExisting=0)
4424 if self.algoType == GHS3DPRL:
4425 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4426 "libGHS3DPRLEngine.so", UseExisting=0)
4429 print "Algo supports no multi-parameter hypothesis"
4433 # Parameter of FULL_NETGEN
4434 # @ingroup l3_hypos_netgen
4435 def SetMaxSize(self, theSize):
4436 self.Parameters().SetMaxSize(theSize)
4438 ## Sets SecondOrder flag
4439 # Parameter of FULL_NETGEN
4440 # @ingroup l3_hypos_netgen
4441 def SetSecondOrder(self, theVal):
4442 self.Parameters().SetSecondOrder(theVal)
4444 ## Sets Optimize flag
4445 # Parameter of FULL_NETGEN
4446 # @ingroup l3_hypos_netgen
4447 def SetOptimize(self, theVal):
4448 self.Parameters().SetOptimize(theVal)
4451 # @param theFineness is:
4452 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4453 # Parameter of FULL_NETGEN
4454 # @ingroup l3_hypos_netgen
4455 def SetFineness(self, theFineness):
4456 self.Parameters().SetFineness(theFineness)
4459 # Parameter of FULL_NETGEN
4460 # @ingroup l3_hypos_netgen
4461 def SetGrowthRate(self, theRate):
4462 self.Parameters().SetGrowthRate(theRate)
4464 ## Sets NbSegPerEdge
4465 # Parameter of FULL_NETGEN
4466 # @ingroup l3_hypos_netgen
4467 def SetNbSegPerEdge(self, theVal):
4468 self.Parameters().SetNbSegPerEdge(theVal)
4470 ## Sets NbSegPerRadius
4471 # Parameter of FULL_NETGEN
4472 # @ingroup l3_hypos_netgen
4473 def SetNbSegPerRadius(self, theVal):
4474 self.Parameters().SetNbSegPerRadius(theVal)
4476 ## Sets number of segments overriding value set by SetLocalLength()
4477 # Only for algoType == NETGEN_FULL
4478 # @ingroup l3_hypos_netgen
4479 def SetNumberOfSegments(self, theVal):
4480 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4482 ## Sets number of segments overriding value set by SetNumberOfSegments()
4483 # Only for algoType == NETGEN_FULL
4484 # @ingroup l3_hypos_netgen
4485 def SetLocalLength(self, theVal):
4486 self.Parameters(SIMPLE).SetLocalLength(theVal)
4488 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4489 # Overrides value set by LengthFromEdges()
4490 # Only for algoType == NETGEN_FULL
4491 # @ingroup l3_hypos_netgen
4492 def MaxElementArea(self, area):
4493 self.Parameters(SIMPLE).SetMaxElementArea(area)
4495 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4496 # Overrides value set by MaxElementArea()
4497 # Only for algoType == NETGEN_FULL
4498 # @ingroup l3_hypos_netgen
4499 def LengthFromEdges(self):
4500 self.Parameters(SIMPLE).LengthFromEdges()
4502 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4503 # Overrides value set by MaxElementVolume()
4504 # Only for algoType == NETGEN_FULL
4505 # @ingroup l3_hypos_netgen
4506 def LengthFromFaces(self):
4507 self.Parameters(SIMPLE).LengthFromFaces()
4509 ## To mesh "holes" in a solid or not. Default is to mesh.
4510 # @ingroup l3_hypos_ghs3dh
4511 def SetToMeshHoles(self, toMesh):
4512 # Parameter of GHS3D
4513 self.Parameters().SetToMeshHoles(toMesh)
4515 ## Set Optimization level:
4516 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4517 # Default is Medium_Optimization
4518 # @ingroup l3_hypos_ghs3dh
4519 def SetOptimizationLevel(self, level):
4520 # Parameter of GHS3D
4521 self.Parameters().SetOptimizationLevel(level)
4523 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4524 # @ingroup l3_hypos_ghs3dh
4525 def SetMaximumMemory(self, MB):
4526 # Advanced parameter of GHS3D
4527 self.Parameters().SetMaximumMemory(MB)
4529 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4530 # automatic memory adjustment mode.
4531 # @ingroup l3_hypos_ghs3dh
4532 def SetInitialMemory(self, MB):
4533 # Advanced parameter of GHS3D
4534 self.Parameters().SetInitialMemory(MB)
4536 ## Path to working directory.
4537 # @ingroup l3_hypos_ghs3dh
4538 def SetWorkingDirectory(self, path):
4539 # Advanced parameter of GHS3D
4540 self.Parameters().SetWorkingDirectory(path)
4542 ## To keep working files or remove them. Log file remains in case of errors anyway.
4543 # @ingroup l3_hypos_ghs3dh
4544 def SetKeepFiles(self, toKeep):
4545 # Advanced parameter of GHS3D and GHS3DPRL
4546 self.Parameters().SetKeepFiles(toKeep)
4548 ## To set verbose level [0-10]. <ul>
4549 #<li> 0 - no standard output,
4550 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4551 # indicates when the final mesh is being saved. In addition the software
4552 # gives indication regarding the CPU time.
4553 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4554 # histogram of the skin mesh, quality statistics histogram together with
4555 # the characteristics of the final mesh.</ul>
4556 # @ingroup l3_hypos_ghs3dh
4557 def SetVerboseLevel(self, level):
4558 # Advanced parameter of GHS3D
4559 self.Parameters().SetVerboseLevel(level)
4561 ## To create new nodes.
4562 # @ingroup l3_hypos_ghs3dh
4563 def SetToCreateNewNodes(self, toCreate):
4564 # Advanced parameter of GHS3D
4565 self.Parameters().SetToCreateNewNodes(toCreate)
4567 ## To use boundary recovery version which tries to create mesh on a very poor
4568 # quality surface mesh.
4569 # @ingroup l3_hypos_ghs3dh
4570 def SetToUseBoundaryRecoveryVersion(self, toUse):
4571 # Advanced parameter of GHS3D
4572 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4574 ## Sets command line option as text.
4575 # @ingroup l3_hypos_ghs3dh
4576 def SetTextOption(self, option):
4577 # Advanced parameter of GHS3D
4578 self.Parameters().SetTextOption(option)
4580 ## Sets MED files name and path.
4581 def SetMEDName(self, value):
4582 self.Parameters().SetMEDName(value)
4584 ## Sets the number of partition of the initial mesh
4585 def SetNbPart(self, value):
4586 self.Parameters().SetNbPart(value)
4588 ## When big mesh, start tepal in background
4589 def SetBackground(self, value):
4590 self.Parameters().SetBackground(value)
4592 # Public class: Mesh_Hexahedron
4593 # ------------------------------
4595 ## Defines a hexahedron 3D algorithm
4597 # @ingroup l3_algos_basic
4598 class Mesh_Hexahedron(Mesh_Algorithm):
4603 ## Private constructor.
4604 def __init__(self, mesh, algoType=Hexa, geom=0):
4605 Mesh_Algorithm.__init__(self)
4607 self.algoType = algoType
4609 if algoType == Hexa:
4610 self.Create(mesh, geom, "Hexa_3D")
4613 elif algoType == Hexotic:
4614 CheckPlugin(Hexotic)
4615 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4618 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4619 # @ingroup l3_hypos_hexotic
4620 def MinMaxQuad(self, min=3, max=8, quad=True):
4621 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4623 self.params.SetHexesMinLevel(min)
4624 self.params.SetHexesMaxLevel(max)
4625 self.params.SetHexoticQuadrangles(quad)
4628 # Deprecated, only for compatibility!
4629 # Public class: Mesh_Netgen
4630 # ------------------------------
4632 ## Defines a NETGEN-based 2D or 3D algorithm
4633 # that needs no discrete boundary (i.e. independent)
4635 # This class is deprecated, only for compatibility!
4638 # @ingroup l3_algos_basic
4639 class Mesh_Netgen(Mesh_Algorithm):
4643 ## Private constructor.
4644 def __init__(self, mesh, is3D, geom=0):
4645 Mesh_Algorithm.__init__(self)
4651 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4655 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4658 ## Defines the hypothesis containing parameters of the algorithm
4659 def Parameters(self):
4661 hyp = self.Hypothesis("NETGEN_Parameters", [],
4662 "libNETGENEngine.so", UseExisting=0)
4664 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4665 "libNETGENEngine.so", UseExisting=0)
4668 # Public class: Mesh_Projection1D
4669 # ------------------------------
4671 ## Defines a projection 1D algorithm
4672 # @ingroup l3_algos_proj
4674 class Mesh_Projection1D(Mesh_Algorithm):
4676 ## Private constructor.
4677 def __init__(self, mesh, geom=0):
4678 Mesh_Algorithm.__init__(self)
4679 self.Create(mesh, geom, "Projection_1D")
4681 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4682 # a mesh pattern is taken, and, optionally, the association of vertices
4683 # between the source edge and a target edge (to which a hypothesis is assigned)
4684 # @param edge from which nodes distribution is taken
4685 # @param mesh from which nodes distribution is taken (optional)
4686 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4687 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4688 # to associate with \a srcV (optional)
4689 # @param UseExisting if ==true - searches for the existing hypothesis created with
4690 # the same parameters, else (default) - creates a new one
4691 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4692 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4694 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4695 hyp.SetSourceEdge( edge )
4696 if not mesh is None and isinstance(mesh, Mesh):
4697 mesh = mesh.GetMesh()
4698 hyp.SetSourceMesh( mesh )
4699 hyp.SetVertexAssociation( srcV, tgtV )
4702 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4703 #def CompareSourceEdge(self, hyp, args):
4704 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4708 # Public class: Mesh_Projection2D
4709 # ------------------------------
4711 ## Defines a projection 2D algorithm
4712 # @ingroup l3_algos_proj
4714 class Mesh_Projection2D(Mesh_Algorithm):
4716 ## Private constructor.
4717 def __init__(self, mesh, geom=0):
4718 Mesh_Algorithm.__init__(self)
4719 self.Create(mesh, geom, "Projection_2D")
4721 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4722 # a mesh pattern is taken, and, optionally, the association of vertices
4723 # between the source face and the target face (to which a hypothesis is assigned)
4724 # @param face from which the mesh pattern is taken
4725 # @param mesh from which the mesh pattern is taken (optional)
4726 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4727 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4728 # to associate with \a srcV1 (optional)
4729 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4730 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4731 # to associate with \a srcV2 (optional)
4732 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4733 # the same parameters, else (default) - forces the creation a new one
4735 # Note: all association vertices must belong to one edge of a face
4736 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4737 srcV2=None, tgtV2=None, UseExisting=0):
4738 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4740 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4741 hyp.SetSourceFace( face )
4742 if not mesh is None and isinstance(mesh, Mesh):
4743 mesh = mesh.GetMesh()
4744 hyp.SetSourceMesh( mesh )
4745 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4748 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4749 #def CompareSourceFace(self, hyp, args):
4750 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4753 # Public class: Mesh_Projection3D
4754 # ------------------------------
4756 ## Defines a projection 3D algorithm
4757 # @ingroup l3_algos_proj
4759 class Mesh_Projection3D(Mesh_Algorithm):
4761 ## Private constructor.
4762 def __init__(self, mesh, geom=0):
4763 Mesh_Algorithm.__init__(self)
4764 self.Create(mesh, geom, "Projection_3D")
4766 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4767 # the mesh pattern is taken, and, optionally, the association of vertices
4768 # between the source and the target solid (to which a hipothesis is assigned)
4769 # @param solid from where the mesh pattern is taken
4770 # @param mesh from where the mesh pattern is taken (optional)
4771 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4772 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4773 # to associate with \a srcV1 (optional)
4774 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4775 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4776 # to associate with \a srcV2 (optional)
4777 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4778 # the same parameters, else (default) - creates a new one
4780 # Note: association vertices must belong to one edge of a solid
4781 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4782 srcV2=0, tgtV2=0, UseExisting=0):
4783 hyp = self.Hypothesis("ProjectionSource3D",
4784 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4786 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4787 hyp.SetSource3DShape( solid )
4788 if not mesh is None and isinstance(mesh, Mesh):
4789 mesh = mesh.GetMesh()
4790 hyp.SetSourceMesh( mesh )
4791 if srcV1 and srcV2 and tgtV1 and tgtV2:
4792 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4793 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4796 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4797 #def CompareSourceShape3D(self, hyp, args):
4798 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4802 # Public class: Mesh_Prism
4803 # ------------------------
4805 ## Defines a 3D extrusion algorithm
4806 # @ingroup l3_algos_3dextr
4808 class Mesh_Prism3D(Mesh_Algorithm):
4810 ## Private constructor.
4811 def __init__(self, mesh, geom=0):
4812 Mesh_Algorithm.__init__(self)
4813 self.Create(mesh, geom, "Prism_3D")
4815 # Public class: Mesh_RadialPrism
4816 # -------------------------------
4818 ## Defines a Radial Prism 3D algorithm
4819 # @ingroup l3_algos_radialp
4821 class Mesh_RadialPrism3D(Mesh_Algorithm):
4823 ## Private constructor.
4824 def __init__(self, mesh, geom=0):
4825 Mesh_Algorithm.__init__(self)
4826 self.Create(mesh, geom, "RadialPrism_3D")
4828 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4829 self.nbLayers = None
4831 ## Return 3D hypothesis holding the 1D one
4832 def Get3DHypothesis(self):
4833 return self.distribHyp
4835 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4836 # hypothesis. Returns the created hypothesis
4837 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4838 #print "OwnHypothesis",hypType
4839 if not self.nbLayers is None:
4840 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4841 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4842 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4843 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4844 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4845 self.distribHyp.SetLayerDistribution( hyp )
4848 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4849 # prisms to build between the inner and outer shells
4850 # @param n number of layers
4851 # @param UseExisting if ==true - searches for the existing hypothesis created with
4852 # the same parameters, else (default) - creates a new one
4853 def NumberOfLayers(self, n, UseExisting=0):
4854 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4855 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4856 CompareMethod=self.CompareNumberOfLayers)
4857 self.nbLayers.SetNumberOfLayers( n )
4858 return self.nbLayers
4860 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4861 def CompareNumberOfLayers(self, hyp, args):
4862 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4864 ## Defines "LocalLength" hypothesis, specifying the segment length
4865 # to build between the inner and the outer shells
4866 # @param l the length of segments
4867 # @param p the precision of rounding
4868 def LocalLength(self, l, p=1e-07):
4869 hyp = self.OwnHypothesis("LocalLength", [l,p])
4874 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4875 # prisms to build between the inner and the outer shells.
4876 # @param n the number of layers
4877 # @param s the scale factor (optional)
4878 def NumberOfSegments(self, n, s=[]):
4880 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4882 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4883 hyp.SetDistrType( 1 )
4884 hyp.SetScaleFactor(s)
4885 hyp.SetNumberOfSegments(n)
4888 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4889 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4890 # @param start the length of the first segment
4891 # @param end the length of the last segment
4892 def Arithmetic1D(self, start, end ):
4893 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4894 hyp.SetLength(start, 1)
4895 hyp.SetLength(end , 0)
4898 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4899 # to build between the inner and the outer shells as geometric length increasing
4900 # @param start for the length of the first segment
4901 # @param end for the length of the last segment
4902 def StartEndLength(self, start, end):
4903 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4904 hyp.SetLength(start, 1)
4905 hyp.SetLength(end , 0)
4908 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4909 # to build between the inner and outer shells
4910 # @param fineness defines the quality of the mesh within the range [0-1]
4911 def AutomaticLength(self, fineness=0):
4912 hyp = self.OwnHypothesis("AutomaticLength")
4913 hyp.SetFineness( fineness )
4916 # Public class: Mesh_RadialQuadrangle1D2D
4917 # -------------------------------
4919 ## Defines a Radial Quadrangle 1D2D algorithm
4920 # @ingroup l2_algos_radialq
4922 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4924 ## Private constructor.
4925 def __init__(self, mesh, geom=0):
4926 Mesh_Algorithm.__init__(self)
4927 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4929 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4930 self.nbLayers = None
4932 ## Return 2D hypothesis holding the 1D one
4933 def Get2DHypothesis(self):
4934 return self.distribHyp
4936 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4937 # hypothesis. Returns the created hypothesis
4938 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4939 #print "OwnHypothesis",hypType
4940 if not self.nbLayers is None:
4941 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4942 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4943 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4944 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4945 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4946 self.distribHyp.SetLayerDistribution( hyp )
4949 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4950 # @param n number of layers
4951 # @param UseExisting if ==true - searches for the existing hypothesis created with
4952 # the same parameters, else (default) - creates a new one
4953 def NumberOfLayers2D(self, n, UseExisting=0):
4954 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4955 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4956 CompareMethod=self.CompareNumberOfLayers)
4957 self.nbLayers.SetNumberOfLayers( n )
4958 return self.nbLayers
4960 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4961 def CompareNumberOfLayers(self, hyp, args):
4962 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4964 ## Defines "LocalLength" hypothesis, specifying the segment length
4965 # @param l the length of segments
4966 # @param p the precision of rounding
4967 def LocalLength(self, l, p=1e-07):
4968 hyp = self.OwnHypothesis("LocalLength", [l,p])
4973 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4974 # @param n the number of layers
4975 # @param s the scale factor (optional)
4976 def NumberOfSegments(self, n, s=[]):
4978 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4980 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4981 hyp.SetDistrType( 1 )
4982 hyp.SetScaleFactor(s)
4983 hyp.SetNumberOfSegments(n)
4986 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4987 # with a length that changes in arithmetic progression
4988 # @param start the length of the first segment
4989 # @param end the length of the last segment
4990 def Arithmetic1D(self, start, end ):
4991 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4992 hyp.SetLength(start, 1)
4993 hyp.SetLength(end , 0)
4996 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4997 # as geometric length increasing
4998 # @param start for the length of the first segment
4999 # @param end for the length of the last segment
5000 def StartEndLength(self, start, end):
5001 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5002 hyp.SetLength(start, 1)
5003 hyp.SetLength(end , 0)
5006 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5007 # @param fineness defines the quality of the mesh within the range [0-1]
5008 def AutomaticLength(self, fineness=0):
5009 hyp = self.OwnHypothesis("AutomaticLength")
5010 hyp.SetFineness( fineness )
5014 # Private class: Mesh_UseExisting
5015 # -------------------------------
5016 class Mesh_UseExisting(Mesh_Algorithm):
5018 def __init__(self, dim, mesh, geom=0):
5020 self.Create(mesh, geom, "UseExisting_1D")
5022 self.Create(mesh, geom, "UseExisting_2D")
5025 import salome_notebook
5026 notebook = salome_notebook.notebook
5028 ##Return values of the notebook variables
5029 def ParseParameters(last, nbParams,nbParam, value):
5033 listSize = len(last)
5034 for n in range(0,nbParams):
5036 if counter < listSize:
5037 strResult = strResult + last[counter]
5039 strResult = strResult + ""
5041 if isinstance(value, str):
5042 if notebook.isVariable(value):
5043 result = notebook.get(value)
5044 strResult=strResult+value
5046 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5048 strResult=strResult+str(value)
5050 if nbParams - 1 != counter:
5051 strResult=strResult+var_separator #":"
5053 return result, strResult
5055 #Wrapper class for StdMeshers_LocalLength hypothesis
5056 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5058 ## Set Length parameter value
5059 # @param length numerical value or name of variable from notebook
5060 def SetLength(self, length):
5061 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5062 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5063 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5065 ## Set Precision parameter value
5066 # @param precision numerical value or name of variable from notebook
5067 def SetPrecision(self, precision):
5068 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5069 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5070 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5072 #Registering the new proxy for LocalLength
5073 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5076 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5077 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5079 def SetLayerDistribution(self, hypo):
5080 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5081 hypo.ClearParameters();
5082 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5084 #Registering the new proxy for LayerDistribution
5085 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5087 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5088 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5090 ## Set Length parameter value
5091 # @param length numerical value or name of variable from notebook
5092 def SetLength(self, length):
5093 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5094 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5095 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5097 #Registering the new proxy for SegmentLengthAroundVertex
5098 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5101 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5102 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5104 ## Set Length parameter value
5105 # @param length numerical value or name of variable from notebook
5106 # @param isStart true is length is Start Length, otherwise false
5107 def SetLength(self, length, isStart):
5111 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5112 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5113 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5115 #Registering the new proxy for Arithmetic1D
5116 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5118 #Wrapper class for StdMeshers_Deflection1D hypothesis
5119 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5121 ## Set Deflection parameter value
5122 # @param deflection numerical value or name of variable from notebook
5123 def SetDeflection(self, deflection):
5124 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5125 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5126 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5128 #Registering the new proxy for Deflection1D
5129 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5131 #Wrapper class for StdMeshers_StartEndLength hypothesis
5132 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5134 ## Set Length parameter value
5135 # @param length numerical value or name of variable from notebook
5136 # @param isStart true is length is Start Length, otherwise false
5137 def SetLength(self, length, isStart):
5141 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5142 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5143 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5145 #Registering the new proxy for StartEndLength
5146 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5148 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5149 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5151 ## Set Max Element Area parameter value
5152 # @param area numerical value or name of variable from notebook
5153 def SetMaxElementArea(self, area):
5154 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5155 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5156 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5158 #Registering the new proxy for MaxElementArea
5159 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5162 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5163 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5165 ## Set Max Element Volume parameter value
5166 # @param area numerical value or name of variable from notebook
5167 def SetMaxElementVolume(self, volume):
5168 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5169 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5170 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5172 #Registering the new proxy for MaxElementVolume
5173 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5176 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5177 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5179 ## Set Number Of Layers parameter value
5180 # @param nbLayers numerical value or name of variable from notebook
5181 def SetNumberOfLayers(self, nbLayers):
5182 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5183 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5184 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5186 #Registering the new proxy for NumberOfLayers
5187 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5189 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5190 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5192 ## Set Number Of Segments parameter value
5193 # @param nbSeg numerical value or name of variable from notebook
5194 def SetNumberOfSegments(self, nbSeg):
5195 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5196 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5197 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5198 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5200 ## Set Scale Factor parameter value
5201 # @param factor numerical value or name of variable from notebook
5202 def SetScaleFactor(self, factor):
5203 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5204 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5205 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5207 #Registering the new proxy for NumberOfSegments
5208 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5210 if not noNETGENPlugin:
5211 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5212 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5214 ## Set Max Size parameter value
5215 # @param maxsize numerical value or name of variable from notebook
5216 def SetMaxSize(self, maxsize):
5217 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5218 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5219 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5220 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5222 ## Set Growth Rate parameter value
5223 # @param value numerical value or name of variable from notebook
5224 def SetGrowthRate(self, value):
5225 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5226 value, parameters = ParseParameters(lastParameters,4,2,value)
5227 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5228 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5230 ## Set Number of Segments per Edge parameter value
5231 # @param value numerical value or name of variable from notebook
5232 def SetNbSegPerEdge(self, value):
5233 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5234 value, parameters = ParseParameters(lastParameters,4,3,value)
5235 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5236 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5238 ## Set Number of Segments per Radius parameter value
5239 # @param value numerical value or name of variable from notebook
5240 def SetNbSegPerRadius(self, value):
5241 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5242 value, parameters = ParseParameters(lastParameters,4,4,value)
5243 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5244 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5246 #Registering the new proxy for NETGENPlugin_Hypothesis
5247 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5250 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5251 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5254 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5255 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5257 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5258 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5260 ## Set Number of Segments parameter value
5261 # @param nbSeg numerical value or name of variable from notebook
5262 def SetNumberOfSegments(self, nbSeg):
5263 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5264 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5265 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5266 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5268 ## Set Local Length parameter value
5269 # @param length numerical value or name of variable from notebook
5270 def SetLocalLength(self, length):
5271 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5272 length, parameters = ParseParameters(lastParameters,2,1,length)
5273 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5274 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5276 ## Set Max Element Area parameter value
5277 # @param area numerical value or name of variable from notebook
5278 def SetMaxElementArea(self, area):
5279 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5280 area, parameters = ParseParameters(lastParameters,2,2,area)
5281 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5282 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5284 def LengthFromEdges(self):
5285 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5287 value, parameters = ParseParameters(lastParameters,2,2,value)
5288 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5289 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5291 #Registering the new proxy for NETGEN_SimpleParameters_2D
5292 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5295 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5296 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5297 ## Set Max Element Volume parameter value
5298 # @param volume numerical value or name of variable from notebook
5299 def SetMaxElementVolume(self, volume):
5300 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5301 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5302 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5303 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5305 def LengthFromFaces(self):
5306 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5308 value, parameters = ParseParameters(lastParameters,3,3,value)
5309 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5310 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5312 #Registering the new proxy for NETGEN_SimpleParameters_3D
5313 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5315 pass # if not noNETGENPlugin:
5317 class Pattern(SMESH._objref_SMESH_Pattern):
5319 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5321 if isinstance(theNodeIndexOnKeyPoint1,str):
5323 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5325 theNodeIndexOnKeyPoint1 -= 1
5326 theMesh.SetParameters(Parameters)
5327 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5329 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5332 if isinstance(theNode000Index,str):
5334 if isinstance(theNode001Index,str):
5336 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5338 theNode000Index -= 1
5340 theNode001Index -= 1
5341 theMesh.SetParameters(Parameters)
5342 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5344 #Registering the new proxy for Pattern
5345 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)