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 edge 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 # @ingroup l2_modif_tofromqu
3065 def ConvertToQuadratic(self, theForce3d):
3066 self.editor.ConvertToQuadratic(theForce3d)
3068 ## Converts the mesh from quadratic to ordinary,
3069 # deletes old quadratic elements, \n replacing
3070 # them with ordinary mesh elements with the same id.
3071 # @return TRUE in case of success, FALSE otherwise.
3072 # @ingroup l2_modif_tofromqu
3073 def ConvertFromQuadratic(self):
3074 return self.editor.ConvertFromQuadratic()
3076 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3077 # @return TRUE if operation has been completed successfully, FALSE otherwise
3078 # @ingroup l2_modif_edit
3079 def Make2DMeshFrom3D(self):
3080 return self.editor. Make2DMeshFrom3D()
3082 ## Creates missing boundary elements
3083 # @param elements - elements whose boundary is to be checked:
3084 # mesh, group, sub-mesh or list of elements
3085 # if elements is mesh, it must be the mesh whose MakeBoundaryMesh() is called
3086 # @param dimension - defines type of boundary elements to create:
3087 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3088 # SMESH.BND_1DFROM3D creates mesh edges on all borders of free facets of 3D cells
3089 # @param groupName - a name of group to store created boundary elements in,
3090 # "" means not to create the group
3091 # @param meshName - a name of new mesh to store created boundary elements in,
3092 # "" means not to create the new mesh
3093 # @param toCopyElements - if true, the checked elements will be copied into
3094 # the new mesh else only boundary elements will be copied into the new mesh
3095 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3096 # boundary elements will be copied into the new mesh
3097 # @return tuple (mesh, group) where bondary elements were added to
3098 # @ingroup l2_modif_edit
3099 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3100 toCopyElements=False, toCopyExistingBondary=False):
3101 if isinstance( elements, Mesh ):
3102 elements = elements.GetMesh()
3103 if ( isinstance( elements, list )):
3104 elemType = SMESH.ALL
3105 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3106 elements = self.editor.MakeIDSource(elements, elemType)
3107 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3108 toCopyElements,toCopyExistingBondary)
3109 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3113 # @brief Creates missing boundary elements around either the whole mesh or
3114 # groups of 2D elements
3115 # @param dimension - defines type of boundary elements to create
3116 # @param groupName - a name of group to store all boundary elements in,
3117 # "" means not to create the group
3118 # @param meshName - a name of a new mesh, which is a copy of the initial
3119 # mesh + created boundary elements; "" means not to create the new mesh
3120 # @param toCopyAll - if true, the whole initial mesh will be copied into
3121 # the new mesh else only boundary elements will be copied into the new mesh
3122 # @param groups - groups of 2D elements to make boundary around
3123 # @retval tuple( long, mesh, groups )
3124 # long - number of added boundary elements
3125 # mesh - the mesh where elements were added to
3126 # group - the group of boundary elements or None
3128 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3129 toCopyAll=False, groups=[]):
3130 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
3132 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3133 return nb, mesh, group
3135 ## Renumber mesh nodes
3136 # @ingroup l2_modif_renumber
3137 def RenumberNodes(self):
3138 self.editor.RenumberNodes()
3140 ## Renumber mesh elements
3141 # @ingroup l2_modif_renumber
3142 def RenumberElements(self):
3143 self.editor.RenumberElements()
3145 ## Generates new elements by rotation of the elements around the axis
3146 # @param IDsOfElements the list of ids of elements to sweep
3147 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3148 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3149 # @param NbOfSteps the number of steps
3150 # @param Tolerance tolerance
3151 # @param MakeGroups forces the generation of new groups from existing ones
3152 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3153 # of all steps, else - size of each step
3154 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3155 # @ingroup l2_modif_extrurev
3156 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3157 MakeGroups=False, TotalAngle=False):
3159 if isinstance(AngleInRadians,str):
3161 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3163 AngleInRadians = DegreesToRadians(AngleInRadians)
3164 if IDsOfElements == []:
3165 IDsOfElements = self.GetElementsId()
3166 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3167 Axis = self.smeshpyD.GetAxisStruct(Axis)
3168 Axis,AxisParameters = ParseAxisStruct(Axis)
3169 if TotalAngle and NbOfSteps:
3170 AngleInRadians /= NbOfSteps
3171 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3172 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3173 self.mesh.SetParameters(Parameters)
3175 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3176 AngleInRadians, NbOfSteps, Tolerance)
3177 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3180 ## Generates new elements by rotation of the elements of object around the axis
3181 # @param theObject object which elements should be sweeped.
3182 # It can be a mesh, a sub mesh or a group.
3183 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3184 # @param AngleInRadians the angle of Rotation
3185 # @param NbOfSteps number of steps
3186 # @param Tolerance tolerance
3187 # @param MakeGroups forces the generation of new groups from existing ones
3188 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3189 # of all steps, else - size of each step
3190 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3191 # @ingroup l2_modif_extrurev
3192 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3193 MakeGroups=False, TotalAngle=False):
3195 if isinstance(AngleInRadians,str):
3197 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3199 AngleInRadians = DegreesToRadians(AngleInRadians)
3200 if ( isinstance( theObject, Mesh )):
3201 theObject = theObject.GetMesh()
3202 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3203 Axis = self.smeshpyD.GetAxisStruct(Axis)
3204 Axis,AxisParameters = ParseAxisStruct(Axis)
3205 if TotalAngle and NbOfSteps:
3206 AngleInRadians /= NbOfSteps
3207 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3208 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3209 self.mesh.SetParameters(Parameters)
3211 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3212 NbOfSteps, Tolerance)
3213 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3216 ## Generates new elements by rotation of the elements of object around the axis
3217 # @param theObject object which elements should be sweeped.
3218 # It can be a mesh, a sub mesh or a group.
3219 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3220 # @param AngleInRadians the angle of Rotation
3221 # @param NbOfSteps number of steps
3222 # @param Tolerance tolerance
3223 # @param MakeGroups forces the generation of new groups from existing ones
3224 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3225 # of all steps, else - size of each step
3226 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3227 # @ingroup l2_modif_extrurev
3228 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3229 MakeGroups=False, TotalAngle=False):
3231 if isinstance(AngleInRadians,str):
3233 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3235 AngleInRadians = DegreesToRadians(AngleInRadians)
3236 if ( isinstance( theObject, Mesh )):
3237 theObject = theObject.GetMesh()
3238 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3239 Axis = self.smeshpyD.GetAxisStruct(Axis)
3240 Axis,AxisParameters = ParseAxisStruct(Axis)
3241 if TotalAngle and NbOfSteps:
3242 AngleInRadians /= NbOfSteps
3243 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3244 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3245 self.mesh.SetParameters(Parameters)
3247 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3248 NbOfSteps, Tolerance)
3249 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3252 ## Generates new elements by rotation of the elements of object around the axis
3253 # @param theObject object which elements should be sweeped.
3254 # It can be a mesh, a sub mesh or a group.
3255 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3256 # @param AngleInRadians the angle of Rotation
3257 # @param NbOfSteps number of steps
3258 # @param Tolerance tolerance
3259 # @param MakeGroups forces the generation of new groups from existing ones
3260 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3261 # of all steps, else - size of each step
3262 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3263 # @ingroup l2_modif_extrurev
3264 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3265 MakeGroups=False, TotalAngle=False):
3267 if isinstance(AngleInRadians,str):
3269 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3271 AngleInRadians = DegreesToRadians(AngleInRadians)
3272 if ( isinstance( theObject, Mesh )):
3273 theObject = theObject.GetMesh()
3274 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3275 Axis = self.smeshpyD.GetAxisStruct(Axis)
3276 Axis,AxisParameters = ParseAxisStruct(Axis)
3277 if TotalAngle and NbOfSteps:
3278 AngleInRadians /= NbOfSteps
3279 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3280 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3281 self.mesh.SetParameters(Parameters)
3283 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3284 NbOfSteps, Tolerance)
3285 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3288 ## Generates new elements by extrusion of the elements with given ids
3289 # @param IDsOfElements the list of elements ids for extrusion
3290 # @param StepVector vector or DirStruct, defining the direction and value of extrusion
3291 # @param NbOfSteps the number of steps
3292 # @param MakeGroups forces the generation of new groups from existing ones
3293 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3294 # @ingroup l2_modif_extrurev
3295 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3296 if IDsOfElements == []:
3297 IDsOfElements = self.GetElementsId()
3298 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3299 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3300 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3301 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3302 Parameters = StepVectorParameters + var_separator + Parameters
3303 self.mesh.SetParameters(Parameters)
3305 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3306 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3309 ## Generates new elements by extrusion of the elements with given ids
3310 # @param IDsOfElements is ids of elements
3311 # @param StepVector vector, defining the direction and value of extrusion
3312 # @param NbOfSteps the number of steps
3313 # @param ExtrFlags sets flags for extrusion
3314 # @param SewTolerance uses for comparing locations of nodes if flag
3315 # EXTRUSION_FLAG_SEW is set
3316 # @param MakeGroups forces the generation of new groups from existing ones
3317 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3318 # @ingroup l2_modif_extrurev
3319 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3320 ExtrFlags, SewTolerance, MakeGroups=False):
3321 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3322 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3324 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3325 ExtrFlags, SewTolerance)
3326 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3327 ExtrFlags, SewTolerance)
3330 ## Generates new elements by extrusion of the elements which belong to the object
3331 # @param theObject the object which elements should be processed.
3332 # It can be a mesh, a sub mesh or a group.
3333 # @param StepVector vector, defining the direction and value of extrusion
3334 # @param NbOfSteps the number of steps
3335 # @param MakeGroups forces the generation of new groups from existing ones
3336 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3337 # @ingroup l2_modif_extrurev
3338 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3339 if ( isinstance( theObject, Mesh )):
3340 theObject = theObject.GetMesh()
3341 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3342 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3343 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3344 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3345 Parameters = StepVectorParameters + var_separator + Parameters
3346 self.mesh.SetParameters(Parameters)
3348 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3349 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3352 ## Generates new elements by extrusion of the elements which belong to the object
3353 # @param theObject object which elements should be processed.
3354 # It can be a mesh, a sub mesh or a group.
3355 # @param StepVector vector, defining the direction and value of extrusion
3356 # @param NbOfSteps the number of steps
3357 # @param MakeGroups to generate new groups from existing ones
3358 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3359 # @ingroup l2_modif_extrurev
3360 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3361 if ( isinstance( theObject, Mesh )):
3362 theObject = theObject.GetMesh()
3363 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3364 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3365 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3366 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3367 Parameters = StepVectorParameters + var_separator + Parameters
3368 self.mesh.SetParameters(Parameters)
3370 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3371 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3374 ## Generates new elements by extrusion of the elements which belong to the object
3375 # @param theObject object which elements should be processed.
3376 # It can be a mesh, a sub mesh or a group.
3377 # @param StepVector vector, defining the direction and value of extrusion
3378 # @param NbOfSteps the number of steps
3379 # @param MakeGroups forces the generation of new groups from existing ones
3380 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3381 # @ingroup l2_modif_extrurev
3382 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3383 if ( isinstance( theObject, Mesh )):
3384 theObject = theObject.GetMesh()
3385 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3386 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3387 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3388 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3389 Parameters = StepVectorParameters + var_separator + Parameters
3390 self.mesh.SetParameters(Parameters)
3392 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3393 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3398 ## Generates new elements by extrusion of the given elements
3399 # The path of extrusion must be a meshed edge.
3400 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3401 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3402 # @param NodeStart the start node from Path. Defines the direction of extrusion
3403 # @param HasAngles allows the shape to be rotated around the path
3404 # to get the resulting mesh in a helical fashion
3405 # @param Angles list of angles in radians
3406 # @param LinearVariation forces the computation of rotation angles as linear
3407 # variation of the given Angles along path steps
3408 # @param HasRefPoint allows using the reference point
3409 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3410 # The User can specify any point as the Reference Point.
3411 # @param MakeGroups forces the generation of new groups from existing ones
3412 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3413 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3414 # only SMESH::Extrusion_Error otherwise
3415 # @ingroup l2_modif_extrurev
3416 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3417 HasAngles, Angles, LinearVariation,
3418 HasRefPoint, RefPoint, MakeGroups, ElemType):
3419 Angles,AnglesParameters = ParseAngles(Angles)
3420 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3421 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3422 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3424 Parameters = AnglesParameters + var_separator + RefPointParameters
3425 self.mesh.SetParameters(Parameters)
3427 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3429 if isinstance(Base, list):
3431 if Base == []: IDsOfElements = self.GetElementsId()
3432 else: IDsOfElements = Base
3433 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3434 HasAngles, Angles, LinearVariation,
3435 HasRefPoint, RefPoint, MakeGroups, ElemType)
3437 if isinstance(Base, Mesh): Base = Base.GetMesh()
3438 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3439 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3440 HasAngles, Angles, LinearVariation,
3441 HasRefPoint, RefPoint, MakeGroups, ElemType)
3443 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3446 ## Generates new elements by extrusion of the given elements
3447 # The path of extrusion must be a meshed edge.
3448 # @param IDsOfElements ids of elements
3449 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3450 # @param PathShape shape(edge) defines the sub-mesh for the path
3451 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3452 # @param HasAngles allows the shape to be rotated around the path
3453 # to get the resulting mesh in a helical fashion
3454 # @param Angles list of angles in radians
3455 # @param HasRefPoint allows using the reference point
3456 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3457 # The User can specify any point as the Reference Point.
3458 # @param MakeGroups forces the generation of new groups from existing ones
3459 # @param LinearVariation forces the computation of rotation angles as linear
3460 # variation of the given Angles along path steps
3461 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3462 # only SMESH::Extrusion_Error otherwise
3463 # @ingroup l2_modif_extrurev
3464 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3465 HasAngles, Angles, HasRefPoint, RefPoint,
3466 MakeGroups=False, LinearVariation=False):
3467 Angles,AnglesParameters = ParseAngles(Angles)
3468 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3469 if IDsOfElements == []:
3470 IDsOfElements = self.GetElementsId()
3471 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3472 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3474 if ( isinstance( PathMesh, Mesh )):
3475 PathMesh = PathMesh.GetMesh()
3476 if HasAngles and Angles and LinearVariation:
3477 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3479 Parameters = AnglesParameters + var_separator + RefPointParameters
3480 self.mesh.SetParameters(Parameters)
3482 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3483 PathShape, NodeStart, HasAngles,
3484 Angles, HasRefPoint, RefPoint)
3485 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3486 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3488 ## Generates new elements by extrusion of the elements which belong to the object
3489 # The path of extrusion must be a meshed edge.
3490 # @param theObject the object which elements should be processed.
3491 # It can be a mesh, a sub mesh or a group.
3492 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3493 # @param PathShape shape(edge) defines the sub-mesh for the path
3494 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3495 # @param HasAngles allows the shape to be rotated around the path
3496 # to get the resulting mesh in a helical fashion
3497 # @param Angles list of angles
3498 # @param HasRefPoint allows using the reference point
3499 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3500 # The User can specify any point as the Reference Point.
3501 # @param MakeGroups forces the generation of new groups from existing ones
3502 # @param LinearVariation forces the computation of rotation angles as linear
3503 # variation of the given Angles along path steps
3504 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3505 # only SMESH::Extrusion_Error otherwise
3506 # @ingroup l2_modif_extrurev
3507 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3508 HasAngles, Angles, HasRefPoint, RefPoint,
3509 MakeGroups=False, LinearVariation=False):
3510 Angles,AnglesParameters = ParseAngles(Angles)
3511 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3512 if ( isinstance( theObject, Mesh )):
3513 theObject = theObject.GetMesh()
3514 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3515 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3516 if ( isinstance( PathMesh, Mesh )):
3517 PathMesh = PathMesh.GetMesh()
3518 if HasAngles and Angles and LinearVariation:
3519 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3521 Parameters = AnglesParameters + var_separator + RefPointParameters
3522 self.mesh.SetParameters(Parameters)
3524 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3525 PathShape, NodeStart, HasAngles,
3526 Angles, HasRefPoint, RefPoint)
3527 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3528 NodeStart, HasAngles, Angles, HasRefPoint,
3531 ## Generates new elements by extrusion of the elements which belong to the object
3532 # The path of extrusion must be a meshed edge.
3533 # @param theObject the object which elements should be processed.
3534 # It can be a mesh, a sub mesh or a group.
3535 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3536 # @param PathShape shape(edge) defines the sub-mesh for the path
3537 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3538 # @param HasAngles allows the shape to be rotated around the path
3539 # to get the resulting mesh in a helical fashion
3540 # @param Angles list of angles
3541 # @param HasRefPoint allows using the reference point
3542 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3543 # The User can specify any point as the Reference Point.
3544 # @param MakeGroups forces the generation of new groups from existing ones
3545 # @param LinearVariation forces the computation of rotation angles as linear
3546 # variation of the given Angles along path steps
3547 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3548 # only SMESH::Extrusion_Error otherwise
3549 # @ingroup l2_modif_extrurev
3550 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3551 HasAngles, Angles, HasRefPoint, RefPoint,
3552 MakeGroups=False, LinearVariation=False):
3553 Angles,AnglesParameters = ParseAngles(Angles)
3554 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3555 if ( isinstance( theObject, Mesh )):
3556 theObject = theObject.GetMesh()
3557 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3558 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3559 if ( isinstance( PathMesh, Mesh )):
3560 PathMesh = PathMesh.GetMesh()
3561 if HasAngles and Angles and LinearVariation:
3562 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3564 Parameters = AnglesParameters + var_separator + RefPointParameters
3565 self.mesh.SetParameters(Parameters)
3567 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3568 PathShape, NodeStart, HasAngles,
3569 Angles, HasRefPoint, RefPoint)
3570 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3571 NodeStart, HasAngles, Angles, HasRefPoint,
3574 ## Generates new elements by extrusion of the elements which belong to the object
3575 # The path of extrusion must be a meshed edge.
3576 # @param theObject the object which elements should be processed.
3577 # It can be a mesh, a sub mesh or a group.
3578 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3579 # @param PathShape shape(edge) defines the sub-mesh for the path
3580 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3581 # @param HasAngles allows the shape to be rotated around the path
3582 # to get the resulting mesh in a helical fashion
3583 # @param Angles list of angles
3584 # @param HasRefPoint allows using the reference point
3585 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3586 # The User can specify any point as the Reference Point.
3587 # @param MakeGroups forces the generation of new groups from existing ones
3588 # @param LinearVariation forces the computation of rotation angles as linear
3589 # variation of the given Angles along path steps
3590 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3591 # only SMESH::Extrusion_Error otherwise
3592 # @ingroup l2_modif_extrurev
3593 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3594 HasAngles, Angles, HasRefPoint, RefPoint,
3595 MakeGroups=False, LinearVariation=False):
3596 Angles,AnglesParameters = ParseAngles(Angles)
3597 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3598 if ( isinstance( theObject, Mesh )):
3599 theObject = theObject.GetMesh()
3600 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3601 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3602 if ( isinstance( PathMesh, Mesh )):
3603 PathMesh = PathMesh.GetMesh()
3604 if HasAngles and Angles and LinearVariation:
3605 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3607 Parameters = AnglesParameters + var_separator + RefPointParameters
3608 self.mesh.SetParameters(Parameters)
3610 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3611 PathShape, NodeStart, HasAngles,
3612 Angles, HasRefPoint, RefPoint)
3613 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3614 NodeStart, HasAngles, Angles, HasRefPoint,
3617 ## Creates a symmetrical copy of mesh elements
3618 # @param IDsOfElements list of elements ids
3619 # @param Mirror is AxisStruct or geom object(point, line, plane)
3620 # @param theMirrorType is POINT, AXIS or PLANE
3621 # If the Mirror is a geom object this parameter is unnecessary
3622 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3623 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3624 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3625 # @ingroup l2_modif_trsf
3626 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3627 if IDsOfElements == []:
3628 IDsOfElements = self.GetElementsId()
3629 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3630 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3631 Mirror,Parameters = ParseAxisStruct(Mirror)
3632 self.mesh.SetParameters(Parameters)
3633 if Copy and MakeGroups:
3634 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3635 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3638 ## Creates a new mesh by a symmetrical copy of mesh elements
3639 # @param IDsOfElements the list of elements ids
3640 # @param Mirror is AxisStruct or geom object (point, line, plane)
3641 # @param theMirrorType is POINT, AXIS or PLANE
3642 # If the Mirror is a geom object this parameter is unnecessary
3643 # @param MakeGroups to generate new groups from existing ones
3644 # @param NewMeshName a name of the new mesh to create
3645 # @return instance of Mesh class
3646 # @ingroup l2_modif_trsf
3647 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3648 if IDsOfElements == []:
3649 IDsOfElements = self.GetElementsId()
3650 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3651 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3652 Mirror,Parameters = ParseAxisStruct(Mirror)
3653 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3654 MakeGroups, NewMeshName)
3655 mesh.SetParameters(Parameters)
3656 return Mesh(self.smeshpyD,self.geompyD,mesh)
3658 ## Creates a symmetrical copy of the object
3659 # @param theObject mesh, submesh or group
3660 # @param Mirror AxisStruct or geom object (point, line, plane)
3661 # @param theMirrorType is POINT, AXIS or PLANE
3662 # If the Mirror is a geom object this parameter is unnecessary
3663 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3664 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3665 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3666 # @ingroup l2_modif_trsf
3667 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3668 if ( isinstance( theObject, Mesh )):
3669 theObject = theObject.GetMesh()
3670 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3671 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3672 Mirror,Parameters = ParseAxisStruct(Mirror)
3673 self.mesh.SetParameters(Parameters)
3674 if Copy and MakeGroups:
3675 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3676 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3679 ## Creates a new mesh by a symmetrical copy of the object
3680 # @param theObject mesh, submesh or group
3681 # @param Mirror AxisStruct or geom object (point, line, plane)
3682 # @param theMirrorType POINT, AXIS or PLANE
3683 # If the Mirror is a geom object this parameter is unnecessary
3684 # @param MakeGroups forces the generation of new groups from existing ones
3685 # @param NewMeshName the name of the new mesh to create
3686 # @return instance of Mesh class
3687 # @ingroup l2_modif_trsf
3688 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3689 if ( isinstance( theObject, Mesh )):
3690 theObject = theObject.GetMesh()
3691 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3692 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3693 Mirror,Parameters = ParseAxisStruct(Mirror)
3694 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3695 MakeGroups, NewMeshName)
3696 mesh.SetParameters(Parameters)
3697 return Mesh( self.smeshpyD,self.geompyD,mesh )
3699 ## Translates the elements
3700 # @param IDsOfElements list of elements ids
3701 # @param Vector the direction of translation (DirStruct or vector)
3702 # @param Copy allows copying the translated elements
3703 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3704 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3705 # @ingroup l2_modif_trsf
3706 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3707 if IDsOfElements == []:
3708 IDsOfElements = self.GetElementsId()
3709 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3710 Vector = self.smeshpyD.GetDirStruct(Vector)
3711 Vector,Parameters = ParseDirStruct(Vector)
3712 self.mesh.SetParameters(Parameters)
3713 if Copy and MakeGroups:
3714 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3715 self.editor.Translate(IDsOfElements, Vector, Copy)
3718 ## Creates a new mesh of translated elements
3719 # @param IDsOfElements list of elements ids
3720 # @param Vector the direction of translation (DirStruct or vector)
3721 # @param MakeGroups forces the generation of new groups from existing ones
3722 # @param NewMeshName the name of the newly created mesh
3723 # @return instance of Mesh class
3724 # @ingroup l2_modif_trsf
3725 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3726 if IDsOfElements == []:
3727 IDsOfElements = self.GetElementsId()
3728 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3729 Vector = self.smeshpyD.GetDirStruct(Vector)
3730 Vector,Parameters = ParseDirStruct(Vector)
3731 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3732 mesh.SetParameters(Parameters)
3733 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3735 ## Translates the object
3736 # @param theObject the object to translate (mesh, submesh, or group)
3737 # @param Vector direction of translation (DirStruct or geom vector)
3738 # @param Copy allows copying the translated elements
3739 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3740 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3741 # @ingroup l2_modif_trsf
3742 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3743 if ( isinstance( theObject, Mesh )):
3744 theObject = theObject.GetMesh()
3745 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3746 Vector = self.smeshpyD.GetDirStruct(Vector)
3747 Vector,Parameters = ParseDirStruct(Vector)
3748 self.mesh.SetParameters(Parameters)
3749 if Copy and MakeGroups:
3750 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3751 self.editor.TranslateObject(theObject, Vector, Copy)
3754 ## Creates a new mesh from the translated object
3755 # @param theObject the object to translate (mesh, submesh, or group)
3756 # @param Vector the direction of translation (DirStruct or geom vector)
3757 # @param MakeGroups forces the generation of new groups from existing ones
3758 # @param NewMeshName the name of the newly created mesh
3759 # @return instance of Mesh class
3760 # @ingroup l2_modif_trsf
3761 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3762 if (isinstance(theObject, Mesh)):
3763 theObject = theObject.GetMesh()
3764 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3765 Vector = self.smeshpyD.GetDirStruct(Vector)
3766 Vector,Parameters = ParseDirStruct(Vector)
3767 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3768 mesh.SetParameters(Parameters)
3769 return Mesh( self.smeshpyD, self.geompyD, mesh )
3773 ## Scales the object
3774 # @param theObject - the object to translate (mesh, submesh, or group)
3775 # @param thePoint - base point for scale
3776 # @param theScaleFact - list of 1-3 scale factors for axises
3777 # @param Copy - allows copying the translated elements
3778 # @param MakeGroups - forces the generation of new groups from existing
3780 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3781 # empty list otherwise
3782 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3783 if ( isinstance( theObject, Mesh )):
3784 theObject = theObject.GetMesh()
3785 if ( isinstance( theObject, list )):
3786 theObject = self.GetIDSource(theObject, SMESH.ALL)
3788 thePoint, Parameters = ParsePointStruct(thePoint)
3789 self.mesh.SetParameters(Parameters)
3791 if Copy and MakeGroups:
3792 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3793 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3796 ## Creates a new mesh from the translated object
3797 # @param theObject - the object to translate (mesh, submesh, or group)
3798 # @param thePoint - base point for scale
3799 # @param theScaleFact - list of 1-3 scale factors for axises
3800 # @param MakeGroups - forces the generation of new groups from existing ones
3801 # @param NewMeshName - the name of the newly created mesh
3802 # @return instance of Mesh class
3803 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3804 if (isinstance(theObject, Mesh)):
3805 theObject = theObject.GetMesh()
3806 if ( isinstance( theObject, list )):
3807 theObject = self.GetIDSource(theObject,SMESH.ALL)
3809 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3810 MakeGroups, NewMeshName)
3811 #mesh.SetParameters(Parameters)
3812 return Mesh( self.smeshpyD, self.geompyD, mesh )
3816 ## Rotates the elements
3817 # @param IDsOfElements list of elements ids
3818 # @param Axis the axis of rotation (AxisStruct or geom line)
3819 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3820 # @param Copy allows copying the rotated elements
3821 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3822 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3823 # @ingroup l2_modif_trsf
3824 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3826 if isinstance(AngleInRadians,str):
3828 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3830 AngleInRadians = DegreesToRadians(AngleInRadians)
3831 if IDsOfElements == []:
3832 IDsOfElements = self.GetElementsId()
3833 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3834 Axis = self.smeshpyD.GetAxisStruct(Axis)
3835 Axis,AxisParameters = ParseAxisStruct(Axis)
3836 Parameters = AxisParameters + var_separator + Parameters
3837 self.mesh.SetParameters(Parameters)
3838 if Copy and MakeGroups:
3839 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3840 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3843 ## Creates a new mesh of rotated elements
3844 # @param IDsOfElements list of element ids
3845 # @param Axis the axis of rotation (AxisStruct or geom line)
3846 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3847 # @param MakeGroups forces the generation of new groups from existing ones
3848 # @param NewMeshName the name of the newly created mesh
3849 # @return instance of Mesh class
3850 # @ingroup l2_modif_trsf
3851 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3853 if isinstance(AngleInRadians,str):
3855 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3857 AngleInRadians = DegreesToRadians(AngleInRadians)
3858 if IDsOfElements == []:
3859 IDsOfElements = self.GetElementsId()
3860 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3861 Axis = self.smeshpyD.GetAxisStruct(Axis)
3862 Axis,AxisParameters = ParseAxisStruct(Axis)
3863 Parameters = AxisParameters + var_separator + Parameters
3864 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3865 MakeGroups, NewMeshName)
3866 mesh.SetParameters(Parameters)
3867 return Mesh( self.smeshpyD, self.geompyD, mesh )
3869 ## Rotates the object
3870 # @param theObject the object to rotate( mesh, submesh, or group)
3871 # @param Axis the axis of rotation (AxisStruct or geom line)
3872 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3873 # @param Copy allows copying the rotated elements
3874 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3875 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3876 # @ingroup l2_modif_trsf
3877 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3879 if isinstance(AngleInRadians,str):
3881 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3883 AngleInRadians = DegreesToRadians(AngleInRadians)
3884 if (isinstance(theObject, Mesh)):
3885 theObject = theObject.GetMesh()
3886 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3887 Axis = self.smeshpyD.GetAxisStruct(Axis)
3888 Axis,AxisParameters = ParseAxisStruct(Axis)
3889 Parameters = AxisParameters + ":" + Parameters
3890 self.mesh.SetParameters(Parameters)
3891 if Copy and MakeGroups:
3892 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3893 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3896 ## Creates a new mesh from the rotated object
3897 # @param theObject the object to rotate (mesh, submesh, or group)
3898 # @param Axis the axis of rotation (AxisStruct or geom line)
3899 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3900 # @param MakeGroups forces the generation of new groups from existing ones
3901 # @param NewMeshName the name of the newly created mesh
3902 # @return instance of Mesh class
3903 # @ingroup l2_modif_trsf
3904 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3906 if isinstance(AngleInRadians,str):
3908 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3910 AngleInRadians = DegreesToRadians(AngleInRadians)
3911 if (isinstance( theObject, Mesh )):
3912 theObject = theObject.GetMesh()
3913 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3914 Axis = self.smeshpyD.GetAxisStruct(Axis)
3915 Axis,AxisParameters = ParseAxisStruct(Axis)
3916 Parameters = AxisParameters + ":" + Parameters
3917 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3918 MakeGroups, NewMeshName)
3919 mesh.SetParameters(Parameters)
3920 return Mesh( self.smeshpyD, self.geompyD, mesh )
3922 ## Finds groups of ajacent nodes within Tolerance.
3923 # @param Tolerance the value of tolerance
3924 # @return the list of groups of nodes
3925 # @ingroup l2_modif_trsf
3926 def FindCoincidentNodes (self, Tolerance):
3927 return self.editor.FindCoincidentNodes(Tolerance)
3929 ## Finds groups of ajacent nodes within Tolerance.
3930 # @param Tolerance the value of tolerance
3931 # @param SubMeshOrGroup SubMesh or Group
3932 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3933 # @return the list of groups of nodes
3934 # @ingroup l2_modif_trsf
3935 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3936 if (isinstance( SubMeshOrGroup, Mesh )):
3937 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3938 if not isinstance( exceptNodes, list):
3939 exceptNodes = [ exceptNodes ]
3940 if exceptNodes and isinstance( exceptNodes[0], int):
3941 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3942 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3945 # @param GroupsOfNodes the list of groups of nodes
3946 # @ingroup l2_modif_trsf
3947 def MergeNodes (self, GroupsOfNodes):
3948 self.editor.MergeNodes(GroupsOfNodes)
3950 ## Finds the elements built on the same nodes.
3951 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3952 # @return a list of groups of equal elements
3953 # @ingroup l2_modif_trsf
3954 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3955 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3956 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3957 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3959 ## Merges elements in each given group.
3960 # @param GroupsOfElementsID groups of elements for merging
3961 # @ingroup l2_modif_trsf
3962 def MergeElements(self, GroupsOfElementsID):
3963 self.editor.MergeElements(GroupsOfElementsID)
3965 ## Leaves one element and removes all other elements built on the same nodes.
3966 # @ingroup l2_modif_trsf
3967 def MergeEqualElements(self):
3968 self.editor.MergeEqualElements()
3970 ## Sews free borders
3971 # @return SMESH::Sew_Error
3972 # @ingroup l2_modif_trsf
3973 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3974 FirstNodeID2, SecondNodeID2, LastNodeID2,
3975 CreatePolygons, CreatePolyedrs):
3976 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3977 FirstNodeID2, SecondNodeID2, LastNodeID2,
3978 CreatePolygons, CreatePolyedrs)
3980 ## Sews conform free borders
3981 # @return SMESH::Sew_Error
3982 # @ingroup l2_modif_trsf
3983 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3984 FirstNodeID2, SecondNodeID2):
3985 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3986 FirstNodeID2, SecondNodeID2)
3988 ## Sews border to side
3989 # @return SMESH::Sew_Error
3990 # @ingroup l2_modif_trsf
3991 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3992 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3993 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3994 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3996 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3997 # merged with the nodes of elements of Side2.
3998 # The number of elements in theSide1 and in theSide2 must be
3999 # equal and they should have similar nodal connectivity.
4000 # The nodes to merge should belong to side borders and
4001 # the first node should be linked to the second.
4002 # @return SMESH::Sew_Error
4003 # @ingroup l2_modif_trsf
4004 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
4005 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4006 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
4007 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
4008 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
4009 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
4011 ## Sets new nodes for the given element.
4012 # @param ide the element id
4013 # @param newIDs nodes ids
4014 # @return If the number of nodes does not correspond to the type of element - returns false
4015 # @ingroup l2_modif_edit
4016 def ChangeElemNodes(self, ide, newIDs):
4017 return self.editor.ChangeElemNodes(ide, newIDs)
4019 ## If during the last operation of MeshEditor some nodes were
4020 # created, this method returns the list of their IDs, \n
4021 # if new nodes were not created - returns empty list
4022 # @return the list of integer values (can be empty)
4023 # @ingroup l1_auxiliary
4024 def GetLastCreatedNodes(self):
4025 return self.editor.GetLastCreatedNodes()
4027 ## If during the last operation of MeshEditor some elements were
4028 # created this method returns the list of their IDs, \n
4029 # if new elements were not created - returns empty list
4030 # @return the list of integer values (can be empty)
4031 # @ingroup l1_auxiliary
4032 def GetLastCreatedElems(self):
4033 return self.editor.GetLastCreatedElems()
4035 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4036 # @param theNodes identifiers of nodes to be doubled
4037 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4038 # nodes. If list of element identifiers is empty then nodes are doubled but
4039 # they not assigned to elements
4040 # @return TRUE if operation has been completed successfully, FALSE otherwise
4041 # @ingroup l2_modif_edit
4042 def DoubleNodes(self, theNodes, theModifiedElems):
4043 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4045 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4046 # This method provided for convenience works as DoubleNodes() described above.
4047 # @param theNodeId identifiers of node to be doubled
4048 # @param theModifiedElems identifiers of elements to be updated
4049 # @return TRUE if operation has been completed successfully, FALSE otherwise
4050 # @ingroup l2_modif_edit
4051 def DoubleNode(self, theNodeId, theModifiedElems):
4052 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4054 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4055 # This method provided for convenience works as DoubleNodes() described above.
4056 # @param theNodes group of nodes to be doubled
4057 # @param theModifiedElems group of elements to be updated.
4058 # @param theMakeGroup forces the generation of a group containing new nodes.
4059 # @return TRUE or a created group if operation has been completed successfully,
4060 # FALSE or None otherwise
4061 # @ingroup l2_modif_edit
4062 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4064 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4065 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4067 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4068 # This method provided for convenience works as DoubleNodes() described above.
4069 # @param theNodes list of groups of nodes to be doubled
4070 # @param theModifiedElems list of groups of elements to be updated.
4071 # @return TRUE if operation has been completed successfully, FALSE otherwise
4072 # @ingroup l2_modif_edit
4073 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4075 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4076 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4078 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4079 # @param theElems - the list of elements (edges or faces) to be replicated
4080 # The nodes for duplication could be found from these elements
4081 # @param theNodesNot - list of nodes to NOT replicate
4082 # @param theAffectedElems - the list of elements (cells and edges) to which the
4083 # replicated nodes should be associated to.
4084 # @return TRUE if operation has been completed successfully, FALSE otherwise
4085 # @ingroup l2_modif_edit
4086 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4087 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4089 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4090 # @param theElems - the list of elements (edges or faces) to be replicated
4091 # The nodes for duplication could be found from these elements
4092 # @param theNodesNot - list of nodes to NOT replicate
4093 # @param theShape - shape to detect affected elements (element which geometric center
4094 # located on or inside shape).
4095 # The replicated nodes should be associated to affected elements.
4096 # @return TRUE if operation has been completed successfully, FALSE otherwise
4097 # @ingroup l2_modif_edit
4098 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4099 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4101 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4102 # This method provided for convenience works as DoubleNodes() described above.
4103 # @param theElems - group of of elements (edges or faces) to be replicated
4104 # @param theNodesNot - group of nodes not to replicated
4105 # @param theAffectedElems - group of elements to which the replicated nodes
4106 # should be associated to.
4107 # @param theMakeGroup forces the generation of a group containing new elements.
4108 # @return TRUE or a created group if operation has been completed successfully,
4109 # FALSE or None otherwise
4110 # @ingroup l2_modif_edit
4111 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4113 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4114 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4116 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4117 # This method provided for convenience works as DoubleNodes() described above.
4118 # @param theElems - group of of elements (edges or faces) to be replicated
4119 # @param theNodesNot - group of nodes not to replicated
4120 # @param theShape - shape to detect affected elements (element which geometric center
4121 # located on or inside shape).
4122 # The replicated nodes should be associated to affected elements.
4123 # @ingroup l2_modif_edit
4124 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4125 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4127 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4128 # This method provided for convenience works as DoubleNodes() described above.
4129 # @param theElems - list of groups of elements (edges or faces) to be replicated
4130 # @param theNodesNot - list of groups of nodes not to replicated
4131 # @param theAffectedElems - group of elements to which the replicated nodes
4132 # should be associated to.
4133 # @param theMakeGroup forces the generation of a group containing new elements.
4134 # @return TRUE or a created group if operation has been completed successfully,
4135 # FALSE or None otherwise
4136 # @ingroup l2_modif_edit
4137 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4139 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4140 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4142 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4143 # This method provided for convenience works as DoubleNodes() described above.
4144 # @param theElems - list of groups of elements (edges or faces) to be replicated
4145 # @param theNodesNot - list of groups of nodes not to replicated
4146 # @param theShape - shape to detect affected elements (element which geometric center
4147 # located on or inside shape).
4148 # The replicated nodes should be associated to affected elements.
4149 # @return TRUE if operation has been completed successfully, FALSE otherwise
4150 # @ingroup l2_modif_edit
4151 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4152 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4154 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4155 # The list of groups must describe a partition of the mesh volumes.
4156 # The nodes of the internal faces at the boundaries of the groups are doubled.
4157 # In option, the internal faces are replaced by flat elements.
4158 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4159 # @param theDomains - list of groups of volumes
4160 # @param createJointElems - if TRUE, create the elements
4161 # @return TRUE if operation has been completed successfully, FALSE otherwise
4162 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4163 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4165 def _valueFromFunctor(self, funcType, elemId):
4166 fn = self.smeshpyD.GetFunctor(funcType)
4167 fn.SetMesh(self.mesh)
4168 if fn.GetElementType() == self.GetElementType(elemId, True):
4169 val = fn.GetValue(elemId)
4174 ## Get length of 1D element.
4175 # @param elemId mesh element ID
4176 # @return element's length value
4177 # @ingroup l1_measurements
4178 def GetLength(self, elemId):
4179 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4181 ## Get area of 2D element.
4182 # @param elemId mesh element ID
4183 # @return element's area value
4184 # @ingroup l1_measurements
4185 def GetArea(self, elemId):
4186 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4188 ## Get volume of 3D element.
4189 # @param elemId mesh element ID
4190 # @return element's volume value
4191 # @ingroup l1_measurements
4192 def GetVolume(self, elemId):
4193 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4195 ## Get maximum element length.
4196 # @param elemId mesh element ID
4197 # @return element's maximum length value
4198 # @ingroup l1_measurements
4199 def GetMaxElementLength(self, elemId):
4200 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4201 ftype = SMESH.FT_MaxElementLength3D
4203 ftype = SMESH.FT_MaxElementLength2D
4204 return self._valueFromFunctor(ftype, elemId)
4206 ## Get aspect ratio of 2D or 3D element.
4207 # @param elemId mesh element ID
4208 # @return element's aspect ratio value
4209 # @ingroup l1_measurements
4210 def GetAspectRatio(self, elemId):
4211 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4212 ftype = SMESH.FT_AspectRatio3D
4214 ftype = SMESH.FT_AspectRatio
4215 return self._valueFromFunctor(ftype, elemId)
4217 ## Get warping angle of 2D element.
4218 # @param elemId mesh element ID
4219 # @return element's warping angle value
4220 # @ingroup l1_measurements
4221 def GetWarping(self, elemId):
4222 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4224 ## Get minimum angle of 2D element.
4225 # @param elemId mesh element ID
4226 # @return element's minimum angle value
4227 # @ingroup l1_measurements
4228 def GetMinimumAngle(self, elemId):
4229 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4231 ## Get taper of 2D element.
4232 # @param elemId mesh element ID
4233 # @return element's taper value
4234 # @ingroup l1_measurements
4235 def GetTaper(self, elemId):
4236 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4238 ## Get skew of 2D element.
4239 # @param elemId mesh element ID
4240 # @return element's skew value
4241 # @ingroup l1_measurements
4242 def GetSkew(self, elemId):
4243 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4245 ## The mother class to define algorithm, it is not recommended to use it directly.
4248 # @ingroup l2_algorithms
4249 class Mesh_Algorithm:
4250 # @class Mesh_Algorithm
4251 # @brief Class Mesh_Algorithm
4253 #def __init__(self,smesh):
4261 ## Finds a hypothesis in the study by its type name and parameters.
4262 # Finds only the hypotheses created in smeshpyD engine.
4263 # @return SMESH.SMESH_Hypothesis
4264 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4265 study = smeshpyD.GetCurrentStudy()
4266 #to do: find component by smeshpyD object, not by its data type
4267 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4268 if scomp is not None:
4269 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4270 # Check if the root label of the hypotheses exists
4271 if res and hypRoot is not None:
4272 iter = study.NewChildIterator(hypRoot)
4273 # Check all published hypotheses
4275 hypo_so_i = iter.Value()
4276 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4277 if attr is not None:
4278 anIOR = attr.Value()
4279 hypo_o_i = salome.orb.string_to_object(anIOR)
4280 if hypo_o_i is not None:
4281 # Check if this is a hypothesis
4282 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4283 if hypo_i is not None:
4284 # Check if the hypothesis belongs to current engine
4285 if smeshpyD.GetObjectId(hypo_i) > 0:
4286 # Check if this is the required hypothesis
4287 if hypo_i.GetName() == hypname:
4289 if CompareMethod(hypo_i, args):
4303 ## Finds the algorithm in the study by its type name.
4304 # Finds only the algorithms, which have been created in smeshpyD engine.
4305 # @return SMESH.SMESH_Algo
4306 def FindAlgorithm (self, algoname, smeshpyD):
4307 study = smeshpyD.GetCurrentStudy()
4308 #to do: find component by smeshpyD object, not by its data type
4309 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4310 if scomp is not None:
4311 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4312 # Check if the root label of the algorithms exists
4313 if res and hypRoot is not None:
4314 iter = study.NewChildIterator(hypRoot)
4315 # Check all published algorithms
4317 algo_so_i = iter.Value()
4318 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4319 if attr is not None:
4320 anIOR = attr.Value()
4321 algo_o_i = salome.orb.string_to_object(anIOR)
4322 if algo_o_i is not None:
4323 # Check if this is an algorithm
4324 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4325 if algo_i is not None:
4326 # Checks if the algorithm belongs to the current engine
4327 if smeshpyD.GetObjectId(algo_i) > 0:
4328 # Check if this is the required algorithm
4329 if algo_i.GetName() == algoname:
4342 ## If the algorithm is global, returns 0; \n
4343 # else returns the submesh associated to this algorithm.
4344 def GetSubMesh(self):
4347 ## Returns the wrapped mesher.
4348 def GetAlgorithm(self):
4351 ## Gets the list of hypothesis that can be used with this algorithm
4352 def GetCompatibleHypothesis(self):
4355 mylist = self.algo.GetCompatibleHypothesis()
4358 ## Gets the name of the algorithm
4362 ## Sets the name to the algorithm
4363 def SetName(self, name):
4364 self.mesh.smeshpyD.SetName(self.algo, name)
4366 ## Gets the id of the algorithm
4368 return self.algo.GetId()
4371 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4373 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4374 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4376 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4378 self.Assign(algo, mesh, geom)
4382 def Assign(self, algo, mesh, geom):
4384 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4393 name = GetName(geom)
4397 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4398 # for all groups SubShapeName() returns "Compound_-1"
4399 name = mesh.geompyD.SubShapeName(geom, piece)
4401 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4402 # publish geom of sub-mesh (issue 0021122)
4403 if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4404 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4405 if studyID != self.mesh.geompyD.myStudyId:
4406 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4407 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4409 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4411 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4412 TreatHypoStatus( status, algo.GetName(), name, True )
4414 def CompareHyp (self, hyp, args):
4415 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4418 def CompareEqualHyp (self, hyp, args):
4422 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4423 UseExisting=0, CompareMethod=""):
4426 if CompareMethod == "": CompareMethod = self.CompareHyp
4427 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4430 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4436 a = a + s + str(args[i])
4440 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4444 geomName = GetName(self.geom)
4445 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4446 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4449 ## Returns entry of the shape to mesh in the study
4450 def MainShapeEntry(self):
4452 if not self.mesh or not self.mesh.GetMesh(): return entry
4453 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4454 study = self.mesh.smeshpyD.GetCurrentStudy()
4455 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4456 sobj = study.FindObjectIOR(ior)
4457 if sobj: entry = sobj.GetID()
4458 if not entry: return ""
4461 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4462 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4463 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4464 # @param thickness total thickness of layers of prisms
4465 # @param numberOfLayers number of layers of prisms
4466 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4467 # @param ignoreFaces geometrical face (or their ids) not to generate layers on
4468 # @ingroup l3_hypos_additi
4469 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4470 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4471 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4472 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4473 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4474 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4475 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4476 hyp = self.Hypothesis("ViscousLayers",
4477 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4478 hyp.SetTotalThickness(thickness)
4479 hyp.SetNumberLayers(numberOfLayers)
4480 hyp.SetStretchFactor(stretchFactor)
4481 hyp.SetIgnoreFaces(ignoreFaces)
4484 # Public class: Mesh_Segment
4485 # --------------------------
4487 ## Class to define a segment 1D algorithm for discretization
4490 # @ingroup l3_algos_basic
4491 class Mesh_Segment(Mesh_Algorithm):
4493 ## Private constructor.
4494 def __init__(self, mesh, geom=0):
4495 Mesh_Algorithm.__init__(self)
4496 self.Create(mesh, geom, "Regular_1D")
4498 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4499 # @param l for the length of segments that cut an edge
4500 # @param UseExisting if ==true - searches for an existing hypothesis created with
4501 # the same parameters, else (default) - creates a new one
4502 # @param p precision, used for calculation of the number of segments.
4503 # The precision should be a positive, meaningful value within the range [0,1].
4504 # In general, the number of segments is calculated with the formula:
4505 # nb = ceil((edge_length / l) - p)
4506 # Function ceil rounds its argument to the higher integer.
4507 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4508 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4509 # p=1 means rounding of (edge_length / l) to the lower integer.
4510 # Default value is 1e-07.
4511 # @return an instance of StdMeshers_LocalLength hypothesis
4512 # @ingroup l3_hypos_1dhyps
4513 def LocalLength(self, l, UseExisting=0, p=1e-07):
4514 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4515 CompareMethod=self.CompareLocalLength)
4521 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4522 def CompareLocalLength(self, hyp, args):
4523 if IsEqual(hyp.GetLength(), args[0]):
4524 return IsEqual(hyp.GetPrecision(), args[1])
4527 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4528 # @param length is optional maximal allowed length of segment, if it is omitted
4529 # the preestimated length is used that depends on geometry size
4530 # @param UseExisting if ==true - searches for an existing hypothesis created with
4531 # the same parameters, else (default) - create a new one
4532 # @return an instance of StdMeshers_MaxLength hypothesis
4533 # @ingroup l3_hypos_1dhyps
4534 def MaxSize(self, length=0.0, UseExisting=0):
4535 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4538 hyp.SetLength(length)
4540 # set preestimated length
4541 gen = self.mesh.smeshpyD
4542 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4543 self.mesh.GetMesh(), self.mesh.GetShape(),
4545 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4547 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4550 hyp.SetUsePreestimatedLength( length == 0.0 )
4553 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4554 # @param n for the number of segments that cut an edge
4555 # @param s for the scale factor (optional)
4556 # @param reversedEdges is a list of edges to mesh using reversed orientation
4557 # @param UseExisting if ==true - searches for an existing hypothesis created with
4558 # the same parameters, else (default) - create a new one
4559 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4560 # @ingroup l3_hypos_1dhyps
4561 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4562 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4563 reversedEdges, UseExisting = [], reversedEdges
4564 entry = self.MainShapeEntry()
4565 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4566 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4568 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4569 UseExisting=UseExisting,
4570 CompareMethod=self.CompareNumberOfSegments)
4572 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4573 UseExisting=UseExisting,
4574 CompareMethod=self.CompareNumberOfSegments)
4575 hyp.SetDistrType( 1 )
4576 hyp.SetScaleFactor(s)
4577 hyp.SetNumberOfSegments(n)
4578 hyp.SetReversedEdges( reversedEdges )
4579 hyp.SetObjectEntry( entry )
4583 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4584 def CompareNumberOfSegments(self, hyp, args):
4585 if hyp.GetNumberOfSegments() == args[0]:
4587 if hyp.GetReversedEdges() == args[1]:
4588 if not args[1] or hyp.GetObjectEntry() == args[2]:
4591 if hyp.GetReversedEdges() == args[2]:
4592 if not args[2] or hyp.GetObjectEntry() == args[3]:
4593 if hyp.GetDistrType() == 1:
4594 if IsEqual(hyp.GetScaleFactor(), args[1]):
4598 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4599 # @param start defines the length of the first segment
4600 # @param end defines the length of the last segment
4601 # @param reversedEdges is a list of edges to mesh using reversed orientation
4602 # @param UseExisting if ==true - searches for an existing hypothesis created with
4603 # the same parameters, else (default) - creates a new one
4604 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4605 # @ingroup l3_hypos_1dhyps
4606 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4607 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4608 reversedEdges, UseExisting = [], reversedEdges
4609 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4610 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4611 entry = self.MainShapeEntry()
4612 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4613 UseExisting=UseExisting,
4614 CompareMethod=self.CompareArithmetic1D)
4615 hyp.SetStartLength(start)
4616 hyp.SetEndLength(end)
4617 hyp.SetReversedEdges( reversedEdges )
4618 hyp.SetObjectEntry( entry )
4622 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4623 def CompareArithmetic1D(self, hyp, args):
4624 if IsEqual(hyp.GetLength(1), args[0]):
4625 if IsEqual(hyp.GetLength(0), args[1]):
4626 if hyp.GetReversedEdges() == args[2]:
4627 if not args[2] or hyp.GetObjectEntry() == args[3]:
4632 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4633 # on curve from 0 to 1 (additionally it is neecessary to check
4634 # orientation of edges and create list of reversed edges if it is
4635 # needed) and sets numbers of segments between given points (default
4636 # values are equals 1
4637 # @param points defines the list of parameters on curve
4638 # @param nbSegs defines the list of numbers of segments
4639 # @param reversedEdges is a list of edges to mesh using reversed orientation
4640 # @param UseExisting if ==true - searches for an existing hypothesis created with
4641 # the same parameters, else (default) - creates a new one
4642 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4643 # @ingroup l3_hypos_1dhyps
4644 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4645 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4646 reversedEdges, UseExisting = [], reversedEdges
4647 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4648 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4649 entry = self.MainShapeEntry()
4650 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4651 UseExisting=UseExisting,
4652 CompareMethod=self.CompareFixedPoints1D)
4653 hyp.SetPoints(points)
4654 hyp.SetNbSegments(nbSegs)
4655 hyp.SetReversedEdges(reversedEdges)
4656 hyp.SetObjectEntry(entry)
4660 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4661 ## as the given arguments
4662 def CompareFixedPoints1D(self, hyp, args):
4663 if hyp.GetPoints() == args[0]:
4664 if hyp.GetNbSegments() == args[1]:
4665 if hyp.GetReversedEdges() == args[2]:
4666 if not args[2] or hyp.GetObjectEntry() == args[3]:
4672 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4673 # @param start defines the length of the first segment
4674 # @param end defines the length of the last segment
4675 # @param reversedEdges is a list of edges to mesh using reversed orientation
4676 # @param UseExisting if ==true - searches for an existing hypothesis created with
4677 # the same parameters, else (default) - creates a new one
4678 # @return an instance of StdMeshers_StartEndLength hypothesis
4679 # @ingroup l3_hypos_1dhyps
4680 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4681 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4682 reversedEdges, UseExisting = [], reversedEdges
4683 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4684 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4685 entry = self.MainShapeEntry()
4686 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4687 UseExisting=UseExisting,
4688 CompareMethod=self.CompareStartEndLength)
4689 hyp.SetStartLength(start)
4690 hyp.SetEndLength(end)
4691 hyp.SetReversedEdges( reversedEdges )
4692 hyp.SetObjectEntry( entry )
4695 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4696 def CompareStartEndLength(self, hyp, args):
4697 if IsEqual(hyp.GetLength(1), args[0]):
4698 if IsEqual(hyp.GetLength(0), args[1]):
4699 if hyp.GetReversedEdges() == args[2]:
4700 if not args[2] or hyp.GetObjectEntry() == args[3]:
4704 ## Defines "Deflection1D" hypothesis
4705 # @param d for the deflection
4706 # @param UseExisting if ==true - searches for an existing hypothesis created with
4707 # the same parameters, else (default) - create a new one
4708 # @ingroup l3_hypos_1dhyps
4709 def Deflection1D(self, d, UseExisting=0):
4710 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4711 CompareMethod=self.CompareDeflection1D)
4712 hyp.SetDeflection(d)
4715 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4716 def CompareDeflection1D(self, hyp, args):
4717 return IsEqual(hyp.GetDeflection(), args[0])
4719 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4720 # the opposite side in case of quadrangular faces
4721 # @ingroup l3_hypos_additi
4722 def Propagation(self):
4723 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4725 ## Defines "AutomaticLength" hypothesis
4726 # @param fineness for the fineness [0-1]
4727 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4728 # same parameters, else (default) - create a new one
4729 # @ingroup l3_hypos_1dhyps
4730 def AutomaticLength(self, fineness=0, UseExisting=0):
4731 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4732 CompareMethod=self.CompareAutomaticLength)
4733 hyp.SetFineness( fineness )
4736 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4737 def CompareAutomaticLength(self, hyp, args):
4738 return IsEqual(hyp.GetFineness(), args[0])
4740 ## Defines "SegmentLengthAroundVertex" hypothesis
4741 # @param length for the segment length
4742 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4743 # Any other integer value means that the hypothesis will be set on the
4744 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4745 # @param UseExisting if ==true - searches for an existing hypothesis created with
4746 # the same parameters, else (default) - creates a new one
4747 # @ingroup l3_algos_segmarv
4748 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4750 store_geom = self.geom
4751 if type(vertex) is types.IntType:
4752 if vertex == 0 or vertex == 1:
4753 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4761 if self.geom is None:
4762 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4764 name = GetName(self.geom)
4767 piece = self.mesh.geom
4768 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4769 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4771 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4773 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4775 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4776 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4778 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4779 CompareMethod=self.CompareLengthNearVertex)
4780 self.geom = store_geom
4781 hyp.SetLength( length )
4784 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4785 # @ingroup l3_algos_segmarv
4786 def CompareLengthNearVertex(self, hyp, args):
4787 return IsEqual(hyp.GetLength(), args[0])
4789 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4790 # If the 2D mesher sees that all boundary edges are quadratic,
4791 # it generates quadratic faces, else it generates linear faces using
4792 # medium nodes as if they are vertices.
4793 # The 3D mesher generates quadratic volumes only if all boundary faces
4794 # are quadratic, else it fails.
4796 # @ingroup l3_hypos_additi
4797 def QuadraticMesh(self):
4798 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4801 # Public class: Mesh_CompositeSegment
4802 # --------------------------
4804 ## Defines a segment 1D algorithm for discretization
4806 # @ingroup l3_algos_basic
4807 class Mesh_CompositeSegment(Mesh_Segment):
4809 ## Private constructor.
4810 def __init__(self, mesh, geom=0):
4811 self.Create(mesh, geom, "CompositeSegment_1D")
4814 # Public class: Mesh_Segment_Python
4815 # ---------------------------------
4817 ## Defines a segment 1D algorithm for discretization with python function
4819 # @ingroup l3_algos_basic
4820 class Mesh_Segment_Python(Mesh_Segment):
4822 ## Private constructor.
4823 def __init__(self, mesh, geom=0):
4824 import Python1dPlugin
4825 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4827 ## Defines "PythonSplit1D" hypothesis
4828 # @param n for the number of segments that cut an edge
4829 # @param func for the python function that calculates the length of all segments
4830 # @param UseExisting if ==true - searches for the existing hypothesis created with
4831 # the same parameters, else (default) - creates a new one
4832 # @ingroup l3_hypos_1dhyps
4833 def PythonSplit1D(self, n, func, UseExisting=0):
4834 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4835 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4836 hyp.SetNumberOfSegments(n)
4837 hyp.SetPythonLog10RatioFunction(func)
4840 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4841 def ComparePythonSplit1D(self, hyp, args):
4842 #if hyp.GetNumberOfSegments() == args[0]:
4843 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4847 # Public class: Mesh_Triangle
4848 # ---------------------------
4850 ## Defines a triangle 2D algorithm
4852 # @ingroup l3_algos_basic
4853 class Mesh_Triangle(Mesh_Algorithm):
4862 ## Private constructor.
4863 def __init__(self, mesh, algoType, geom=0):
4864 Mesh_Algorithm.__init__(self)
4866 self.algoType = algoType
4867 if algoType == MEFISTO:
4868 self.Create(mesh, geom, "MEFISTO_2D")
4870 elif algoType == BLSURF:
4872 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4873 #self.SetPhysicalMesh() - PAL19680
4874 elif algoType == NETGEN:
4876 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4878 elif algoType == NETGEN_2D:
4880 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4883 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4884 # @param area for the maximum area of each triangle
4885 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4886 # same parameters, else (default) - creates a new one
4888 # Only for algoType == MEFISTO || NETGEN_2D
4889 # @ingroup l3_hypos_2dhyps
4890 def MaxElementArea(self, area, UseExisting=0):
4891 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4892 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4893 CompareMethod=self.CompareMaxElementArea)
4894 elif self.algoType == NETGEN:
4895 hyp = self.Parameters(SIMPLE)
4896 hyp.SetMaxElementArea(area)
4899 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4900 def CompareMaxElementArea(self, hyp, args):
4901 return IsEqual(hyp.GetMaxElementArea(), args[0])
4903 ## Defines "LengthFromEdges" hypothesis to build triangles
4904 # based on the length of the edges taken from the wire
4906 # Only for algoType == MEFISTO || NETGEN_2D
4907 # @ingroup l3_hypos_2dhyps
4908 def LengthFromEdges(self):
4909 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4910 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4912 elif self.algoType == NETGEN:
4913 hyp = self.Parameters(SIMPLE)
4914 hyp.LengthFromEdges()
4917 ## Sets a way to define size of mesh elements to generate.
4918 # @param thePhysicalMesh is: DefaultSize or Custom.
4919 # @ingroup l3_hypos_blsurf
4920 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4921 # Parameter of BLSURF algo
4922 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4924 ## Sets size of mesh elements to generate.
4925 # @ingroup l3_hypos_blsurf
4926 def SetPhySize(self, theVal):
4927 # Parameter of BLSURF algo
4928 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4929 self.Parameters().SetPhySize(theVal)
4931 ## Sets lower boundary of mesh element size (PhySize).
4932 # @ingroup l3_hypos_blsurf
4933 def SetPhyMin(self, theVal=-1):
4934 # Parameter of BLSURF algo
4935 self.Parameters().SetPhyMin(theVal)
4937 ## Sets upper boundary of mesh element size (PhySize).
4938 # @ingroup l3_hypos_blsurf
4939 def SetPhyMax(self, theVal=-1):
4940 # Parameter of BLSURF algo
4941 self.Parameters().SetPhyMax(theVal)
4943 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4944 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4945 # @ingroup l3_hypos_blsurf
4946 def SetGeometricMesh(self, theGeometricMesh=0):
4947 # Parameter of BLSURF algo
4948 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4949 self.params.SetGeometricMesh(theGeometricMesh)
4951 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4952 # @ingroup l3_hypos_blsurf
4953 def SetAngleMeshS(self, theVal=_angleMeshS):
4954 # Parameter of BLSURF algo
4955 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4956 self.params.SetAngleMeshS(theVal)
4958 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4959 # @ingroup l3_hypos_blsurf
4960 def SetAngleMeshC(self, theVal=_angleMeshS):
4961 # Parameter of BLSURF algo
4962 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4963 self.params.SetAngleMeshC(theVal)
4965 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4966 # @ingroup l3_hypos_blsurf
4967 def SetGeoMin(self, theVal=-1):
4968 # Parameter of BLSURF algo
4969 self.Parameters().SetGeoMin(theVal)
4971 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4972 # @ingroup l3_hypos_blsurf
4973 def SetGeoMax(self, theVal=-1):
4974 # Parameter of BLSURF algo
4975 self.Parameters().SetGeoMax(theVal)
4977 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4978 # @ingroup l3_hypos_blsurf
4979 def SetGradation(self, theVal=_gradation):
4980 # Parameter of BLSURF algo
4981 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4982 self.params.SetGradation(theVal)
4984 ## Sets topology usage way.
4985 # @param way defines how mesh conformity is assured <ul>
4986 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4987 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4988 # @ingroup l3_hypos_blsurf
4989 def SetTopology(self, way):
4990 # Parameter of BLSURF algo
4991 self.Parameters().SetTopology(way)
4993 ## To respect geometrical edges or not.
4994 # @ingroup l3_hypos_blsurf
4995 def SetDecimesh(self, toIgnoreEdges=False):
4996 # Parameter of BLSURF algo
4997 self.Parameters().SetDecimesh(toIgnoreEdges)
4999 ## Sets verbosity level in the range 0 to 100.
5000 # @ingroup l3_hypos_blsurf
5001 def SetVerbosity(self, level):
5002 # Parameter of BLSURF algo
5003 self.Parameters().SetVerbosity(level)
5005 ## Sets advanced option value.
5006 # @ingroup l3_hypos_blsurf
5007 def SetOptionValue(self, optionName, level):
5008 # Parameter of BLSURF algo
5009 self.Parameters().SetOptionValue(optionName,level)
5011 ## Sets QuadAllowed flag.
5012 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
5013 # @ingroup l3_hypos_netgen l3_hypos_blsurf
5014 def SetQuadAllowed(self, toAllow=True):
5015 if self.algoType == NETGEN_2D:
5018 hasSimpleHyps = False
5019 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
5020 for hyp in self.mesh.GetHypothesisList( self.geom ):
5021 if hyp.GetName() in simpleHyps:
5022 hasSimpleHyps = True
5023 if hyp.GetName() == "QuadranglePreference":
5024 if not toAllow: # remove QuadranglePreference
5025 self.mesh.RemoveHypothesis( self.geom, hyp )
5031 if toAllow: # add QuadranglePreference
5032 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5037 if self.Parameters():
5038 self.params.SetQuadAllowed(toAllow)
5041 ## Defines hypothesis having several parameters
5043 # @ingroup l3_hypos_netgen
5044 def Parameters(self, which=SOLE):
5046 if self.algoType == NETGEN:
5048 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5049 "libNETGENEngine.so", UseExisting=0)
5051 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5052 "libNETGENEngine.so", UseExisting=0)
5053 elif self.algoType == MEFISTO:
5054 print "Mefisto algo support no multi-parameter hypothesis"
5055 elif self.algoType == NETGEN_2D:
5056 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5057 "libNETGENEngine.so", UseExisting=0)
5058 elif self.algoType == BLSURF:
5059 self.params = self.Hypothesis("BLSURF_Parameters", [],
5060 "libBLSURFEngine.so", UseExisting=0)
5062 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5067 # Only for algoType == NETGEN
5068 # @ingroup l3_hypos_netgen
5069 def SetMaxSize(self, theSize):
5070 if self.Parameters():
5071 self.params.SetMaxSize(theSize)
5073 ## Sets SecondOrder flag
5075 # Only for algoType == NETGEN
5076 # @ingroup l3_hypos_netgen
5077 def SetSecondOrder(self, theVal):
5078 if self.Parameters():
5079 self.params.SetSecondOrder(theVal)
5081 ## Sets Optimize flag
5083 # Only for algoType == NETGEN
5084 # @ingroup l3_hypos_netgen
5085 def SetOptimize(self, theVal):
5086 if self.Parameters():
5087 self.params.SetOptimize(theVal)
5090 # @param theFineness is:
5091 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5093 # Only for algoType == NETGEN
5094 # @ingroup l3_hypos_netgen
5095 def SetFineness(self, theFineness):
5096 if self.Parameters():
5097 self.params.SetFineness(theFineness)
5101 # Only for algoType == NETGEN
5102 # @ingroup l3_hypos_netgen
5103 def SetGrowthRate(self, theRate):
5104 if self.Parameters():
5105 self.params.SetGrowthRate(theRate)
5107 ## Sets NbSegPerEdge
5109 # Only for algoType == NETGEN
5110 # @ingroup l3_hypos_netgen
5111 def SetNbSegPerEdge(self, theVal):
5112 if self.Parameters():
5113 self.params.SetNbSegPerEdge(theVal)
5115 ## Sets NbSegPerRadius
5117 # Only for algoType == NETGEN
5118 # @ingroup l3_hypos_netgen
5119 def SetNbSegPerRadius(self, theVal):
5120 if self.Parameters():
5121 self.params.SetNbSegPerRadius(theVal)
5123 ## Sets number of segments overriding value set by SetLocalLength()
5125 # Only for algoType == NETGEN
5126 # @ingroup l3_hypos_netgen
5127 def SetNumberOfSegments(self, theVal):
5128 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5130 ## Sets number of segments overriding value set by SetNumberOfSegments()
5132 # Only for algoType == NETGEN
5133 # @ingroup l3_hypos_netgen
5134 def SetLocalLength(self, theVal):
5135 self.Parameters(SIMPLE).SetLocalLength(theVal)
5140 # Public class: Mesh_Quadrangle
5141 # -----------------------------
5143 ## Defines a quadrangle 2D algorithm
5145 # @ingroup l3_algos_basic
5146 class Mesh_Quadrangle(Mesh_Algorithm):
5150 ## Private constructor.
5151 def __init__(self, mesh, geom=0):
5152 Mesh_Algorithm.__init__(self)
5153 self.Create(mesh, geom, "Quadrangle_2D")
5156 ## Defines "QuadrangleParameters" hypothesis
5157 # @param quadType defines the algorithm of transition between differently descretized
5158 # sides of a geometrical face:
5159 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5160 # area along the finer meshed sides.
5161 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5162 # finer meshed sides.
5163 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5164 # the finer meshed sides, iff the total quantity of segments on
5165 # all four sides of the face is even (divisible by 2).
5166 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5167 # area is located along the coarser meshed sides.
5168 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5169 # is made gradually, layer by layer. This type has a limitation on
5170 # the number of segments: one pair of opposite sides must have the
5171 # same number of segments, the other pair must have an even difference
5172 # between the numbers of segments on the sides.
5173 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5174 # will be created while other elements will be quadrangles.
5175 # Vertex can be either a GEOM_Object or a vertex ID within the
5177 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5178 # the same parameters, else (default) - creates a new one
5179 # @ingroup l3_hypos_quad
5180 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5181 vertexID = triangleVertex
5182 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5183 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5185 compFun = lambda hyp,args: \
5186 hyp.GetQuadType() == args[0] and \
5187 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5188 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5189 UseExisting = UseExisting, CompareMethod=compFun)
5191 if self.params.GetQuadType() != quadType:
5192 self.params.SetQuadType(quadType)
5194 self.params.SetTriaVertex( vertexID )
5197 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5198 # quadrangles are built in the transition area along the finer meshed sides,
5199 # iff the total quantity of segments on all four sides of the face is even.
5200 # @param reversed if True, transition area is located along the coarser meshed sides.
5201 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5202 # the same parameters, else (default) - creates a new one
5203 # @ingroup l3_hypos_quad
5204 def QuadranglePreference(self, reversed=False, UseExisting=0):
5206 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5207 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5209 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5210 # triangles are built in the transition area along the finer meshed sides.
5211 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5212 # the same parameters, else (default) - creates a new one
5213 # @ingroup l3_hypos_quad
5214 def TrianglePreference(self, UseExisting=0):
5215 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5217 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5218 # quadrangles are built and the transition between the sides is made gradually,
5219 # layer by layer. This type has a limitation on the number of segments: one pair
5220 # of opposite sides must have the same number of segments, the other pair must
5221 # have an even difference between the numbers of segments on the sides.
5222 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5223 # the same parameters, else (default) - creates a new one
5224 # @ingroup l3_hypos_quad
5225 def Reduced(self, UseExisting=0):
5226 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5228 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5229 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5230 # will be created while other elements will be quadrangles.
5231 # Vertex can be either a GEOM_Object or a vertex ID within the
5233 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5234 # the same parameters, else (default) - creates a new one
5235 # @ingroup l3_hypos_quad
5236 def TriangleVertex(self, vertex, UseExisting=0):
5237 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5240 # Public class: Mesh_Tetrahedron
5241 # ------------------------------
5243 ## Defines a tetrahedron 3D algorithm
5245 # @ingroup l3_algos_basic
5246 class Mesh_Tetrahedron(Mesh_Algorithm):
5251 ## Private constructor.
5252 def __init__(self, mesh, algoType, geom=0):
5253 Mesh_Algorithm.__init__(self)
5255 if algoType == NETGEN:
5257 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5260 elif algoType == FULL_NETGEN:
5262 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5265 elif algoType == GHS3D:
5267 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5270 elif algoType == GHS3DPRL:
5271 CheckPlugin(GHS3DPRL)
5272 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5275 self.algoType = algoType
5277 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5278 # @param vol for the maximum volume of each tetrahedron
5279 # @param UseExisting if ==true - searches for the existing hypothesis created with
5280 # the same parameters, else (default) - creates a new one
5281 # @ingroup l3_hypos_maxvol
5282 def MaxElementVolume(self, vol, UseExisting=0):
5283 if self.algoType == NETGEN:
5284 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5285 CompareMethod=self.CompareMaxElementVolume)
5286 hyp.SetMaxElementVolume(vol)
5288 elif self.algoType == FULL_NETGEN:
5289 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5292 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5293 def CompareMaxElementVolume(self, hyp, args):
5294 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5296 ## Defines hypothesis having several parameters
5298 # @ingroup l3_hypos_netgen
5299 def Parameters(self, which=SOLE):
5302 if self.algoType == FULL_NETGEN:
5304 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5305 "libNETGENEngine.so", UseExisting=0)
5307 self.params = self.Hypothesis("NETGEN_Parameters", [],
5308 "libNETGENEngine.so", UseExisting=0)
5310 elif self.algoType == NETGEN:
5311 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5312 "libNETGENEngine.so", UseExisting=0)
5314 elif self.algoType == GHS3D:
5315 self.params = self.Hypothesis("GHS3D_Parameters", [],
5316 "libGHS3DEngine.so", UseExisting=0)
5318 elif self.algoType == GHS3DPRL:
5319 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5320 "libGHS3DPRLEngine.so", UseExisting=0)
5322 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
5327 # Parameter of FULL_NETGEN and NETGEN
5328 # @ingroup l3_hypos_netgen
5329 def SetMaxSize(self, theSize):
5330 self.Parameters().SetMaxSize(theSize)
5332 ## Sets SecondOrder flag
5333 # Parameter of FULL_NETGEN
5334 # @ingroup l3_hypos_netgen
5335 def SetSecondOrder(self, theVal):
5336 self.Parameters().SetSecondOrder(theVal)
5338 ## Sets Optimize flag
5339 # Parameter of FULL_NETGEN and NETGEN
5340 # @ingroup l3_hypos_netgen
5341 def SetOptimize(self, theVal):
5342 self.Parameters().SetOptimize(theVal)
5345 # @param theFineness is:
5346 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5347 # Parameter of FULL_NETGEN
5348 # @ingroup l3_hypos_netgen
5349 def SetFineness(self, theFineness):
5350 self.Parameters().SetFineness(theFineness)
5353 # Parameter of FULL_NETGEN
5354 # @ingroup l3_hypos_netgen
5355 def SetGrowthRate(self, theRate):
5356 self.Parameters().SetGrowthRate(theRate)
5358 ## Sets NbSegPerEdge
5359 # Parameter of FULL_NETGEN
5360 # @ingroup l3_hypos_netgen
5361 def SetNbSegPerEdge(self, theVal):
5362 self.Parameters().SetNbSegPerEdge(theVal)
5364 ## Sets NbSegPerRadius
5365 # Parameter of FULL_NETGEN
5366 # @ingroup l3_hypos_netgen
5367 def SetNbSegPerRadius(self, theVal):
5368 self.Parameters().SetNbSegPerRadius(theVal)
5370 ## Sets number of segments overriding value set by SetLocalLength()
5371 # Only for algoType == NETGEN_FULL
5372 # @ingroup l3_hypos_netgen
5373 def SetNumberOfSegments(self, theVal):
5374 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5376 ## Sets number of segments overriding value set by SetNumberOfSegments()
5377 # Only for algoType == NETGEN_FULL
5378 # @ingroup l3_hypos_netgen
5379 def SetLocalLength(self, theVal):
5380 self.Parameters(SIMPLE).SetLocalLength(theVal)
5382 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5383 # Overrides value set by LengthFromEdges()
5384 # Only for algoType == NETGEN_FULL
5385 # @ingroup l3_hypos_netgen
5386 def MaxElementArea(self, area):
5387 self.Parameters(SIMPLE).SetMaxElementArea(area)
5389 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5390 # Overrides value set by MaxElementArea()
5391 # Only for algoType == NETGEN_FULL
5392 # @ingroup l3_hypos_netgen
5393 def LengthFromEdges(self):
5394 self.Parameters(SIMPLE).LengthFromEdges()
5396 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5397 # Overrides value set by MaxElementVolume()
5398 # Only for algoType == NETGEN_FULL
5399 # @ingroup l3_hypos_netgen
5400 def LengthFromFaces(self):
5401 self.Parameters(SIMPLE).LengthFromFaces()
5403 ## To mesh "holes" in a solid or not. Default is to mesh.
5404 # @ingroup l3_hypos_ghs3dh
5405 def SetToMeshHoles(self, toMesh):
5406 # Parameter of GHS3D
5407 self.Parameters().SetToMeshHoles(toMesh)
5409 ## Set Optimization level:
5410 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5411 # Strong_Optimization.
5412 # Default is Standard_Optimization
5413 # @ingroup l3_hypos_ghs3dh
5414 def SetOptimizationLevel(self, level):
5415 # Parameter of GHS3D
5416 self.Parameters().SetOptimizationLevel(level)
5418 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5419 # @ingroup l3_hypos_ghs3dh
5420 def SetMaximumMemory(self, MB):
5421 # Advanced parameter of GHS3D
5422 self.Parameters().SetMaximumMemory(MB)
5424 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5425 # automatic memory adjustment mode.
5426 # @ingroup l3_hypos_ghs3dh
5427 def SetInitialMemory(self, MB):
5428 # Advanced parameter of GHS3D
5429 self.Parameters().SetInitialMemory(MB)
5431 ## Path to working directory.
5432 # @ingroup l3_hypos_ghs3dh
5433 def SetWorkingDirectory(self, path):
5434 # Advanced parameter of GHS3D
5435 self.Parameters().SetWorkingDirectory(path)
5437 ## To keep working files or remove them. Log file remains in case of errors anyway.
5438 # @ingroup l3_hypos_ghs3dh
5439 def SetKeepFiles(self, toKeep):
5440 # Advanced parameter of GHS3D and GHS3DPRL
5441 self.Parameters().SetKeepFiles(toKeep)
5443 ## To set verbose level [0-10]. <ul>
5444 #<li> 0 - no standard output,
5445 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5446 # indicates when the final mesh is being saved. In addition the software
5447 # gives indication regarding the CPU time.
5448 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5449 # histogram of the skin mesh, quality statistics histogram together with
5450 # the characteristics of the final mesh.</ul>
5451 # @ingroup l3_hypos_ghs3dh
5452 def SetVerboseLevel(self, level):
5453 # Advanced parameter of GHS3D
5454 self.Parameters().SetVerboseLevel(level)
5456 ## To create new nodes.
5457 # @ingroup l3_hypos_ghs3dh
5458 def SetToCreateNewNodes(self, toCreate):
5459 # Advanced parameter of GHS3D
5460 self.Parameters().SetToCreateNewNodes(toCreate)
5462 ## To use boundary recovery version which tries to create mesh on a very poor
5463 # quality surface mesh.
5464 # @ingroup l3_hypos_ghs3dh
5465 def SetToUseBoundaryRecoveryVersion(self, toUse):
5466 # Advanced parameter of GHS3D
5467 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5469 ## Sets command line option as text.
5470 # @ingroup l3_hypos_ghs3dh
5471 def SetTextOption(self, option):
5472 # Advanced parameter of GHS3D
5473 self.Parameters().SetTextOption(option)
5475 ## Sets MED files name and path.
5476 def SetMEDName(self, value):
5477 self.Parameters().SetMEDName(value)
5479 ## Sets the number of partition of the initial mesh
5480 def SetNbPart(self, value):
5481 self.Parameters().SetNbPart(value)
5483 ## When big mesh, start tepal in background
5484 def SetBackground(self, value):
5485 self.Parameters().SetBackground(value)
5487 # Public class: Mesh_Hexahedron
5488 # ------------------------------
5490 ## Defines a hexahedron 3D algorithm
5492 # @ingroup l3_algos_basic
5493 class Mesh_Hexahedron(Mesh_Algorithm):
5498 ## Private constructor.
5499 def __init__(self, mesh, algoType=Hexa, geom=0):
5500 Mesh_Algorithm.__init__(self)
5502 self.algoType = algoType
5504 if algoType == Hexa:
5505 self.Create(mesh, geom, "Hexa_3D")
5508 elif algoType == Hexotic:
5509 CheckPlugin(Hexotic)
5510 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5513 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5514 # @ingroup l3_hypos_hexotic
5515 def MinMaxQuad(self, min=3, max=8, quad=True):
5516 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5518 self.params.SetHexesMinLevel(min)
5519 self.params.SetHexesMaxLevel(max)
5520 self.params.SetHexoticQuadrangles(quad)
5523 # Deprecated, only for compatibility!
5524 # Public class: Mesh_Netgen
5525 # ------------------------------
5527 ## Defines a NETGEN-based 2D or 3D algorithm
5528 # that needs no discrete boundary (i.e. independent)
5530 # This class is deprecated, only for compatibility!
5533 # @ingroup l3_algos_basic
5534 class Mesh_Netgen(Mesh_Algorithm):
5538 ## Private constructor.
5539 def __init__(self, mesh, is3D, geom=0):
5540 Mesh_Algorithm.__init__(self)
5546 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5550 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5553 ## Defines the hypothesis containing parameters of the algorithm
5554 def Parameters(self):
5556 hyp = self.Hypothesis("NETGEN_Parameters", [],
5557 "libNETGENEngine.so", UseExisting=0)
5559 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5560 "libNETGENEngine.so", UseExisting=0)
5563 # Public class: Mesh_Projection1D
5564 # ------------------------------
5566 ## Defines a projection 1D algorithm
5567 # @ingroup l3_algos_proj
5569 class Mesh_Projection1D(Mesh_Algorithm):
5571 ## Private constructor.
5572 def __init__(self, mesh, geom=0):
5573 Mesh_Algorithm.__init__(self)
5574 self.Create(mesh, geom, "Projection_1D")
5576 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5577 # a mesh pattern is taken, and, optionally, the association of vertices
5578 # between the source edge and a target edge (to which a hypothesis is assigned)
5579 # @param edge from which nodes distribution is taken
5580 # @param mesh from which nodes distribution is taken (optional)
5581 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5582 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5583 # to associate with \a srcV (optional)
5584 # @param UseExisting if ==true - searches for the existing hypothesis created with
5585 # the same parameters, else (default) - creates a new one
5586 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5587 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5589 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5590 hyp.SetSourceEdge( edge )
5591 if not mesh is None and isinstance(mesh, Mesh):
5592 mesh = mesh.GetMesh()
5593 hyp.SetSourceMesh( mesh )
5594 hyp.SetVertexAssociation( srcV, tgtV )
5597 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5598 #def CompareSourceEdge(self, hyp, args):
5599 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5603 # Public class: Mesh_Projection2D
5604 # ------------------------------
5606 ## Defines a projection 2D algorithm
5607 # @ingroup l3_algos_proj
5609 class Mesh_Projection2D(Mesh_Algorithm):
5611 ## Private constructor.
5612 def __init__(self, mesh, geom=0):
5613 Mesh_Algorithm.__init__(self)
5614 self.Create(mesh, geom, "Projection_2D")
5616 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5617 # a mesh pattern is taken, and, optionally, the association of vertices
5618 # between the source face and the target face (to which a hypothesis is assigned)
5619 # @param face from which the mesh pattern is taken
5620 # @param mesh from which the mesh pattern is taken (optional)
5621 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5622 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5623 # to associate with \a srcV1 (optional)
5624 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5625 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5626 # to associate with \a srcV2 (optional)
5627 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5628 # the same parameters, else (default) - forces the creation a new one
5630 # Note: all association vertices must belong to one edge of a face
5631 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5632 srcV2=None, tgtV2=None, UseExisting=0):
5633 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5635 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5636 hyp.SetSourceFace( face )
5637 if not mesh is None and isinstance(mesh, Mesh):
5638 mesh = mesh.GetMesh()
5639 hyp.SetSourceMesh( mesh )
5640 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5643 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5644 #def CompareSourceFace(self, hyp, args):
5645 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5648 # Public class: Mesh_Projection3D
5649 # ------------------------------
5651 ## Defines a projection 3D algorithm
5652 # @ingroup l3_algos_proj
5654 class Mesh_Projection3D(Mesh_Algorithm):
5656 ## Private constructor.
5657 def __init__(self, mesh, geom=0):
5658 Mesh_Algorithm.__init__(self)
5659 self.Create(mesh, geom, "Projection_3D")
5661 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5662 # the mesh pattern is taken, and, optionally, the association of vertices
5663 # between the source and the target solid (to which a hipothesis is assigned)
5664 # @param solid from where the mesh pattern is taken
5665 # @param mesh from where the mesh pattern is taken (optional)
5666 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5667 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5668 # to associate with \a srcV1 (optional)
5669 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5670 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5671 # to associate with \a srcV2 (optional)
5672 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5673 # the same parameters, else (default) - creates a new one
5675 # Note: association vertices must belong to one edge of a solid
5676 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5677 srcV2=0, tgtV2=0, UseExisting=0):
5678 hyp = self.Hypothesis("ProjectionSource3D",
5679 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5681 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5682 hyp.SetSource3DShape( solid )
5683 if not mesh is None and isinstance(mesh, Mesh):
5684 mesh = mesh.GetMesh()
5685 hyp.SetSourceMesh( mesh )
5686 if srcV1 and srcV2 and tgtV1 and tgtV2:
5687 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5688 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5691 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5692 #def CompareSourceShape3D(self, hyp, args):
5693 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5697 # Public class: Mesh_Prism
5698 # ------------------------
5700 ## Defines a 3D extrusion algorithm
5701 # @ingroup l3_algos_3dextr
5703 class Mesh_Prism3D(Mesh_Algorithm):
5705 ## Private constructor.
5706 def __init__(self, mesh, geom=0):
5707 Mesh_Algorithm.__init__(self)
5708 self.Create(mesh, geom, "Prism_3D")
5710 # Public class: Mesh_RadialPrism
5711 # -------------------------------
5713 ## Defines a Radial Prism 3D algorithm
5714 # @ingroup l3_algos_radialp
5716 class Mesh_RadialPrism3D(Mesh_Algorithm):
5718 ## Private constructor.
5719 def __init__(self, mesh, geom=0):
5720 Mesh_Algorithm.__init__(self)
5721 self.Create(mesh, geom, "RadialPrism_3D")
5723 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5724 self.nbLayers = None
5726 ## Return 3D hypothesis holding the 1D one
5727 def Get3DHypothesis(self):
5728 return self.distribHyp
5730 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5731 # hypothesis. Returns the created hypothesis
5732 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5733 #print "OwnHypothesis",hypType
5734 if not self.nbLayers is None:
5735 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5736 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5737 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5738 self.mesh.smeshpyD.SetCurrentStudy( None )
5739 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5740 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5741 self.distribHyp.SetLayerDistribution( hyp )
5744 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5745 # prisms to build between the inner and outer shells
5746 # @param n number of layers
5747 # @param UseExisting if ==true - searches for the existing hypothesis created with
5748 # the same parameters, else (default) - creates a new one
5749 def NumberOfLayers(self, n, UseExisting=0):
5750 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5751 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5752 CompareMethod=self.CompareNumberOfLayers)
5753 self.nbLayers.SetNumberOfLayers( n )
5754 return self.nbLayers
5756 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5757 def CompareNumberOfLayers(self, hyp, args):
5758 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5760 ## Defines "LocalLength" hypothesis, specifying the segment length
5761 # to build between the inner and the outer shells
5762 # @param l the length of segments
5763 # @param p the precision of rounding
5764 def LocalLength(self, l, p=1e-07):
5765 hyp = self.OwnHypothesis("LocalLength", [l,p])
5770 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5771 # prisms to build between the inner and the outer shells.
5772 # @param n the number of layers
5773 # @param s the scale factor (optional)
5774 def NumberOfSegments(self, n, s=[]):
5776 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5778 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5779 hyp.SetDistrType( 1 )
5780 hyp.SetScaleFactor(s)
5781 hyp.SetNumberOfSegments(n)
5784 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5785 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5786 # @param start the length of the first segment
5787 # @param end the length of the last segment
5788 def Arithmetic1D(self, start, end ):
5789 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5790 hyp.SetLength(start, 1)
5791 hyp.SetLength(end , 0)
5794 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5795 # to build between the inner and the outer shells as geometric length increasing
5796 # @param start for the length of the first segment
5797 # @param end for the length of the last segment
5798 def StartEndLength(self, start, end):
5799 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5800 hyp.SetLength(start, 1)
5801 hyp.SetLength(end , 0)
5804 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5805 # to build between the inner and outer shells
5806 # @param fineness defines the quality of the mesh within the range [0-1]
5807 def AutomaticLength(self, fineness=0):
5808 hyp = self.OwnHypothesis("AutomaticLength")
5809 hyp.SetFineness( fineness )
5812 # Public class: Mesh_RadialQuadrangle1D2D
5813 # -------------------------------
5815 ## Defines a Radial Quadrangle 1D2D algorithm
5816 # @ingroup l2_algos_radialq
5818 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5820 ## Private constructor.
5821 def __init__(self, mesh, geom=0):
5822 Mesh_Algorithm.__init__(self)
5823 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5825 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5826 self.nbLayers = None
5828 ## Return 2D hypothesis holding the 1D one
5829 def Get2DHypothesis(self):
5830 return self.distribHyp
5832 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5833 # hypothesis. Returns the created hypothesis
5834 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5835 #print "OwnHypothesis",hypType
5837 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5838 if self.distribHyp is None:
5839 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5841 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5842 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5843 self.mesh.smeshpyD.SetCurrentStudy( None )
5844 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5845 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5846 self.distribHyp.SetLayerDistribution( hyp )
5849 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5850 # @param n number of layers
5851 # @param UseExisting if ==true - searches for the existing hypothesis created with
5852 # the same parameters, else (default) - creates a new one
5853 def NumberOfLayers(self, n, UseExisting=0):
5855 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5856 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5857 CompareMethod=self.CompareNumberOfLayers)
5858 self.nbLayers.SetNumberOfLayers( n )
5859 return self.nbLayers
5861 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5862 def CompareNumberOfLayers(self, hyp, args):
5863 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5865 ## Defines "LocalLength" hypothesis, specifying the segment length
5866 # @param l the length of segments
5867 # @param p the precision of rounding
5868 def LocalLength(self, l, p=1e-07):
5869 hyp = self.OwnHypothesis("LocalLength", [l,p])
5874 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5875 # @param n the number of layers
5876 # @param s the scale factor (optional)
5877 def NumberOfSegments(self, n, s=[]):
5879 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5881 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5882 hyp.SetDistrType( 1 )
5883 hyp.SetScaleFactor(s)
5884 hyp.SetNumberOfSegments(n)
5887 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5888 # with a length that changes in arithmetic progression
5889 # @param start the length of the first segment
5890 # @param end the length of the last segment
5891 def Arithmetic1D(self, start, end ):
5892 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5893 hyp.SetLength(start, 1)
5894 hyp.SetLength(end , 0)
5897 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5898 # as geometric length increasing
5899 # @param start for the length of the first segment
5900 # @param end for the length of the last segment
5901 def StartEndLength(self, start, end):
5902 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5903 hyp.SetLength(start, 1)
5904 hyp.SetLength(end , 0)
5907 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5908 # @param fineness defines the quality of the mesh within the range [0-1]
5909 def AutomaticLength(self, fineness=0):
5910 hyp = self.OwnHypothesis("AutomaticLength")
5911 hyp.SetFineness( fineness )
5915 # Public class: Mesh_UseExistingElements
5916 # --------------------------------------
5917 ## Defines a Radial Quadrangle 1D2D algorithm
5918 # @ingroup l3_algos_basic
5920 class Mesh_UseExistingElements(Mesh_Algorithm):
5922 def __init__(self, dim, mesh, geom=0):
5924 self.Create(mesh, geom, "Import_1D")
5926 self.Create(mesh, geom, "Import_1D2D")
5929 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5930 # @param groups list of groups of edges
5931 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5932 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5933 # @param UseExisting if ==true - searches for the existing hypothesis created with
5934 # the same parameters, else (default) - creates a new one
5935 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5936 if self.algo.GetName() == "Import_2D":
5937 raise ValueError, "algoritm dimension mismatch"
5938 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5939 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5940 hyp.SetSourceEdges(groups)
5941 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5944 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5945 # @param groups list of groups of faces
5946 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5947 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5948 # @param UseExisting if ==true - searches for the existing hypothesis created with
5949 # the same parameters, else (default) - creates a new one
5950 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5951 if self.algo.GetName() == "Import_1D":
5952 raise ValueError, "algoritm dimension mismatch"
5953 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5954 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5955 hyp.SetSourceFaces(groups)
5956 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5959 def _compareHyp(self,hyp,args):
5960 if hasattr( hyp, "GetSourceEdges"):
5961 entries = hyp.GetSourceEdges()
5963 entries = hyp.GetSourceFaces()
5965 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5966 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5968 study = self.mesh.smeshpyD.GetCurrentStudy()
5971 ior = salome.orb.object_to_string(g)
5972 sobj = study.FindObjectIOR(ior)
5973 if sobj: entries2.append( sobj.GetID() )
5978 return entries == entries2
5982 # Private class: Mesh_UseExisting
5983 # -------------------------------
5984 class Mesh_UseExisting(Mesh_Algorithm):
5986 def __init__(self, dim, mesh, geom=0):
5988 self.Create(mesh, geom, "UseExisting_1D")
5990 self.Create(mesh, geom, "UseExisting_2D")
5993 import salome_notebook
5994 notebook = salome_notebook.notebook
5996 ##Return values of the notebook variables
5997 def ParseParameters(last, nbParams,nbParam, value):
6001 listSize = len(last)
6002 for n in range(0,nbParams):
6004 if counter < listSize:
6005 strResult = strResult + last[counter]
6007 strResult = strResult + ""
6009 if isinstance(value, str):
6010 if notebook.isVariable(value):
6011 result = notebook.get(value)
6012 strResult=strResult+value
6014 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
6016 strResult=strResult+str(value)
6018 if nbParams - 1 != counter:
6019 strResult=strResult+var_separator #":"
6021 return result, strResult
6023 #Wrapper class for StdMeshers_LocalLength hypothesis
6024 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6026 ## Set Length parameter value
6027 # @param length numerical value or name of variable from notebook
6028 def SetLength(self, length):
6029 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6030 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6031 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6033 ## Set Precision parameter value
6034 # @param precision numerical value or name of variable from notebook
6035 def SetPrecision(self, precision):
6036 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6037 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6038 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6040 #Registering the new proxy for LocalLength
6041 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6044 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6045 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6047 def SetLayerDistribution(self, hypo):
6048 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6049 hypo.ClearParameters();
6050 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6052 #Registering the new proxy for LayerDistribution
6053 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6055 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6056 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6058 ## Set Length parameter value
6059 # @param length numerical value or name of variable from notebook
6060 def SetLength(self, length):
6061 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6062 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6063 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6065 #Registering the new proxy for SegmentLengthAroundVertex
6066 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6069 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6070 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6072 ## Set Length parameter value
6073 # @param length numerical value or name of variable from notebook
6074 # @param isStart true is length is Start Length, otherwise false
6075 def SetLength(self, length, isStart):
6079 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6080 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6081 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6083 #Registering the new proxy for Arithmetic1D
6084 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6086 #Wrapper class for StdMeshers_Deflection1D hypothesis
6087 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6089 ## Set Deflection parameter value
6090 # @param deflection numerical value or name of variable from notebook
6091 def SetDeflection(self, deflection):
6092 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6093 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6094 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6096 #Registering the new proxy for Deflection1D
6097 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6099 #Wrapper class for StdMeshers_StartEndLength hypothesis
6100 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6102 ## Set Length parameter value
6103 # @param length numerical value or name of variable from notebook
6104 # @param isStart true is length is Start Length, otherwise false
6105 def SetLength(self, length, isStart):
6109 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6110 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6111 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6113 #Registering the new proxy for StartEndLength
6114 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6116 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6117 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6119 ## Set Max Element Area parameter value
6120 # @param area numerical value or name of variable from notebook
6121 def SetMaxElementArea(self, area):
6122 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6123 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6124 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6126 #Registering the new proxy for MaxElementArea
6127 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6130 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6131 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6133 ## Set Max Element Volume parameter value
6134 # @param volume numerical value or name of variable from notebook
6135 def SetMaxElementVolume(self, volume):
6136 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6137 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6138 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6140 #Registering the new proxy for MaxElementVolume
6141 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6144 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6145 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6147 ## Set Number Of Layers parameter value
6148 # @param nbLayers numerical value or name of variable from notebook
6149 def SetNumberOfLayers(self, nbLayers):
6150 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6151 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6152 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6154 #Registering the new proxy for NumberOfLayers
6155 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6157 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6158 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6160 ## Set Number Of Segments parameter value
6161 # @param nbSeg numerical value or name of variable from notebook
6162 def SetNumberOfSegments(self, nbSeg):
6163 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6164 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6165 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6166 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6168 ## Set Scale Factor parameter value
6169 # @param factor numerical value or name of variable from notebook
6170 def SetScaleFactor(self, factor):
6171 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6172 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6173 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6175 #Registering the new proxy for NumberOfSegments
6176 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6178 if not noNETGENPlugin:
6179 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6180 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6182 ## Set Max Size parameter value
6183 # @param maxsize numerical value or name of variable from notebook
6184 def SetMaxSize(self, maxsize):
6185 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6186 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6187 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6188 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6190 ## Set Growth Rate parameter value
6191 # @param value numerical value or name of variable from notebook
6192 def SetGrowthRate(self, value):
6193 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6194 value, parameters = ParseParameters(lastParameters,4,2,value)
6195 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6196 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6198 ## Set Number of Segments per Edge parameter value
6199 # @param value numerical value or name of variable from notebook
6200 def SetNbSegPerEdge(self, value):
6201 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6202 value, parameters = ParseParameters(lastParameters,4,3,value)
6203 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6204 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6206 ## Set Number of Segments per Radius parameter value
6207 # @param value numerical value or name of variable from notebook
6208 def SetNbSegPerRadius(self, value):
6209 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6210 value, parameters = ParseParameters(lastParameters,4,4,value)
6211 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6212 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6214 #Registering the new proxy for NETGENPlugin_Hypothesis
6215 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6218 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6219 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6222 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6223 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6225 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6226 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6228 ## Set Number of Segments parameter value
6229 # @param nbSeg numerical value or name of variable from notebook
6230 def SetNumberOfSegments(self, nbSeg):
6231 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6232 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6233 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6234 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6236 ## Set Local Length parameter value
6237 # @param length numerical value or name of variable from notebook
6238 def SetLocalLength(self, length):
6239 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6240 length, parameters = ParseParameters(lastParameters,2,1,length)
6241 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6242 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6244 ## Set Max Element Area parameter value
6245 # @param area numerical value or name of variable from notebook
6246 def SetMaxElementArea(self, area):
6247 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6248 area, parameters = ParseParameters(lastParameters,2,2,area)
6249 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6250 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6252 def LengthFromEdges(self):
6253 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6255 value, parameters = ParseParameters(lastParameters,2,2,value)
6256 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6257 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6259 #Registering the new proxy for NETGEN_SimpleParameters_2D
6260 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6263 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6264 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6265 ## Set Max Element Volume parameter value
6266 # @param volume numerical value or name of variable from notebook
6267 def SetMaxElementVolume(self, volume):
6268 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6269 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6270 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6271 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6273 def LengthFromFaces(self):
6274 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6276 value, parameters = ParseParameters(lastParameters,3,3,value)
6277 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6278 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6280 #Registering the new proxy for NETGEN_SimpleParameters_3D
6281 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6283 pass # if not noNETGENPlugin:
6285 class Pattern(SMESH._objref_SMESH_Pattern):
6287 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6289 if isinstance(theNodeIndexOnKeyPoint1,str):
6291 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6293 theNodeIndexOnKeyPoint1 -= 1
6294 theMesh.SetParameters(Parameters)
6295 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6297 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6300 if isinstance(theNode000Index,str):
6302 if isinstance(theNode001Index,str):
6304 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6306 theNode000Index -= 1
6308 theNode001Index -= 1
6309 theMesh.SetParameters(Parameters)
6310 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6312 #Registering the new proxy for Pattern
6313 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)