1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_quad Quadrangle Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
90 ## @defgroup l1_measurements Measurements
95 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 # import GHS3DPlugin module if possible
119 # import GHS3DPRLPlugin module if possible
122 import GHS3DPRLPlugin
127 # import HexoticPlugin module if possible
135 # import BLSURFPlugin module if possible
143 ## @addtogroup l1_auxiliary
146 # Types of algorithms
159 NETGEN_1D2D3D = FULL_NETGEN
160 NETGEN_FULL = FULL_NETGEN
168 # MirrorType enumeration
169 POINT = SMESH_MeshEditor.POINT
170 AXIS = SMESH_MeshEditor.AXIS
171 PLANE = SMESH_MeshEditor.PLANE
173 # Smooth_Method enumeration
174 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
175 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
177 # Fineness enumeration (for NETGEN)
185 # Optimization level of GHS3D
187 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
188 # V4.1 (partialy redefines V3.1). Issue 0020574
189 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
191 # Topology treatment way of BLSURF
192 FromCAD, PreProcess, PreProcessPlus = 0,1,2
194 # Element size flag of BLSURF
195 DefaultSize, DefaultGeom, Custom = 0,0,1
197 PrecisionConfusion = 1e-07
199 # TopAbs_State enumeration
200 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 # Methods of splitting a hexahedron into tetrahedra
203 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
205 # import items of enum QuadType
206 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
208 ## Converts an angle from degrees to radians
209 def DegreesToRadians(AngleInDegrees):
211 return AngleInDegrees * pi / 180.0
213 # Salome notebook variable separator
216 # Parametrized substitute for PointStruct
217 class PointStructStr:
226 def __init__(self, xStr, yStr, zStr):
230 if isinstance(xStr, str) and notebook.isVariable(xStr):
231 self.x = notebook.get(xStr)
234 if isinstance(yStr, str) and notebook.isVariable(yStr):
235 self.y = notebook.get(yStr)
238 if isinstance(zStr, str) and notebook.isVariable(zStr):
239 self.z = notebook.get(zStr)
243 # Parametrized substitute for PointStruct (with 6 parameters)
244 class PointStructStr6:
259 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
266 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
267 self.x1 = notebook.get(x1Str)
270 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
271 self.x2 = notebook.get(x2Str)
274 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
275 self.y1 = notebook.get(y1Str)
278 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
279 self.y2 = notebook.get(y2Str)
282 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
283 self.z1 = notebook.get(z1Str)
286 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
287 self.z2 = notebook.get(z2Str)
291 # Parametrized substitute for AxisStruct
307 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
314 if isinstance(xStr, str) and notebook.isVariable(xStr):
315 self.x = notebook.get(xStr)
318 if isinstance(yStr, str) and notebook.isVariable(yStr):
319 self.y = notebook.get(yStr)
322 if isinstance(zStr, str) and notebook.isVariable(zStr):
323 self.z = notebook.get(zStr)
326 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
327 self.dx = notebook.get(dxStr)
330 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
331 self.dy = notebook.get(dyStr)
334 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
335 self.dz = notebook.get(dzStr)
339 # Parametrized substitute for DirStruct
342 def __init__(self, pointStruct):
343 self.pointStruct = pointStruct
345 # Returns list of variable values from salome notebook
346 def ParsePointStruct(Point):
347 Parameters = 2*var_separator
348 if isinstance(Point, PointStructStr):
349 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
350 Point = PointStruct(Point.x, Point.y, Point.z)
351 return Point, Parameters
353 # Returns list of variable values from salome notebook
354 def ParseDirStruct(Dir):
355 Parameters = 2*var_separator
356 if isinstance(Dir, DirStructStr):
357 pntStr = Dir.pointStruct
358 if isinstance(pntStr, PointStructStr6):
359 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
360 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
361 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
362 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
364 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
365 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
366 Dir = DirStruct(Point)
367 return Dir, Parameters
369 # Returns list of variable values from salome notebook
370 def ParseAxisStruct(Axis):
371 Parameters = 5*var_separator
372 if isinstance(Axis, AxisStructStr):
373 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
374 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
375 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
376 return Axis, Parameters
378 ## Return list of variable values from salome notebook
379 def ParseAngles(list):
382 for parameter in list:
383 if isinstance(parameter,str) and notebook.isVariable(parameter):
384 Result.append(DegreesToRadians(notebook.get(parameter)))
387 Result.append(parameter)
390 Parameters = Parameters + str(parameter)
391 Parameters = Parameters + var_separator
393 Parameters = Parameters[:len(Parameters)-1]
394 return Result, Parameters
396 def IsEqual(val1, val2, tol=PrecisionConfusion):
397 if abs(val1 - val2) < tol:
407 if isinstance(obj, SALOMEDS._objref_SObject):
410 ior = salome.orb.object_to_string(obj)
413 studies = salome.myStudyManager.GetOpenStudies()
414 for sname in studies:
415 s = salome.myStudyManager.GetStudyByName(sname)
417 sobj = s.FindObjectIOR(ior)
418 if not sobj: continue
419 return sobj.GetName()
420 if hasattr(obj, "GetName"):
421 # unknown CORBA object, having GetName() method
424 # unknown CORBA object, no GetName() method
427 if hasattr(obj, "GetName"):
428 # unknown non-CORBA object, having GetName() method
431 raise RuntimeError, "Null or invalid object"
433 ## Prints error message if a hypothesis was not assigned.
434 def TreatHypoStatus(status, hypName, geomName, isAlgo):
436 hypType = "algorithm"
438 hypType = "hypothesis"
440 if status == HYP_UNKNOWN_FATAL :
441 reason = "for unknown reason"
442 elif status == HYP_INCOMPATIBLE :
443 reason = "this hypothesis mismatches the algorithm"
444 elif status == HYP_NOTCONFORM :
445 reason = "a non-conform mesh would be built"
446 elif status == HYP_ALREADY_EXIST :
447 if isAlgo: return # it does not influence anything
448 reason = hypType + " of the same dimension is already assigned to this shape"
449 elif status == HYP_BAD_DIM :
450 reason = hypType + " mismatches the shape"
451 elif status == HYP_CONCURENT :
452 reason = "there are concurrent hypotheses on sub-shapes"
453 elif status == HYP_BAD_SUBSHAPE :
454 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
455 elif status == HYP_BAD_GEOMETRY:
456 reason = "geometry mismatches the expectation of the algorithm"
457 elif status == HYP_HIDDEN_ALGO:
458 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
459 elif status == HYP_HIDING_ALGO:
460 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
461 elif status == HYP_NEED_SHAPE:
462 reason = "Algorithm can't work without shape"
465 hypName = '"' + hypName + '"'
466 geomName= '"' + geomName+ '"'
467 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
468 print hypName, "was assigned to", geomName,"but", reason
469 elif not geomName == '""':
470 print hypName, "was not assigned to",geomName,":", reason
472 print hypName, "was not assigned:", reason
475 ## Check meshing plugin availability
476 def CheckPlugin(plugin):
477 if plugin == NETGEN and noNETGENPlugin:
478 print "Warning: NETGENPlugin module unavailable"
480 elif plugin == GHS3D and noGHS3DPlugin:
481 print "Warning: GHS3DPlugin module unavailable"
483 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
484 print "Warning: GHS3DPRLPlugin module unavailable"
486 elif plugin == Hexotic and noHexoticPlugin:
487 print "Warning: HexoticPlugin module unavailable"
489 elif plugin == BLSURF and noBLSURFPlugin:
490 print "Warning: BLSURFPlugin module unavailable"
494 # end of l1_auxiliary
497 # All methods of this class are accessible directly from the smesh.py package.
498 class smeshDC(SMESH._objref_SMESH_Gen):
500 ## Sets the current study and Geometry component
501 # @ingroup l1_auxiliary
502 def init_smesh(self,theStudy,geompyD):
503 self.SetCurrentStudy(theStudy,geompyD)
505 ## Creates an empty Mesh. This mesh can have an underlying geometry.
506 # @param obj the Geometrical object on which the mesh is built. If not defined,
507 # the mesh will have no underlying geometry.
508 # @param name the name for the new mesh.
509 # @return an instance of Mesh class.
510 # @ingroup l2_construct
511 def Mesh(self, obj=0, name=0):
512 if isinstance(obj,str):
514 return Mesh(self,self.geompyD,obj,name)
516 ## Returns a long value from enumeration
517 # Should be used for SMESH.FunctorType enumeration
518 # @ingroup l1_controls
519 def EnumToLong(self,theItem):
522 ## Returns a string representation of the color.
523 # To be used with filters.
524 # @param c color value (SALOMEDS.Color)
525 # @ingroup l1_controls
526 def ColorToString(self,c):
528 if isinstance(c, SALOMEDS.Color):
529 val = "%s;%s;%s" % (c.R, c.G, c.B)
530 elif isinstance(c, str):
533 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
536 ## Gets PointStruct from vertex
537 # @param theVertex a GEOM object(vertex)
538 # @return SMESH.PointStruct
539 # @ingroup l1_auxiliary
540 def GetPointStruct(self,theVertex):
541 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
542 return PointStruct(x,y,z)
544 ## Gets DirStruct from vector
545 # @param theVector a GEOM object(vector)
546 # @return SMESH.DirStruct
547 # @ingroup l1_auxiliary
548 def GetDirStruct(self,theVector):
549 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
550 if(len(vertices) != 2):
551 print "Error: vector object is incorrect."
553 p1 = self.geompyD.PointCoordinates(vertices[0])
554 p2 = self.geompyD.PointCoordinates(vertices[1])
555 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
556 dirst = DirStruct(pnt)
559 ## Makes DirStruct from a triplet
560 # @param x,y,z vector components
561 # @return SMESH.DirStruct
562 # @ingroup l1_auxiliary
563 def MakeDirStruct(self,x,y,z):
564 pnt = PointStruct(x,y,z)
565 return DirStruct(pnt)
567 ## Get AxisStruct from object
568 # @param theObj a GEOM object (line or plane)
569 # @return SMESH.AxisStruct
570 # @ingroup l1_auxiliary
571 def GetAxisStruct(self,theObj):
572 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
574 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
575 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
576 vertex1 = self.geompyD.PointCoordinates(vertex1)
577 vertex2 = self.geompyD.PointCoordinates(vertex2)
578 vertex3 = self.geompyD.PointCoordinates(vertex3)
579 vertex4 = self.geompyD.PointCoordinates(vertex4)
580 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
581 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
582 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] ]
583 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
585 elif len(edges) == 1:
586 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
587 p1 = self.geompyD.PointCoordinates( vertex1 )
588 p2 = self.geompyD.PointCoordinates( vertex2 )
589 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
593 # From SMESH_Gen interface:
594 # ------------------------
596 ## Sets the given name to the object
597 # @param obj the object to rename
598 # @param name a new object name
599 # @ingroup l1_auxiliary
600 def SetName(self, obj, name):
601 if isinstance( obj, Mesh ):
603 elif isinstance( obj, Mesh_Algorithm ):
604 obj = obj.GetAlgorithm()
605 ior = salome.orb.object_to_string(obj)
606 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
608 ## Sets the current mode
609 # @ingroup l1_auxiliary
610 def SetEmbeddedMode( self,theMode ):
611 #self.SetEmbeddedMode(theMode)
612 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
614 ## Gets the current mode
615 # @ingroup l1_auxiliary
616 def IsEmbeddedMode(self):
617 #return self.IsEmbeddedMode()
618 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
620 ## Sets the current study
621 # @ingroup l1_auxiliary
622 def SetCurrentStudy( self, theStudy, geompyD = None ):
623 #self.SetCurrentStudy(theStudy)
626 geompyD = geompy.geom
629 self.SetGeomEngine(geompyD)
630 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
632 ## Gets the current study
633 # @ingroup l1_auxiliary
634 def GetCurrentStudy(self):
635 #return self.GetCurrentStudy()
636 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
638 ## Creates a Mesh object importing data from the given UNV file
639 # @return an instance of Mesh class
641 def CreateMeshesFromUNV( self,theFileName ):
642 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
643 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
646 ## Creates a Mesh object(s) importing data from the given MED file
647 # @return a list of Mesh class instances
649 def CreateMeshesFromMED( self,theFileName ):
650 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
652 for iMesh in range(len(aSmeshMeshes)) :
653 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
654 aMeshes.append(aMesh)
655 return aMeshes, aStatus
657 ## Creates a Mesh object importing data from the given STL file
658 # @return an instance of Mesh class
660 def CreateMeshesFromSTL( self, theFileName ):
661 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
662 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
665 ## Concatenate the given meshes into one mesh.
666 # @return an instance of Mesh class
667 # @param meshes the meshes to combine into one mesh
668 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
669 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
670 # @param mergeTolerance tolerance for merging nodes
671 # @param allGroups forces creation of groups of all elements
672 def Concatenate( self, meshes, uniteIdenticalGroups,
673 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
674 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
675 for i,m in enumerate(meshes):
676 if isinstance(m, Mesh):
677 meshes[i] = m.GetMesh()
679 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
680 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
682 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
683 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
684 aSmeshMesh.SetParameters(Parameters)
685 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
688 ## Create a mesh by copying a part of another mesh.
689 # @param meshPart a part of mesh to copy, either a Mesh, a sub-mesh or a group;
690 # to copy nodes or elements not contained in any mesh object,
691 # pass result of Mesh.GetIDSource( list_of_ids, type ) as meshPart
692 # @param meshName a name of the new mesh
693 # @param toCopyGroups to create in the new mesh groups the copied elements belongs to
694 # @param toKeepIDs to preserve IDs of the copied elements or not
695 # @return an instance of Mesh class
696 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
697 if (isinstance( meshPart, Mesh )):
698 meshPart = meshPart.GetMesh()
699 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
700 return Mesh(self, self.geompyD, mesh)
702 ## From SMESH_Gen interface
703 # @return the list of integer values
704 # @ingroup l1_auxiliary
705 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
706 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
708 ## From SMESH_Gen interface. Creates a pattern
709 # @return an instance of SMESH_Pattern
711 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
712 # @ingroup l2_modif_patterns
713 def GetPattern(self):
714 return SMESH._objref_SMESH_Gen.GetPattern(self)
716 ## Sets number of segments per diagonal of boundary box of geometry by which
717 # default segment length of appropriate 1D hypotheses is defined.
718 # Default value is 10
719 # @ingroup l1_auxiliary
720 def SetBoundaryBoxSegmentation(self, nbSegments):
721 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
723 # Filtering. Auxiliary functions:
724 # ------------------------------
726 ## Creates an empty criterion
727 # @return SMESH.Filter.Criterion
728 # @ingroup l1_controls
729 def GetEmptyCriterion(self):
730 Type = self.EnumToLong(FT_Undefined)
731 Compare = self.EnumToLong(FT_Undefined)
735 UnaryOp = self.EnumToLong(FT_Undefined)
736 BinaryOp = self.EnumToLong(FT_Undefined)
739 Precision = -1 ##@1e-07
740 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
741 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
743 ## Creates a criterion by the given parameters
744 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
745 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
746 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
747 # @param Treshold the threshold value (range of ids as string, shape, numeric)
748 # @param UnaryOp FT_LogicalNOT or FT_Undefined
749 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
750 # FT_Undefined (must be for the last criterion of all criteria)
751 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
752 # FT_LyingOnGeom, FT_CoplanarFaces criteria
753 # @return SMESH.Filter.Criterion
754 # @ingroup l1_controls
755 def GetCriterion(self,elementType,
757 Compare = FT_EqualTo,
759 UnaryOp=FT_Undefined,
760 BinaryOp=FT_Undefined,
762 aCriterion = self.GetEmptyCriterion()
763 aCriterion.TypeOfElement = elementType
764 aCriterion.Type = self.EnumToLong(CritType)
765 aCriterion.Tolerance = Tolerance
769 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
770 aCriterion.Compare = self.EnumToLong(Compare)
771 elif Compare == "=" or Compare == "==":
772 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
774 aCriterion.Compare = self.EnumToLong(FT_LessThan)
776 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
778 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
781 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
782 FT_BelongToCylinder, FT_LyingOnGeom]:
783 # Checks the treshold
784 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
785 aCriterion.ThresholdStr = GetName(aTreshold)
786 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
788 print "Error: The treshold should be a shape."
790 if isinstance(UnaryOp,float):
791 aCriterion.Tolerance = UnaryOp
792 UnaryOp = FT_Undefined
794 elif CritType == FT_RangeOfIds:
795 # Checks the treshold
796 if isinstance(aTreshold, str):
797 aCriterion.ThresholdStr = aTreshold
799 print "Error: The treshold should be a string."
801 elif CritType == FT_CoplanarFaces:
802 # Checks the treshold
803 if isinstance(aTreshold, int):
804 aCriterion.ThresholdID = "%s"%aTreshold
805 elif isinstance(aTreshold, str):
808 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
809 aCriterion.ThresholdID = aTreshold
812 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
813 elif CritType == FT_ElemGeomType:
814 # Checks the treshold
816 aCriterion.Threshold = self.EnumToLong(aTreshold)
818 if isinstance(aTreshold, int):
819 aCriterion.Threshold = aTreshold
821 print "Error: The treshold should be an integer or SMESH.GeometryType."
825 elif CritType == FT_GroupColor:
826 # Checks the treshold
828 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
830 print "Error: The threshold value should be of SALOMEDS.Color type"
833 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
834 FT_FreeFaces, FT_LinearOrQuadratic,
835 FT_BareBorderFace, FT_BareBorderVolume,
836 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
837 # At this point the treshold is unnecessary
838 if aTreshold == FT_LogicalNOT:
839 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
840 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
841 aCriterion.BinaryOp = aTreshold
845 aTreshold = float(aTreshold)
846 aCriterion.Threshold = aTreshold
848 print "Error: The treshold should be a number."
851 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
852 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
854 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
855 aCriterion.BinaryOp = self.EnumToLong(Treshold)
857 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
858 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
860 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
861 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
865 ## Creates a filter with the given parameters
866 # @param elementType the type of elements in the group
867 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
868 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
869 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
870 # @param UnaryOp FT_LogicalNOT or FT_Undefined
871 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
872 # FT_LyingOnGeom, FT_CoplanarFaces criteria
873 # @return SMESH_Filter
874 # @ingroup l1_controls
875 def GetFilter(self,elementType,
876 CritType=FT_Undefined,
879 UnaryOp=FT_Undefined,
881 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
882 aFilterMgr = self.CreateFilterManager()
883 aFilter = aFilterMgr.CreateFilter()
885 aCriteria.append(aCriterion)
886 aFilter.SetCriteria(aCriteria)
887 aFilterMgr.UnRegister()
890 ## Creates a numerical functor by its type
891 # @param theCriterion FT_...; functor type
892 # @return SMESH_NumericalFunctor
893 # @ingroup l1_controls
894 def GetFunctor(self,theCriterion):
895 aFilterMgr = self.CreateFilterManager()
896 if theCriterion == FT_AspectRatio:
897 return aFilterMgr.CreateAspectRatio()
898 elif theCriterion == FT_AspectRatio3D:
899 return aFilterMgr.CreateAspectRatio3D()
900 elif theCriterion == FT_Warping:
901 return aFilterMgr.CreateWarping()
902 elif theCriterion == FT_MinimumAngle:
903 return aFilterMgr.CreateMinimumAngle()
904 elif theCriterion == FT_Taper:
905 return aFilterMgr.CreateTaper()
906 elif theCriterion == FT_Skew:
907 return aFilterMgr.CreateSkew()
908 elif theCriterion == FT_Area:
909 return aFilterMgr.CreateArea()
910 elif theCriterion == FT_Volume3D:
911 return aFilterMgr.CreateVolume3D()
912 elif theCriterion == FT_MaxElementLength2D:
913 return aFilterMgr.CreateMaxElementLength2D()
914 elif theCriterion == FT_MaxElementLength3D:
915 return aFilterMgr.CreateMaxElementLength3D()
916 elif theCriterion == FT_MultiConnection:
917 return aFilterMgr.CreateMultiConnection()
918 elif theCriterion == FT_MultiConnection2D:
919 return aFilterMgr.CreateMultiConnection2D()
920 elif theCriterion == FT_Length:
921 return aFilterMgr.CreateLength()
922 elif theCriterion == FT_Length2D:
923 return aFilterMgr.CreateLength2D()
925 print "Error: given parameter is not numerucal functor type."
927 ## Creates hypothesis
928 # @param theHType mesh hypothesis type (string)
929 # @param theLibName mesh plug-in library name
930 # @return created hypothesis instance
931 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
932 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
934 ## Gets the mesh stattistic
935 # @return dictionary type element - count of elements
936 # @ingroup l1_meshinfo
937 def GetMeshInfo(self, obj):
938 if isinstance( obj, Mesh ):
941 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
942 values = obj.GetMeshInfo()
943 for i in range(SMESH.Entity_Last._v):
944 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
948 ## Get minimum distance between two objects
950 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
951 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
953 # @param src1 first source object
954 # @param src2 second source object
955 # @param id1 node/element id from the first source
956 # @param id2 node/element id from the second (or first) source
957 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
958 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
959 # @return minimum distance value
960 # @sa GetMinDistance()
961 # @ingroup l1_measurements
962 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
963 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
967 result = result.value
970 ## Get measure structure specifying minimum distance data between two objects
972 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
973 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
975 # @param src1 first source object
976 # @param src2 second source object
977 # @param id1 node/element id from the first source
978 # @param id2 node/element id from the second (or first) source
979 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
980 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
981 # @return Measure structure or None if input data is invalid
983 # @ingroup l1_measurements
984 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
985 if isinstance(src1, Mesh): src1 = src1.mesh
986 if isinstance(src2, Mesh): src2 = src2.mesh
987 if src2 is None and id2 != 0: src2 = src1
988 if not hasattr(src1, "_narrow"): return None
989 src1 = src1._narrow(SMESH.SMESH_IDSource)
990 if not src1: return None
993 e = m.GetMeshEditor()
995 src1 = e.MakeIDSource([id1], SMESH.FACE)
997 src1 = e.MakeIDSource([id1], SMESH.NODE)
999 if hasattr(src2, "_narrow"):
1000 src2 = src2._narrow(SMESH.SMESH_IDSource)
1001 if src2 and id2 != 0:
1003 e = m.GetMeshEditor()
1005 src2 = e.MakeIDSource([id2], SMESH.FACE)
1007 src2 = e.MakeIDSource([id2], SMESH.NODE)
1010 aMeasurements = self.CreateMeasurements()
1011 result = aMeasurements.MinDistance(src1, src2)
1012 aMeasurements.UnRegister()
1015 ## Get bounding box of the specified object(s)
1016 # @param objects single source object or list of source objects
1017 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1018 # @sa GetBoundingBox()
1019 # @ingroup l1_measurements
1020 def BoundingBox(self, objects):
1021 result = self.GetBoundingBox(objects)
1025 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1028 ## Get measure structure specifying bounding box data of the specified object(s)
1029 # @param objects single source object or list of source objects
1030 # @return Measure structure
1032 # @ingroup l1_measurements
1033 def GetBoundingBox(self, objects):
1034 if isinstance(objects, tuple):
1035 objects = list(objects)
1036 if not isinstance(objects, list):
1040 if isinstance(o, Mesh):
1041 srclist.append(o.mesh)
1042 elif hasattr(o, "_narrow"):
1043 src = o._narrow(SMESH.SMESH_IDSource)
1044 if src: srclist.append(src)
1047 aMeasurements = self.CreateMeasurements()
1048 result = aMeasurements.BoundingBox(srclist)
1049 aMeasurements.UnRegister()
1053 #Registering the new proxy for SMESH_Gen
1054 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1057 # Public class: Mesh
1058 # ==================
1060 ## This class allows defining and managing a mesh.
1061 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1062 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1063 # new nodes and elements and by changing the existing entities), to get information
1064 # about a mesh and to export a mesh into different formats.
1073 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1074 # sets the GUI name of this mesh to \a name.
1075 # @param smeshpyD an instance of smeshDC class
1076 # @param geompyD an instance of geompyDC class
1077 # @param obj Shape to be meshed or SMESH_Mesh object
1078 # @param name Study name of the mesh
1079 # @ingroup l2_construct
1080 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1081 self.smeshpyD=smeshpyD
1082 self.geompyD=geompyD
1086 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1088 # publish geom of mesh (issue 0021122)
1089 if not self.geom.GetStudyEntry():
1090 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1091 if studyID != geompyD.myStudyId:
1092 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1094 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1095 geompyD.addToStudy( self.geom, geo_name )
1096 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1098 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1101 self.mesh = self.smeshpyD.CreateEmptyMesh()
1103 self.smeshpyD.SetName(self.mesh, name)
1105 self.smeshpyD.SetName(self.mesh, GetName(obj))
1108 self.geom = self.mesh.GetShapeToMesh()
1110 self.editor = self.mesh.GetMeshEditor()
1112 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1113 # @param theMesh a SMESH_Mesh object
1114 # @ingroup l2_construct
1115 def SetMesh(self, theMesh):
1117 self.geom = self.mesh.GetShapeToMesh()
1119 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1120 # @return a SMESH_Mesh object
1121 # @ingroup l2_construct
1125 ## Gets the name of the mesh
1126 # @return the name of the mesh as a string
1127 # @ingroup l2_construct
1129 name = GetName(self.GetMesh())
1132 ## Sets a name to the mesh
1133 # @param name a new name of the mesh
1134 # @ingroup l2_construct
1135 def SetName(self, name):
1136 self.smeshpyD.SetName(self.GetMesh(), name)
1138 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1139 # The subMesh object gives access to the IDs of nodes and elements.
1140 # @param theSubObject a geometrical object (shape)
1141 # @param theName a name for the submesh
1142 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1143 # @ingroup l2_submeshes
1144 def GetSubMesh(self, theSubObject, theName):
1145 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1148 ## Returns the shape associated to the mesh
1149 # @return a GEOM_Object
1150 # @ingroup l2_construct
1154 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1155 # @param geom the shape to be meshed (GEOM_Object)
1156 # @ingroup l2_construct
1157 def SetShape(self, geom):
1158 self.mesh = self.smeshpyD.CreateMesh(geom)
1160 ## Returns true if the hypotheses are defined well
1161 # @param theSubObject a subshape of a mesh shape
1162 # @return True or False
1163 # @ingroup l2_construct
1164 def IsReadyToCompute(self, theSubObject):
1165 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1167 ## Returns errors of hypotheses definition.
1168 # The list of errors is empty if everything is OK.
1169 # @param theSubObject a subshape of a mesh shape
1170 # @return a list of errors
1171 # @ingroup l2_construct
1172 def GetAlgoState(self, theSubObject):
1173 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1175 ## Returns a geometrical object on which the given element was built.
1176 # The returned geometrical object, if not nil, is either found in the
1177 # study or published by this method with the given name
1178 # @param theElementID the id of the mesh element
1179 # @param theGeomName the user-defined name of the geometrical object
1180 # @return GEOM::GEOM_Object instance
1181 # @ingroup l2_construct
1182 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1183 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1185 ## Returns the mesh dimension depending on the dimension of the underlying shape
1186 # @return mesh dimension as an integer value [0,3]
1187 # @ingroup l1_auxiliary
1188 def MeshDimension(self):
1189 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1190 if len( shells ) > 0 :
1192 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1194 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1200 ## Creates a segment discretization 1D algorithm.
1201 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1202 # \n If the optional \a geom parameter is not set, this algorithm is global.
1203 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1204 # @param algo the type of the required algorithm. Possible values are:
1206 # - smesh.PYTHON for discretization via a python function,
1207 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1208 # @param geom If defined is the subshape to be meshed
1209 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1210 # @ingroup l3_algos_basic
1211 def Segment(self, algo=REGULAR, geom=0):
1212 ## if Segment(geom) is called by mistake
1213 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1214 algo, geom = geom, algo
1215 if not algo: algo = REGULAR
1218 return Mesh_Segment(self, geom)
1219 elif algo == PYTHON:
1220 return Mesh_Segment_Python(self, geom)
1221 elif algo == COMPOSITE:
1222 return Mesh_CompositeSegment(self, geom)
1224 return Mesh_Segment(self, geom)
1226 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1227 # If the optional \a geom parameter is not set, this algorithm is global.
1228 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1229 # @param geom If defined the subshape is to be meshed
1230 # @return an instance of Mesh_UseExistingElements class
1231 # @ingroup l3_algos_basic
1232 def UseExisting1DElements(self, geom=0):
1233 return Mesh_UseExistingElements(1,self, geom)
1235 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1236 # If the optional \a geom parameter is not set, this algorithm is global.
1237 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1238 # @param geom If defined the subshape is to be meshed
1239 # @return an instance of Mesh_UseExistingElements class
1240 # @ingroup l3_algos_basic
1241 def UseExisting2DElements(self, geom=0):
1242 return Mesh_UseExistingElements(2,self, geom)
1244 ## Enables creation of nodes and segments usable by 2D algoritms.
1245 # The added nodes and segments must be bound to edges and vertices by
1246 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1247 # If the optional \a geom parameter is not set, this algorithm is global.
1248 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1249 # @param geom the subshape to be manually meshed
1250 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1251 # @ingroup l3_algos_basic
1252 def UseExistingSegments(self, geom=0):
1253 algo = Mesh_UseExisting(1,self,geom)
1254 return algo.GetAlgorithm()
1256 ## Enables creation of nodes and faces usable by 3D algoritms.
1257 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1258 # and SetMeshElementOnShape()
1259 # If the optional \a geom parameter is not set, this algorithm is global.
1260 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1261 # @param geom the subshape to be manually meshed
1262 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1263 # @ingroup l3_algos_basic
1264 def UseExistingFaces(self, geom=0):
1265 algo = Mesh_UseExisting(2,self,geom)
1266 return algo.GetAlgorithm()
1268 ## Creates a triangle 2D algorithm for faces.
1269 # If the optional \a geom parameter is not set, this algorithm is global.
1270 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1271 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1272 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1273 # @return an instance of Mesh_Triangle algorithm
1274 # @ingroup l3_algos_basic
1275 def Triangle(self, algo=MEFISTO, geom=0):
1276 ## if Triangle(geom) is called by mistake
1277 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1280 return Mesh_Triangle(self, algo, geom)
1282 ## Creates a quadrangle 2D algorithm for faces.
1283 # If the optional \a geom parameter is not set, this algorithm is global.
1284 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1285 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1286 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1287 # @return an instance of Mesh_Quadrangle algorithm
1288 # @ingroup l3_algos_basic
1289 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1290 if algo==RADIAL_QUAD:
1291 return Mesh_RadialQuadrangle1D2D(self,geom)
1293 return Mesh_Quadrangle(self, geom)
1295 ## Creates a tetrahedron 3D algorithm for solids.
1296 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1297 # If the optional \a geom parameter is not set, this algorithm is global.
1298 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1299 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1300 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1301 # @return an instance of Mesh_Tetrahedron algorithm
1302 # @ingroup l3_algos_basic
1303 def Tetrahedron(self, algo=NETGEN, geom=0):
1304 ## if Tetrahedron(geom) is called by mistake
1305 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1306 algo, geom = geom, algo
1307 if not algo: algo = NETGEN
1309 return Mesh_Tetrahedron(self, algo, geom)
1311 ## Creates a hexahedron 3D algorithm for solids.
1312 # If the optional \a geom parameter is not set, this algorithm is global.
1313 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1314 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1315 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1316 # @return an instance of Mesh_Hexahedron algorithm
1317 # @ingroup l3_algos_basic
1318 def Hexahedron(self, algo=Hexa, geom=0):
1319 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1320 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1321 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1322 elif geom == 0: algo, geom = Hexa, algo
1323 return Mesh_Hexahedron(self, algo, geom)
1325 ## Deprecated, used only for compatibility!
1326 # @return an instance of Mesh_Netgen algorithm
1327 # @ingroup l3_algos_basic
1328 def Netgen(self, is3D, geom=0):
1329 return Mesh_Netgen(self, is3D, geom)
1331 ## Creates a projection 1D algorithm for edges.
1332 # If the optional \a geom parameter is not set, this algorithm is global.
1333 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1334 # @param geom If defined, the subshape to be meshed
1335 # @return an instance of Mesh_Projection1D algorithm
1336 # @ingroup l3_algos_proj
1337 def Projection1D(self, geom=0):
1338 return Mesh_Projection1D(self, geom)
1340 ## Creates a projection 2D algorithm for faces.
1341 # If the optional \a geom parameter is not set, this algorithm is global.
1342 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1343 # @param geom If defined, the subshape to be meshed
1344 # @return an instance of Mesh_Projection2D algorithm
1345 # @ingroup l3_algos_proj
1346 def Projection2D(self, geom=0):
1347 return Mesh_Projection2D(self, geom)
1349 ## Creates a projection 3D algorithm for solids.
1350 # If the optional \a geom parameter is not set, this algorithm is global.
1351 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1352 # @param geom If defined, the subshape to be meshed
1353 # @return an instance of Mesh_Projection3D algorithm
1354 # @ingroup l3_algos_proj
1355 def Projection3D(self, geom=0):
1356 return Mesh_Projection3D(self, geom)
1358 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1359 # If the optional \a geom parameter is not set, this algorithm is global.
1360 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1361 # @param geom If defined, the subshape to be meshed
1362 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1363 # @ingroup l3_algos_radialp l3_algos_3dextr
1364 def Prism(self, geom=0):
1368 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1369 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1370 if nbSolids == 0 or nbSolids == nbShells:
1371 return Mesh_Prism3D(self, geom)
1372 return Mesh_RadialPrism3D(self, geom)
1374 ## Evaluates size of prospective mesh on a shape
1375 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1376 # To know predicted number of e.g. edges, inquire it this way
1377 # Evaluate()[ EnumToLong( Entity_Edge )]
1378 def Evaluate(self, geom=0):
1379 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1381 geom = self.mesh.GetShapeToMesh()
1384 return self.smeshpyD.Evaluate(self.mesh, geom)
1387 ## Computes the mesh and returns the status of the computation
1388 # @param geom geomtrical shape on which mesh data should be computed
1389 # @param discardModifs if True and the mesh has been edited since
1390 # a last total re-compute and that may prevent successful partial re-compute,
1391 # then the mesh is cleaned before Compute()
1392 # @return True or False
1393 # @ingroup l2_construct
1394 def Compute(self, geom=0, discardModifs=False):
1395 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1397 geom = self.mesh.GetShapeToMesh()
1402 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1404 ok = self.smeshpyD.Compute(self.mesh, geom)
1405 except SALOME.SALOME_Exception, ex:
1406 print "Mesh computation failed, exception caught:"
1407 print " ", ex.details.text
1410 print "Mesh computation failed, exception caught:"
1411 traceback.print_exc()
1415 # Treat compute errors
1416 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1417 for err in computeErrors:
1419 if self.mesh.HasShapeToMesh():
1421 mainIOR = salome.orb.object_to_string(geom)
1422 for sname in salome.myStudyManager.GetOpenStudies():
1423 s = salome.myStudyManager.GetStudyByName(sname)
1425 mainSO = s.FindObjectIOR(mainIOR)
1426 if not mainSO: continue
1427 if err.subShapeID == 1:
1428 shapeText = ' on "%s"' % mainSO.GetName()
1429 subIt = s.NewChildIterator(mainSO)
1431 subSO = subIt.Value()
1433 obj = subSO.GetObject()
1434 if not obj: continue
1435 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1437 ids = go.GetSubShapeIndices()
1438 if len(ids) == 1 and ids[0] == err.subShapeID:
1439 shapeText = ' on "%s"' % subSO.GetName()
1442 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1444 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1446 shapeText = " on subshape #%s" % (err.subShapeID)
1448 shapeText = " on subshape #%s" % (err.subShapeID)
1450 stdErrors = ["OK", #COMPERR_OK
1451 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1452 "std::exception", #COMPERR_STD_EXCEPTION
1453 "OCC exception", #COMPERR_OCC_EXCEPTION
1454 "SALOME exception", #COMPERR_SLM_EXCEPTION
1455 "Unknown exception", #COMPERR_EXCEPTION
1456 "Memory allocation problem", #COMPERR_MEMORY_PB
1457 "Algorithm failed", #COMPERR_ALGO_FAILED
1458 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1460 if err.code < len(stdErrors): errText = stdErrors[err.code]
1462 errText = "code %s" % -err.code
1463 if errText: errText += ". "
1464 errText += err.comment
1465 if allReasons != "":allReasons += "\n"
1466 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1470 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1472 if err.isGlobalAlgo:
1480 reason = '%s %sD algorithm is missing' % (glob, dim)
1481 elif err.state == HYP_MISSING:
1482 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1483 % (glob, dim, name, dim))
1484 elif err.state == HYP_NOTCONFORM:
1485 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1486 elif err.state == HYP_BAD_PARAMETER:
1487 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1488 % ( glob, dim, name ))
1489 elif err.state == HYP_BAD_GEOMETRY:
1490 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1491 'geometry' % ( glob, dim, name ))
1493 reason = "For unknown reason."+\
1494 " Revise Mesh.Compute() implementation in smeshDC.py!"
1496 if allReasons != "":allReasons += "\n"
1497 allReasons += reason
1499 if allReasons != "":
1500 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1504 print '"' + GetName(self.mesh) + '"',"has not been computed."
1507 if salome.sg.hasDesktop():
1508 smeshgui = salome.ImportComponentGUI("SMESH")
1509 smeshgui.Init(self.mesh.GetStudyId())
1510 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1511 salome.sg.updateObjBrowser(1)
1515 ## Return submesh objects list in meshing order
1516 # @return list of list of submesh objects
1517 # @ingroup l2_construct
1518 def GetMeshOrder(self):
1519 return self.mesh.GetMeshOrder()
1521 ## Return submesh objects list in meshing order
1522 # @return list of list of submesh objects
1523 # @ingroup l2_construct
1524 def SetMeshOrder(self, submeshes):
1525 return self.mesh.SetMeshOrder(submeshes)
1527 ## Removes all nodes and elements
1528 # @ingroup l2_construct
1531 if salome.sg.hasDesktop():
1532 smeshgui = salome.ImportComponentGUI("SMESH")
1533 smeshgui.Init(self.mesh.GetStudyId())
1534 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1535 salome.sg.updateObjBrowser(1)
1537 ## Removes all nodes and elements of indicated shape
1538 # @ingroup l2_construct
1539 def ClearSubMesh(self, geomId):
1540 self.mesh.ClearSubMesh(geomId)
1541 if salome.sg.hasDesktop():
1542 smeshgui = salome.ImportComponentGUI("SMESH")
1543 smeshgui.Init(self.mesh.GetStudyId())
1544 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1545 salome.sg.updateObjBrowser(1)
1547 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1548 # @param fineness [0,-1] defines mesh fineness
1549 # @return True or False
1550 # @ingroup l3_algos_basic
1551 def AutomaticTetrahedralization(self, fineness=0):
1552 dim = self.MeshDimension()
1554 self.RemoveGlobalHypotheses()
1555 self.Segment().AutomaticLength(fineness)
1557 self.Triangle().LengthFromEdges()
1560 self.Tetrahedron(NETGEN)
1562 return self.Compute()
1564 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1565 # @param fineness [0,-1] defines mesh fineness
1566 # @return True or False
1567 # @ingroup l3_algos_basic
1568 def AutomaticHexahedralization(self, fineness=0):
1569 dim = self.MeshDimension()
1570 # assign the hypotheses
1571 self.RemoveGlobalHypotheses()
1572 self.Segment().AutomaticLength(fineness)
1579 return self.Compute()
1581 ## Assigns a hypothesis
1582 # @param hyp a hypothesis to assign
1583 # @param geom a subhape of mesh geometry
1584 # @return SMESH.Hypothesis_Status
1585 # @ingroup l2_hypotheses
1586 def AddHypothesis(self, hyp, geom=0):
1587 if isinstance( hyp, Mesh_Algorithm ):
1588 hyp = hyp.GetAlgorithm()
1593 geom = self.mesh.GetShapeToMesh()
1595 status = self.mesh.AddHypothesis(geom, hyp)
1596 isAlgo = hyp._narrow( SMESH_Algo )
1597 hyp_name = GetName( hyp )
1600 geom_name = GetName( geom )
1601 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1604 ## Unassigns a hypothesis
1605 # @param hyp a hypothesis to unassign
1606 # @param geom a subshape of mesh geometry
1607 # @return SMESH.Hypothesis_Status
1608 # @ingroup l2_hypotheses
1609 def RemoveHypothesis(self, hyp, geom=0):
1610 if isinstance( hyp, Mesh_Algorithm ):
1611 hyp = hyp.GetAlgorithm()
1616 status = self.mesh.RemoveHypothesis(geom, hyp)
1619 ## Gets the list of hypotheses added on a geometry
1620 # @param geom a subshape of mesh geometry
1621 # @return the sequence of SMESH_Hypothesis
1622 # @ingroup l2_hypotheses
1623 def GetHypothesisList(self, geom):
1624 return self.mesh.GetHypothesisList( geom )
1626 ## Removes all global hypotheses
1627 # @ingroup l2_hypotheses
1628 def RemoveGlobalHypotheses(self):
1629 current_hyps = self.mesh.GetHypothesisList( self.geom )
1630 for hyp in current_hyps:
1631 self.mesh.RemoveHypothesis( self.geom, hyp )
1635 ## Creates a mesh group based on the geometric object \a grp
1636 # and gives a \a name, \n if this parameter is not defined
1637 # the name is the same as the geometric group name \n
1638 # Note: Works like GroupOnGeom().
1639 # @param grp a geometric group, a vertex, an edge, a face or a solid
1640 # @param name the name of the mesh group
1641 # @return SMESH_GroupOnGeom
1642 # @ingroup l2_grps_create
1643 def Group(self, grp, name=""):
1644 return self.GroupOnGeom(grp, name)
1646 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1647 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1648 ## allowing to overwrite the file if it exists or add the exported data to its contents
1649 # @param f the file name
1650 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1651 # @param opt boolean parameter for creating/not creating
1652 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1653 # @param overwrite boolean parameter for overwriting/not overwriting the file
1654 # @ingroup l2_impexp
1655 def ExportToMED(self, f, version, opt=0, overwrite=1):
1656 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1658 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1659 ## allowing to overwrite the file if it exists or add the exported data to its contents
1660 # @param f is the file name
1661 # @param auto_groups boolean parameter for creating/not creating
1662 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1663 # the typical use is auto_groups=false.
1664 # @param version MED format version(MED_V2_1 or MED_V2_2)
1665 # @param overwrite boolean parameter for overwriting/not overwriting the file
1666 # @ingroup l2_impexp
1667 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1668 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1670 ## Exports the mesh in a file in DAT format
1671 # @param f the file name
1672 # @ingroup l2_impexp
1673 def ExportDAT(self, f):
1674 self.mesh.ExportDAT(f)
1676 ## Exports the mesh in a file in UNV format
1677 # @param f the file name
1678 # @ingroup l2_impexp
1679 def ExportUNV(self, f):
1680 self.mesh.ExportUNV(f)
1682 ## Export the mesh in a file in STL format
1683 # @param f the file name
1684 # @param ascii defines the file encoding
1685 # @ingroup l2_impexp
1686 def ExportSTL(self, f, ascii=1):
1687 self.mesh.ExportSTL(f, ascii)
1690 # Operations with groups:
1691 # ----------------------
1693 ## Creates an empty mesh group
1694 # @param elementType the type of elements in the group
1695 # @param name the name of the mesh group
1696 # @return SMESH_Group
1697 # @ingroup l2_grps_create
1698 def CreateEmptyGroup(self, elementType, name):
1699 return self.mesh.CreateGroup(elementType, name)
1701 ## Creates a mesh group based on the geometrical object \a grp
1702 # and gives a \a name, \n if this parameter is not defined
1703 # the name is the same as the geometrical group name
1704 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1705 # @param name the name of the mesh group
1706 # @param typ the type of elements in the group. If not set, it is
1707 # automatically detected by the type of the geometry
1708 # @return SMESH_GroupOnGeom
1709 # @ingroup l2_grps_create
1710 def GroupOnGeom(self, grp, name="", typ=None):
1712 name = grp.GetName()
1715 tgeo = str(grp.GetShapeType())
1716 if tgeo == "VERTEX":
1718 elif tgeo == "EDGE":
1720 elif tgeo == "FACE":
1722 elif tgeo == "SOLID":
1724 elif tgeo == "SHELL":
1726 elif tgeo == "COMPOUND":
1727 try: # it raises on a compound of compounds
1728 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1729 print "Mesh.Group: empty geometric group", GetName( grp )
1734 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1736 tgeo = self.geompyD.GetType(grp)
1737 if tgeo == geompyDC.ShapeType["VERTEX"]:
1739 elif tgeo == geompyDC.ShapeType["EDGE"]:
1741 elif tgeo == geompyDC.ShapeType["FACE"]:
1743 elif tgeo == geompyDC.ShapeType["SOLID"]:
1749 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1750 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1751 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1759 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1762 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1764 ## Creates a mesh group by the given ids of elements
1765 # @param groupName the name of the mesh group
1766 # @param elementType the type of elements in the group
1767 # @param elemIDs the list of ids
1768 # @return SMESH_Group
1769 # @ingroup l2_grps_create
1770 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1771 group = self.mesh.CreateGroup(elementType, groupName)
1775 ## Creates a mesh group by the given conditions
1776 # @param groupName the name of the mesh group
1777 # @param elementType the type of elements in the group
1778 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1779 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1780 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1781 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1782 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1783 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1784 # @return SMESH_Group
1785 # @ingroup l2_grps_create
1789 CritType=FT_Undefined,
1792 UnaryOp=FT_Undefined,
1794 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1795 group = self.MakeGroupByCriterion(groupName, aCriterion)
1798 ## Creates a mesh group by the given criterion
1799 # @param groupName the name of the mesh group
1800 # @param Criterion the instance of Criterion class
1801 # @return SMESH_Group
1802 # @ingroup l2_grps_create
1803 def MakeGroupByCriterion(self, groupName, Criterion):
1804 aFilterMgr = self.smeshpyD.CreateFilterManager()
1805 aFilter = aFilterMgr.CreateFilter()
1807 aCriteria.append(Criterion)
1808 aFilter.SetCriteria(aCriteria)
1809 group = self.MakeGroupByFilter(groupName, aFilter)
1810 aFilterMgr.UnRegister()
1813 ## Creates a mesh group by the given criteria (list of criteria)
1814 # @param groupName the name of the mesh group
1815 # @param theCriteria the list of criteria
1816 # @return SMESH_Group
1817 # @ingroup l2_grps_create
1818 def MakeGroupByCriteria(self, groupName, theCriteria):
1819 aFilterMgr = self.smeshpyD.CreateFilterManager()
1820 aFilter = aFilterMgr.CreateFilter()
1821 aFilter.SetCriteria(theCriteria)
1822 group = self.MakeGroupByFilter(groupName, aFilter)
1823 aFilterMgr.UnRegister()
1826 ## Creates a mesh group by the given filter
1827 # @param groupName the name of the mesh group
1828 # @param theFilter the instance of Filter class
1829 # @return SMESH_Group
1830 # @ingroup l2_grps_create
1831 def MakeGroupByFilter(self, groupName, theFilter):
1832 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1833 theFilter.SetMesh( self.mesh )
1834 group.AddFrom( theFilter )
1837 ## Passes mesh elements through the given filter and return IDs of fitting elements
1838 # @param theFilter SMESH_Filter
1839 # @return a list of ids
1840 # @ingroup l1_controls
1841 def GetIdsFromFilter(self, theFilter):
1842 theFilter.SetMesh( self.mesh )
1843 return theFilter.GetIDs()
1845 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1846 # Returns a list of special structures (borders).
1847 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1848 # @ingroup l1_controls
1849 def GetFreeBorders(self):
1850 aFilterMgr = self.smeshpyD.CreateFilterManager()
1851 aPredicate = aFilterMgr.CreateFreeEdges()
1852 aPredicate.SetMesh(self.mesh)
1853 aBorders = aPredicate.GetBorders()
1854 aFilterMgr.UnRegister()
1858 # @ingroup l2_grps_delete
1859 def RemoveGroup(self, group):
1860 self.mesh.RemoveGroup(group)
1862 ## Removes a group with its contents
1863 # @ingroup l2_grps_delete
1864 def RemoveGroupWithContents(self, group):
1865 self.mesh.RemoveGroupWithContents(group)
1867 ## Gets the list of groups existing in the mesh
1868 # @return a sequence of SMESH_GroupBase
1869 # @ingroup l2_grps_create
1870 def GetGroups(self):
1871 return self.mesh.GetGroups()
1873 ## Gets the number of groups existing in the mesh
1874 # @return the quantity of groups as an integer value
1875 # @ingroup l2_grps_create
1877 return self.mesh.NbGroups()
1879 ## Gets the list of names of groups existing in the mesh
1880 # @return list of strings
1881 # @ingroup l2_grps_create
1882 def GetGroupNames(self):
1883 groups = self.GetGroups()
1885 for group in groups:
1886 names.append(group.GetName())
1889 ## Produces a union of two groups
1890 # A new group is created. All mesh elements that are
1891 # present in the initial groups are added to the new one
1892 # @return an instance of SMESH_Group
1893 # @ingroup l2_grps_operon
1894 def UnionGroups(self, group1, group2, name):
1895 return self.mesh.UnionGroups(group1, group2, name)
1897 ## Produces a union list of groups
1898 # New group is created. All mesh elements that are present in
1899 # initial groups are added to the new one
1900 # @return an instance of SMESH_Group
1901 # @ingroup l2_grps_operon
1902 def UnionListOfGroups(self, groups, name):
1903 return self.mesh.UnionListOfGroups(groups, name)
1905 ## Prodices an intersection of two groups
1906 # A new group is created. All mesh elements that are common
1907 # for the two initial groups are added to the new one.
1908 # @return an instance of SMESH_Group
1909 # @ingroup l2_grps_operon
1910 def IntersectGroups(self, group1, group2, name):
1911 return self.mesh.IntersectGroups(group1, group2, name)
1913 ## Produces an intersection of groups
1914 # New group is created. All mesh elements that are present in all
1915 # initial groups simultaneously are added to the new one
1916 # @return an instance of SMESH_Group
1917 # @ingroup l2_grps_operon
1918 def IntersectListOfGroups(self, groups, name):
1919 return self.mesh.IntersectListOfGroups(groups, name)
1921 ## Produces a cut of two groups
1922 # A new group is created. All mesh elements that are present in
1923 # the main group but are not present in the tool group are added to the new one
1924 # @return an instance of SMESH_Group
1925 # @ingroup l2_grps_operon
1926 def CutGroups(self, main_group, tool_group, name):
1927 return self.mesh.CutGroups(main_group, tool_group, name)
1929 ## Produces a cut of groups
1930 # A new group is created. All mesh elements that are present in main groups
1931 # but do not present in tool groups are added to the new one
1932 # @return an instance of SMESH_Group
1933 # @ingroup l2_grps_operon
1934 def CutListOfGroups(self, main_groups, tool_groups, name):
1935 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1937 ## Produces a group of elements of specified type using list of existing groups
1938 # A new group is created. System
1939 # 1) extracts all nodes on which groups elements are built
1940 # 2) combines all elements of specified dimension laying on these nodes
1941 # @return an instance of SMESH_Group
1942 # @ingroup l2_grps_operon
1943 def CreateDimGroup(self, groups, elem_type, name):
1944 return self.mesh.CreateDimGroup(groups, elem_type, name)
1947 ## Convert group on geom into standalone group
1948 # @ingroup l2_grps_delete
1949 def ConvertToStandalone(self, group):
1950 return self.mesh.ConvertToStandalone(group)
1952 # Get some info about mesh:
1953 # ------------------------
1955 ## Returns the log of nodes and elements added or removed
1956 # since the previous clear of the log.
1957 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1958 # @return list of log_block structures:
1963 # @ingroup l1_auxiliary
1964 def GetLog(self, clearAfterGet):
1965 return self.mesh.GetLog(clearAfterGet)
1967 ## Clears the log of nodes and elements added or removed since the previous
1968 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1969 # @ingroup l1_auxiliary
1971 self.mesh.ClearLog()
1973 ## Toggles auto color mode on the object.
1974 # @param theAutoColor the flag which toggles auto color mode.
1975 # @ingroup l1_auxiliary
1976 def SetAutoColor(self, theAutoColor):
1977 self.mesh.SetAutoColor(theAutoColor)
1979 ## Gets flag of object auto color mode.
1980 # @return True or False
1981 # @ingroup l1_auxiliary
1982 def GetAutoColor(self):
1983 return self.mesh.GetAutoColor()
1985 ## Gets the internal ID
1986 # @return integer value, which is the internal Id of the mesh
1987 # @ingroup l1_auxiliary
1989 return self.mesh.GetId()
1992 # @return integer value, which is the study Id of the mesh
1993 # @ingroup l1_auxiliary
1994 def GetStudyId(self):
1995 return self.mesh.GetStudyId()
1997 ## Checks the group names for duplications.
1998 # Consider the maximum group name length stored in MED file.
1999 # @return True or False
2000 # @ingroup l1_auxiliary
2001 def HasDuplicatedGroupNamesMED(self):
2002 return self.mesh.HasDuplicatedGroupNamesMED()
2004 ## Obtains the mesh editor tool
2005 # @return an instance of SMESH_MeshEditor
2006 # @ingroup l1_modifying
2007 def GetMeshEditor(self):
2008 return self.mesh.GetMeshEditor()
2010 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2011 # can be passed as argument to accepting mesh, group or sub-mesh
2012 # @return an instance of SMESH_IDSource
2013 # @ingroup l1_auxiliary
2014 def GetIDSource(self, ids, elemType):
2015 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2018 # @return an instance of SALOME_MED::MESH
2019 # @ingroup l1_auxiliary
2020 def GetMEDMesh(self):
2021 return self.mesh.GetMEDMesh()
2024 # Get informations about mesh contents:
2025 # ------------------------------------
2027 ## Gets the mesh stattistic
2028 # @return dictionary type element - count of elements
2029 # @ingroup l1_meshinfo
2030 def GetMeshInfo(self, obj = None):
2031 if not obj: obj = self.mesh
2032 return self.smeshpyD.GetMeshInfo(obj)
2034 ## Returns the number of nodes in the mesh
2035 # @return an integer value
2036 # @ingroup l1_meshinfo
2038 return self.mesh.NbNodes()
2040 ## Returns the number of elements in the mesh
2041 # @return an integer value
2042 # @ingroup l1_meshinfo
2043 def NbElements(self):
2044 return self.mesh.NbElements()
2046 ## Returns the number of 0d elements in the mesh
2047 # @return an integer value
2048 # @ingroup l1_meshinfo
2049 def Nb0DElements(self):
2050 return self.mesh.Nb0DElements()
2052 ## Returns the number of edges in the mesh
2053 # @return an integer value
2054 # @ingroup l1_meshinfo
2056 return self.mesh.NbEdges()
2058 ## Returns the number of edges with the given order in the mesh
2059 # @param elementOrder the order of elements:
2060 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2061 # @return an integer value
2062 # @ingroup l1_meshinfo
2063 def NbEdgesOfOrder(self, elementOrder):
2064 return self.mesh.NbEdgesOfOrder(elementOrder)
2066 ## Returns the number of faces in the mesh
2067 # @return an integer value
2068 # @ingroup l1_meshinfo
2070 return self.mesh.NbFaces()
2072 ## Returns the number of faces with the given order in the mesh
2073 # @param elementOrder the order of elements:
2074 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2075 # @return an integer value
2076 # @ingroup l1_meshinfo
2077 def NbFacesOfOrder(self, elementOrder):
2078 return self.mesh.NbFacesOfOrder(elementOrder)
2080 ## Returns the number of triangles in the mesh
2081 # @return an integer value
2082 # @ingroup l1_meshinfo
2083 def NbTriangles(self):
2084 return self.mesh.NbTriangles()
2086 ## Returns the number of triangles with the given order in the mesh
2087 # @param elementOrder is the order of elements:
2088 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2089 # @return an integer value
2090 # @ingroup l1_meshinfo
2091 def NbTrianglesOfOrder(self, elementOrder):
2092 return self.mesh.NbTrianglesOfOrder(elementOrder)
2094 ## Returns the number of quadrangles in the mesh
2095 # @return an integer value
2096 # @ingroup l1_meshinfo
2097 def NbQuadrangles(self):
2098 return self.mesh.NbQuadrangles()
2100 ## Returns the number of quadrangles with the given order in the mesh
2101 # @param elementOrder the order of elements:
2102 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2103 # @return an integer value
2104 # @ingroup l1_meshinfo
2105 def NbQuadranglesOfOrder(self, elementOrder):
2106 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2108 ## Returns the number of polygons in the mesh
2109 # @return an integer value
2110 # @ingroup l1_meshinfo
2111 def NbPolygons(self):
2112 return self.mesh.NbPolygons()
2114 ## Returns the number of volumes in the mesh
2115 # @return an integer value
2116 # @ingroup l1_meshinfo
2117 def NbVolumes(self):
2118 return self.mesh.NbVolumes()
2120 ## Returns the number of volumes with the given order in the mesh
2121 # @param elementOrder the order of elements:
2122 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2123 # @return an integer value
2124 # @ingroup l1_meshinfo
2125 def NbVolumesOfOrder(self, elementOrder):
2126 return self.mesh.NbVolumesOfOrder(elementOrder)
2128 ## Returns the number of tetrahedrons in the mesh
2129 # @return an integer value
2130 # @ingroup l1_meshinfo
2132 return self.mesh.NbTetras()
2134 ## Returns the number of tetrahedrons with the given order in the mesh
2135 # @param elementOrder the order of elements:
2136 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2137 # @return an integer value
2138 # @ingroup l1_meshinfo
2139 def NbTetrasOfOrder(self, elementOrder):
2140 return self.mesh.NbTetrasOfOrder(elementOrder)
2142 ## Returns the number of hexahedrons in the mesh
2143 # @return an integer value
2144 # @ingroup l1_meshinfo
2146 return self.mesh.NbHexas()
2148 ## Returns the number of hexahedrons with the given order in the mesh
2149 # @param elementOrder the order of elements:
2150 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2151 # @return an integer value
2152 # @ingroup l1_meshinfo
2153 def NbHexasOfOrder(self, elementOrder):
2154 return self.mesh.NbHexasOfOrder(elementOrder)
2156 ## Returns the number of pyramids in the mesh
2157 # @return an integer value
2158 # @ingroup l1_meshinfo
2159 def NbPyramids(self):
2160 return self.mesh.NbPyramids()
2162 ## Returns the number of pyramids with the given order in the mesh
2163 # @param elementOrder the order of elements:
2164 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2165 # @return an integer value
2166 # @ingroup l1_meshinfo
2167 def NbPyramidsOfOrder(self, elementOrder):
2168 return self.mesh.NbPyramidsOfOrder(elementOrder)
2170 ## Returns the number of prisms in the mesh
2171 # @return an integer value
2172 # @ingroup l1_meshinfo
2174 return self.mesh.NbPrisms()
2176 ## Returns the number of prisms with the given order in the mesh
2177 # @param elementOrder the order of elements:
2178 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2179 # @return an integer value
2180 # @ingroup l1_meshinfo
2181 def NbPrismsOfOrder(self, elementOrder):
2182 return self.mesh.NbPrismsOfOrder(elementOrder)
2184 ## Returns the number of polyhedrons in the mesh
2185 # @return an integer value
2186 # @ingroup l1_meshinfo
2187 def NbPolyhedrons(self):
2188 return self.mesh.NbPolyhedrons()
2190 ## Returns the number of submeshes in the mesh
2191 # @return an integer value
2192 # @ingroup l1_meshinfo
2193 def NbSubMesh(self):
2194 return self.mesh.NbSubMesh()
2196 ## Returns the list of mesh elements IDs
2197 # @return the list of integer values
2198 # @ingroup l1_meshinfo
2199 def GetElementsId(self):
2200 return self.mesh.GetElementsId()
2202 ## Returns the list of IDs of mesh elements with the given type
2203 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2204 # @return list of integer values
2205 # @ingroup l1_meshinfo
2206 def GetElementsByType(self, elementType):
2207 return self.mesh.GetElementsByType(elementType)
2209 ## Returns the list of mesh nodes IDs
2210 # @return the list of integer values
2211 # @ingroup l1_meshinfo
2212 def GetNodesId(self):
2213 return self.mesh.GetNodesId()
2215 # Get the information about mesh elements:
2216 # ------------------------------------
2218 ## Returns the type of mesh element
2219 # @return the value from SMESH::ElementType enumeration
2220 # @ingroup l1_meshinfo
2221 def GetElementType(self, id, iselem):
2222 return self.mesh.GetElementType(id, iselem)
2224 ## Returns the geometric type of mesh element
2225 # @return the value from SMESH::EntityType enumeration
2226 # @ingroup l1_meshinfo
2227 def GetElementGeomType(self, id):
2228 return self.mesh.GetElementGeomType(id)
2230 ## Returns the list of submesh elements IDs
2231 # @param Shape a geom object(subshape) IOR
2232 # Shape must be the subshape of a ShapeToMesh()
2233 # @return the list of integer values
2234 # @ingroup l1_meshinfo
2235 def GetSubMeshElementsId(self, Shape):
2236 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2237 ShapeID = Shape.GetSubShapeIndices()[0]
2240 return self.mesh.GetSubMeshElementsId(ShapeID)
2242 ## Returns the list of submesh nodes IDs
2243 # @param Shape a geom object(subshape) IOR
2244 # Shape must be the subshape of a ShapeToMesh()
2245 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2246 # @return the list of integer values
2247 # @ingroup l1_meshinfo
2248 def GetSubMeshNodesId(self, Shape, all):
2249 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2250 ShapeID = Shape.GetSubShapeIndices()[0]
2253 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2255 ## Returns type of elements on given shape
2256 # @param Shape a geom object(subshape) IOR
2257 # Shape must be a subshape of a ShapeToMesh()
2258 # @return element type
2259 # @ingroup l1_meshinfo
2260 def GetSubMeshElementType(self, Shape):
2261 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2262 ShapeID = Shape.GetSubShapeIndices()[0]
2265 return self.mesh.GetSubMeshElementType(ShapeID)
2267 ## Gets the mesh description
2268 # @return string value
2269 # @ingroup l1_meshinfo
2271 return self.mesh.Dump()
2274 # Get the information about nodes and elements of a mesh by its IDs:
2275 # -----------------------------------------------------------
2277 ## Gets XYZ coordinates of a node
2278 # \n If there is no nodes for the given ID - returns an empty list
2279 # @return a list of double precision values
2280 # @ingroup l1_meshinfo
2281 def GetNodeXYZ(self, id):
2282 return self.mesh.GetNodeXYZ(id)
2284 ## Returns list of IDs of inverse elements for the given node
2285 # \n If there is no node for the given ID - returns an empty list
2286 # @return a list of integer values
2287 # @ingroup l1_meshinfo
2288 def GetNodeInverseElements(self, id):
2289 return self.mesh.GetNodeInverseElements(id)
2291 ## @brief Returns the position of a node on the shape
2292 # @return SMESH::NodePosition
2293 # @ingroup l1_meshinfo
2294 def GetNodePosition(self,NodeID):
2295 return self.mesh.GetNodePosition(NodeID)
2297 ## If the given element is a node, returns the ID of shape
2298 # \n If there is no node for the given ID - returns -1
2299 # @return an integer value
2300 # @ingroup l1_meshinfo
2301 def GetShapeID(self, id):
2302 return self.mesh.GetShapeID(id)
2304 ## Returns the ID of the result shape after
2305 # FindShape() from SMESH_MeshEditor for the given element
2306 # \n If there is no element for the given ID - returns -1
2307 # @return an integer value
2308 # @ingroup l1_meshinfo
2309 def GetShapeIDForElem(self,id):
2310 return self.mesh.GetShapeIDForElem(id)
2312 ## Returns the number of nodes for the given element
2313 # \n If there is no element for the given ID - returns -1
2314 # @return an integer value
2315 # @ingroup l1_meshinfo
2316 def GetElemNbNodes(self, id):
2317 return self.mesh.GetElemNbNodes(id)
2319 ## Returns the node ID the given index for the given element
2320 # \n If there is no element for the given ID - returns -1
2321 # \n If there is no node for the given index - returns -2
2322 # @return an integer value
2323 # @ingroup l1_meshinfo
2324 def GetElemNode(self, id, index):
2325 return self.mesh.GetElemNode(id, index)
2327 ## Returns the IDs of nodes of the given element
2328 # @return a list of integer values
2329 # @ingroup l1_meshinfo
2330 def GetElemNodes(self, id):
2331 return self.mesh.GetElemNodes(id)
2333 ## Returns true if the given node is the medium node in the given quadratic element
2334 # @ingroup l1_meshinfo
2335 def IsMediumNode(self, elementID, nodeID):
2336 return self.mesh.IsMediumNode(elementID, nodeID)
2338 ## Returns true if the given node is the medium node in one of quadratic elements
2339 # @ingroup l1_meshinfo
2340 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2341 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2343 ## Returns the number of edges for the given element
2344 # @ingroup l1_meshinfo
2345 def ElemNbEdges(self, id):
2346 return self.mesh.ElemNbEdges(id)
2348 ## Returns the number of faces for the given element
2349 # @ingroup l1_meshinfo
2350 def ElemNbFaces(self, id):
2351 return self.mesh.ElemNbFaces(id)
2353 ## Returns nodes of given face (counted from zero) for given volumic element.
2354 # @ingroup l1_meshinfo
2355 def GetElemFaceNodes(self,elemId, faceIndex):
2356 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2358 ## Returns an element based on all given nodes.
2359 # @ingroup l1_meshinfo
2360 def FindElementByNodes(self,nodes):
2361 return self.mesh.FindElementByNodes(nodes)
2363 ## Returns true if the given element is a polygon
2364 # @ingroup l1_meshinfo
2365 def IsPoly(self, id):
2366 return self.mesh.IsPoly(id)
2368 ## Returns true if the given element is quadratic
2369 # @ingroup l1_meshinfo
2370 def IsQuadratic(self, id):
2371 return self.mesh.IsQuadratic(id)
2373 ## Returns XYZ coordinates of the barycenter of the given element
2374 # \n If there is no element for the given ID - returns an empty list
2375 # @return a list of three double values
2376 # @ingroup l1_meshinfo
2377 def BaryCenter(self, id):
2378 return self.mesh.BaryCenter(id)
2381 # Get mesh measurements information:
2382 # ------------------------------------
2384 ## Get minimum distance between two nodes, elements or distance to the origin
2385 # @param id1 first node/element id
2386 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2387 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2388 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2389 # @return minimum distance value
2390 # @sa GetMinDistance()
2391 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2392 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2393 return aMeasure.value
2395 ## Get measure structure specifying minimum distance data between two objects
2396 # @param id1 first node/element id
2397 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2398 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2399 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2400 # @return Measure structure
2402 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2404 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2406 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2409 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2411 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2416 aMeasurements = self.smeshpyD.CreateMeasurements()
2417 aMeasure = aMeasurements.MinDistance(id1, id2)
2418 aMeasurements.UnRegister()
2421 ## Get bounding box of the specified object(s)
2422 # @param objects single source object or list of source objects or list of nodes/elements IDs
2423 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2424 # @c False specifies that @a objects are nodes
2425 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2426 # @sa GetBoundingBox()
2427 def BoundingBox(self, objects=None, isElem=False):
2428 result = self.GetBoundingBox(objects, isElem)
2432 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2435 ## Get measure structure specifying bounding box data of the specified object(s)
2436 # @param objects single source object or list of source objects or list of nodes/elements IDs
2437 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2438 # @c False specifies that @a objects are nodes
2439 # @return Measure structure
2441 def GetBoundingBox(self, IDs=None, isElem=False):
2444 elif isinstance(IDs, tuple):
2446 if not isinstance(IDs, list):
2448 if len(IDs) > 0 and isinstance(IDs[0], int):
2452 if isinstance(o, Mesh):
2453 srclist.append(o.mesh)
2454 elif hasattr(o, "_narrow"):
2455 src = o._narrow(SMESH.SMESH_IDSource)
2456 if src: srclist.append(src)
2458 elif isinstance(o, list):
2460 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2462 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2465 aMeasurements = self.smeshpyD.CreateMeasurements()
2466 aMeasure = aMeasurements.BoundingBox(srclist)
2467 aMeasurements.UnRegister()
2470 # Mesh edition (SMESH_MeshEditor functionality):
2471 # ---------------------------------------------
2473 ## Removes the elements from the mesh by ids
2474 # @param IDsOfElements is a list of ids of elements to remove
2475 # @return True or False
2476 # @ingroup l2_modif_del
2477 def RemoveElements(self, IDsOfElements):
2478 return self.editor.RemoveElements(IDsOfElements)
2480 ## Removes nodes from mesh by ids
2481 # @param IDsOfNodes is a list of ids of nodes to remove
2482 # @return True or False
2483 # @ingroup l2_modif_del
2484 def RemoveNodes(self, IDsOfNodes):
2485 return self.editor.RemoveNodes(IDsOfNodes)
2487 ## Removes all orphan (free) nodes from mesh
2488 # @return number of the removed nodes
2489 # @ingroup l2_modif_del
2490 def RemoveOrphanNodes(self):
2491 return self.editor.RemoveOrphanNodes()
2493 ## Add a node to the mesh by coordinates
2494 # @return Id of the new node
2495 # @ingroup l2_modif_add
2496 def AddNode(self, x, y, z):
2497 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2498 self.mesh.SetParameters(Parameters)
2499 return self.editor.AddNode( x, y, z)
2501 ## Creates a 0D element on a node with given number.
2502 # @param IDOfNode the ID of node for creation of the element.
2503 # @return the Id of the new 0D element
2504 # @ingroup l2_modif_add
2505 def Add0DElement(self, IDOfNode):
2506 return self.editor.Add0DElement(IDOfNode)
2508 ## Creates a linear or quadratic edge (this is determined
2509 # by the number of given nodes).
2510 # @param IDsOfNodes the list of node IDs for creation of the element.
2511 # The order of nodes in this list should correspond to the description
2512 # of MED. \n This description is located by the following link:
2513 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2514 # @return the Id of the new edge
2515 # @ingroup l2_modif_add
2516 def AddEdge(self, IDsOfNodes):
2517 return self.editor.AddEdge(IDsOfNodes)
2519 ## Creates a linear or quadratic face (this is determined
2520 # by the number of given nodes).
2521 # @param IDsOfNodes the list of node IDs for creation of the element.
2522 # The order of nodes in this list should correspond to the description
2523 # of MED. \n This description is located by the following link:
2524 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2525 # @return the Id of the new face
2526 # @ingroup l2_modif_add
2527 def AddFace(self, IDsOfNodes):
2528 return self.editor.AddFace(IDsOfNodes)
2530 ## Adds a polygonal face to the mesh by the list of node IDs
2531 # @param IdsOfNodes the list of node IDs for creation of the element.
2532 # @return the Id of the new face
2533 # @ingroup l2_modif_add
2534 def AddPolygonalFace(self, IdsOfNodes):
2535 return self.editor.AddPolygonalFace(IdsOfNodes)
2537 ## Creates both simple and quadratic volume (this is determined
2538 # by the number of given nodes).
2539 # @param IDsOfNodes the list of node IDs for creation of the element.
2540 # The order of nodes in this list should correspond to the description
2541 # of MED. \n This description is located by the following link:
2542 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2543 # @return the Id of the new volumic element
2544 # @ingroup l2_modif_add
2545 def AddVolume(self, IDsOfNodes):
2546 return self.editor.AddVolume(IDsOfNodes)
2548 ## Creates a volume of many faces, giving nodes for each face.
2549 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2550 # @param Quantities the list of integer values, Quantities[i]
2551 # gives the quantity of nodes in face number i.
2552 # @return the Id of the new volumic element
2553 # @ingroup l2_modif_add
2554 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2555 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2557 ## Creates a volume of many faces, giving the IDs of the existing faces.
2558 # @param IdsOfFaces the list of face IDs for volume creation.
2560 # Note: The created volume will refer only to the nodes
2561 # of the given faces, not to the faces themselves.
2562 # @return the Id of the new volumic element
2563 # @ingroup l2_modif_add
2564 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2565 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2568 ## @brief Binds a node to a vertex
2569 # @param NodeID a node ID
2570 # @param Vertex a vertex or vertex ID
2571 # @return True if succeed else raises an exception
2572 # @ingroup l2_modif_add
2573 def SetNodeOnVertex(self, NodeID, Vertex):
2574 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2575 VertexID = Vertex.GetSubShapeIndices()[0]
2579 self.editor.SetNodeOnVertex(NodeID, VertexID)
2580 except SALOME.SALOME_Exception, inst:
2581 raise ValueError, inst.details.text
2585 ## @brief Stores the node position on an edge
2586 # @param NodeID a node ID
2587 # @param Edge an edge or edge ID
2588 # @param paramOnEdge a parameter on the edge where the node is located
2589 # @return True if succeed else raises an exception
2590 # @ingroup l2_modif_add
2591 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2592 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2593 EdgeID = Edge.GetSubShapeIndices()[0]
2597 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2598 except SALOME.SALOME_Exception, inst:
2599 raise ValueError, inst.details.text
2602 ## @brief Stores node position on a face
2603 # @param NodeID a node ID
2604 # @param Face a face or face ID
2605 # @param u U parameter on the face where the node is located
2606 # @param v V parameter on the face where the node is located
2607 # @return True if succeed else raises an exception
2608 # @ingroup l2_modif_add
2609 def SetNodeOnFace(self, NodeID, Face, u, v):
2610 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2611 FaceID = Face.GetSubShapeIndices()[0]
2615 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2616 except SALOME.SALOME_Exception, inst:
2617 raise ValueError, inst.details.text
2620 ## @brief Binds a node to a solid
2621 # @param NodeID a node ID
2622 # @param Solid a solid or solid ID
2623 # @return True if succeed else raises an exception
2624 # @ingroup l2_modif_add
2625 def SetNodeInVolume(self, NodeID, Solid):
2626 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2627 SolidID = Solid.GetSubShapeIndices()[0]
2631 self.editor.SetNodeInVolume(NodeID, SolidID)
2632 except SALOME.SALOME_Exception, inst:
2633 raise ValueError, inst.details.text
2636 ## @brief Bind an element to a shape
2637 # @param ElementID an element ID
2638 # @param Shape a shape or shape ID
2639 # @return True if succeed else raises an exception
2640 # @ingroup l2_modif_add
2641 def SetMeshElementOnShape(self, ElementID, Shape):
2642 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2643 ShapeID = Shape.GetSubShapeIndices()[0]
2647 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2648 except SALOME.SALOME_Exception, inst:
2649 raise ValueError, inst.details.text
2653 ## Moves the node with the given id
2654 # @param NodeID the id of the node
2655 # @param x a new X coordinate
2656 # @param y a new Y coordinate
2657 # @param z a new Z coordinate
2658 # @return True if succeed else False
2659 # @ingroup l2_modif_movenode
2660 def MoveNode(self, NodeID, x, y, z):
2661 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2662 self.mesh.SetParameters(Parameters)
2663 return self.editor.MoveNode(NodeID, x, y, z)
2665 ## Finds the node closest to a point and moves it to a point location
2666 # @param x the X coordinate of a point
2667 # @param y the Y coordinate of a point
2668 # @param z the Z coordinate of a point
2669 # @param NodeID if specified (>0), the node with this ID is moved,
2670 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2671 # @return the ID of a node
2672 # @ingroup l2_modif_throughp
2673 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2674 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2675 self.mesh.SetParameters(Parameters)
2676 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2678 ## Finds the node closest to a point
2679 # @param x the X coordinate of a point
2680 # @param y the Y coordinate of a point
2681 # @param z the Z coordinate of a point
2682 # @return the ID of a node
2683 # @ingroup l2_modif_throughp
2684 def FindNodeClosestTo(self, x, y, z):
2685 #preview = self.mesh.GetMeshEditPreviewer()
2686 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2687 return self.editor.FindNodeClosestTo(x, y, z)
2689 ## Finds the elements where a point lays IN or ON
2690 # @param x the X coordinate of a point
2691 # @param y the Y coordinate of a point
2692 # @param z the Z coordinate of a point
2693 # @param elementType type of elements to find (SMESH.ALL type
2694 # means elements of any type excluding nodes and 0D elements)
2695 # @return list of IDs of found elements
2696 # @ingroup l2_modif_throughp
2697 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2698 return self.editor.FindElementsByPoint(x, y, z, elementType)
2700 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2701 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2703 def GetPointState(self, x, y, z):
2704 return self.editor.GetPointState(x, y, z)
2706 ## Finds the node closest to a point and moves it to a point location
2707 # @param x the X coordinate of a point
2708 # @param y the Y coordinate of a point
2709 # @param z the Z coordinate of a point
2710 # @return the ID of a moved node
2711 # @ingroup l2_modif_throughp
2712 def MeshToPassThroughAPoint(self, x, y, z):
2713 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2715 ## Replaces two neighbour triangles sharing Node1-Node2 link
2716 # with the triangles built on the same 4 nodes but having other common link.
2717 # @param NodeID1 the ID of the first node
2718 # @param NodeID2 the ID of the second node
2719 # @return false if proper faces were not found
2720 # @ingroup l2_modif_invdiag
2721 def InverseDiag(self, NodeID1, NodeID2):
2722 return self.editor.InverseDiag(NodeID1, NodeID2)
2724 ## Replaces two neighbour triangles sharing Node1-Node2 link
2725 # with a quadrangle built on the same 4 nodes.
2726 # @param NodeID1 the ID of the first node
2727 # @param NodeID2 the ID of the second node
2728 # @return false if proper faces were not found
2729 # @ingroup l2_modif_unitetri
2730 def DeleteDiag(self, NodeID1, NodeID2):
2731 return self.editor.DeleteDiag(NodeID1, NodeID2)
2733 ## Reorients elements by ids
2734 # @param IDsOfElements if undefined reorients all mesh elements
2735 # @return True if succeed else False
2736 # @ingroup l2_modif_changori
2737 def Reorient(self, IDsOfElements=None):
2738 if IDsOfElements == None:
2739 IDsOfElements = self.GetElementsId()
2740 return self.editor.Reorient(IDsOfElements)
2742 ## Reorients all elements of the object
2743 # @param theObject mesh, submesh or group
2744 # @return True if succeed else False
2745 # @ingroup l2_modif_changori
2746 def ReorientObject(self, theObject):
2747 if ( isinstance( theObject, Mesh )):
2748 theObject = theObject.GetMesh()
2749 return self.editor.ReorientObject(theObject)
2751 ## Fuses the neighbouring triangles into quadrangles.
2752 # @param IDsOfElements The triangles to be fused,
2753 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2754 # @param MaxAngle is the maximum angle between element normals at which the fusion
2755 # is still performed; theMaxAngle is mesured in radians.
2756 # Also it could be a name of variable which defines angle in degrees.
2757 # @return TRUE in case of success, FALSE otherwise.
2758 # @ingroup l2_modif_unitetri
2759 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2761 if isinstance(MaxAngle,str):
2763 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2765 MaxAngle = DegreesToRadians(MaxAngle)
2766 if IDsOfElements == []:
2767 IDsOfElements = self.GetElementsId()
2768 self.mesh.SetParameters(Parameters)
2770 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2771 Functor = theCriterion
2773 Functor = self.smeshpyD.GetFunctor(theCriterion)
2774 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2776 ## Fuses the neighbouring triangles of the object into quadrangles
2777 # @param theObject is mesh, submesh or group
2778 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2779 # @param MaxAngle a max angle between element normals at which the fusion
2780 # is still performed; theMaxAngle is mesured in radians.
2781 # @return TRUE in case of success, FALSE otherwise.
2782 # @ingroup l2_modif_unitetri
2783 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2784 if ( isinstance( theObject, Mesh )):
2785 theObject = theObject.GetMesh()
2786 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2788 ## Splits quadrangles into triangles.
2789 # @param IDsOfElements the faces to be splitted.
2790 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2791 # @return TRUE in case of success, FALSE otherwise.
2792 # @ingroup l2_modif_cutquadr
2793 def QuadToTri (self, IDsOfElements, theCriterion):
2794 if IDsOfElements == []:
2795 IDsOfElements = self.GetElementsId()
2796 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2798 ## Splits quadrangles into triangles.
2799 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2800 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2801 # @return TRUE in case of success, FALSE otherwise.
2802 # @ingroup l2_modif_cutquadr
2803 def QuadToTriObject (self, theObject, theCriterion):
2804 if ( isinstance( theObject, Mesh )):
2805 theObject = theObject.GetMesh()
2806 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2808 ## Splits quadrangles into triangles.
2809 # @param IDsOfElements the faces to be splitted
2810 # @param Diag13 is used to choose a diagonal for splitting.
2811 # @return TRUE in case of success, FALSE otherwise.
2812 # @ingroup l2_modif_cutquadr
2813 def SplitQuad (self, IDsOfElements, Diag13):
2814 if IDsOfElements == []:
2815 IDsOfElements = self.GetElementsId()
2816 return self.editor.SplitQuad(IDsOfElements, Diag13)
2818 ## Splits quadrangles into triangles.
2819 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2820 # @param Diag13 is used to choose a diagonal for splitting.
2821 # @return TRUE in case of success, FALSE otherwise.
2822 # @ingroup l2_modif_cutquadr
2823 def SplitQuadObject (self, theObject, Diag13):
2824 if ( isinstance( theObject, Mesh )):
2825 theObject = theObject.GetMesh()
2826 return self.editor.SplitQuadObject(theObject, Diag13)
2828 ## Finds a better splitting of the given quadrangle.
2829 # @param IDOfQuad the ID of the quadrangle to be splitted.
2830 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2831 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2832 # diagonal is better, 0 if error occurs.
2833 # @ingroup l2_modif_cutquadr
2834 def BestSplit (self, IDOfQuad, theCriterion):
2835 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2837 ## Splits volumic elements into tetrahedrons
2838 # @param elemIDs either list of elements or mesh or group or submesh
2839 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2840 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2841 # @ingroup l2_modif_cutquadr
2842 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2843 if isinstance( elemIDs, Mesh ):
2844 elemIDs = elemIDs.GetMesh()
2845 if ( isinstance( elemIDs, list )):
2846 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2847 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2849 ## Splits quadrangle faces near triangular facets of volumes
2851 # @ingroup l1_auxiliary
2852 def SplitQuadsNearTriangularFacets(self):
2853 faces_array = self.GetElementsByType(SMESH.FACE)
2854 for face_id in faces_array:
2855 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2856 quad_nodes = self.mesh.GetElemNodes(face_id)
2857 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2858 isVolumeFound = False
2859 for node1_elem in node1_elems:
2860 if not isVolumeFound:
2861 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2862 nb_nodes = self.GetElemNbNodes(node1_elem)
2863 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2864 volume_elem = node1_elem
2865 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2866 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2867 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2868 isVolumeFound = True
2869 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2870 self.SplitQuad([face_id], False) # diagonal 2-4
2871 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2872 isVolumeFound = True
2873 self.SplitQuad([face_id], True) # diagonal 1-3
2874 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2875 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2876 isVolumeFound = True
2877 self.SplitQuad([face_id], True) # diagonal 1-3
2879 ## @brief Splits hexahedrons into tetrahedrons.
2881 # This operation uses pattern mapping functionality for splitting.
2882 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2883 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2884 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2885 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2886 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2887 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2888 # @return TRUE in case of success, FALSE otherwise.
2889 # @ingroup l1_auxiliary
2890 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2891 # Pattern: 5.---------.6
2896 # (0,0,1) 4.---------.7 * |
2903 # (0,0,0) 0.---------.3
2904 pattern_tetra = "!!! Nb of points: \n 8 \n\
2914 !!! Indices of points of 6 tetras: \n\
2922 pattern = self.smeshpyD.GetPattern()
2923 isDone = pattern.LoadFromFile(pattern_tetra)
2925 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2928 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2929 isDone = pattern.MakeMesh(self.mesh, False, False)
2930 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2932 # split quafrangle faces near triangular facets of volumes
2933 self.SplitQuadsNearTriangularFacets()
2937 ## @brief Split hexahedrons into prisms.
2939 # Uses the pattern mapping functionality for splitting.
2940 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2941 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2942 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2943 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2944 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2945 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2946 # @return TRUE in case of success, FALSE otherwise.
2947 # @ingroup l1_auxiliary
2948 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2949 # Pattern: 5.---------.6
2954 # (0,0,1) 4.---------.7 |
2961 # (0,0,0) 0.---------.3
2962 pattern_prism = "!!! Nb of points: \n 8 \n\
2972 !!! Indices of points of 2 prisms: \n\
2976 pattern = self.smeshpyD.GetPattern()
2977 isDone = pattern.LoadFromFile(pattern_prism)
2979 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2982 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2983 isDone = pattern.MakeMesh(self.mesh, False, False)
2984 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2986 # Splits quafrangle faces near triangular facets of volumes
2987 self.SplitQuadsNearTriangularFacets()
2991 ## Smoothes elements
2992 # @param IDsOfElements the list if ids of elements to smooth
2993 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2994 # Note that nodes built on edges and boundary nodes are always fixed.
2995 # @param MaxNbOfIterations the maximum number of iterations
2996 # @param MaxAspectRatio varies in range [1.0, inf]
2997 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2998 # @return TRUE in case of success, FALSE otherwise.
2999 # @ingroup l2_modif_smooth
3000 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
3001 MaxNbOfIterations, MaxAspectRatio, Method):
3002 if IDsOfElements == []:
3003 IDsOfElements = self.GetElementsId()
3004 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3005 self.mesh.SetParameters(Parameters)
3006 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3007 MaxNbOfIterations, MaxAspectRatio, Method)
3009 ## Smoothes elements which belong to the given object
3010 # @param theObject the object to smooth
3011 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3012 # Note that nodes built on edges and boundary nodes are always fixed.
3013 # @param MaxNbOfIterations the maximum number of iterations
3014 # @param MaxAspectRatio varies in range [1.0, inf]
3015 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3016 # @return TRUE in case of success, FALSE otherwise.
3017 # @ingroup l2_modif_smooth
3018 def SmoothObject(self, theObject, IDsOfFixedNodes,
3019 MaxNbOfIterations, MaxAspectRatio, Method):
3020 if ( isinstance( theObject, Mesh )):
3021 theObject = theObject.GetMesh()
3022 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3023 MaxNbOfIterations, MaxAspectRatio, Method)
3025 ## Parametrically smoothes the given elements
3026 # @param IDsOfElements the list if ids of elements to smooth
3027 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3028 # Note that nodes built on edges and boundary nodes are always fixed.
3029 # @param MaxNbOfIterations the maximum number of iterations
3030 # @param MaxAspectRatio varies in range [1.0, inf]
3031 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3032 # @return TRUE in case of success, FALSE otherwise.
3033 # @ingroup l2_modif_smooth
3034 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3035 MaxNbOfIterations, MaxAspectRatio, Method):
3036 if IDsOfElements == []:
3037 IDsOfElements = self.GetElementsId()
3038 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3039 self.mesh.SetParameters(Parameters)
3040 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3041 MaxNbOfIterations, MaxAspectRatio, Method)
3043 ## Parametrically smoothes the elements which belong to the given object
3044 # @param theObject the object to smooth
3045 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3046 # Note that nodes built on edges and boundary nodes are always fixed.
3047 # @param MaxNbOfIterations the maximum number of iterations
3048 # @param MaxAspectRatio varies in range [1.0, inf]
3049 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3050 # @return TRUE in case of success, FALSE otherwise.
3051 # @ingroup l2_modif_smooth
3052 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3053 MaxNbOfIterations, MaxAspectRatio, Method):
3054 if ( isinstance( theObject, Mesh )):
3055 theObject = theObject.GetMesh()
3056 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3057 MaxNbOfIterations, MaxAspectRatio, Method)
3059 ## Converts the mesh to quadratic, deletes old elements, replacing
3060 # them with quadratic with the same id.
3061 # @param theForce3d new node creation method:
3062 # 0 - the medium node lies at the geometrical entity from which the mesh element is built
3063 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3064 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3065 # @ingroup l2_modif_tofromqu
3066 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
3068 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
3070 self.editor.ConvertToQuadratic(theForce3d)
3072 ## Converts the mesh from quadratic to ordinary,
3073 # deletes old quadratic elements, \n replacing
3074 # them with ordinary mesh elements with the same id.
3075 # @param theSubMesh a group or a sub-mesh to convert; WARNING: in this case the mesh can become not conformal
3076 # @ingroup l2_modif_tofromqu
3077 def ConvertFromQuadratic(self, theSubMesh=None):
3079 self.editor.ConvertFromQuadraticObject(theSubMesh)
3081 return self.editor.ConvertFromQuadratic()
3083 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3084 # @return TRUE if operation has been completed successfully, FALSE otherwise
3085 # @ingroup l2_modif_edit
3086 def Make2DMeshFrom3D(self):
3087 return self.editor. Make2DMeshFrom3D()
3089 ## Creates missing boundary elements
3090 # @param elements - elements whose boundary is to be checked:
3091 # mesh, group, sub-mesh or list of elements
3092 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3093 # @param dimension - defines type of boundary elements to create:
3094 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3095 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3096 # @param groupName - a name of group to store created boundary elements in,
3097 # "" means not to create the group
3098 # @param meshName - a name of new mesh to store created boundary elements in,
3099 # "" means not to create the new mesh
3100 # @param toCopyElements - if true, the checked elements will be copied into
3101 # the new mesh else only boundary elements will be copied into the new mesh
3102 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3103 # boundary elements will be copied into the new mesh
3104 # @return tuple (mesh, group) where bondary elements were added to
3105 # @ingroup l2_modif_edit
3106 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3107 toCopyElements=False, toCopyExistingBondary=False):
3108 if isinstance( elements, Mesh ):
3109 elements = elements.GetMesh()
3110 if ( isinstance( elements, list )):
3111 elemType = SMESH.ALL
3112 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3113 elements = self.editor.MakeIDSource(elements, elemType)
3114 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3115 toCopyElements,toCopyExistingBondary)
3116 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3120 # @brief Creates missing boundary elements around either the whole mesh or
3121 # groups of 2D elements
3122 # @param dimension - defines type of boundary elements to create
3123 # @param groupName - a name of group to store all boundary elements in,
3124 # "" means not to create the group
3125 # @param meshName - a name of a new mesh, which is a copy of the initial
3126 # mesh + created boundary elements; "" means not to create the new mesh
3127 # @param toCopyAll - if true, the whole initial mesh will be copied into
3128 # the new mesh else only boundary elements will be copied into the new mesh
3129 # @param groups - groups of 2D elements to make boundary around
3130 # @retval tuple( long, mesh, groups )
3131 # long - number of added boundary elements
3132 # mesh - the mesh where elements were added to
3133 # group - the group of boundary elements or None
3135 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3136 toCopyAll=False, groups=[]):
3137 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3139 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3140 return nb, mesh, group
3142 ## Renumber mesh nodes
3143 # @ingroup l2_modif_renumber
3144 def RenumberNodes(self):
3145 self.editor.RenumberNodes()
3147 ## Renumber mesh elements
3148 # @ingroup l2_modif_renumber
3149 def RenumberElements(self):
3150 self.editor.RenumberElements()
3152 ## Generates new elements by rotation of the elements around the axis
3153 # @param IDsOfElements the list of ids of elements to sweep
3154 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3155 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3156 # @param NbOfSteps the number of steps
3157 # @param Tolerance tolerance
3158 # @param MakeGroups forces the generation of new groups from existing ones
3159 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3160 # of all steps, else - size of each step
3161 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3162 # @ingroup l2_modif_extrurev
3163 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3164 MakeGroups=False, TotalAngle=False):
3166 if isinstance(AngleInRadians,str):
3168 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3170 AngleInRadians = DegreesToRadians(AngleInRadians)
3171 if IDsOfElements == []:
3172 IDsOfElements = self.GetElementsId()
3173 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3174 Axis = self.smeshpyD.GetAxisStruct(Axis)
3175 Axis,AxisParameters = ParseAxisStruct(Axis)
3176 if TotalAngle and NbOfSteps:
3177 AngleInRadians /= NbOfSteps
3178 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3179 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3180 self.mesh.SetParameters(Parameters)
3182 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3183 AngleInRadians, NbOfSteps, Tolerance)
3184 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3187 ## Generates new elements by rotation of the elements of object around the axis
3188 # @param theObject object which elements should be sweeped.
3189 # It can be a mesh, a sub mesh or a group.
3190 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3191 # @param AngleInRadians the angle of Rotation
3192 # @param NbOfSteps number of steps
3193 # @param Tolerance tolerance
3194 # @param MakeGroups forces the generation of new groups from existing ones
3195 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3196 # of all steps, else - size of each step
3197 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3198 # @ingroup l2_modif_extrurev
3199 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3200 MakeGroups=False, TotalAngle=False):
3202 if isinstance(AngleInRadians,str):
3204 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3206 AngleInRadians = DegreesToRadians(AngleInRadians)
3207 if ( isinstance( theObject, Mesh )):
3208 theObject = theObject.GetMesh()
3209 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3210 Axis = self.smeshpyD.GetAxisStruct(Axis)
3211 Axis,AxisParameters = ParseAxisStruct(Axis)
3212 if TotalAngle and NbOfSteps:
3213 AngleInRadians /= NbOfSteps
3214 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3215 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3216 self.mesh.SetParameters(Parameters)
3218 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3219 NbOfSteps, Tolerance)
3220 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3223 ## Generates new elements by rotation of the elements of object around the axis
3224 # @param theObject object which elements should be sweeped.
3225 # It can be a mesh, a sub mesh or a group.
3226 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3227 # @param AngleInRadians the angle of Rotation
3228 # @param NbOfSteps number of steps
3229 # @param Tolerance tolerance
3230 # @param MakeGroups forces the generation of new groups from existing ones
3231 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3232 # of all steps, else - size of each step
3233 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3234 # @ingroup l2_modif_extrurev
3235 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3236 MakeGroups=False, TotalAngle=False):
3238 if isinstance(AngleInRadians,str):
3240 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3242 AngleInRadians = DegreesToRadians(AngleInRadians)
3243 if ( isinstance( theObject, Mesh )):
3244 theObject = theObject.GetMesh()
3245 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3246 Axis = self.smeshpyD.GetAxisStruct(Axis)
3247 Axis,AxisParameters = ParseAxisStruct(Axis)
3248 if TotalAngle and NbOfSteps:
3249 AngleInRadians /= NbOfSteps
3250 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3251 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3252 self.mesh.SetParameters(Parameters)
3254 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3255 NbOfSteps, Tolerance)
3256 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3259 ## Generates new elements by rotation of the elements of object around the axis
3260 # @param theObject object which elements should be sweeped.
3261 # It can be a mesh, a sub mesh or a group.
3262 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3263 # @param AngleInRadians the angle of Rotation
3264 # @param NbOfSteps number of steps
3265 # @param Tolerance tolerance
3266 # @param MakeGroups forces the generation of new groups from existing ones
3267 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3268 # of all steps, else - size of each step
3269 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3270 # @ingroup l2_modif_extrurev
3271 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3272 MakeGroups=False, TotalAngle=False):
3274 if isinstance(AngleInRadians,str):
3276 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3278 AngleInRadians = DegreesToRadians(AngleInRadians)
3279 if ( isinstance( theObject, Mesh )):
3280 theObject = theObject.GetMesh()
3281 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3282 Axis = self.smeshpyD.GetAxisStruct(Axis)
3283 Axis,AxisParameters = ParseAxisStruct(Axis)
3284 if TotalAngle and NbOfSteps:
3285 AngleInRadians /= NbOfSteps
3286 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3287 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3288 self.mesh.SetParameters(Parameters)
3290 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3291 NbOfSteps, Tolerance)
3292 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3295 ## Generates new elements by extrusion of the elements with given ids
3296 # @param IDsOfElements the list of elements ids for extrusion
3297 # @param StepVector vector or DirStruct, defining the direction and value of extrusion
3298 # @param NbOfSteps the number of steps
3299 # @param MakeGroups forces the generation of new groups from existing ones
3300 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3301 # @ingroup l2_modif_extrurev
3302 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3303 if IDsOfElements == []:
3304 IDsOfElements = self.GetElementsId()
3305 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3306 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3307 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3308 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3309 Parameters = StepVectorParameters + var_separator + Parameters
3310 self.mesh.SetParameters(Parameters)
3312 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3313 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3316 ## Generates new elements by extrusion of the elements with given ids
3317 # @param IDsOfElements is ids of elements
3318 # @param StepVector vector, defining the direction and value of extrusion
3319 # @param NbOfSteps the number of steps
3320 # @param ExtrFlags sets flags for extrusion
3321 # @param SewTolerance uses for comparing locations of nodes if flag
3322 # EXTRUSION_FLAG_SEW is set
3323 # @param MakeGroups forces the generation of new groups from existing ones
3324 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3325 # @ingroup l2_modif_extrurev
3326 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3327 ExtrFlags, SewTolerance, MakeGroups=False):
3328 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3329 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3331 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3332 ExtrFlags, SewTolerance)
3333 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3334 ExtrFlags, SewTolerance)
3337 ## Generates new elements by extrusion of the elements which belong to the object
3338 # @param theObject the object which elements should be processed.
3339 # It can be a mesh, a sub mesh or a group.
3340 # @param StepVector vector, defining the direction and value of extrusion
3341 # @param NbOfSteps the number of steps
3342 # @param MakeGroups forces the generation of new groups from existing ones
3343 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3344 # @ingroup l2_modif_extrurev
3345 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3346 if ( isinstance( theObject, Mesh )):
3347 theObject = theObject.GetMesh()
3348 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3349 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3350 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3351 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3352 Parameters = StepVectorParameters + var_separator + Parameters
3353 self.mesh.SetParameters(Parameters)
3355 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3356 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3359 ## Generates new elements by extrusion of the elements which belong to the object
3360 # @param theObject object which elements should be processed.
3361 # It can be a mesh, a sub mesh or a group.
3362 # @param StepVector vector, defining the direction and value of extrusion
3363 # @param NbOfSteps the number of steps
3364 # @param MakeGroups to generate new groups from existing ones
3365 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3366 # @ingroup l2_modif_extrurev
3367 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3368 if ( isinstance( theObject, Mesh )):
3369 theObject = theObject.GetMesh()
3370 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3371 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3372 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3373 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3374 Parameters = StepVectorParameters + var_separator + Parameters
3375 self.mesh.SetParameters(Parameters)
3377 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3378 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3381 ## Generates new elements by extrusion of the elements which belong to the object
3382 # @param theObject object which elements should be processed.
3383 # It can be a mesh, a sub mesh or a group.
3384 # @param StepVector vector, defining the direction and value of extrusion
3385 # @param NbOfSteps the number of steps
3386 # @param MakeGroups forces the generation of new groups from existing ones
3387 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3388 # @ingroup l2_modif_extrurev
3389 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3390 if ( isinstance( theObject, Mesh )):
3391 theObject = theObject.GetMesh()
3392 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3393 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3394 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3395 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3396 Parameters = StepVectorParameters + var_separator + Parameters
3397 self.mesh.SetParameters(Parameters)
3399 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3400 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3405 ## Generates new elements by extrusion of the given elements
3406 # The path of extrusion must be a meshed edge.
3407 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3408 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3409 # @param NodeStart the start node from Path. Defines the direction of extrusion
3410 # @param HasAngles allows the shape to be rotated around the path
3411 # to get the resulting mesh in a helical fashion
3412 # @param Angles list of angles in radians
3413 # @param LinearVariation forces the computation of rotation angles as linear
3414 # variation of the given Angles along path steps
3415 # @param HasRefPoint allows using the reference point
3416 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3417 # The User can specify any point as the Reference Point.
3418 # @param MakeGroups forces the generation of new groups from existing ones
3419 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3420 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3421 # only SMESH::Extrusion_Error otherwise
3422 # @ingroup l2_modif_extrurev
3423 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3424 HasAngles, Angles, LinearVariation,
3425 HasRefPoint, RefPoint, MakeGroups, ElemType):
3426 Angles,AnglesParameters = ParseAngles(Angles)
3427 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3428 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3429 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3431 Parameters = AnglesParameters + var_separator + RefPointParameters
3432 self.mesh.SetParameters(Parameters)
3434 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3436 if isinstance(Base, list):
3438 if Base == []: IDsOfElements = self.GetElementsId()
3439 else: IDsOfElements = Base
3440 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3441 HasAngles, Angles, LinearVariation,
3442 HasRefPoint, RefPoint, MakeGroups, ElemType)
3444 if isinstance(Base, Mesh): Base = Base.GetMesh()
3445 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3446 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3447 HasAngles, Angles, LinearVariation,
3448 HasRefPoint, RefPoint, MakeGroups, ElemType)
3450 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3453 ## Generates new elements by extrusion of the given elements
3454 # The path of extrusion must be a meshed edge.
3455 # @param IDsOfElements ids of elements
3456 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3457 # @param PathShape shape(edge) defines the sub-mesh for the path
3458 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3459 # @param HasAngles allows the shape to be rotated around the path
3460 # to get the resulting mesh in a helical fashion
3461 # @param Angles list of angles in radians
3462 # @param HasRefPoint allows using the reference point
3463 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3464 # The User can specify any point as the Reference Point.
3465 # @param MakeGroups forces the generation of new groups from existing ones
3466 # @param LinearVariation forces the computation of rotation angles as linear
3467 # variation of the given Angles along path steps
3468 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3469 # only SMESH::Extrusion_Error otherwise
3470 # @ingroup l2_modif_extrurev
3471 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3472 HasAngles, Angles, HasRefPoint, RefPoint,
3473 MakeGroups=False, LinearVariation=False):
3474 Angles,AnglesParameters = ParseAngles(Angles)
3475 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3476 if IDsOfElements == []:
3477 IDsOfElements = self.GetElementsId()
3478 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3479 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3481 if ( isinstance( PathMesh, Mesh )):
3482 PathMesh = PathMesh.GetMesh()
3483 if HasAngles and Angles and LinearVariation:
3484 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3486 Parameters = AnglesParameters + var_separator + RefPointParameters
3487 self.mesh.SetParameters(Parameters)
3489 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3490 PathShape, NodeStart, HasAngles,
3491 Angles, HasRefPoint, RefPoint)
3492 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3493 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3495 ## Generates new elements by extrusion of the elements which belong to the object
3496 # The path of extrusion must be a meshed edge.
3497 # @param theObject the object which elements should be processed.
3498 # It can be a mesh, a sub mesh or a group.
3499 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3500 # @param PathShape shape(edge) defines the sub-mesh for the path
3501 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3502 # @param HasAngles allows the shape to be rotated around the path
3503 # to get the resulting mesh in a helical fashion
3504 # @param Angles list of angles
3505 # @param HasRefPoint allows using the reference point
3506 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3507 # The User can specify any point as the Reference Point.
3508 # @param MakeGroups forces the generation of new groups from existing ones
3509 # @param LinearVariation forces the computation of rotation angles as linear
3510 # variation of the given Angles along path steps
3511 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3512 # only SMESH::Extrusion_Error otherwise
3513 # @ingroup l2_modif_extrurev
3514 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3515 HasAngles, Angles, HasRefPoint, RefPoint,
3516 MakeGroups=False, LinearVariation=False):
3517 Angles,AnglesParameters = ParseAngles(Angles)
3518 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3519 if ( isinstance( theObject, Mesh )):
3520 theObject = theObject.GetMesh()
3521 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3522 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3523 if ( isinstance( PathMesh, Mesh )):
3524 PathMesh = PathMesh.GetMesh()
3525 if HasAngles and Angles and LinearVariation:
3526 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3528 Parameters = AnglesParameters + var_separator + RefPointParameters
3529 self.mesh.SetParameters(Parameters)
3531 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3532 PathShape, NodeStart, HasAngles,
3533 Angles, HasRefPoint, RefPoint)
3534 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3535 NodeStart, HasAngles, Angles, HasRefPoint,
3538 ## Generates new elements by extrusion of the elements which belong to the object
3539 # The path of extrusion must be a meshed edge.
3540 # @param theObject the object which elements should be processed.
3541 # It can be a mesh, a sub mesh or a group.
3542 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3543 # @param PathShape shape(edge) defines the sub-mesh for the path
3544 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3545 # @param HasAngles allows the shape to be rotated around the path
3546 # to get the resulting mesh in a helical fashion
3547 # @param Angles list of angles
3548 # @param HasRefPoint allows using the reference point
3549 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3550 # The User can specify any point as the Reference Point.
3551 # @param MakeGroups forces the generation of new groups from existing ones
3552 # @param LinearVariation forces the computation of rotation angles as linear
3553 # variation of the given Angles along path steps
3554 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3555 # only SMESH::Extrusion_Error otherwise
3556 # @ingroup l2_modif_extrurev
3557 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3558 HasAngles, Angles, HasRefPoint, RefPoint,
3559 MakeGroups=False, LinearVariation=False):
3560 Angles,AnglesParameters = ParseAngles(Angles)
3561 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3562 if ( isinstance( theObject, Mesh )):
3563 theObject = theObject.GetMesh()
3564 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3565 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3566 if ( isinstance( PathMesh, Mesh )):
3567 PathMesh = PathMesh.GetMesh()
3568 if HasAngles and Angles and LinearVariation:
3569 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3571 Parameters = AnglesParameters + var_separator + RefPointParameters
3572 self.mesh.SetParameters(Parameters)
3574 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3575 PathShape, NodeStart, HasAngles,
3576 Angles, HasRefPoint, RefPoint)
3577 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3578 NodeStart, HasAngles, Angles, HasRefPoint,
3581 ## Generates new elements by extrusion of the elements which belong to the object
3582 # The path of extrusion must be a meshed edge.
3583 # @param theObject the object which elements should be processed.
3584 # It can be a mesh, a sub mesh or a group.
3585 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3586 # @param PathShape shape(edge) defines the sub-mesh for the path
3587 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3588 # @param HasAngles allows the shape to be rotated around the path
3589 # to get the resulting mesh in a helical fashion
3590 # @param Angles list of angles
3591 # @param HasRefPoint allows using the reference point
3592 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3593 # The User can specify any point as the Reference Point.
3594 # @param MakeGroups forces the generation of new groups from existing ones
3595 # @param LinearVariation forces the computation of rotation angles as linear
3596 # variation of the given Angles along path steps
3597 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3598 # only SMESH::Extrusion_Error otherwise
3599 # @ingroup l2_modif_extrurev
3600 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3601 HasAngles, Angles, HasRefPoint, RefPoint,
3602 MakeGroups=False, LinearVariation=False):
3603 Angles,AnglesParameters = ParseAngles(Angles)
3604 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3605 if ( isinstance( theObject, Mesh )):
3606 theObject = theObject.GetMesh()
3607 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3608 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3609 if ( isinstance( PathMesh, Mesh )):
3610 PathMesh = PathMesh.GetMesh()
3611 if HasAngles and Angles and LinearVariation:
3612 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3614 Parameters = AnglesParameters + var_separator + RefPointParameters
3615 self.mesh.SetParameters(Parameters)
3617 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3618 PathShape, NodeStart, HasAngles,
3619 Angles, HasRefPoint, RefPoint)
3620 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3621 NodeStart, HasAngles, Angles, HasRefPoint,
3624 ## Creates a symmetrical copy of mesh elements
3625 # @param IDsOfElements list of elements ids
3626 # @param Mirror is AxisStruct or geom object(point, line, plane)
3627 # @param theMirrorType is POINT, AXIS or PLANE
3628 # If the Mirror is a geom object this parameter is unnecessary
3629 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3630 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3631 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3632 # @ingroup l2_modif_trsf
3633 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3634 if IDsOfElements == []:
3635 IDsOfElements = self.GetElementsId()
3636 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3637 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3638 Mirror,Parameters = ParseAxisStruct(Mirror)
3639 self.mesh.SetParameters(Parameters)
3640 if Copy and MakeGroups:
3641 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3642 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3645 ## Creates a new mesh by a symmetrical copy of mesh elements
3646 # @param IDsOfElements the list of elements ids
3647 # @param Mirror is AxisStruct or geom object (point, line, plane)
3648 # @param theMirrorType is POINT, AXIS or PLANE
3649 # If the Mirror is a geom object this parameter is unnecessary
3650 # @param MakeGroups to generate new groups from existing ones
3651 # @param NewMeshName a name of the new mesh to create
3652 # @return instance of Mesh class
3653 # @ingroup l2_modif_trsf
3654 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3655 if IDsOfElements == []:
3656 IDsOfElements = self.GetElementsId()
3657 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3658 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3659 Mirror,Parameters = ParseAxisStruct(Mirror)
3660 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3661 MakeGroups, NewMeshName)
3662 mesh.SetParameters(Parameters)
3663 return Mesh(self.smeshpyD,self.geompyD,mesh)
3665 ## Creates a symmetrical copy of the object
3666 # @param theObject mesh, submesh or group
3667 # @param Mirror AxisStruct or geom object (point, line, plane)
3668 # @param theMirrorType is POINT, AXIS or PLANE
3669 # If the Mirror is a geom object this parameter is unnecessary
3670 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3671 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3672 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3673 # @ingroup l2_modif_trsf
3674 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3675 if ( isinstance( theObject, Mesh )):
3676 theObject = theObject.GetMesh()
3677 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3678 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3679 Mirror,Parameters = ParseAxisStruct(Mirror)
3680 self.mesh.SetParameters(Parameters)
3681 if Copy and MakeGroups:
3682 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3683 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3686 ## Creates a new mesh by a symmetrical copy of the object
3687 # @param theObject mesh, submesh or group
3688 # @param Mirror AxisStruct or geom object (point, line, plane)
3689 # @param theMirrorType POINT, AXIS or PLANE
3690 # If the Mirror is a geom object this parameter is unnecessary
3691 # @param MakeGroups forces the generation of new groups from existing ones
3692 # @param NewMeshName the name of the new mesh to create
3693 # @return instance of Mesh class
3694 # @ingroup l2_modif_trsf
3695 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3696 if ( isinstance( theObject, Mesh )):
3697 theObject = theObject.GetMesh()
3698 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3699 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3700 Mirror,Parameters = ParseAxisStruct(Mirror)
3701 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3702 MakeGroups, NewMeshName)
3703 mesh.SetParameters(Parameters)
3704 return Mesh( self.smeshpyD,self.geompyD,mesh )
3706 ## Translates the elements
3707 # @param IDsOfElements list of elements ids
3708 # @param Vector the direction of translation (DirStruct or vector)
3709 # @param Copy allows copying the translated elements
3710 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3711 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3712 # @ingroup l2_modif_trsf
3713 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3714 if IDsOfElements == []:
3715 IDsOfElements = self.GetElementsId()
3716 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3717 Vector = self.smeshpyD.GetDirStruct(Vector)
3718 Vector,Parameters = ParseDirStruct(Vector)
3719 self.mesh.SetParameters(Parameters)
3720 if Copy and MakeGroups:
3721 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3722 self.editor.Translate(IDsOfElements, Vector, Copy)
3725 ## Creates a new mesh of translated elements
3726 # @param IDsOfElements list of elements ids
3727 # @param Vector the direction of translation (DirStruct or vector)
3728 # @param MakeGroups forces the generation of new groups from existing ones
3729 # @param NewMeshName the name of the newly created mesh
3730 # @return instance of Mesh class
3731 # @ingroup l2_modif_trsf
3732 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3733 if IDsOfElements == []:
3734 IDsOfElements = self.GetElementsId()
3735 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3736 Vector = self.smeshpyD.GetDirStruct(Vector)
3737 Vector,Parameters = ParseDirStruct(Vector)
3738 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3739 mesh.SetParameters(Parameters)
3740 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3742 ## Translates the object
3743 # @param theObject the object to translate (mesh, submesh, or group)
3744 # @param Vector direction of translation (DirStruct or geom vector)
3745 # @param Copy allows copying the translated elements
3746 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3747 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3748 # @ingroup l2_modif_trsf
3749 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3750 if ( isinstance( theObject, Mesh )):
3751 theObject = theObject.GetMesh()
3752 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3753 Vector = self.smeshpyD.GetDirStruct(Vector)
3754 Vector,Parameters = ParseDirStruct(Vector)
3755 self.mesh.SetParameters(Parameters)
3756 if Copy and MakeGroups:
3757 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3758 self.editor.TranslateObject(theObject, Vector, Copy)
3761 ## Creates a new mesh from the translated object
3762 # @param theObject the object to translate (mesh, submesh, or group)
3763 # @param Vector the direction of translation (DirStruct or geom vector)
3764 # @param MakeGroups forces the generation of new groups from existing ones
3765 # @param NewMeshName the name of the newly created mesh
3766 # @return instance of Mesh class
3767 # @ingroup l2_modif_trsf
3768 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3769 if (isinstance(theObject, Mesh)):
3770 theObject = theObject.GetMesh()
3771 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3772 Vector = self.smeshpyD.GetDirStruct(Vector)
3773 Vector,Parameters = ParseDirStruct(Vector)
3774 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3775 mesh.SetParameters(Parameters)
3776 return Mesh( self.smeshpyD, self.geompyD, mesh )
3780 ## Scales the object
3781 # @param theObject - the object to translate (mesh, submesh, or group)
3782 # @param thePoint - base point for scale
3783 # @param theScaleFact - list of 1-3 scale factors for axises
3784 # @param Copy - allows copying the translated elements
3785 # @param MakeGroups - forces the generation of new groups from existing
3787 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3788 # empty list otherwise
3789 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3790 if ( isinstance( theObject, Mesh )):
3791 theObject = theObject.GetMesh()
3792 if ( isinstance( theObject, list )):
3793 theObject = self.GetIDSource(theObject, SMESH.ALL)
3795 thePoint, Parameters = ParsePointStruct(thePoint)
3796 self.mesh.SetParameters(Parameters)
3798 if Copy and MakeGroups:
3799 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3800 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3803 ## Creates a new mesh from the translated object
3804 # @param theObject - the object to translate (mesh, submesh, or group)
3805 # @param thePoint - base point for scale
3806 # @param theScaleFact - list of 1-3 scale factors for axises
3807 # @param MakeGroups - forces the generation of new groups from existing ones
3808 # @param NewMeshName - the name of the newly created mesh
3809 # @return instance of Mesh class
3810 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3811 if (isinstance(theObject, Mesh)):
3812 theObject = theObject.GetMesh()
3813 if ( isinstance( theObject, list )):
3814 theObject = self.GetIDSource(theObject,SMESH.ALL)
3816 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3817 MakeGroups, NewMeshName)
3818 #mesh.SetParameters(Parameters)
3819 return Mesh( self.smeshpyD, self.geompyD, mesh )
3823 ## Rotates the elements
3824 # @param IDsOfElements list of elements ids
3825 # @param Axis the axis of rotation (AxisStruct or geom line)
3826 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3827 # @param Copy allows copying the rotated elements
3828 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3829 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3830 # @ingroup l2_modif_trsf
3831 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3833 if isinstance(AngleInRadians,str):
3835 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3837 AngleInRadians = DegreesToRadians(AngleInRadians)
3838 if IDsOfElements == []:
3839 IDsOfElements = self.GetElementsId()
3840 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3841 Axis = self.smeshpyD.GetAxisStruct(Axis)
3842 Axis,AxisParameters = ParseAxisStruct(Axis)
3843 Parameters = AxisParameters + var_separator + Parameters
3844 self.mesh.SetParameters(Parameters)
3845 if Copy and MakeGroups:
3846 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3847 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3850 ## Creates a new mesh of rotated elements
3851 # @param IDsOfElements list of element ids
3852 # @param Axis the axis of rotation (AxisStruct or geom line)
3853 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3854 # @param MakeGroups forces the generation of new groups from existing ones
3855 # @param NewMeshName the name of the newly created mesh
3856 # @return instance of Mesh class
3857 # @ingroup l2_modif_trsf
3858 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3860 if isinstance(AngleInRadians,str):
3862 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3864 AngleInRadians = DegreesToRadians(AngleInRadians)
3865 if IDsOfElements == []:
3866 IDsOfElements = self.GetElementsId()
3867 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3868 Axis = self.smeshpyD.GetAxisStruct(Axis)
3869 Axis,AxisParameters = ParseAxisStruct(Axis)
3870 Parameters = AxisParameters + var_separator + Parameters
3871 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3872 MakeGroups, NewMeshName)
3873 mesh.SetParameters(Parameters)
3874 return Mesh( self.smeshpyD, self.geompyD, mesh )
3876 ## Rotates the object
3877 # @param theObject the object to rotate( mesh, submesh, or group)
3878 # @param Axis the axis of rotation (AxisStruct or geom line)
3879 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3880 # @param Copy allows copying the rotated elements
3881 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3882 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3883 # @ingroup l2_modif_trsf
3884 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3886 if isinstance(AngleInRadians,str):
3888 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3890 AngleInRadians = DegreesToRadians(AngleInRadians)
3891 if (isinstance(theObject, Mesh)):
3892 theObject = theObject.GetMesh()
3893 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3894 Axis = self.smeshpyD.GetAxisStruct(Axis)
3895 Axis,AxisParameters = ParseAxisStruct(Axis)
3896 Parameters = AxisParameters + ":" + Parameters
3897 self.mesh.SetParameters(Parameters)
3898 if Copy and MakeGroups:
3899 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3900 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3903 ## Creates a new mesh from the rotated object
3904 # @param theObject the object to rotate (mesh, submesh, or group)
3905 # @param Axis the axis of rotation (AxisStruct or geom line)
3906 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3907 # @param MakeGroups forces the generation of new groups from existing ones
3908 # @param NewMeshName the name of the newly created mesh
3909 # @return instance of Mesh class
3910 # @ingroup l2_modif_trsf
3911 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3913 if isinstance(AngleInRadians,str):
3915 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3917 AngleInRadians = DegreesToRadians(AngleInRadians)
3918 if (isinstance( theObject, Mesh )):
3919 theObject = theObject.GetMesh()
3920 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3921 Axis = self.smeshpyD.GetAxisStruct(Axis)
3922 Axis,AxisParameters = ParseAxisStruct(Axis)
3923 Parameters = AxisParameters + ":" + Parameters
3924 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3925 MakeGroups, NewMeshName)
3926 mesh.SetParameters(Parameters)
3927 return Mesh( self.smeshpyD, self.geompyD, mesh )
3929 ## Finds groups of ajacent nodes within Tolerance.
3930 # @param Tolerance the value of tolerance
3931 # @return the list of groups of nodes
3932 # @ingroup l2_modif_trsf
3933 def FindCoincidentNodes (self, Tolerance):
3934 return self.editor.FindCoincidentNodes(Tolerance)
3936 ## Finds groups of ajacent nodes within Tolerance.
3937 # @param Tolerance the value of tolerance
3938 # @param SubMeshOrGroup SubMesh or Group
3939 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3940 # @return the list of groups of nodes
3941 # @ingroup l2_modif_trsf
3942 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3943 if (isinstance( SubMeshOrGroup, Mesh )):
3944 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3945 if not isinstance( exceptNodes, list):
3946 exceptNodes = [ exceptNodes ]
3947 if exceptNodes and isinstance( exceptNodes[0], int):
3948 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3949 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3952 # @param GroupsOfNodes the list of groups of nodes
3953 # @ingroup l2_modif_trsf
3954 def MergeNodes (self, GroupsOfNodes):
3955 self.editor.MergeNodes(GroupsOfNodes)
3957 ## Finds the elements built on the same nodes.
3958 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3959 # @return a list of groups of equal elements
3960 # @ingroup l2_modif_trsf
3961 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3962 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3963 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3964 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3966 ## Merges elements in each given group.
3967 # @param GroupsOfElementsID groups of elements for merging
3968 # @ingroup l2_modif_trsf
3969 def MergeElements(self, GroupsOfElementsID):
3970 self.editor.MergeElements(GroupsOfElementsID)
3972 ## Leaves one element and removes all other elements built on the same nodes.
3973 # @ingroup l2_modif_trsf
3974 def MergeEqualElements(self):
3975 self.editor.MergeEqualElements()
3977 ## Sews free borders
3978 # @return SMESH::Sew_Error
3979 # @ingroup l2_modif_trsf
3980 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3981 FirstNodeID2, SecondNodeID2, LastNodeID2,
3982 CreatePolygons, CreatePolyedrs):
3983 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3984 FirstNodeID2, SecondNodeID2, LastNodeID2,
3985 CreatePolygons, CreatePolyedrs)
3987 ## Sews conform free borders
3988 # @return SMESH::Sew_Error
3989 # @ingroup l2_modif_trsf
3990 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3991 FirstNodeID2, SecondNodeID2):
3992 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3993 FirstNodeID2, SecondNodeID2)
3995 ## Sews border to side
3996 # @return SMESH::Sew_Error
3997 # @ingroup l2_modif_trsf
3998 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3999 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
4000 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
4001 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
4003 ## Sews two sides of a mesh. The nodes belonging to Side1 are
4004 # merged with the nodes of elements of Side2.
4005 # The number of elements in theSide1 and in theSide2 must be
4006 # equal and they should have similar nodal connectivity.
4007 # The nodes to merge should belong to side borders and
4008 # the first node should be linked to the second.
4009 # @return SMESH::Sew_Error
4010 # @ingroup l2_modif_trsf
4011 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4012 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4013 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4014 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4015 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4016 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4018 ## Sets new nodes for the given element.
4019 # @param ide the element id
4020 # @param newIDs nodes ids
4021 # @return If the number of nodes does not correspond to the type of element - returns false
4022 # @ingroup l2_modif_edit
4023 def ChangeElemNodes(self, ide, newIDs):
4024 return self.editor.ChangeElemNodes(ide, newIDs)
4026 ## If during the last operation of MeshEditor some nodes were
4027 # created, this method returns the list of their IDs, \n
4028 # if new nodes were not created - returns empty list
4029 # @return the list of integer values (can be empty)
4030 # @ingroup l1_auxiliary
4031 def GetLastCreatedNodes(self):
4032 return self.editor.GetLastCreatedNodes()
4034 ## If during the last operation of MeshEditor some elements were
4035 # created this method returns the list of their IDs, \n
4036 # if new elements were not created - returns empty list
4037 # @return the list of integer values (can be empty)
4038 # @ingroup l1_auxiliary
4039 def GetLastCreatedElems(self):
4040 return self.editor.GetLastCreatedElems()
4042 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4043 # @param theNodes identifiers of nodes to be doubled
4044 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4045 # nodes. If list of element identifiers is empty then nodes are doubled but
4046 # they not assigned to elements
4047 # @return TRUE if operation has been completed successfully, FALSE otherwise
4048 # @ingroup l2_modif_edit
4049 def DoubleNodes(self, theNodes, theModifiedElems):
4050 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4052 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4053 # This method provided for convenience works as DoubleNodes() described above.
4054 # @param theNodeId identifiers of node to be doubled
4055 # @param theModifiedElems identifiers of elements to be updated
4056 # @return TRUE if operation has been completed successfully, FALSE otherwise
4057 # @ingroup l2_modif_edit
4058 def DoubleNode(self, theNodeId, theModifiedElems):
4059 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4061 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4062 # This method provided for convenience works as DoubleNodes() described above.
4063 # @param theNodes group of nodes to be doubled
4064 # @param theModifiedElems group of elements to be updated.
4065 # @param theMakeGroup forces the generation of a group containing new nodes.
4066 # @return TRUE or a created group if operation has been completed successfully,
4067 # FALSE or None otherwise
4068 # @ingroup l2_modif_edit
4069 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4071 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4072 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4074 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4075 # This method provided for convenience works as DoubleNodes() described above.
4076 # @param theNodes list of groups of nodes to be doubled
4077 # @param theModifiedElems list of groups of elements to be updated.
4078 # @return TRUE if operation has been completed successfully, FALSE otherwise
4079 # @ingroup l2_modif_edit
4080 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4082 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4083 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4085 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4086 # @param theElems - the list of elements (edges or faces) to be replicated
4087 # The nodes for duplication could be found from these elements
4088 # @param theNodesNot - list of nodes to NOT replicate
4089 # @param theAffectedElems - the list of elements (cells and edges) to which the
4090 # replicated nodes should be associated to.
4091 # @return TRUE if operation has been completed successfully, FALSE otherwise
4092 # @ingroup l2_modif_edit
4093 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4094 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4096 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4097 # @param theElems - the list of elements (edges or faces) to be replicated
4098 # The nodes for duplication could be found from these elements
4099 # @param theNodesNot - list of nodes to NOT replicate
4100 # @param theShape - shape to detect affected elements (element which geometric center
4101 # located on or inside shape).
4102 # The replicated nodes should be associated to affected elements.
4103 # @return TRUE if operation has been completed successfully, FALSE otherwise
4104 # @ingroup l2_modif_edit
4105 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4106 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4108 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4109 # This method provided for convenience works as DoubleNodes() described above.
4110 # @param theElems - group of of elements (edges or faces) to be replicated
4111 # @param theNodesNot - group of nodes not to replicated
4112 # @param theAffectedElems - group of elements to which the replicated nodes
4113 # should be associated to.
4114 # @param theMakeGroup forces the generation of a group containing new elements.
4115 # @return TRUE or a created group if operation has been completed successfully,
4116 # FALSE or None otherwise
4117 # @ingroup l2_modif_edit
4118 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4120 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4121 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4123 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4124 # This method provided for convenience works as DoubleNodes() described above.
4125 # @param theElems - group of of elements (edges or faces) to be replicated
4126 # @param theNodesNot - group of nodes not to replicated
4127 # @param theShape - shape to detect affected elements (element which geometric center
4128 # located on or inside shape).
4129 # The replicated nodes should be associated to affected elements.
4130 # @ingroup l2_modif_edit
4131 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4132 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4134 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4135 # This method provided for convenience works as DoubleNodes() described above.
4136 # @param theElems - list of groups of elements (edges or faces) to be replicated
4137 # @param theNodesNot - list of groups of nodes not to replicated
4138 # @param theAffectedElems - group of elements to which the replicated nodes
4139 # should be associated to.
4140 # @param theMakeGroup forces the generation of a group containing new elements.
4141 # @return TRUE or a created group if operation has been completed successfully,
4142 # FALSE or None otherwise
4143 # @ingroup l2_modif_edit
4144 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4146 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4147 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4149 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4150 # This method provided for convenience works as DoubleNodes() described above.
4151 # @param theElems - list of groups of elements (edges or faces) to be replicated
4152 # @param theNodesNot - list of groups of nodes not to replicated
4153 # @param theShape - shape to detect affected elements (element which geometric center
4154 # located on or inside shape).
4155 # The replicated nodes should be associated to affected elements.
4156 # @return TRUE if operation has been completed successfully, FALSE otherwise
4157 # @ingroup l2_modif_edit
4158 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4159 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4161 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4162 # The list of groups must describe a partition of the mesh volumes.
4163 # The nodes of the internal faces at the boundaries of the groups are doubled.
4164 # In option, the internal faces are replaced by flat elements.
4165 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4166 # @param theDomains - list of groups of volumes
4167 # @param createJointElems - if TRUE, create the elements
4168 # @return TRUE if operation has been completed successfully, FALSE otherwise
4169 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4170 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4172 def _valueFromFunctor(self, funcType, elemId):
4173 fn = self.smeshpyD.GetFunctor(funcType)
4174 fn.SetMesh(self.mesh)
4175 if fn.GetElementType() == self.GetElementType(elemId, True):
4176 val = fn.GetValue(elemId)
4181 ## Get length of 1D element.
4182 # @param elemId mesh element ID
4183 # @return element's length value
4184 # @ingroup l1_measurements
4185 def GetLength(self, elemId):
4186 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4188 ## Get area of 2D element.
4189 # @param elemId mesh element ID
4190 # @return element's area value
4191 # @ingroup l1_measurements
4192 def GetArea(self, elemId):
4193 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4195 ## Get volume of 3D element.
4196 # @param elemId mesh element ID
4197 # @return element's volume value
4198 # @ingroup l1_measurements
4199 def GetVolume(self, elemId):
4200 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4202 ## Get maximum element length.
4203 # @param elemId mesh element ID
4204 # @return element's maximum length value
4205 # @ingroup l1_measurements
4206 def GetMaxElementLength(self, elemId):
4207 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4208 ftype = SMESH.FT_MaxElementLength3D
4210 ftype = SMESH.FT_MaxElementLength2D
4211 return self._valueFromFunctor(ftype, elemId)
4213 ## Get aspect ratio of 2D or 3D element.
4214 # @param elemId mesh element ID
4215 # @return element's aspect ratio value
4216 # @ingroup l1_measurements
4217 def GetAspectRatio(self, elemId):
4218 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4219 ftype = SMESH.FT_AspectRatio3D
4221 ftype = SMESH.FT_AspectRatio
4222 return self._valueFromFunctor(ftype, elemId)
4224 ## Get warping angle of 2D element.
4225 # @param elemId mesh element ID
4226 # @return element's warping angle value
4227 # @ingroup l1_measurements
4228 def GetWarping(self, elemId):
4229 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4231 ## Get minimum angle of 2D element.
4232 # @param elemId mesh element ID
4233 # @return element's minimum angle value
4234 # @ingroup l1_measurements
4235 def GetMinimumAngle(self, elemId):
4236 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4238 ## Get taper of 2D element.
4239 # @param elemId mesh element ID
4240 # @return element's taper value
4241 # @ingroup l1_measurements
4242 def GetTaper(self, elemId):
4243 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4245 ## Get skew of 2D element.
4246 # @param elemId mesh element ID
4247 # @return element's skew value
4248 # @ingroup l1_measurements
4249 def GetSkew(self, elemId):
4250 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4252 ## The mother class to define algorithm, it is not recommended to use it directly.
4255 # @ingroup l2_algorithms
4256 class Mesh_Algorithm:
4257 # @class Mesh_Algorithm
4258 # @brief Class Mesh_Algorithm
4260 #def __init__(self,smesh):
4268 ## Finds a hypothesis in the study by its type name and parameters.
4269 # Finds only the hypotheses created in smeshpyD engine.
4270 # @return SMESH.SMESH_Hypothesis
4271 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4272 study = smeshpyD.GetCurrentStudy()
4273 #to do: find component by smeshpyD object, not by its data type
4274 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4275 if scomp is not None:
4276 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4277 # Check if the root label of the hypotheses exists
4278 if res and hypRoot is not None:
4279 iter = study.NewChildIterator(hypRoot)
4280 # Check all published hypotheses
4282 hypo_so_i = iter.Value()
4283 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4284 if attr is not None:
4285 anIOR = attr.Value()
4286 hypo_o_i = salome.orb.string_to_object(anIOR)
4287 if hypo_o_i is not None:
4288 # Check if this is a hypothesis
4289 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4290 if hypo_i is not None:
4291 # Check if the hypothesis belongs to current engine
4292 if smeshpyD.GetObjectId(hypo_i) > 0:
4293 # Check if this is the required hypothesis
4294 if hypo_i.GetName() == hypname:
4296 if CompareMethod(hypo_i, args):
4310 ## Finds the algorithm in the study by its type name.
4311 # Finds only the algorithms, which have been created in smeshpyD engine.
4312 # @return SMESH.SMESH_Algo
4313 def FindAlgorithm (self, algoname, smeshpyD):
4314 study = smeshpyD.GetCurrentStudy()
4315 #to do: find component by smeshpyD object, not by its data type
4316 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4317 if scomp is not None:
4318 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4319 # Check if the root label of the algorithms exists
4320 if res and hypRoot is not None:
4321 iter = study.NewChildIterator(hypRoot)
4322 # Check all published algorithms
4324 algo_so_i = iter.Value()
4325 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4326 if attr is not None:
4327 anIOR = attr.Value()
4328 algo_o_i = salome.orb.string_to_object(anIOR)
4329 if algo_o_i is not None:
4330 # Check if this is an algorithm
4331 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4332 if algo_i is not None:
4333 # Checks if the algorithm belongs to the current engine
4334 if smeshpyD.GetObjectId(algo_i) > 0:
4335 # Check if this is the required algorithm
4336 if algo_i.GetName() == algoname:
4349 ## If the algorithm is global, returns 0; \n
4350 # else returns the submesh associated to this algorithm.
4351 def GetSubMesh(self):
4354 ## Returns the wrapped mesher.
4355 def GetAlgorithm(self):
4358 ## Gets the list of hypothesis that can be used with this algorithm
4359 def GetCompatibleHypothesis(self):
4362 mylist = self.algo.GetCompatibleHypothesis()
4365 ## Gets the name of the algorithm
4369 ## Sets the name to the algorithm
4370 def SetName(self, name):
4371 self.mesh.smeshpyD.SetName(self.algo, name)
4373 ## Gets the id of the algorithm
4375 return self.algo.GetId()
4378 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4380 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4381 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4383 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4385 self.Assign(algo, mesh, geom)
4389 def Assign(self, algo, mesh, geom):
4391 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4400 name = GetName(geom)
4404 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4405 # for all groups SubShapeName() returns "Compound_-1"
4406 name = mesh.geompyD.SubShapeName(geom, piece)
4408 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4409 # publish geom of sub-mesh (issue 0021122)
4410 if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4411 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4412 if studyID != self.mesh.geompyD.myStudyId:
4413 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4414 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4416 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4418 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4419 TreatHypoStatus( status, algo.GetName(), name, True )
4421 def CompareHyp (self, hyp, args):
4422 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4425 def CompareEqualHyp (self, hyp, args):
4429 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4430 UseExisting=0, CompareMethod=""):
4433 if CompareMethod == "": CompareMethod = self.CompareHyp
4434 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4437 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4443 a = a + s + str(args[i])
4447 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4451 geomName = GetName(self.geom)
4452 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4453 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4456 ## Returns entry of the shape to mesh in the study
4457 def MainShapeEntry(self):
4459 if not self.mesh or not self.mesh.GetMesh(): return entry
4460 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4461 study = self.mesh.smeshpyD.GetCurrentStudy()
4462 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4463 sobj = study.FindObjectIOR(ior)
4464 if sobj: entry = sobj.GetID()
4465 if not entry: return ""
4468 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4469 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4470 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4471 # @param thickness total thickness of layers of prisms
4472 # @param numberOfLayers number of layers of prisms
4473 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4474 # @param ignoreFaces geometrical face (or their ids) not to generate layers on
4475 # @ingroup l3_hypos_additi
4476 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4477 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4478 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4479 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4480 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4481 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4482 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4483 hyp = self.Hypothesis("ViscousLayers",
4484 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4485 hyp.SetTotalThickness(thickness)
4486 hyp.SetNumberLayers(numberOfLayers)
4487 hyp.SetStretchFactor(stretchFactor)
4488 hyp.SetIgnoreFaces(ignoreFaces)
4491 # Public class: Mesh_Segment
4492 # --------------------------
4494 ## Class to define a segment 1D algorithm for discretization
4497 # @ingroup l3_algos_basic
4498 class Mesh_Segment(Mesh_Algorithm):
4500 ## Private constructor.
4501 def __init__(self, mesh, geom=0):
4502 Mesh_Algorithm.__init__(self)
4503 self.Create(mesh, geom, "Regular_1D")
4505 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4506 # @param l for the length of segments that cut an edge
4507 # @param UseExisting if ==true - searches for an existing hypothesis created with
4508 # the same parameters, else (default) - creates a new one
4509 # @param p precision, used for calculation of the number of segments.
4510 # The precision should be a positive, meaningful value within the range [0,1].
4511 # In general, the number of segments is calculated with the formula:
4512 # nb = ceil((edge_length / l) - p)
4513 # Function ceil rounds its argument to the higher integer.
4514 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4515 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4516 # p=1 means rounding of (edge_length / l) to the lower integer.
4517 # Default value is 1e-07.
4518 # @return an instance of StdMeshers_LocalLength hypothesis
4519 # @ingroup l3_hypos_1dhyps
4520 def LocalLength(self, l, UseExisting=0, p=1e-07):
4521 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4522 CompareMethod=self.CompareLocalLength)
4528 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4529 def CompareLocalLength(self, hyp, args):
4530 if IsEqual(hyp.GetLength(), args[0]):
4531 return IsEqual(hyp.GetPrecision(), args[1])
4534 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4535 # @param length is optional maximal allowed length of segment, if it is omitted
4536 # the preestimated length is used that depends on geometry size
4537 # @param UseExisting if ==true - searches for an existing hypothesis created with
4538 # the same parameters, else (default) - create a new one
4539 # @return an instance of StdMeshers_MaxLength hypothesis
4540 # @ingroup l3_hypos_1dhyps
4541 def MaxSize(self, length=0.0, UseExisting=0):
4542 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4545 hyp.SetLength(length)
4547 # set preestimated length
4548 gen = self.mesh.smeshpyD
4549 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4550 self.mesh.GetMesh(), self.mesh.GetShape(),
4552 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4554 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4557 hyp.SetUsePreestimatedLength( length == 0.0 )
4560 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4561 # @param n for the number of segments that cut an edge
4562 # @param s for the scale factor (optional)
4563 # @param reversedEdges is a list of edges to mesh using reversed orientation
4564 # @param UseExisting if ==true - searches for an existing hypothesis created with
4565 # the same parameters, else (default) - create a new one
4566 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4567 # @ingroup l3_hypos_1dhyps
4568 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4569 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4570 reversedEdges, UseExisting = [], reversedEdges
4571 entry = self.MainShapeEntry()
4572 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4573 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4575 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4576 UseExisting=UseExisting,
4577 CompareMethod=self.CompareNumberOfSegments)
4579 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4580 UseExisting=UseExisting,
4581 CompareMethod=self.CompareNumberOfSegments)
4582 hyp.SetDistrType( 1 )
4583 hyp.SetScaleFactor(s)
4584 hyp.SetNumberOfSegments(n)
4585 hyp.SetReversedEdges( reversedEdges )
4586 hyp.SetObjectEntry( entry )
4590 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4591 def CompareNumberOfSegments(self, hyp, args):
4592 if hyp.GetNumberOfSegments() == args[0]:
4594 if hyp.GetReversedEdges() == args[1]:
4595 if not args[1] or hyp.GetObjectEntry() == args[2]:
4598 if hyp.GetReversedEdges() == args[2]:
4599 if not args[2] or hyp.GetObjectEntry() == args[3]:
4600 if hyp.GetDistrType() == 1:
4601 if IsEqual(hyp.GetScaleFactor(), args[1]):
4605 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4606 # @param start defines the length of the first segment
4607 # @param end defines the length of the last segment
4608 # @param reversedEdges is a list of edges to mesh using reversed orientation
4609 # @param UseExisting if ==true - searches for an existing hypothesis created with
4610 # the same parameters, else (default) - creates a new one
4611 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4612 # @ingroup l3_hypos_1dhyps
4613 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4614 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4615 reversedEdges, UseExisting = [], reversedEdges
4616 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4617 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4618 entry = self.MainShapeEntry()
4619 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4620 UseExisting=UseExisting,
4621 CompareMethod=self.CompareArithmetic1D)
4622 hyp.SetStartLength(start)
4623 hyp.SetEndLength(end)
4624 hyp.SetReversedEdges( reversedEdges )
4625 hyp.SetObjectEntry( entry )
4629 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4630 def CompareArithmetic1D(self, hyp, args):
4631 if IsEqual(hyp.GetLength(1), args[0]):
4632 if IsEqual(hyp.GetLength(0), args[1]):
4633 if hyp.GetReversedEdges() == args[2]:
4634 if not args[2] or hyp.GetObjectEntry() == args[3]:
4639 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4640 # on curve from 0 to 1 (additionally it is neecessary to check
4641 # orientation of edges and create list of reversed edges if it is
4642 # needed) and sets numbers of segments between given points (default
4643 # values are equals 1
4644 # @param points defines the list of parameters on curve
4645 # @param nbSegs defines the list of numbers of segments
4646 # @param reversedEdges is a list of edges to mesh using reversed orientation
4647 # @param UseExisting if ==true - searches for an existing hypothesis created with
4648 # the same parameters, else (default) - creates a new one
4649 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4650 # @ingroup l3_hypos_1dhyps
4651 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4652 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4653 reversedEdges, UseExisting = [], reversedEdges
4654 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4655 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4656 entry = self.MainShapeEntry()
4657 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4658 UseExisting=UseExisting,
4659 CompareMethod=self.CompareFixedPoints1D)
4660 hyp.SetPoints(points)
4661 hyp.SetNbSegments(nbSegs)
4662 hyp.SetReversedEdges(reversedEdges)
4663 hyp.SetObjectEntry(entry)
4667 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4668 ## as the given arguments
4669 def CompareFixedPoints1D(self, hyp, args):
4670 if hyp.GetPoints() == args[0]:
4671 if hyp.GetNbSegments() == args[1]:
4672 if hyp.GetReversedEdges() == args[2]:
4673 if not args[2] or hyp.GetObjectEntry() == args[3]:
4679 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4680 # @param start defines the length of the first segment
4681 # @param end defines the length of the last segment
4682 # @param reversedEdges is a list of edges to mesh using reversed orientation
4683 # @param UseExisting if ==true - searches for an existing hypothesis created with
4684 # the same parameters, else (default) - creates a new one
4685 # @return an instance of StdMeshers_StartEndLength hypothesis
4686 # @ingroup l3_hypos_1dhyps
4687 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4688 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4689 reversedEdges, UseExisting = [], reversedEdges
4690 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4691 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4692 entry = self.MainShapeEntry()
4693 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4694 UseExisting=UseExisting,
4695 CompareMethod=self.CompareStartEndLength)
4696 hyp.SetStartLength(start)
4697 hyp.SetEndLength(end)
4698 hyp.SetReversedEdges( reversedEdges )
4699 hyp.SetObjectEntry( entry )
4702 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4703 def CompareStartEndLength(self, hyp, args):
4704 if IsEqual(hyp.GetLength(1), args[0]):
4705 if IsEqual(hyp.GetLength(0), args[1]):
4706 if hyp.GetReversedEdges() == args[2]:
4707 if not args[2] or hyp.GetObjectEntry() == args[3]:
4711 ## Defines "Deflection1D" hypothesis
4712 # @param d for the deflection
4713 # @param UseExisting if ==true - searches for an existing hypothesis created with
4714 # the same parameters, else (default) - create a new one
4715 # @ingroup l3_hypos_1dhyps
4716 def Deflection1D(self, d, UseExisting=0):
4717 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4718 CompareMethod=self.CompareDeflection1D)
4719 hyp.SetDeflection(d)
4722 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4723 def CompareDeflection1D(self, hyp, args):
4724 return IsEqual(hyp.GetDeflection(), args[0])
4726 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4727 # the opposite side in case of quadrangular faces
4728 # @ingroup l3_hypos_additi
4729 def Propagation(self):
4730 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4732 ## Defines "AutomaticLength" hypothesis
4733 # @param fineness for the fineness [0-1]
4734 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4735 # same parameters, else (default) - create a new one
4736 # @ingroup l3_hypos_1dhyps
4737 def AutomaticLength(self, fineness=0, UseExisting=0):
4738 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4739 CompareMethod=self.CompareAutomaticLength)
4740 hyp.SetFineness( fineness )
4743 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4744 def CompareAutomaticLength(self, hyp, args):
4745 return IsEqual(hyp.GetFineness(), args[0])
4747 ## Defines "SegmentLengthAroundVertex" hypothesis
4748 # @param length for the segment length
4749 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4750 # Any other integer value means that the hypothesis will be set on the
4751 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4752 # @param UseExisting if ==true - searches for an existing hypothesis created with
4753 # the same parameters, else (default) - creates a new one
4754 # @ingroup l3_algos_segmarv
4755 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4757 store_geom = self.geom
4758 if type(vertex) is types.IntType:
4759 if vertex == 0 or vertex == 1:
4760 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4768 if self.geom is None:
4769 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4771 name = GetName(self.geom)
4774 piece = self.mesh.geom
4775 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4776 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4778 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4780 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4782 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4783 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4785 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4786 CompareMethod=self.CompareLengthNearVertex)
4787 self.geom = store_geom
4788 hyp.SetLength( length )
4791 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4792 # @ingroup l3_algos_segmarv
4793 def CompareLengthNearVertex(self, hyp, args):
4794 return IsEqual(hyp.GetLength(), args[0])
4796 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4797 # If the 2D mesher sees that all boundary edges are quadratic,
4798 # it generates quadratic faces, else it generates linear faces using
4799 # medium nodes as if they are vertices.
4800 # The 3D mesher generates quadratic volumes only if all boundary faces
4801 # are quadratic, else it fails.
4803 # @ingroup l3_hypos_additi
4804 def QuadraticMesh(self):
4805 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4808 # Public class: Mesh_CompositeSegment
4809 # --------------------------
4811 ## Defines a segment 1D algorithm for discretization
4813 # @ingroup l3_algos_basic
4814 class Mesh_CompositeSegment(Mesh_Segment):
4816 ## Private constructor.
4817 def __init__(self, mesh, geom=0):
4818 self.Create(mesh, geom, "CompositeSegment_1D")
4821 # Public class: Mesh_Segment_Python
4822 # ---------------------------------
4824 ## Defines a segment 1D algorithm for discretization with python function
4826 # @ingroup l3_algos_basic
4827 class Mesh_Segment_Python(Mesh_Segment):
4829 ## Private constructor.
4830 def __init__(self, mesh, geom=0):
4831 import Python1dPlugin
4832 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4834 ## Defines "PythonSplit1D" hypothesis
4835 # @param n for the number of segments that cut an edge
4836 # @param func for the python function that calculates the length of all segments
4837 # @param UseExisting if ==true - searches for the existing hypothesis created with
4838 # the same parameters, else (default) - creates a new one
4839 # @ingroup l3_hypos_1dhyps
4840 def PythonSplit1D(self, n, func, UseExisting=0):
4841 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4842 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4843 hyp.SetNumberOfSegments(n)
4844 hyp.SetPythonLog10RatioFunction(func)
4847 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4848 def ComparePythonSplit1D(self, hyp, args):
4849 #if hyp.GetNumberOfSegments() == args[0]:
4850 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4854 # Public class: Mesh_Triangle
4855 # ---------------------------
4857 ## Defines a triangle 2D algorithm
4859 # @ingroup l3_algos_basic
4860 class Mesh_Triangle(Mesh_Algorithm):
4869 ## Private constructor.
4870 def __init__(self, mesh, algoType, geom=0):
4871 Mesh_Algorithm.__init__(self)
4873 self.algoType = algoType
4874 if algoType == MEFISTO:
4875 self.Create(mesh, geom, "MEFISTO_2D")
4877 elif algoType == BLSURF:
4879 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4880 #self.SetPhysicalMesh() - PAL19680
4881 elif algoType == NETGEN:
4883 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4885 elif algoType == NETGEN_2D:
4887 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4890 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4891 # @param area for the maximum area of each triangle
4892 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4893 # same parameters, else (default) - creates a new one
4895 # Only for algoType == MEFISTO || NETGEN_2D
4896 # @ingroup l3_hypos_2dhyps
4897 def MaxElementArea(self, area, UseExisting=0):
4898 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4899 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4900 CompareMethod=self.CompareMaxElementArea)
4901 elif self.algoType == NETGEN:
4902 hyp = self.Parameters(SIMPLE)
4903 hyp.SetMaxElementArea(area)
4906 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4907 def CompareMaxElementArea(self, hyp, args):
4908 return IsEqual(hyp.GetMaxElementArea(), args[0])
4910 ## Defines "LengthFromEdges" hypothesis to build triangles
4911 # based on the length of the edges taken from the wire
4913 # Only for algoType == MEFISTO || NETGEN_2D
4914 # @ingroup l3_hypos_2dhyps
4915 def LengthFromEdges(self):
4916 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4917 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4919 elif self.algoType == NETGEN:
4920 hyp = self.Parameters(SIMPLE)
4921 hyp.LengthFromEdges()
4924 ## Sets a way to define size of mesh elements to generate.
4925 # @param thePhysicalMesh is: DefaultSize or Custom.
4926 # @ingroup l3_hypos_blsurf
4927 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4928 # Parameter of BLSURF algo
4929 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4931 ## Sets size of mesh elements to generate.
4932 # @ingroup l3_hypos_blsurf
4933 def SetPhySize(self, theVal):
4934 # Parameter of BLSURF algo
4935 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4936 self.Parameters().SetPhySize(theVal)
4938 ## Sets lower boundary of mesh element size (PhySize).
4939 # @ingroup l3_hypos_blsurf
4940 def SetPhyMin(self, theVal=-1):
4941 # Parameter of BLSURF algo
4942 self.Parameters().SetPhyMin(theVal)
4944 ## Sets upper boundary of mesh element size (PhySize).
4945 # @ingroup l3_hypos_blsurf
4946 def SetPhyMax(self, theVal=-1):
4947 # Parameter of BLSURF algo
4948 self.Parameters().SetPhyMax(theVal)
4950 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4951 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4952 # @ingroup l3_hypos_blsurf
4953 def SetGeometricMesh(self, theGeometricMesh=0):
4954 # Parameter of BLSURF algo
4955 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4956 self.params.SetGeometricMesh(theGeometricMesh)
4958 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4959 # @ingroup l3_hypos_blsurf
4960 def SetAngleMeshS(self, theVal=_angleMeshS):
4961 # Parameter of BLSURF algo
4962 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4963 self.params.SetAngleMeshS(theVal)
4965 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4966 # @ingroup l3_hypos_blsurf
4967 def SetAngleMeshC(self, theVal=_angleMeshS):
4968 # Parameter of BLSURF algo
4969 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4970 self.params.SetAngleMeshC(theVal)
4972 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4973 # @ingroup l3_hypos_blsurf
4974 def SetGeoMin(self, theVal=-1):
4975 # Parameter of BLSURF algo
4976 self.Parameters().SetGeoMin(theVal)
4978 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4979 # @ingroup l3_hypos_blsurf
4980 def SetGeoMax(self, theVal=-1):
4981 # Parameter of BLSURF algo
4982 self.Parameters().SetGeoMax(theVal)
4984 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4985 # @ingroup l3_hypos_blsurf
4986 def SetGradation(self, theVal=_gradation):
4987 # Parameter of BLSURF algo
4988 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4989 self.params.SetGradation(theVal)
4991 ## Sets topology usage way.
4992 # @param way defines how mesh conformity is assured <ul>
4993 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4994 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4995 # @ingroup l3_hypos_blsurf
4996 def SetTopology(self, way):
4997 # Parameter of BLSURF algo
4998 self.Parameters().SetTopology(way)
5000 ## To respect geometrical edges or not.
5001 # @ingroup l3_hypos_blsurf
5002 def SetDecimesh(self, toIgnoreEdges=False):
5003 # Parameter of BLSURF algo
5004 self.Parameters().SetDecimesh(toIgnoreEdges)
5006 ## Sets verbosity level in the range 0 to 100.
5007 # @ingroup l3_hypos_blsurf
5008 def SetVerbosity(self, level):
5009 # Parameter of BLSURF algo
5010 self.Parameters().SetVerbosity(level)
5012 ## Sets advanced option value.
5013 # @ingroup l3_hypos_blsurf
5014 def SetOptionValue(self, optionName, level):
5015 # Parameter of BLSURF algo
5016 self.Parameters().SetOptionValue(optionName,level)
5018 ## Sets QuadAllowed flag.
5019 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5020 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5021 def SetQuadAllowed(self, toAllow=True):
5022 if self.algoType == NETGEN_2D:
5025 hasSimpleHyps = False
5026 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5027 for hyp in self.mesh.GetHypothesisList( self.geom ):
5028 if hyp.GetName() in simpleHyps:
5029 hasSimpleHyps = True
5030 if hyp.GetName() == "QuadranglePreference":
5031 if not toAllow: # remove QuadranglePreference
5032 self.mesh.RemoveHypothesis( self.geom, hyp )
5038 if toAllow: # add QuadranglePreference
5039 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5044 if self.Parameters():
5045 self.params.SetQuadAllowed(toAllow)
5048 ## Defines hypothesis having several parameters
5050 # @ingroup l3_hypos_netgen
5051 def Parameters(self, which=SOLE):
5053 if self.algoType == NETGEN:
5055 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5056 "libNETGENEngine.so", UseExisting=0)
5058 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5059 "libNETGENEngine.so", UseExisting=0)
5060 elif self.algoType == MEFISTO:
5061 print "Mefisto algo support no multi-parameter hypothesis"
5062 elif self.algoType == NETGEN_2D:
5063 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5064 "libNETGENEngine.so", UseExisting=0)
5065 elif self.algoType == BLSURF:
5066 self.params = self.Hypothesis("BLSURF_Parameters", [],
5067 "libBLSURFEngine.so", UseExisting=0)
5069 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5074 # Only for algoType == NETGEN
5075 # @ingroup l3_hypos_netgen
5076 def SetMaxSize(self, theSize):
5077 if self.Parameters():
5078 self.params.SetMaxSize(theSize)
5080 ## Sets SecondOrder flag
5082 # Only for algoType == NETGEN
5083 # @ingroup l3_hypos_netgen
5084 def SetSecondOrder(self, theVal):
5085 if self.Parameters():
5086 self.params.SetSecondOrder(theVal)
5088 ## Sets Optimize flag
5090 # Only for algoType == NETGEN
5091 # @ingroup l3_hypos_netgen
5092 def SetOptimize(self, theVal):
5093 if self.Parameters():
5094 self.params.SetOptimize(theVal)
5097 # @param theFineness is:
5098 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5100 # Only for algoType == NETGEN
5101 # @ingroup l3_hypos_netgen
5102 def SetFineness(self, theFineness):
5103 if self.Parameters():
5104 self.params.SetFineness(theFineness)
5108 # Only for algoType == NETGEN
5109 # @ingroup l3_hypos_netgen
5110 def SetGrowthRate(self, theRate):
5111 if self.Parameters():
5112 self.params.SetGrowthRate(theRate)
5114 ## Sets NbSegPerEdge
5116 # Only for algoType == NETGEN
5117 # @ingroup l3_hypos_netgen
5118 def SetNbSegPerEdge(self, theVal):
5119 if self.Parameters():
5120 self.params.SetNbSegPerEdge(theVal)
5122 ## Sets NbSegPerRadius
5124 # Only for algoType == NETGEN
5125 # @ingroup l3_hypos_netgen
5126 def SetNbSegPerRadius(self, theVal):
5127 if self.Parameters():
5128 self.params.SetNbSegPerRadius(theVal)
5130 ## Sets number of segments overriding value set by SetLocalLength()
5132 # Only for algoType == NETGEN
5133 # @ingroup l3_hypos_netgen
5134 def SetNumberOfSegments(self, theVal):
5135 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5137 ## Sets number of segments overriding value set by SetNumberOfSegments()
5139 # Only for algoType == NETGEN
5140 # @ingroup l3_hypos_netgen
5141 def SetLocalLength(self, theVal):
5142 self.Parameters(SIMPLE).SetLocalLength(theVal)
5147 # Public class: Mesh_Quadrangle
5148 # -----------------------------
5150 ## Defines a quadrangle 2D algorithm
5152 # @ingroup l3_algos_basic
5153 class Mesh_Quadrangle(Mesh_Algorithm):
5157 ## Private constructor.
5158 def __init__(self, mesh, geom=0):
5159 Mesh_Algorithm.__init__(self)
5160 self.Create(mesh, geom, "Quadrangle_2D")
5163 ## Defines "QuadrangleParameters" hypothesis
5164 # @param quadType defines the algorithm of transition between differently descretized
5165 # sides of a geometrical face:
5166 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5167 # area along the finer meshed sides.
5168 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5169 # finer meshed sides.
5170 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5171 # the finer meshed sides, iff the total quantity of segments on
5172 # all four sides of the face is even (divisible by 2).
5173 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5174 # area is located along the coarser meshed sides.
5175 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5176 # is made gradually, layer by layer. This type has a limitation on
5177 # the number of segments: one pair of opposite sides must have the
5178 # same number of segments, the other pair must have an even difference
5179 # between the numbers of segments on the sides.
5180 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5181 # will be created while other elements will be quadrangles.
5182 # Vertex can be either a GEOM_Object or a vertex ID within the
5184 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5185 # the same parameters, else (default) - creates a new one
5186 # @ingroup l3_hypos_quad
5187 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5188 vertexID = triangleVertex
5189 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5190 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5192 compFun = lambda hyp,args: \
5193 hyp.GetQuadType() == args[0] and \
5194 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5195 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5196 UseExisting = UseExisting, CompareMethod=compFun)
5198 if self.params.GetQuadType() != quadType:
5199 self.params.SetQuadType(quadType)
5201 self.params.SetTriaVertex( vertexID )
5204 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5205 # quadrangles are built in the transition area along the finer meshed sides,
5206 # iff the total quantity of segments on all four sides of the face is even.
5207 # @param reversed if True, transition area is located along the coarser meshed sides.
5208 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5209 # the same parameters, else (default) - creates a new one
5210 # @ingroup l3_hypos_quad
5211 def QuadranglePreference(self, reversed=False, UseExisting=0):
5213 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5214 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5216 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5217 # triangles are built in the transition area along the finer meshed sides.
5218 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5219 # the same parameters, else (default) - creates a new one
5220 # @ingroup l3_hypos_quad
5221 def TrianglePreference(self, UseExisting=0):
5222 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5224 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5225 # quadrangles are built and the transition between the sides is made gradually,
5226 # layer by layer. This type has a limitation on the number of segments: one pair
5227 # of opposite sides must have the same number of segments, the other pair must
5228 # have an even difference between the numbers of segments on the sides.
5229 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5230 # the same parameters, else (default) - creates a new one
5231 # @ingroup l3_hypos_quad
5232 def Reduced(self, UseExisting=0):
5233 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5235 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5236 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5237 # will be created while other elements will be quadrangles.
5238 # Vertex can be either a GEOM_Object or a vertex ID within the
5240 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5241 # the same parameters, else (default) - creates a new one
5242 # @ingroup l3_hypos_quad
5243 def TriangleVertex(self, vertex, UseExisting=0):
5244 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5247 # Public class: Mesh_Tetrahedron
5248 # ------------------------------
5250 ## Defines a tetrahedron 3D algorithm
5252 # @ingroup l3_algos_basic
5253 class Mesh_Tetrahedron(Mesh_Algorithm):
5258 ## Private constructor.
5259 def __init__(self, mesh, algoType, geom=0):
5260 Mesh_Algorithm.__init__(self)
5262 if algoType == NETGEN:
5264 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5267 elif algoType == FULL_NETGEN:
5269 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5272 elif algoType == GHS3D:
5274 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5277 elif algoType == GHS3DPRL:
5278 CheckPlugin(GHS3DPRL)
5279 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5282 self.algoType = algoType
5284 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5285 # @param vol for the maximum volume of each tetrahedron
5286 # @param UseExisting if ==true - searches for the existing hypothesis created with
5287 # the same parameters, else (default) - creates a new one
5288 # @ingroup l3_hypos_maxvol
5289 def MaxElementVolume(self, vol, UseExisting=0):
5290 if self.algoType == NETGEN:
5291 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5292 CompareMethod=self.CompareMaxElementVolume)
5293 hyp.SetMaxElementVolume(vol)
5295 elif self.algoType == FULL_NETGEN:
5296 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5299 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5300 def CompareMaxElementVolume(self, hyp, args):
5301 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5303 ## Defines hypothesis having several parameters
5305 # @ingroup l3_hypos_netgen
5306 def Parameters(self, which=SOLE):
5309 if self.algoType == FULL_NETGEN:
5311 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5312 "libNETGENEngine.so", UseExisting=0)
5314 self.params = self.Hypothesis("NETGEN_Parameters", [],
5315 "libNETGENEngine.so", UseExisting=0)
5317 elif self.algoType == NETGEN:
5318 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5319 "libNETGENEngine.so", UseExisting=0)
5321 elif self.algoType == GHS3D:
5322 self.params = self.Hypothesis("GHS3D_Parameters", [],
5323 "libGHS3DEngine.so", UseExisting=0)
5325 elif self.algoType == GHS3DPRL:
5326 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5327 "libGHS3DPRLEngine.so", UseExisting=0)
5329 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5334 # Parameter of FULL_NETGEN and NETGEN
5335 # @ingroup l3_hypos_netgen
5336 def SetMaxSize(self, theSize):
5337 self.Parameters().SetMaxSize(theSize)
5339 ## Sets SecondOrder flag
5340 # Parameter of FULL_NETGEN
5341 # @ingroup l3_hypos_netgen
5342 def SetSecondOrder(self, theVal):
5343 self.Parameters().SetSecondOrder(theVal)
5345 ## Sets Optimize flag
5346 # Parameter of FULL_NETGEN and NETGEN
5347 # @ingroup l3_hypos_netgen
5348 def SetOptimize(self, theVal):
5349 self.Parameters().SetOptimize(theVal)
5352 # @param theFineness is:
5353 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5354 # Parameter of FULL_NETGEN
5355 # @ingroup l3_hypos_netgen
5356 def SetFineness(self, theFineness):
5357 self.Parameters().SetFineness(theFineness)
5360 # Parameter of FULL_NETGEN
5361 # @ingroup l3_hypos_netgen
5362 def SetGrowthRate(self, theRate):
5363 self.Parameters().SetGrowthRate(theRate)
5365 ## Sets NbSegPerEdge
5366 # Parameter of FULL_NETGEN
5367 # @ingroup l3_hypos_netgen
5368 def SetNbSegPerEdge(self, theVal):
5369 self.Parameters().SetNbSegPerEdge(theVal)
5371 ## Sets NbSegPerRadius
5372 # Parameter of FULL_NETGEN
5373 # @ingroup l3_hypos_netgen
5374 def SetNbSegPerRadius(self, theVal):
5375 self.Parameters().SetNbSegPerRadius(theVal)
5377 ## Sets number of segments overriding value set by SetLocalLength()
5378 # Only for algoType == NETGEN_FULL
5379 # @ingroup l3_hypos_netgen
5380 def SetNumberOfSegments(self, theVal):
5381 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5383 ## Sets number of segments overriding value set by SetNumberOfSegments()
5384 # Only for algoType == NETGEN_FULL
5385 # @ingroup l3_hypos_netgen
5386 def SetLocalLength(self, theVal):
5387 self.Parameters(SIMPLE).SetLocalLength(theVal)
5389 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5390 # Overrides value set by LengthFromEdges()
5391 # Only for algoType == NETGEN_FULL
5392 # @ingroup l3_hypos_netgen
5393 def MaxElementArea(self, area):
5394 self.Parameters(SIMPLE).SetMaxElementArea(area)
5396 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5397 # Overrides value set by MaxElementArea()
5398 # Only for algoType == NETGEN_FULL
5399 # @ingroup l3_hypos_netgen
5400 def LengthFromEdges(self):
5401 self.Parameters(SIMPLE).LengthFromEdges()
5403 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5404 # Overrides value set by MaxElementVolume()
5405 # Only for algoType == NETGEN_FULL
5406 # @ingroup l3_hypos_netgen
5407 def LengthFromFaces(self):
5408 self.Parameters(SIMPLE).LengthFromFaces()
5410 ## To mesh "holes" in a solid or not. Default is to mesh.
5411 # @ingroup l3_hypos_ghs3dh
5412 def SetToMeshHoles(self, toMesh):
5413 # Parameter of GHS3D
5414 self.Parameters().SetToMeshHoles(toMesh)
5416 ## Set Optimization level:
5417 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5418 # Strong_Optimization.
5419 # Default is Standard_Optimization
5420 # @ingroup l3_hypos_ghs3dh
5421 def SetOptimizationLevel(self, level):
5422 # Parameter of GHS3D
5423 self.Parameters().SetOptimizationLevel(level)
5425 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5426 # @ingroup l3_hypos_ghs3dh
5427 def SetMaximumMemory(self, MB):
5428 # Advanced parameter of GHS3D
5429 self.Parameters().SetMaximumMemory(MB)
5431 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5432 # automatic memory adjustment mode.
5433 # @ingroup l3_hypos_ghs3dh
5434 def SetInitialMemory(self, MB):
5435 # Advanced parameter of GHS3D
5436 self.Parameters().SetInitialMemory(MB)
5438 ## Path to working directory.
5439 # @ingroup l3_hypos_ghs3dh
5440 def SetWorkingDirectory(self, path):
5441 # Advanced parameter of GHS3D
5442 self.Parameters().SetWorkingDirectory(path)
5444 ## To keep working files or remove them. Log file remains in case of errors anyway.
5445 # @ingroup l3_hypos_ghs3dh
5446 def SetKeepFiles(self, toKeep):
5447 # Advanced parameter of GHS3D and GHS3DPRL
5448 self.Parameters().SetKeepFiles(toKeep)
5450 ## To set verbose level [0-10]. <ul>
5451 #<li> 0 - no standard output,
5452 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5453 # indicates when the final mesh is being saved. In addition the software
5454 # gives indication regarding the CPU time.
5455 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5456 # histogram of the skin mesh, quality statistics histogram together with
5457 # the characteristics of the final mesh.</ul>
5458 # @ingroup l3_hypos_ghs3dh
5459 def SetVerboseLevel(self, level):
5460 # Advanced parameter of GHS3D
5461 self.Parameters().SetVerboseLevel(level)
5463 ## To create new nodes.
5464 # @ingroup l3_hypos_ghs3dh
5465 def SetToCreateNewNodes(self, toCreate):
5466 # Advanced parameter of GHS3D
5467 self.Parameters().SetToCreateNewNodes(toCreate)
5469 ## To use boundary recovery version which tries to create mesh on a very poor
5470 # quality surface mesh.
5471 # @ingroup l3_hypos_ghs3dh
5472 def SetToUseBoundaryRecoveryVersion(self, toUse):
5473 # Advanced parameter of GHS3D
5474 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5476 ## Sets command line option as text.
5477 # @ingroup l3_hypos_ghs3dh
5478 def SetTextOption(self, option):
5479 # Advanced parameter of GHS3D
5480 self.Parameters().SetTextOption(option)
5482 ## Sets MED files name and path.
5483 def SetMEDName(self, value):
5484 self.Parameters().SetMEDName(value)
5486 ## Sets the number of partition of the initial mesh
5487 def SetNbPart(self, value):
5488 self.Parameters().SetNbPart(value)
5490 ## When big mesh, start tepal in background
5491 def SetBackground(self, value):
5492 self.Parameters().SetBackground(value)
5494 # Public class: Mesh_Hexahedron
5495 # ------------------------------
5497 ## Defines a hexahedron 3D algorithm
5499 # @ingroup l3_algos_basic
5500 class Mesh_Hexahedron(Mesh_Algorithm):
5505 ## Private constructor.
5506 def __init__(self, mesh, algoType=Hexa, geom=0):
5507 Mesh_Algorithm.__init__(self)
5509 self.algoType = algoType
5511 if algoType == Hexa:
5512 self.Create(mesh, geom, "Hexa_3D")
5515 elif algoType == Hexotic:
5516 CheckPlugin(Hexotic)
5517 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5520 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5521 # @ingroup l3_hypos_hexotic
5522 def MinMaxQuad(self, min=3, max=8, quad=True):
5523 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5525 self.params.SetHexesMinLevel(min)
5526 self.params.SetHexesMaxLevel(max)
5527 self.params.SetHexoticQuadrangles(quad)
5530 # Deprecated, only for compatibility!
5531 # Public class: Mesh_Netgen
5532 # ------------------------------
5534 ## Defines a NETGEN-based 2D or 3D algorithm
5535 # that needs no discrete boundary (i.e. independent)
5537 # This class is deprecated, only for compatibility!
5540 # @ingroup l3_algos_basic
5541 class Mesh_Netgen(Mesh_Algorithm):
5545 ## Private constructor.
5546 def __init__(self, mesh, is3D, geom=0):
5547 Mesh_Algorithm.__init__(self)
5553 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5557 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5560 ## Defines the hypothesis containing parameters of the algorithm
5561 def Parameters(self):
5563 hyp = self.Hypothesis("NETGEN_Parameters", [],
5564 "libNETGENEngine.so", UseExisting=0)
5566 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5567 "libNETGENEngine.so", UseExisting=0)
5570 # Public class: Mesh_Projection1D
5571 # ------------------------------
5573 ## Defines a projection 1D algorithm
5574 # @ingroup l3_algos_proj
5576 class Mesh_Projection1D(Mesh_Algorithm):
5578 ## Private constructor.
5579 def __init__(self, mesh, geom=0):
5580 Mesh_Algorithm.__init__(self)
5581 self.Create(mesh, geom, "Projection_1D")
5583 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5584 # a mesh pattern is taken, and, optionally, the association of vertices
5585 # between the source edge and a target edge (to which a hypothesis is assigned)
5586 # @param edge from which nodes distribution is taken
5587 # @param mesh from which nodes distribution is taken (optional)
5588 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5589 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5590 # to associate with \a srcV (optional)
5591 # @param UseExisting if ==true - searches for the existing hypothesis created with
5592 # the same parameters, else (default) - creates a new one
5593 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5594 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5596 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5597 hyp.SetSourceEdge( edge )
5598 if not mesh is None and isinstance(mesh, Mesh):
5599 mesh = mesh.GetMesh()
5600 hyp.SetSourceMesh( mesh )
5601 hyp.SetVertexAssociation( srcV, tgtV )
5604 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5605 #def CompareSourceEdge(self, hyp, args):
5606 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5610 # Public class: Mesh_Projection2D
5611 # ------------------------------
5613 ## Defines a projection 2D algorithm
5614 # @ingroup l3_algos_proj
5616 class Mesh_Projection2D(Mesh_Algorithm):
5618 ## Private constructor.
5619 def __init__(self, mesh, geom=0):
5620 Mesh_Algorithm.__init__(self)
5621 self.Create(mesh, geom, "Projection_2D")
5623 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5624 # a mesh pattern is taken, and, optionally, the association of vertices
5625 # between the source face and the target face (to which a hypothesis is assigned)
5626 # @param face from which the mesh pattern is taken
5627 # @param mesh from which the mesh pattern is taken (optional)
5628 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5629 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5630 # to associate with \a srcV1 (optional)
5631 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5632 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5633 # to associate with \a srcV2 (optional)
5634 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5635 # the same parameters, else (default) - forces the creation a new one
5637 # Note: all association vertices must belong to one edge of a face
5638 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5639 srcV2=None, tgtV2=None, UseExisting=0):
5640 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5642 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5643 hyp.SetSourceFace( face )
5644 if not mesh is None and isinstance(mesh, Mesh):
5645 mesh = mesh.GetMesh()
5646 hyp.SetSourceMesh( mesh )
5647 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5650 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5651 #def CompareSourceFace(self, hyp, args):
5652 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5655 # Public class: Mesh_Projection3D
5656 # ------------------------------
5658 ## Defines a projection 3D algorithm
5659 # @ingroup l3_algos_proj
5661 class Mesh_Projection3D(Mesh_Algorithm):
5663 ## Private constructor.
5664 def __init__(self, mesh, geom=0):
5665 Mesh_Algorithm.__init__(self)
5666 self.Create(mesh, geom, "Projection_3D")
5668 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5669 # the mesh pattern is taken, and, optionally, the association of vertices
5670 # between the source and the target solid (to which a hipothesis is assigned)
5671 # @param solid from where the mesh pattern is taken
5672 # @param mesh from where the mesh pattern is taken (optional)
5673 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5674 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5675 # to associate with \a srcV1 (optional)
5676 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5677 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5678 # to associate with \a srcV2 (optional)
5679 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5680 # the same parameters, else (default) - creates a new one
5682 # Note: association vertices must belong to one edge of a solid
5683 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5684 srcV2=0, tgtV2=0, UseExisting=0):
5685 hyp = self.Hypothesis("ProjectionSource3D",
5686 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5688 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5689 hyp.SetSource3DShape( solid )
5690 if not mesh is None and isinstance(mesh, Mesh):
5691 mesh = mesh.GetMesh()
5692 hyp.SetSourceMesh( mesh )
5693 if srcV1 and srcV2 and tgtV1 and tgtV2:
5694 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5695 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5698 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5699 #def CompareSourceShape3D(self, hyp, args):
5700 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5704 # Public class: Mesh_Prism
5705 # ------------------------
5707 ## Defines a 3D extrusion algorithm
5708 # @ingroup l3_algos_3dextr
5710 class Mesh_Prism3D(Mesh_Algorithm):
5712 ## Private constructor.
5713 def __init__(self, mesh, geom=0):
5714 Mesh_Algorithm.__init__(self)
5715 self.Create(mesh, geom, "Prism_3D")
5717 # Public class: Mesh_RadialPrism
5718 # -------------------------------
5720 ## Defines a Radial Prism 3D algorithm
5721 # @ingroup l3_algos_radialp
5723 class Mesh_RadialPrism3D(Mesh_Algorithm):
5725 ## Private constructor.
5726 def __init__(self, mesh, geom=0):
5727 Mesh_Algorithm.__init__(self)
5728 self.Create(mesh, geom, "RadialPrism_3D")
5730 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5731 self.nbLayers = None
5733 ## Return 3D hypothesis holding the 1D one
5734 def Get3DHypothesis(self):
5735 return self.distribHyp
5737 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5738 # hypothesis. Returns the created hypothesis
5739 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5740 #print "OwnHypothesis",hypType
5741 if not self.nbLayers is None:
5742 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5743 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5744 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5745 self.mesh.smeshpyD.SetCurrentStudy( None )
5746 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5747 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5748 self.distribHyp.SetLayerDistribution( hyp )
5751 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5752 # prisms to build between the inner and outer shells
5753 # @param n number of layers
5754 # @param UseExisting if ==true - searches for the existing hypothesis created with
5755 # the same parameters, else (default) - creates a new one
5756 def NumberOfLayers(self, n, UseExisting=0):
5757 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5758 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5759 CompareMethod=self.CompareNumberOfLayers)
5760 self.nbLayers.SetNumberOfLayers( n )
5761 return self.nbLayers
5763 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5764 def CompareNumberOfLayers(self, hyp, args):
5765 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5767 ## Defines "LocalLength" hypothesis, specifying the segment length
5768 # to build between the inner and the outer shells
5769 # @param l the length of segments
5770 # @param p the precision of rounding
5771 def LocalLength(self, l, p=1e-07):
5772 hyp = self.OwnHypothesis("LocalLength", [l,p])
5777 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5778 # prisms to build between the inner and the outer shells.
5779 # @param n the number of layers
5780 # @param s the scale factor (optional)
5781 def NumberOfSegments(self, n, s=[]):
5783 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5785 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5786 hyp.SetDistrType( 1 )
5787 hyp.SetScaleFactor(s)
5788 hyp.SetNumberOfSegments(n)
5791 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5792 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5793 # @param start the length of the first segment
5794 # @param end the length of the last segment
5795 def Arithmetic1D(self, start, end ):
5796 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5797 hyp.SetLength(start, 1)
5798 hyp.SetLength(end , 0)
5801 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5802 # to build between the inner and the outer shells as geometric length increasing
5803 # @param start for the length of the first segment
5804 # @param end for the length of the last segment
5805 def StartEndLength(self, start, end):
5806 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5807 hyp.SetLength(start, 1)
5808 hyp.SetLength(end , 0)
5811 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5812 # to build between the inner and outer shells
5813 # @param fineness defines the quality of the mesh within the range [0-1]
5814 def AutomaticLength(self, fineness=0):
5815 hyp = self.OwnHypothesis("AutomaticLength")
5816 hyp.SetFineness( fineness )
5819 # Public class: Mesh_RadialQuadrangle1D2D
5820 # -------------------------------
5822 ## Defines a Radial Quadrangle 1D2D algorithm
5823 # @ingroup l2_algos_radialq
5825 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5827 ## Private constructor.
5828 def __init__(self, mesh, geom=0):
5829 Mesh_Algorithm.__init__(self)
5830 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5832 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5833 self.nbLayers = None
5835 ## Return 2D hypothesis holding the 1D one
5836 def Get2DHypothesis(self):
5837 return self.distribHyp
5839 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5840 # hypothesis. Returns the created hypothesis
5841 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5842 #print "OwnHypothesis",hypType
5844 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5845 if self.distribHyp is None:
5846 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5848 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5849 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5850 self.mesh.smeshpyD.SetCurrentStudy( None )
5851 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5852 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5853 self.distribHyp.SetLayerDistribution( hyp )
5856 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5857 # @param n number of layers
5858 # @param UseExisting if ==true - searches for the existing hypothesis created with
5859 # the same parameters, else (default) - creates a new one
5860 def NumberOfLayers(self, n, UseExisting=0):
5862 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5863 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5864 CompareMethod=self.CompareNumberOfLayers)
5865 self.nbLayers.SetNumberOfLayers( n )
5866 return self.nbLayers
5868 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5869 def CompareNumberOfLayers(self, hyp, args):
5870 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5872 ## Defines "LocalLength" hypothesis, specifying the segment length
5873 # @param l the length of segments
5874 # @param p the precision of rounding
5875 def LocalLength(self, l, p=1e-07):
5876 hyp = self.OwnHypothesis("LocalLength", [l,p])
5881 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5882 # @param n the number of layers
5883 # @param s the scale factor (optional)
5884 def NumberOfSegments(self, n, s=[]):
5886 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5888 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5889 hyp.SetDistrType( 1 )
5890 hyp.SetScaleFactor(s)
5891 hyp.SetNumberOfSegments(n)
5894 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5895 # with a length that changes in arithmetic progression
5896 # @param start the length of the first segment
5897 # @param end the length of the last segment
5898 def Arithmetic1D(self, start, end ):
5899 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5900 hyp.SetLength(start, 1)
5901 hyp.SetLength(end , 0)
5904 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5905 # as geometric length increasing
5906 # @param start for the length of the first segment
5907 # @param end for the length of the last segment
5908 def StartEndLength(self, start, end):
5909 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5910 hyp.SetLength(start, 1)
5911 hyp.SetLength(end , 0)
5914 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5915 # @param fineness defines the quality of the mesh within the range [0-1]
5916 def AutomaticLength(self, fineness=0):
5917 hyp = self.OwnHypothesis("AutomaticLength")
5918 hyp.SetFineness( fineness )
5922 # Public class: Mesh_UseExistingElements
5923 # --------------------------------------
5924 ## Defines a Radial Quadrangle 1D2D algorithm
5925 # @ingroup l3_algos_basic
5927 class Mesh_UseExistingElements(Mesh_Algorithm):
5929 def __init__(self, dim, mesh, geom=0):
5931 self.Create(mesh, geom, "Import_1D")
5933 self.Create(mesh, geom, "Import_1D2D")
5936 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5937 # @param groups list of groups of edges
5938 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5939 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5940 # @param UseExisting if ==true - searches for the existing hypothesis created with
5941 # the same parameters, else (default) - creates a new one
5942 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5943 if self.algo.GetName() == "Import_2D":
5944 raise ValueError, "algoritm dimension mismatch"
5945 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5946 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5947 hyp.SetSourceEdges(groups)
5948 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5951 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5952 # @param groups list of groups of faces
5953 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5954 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5955 # @param UseExisting if ==true - searches for the existing hypothesis created with
5956 # the same parameters, else (default) - creates a new one
5957 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5958 if self.algo.GetName() == "Import_1D":
5959 raise ValueError, "algoritm dimension mismatch"
5960 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5961 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5962 hyp.SetSourceFaces(groups)
5963 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5966 def _compareHyp(self,hyp,args):
5967 if hasattr( hyp, "GetSourceEdges"):
5968 entries = hyp.GetSourceEdges()
5970 entries = hyp.GetSourceFaces()
5972 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5973 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5975 study = self.mesh.smeshpyD.GetCurrentStudy()
5978 ior = salome.orb.object_to_string(g)
5979 sobj = study.FindObjectIOR(ior)
5980 if sobj: entries2.append( sobj.GetID() )
5985 return entries == entries2
5989 # Private class: Mesh_UseExisting
5990 # -------------------------------
5991 class Mesh_UseExisting(Mesh_Algorithm):
5993 def __init__(self, dim, mesh, geom=0):
5995 self.Create(mesh, geom, "UseExisting_1D")
5997 self.Create(mesh, geom, "UseExisting_2D")
6000 import salome_notebook
6001 notebook = salome_notebook.notebook
6003 ##Return values of the notebook variables
6004 def ParseParameters(last, nbParams,nbParam, value):
6008 listSize = len(last)
6009 for n in range(0,nbParams):
6011 if counter < listSize:
6012 strResult = strResult + last[counter]
6014 strResult = strResult + ""
6016 if isinstance(value, str):
6017 if notebook.isVariable(value):
6018 result = notebook.get(value)
6019 strResult=strResult+value
6021 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6023 strResult=strResult+str(value)
6025 if nbParams - 1 != counter:
6026 strResult=strResult+var_separator #":"
6028 return result, strResult
6030 #Wrapper class for StdMeshers_LocalLength hypothesis
6031 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6033 ## Set Length parameter value
6034 # @param length numerical value or name of variable from notebook
6035 def SetLength(self, length):
6036 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6037 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6038 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6040 ## Set Precision parameter value
6041 # @param precision numerical value or name of variable from notebook
6042 def SetPrecision(self, precision):
6043 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6044 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6045 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6047 #Registering the new proxy for LocalLength
6048 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6051 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6052 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6054 def SetLayerDistribution(self, hypo):
6055 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6056 hypo.ClearParameters();
6057 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6059 #Registering the new proxy for LayerDistribution
6060 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6062 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6063 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6065 ## Set Length parameter value
6066 # @param length numerical value or name of variable from notebook
6067 def SetLength(self, length):
6068 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6069 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6070 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6072 #Registering the new proxy for SegmentLengthAroundVertex
6073 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6076 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6077 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6079 ## Set Length parameter value
6080 # @param length numerical value or name of variable from notebook
6081 # @param isStart true is length is Start Length, otherwise false
6082 def SetLength(self, length, isStart):
6086 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6087 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6088 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6090 #Registering the new proxy for Arithmetic1D
6091 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6093 #Wrapper class for StdMeshers_Deflection1D hypothesis
6094 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6096 ## Set Deflection parameter value
6097 # @param deflection numerical value or name of variable from notebook
6098 def SetDeflection(self, deflection):
6099 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6100 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6101 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6103 #Registering the new proxy for Deflection1D
6104 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6106 #Wrapper class for StdMeshers_StartEndLength hypothesis
6107 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6109 ## Set Length parameter value
6110 # @param length numerical value or name of variable from notebook
6111 # @param isStart true is length is Start Length, otherwise false
6112 def SetLength(self, length, isStart):
6116 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6117 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6118 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6120 #Registering the new proxy for StartEndLength
6121 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6123 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6124 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6126 ## Set Max Element Area parameter value
6127 # @param area numerical value or name of variable from notebook
6128 def SetMaxElementArea(self, area):
6129 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6130 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6131 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6133 #Registering the new proxy for MaxElementArea
6134 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6137 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6138 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6140 ## Set Max Element Volume parameter value
6141 # @param volume numerical value or name of variable from notebook
6142 def SetMaxElementVolume(self, volume):
6143 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6144 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6145 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6147 #Registering the new proxy for MaxElementVolume
6148 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6151 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6152 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6154 ## Set Number Of Layers parameter value
6155 # @param nbLayers numerical value or name of variable from notebook
6156 def SetNumberOfLayers(self, nbLayers):
6157 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6158 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6159 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6161 #Registering the new proxy for NumberOfLayers
6162 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6164 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6165 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6167 ## Set Number Of Segments parameter value
6168 # @param nbSeg numerical value or name of variable from notebook
6169 def SetNumberOfSegments(self, nbSeg):
6170 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6171 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6172 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6173 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6175 ## Set Scale Factor parameter value
6176 # @param factor numerical value or name of variable from notebook
6177 def SetScaleFactor(self, factor):
6178 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6179 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6180 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6182 #Registering the new proxy for NumberOfSegments
6183 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6185 if not noNETGENPlugin:
6186 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6187 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6189 ## Set Max Size parameter value
6190 # @param maxsize numerical value or name of variable from notebook
6191 def SetMaxSize(self, maxsize):
6192 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6193 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6194 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6195 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6197 ## Set Growth Rate parameter value
6198 # @param value numerical value or name of variable from notebook
6199 def SetGrowthRate(self, value):
6200 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6201 value, parameters = ParseParameters(lastParameters,4,2,value)
6202 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6203 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6205 ## Set Number of Segments per Edge parameter value
6206 # @param value numerical value or name of variable from notebook
6207 def SetNbSegPerEdge(self, value):
6208 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6209 value, parameters = ParseParameters(lastParameters,4,3,value)
6210 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6211 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6213 ## Set Number of Segments per Radius parameter value
6214 # @param value numerical value or name of variable from notebook
6215 def SetNbSegPerRadius(self, value):
6216 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6217 value, parameters = ParseParameters(lastParameters,4,4,value)
6218 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6219 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6221 #Registering the new proxy for NETGENPlugin_Hypothesis
6222 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6225 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6226 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6229 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6230 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6232 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6233 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6235 ## Set Number of Segments parameter value
6236 # @param nbSeg numerical value or name of variable from notebook
6237 def SetNumberOfSegments(self, nbSeg):
6238 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6239 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6240 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6241 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6243 ## Set Local Length parameter value
6244 # @param length numerical value or name of variable from notebook
6245 def SetLocalLength(self, length):
6246 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6247 length, parameters = ParseParameters(lastParameters,2,1,length)
6248 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6249 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6251 ## Set Max Element Area parameter value
6252 # @param area numerical value or name of variable from notebook
6253 def SetMaxElementArea(self, area):
6254 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6255 area, parameters = ParseParameters(lastParameters,2,2,area)
6256 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6257 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6259 def LengthFromEdges(self):
6260 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6262 value, parameters = ParseParameters(lastParameters,2,2,value)
6263 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6264 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6266 #Registering the new proxy for NETGEN_SimpleParameters_2D
6267 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6270 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6271 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6272 ## Set Max Element Volume parameter value
6273 # @param volume numerical value or name of variable from notebook
6274 def SetMaxElementVolume(self, volume):
6275 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6276 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6277 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6278 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6280 def LengthFromFaces(self):
6281 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6283 value, parameters = ParseParameters(lastParameters,3,3,value)
6284 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6285 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6287 #Registering the new proxy for NETGEN_SimpleParameters_3D
6288 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6290 pass # if not noNETGENPlugin:
6292 class Pattern(SMESH._objref_SMESH_Pattern):
6294 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6296 if isinstance(theNodeIndexOnKeyPoint1,str):
6298 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6300 theNodeIndexOnKeyPoint1 -= 1
6301 theMesh.SetParameters(Parameters)
6302 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6304 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6307 if isinstance(theNode000Index,str):
6309 if isinstance(theNode001Index,str):
6311 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6313 theNode000Index -= 1
6315 theNode001Index -= 1
6316 theMesh.SetParameters(Parameters)
6317 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6319 #Registering the new proxy for Pattern
6320 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)