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.ExtractShapes( 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)
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.Destroy()
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.Destroy()
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 name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1095 geompyD.addToStudy( self.geom, 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.Destroy()
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.Destroy()
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.Destroy()
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.Destroy()
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.Destroy()
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 # @param dimension - defines type of boundary elements to create:
3086 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3087 # @param groupName - a name of group to store created boundary elements in,
3088 # "" means not to create the group
3089 # @param meshName - a name of new mesh to store created boundary elements in,
3090 # "" means not to create the new mesh
3091 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
3092 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3093 # boundary elements will be copied into the new mesh
3094 # @return tuple (mesh, group) where bondary elements were added to
3095 # @ingroup l2_modif_edit
3096 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3097 toCopyElements=False, toCopyExistingBondary=False):
3098 if isinstance( elements, Mesh ):
3099 elements = elements.GetMesh()
3100 if ( isinstance( elements, list )):
3101 elemType = SMESH.ALL
3102 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3103 elements = self.editor.MakeIDSource(elements, elemType)
3104 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3105 toCopyElements,toCopyExistingBondary)
3106 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3109 ## Renumber mesh nodes
3110 # @ingroup l2_modif_renumber
3111 def RenumberNodes(self):
3112 self.editor.RenumberNodes()
3114 ## Renumber mesh elements
3115 # @ingroup l2_modif_renumber
3116 def RenumberElements(self):
3117 self.editor.RenumberElements()
3119 ## Generates new elements by rotation of the elements around the axis
3120 # @param IDsOfElements the list of ids of elements to sweep
3121 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3122 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3123 # @param NbOfSteps the number of steps
3124 # @param Tolerance tolerance
3125 # @param MakeGroups forces the generation of new groups from existing ones
3126 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3127 # of all steps, else - size of each step
3128 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3129 # @ingroup l2_modif_extrurev
3130 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3131 MakeGroups=False, TotalAngle=False):
3133 if isinstance(AngleInRadians,str):
3135 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3137 AngleInRadians = DegreesToRadians(AngleInRadians)
3138 if IDsOfElements == []:
3139 IDsOfElements = self.GetElementsId()
3140 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3141 Axis = self.smeshpyD.GetAxisStruct(Axis)
3142 Axis,AxisParameters = ParseAxisStruct(Axis)
3143 if TotalAngle and NbOfSteps:
3144 AngleInRadians /= NbOfSteps
3145 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3146 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3147 self.mesh.SetParameters(Parameters)
3149 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3150 AngleInRadians, NbOfSteps, Tolerance)
3151 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3154 ## Generates new elements by rotation of the elements of object around the axis
3155 # @param theObject object which elements should be sweeped.
3156 # It can be a mesh, a sub mesh or a group.
3157 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3158 # @param AngleInRadians the angle of Rotation
3159 # @param NbOfSteps number of steps
3160 # @param Tolerance tolerance
3161 # @param MakeGroups forces the generation of new groups from existing ones
3162 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3163 # of all steps, else - size of each step
3164 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3165 # @ingroup l2_modif_extrurev
3166 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3167 MakeGroups=False, TotalAngle=False):
3169 if isinstance(AngleInRadians,str):
3171 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3173 AngleInRadians = DegreesToRadians(AngleInRadians)
3174 if ( isinstance( theObject, Mesh )):
3175 theObject = theObject.GetMesh()
3176 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3177 Axis = self.smeshpyD.GetAxisStruct(Axis)
3178 Axis,AxisParameters = ParseAxisStruct(Axis)
3179 if TotalAngle and NbOfSteps:
3180 AngleInRadians /= NbOfSteps
3181 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3182 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3183 self.mesh.SetParameters(Parameters)
3185 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3186 NbOfSteps, Tolerance)
3187 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3190 ## Generates new elements by rotation of the elements of object around the axis
3191 # @param theObject object which elements should be sweeped.
3192 # It can be a mesh, a sub mesh or a group.
3193 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3194 # @param AngleInRadians the angle of Rotation
3195 # @param NbOfSteps number of steps
3196 # @param Tolerance tolerance
3197 # @param MakeGroups forces the generation of new groups from existing ones
3198 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3199 # of all steps, else - size of each step
3200 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3201 # @ingroup l2_modif_extrurev
3202 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3203 MakeGroups=False, TotalAngle=False):
3205 if isinstance(AngleInRadians,str):
3207 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3209 AngleInRadians = DegreesToRadians(AngleInRadians)
3210 if ( isinstance( theObject, Mesh )):
3211 theObject = theObject.GetMesh()
3212 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3213 Axis = self.smeshpyD.GetAxisStruct(Axis)
3214 Axis,AxisParameters = ParseAxisStruct(Axis)
3215 if TotalAngle and NbOfSteps:
3216 AngleInRadians /= NbOfSteps
3217 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3218 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3219 self.mesh.SetParameters(Parameters)
3221 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3222 NbOfSteps, Tolerance)
3223 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3226 ## Generates new elements by rotation of the elements of object around the axis
3227 # @param theObject object which elements should be sweeped.
3228 # It can be a mesh, a sub mesh or a group.
3229 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3230 # @param AngleInRadians the angle of Rotation
3231 # @param NbOfSteps number of steps
3232 # @param Tolerance tolerance
3233 # @param MakeGroups forces the generation of new groups from existing ones
3234 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3235 # of all steps, else - size of each step
3236 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3237 # @ingroup l2_modif_extrurev
3238 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3239 MakeGroups=False, TotalAngle=False):
3241 if isinstance(AngleInRadians,str):
3243 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3245 AngleInRadians = DegreesToRadians(AngleInRadians)
3246 if ( isinstance( theObject, Mesh )):
3247 theObject = theObject.GetMesh()
3248 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3249 Axis = self.smeshpyD.GetAxisStruct(Axis)
3250 Axis,AxisParameters = ParseAxisStruct(Axis)
3251 if TotalAngle and NbOfSteps:
3252 AngleInRadians /= NbOfSteps
3253 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3254 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3255 self.mesh.SetParameters(Parameters)
3257 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3258 NbOfSteps, Tolerance)
3259 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3262 ## Generates new elements by extrusion of the elements with given ids
3263 # @param IDsOfElements the list of elements ids for extrusion
3264 # @param StepVector vector or DirStruct, defining the direction and value of extrusion
3265 # @param NbOfSteps the number of steps
3266 # @param MakeGroups forces the generation of new groups from existing ones
3267 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3268 # @ingroup l2_modif_extrurev
3269 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3270 if IDsOfElements == []:
3271 IDsOfElements = self.GetElementsId()
3272 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3273 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3274 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3275 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3276 Parameters = StepVectorParameters + var_separator + Parameters
3277 self.mesh.SetParameters(Parameters)
3279 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3280 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3283 ## Generates new elements by extrusion of the elements with given ids
3284 # @param IDsOfElements is ids of elements
3285 # @param StepVector vector, defining the direction and value of extrusion
3286 # @param NbOfSteps the number of steps
3287 # @param ExtrFlags sets flags for extrusion
3288 # @param SewTolerance uses for comparing locations of nodes if flag
3289 # EXTRUSION_FLAG_SEW is set
3290 # @param MakeGroups forces the generation of new groups from existing ones
3291 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3292 # @ingroup l2_modif_extrurev
3293 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3294 ExtrFlags, SewTolerance, MakeGroups=False):
3295 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3296 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3298 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3299 ExtrFlags, SewTolerance)
3300 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3301 ExtrFlags, SewTolerance)
3304 ## Generates new elements by extrusion of the elements which belong to the object
3305 # @param theObject the object which elements should be processed.
3306 # It can be a mesh, a sub mesh or a group.
3307 # @param StepVector vector, defining the direction and value of extrusion
3308 # @param NbOfSteps the number of steps
3309 # @param MakeGroups forces the generation of new groups from existing ones
3310 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3311 # @ingroup l2_modif_extrurev
3312 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3313 if ( isinstance( theObject, Mesh )):
3314 theObject = theObject.GetMesh()
3315 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3316 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3317 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3318 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3319 Parameters = StepVectorParameters + var_separator + Parameters
3320 self.mesh.SetParameters(Parameters)
3322 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3323 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3326 ## Generates new elements by extrusion of the elements which belong to the object
3327 # @param theObject object which elements should be processed.
3328 # It can be a mesh, a sub mesh or a group.
3329 # @param StepVector vector, defining the direction and value of extrusion
3330 # @param NbOfSteps the number of steps
3331 # @param MakeGroups to generate new groups from existing ones
3332 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3333 # @ingroup l2_modif_extrurev
3334 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3335 if ( isinstance( theObject, Mesh )):
3336 theObject = theObject.GetMesh()
3337 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3338 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3339 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3340 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3341 Parameters = StepVectorParameters + var_separator + Parameters
3342 self.mesh.SetParameters(Parameters)
3344 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3345 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3348 ## Generates new elements by extrusion of the elements which belong to the object
3349 # @param theObject object which elements should be processed.
3350 # It can be a mesh, a sub mesh or a group.
3351 # @param StepVector vector, defining the direction and value of extrusion
3352 # @param NbOfSteps the number of steps
3353 # @param MakeGroups forces the generation of new groups from existing ones
3354 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3355 # @ingroup l2_modif_extrurev
3356 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3357 if ( isinstance( theObject, Mesh )):
3358 theObject = theObject.GetMesh()
3359 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3360 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3361 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3362 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3363 Parameters = StepVectorParameters + var_separator + Parameters
3364 self.mesh.SetParameters(Parameters)
3366 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3367 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3372 ## Generates new elements by extrusion of the given elements
3373 # The path of extrusion must be a meshed edge.
3374 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3375 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3376 # @param NodeStart the start node from Path. Defines the direction of extrusion
3377 # @param HasAngles allows the shape to be rotated around the path
3378 # to get the resulting mesh in a helical fashion
3379 # @param Angles list of angles in radians
3380 # @param LinearVariation forces the computation of rotation angles as linear
3381 # variation of the given Angles along path steps
3382 # @param HasRefPoint allows using the reference point
3383 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3384 # The User can specify any point as the Reference Point.
3385 # @param MakeGroups forces the generation of new groups from existing ones
3386 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3387 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3388 # only SMESH::Extrusion_Error otherwise
3389 # @ingroup l2_modif_extrurev
3390 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3391 HasAngles, Angles, LinearVariation,
3392 HasRefPoint, RefPoint, MakeGroups, ElemType):
3393 Angles,AnglesParameters = ParseAngles(Angles)
3394 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3395 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3396 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3398 Parameters = AnglesParameters + var_separator + RefPointParameters
3399 self.mesh.SetParameters(Parameters)
3401 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3403 if isinstance(Base, list):
3405 if Base == []: IDsOfElements = self.GetElementsId()
3406 else: IDsOfElements = Base
3407 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3408 HasAngles, Angles, LinearVariation,
3409 HasRefPoint, RefPoint, MakeGroups, ElemType)
3411 if isinstance(Base, Mesh): Base = Base.GetMesh()
3412 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3413 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3414 HasAngles, Angles, LinearVariation,
3415 HasRefPoint, RefPoint, MakeGroups, ElemType)
3417 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3420 ## Generates new elements by extrusion of the given elements
3421 # The path of extrusion must be a meshed edge.
3422 # @param IDsOfElements ids of elements
3423 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3424 # @param PathShape shape(edge) defines the sub-mesh for the path
3425 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3426 # @param HasAngles allows the shape to be rotated around the path
3427 # to get the resulting mesh in a helical fashion
3428 # @param Angles list of angles in radians
3429 # @param HasRefPoint allows using the reference point
3430 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3431 # The User can specify any point as the Reference Point.
3432 # @param MakeGroups forces the generation of new groups from existing ones
3433 # @param LinearVariation forces the computation of rotation angles as linear
3434 # variation of the given Angles along path steps
3435 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3436 # only SMESH::Extrusion_Error otherwise
3437 # @ingroup l2_modif_extrurev
3438 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3439 HasAngles, Angles, HasRefPoint, RefPoint,
3440 MakeGroups=False, LinearVariation=False):
3441 Angles,AnglesParameters = ParseAngles(Angles)
3442 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3443 if IDsOfElements == []:
3444 IDsOfElements = self.GetElementsId()
3445 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3446 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3448 if ( isinstance( PathMesh, Mesh )):
3449 PathMesh = PathMesh.GetMesh()
3450 if HasAngles and Angles and LinearVariation:
3451 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3453 Parameters = AnglesParameters + var_separator + RefPointParameters
3454 self.mesh.SetParameters(Parameters)
3456 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3457 PathShape, NodeStart, HasAngles,
3458 Angles, HasRefPoint, RefPoint)
3459 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3460 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3462 ## Generates new elements by extrusion of the elements which belong to the object
3463 # The path of extrusion must be a meshed edge.
3464 # @param theObject the object which elements should be processed.
3465 # It can be a mesh, a sub mesh or a group.
3466 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3467 # @param PathShape shape(edge) defines the sub-mesh for the path
3468 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3469 # @param HasAngles allows the shape to be rotated around the path
3470 # to get the resulting mesh in a helical fashion
3471 # @param Angles list of angles
3472 # @param HasRefPoint allows using the reference point
3473 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3474 # The User can specify any point as the Reference Point.
3475 # @param MakeGroups forces the generation of new groups from existing ones
3476 # @param LinearVariation forces the computation of rotation angles as linear
3477 # variation of the given Angles along path steps
3478 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3479 # only SMESH::Extrusion_Error otherwise
3480 # @ingroup l2_modif_extrurev
3481 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3482 HasAngles, Angles, HasRefPoint, RefPoint,
3483 MakeGroups=False, LinearVariation=False):
3484 Angles,AnglesParameters = ParseAngles(Angles)
3485 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3486 if ( isinstance( theObject, Mesh )):
3487 theObject = theObject.GetMesh()
3488 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3489 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3490 if ( isinstance( PathMesh, Mesh )):
3491 PathMesh = PathMesh.GetMesh()
3492 if HasAngles and Angles and LinearVariation:
3493 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3495 Parameters = AnglesParameters + var_separator + RefPointParameters
3496 self.mesh.SetParameters(Parameters)
3498 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3499 PathShape, NodeStart, HasAngles,
3500 Angles, HasRefPoint, RefPoint)
3501 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3502 NodeStart, HasAngles, Angles, HasRefPoint,
3505 ## Generates new elements by extrusion of the elements which belong to the object
3506 # The path of extrusion must be a meshed edge.
3507 # @param theObject the object which elements should be processed.
3508 # It can be a mesh, a sub mesh or a group.
3509 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3510 # @param PathShape shape(edge) defines the sub-mesh for the path
3511 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3512 # @param HasAngles allows the shape to be rotated around the path
3513 # to get the resulting mesh in a helical fashion
3514 # @param Angles list of angles
3515 # @param HasRefPoint allows using the reference point
3516 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3517 # The User can specify any point as the Reference Point.
3518 # @param MakeGroups forces the generation of new groups from existing ones
3519 # @param LinearVariation forces the computation of rotation angles as linear
3520 # variation of the given Angles along path steps
3521 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3522 # only SMESH::Extrusion_Error otherwise
3523 # @ingroup l2_modif_extrurev
3524 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3525 HasAngles, Angles, HasRefPoint, RefPoint,
3526 MakeGroups=False, LinearVariation=False):
3527 Angles,AnglesParameters = ParseAngles(Angles)
3528 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3529 if ( isinstance( theObject, Mesh )):
3530 theObject = theObject.GetMesh()
3531 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3532 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3533 if ( isinstance( PathMesh, Mesh )):
3534 PathMesh = PathMesh.GetMesh()
3535 if HasAngles and Angles and LinearVariation:
3536 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3538 Parameters = AnglesParameters + var_separator + RefPointParameters
3539 self.mesh.SetParameters(Parameters)
3541 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3542 PathShape, NodeStart, HasAngles,
3543 Angles, HasRefPoint, RefPoint)
3544 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3545 NodeStart, HasAngles, Angles, HasRefPoint,
3548 ## Generates new elements by extrusion of the elements which belong to the object
3549 # The path of extrusion must be a meshed edge.
3550 # @param theObject the object which elements should be processed.
3551 # It can be a mesh, a sub mesh or a group.
3552 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3553 # @param PathShape shape(edge) defines the sub-mesh for the path
3554 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3555 # @param HasAngles allows the shape to be rotated around the path
3556 # to get the resulting mesh in a helical fashion
3557 # @param Angles list of angles
3558 # @param HasRefPoint allows using the reference point
3559 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3560 # The User can specify any point as the Reference Point.
3561 # @param MakeGroups forces the generation of new groups from existing ones
3562 # @param LinearVariation forces the computation of rotation angles as linear
3563 # variation of the given Angles along path steps
3564 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3565 # only SMESH::Extrusion_Error otherwise
3566 # @ingroup l2_modif_extrurev
3567 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3568 HasAngles, Angles, HasRefPoint, RefPoint,
3569 MakeGroups=False, LinearVariation=False):
3570 Angles,AnglesParameters = ParseAngles(Angles)
3571 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3572 if ( isinstance( theObject, Mesh )):
3573 theObject = theObject.GetMesh()
3574 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3575 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3576 if ( isinstance( PathMesh, Mesh )):
3577 PathMesh = PathMesh.GetMesh()
3578 if HasAngles and Angles and LinearVariation:
3579 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3581 Parameters = AnglesParameters + var_separator + RefPointParameters
3582 self.mesh.SetParameters(Parameters)
3584 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3585 PathShape, NodeStart, HasAngles,
3586 Angles, HasRefPoint, RefPoint)
3587 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3588 NodeStart, HasAngles, Angles, HasRefPoint,
3591 ## Creates a symmetrical copy of mesh elements
3592 # @param IDsOfElements list of elements ids
3593 # @param Mirror is AxisStruct or geom object(point, line, plane)
3594 # @param theMirrorType is POINT, AXIS or PLANE
3595 # If the Mirror is a geom object this parameter is unnecessary
3596 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3597 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3598 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3599 # @ingroup l2_modif_trsf
3600 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3601 if IDsOfElements == []:
3602 IDsOfElements = self.GetElementsId()
3603 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3604 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3605 Mirror,Parameters = ParseAxisStruct(Mirror)
3606 self.mesh.SetParameters(Parameters)
3607 if Copy and MakeGroups:
3608 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3609 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3612 ## Creates a new mesh by a symmetrical copy of mesh elements
3613 # @param IDsOfElements the list of elements ids
3614 # @param Mirror is AxisStruct or geom object (point, line, plane)
3615 # @param theMirrorType is POINT, AXIS or PLANE
3616 # If the Mirror is a geom object this parameter is unnecessary
3617 # @param MakeGroups to generate new groups from existing ones
3618 # @param NewMeshName a name of the new mesh to create
3619 # @return instance of Mesh class
3620 # @ingroup l2_modif_trsf
3621 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3622 if IDsOfElements == []:
3623 IDsOfElements = self.GetElementsId()
3624 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3625 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3626 Mirror,Parameters = ParseAxisStruct(Mirror)
3627 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3628 MakeGroups, NewMeshName)
3629 mesh.SetParameters(Parameters)
3630 return Mesh(self.smeshpyD,self.geompyD,mesh)
3632 ## Creates a symmetrical copy of the object
3633 # @param theObject mesh, submesh or group
3634 # @param Mirror AxisStruct or geom object (point, line, plane)
3635 # @param theMirrorType is POINT, AXIS or PLANE
3636 # If the Mirror is a geom object this parameter is unnecessary
3637 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3638 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3639 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3640 # @ingroup l2_modif_trsf
3641 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3642 if ( isinstance( theObject, Mesh )):
3643 theObject = theObject.GetMesh()
3644 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3645 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3646 Mirror,Parameters = ParseAxisStruct(Mirror)
3647 self.mesh.SetParameters(Parameters)
3648 if Copy and MakeGroups:
3649 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3650 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3653 ## Creates a new mesh by a symmetrical copy of the object
3654 # @param theObject mesh, submesh or group
3655 # @param Mirror AxisStruct or geom object (point, line, plane)
3656 # @param theMirrorType POINT, AXIS or PLANE
3657 # If the Mirror is a geom object this parameter is unnecessary
3658 # @param MakeGroups forces the generation of new groups from existing ones
3659 # @param NewMeshName the name of the new mesh to create
3660 # @return instance of Mesh class
3661 # @ingroup l2_modif_trsf
3662 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3663 if ( isinstance( theObject, Mesh )):
3664 theObject = theObject.GetMesh()
3665 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3666 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3667 Mirror,Parameters = ParseAxisStruct(Mirror)
3668 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3669 MakeGroups, NewMeshName)
3670 mesh.SetParameters(Parameters)
3671 return Mesh( self.smeshpyD,self.geompyD,mesh )
3673 ## Translates the elements
3674 # @param IDsOfElements list of elements ids
3675 # @param Vector the direction of translation (DirStruct or vector)
3676 # @param Copy allows copying the translated elements
3677 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3678 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3679 # @ingroup l2_modif_trsf
3680 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3681 if IDsOfElements == []:
3682 IDsOfElements = self.GetElementsId()
3683 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3684 Vector = self.smeshpyD.GetDirStruct(Vector)
3685 Vector,Parameters = ParseDirStruct(Vector)
3686 self.mesh.SetParameters(Parameters)
3687 if Copy and MakeGroups:
3688 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3689 self.editor.Translate(IDsOfElements, Vector, Copy)
3692 ## Creates a new mesh of translated elements
3693 # @param IDsOfElements list of elements ids
3694 # @param Vector the direction of translation (DirStruct or vector)
3695 # @param MakeGroups forces the generation of new groups from existing ones
3696 # @param NewMeshName the name of the newly created mesh
3697 # @return instance of Mesh class
3698 # @ingroup l2_modif_trsf
3699 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3700 if IDsOfElements == []:
3701 IDsOfElements = self.GetElementsId()
3702 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3703 Vector = self.smeshpyD.GetDirStruct(Vector)
3704 Vector,Parameters = ParseDirStruct(Vector)
3705 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3706 mesh.SetParameters(Parameters)
3707 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3709 ## Translates the object
3710 # @param theObject the object to translate (mesh, submesh, or group)
3711 # @param Vector direction of translation (DirStruct or geom vector)
3712 # @param Copy allows copying the translated elements
3713 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3714 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3715 # @ingroup l2_modif_trsf
3716 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3717 if ( isinstance( theObject, Mesh )):
3718 theObject = theObject.GetMesh()
3719 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3720 Vector = self.smeshpyD.GetDirStruct(Vector)
3721 Vector,Parameters = ParseDirStruct(Vector)
3722 self.mesh.SetParameters(Parameters)
3723 if Copy and MakeGroups:
3724 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3725 self.editor.TranslateObject(theObject, Vector, Copy)
3728 ## Creates a new mesh from the translated object
3729 # @param theObject the object to translate (mesh, submesh, or group)
3730 # @param Vector the direction of translation (DirStruct or geom vector)
3731 # @param MakeGroups forces the generation of new groups from existing ones
3732 # @param NewMeshName the name of the newly created mesh
3733 # @return instance of Mesh class
3734 # @ingroup l2_modif_trsf
3735 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3736 if (isinstance(theObject, Mesh)):
3737 theObject = theObject.GetMesh()
3738 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3739 Vector = self.smeshpyD.GetDirStruct(Vector)
3740 Vector,Parameters = ParseDirStruct(Vector)
3741 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3742 mesh.SetParameters(Parameters)
3743 return Mesh( self.smeshpyD, self.geompyD, mesh )
3747 ## Scales the object
3748 # @param theObject - the object to translate (mesh, submesh, or group)
3749 # @param thePoint - base point for scale
3750 # @param theScaleFact - list of 1-3 scale factors for axises
3751 # @param Copy - allows copying the translated elements
3752 # @param MakeGroups - forces the generation of new groups from existing
3754 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3755 # empty list otherwise
3756 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3757 if ( isinstance( theObject, Mesh )):
3758 theObject = theObject.GetMesh()
3759 if ( isinstance( theObject, list )):
3760 theObject = self.GetIDSource(theObject, SMESH.ALL)
3762 thePoint, Parameters = ParsePointStruct(thePoint)
3763 self.mesh.SetParameters(Parameters)
3765 if Copy and MakeGroups:
3766 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3767 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3770 ## Creates a new mesh from the translated object
3771 # @param theObject - the object to translate (mesh, submesh, or group)
3772 # @param thePoint - base point for scale
3773 # @param theScaleFact - list of 1-3 scale factors for axises
3774 # @param MakeGroups - forces the generation of new groups from existing ones
3775 # @param NewMeshName - the name of the newly created mesh
3776 # @return instance of Mesh class
3777 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3778 if (isinstance(theObject, Mesh)):
3779 theObject = theObject.GetMesh()
3780 if ( isinstance( theObject, list )):
3781 theObject = self.GetIDSource(theObject,SMESH.ALL)
3783 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3784 MakeGroups, NewMeshName)
3785 #mesh.SetParameters(Parameters)
3786 return Mesh( self.smeshpyD, self.geompyD, mesh )
3790 ## Rotates the elements
3791 # @param IDsOfElements list of elements ids
3792 # @param Axis the axis of rotation (AxisStruct or geom line)
3793 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3794 # @param Copy allows copying the rotated elements
3795 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3796 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3797 # @ingroup l2_modif_trsf
3798 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3800 if isinstance(AngleInRadians,str):
3802 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3804 AngleInRadians = DegreesToRadians(AngleInRadians)
3805 if IDsOfElements == []:
3806 IDsOfElements = self.GetElementsId()
3807 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3808 Axis = self.smeshpyD.GetAxisStruct(Axis)
3809 Axis,AxisParameters = ParseAxisStruct(Axis)
3810 Parameters = AxisParameters + var_separator + Parameters
3811 self.mesh.SetParameters(Parameters)
3812 if Copy and MakeGroups:
3813 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3814 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3817 ## Creates a new mesh of rotated elements
3818 # @param IDsOfElements list of element ids
3819 # @param Axis the axis of rotation (AxisStruct or geom line)
3820 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3821 # @param MakeGroups forces the generation of new groups from existing ones
3822 # @param NewMeshName the name of the newly created mesh
3823 # @return instance of Mesh class
3824 # @ingroup l2_modif_trsf
3825 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3827 if isinstance(AngleInRadians,str):
3829 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3831 AngleInRadians = DegreesToRadians(AngleInRadians)
3832 if IDsOfElements == []:
3833 IDsOfElements = self.GetElementsId()
3834 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3835 Axis = self.smeshpyD.GetAxisStruct(Axis)
3836 Axis,AxisParameters = ParseAxisStruct(Axis)
3837 Parameters = AxisParameters + var_separator + Parameters
3838 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3839 MakeGroups, NewMeshName)
3840 mesh.SetParameters(Parameters)
3841 return Mesh( self.smeshpyD, self.geompyD, mesh )
3843 ## Rotates the object
3844 # @param theObject the object to rotate( mesh, submesh, or group)
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 Copy allows copying the rotated elements
3848 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3849 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3850 # @ingroup l2_modif_trsf
3851 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3853 if isinstance(AngleInRadians,str):
3855 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3857 AngleInRadians = DegreesToRadians(AngleInRadians)
3858 if (isinstance(theObject, Mesh)):
3859 theObject = theObject.GetMesh()
3860 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3861 Axis = self.smeshpyD.GetAxisStruct(Axis)
3862 Axis,AxisParameters = ParseAxisStruct(Axis)
3863 Parameters = AxisParameters + ":" + Parameters
3864 self.mesh.SetParameters(Parameters)
3865 if Copy and MakeGroups:
3866 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3867 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3870 ## Creates a new mesh from the rotated object
3871 # @param theObject the object to rotate (mesh, submesh, or group)
3872 # @param Axis the axis of rotation (AxisStruct or geom line)
3873 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3874 # @param MakeGroups forces the generation of new groups from existing ones
3875 # @param NewMeshName the name of the newly created mesh
3876 # @return instance of Mesh class
3877 # @ingroup l2_modif_trsf
3878 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3880 if isinstance(AngleInRadians,str):
3882 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3884 AngleInRadians = DegreesToRadians(AngleInRadians)
3885 if (isinstance( theObject, Mesh )):
3886 theObject = theObject.GetMesh()
3887 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3888 Axis = self.smeshpyD.GetAxisStruct(Axis)
3889 Axis,AxisParameters = ParseAxisStruct(Axis)
3890 Parameters = AxisParameters + ":" + Parameters
3891 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3892 MakeGroups, NewMeshName)
3893 mesh.SetParameters(Parameters)
3894 return Mesh( self.smeshpyD, self.geompyD, mesh )
3896 ## Finds groups of ajacent nodes within Tolerance.
3897 # @param Tolerance the value of tolerance
3898 # @return the list of groups of nodes
3899 # @ingroup l2_modif_trsf
3900 def FindCoincidentNodes (self, Tolerance):
3901 return self.editor.FindCoincidentNodes(Tolerance)
3903 ## Finds groups of ajacent nodes within Tolerance.
3904 # @param Tolerance the value of tolerance
3905 # @param SubMeshOrGroup SubMesh or Group
3906 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3907 # @return the list of groups of nodes
3908 # @ingroup l2_modif_trsf
3909 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3910 if (isinstance( SubMeshOrGroup, Mesh )):
3911 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3912 if not isinstance( exceptNodes, list):
3913 exceptNodes = [ exceptNodes ]
3914 if exceptNodes and isinstance( exceptNodes[0], int):
3915 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3916 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3919 # @param GroupsOfNodes the list of groups of nodes
3920 # @ingroup l2_modif_trsf
3921 def MergeNodes (self, GroupsOfNodes):
3922 self.editor.MergeNodes(GroupsOfNodes)
3924 ## Finds the elements built on the same nodes.
3925 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3926 # @return a list of groups of equal elements
3927 # @ingroup l2_modif_trsf
3928 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3929 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3930 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3931 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3933 ## Merges elements in each given group.
3934 # @param GroupsOfElementsID groups of elements for merging
3935 # @ingroup l2_modif_trsf
3936 def MergeElements(self, GroupsOfElementsID):
3937 self.editor.MergeElements(GroupsOfElementsID)
3939 ## Leaves one element and removes all other elements built on the same nodes.
3940 # @ingroup l2_modif_trsf
3941 def MergeEqualElements(self):
3942 self.editor.MergeEqualElements()
3944 ## Sews free borders
3945 # @return SMESH::Sew_Error
3946 # @ingroup l2_modif_trsf
3947 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3948 FirstNodeID2, SecondNodeID2, LastNodeID2,
3949 CreatePolygons, CreatePolyedrs):
3950 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3951 FirstNodeID2, SecondNodeID2, LastNodeID2,
3952 CreatePolygons, CreatePolyedrs)
3954 ## Sews conform free borders
3955 # @return SMESH::Sew_Error
3956 # @ingroup l2_modif_trsf
3957 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3958 FirstNodeID2, SecondNodeID2):
3959 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3960 FirstNodeID2, SecondNodeID2)
3962 ## Sews border to side
3963 # @return SMESH::Sew_Error
3964 # @ingroup l2_modif_trsf
3965 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3966 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3967 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3968 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3970 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3971 # merged with the nodes of elements of Side2.
3972 # The number of elements in theSide1 and in theSide2 must be
3973 # equal and they should have similar nodal connectivity.
3974 # The nodes to merge should belong to side borders and
3975 # the first node should be linked to the second.
3976 # @return SMESH::Sew_Error
3977 # @ingroup l2_modif_trsf
3978 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3979 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3980 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3981 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3982 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3983 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3985 ## Sets new nodes for the given element.
3986 # @param ide the element id
3987 # @param newIDs nodes ids
3988 # @return If the number of nodes does not correspond to the type of element - returns false
3989 # @ingroup l2_modif_edit
3990 def ChangeElemNodes(self, ide, newIDs):
3991 return self.editor.ChangeElemNodes(ide, newIDs)
3993 ## If during the last operation of MeshEditor some nodes were
3994 # created, this method returns the list of their IDs, \n
3995 # if new nodes were not created - returns empty list
3996 # @return the list of integer values (can be empty)
3997 # @ingroup l1_auxiliary
3998 def GetLastCreatedNodes(self):
3999 return self.editor.GetLastCreatedNodes()
4001 ## If during the last operation of MeshEditor some elements were
4002 # created this method returns the list of their IDs, \n
4003 # if new elements were not created - returns empty list
4004 # @return the list of integer values (can be empty)
4005 # @ingroup l1_auxiliary
4006 def GetLastCreatedElems(self):
4007 return self.editor.GetLastCreatedElems()
4009 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4010 # @param theNodes identifiers of nodes to be doubled
4011 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4012 # nodes. If list of element identifiers is empty then nodes are doubled but
4013 # they not assigned to elements
4014 # @return TRUE if operation has been completed successfully, FALSE otherwise
4015 # @ingroup l2_modif_edit
4016 def DoubleNodes(self, theNodes, theModifiedElems):
4017 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4019 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4020 # This method provided for convenience works as DoubleNodes() described above.
4021 # @param theNodeId identifiers of node to be doubled
4022 # @param theModifiedElems identifiers of elements to be updated
4023 # @return TRUE if operation has been completed successfully, FALSE otherwise
4024 # @ingroup l2_modif_edit
4025 def DoubleNode(self, theNodeId, theModifiedElems):
4026 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4028 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4029 # This method provided for convenience works as DoubleNodes() described above.
4030 # @param theNodes group of nodes to be doubled
4031 # @param theModifiedElems group of elements to be updated.
4032 # @param theMakeGroup forces the generation of a group containing new nodes.
4033 # @return TRUE or a created group if operation has been completed successfully,
4034 # FALSE or None otherwise
4035 # @ingroup l2_modif_edit
4036 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4038 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4039 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4041 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4042 # This method provided for convenience works as DoubleNodes() described above.
4043 # @param theNodes list of groups of nodes to be doubled
4044 # @param theModifiedElems list of groups of elements to be updated.
4045 # @return TRUE if operation has been completed successfully, FALSE otherwise
4046 # @ingroup l2_modif_edit
4047 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4049 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4050 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4052 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4053 # @param theElems - the list of elements (edges or faces) to be replicated
4054 # The nodes for duplication could be found from these elements
4055 # @param theNodesNot - list of nodes to NOT replicate
4056 # @param theAffectedElems - the list of elements (cells and edges) to which the
4057 # replicated nodes should be associated to.
4058 # @return TRUE if operation has been completed successfully, FALSE otherwise
4059 # @ingroup l2_modif_edit
4060 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4061 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4063 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4064 # @param theElems - the list of elements (edges or faces) to be replicated
4065 # The nodes for duplication could be found from these elements
4066 # @param theNodesNot - list of nodes to NOT replicate
4067 # @param theShape - shape to detect affected elements (element which geometric center
4068 # located on or inside shape).
4069 # The replicated nodes should be associated to affected elements.
4070 # @return TRUE if operation has been completed successfully, FALSE otherwise
4071 # @ingroup l2_modif_edit
4072 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4073 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4075 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4076 # This method provided for convenience works as DoubleNodes() described above.
4077 # @param theElems - group of of elements (edges or faces) to be replicated
4078 # @param theNodesNot - group of nodes not to replicated
4079 # @param theAffectedElems - group of elements to which the replicated nodes
4080 # should be associated to.
4081 # @param theMakeGroup forces the generation of a group containing new elements.
4082 # @return TRUE or a created group if operation has been completed successfully,
4083 # FALSE or None otherwise
4084 # @ingroup l2_modif_edit
4085 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4087 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4088 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4090 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4091 # This method provided for convenience works as DoubleNodes() described above.
4092 # @param theElems - group of of elements (edges or faces) to be replicated
4093 # @param theNodesNot - group of nodes not to replicated
4094 # @param theShape - shape to detect affected elements (element which geometric center
4095 # located on or inside shape).
4096 # The replicated nodes should be associated to affected elements.
4097 # @ingroup l2_modif_edit
4098 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4099 return self.editor.DoubleNodeElemGroupInRegion(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 - list of groups of elements (edges or faces) to be replicated
4104 # @param theNodesNot - list of groups 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 DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4113 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4114 return self.editor.DoubleNodeElemGroups(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 - list of groups of elements (edges or faces) to be replicated
4119 # @param theNodesNot - list of groups 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 # @return TRUE if operation has been completed successfully, FALSE otherwise
4124 # @ingroup l2_modif_edit
4125 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4126 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4128 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4129 # The list of groups must describe a partition of the mesh volumes.
4130 # The nodes of the internal faces at the boundaries of the groups are doubled.
4131 # In option, the internal faces are replaced by flat elements.
4132 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4133 # @param theDomains - list of groups of volumes
4134 # @param createJointElems - if TRUE, create the elements
4135 # @return TRUE if operation has been completed successfully, FALSE otherwise
4136 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4137 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4139 def _valueFromFunctor(self, funcType, elemId):
4140 fn = self.smeshpyD.GetFunctor(funcType)
4141 fn.SetMesh(self.mesh)
4142 if fn.GetElementType() == self.GetElementType(elemId, True):
4143 val = fn.GetValue(elemId)
4148 ## Get length of 1D element.
4149 # @param elemId mesh element ID
4150 # @return element's length value
4151 # @ingroup l1_measurements
4152 def GetLength(self, elemId):
4153 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4155 ## Get area of 2D element.
4156 # @param elemId mesh element ID
4157 # @return element's area value
4158 # @ingroup l1_measurements
4159 def GetArea(self, elemId):
4160 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4162 ## Get volume of 3D element.
4163 # @param elemId mesh element ID
4164 # @return element's volume value
4165 # @ingroup l1_measurements
4166 def GetVolume(self, elemId):
4167 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4169 ## Get maximum element length.
4170 # @param elemId mesh element ID
4171 # @return element's maximum length value
4172 # @ingroup l1_measurements
4173 def GetMaxElementLength(self, elemId):
4174 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4175 ftype = SMESH.FT_MaxElementLength3D
4177 ftype = SMESH.FT_MaxElementLength2D
4178 return self._valueFromFunctor(ftype, elemId)
4180 ## Get aspect ratio of 2D or 3D element.
4181 # @param elemId mesh element ID
4182 # @return element's aspect ratio value
4183 # @ingroup l1_measurements
4184 def GetAspectRatio(self, elemId):
4185 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4186 ftype = SMESH.FT_AspectRatio3D
4188 ftype = SMESH.FT_AspectRatio
4189 return self._valueFromFunctor(ftype, elemId)
4191 ## Get warping angle of 2D element.
4192 # @param elemId mesh element ID
4193 # @return element's warping angle value
4194 # @ingroup l1_measurements
4195 def GetWarping(self, elemId):
4196 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4198 ## Get minimum angle of 2D element.
4199 # @param elemId mesh element ID
4200 # @return element's minimum angle value
4201 # @ingroup l1_measurements
4202 def GetMinimumAngle(self, elemId):
4203 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4205 ## Get taper of 2D element.
4206 # @param elemId mesh element ID
4207 # @return element's taper value
4208 # @ingroup l1_measurements
4209 def GetTaper(self, elemId):
4210 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4212 ## Get skew of 2D element.
4213 # @param elemId mesh element ID
4214 # @return element's skew value
4215 # @ingroup l1_measurements
4216 def GetSkew(self, elemId):
4217 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4219 ## The mother class to define algorithm, it is not recommended to use it directly.
4222 # @ingroup l2_algorithms
4223 class Mesh_Algorithm:
4224 # @class Mesh_Algorithm
4225 # @brief Class Mesh_Algorithm
4227 #def __init__(self,smesh):
4235 ## Finds a hypothesis in the study by its type name and parameters.
4236 # Finds only the hypotheses created in smeshpyD engine.
4237 # @return SMESH.SMESH_Hypothesis
4238 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4239 study = smeshpyD.GetCurrentStudy()
4240 #to do: find component by smeshpyD object, not by its data type
4241 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4242 if scomp is not None:
4243 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4244 # Check if the root label of the hypotheses exists
4245 if res and hypRoot is not None:
4246 iter = study.NewChildIterator(hypRoot)
4247 # Check all published hypotheses
4249 hypo_so_i = iter.Value()
4250 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4251 if attr is not None:
4252 anIOR = attr.Value()
4253 hypo_o_i = salome.orb.string_to_object(anIOR)
4254 if hypo_o_i is not None:
4255 # Check if this is a hypothesis
4256 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4257 if hypo_i is not None:
4258 # Check if the hypothesis belongs to current engine
4259 if smeshpyD.GetObjectId(hypo_i) > 0:
4260 # Check if this is the required hypothesis
4261 if hypo_i.GetName() == hypname:
4263 if CompareMethod(hypo_i, args):
4277 ## Finds the algorithm in the study by its type name.
4278 # Finds only the algorithms, which have been created in smeshpyD engine.
4279 # @return SMESH.SMESH_Algo
4280 def FindAlgorithm (self, algoname, smeshpyD):
4281 study = smeshpyD.GetCurrentStudy()
4282 #to do: find component by smeshpyD object, not by its data type
4283 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4284 if scomp is not None:
4285 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4286 # Check if the root label of the algorithms exists
4287 if res and hypRoot is not None:
4288 iter = study.NewChildIterator(hypRoot)
4289 # Check all published algorithms
4291 algo_so_i = iter.Value()
4292 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4293 if attr is not None:
4294 anIOR = attr.Value()
4295 algo_o_i = salome.orb.string_to_object(anIOR)
4296 if algo_o_i is not None:
4297 # Check if this is an algorithm
4298 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4299 if algo_i is not None:
4300 # Checks if the algorithm belongs to the current engine
4301 if smeshpyD.GetObjectId(algo_i) > 0:
4302 # Check if this is the required algorithm
4303 if algo_i.GetName() == algoname:
4316 ## If the algorithm is global, returns 0; \n
4317 # else returns the submesh associated to this algorithm.
4318 def GetSubMesh(self):
4321 ## Returns the wrapped mesher.
4322 def GetAlgorithm(self):
4325 ## Gets the list of hypothesis that can be used with this algorithm
4326 def GetCompatibleHypothesis(self):
4329 mylist = self.algo.GetCompatibleHypothesis()
4332 ## Gets the name of the algorithm
4336 ## Sets the name to the algorithm
4337 def SetName(self, name):
4338 self.mesh.smeshpyD.SetName(self.algo, name)
4340 ## Gets the id of the algorithm
4342 return self.algo.GetId()
4345 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4347 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4348 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4350 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4352 self.Assign(algo, mesh, geom)
4356 def Assign(self, algo, mesh, geom):
4358 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4367 name = GetName(geom)
4371 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4372 # for all groups SubShapeName() returns "Compound_-1"
4373 name = mesh.geompyD.SubShapeName(geom, piece)
4375 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4376 # publish geom of sub-mesh (issue 0021122)
4377 if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4378 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4379 if studyID != self.mesh.geompyD.myStudyId:
4380 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4381 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4383 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4385 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4386 TreatHypoStatus( status, algo.GetName(), name, True )
4388 def CompareHyp (self, hyp, args):
4389 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4392 def CompareEqualHyp (self, hyp, args):
4396 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4397 UseExisting=0, CompareMethod=""):
4400 if CompareMethod == "": CompareMethod = self.CompareHyp
4401 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4404 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4410 a = a + s + str(args[i])
4414 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4418 geomName = GetName(self.geom)
4419 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4420 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4423 ## Returns entry of the shape to mesh in the study
4424 def MainShapeEntry(self):
4426 if not self.mesh or not self.mesh.GetMesh(): return entry
4427 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4428 study = self.mesh.smeshpyD.GetCurrentStudy()
4429 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4430 sobj = study.FindObjectIOR(ior)
4431 if sobj: entry = sobj.GetID()
4432 if not entry: return ""
4435 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4436 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4437 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4438 # @param thickness total thickness of layers of prisms
4439 # @param numberOfLayers number of layers of prisms
4440 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4441 # @param ignoreFaces geometrical face (or their ids) not to generate layers on
4442 # @ingroup l3_hypos_additi
4443 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4444 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4445 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4446 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4447 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4448 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4449 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4450 hyp = self.Hypothesis("ViscousLayers",
4451 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4452 hyp.SetTotalThickness(thickness)
4453 hyp.SetNumberLayers(numberOfLayers)
4454 hyp.SetStretchFactor(stretchFactor)
4455 hyp.SetIgnoreFaces(ignoreFaces)
4458 # Public class: Mesh_Segment
4459 # --------------------------
4461 ## Class to define a segment 1D algorithm for discretization
4464 # @ingroup l3_algos_basic
4465 class Mesh_Segment(Mesh_Algorithm):
4467 ## Private constructor.
4468 def __init__(self, mesh, geom=0):
4469 Mesh_Algorithm.__init__(self)
4470 self.Create(mesh, geom, "Regular_1D")
4472 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4473 # @param l for the length of segments that cut an edge
4474 # @param UseExisting if ==true - searches for an existing hypothesis created with
4475 # the same parameters, else (default) - creates a new one
4476 # @param p precision, used for calculation of the number of segments.
4477 # The precision should be a positive, meaningful value within the range [0,1].
4478 # In general, the number of segments is calculated with the formula:
4479 # nb = ceil((edge_length / l) - p)
4480 # Function ceil rounds its argument to the higher integer.
4481 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4482 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4483 # p=1 means rounding of (edge_length / l) to the lower integer.
4484 # Default value is 1e-07.
4485 # @return an instance of StdMeshers_LocalLength hypothesis
4486 # @ingroup l3_hypos_1dhyps
4487 def LocalLength(self, l, UseExisting=0, p=1e-07):
4488 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4489 CompareMethod=self.CompareLocalLength)
4495 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4496 def CompareLocalLength(self, hyp, args):
4497 if IsEqual(hyp.GetLength(), args[0]):
4498 return IsEqual(hyp.GetPrecision(), args[1])
4501 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4502 # @param length is optional maximal allowed length of segment, if it is omitted
4503 # the preestimated length is used that depends on geometry size
4504 # @param UseExisting if ==true - searches for an existing hypothesis created with
4505 # the same parameters, else (default) - create a new one
4506 # @return an instance of StdMeshers_MaxLength hypothesis
4507 # @ingroup l3_hypos_1dhyps
4508 def MaxSize(self, length=0.0, UseExisting=0):
4509 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4512 hyp.SetLength(length)
4514 # set preestimated length
4515 gen = self.mesh.smeshpyD
4516 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4517 self.mesh.GetMesh(), self.mesh.GetShape(),
4519 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4521 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4524 hyp.SetUsePreestimatedLength( length == 0.0 )
4527 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4528 # @param n for the number of segments that cut an edge
4529 # @param s for the scale factor (optional)
4530 # @param reversedEdges is a list of edges to mesh using reversed orientation
4531 # @param UseExisting if ==true - searches for an existing hypothesis created with
4532 # the same parameters, else (default) - create a new one
4533 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4534 # @ingroup l3_hypos_1dhyps
4535 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4536 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4537 reversedEdges, UseExisting = [], reversedEdges
4538 entry = self.MainShapeEntry()
4539 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4540 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4542 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4543 UseExisting=UseExisting,
4544 CompareMethod=self.CompareNumberOfSegments)
4546 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4547 UseExisting=UseExisting,
4548 CompareMethod=self.CompareNumberOfSegments)
4549 hyp.SetDistrType( 1 )
4550 hyp.SetScaleFactor(s)
4551 hyp.SetNumberOfSegments(n)
4552 hyp.SetReversedEdges( reversedEdges )
4553 hyp.SetObjectEntry( entry )
4557 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4558 def CompareNumberOfSegments(self, hyp, args):
4559 if hyp.GetNumberOfSegments() == args[0]:
4561 if hyp.GetReversedEdges() == args[1]:
4562 if not args[1] or hyp.GetObjectEntry() == args[2]:
4565 if hyp.GetReversedEdges() == args[2]:
4566 if not args[2] or hyp.GetObjectEntry() == args[3]:
4567 if hyp.GetDistrType() == 1:
4568 if IsEqual(hyp.GetScaleFactor(), args[1]):
4572 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4573 # @param start defines the length of the first segment
4574 # @param end defines the length of the last segment
4575 # @param reversedEdges is a list of edges to mesh using reversed orientation
4576 # @param UseExisting if ==true - searches for an existing hypothesis created with
4577 # the same parameters, else (default) - creates a new one
4578 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4579 # @ingroup l3_hypos_1dhyps
4580 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4581 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4582 reversedEdges, UseExisting = [], reversedEdges
4583 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4584 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4585 entry = self.MainShapeEntry()
4586 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4587 UseExisting=UseExisting,
4588 CompareMethod=self.CompareArithmetic1D)
4589 hyp.SetStartLength(start)
4590 hyp.SetEndLength(end)
4591 hyp.SetReversedEdges( reversedEdges )
4592 hyp.SetObjectEntry( entry )
4596 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4597 def CompareArithmetic1D(self, hyp, args):
4598 if IsEqual(hyp.GetLength(1), args[0]):
4599 if IsEqual(hyp.GetLength(0), args[1]):
4600 if hyp.GetReversedEdges() == args[2]:
4601 if not args[2] or hyp.GetObjectEntry() == args[3]:
4606 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4607 # on curve from 0 to 1 (additionally it is neecessary to check
4608 # orientation of edges and create list of reversed edges if it is
4609 # needed) and sets numbers of segments between given points (default
4610 # values are equals 1
4611 # @param points defines the list of parameters on curve
4612 # @param nbSegs defines the list of numbers of segments
4613 # @param reversedEdges is a list of edges to mesh using reversed orientation
4614 # @param UseExisting if ==true - searches for an existing hypothesis created with
4615 # the same parameters, else (default) - creates a new one
4616 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4617 # @ingroup l3_hypos_1dhyps
4618 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4619 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4620 reversedEdges, UseExisting = [], reversedEdges
4621 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4622 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4623 entry = self.MainShapeEntry()
4624 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4625 UseExisting=UseExisting,
4626 CompareMethod=self.CompareFixedPoints1D)
4627 hyp.SetPoints(points)
4628 hyp.SetNbSegments(nbSegs)
4629 hyp.SetReversedEdges(reversedEdges)
4630 hyp.SetObjectEntry(entry)
4634 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4635 ## as the given arguments
4636 def CompareFixedPoints1D(self, hyp, args):
4637 if hyp.GetPoints() == args[0]:
4638 if hyp.GetNbSegments() == args[1]:
4639 if hyp.GetReversedEdges() == args[2]:
4640 if not args[2] or hyp.GetObjectEntry() == args[3]:
4646 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4647 # @param start defines the length of the first segment
4648 # @param end defines the length of the last segment
4649 # @param reversedEdges is a list of edges to mesh using reversed orientation
4650 # @param UseExisting if ==true - searches for an existing hypothesis created with
4651 # the same parameters, else (default) - creates a new one
4652 # @return an instance of StdMeshers_StartEndLength hypothesis
4653 # @ingroup l3_hypos_1dhyps
4654 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4655 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4656 reversedEdges, UseExisting = [], reversedEdges
4657 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4658 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4659 entry = self.MainShapeEntry()
4660 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4661 UseExisting=UseExisting,
4662 CompareMethod=self.CompareStartEndLength)
4663 hyp.SetStartLength(start)
4664 hyp.SetEndLength(end)
4665 hyp.SetReversedEdges( reversedEdges )
4666 hyp.SetObjectEntry( entry )
4669 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4670 def CompareStartEndLength(self, hyp, args):
4671 if IsEqual(hyp.GetLength(1), args[0]):
4672 if IsEqual(hyp.GetLength(0), args[1]):
4673 if hyp.GetReversedEdges() == args[2]:
4674 if not args[2] or hyp.GetObjectEntry() == args[3]:
4678 ## Defines "Deflection1D" hypothesis
4679 # @param d for the deflection
4680 # @param UseExisting if ==true - searches for an existing hypothesis created with
4681 # the same parameters, else (default) - create a new one
4682 # @ingroup l3_hypos_1dhyps
4683 def Deflection1D(self, d, UseExisting=0):
4684 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4685 CompareMethod=self.CompareDeflection1D)
4686 hyp.SetDeflection(d)
4689 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4690 def CompareDeflection1D(self, hyp, args):
4691 return IsEqual(hyp.GetDeflection(), args[0])
4693 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4694 # the opposite side in case of quadrangular faces
4695 # @ingroup l3_hypos_additi
4696 def Propagation(self):
4697 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4699 ## Defines "AutomaticLength" hypothesis
4700 # @param fineness for the fineness [0-1]
4701 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4702 # same parameters, else (default) - create a new one
4703 # @ingroup l3_hypos_1dhyps
4704 def AutomaticLength(self, fineness=0, UseExisting=0):
4705 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4706 CompareMethod=self.CompareAutomaticLength)
4707 hyp.SetFineness( fineness )
4710 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4711 def CompareAutomaticLength(self, hyp, args):
4712 return IsEqual(hyp.GetFineness(), args[0])
4714 ## Defines "SegmentLengthAroundVertex" hypothesis
4715 # @param length for the segment length
4716 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4717 # Any other integer value means that the hypothesis will be set on the
4718 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4719 # @param UseExisting if ==true - searches for an existing hypothesis created with
4720 # the same parameters, else (default) - creates a new one
4721 # @ingroup l3_algos_segmarv
4722 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4724 store_geom = self.geom
4725 if type(vertex) is types.IntType:
4726 if vertex == 0 or vertex == 1:
4727 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4735 if self.geom is None:
4736 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4738 name = GetName(self.geom)
4741 piece = self.mesh.geom
4742 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4743 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4745 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4747 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4749 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4750 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4752 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4753 CompareMethod=self.CompareLengthNearVertex)
4754 self.geom = store_geom
4755 hyp.SetLength( length )
4758 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4759 # @ingroup l3_algos_segmarv
4760 def CompareLengthNearVertex(self, hyp, args):
4761 return IsEqual(hyp.GetLength(), args[0])
4763 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4764 # If the 2D mesher sees that all boundary edges are quadratic,
4765 # it generates quadratic faces, else it generates linear faces using
4766 # medium nodes as if they are vertices.
4767 # The 3D mesher generates quadratic volumes only if all boundary faces
4768 # are quadratic, else it fails.
4770 # @ingroup l3_hypos_additi
4771 def QuadraticMesh(self):
4772 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4775 # Public class: Mesh_CompositeSegment
4776 # --------------------------
4778 ## Defines a segment 1D algorithm for discretization
4780 # @ingroup l3_algos_basic
4781 class Mesh_CompositeSegment(Mesh_Segment):
4783 ## Private constructor.
4784 def __init__(self, mesh, geom=0):
4785 self.Create(mesh, geom, "CompositeSegment_1D")
4788 # Public class: Mesh_Segment_Python
4789 # ---------------------------------
4791 ## Defines a segment 1D algorithm for discretization with python function
4793 # @ingroup l3_algos_basic
4794 class Mesh_Segment_Python(Mesh_Segment):
4796 ## Private constructor.
4797 def __init__(self, mesh, geom=0):
4798 import Python1dPlugin
4799 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4801 ## Defines "PythonSplit1D" hypothesis
4802 # @param n for the number of segments that cut an edge
4803 # @param func for the python function that calculates the length of all segments
4804 # @param UseExisting if ==true - searches for the existing hypothesis created with
4805 # the same parameters, else (default) - creates a new one
4806 # @ingroup l3_hypos_1dhyps
4807 def PythonSplit1D(self, n, func, UseExisting=0):
4808 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4809 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4810 hyp.SetNumberOfSegments(n)
4811 hyp.SetPythonLog10RatioFunction(func)
4814 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4815 def ComparePythonSplit1D(self, hyp, args):
4816 #if hyp.GetNumberOfSegments() == args[0]:
4817 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4821 # Public class: Mesh_Triangle
4822 # ---------------------------
4824 ## Defines a triangle 2D algorithm
4826 # @ingroup l3_algos_basic
4827 class Mesh_Triangle(Mesh_Algorithm):
4836 ## Private constructor.
4837 def __init__(self, mesh, algoType, geom=0):
4838 Mesh_Algorithm.__init__(self)
4840 self.algoType = algoType
4841 if algoType == MEFISTO:
4842 self.Create(mesh, geom, "MEFISTO_2D")
4844 elif algoType == BLSURF:
4846 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4847 #self.SetPhysicalMesh() - PAL19680
4848 elif algoType == NETGEN:
4850 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4852 elif algoType == NETGEN_2D:
4854 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4857 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4858 # @param area for the maximum area of each triangle
4859 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4860 # same parameters, else (default) - creates a new one
4862 # Only for algoType == MEFISTO || NETGEN_2D
4863 # @ingroup l3_hypos_2dhyps
4864 def MaxElementArea(self, area, UseExisting=0):
4865 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4866 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4867 CompareMethod=self.CompareMaxElementArea)
4868 elif self.algoType == NETGEN:
4869 hyp = self.Parameters(SIMPLE)
4870 hyp.SetMaxElementArea(area)
4873 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4874 def CompareMaxElementArea(self, hyp, args):
4875 return IsEqual(hyp.GetMaxElementArea(), args[0])
4877 ## Defines "LengthFromEdges" hypothesis to build triangles
4878 # based on the length of the edges taken from the wire
4880 # Only for algoType == MEFISTO || NETGEN_2D
4881 # @ingroup l3_hypos_2dhyps
4882 def LengthFromEdges(self):
4883 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4884 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4886 elif self.algoType == NETGEN:
4887 hyp = self.Parameters(SIMPLE)
4888 hyp.LengthFromEdges()
4891 ## Sets a way to define size of mesh elements to generate.
4892 # @param thePhysicalMesh is: DefaultSize or Custom.
4893 # @ingroup l3_hypos_blsurf
4894 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4895 # Parameter of BLSURF algo
4896 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4898 ## Sets size of mesh elements to generate.
4899 # @ingroup l3_hypos_blsurf
4900 def SetPhySize(self, theVal):
4901 # Parameter of BLSURF algo
4902 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4903 self.Parameters().SetPhySize(theVal)
4905 ## Sets lower boundary of mesh element size (PhySize).
4906 # @ingroup l3_hypos_blsurf
4907 def SetPhyMin(self, theVal=-1):
4908 # Parameter of BLSURF algo
4909 self.Parameters().SetPhyMin(theVal)
4911 ## Sets upper boundary of mesh element size (PhySize).
4912 # @ingroup l3_hypos_blsurf
4913 def SetPhyMax(self, theVal=-1):
4914 # Parameter of BLSURF algo
4915 self.Parameters().SetPhyMax(theVal)
4917 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4918 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4919 # @ingroup l3_hypos_blsurf
4920 def SetGeometricMesh(self, theGeometricMesh=0):
4921 # Parameter of BLSURF algo
4922 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4923 self.params.SetGeometricMesh(theGeometricMesh)
4925 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4926 # @ingroup l3_hypos_blsurf
4927 def SetAngleMeshS(self, theVal=_angleMeshS):
4928 # Parameter of BLSURF algo
4929 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4930 self.params.SetAngleMeshS(theVal)
4932 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4933 # @ingroup l3_hypos_blsurf
4934 def SetAngleMeshC(self, theVal=_angleMeshS):
4935 # Parameter of BLSURF algo
4936 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4937 self.params.SetAngleMeshC(theVal)
4939 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4940 # @ingroup l3_hypos_blsurf
4941 def SetGeoMin(self, theVal=-1):
4942 # Parameter of BLSURF algo
4943 self.Parameters().SetGeoMin(theVal)
4945 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4946 # @ingroup l3_hypos_blsurf
4947 def SetGeoMax(self, theVal=-1):
4948 # Parameter of BLSURF algo
4949 self.Parameters().SetGeoMax(theVal)
4951 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4952 # @ingroup l3_hypos_blsurf
4953 def SetGradation(self, theVal=_gradation):
4954 # Parameter of BLSURF algo
4955 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4956 self.params.SetGradation(theVal)
4958 ## Sets topology usage way.
4959 # @param way defines how mesh conformity is assured <ul>
4960 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4961 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4962 # @ingroup l3_hypos_blsurf
4963 def SetTopology(self, way):
4964 # Parameter of BLSURF algo
4965 self.Parameters().SetTopology(way)
4967 ## To respect geometrical edges or not.
4968 # @ingroup l3_hypos_blsurf
4969 def SetDecimesh(self, toIgnoreEdges=False):
4970 # Parameter of BLSURF algo
4971 self.Parameters().SetDecimesh(toIgnoreEdges)
4973 ## Sets verbosity level in the range 0 to 100.
4974 # @ingroup l3_hypos_blsurf
4975 def SetVerbosity(self, level):
4976 # Parameter of BLSURF algo
4977 self.Parameters().SetVerbosity(level)
4979 ## Sets advanced option value.
4980 # @ingroup l3_hypos_blsurf
4981 def SetOptionValue(self, optionName, level):
4982 # Parameter of BLSURF algo
4983 self.Parameters().SetOptionValue(optionName,level)
4985 ## Sets QuadAllowed flag.
4986 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
4987 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4988 def SetQuadAllowed(self, toAllow=True):
4989 if self.algoType == NETGEN_2D:
4992 hasSimpleHyps = False
4993 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
4994 for hyp in self.mesh.GetHypothesisList( self.geom ):
4995 if hyp.GetName() in simpleHyps:
4996 hasSimpleHyps = True
4997 if hyp.GetName() == "QuadranglePreference":
4998 if not toAllow: # remove QuadranglePreference
4999 self.mesh.RemoveHypothesis( self.geom, hyp )
5005 if toAllow: # add QuadranglePreference
5006 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5011 if self.Parameters():
5012 self.params.SetQuadAllowed(toAllow)
5015 ## Defines hypothesis having several parameters
5017 # @ingroup l3_hypos_netgen
5018 def Parameters(self, which=SOLE):
5020 if self.algoType == NETGEN:
5022 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5023 "libNETGENEngine.so", UseExisting=0)
5025 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5026 "libNETGENEngine.so", UseExisting=0)
5027 elif self.algoType == MEFISTO:
5028 print "Mefisto algo support no multi-parameter hypothesis"
5029 elif self.algoType == NETGEN_2D:
5030 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5031 "libNETGENEngine.so", UseExisting=0)
5032 elif self.algoType == BLSURF:
5033 self.params = self.Hypothesis("BLSURF_Parameters", [],
5034 "libBLSURFEngine.so", UseExisting=0)
5036 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5041 # Only for algoType == NETGEN
5042 # @ingroup l3_hypos_netgen
5043 def SetMaxSize(self, theSize):
5044 if self.Parameters():
5045 self.params.SetMaxSize(theSize)
5047 ## Sets SecondOrder flag
5049 # Only for algoType == NETGEN
5050 # @ingroup l3_hypos_netgen
5051 def SetSecondOrder(self, theVal):
5052 if self.Parameters():
5053 self.params.SetSecondOrder(theVal)
5055 ## Sets Optimize flag
5057 # Only for algoType == NETGEN
5058 # @ingroup l3_hypos_netgen
5059 def SetOptimize(self, theVal):
5060 if self.Parameters():
5061 self.params.SetOptimize(theVal)
5064 # @param theFineness is:
5065 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5067 # Only for algoType == NETGEN
5068 # @ingroup l3_hypos_netgen
5069 def SetFineness(self, theFineness):
5070 if self.Parameters():
5071 self.params.SetFineness(theFineness)
5075 # Only for algoType == NETGEN
5076 # @ingroup l3_hypos_netgen
5077 def SetGrowthRate(self, theRate):
5078 if self.Parameters():
5079 self.params.SetGrowthRate(theRate)
5081 ## Sets NbSegPerEdge
5083 # Only for algoType == NETGEN
5084 # @ingroup l3_hypos_netgen
5085 def SetNbSegPerEdge(self, theVal):
5086 if self.Parameters():
5087 self.params.SetNbSegPerEdge(theVal)
5089 ## Sets NbSegPerRadius
5091 # Only for algoType == NETGEN
5092 # @ingroup l3_hypos_netgen
5093 def SetNbSegPerRadius(self, theVal):
5094 if self.Parameters():
5095 self.params.SetNbSegPerRadius(theVal)
5097 ## Sets number of segments overriding value set by SetLocalLength()
5099 # Only for algoType == NETGEN
5100 # @ingroup l3_hypos_netgen
5101 def SetNumberOfSegments(self, theVal):
5102 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5104 ## Sets number of segments overriding value set by SetNumberOfSegments()
5106 # Only for algoType == NETGEN
5107 # @ingroup l3_hypos_netgen
5108 def SetLocalLength(self, theVal):
5109 self.Parameters(SIMPLE).SetLocalLength(theVal)
5114 # Public class: Mesh_Quadrangle
5115 # -----------------------------
5117 ## Defines a quadrangle 2D algorithm
5119 # @ingroup l3_algos_basic
5120 class Mesh_Quadrangle(Mesh_Algorithm):
5124 ## Private constructor.
5125 def __init__(self, mesh, geom=0):
5126 Mesh_Algorithm.__init__(self)
5127 self.Create(mesh, geom, "Quadrangle_2D")
5130 ## Defines "QuadrangleParameters" hypothesis
5131 # @param quadType defines the algorithm of transition between differently descretized
5132 # sides of a geometrical face:
5133 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5134 # area along the finer meshed sides.
5135 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5136 # finer meshed sides.
5137 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5138 # the finer meshed sides, iff the total quantity of segments on
5139 # all four sides of the face is even (divisible by 2).
5140 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5141 # area is located along the coarser meshed sides.
5142 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5143 # is made gradually, layer by layer. This type has a limitation on
5144 # the number of segments: one pair of opposite sides must have the
5145 # same number of segments, the other pair must have an even difference
5146 # between the numbers of segments on the sides.
5147 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5148 # will be created while other elements will be quadrangles.
5149 # Vertex can be either a GEOM_Object or a vertex ID within the
5151 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5152 # the same parameters, else (default) - creates a new one
5153 # @ingroup l3_hypos_quad
5154 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5155 vertexID = triangleVertex
5156 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5157 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5159 compFun = lambda hyp,args: \
5160 hyp.GetQuadType() == args[0] and \
5161 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5162 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5163 UseExisting = UseExisting, CompareMethod=compFun)
5165 if self.params.GetQuadType() != quadType:
5166 self.params.SetQuadType(quadType)
5168 self.params.SetTriaVertex( vertexID )
5171 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5172 # quadrangles are built in the transition area along the finer meshed sides,
5173 # iff the total quantity of segments on all four sides of the face is even.
5174 # @param reversed if True, transition area is located along the coarser meshed sides.
5175 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5176 # the same parameters, else (default) - creates a new one
5177 # @ingroup l3_hypos_quad
5178 def QuadranglePreference(self, reversed=False, UseExisting=0):
5180 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5181 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5183 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5184 # triangles are built in the transition area along the finer meshed sides.
5185 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5186 # the same parameters, else (default) - creates a new one
5187 # @ingroup l3_hypos_quad
5188 def TrianglePreference(self, UseExisting=0):
5189 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5191 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5192 # quadrangles are built and the transition between the sides is made gradually,
5193 # layer by layer. This type has a limitation on the number of segments: one pair
5194 # of opposite sides must have the same number of segments, the other pair must
5195 # have an even difference between the numbers of segments on the sides.
5196 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5197 # the same parameters, else (default) - creates a new one
5198 # @ingroup l3_hypos_quad
5199 def Reduced(self, UseExisting=0):
5200 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5202 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5203 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5204 # will be created while other elements will be quadrangles.
5205 # Vertex can be either a GEOM_Object or a vertex ID within the
5207 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5208 # the same parameters, else (default) - creates a new one
5209 # @ingroup l3_hypos_quad
5210 def TriangleVertex(self, vertex, UseExisting=0):
5211 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5214 # Public class: Mesh_Tetrahedron
5215 # ------------------------------
5217 ## Defines a tetrahedron 3D algorithm
5219 # @ingroup l3_algos_basic
5220 class Mesh_Tetrahedron(Mesh_Algorithm):
5225 ## Private constructor.
5226 def __init__(self, mesh, algoType, geom=0):
5227 Mesh_Algorithm.__init__(self)
5229 if algoType == NETGEN:
5231 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5234 elif algoType == FULL_NETGEN:
5236 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5239 elif algoType == GHS3D:
5241 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5244 elif algoType == GHS3DPRL:
5245 CheckPlugin(GHS3DPRL)
5246 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5249 self.algoType = algoType
5251 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5252 # @param vol for the maximum volume of each tetrahedron
5253 # @param UseExisting if ==true - searches for the existing hypothesis created with
5254 # the same parameters, else (default) - creates a new one
5255 # @ingroup l3_hypos_maxvol
5256 def MaxElementVolume(self, vol, UseExisting=0):
5257 if self.algoType == NETGEN:
5258 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5259 CompareMethod=self.CompareMaxElementVolume)
5260 hyp.SetMaxElementVolume(vol)
5262 elif self.algoType == FULL_NETGEN:
5263 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5266 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5267 def CompareMaxElementVolume(self, hyp, args):
5268 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5270 ## Defines hypothesis having several parameters
5272 # @ingroup l3_hypos_netgen
5273 def Parameters(self, which=SOLE):
5276 if self.algoType == FULL_NETGEN:
5278 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5279 "libNETGENEngine.so", UseExisting=0)
5281 self.params = self.Hypothesis("NETGEN_Parameters", [],
5282 "libNETGENEngine.so", UseExisting=0)
5284 if self.algoType == NETGEN:
5285 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5286 "libNETGENEngine.so", UseExisting=0)
5288 elif self.algoType == GHS3D:
5289 self.params = self.Hypothesis("GHS3D_Parameters", [],
5290 "libGHS3DEngine.so", UseExisting=0)
5292 elif self.algoType == GHS3DPRL:
5293 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5294 "libGHS3DPRLEngine.so", UseExisting=0)
5296 print "Algo supports no multi-parameter hypothesis"
5301 # Parameter of FULL_NETGEN and NETGEN
5302 # @ingroup l3_hypos_netgen
5303 def SetMaxSize(self, theSize):
5304 self.Parameters().SetMaxSize(theSize)
5306 ## Sets SecondOrder flag
5307 # Parameter of FULL_NETGEN
5308 # @ingroup l3_hypos_netgen
5309 def SetSecondOrder(self, theVal):
5310 self.Parameters().SetSecondOrder(theVal)
5312 ## Sets Optimize flag
5313 # Parameter of FULL_NETGEN and NETGEN
5314 # @ingroup l3_hypos_netgen
5315 def SetOptimize(self, theVal):
5316 self.Parameters().SetOptimize(theVal)
5319 # @param theFineness is:
5320 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5321 # Parameter of FULL_NETGEN
5322 # @ingroup l3_hypos_netgen
5323 def SetFineness(self, theFineness):
5324 self.Parameters().SetFineness(theFineness)
5327 # Parameter of FULL_NETGEN
5328 # @ingroup l3_hypos_netgen
5329 def SetGrowthRate(self, theRate):
5330 self.Parameters().SetGrowthRate(theRate)
5332 ## Sets NbSegPerEdge
5333 # Parameter of FULL_NETGEN
5334 # @ingroup l3_hypos_netgen
5335 def SetNbSegPerEdge(self, theVal):
5336 self.Parameters().SetNbSegPerEdge(theVal)
5338 ## Sets NbSegPerRadius
5339 # Parameter of FULL_NETGEN
5340 # @ingroup l3_hypos_netgen
5341 def SetNbSegPerRadius(self, theVal):
5342 self.Parameters().SetNbSegPerRadius(theVal)
5344 ## Sets number of segments overriding value set by SetLocalLength()
5345 # Only for algoType == NETGEN_FULL
5346 # @ingroup l3_hypos_netgen
5347 def SetNumberOfSegments(self, theVal):
5348 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5350 ## Sets number of segments overriding value set by SetNumberOfSegments()
5351 # Only for algoType == NETGEN_FULL
5352 # @ingroup l3_hypos_netgen
5353 def SetLocalLength(self, theVal):
5354 self.Parameters(SIMPLE).SetLocalLength(theVal)
5356 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5357 # Overrides value set by LengthFromEdges()
5358 # Only for algoType == NETGEN_FULL
5359 # @ingroup l3_hypos_netgen
5360 def MaxElementArea(self, area):
5361 self.Parameters(SIMPLE).SetMaxElementArea(area)
5363 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5364 # Overrides value set by MaxElementArea()
5365 # Only for algoType == NETGEN_FULL
5366 # @ingroup l3_hypos_netgen
5367 def LengthFromEdges(self):
5368 self.Parameters(SIMPLE).LengthFromEdges()
5370 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5371 # Overrides value set by MaxElementVolume()
5372 # Only for algoType == NETGEN_FULL
5373 # @ingroup l3_hypos_netgen
5374 def LengthFromFaces(self):
5375 self.Parameters(SIMPLE).LengthFromFaces()
5377 ## To mesh "holes" in a solid or not. Default is to mesh.
5378 # @ingroup l3_hypos_ghs3dh
5379 def SetToMeshHoles(self, toMesh):
5380 # Parameter of GHS3D
5381 self.Parameters().SetToMeshHoles(toMesh)
5383 ## Set Optimization level:
5384 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5385 # Strong_Optimization.
5386 # Default is Standard_Optimization
5387 # @ingroup l3_hypos_ghs3dh
5388 def SetOptimizationLevel(self, level):
5389 # Parameter of GHS3D
5390 self.Parameters().SetOptimizationLevel(level)
5392 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5393 # @ingroup l3_hypos_ghs3dh
5394 def SetMaximumMemory(self, MB):
5395 # Advanced parameter of GHS3D
5396 self.Parameters().SetMaximumMemory(MB)
5398 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5399 # automatic memory adjustment mode.
5400 # @ingroup l3_hypos_ghs3dh
5401 def SetInitialMemory(self, MB):
5402 # Advanced parameter of GHS3D
5403 self.Parameters().SetInitialMemory(MB)
5405 ## Path to working directory.
5406 # @ingroup l3_hypos_ghs3dh
5407 def SetWorkingDirectory(self, path):
5408 # Advanced parameter of GHS3D
5409 self.Parameters().SetWorkingDirectory(path)
5411 ## To keep working files or remove them. Log file remains in case of errors anyway.
5412 # @ingroup l3_hypos_ghs3dh
5413 def SetKeepFiles(self, toKeep):
5414 # Advanced parameter of GHS3D and GHS3DPRL
5415 self.Parameters().SetKeepFiles(toKeep)
5417 ## To set verbose level [0-10]. <ul>
5418 #<li> 0 - no standard output,
5419 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5420 # indicates when the final mesh is being saved. In addition the software
5421 # gives indication regarding the CPU time.
5422 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5423 # histogram of the skin mesh, quality statistics histogram together with
5424 # the characteristics of the final mesh.</ul>
5425 # @ingroup l3_hypos_ghs3dh
5426 def SetVerboseLevel(self, level):
5427 # Advanced parameter of GHS3D
5428 self.Parameters().SetVerboseLevel(level)
5430 ## To create new nodes.
5431 # @ingroup l3_hypos_ghs3dh
5432 def SetToCreateNewNodes(self, toCreate):
5433 # Advanced parameter of GHS3D
5434 self.Parameters().SetToCreateNewNodes(toCreate)
5436 ## To use boundary recovery version which tries to create mesh on a very poor
5437 # quality surface mesh.
5438 # @ingroup l3_hypos_ghs3dh
5439 def SetToUseBoundaryRecoveryVersion(self, toUse):
5440 # Advanced parameter of GHS3D
5441 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5443 ## Sets command line option as text.
5444 # @ingroup l3_hypos_ghs3dh
5445 def SetTextOption(self, option):
5446 # Advanced parameter of GHS3D
5447 self.Parameters().SetTextOption(option)
5449 ## Sets MED files name and path.
5450 def SetMEDName(self, value):
5451 self.Parameters().SetMEDName(value)
5453 ## Sets the number of partition of the initial mesh
5454 def SetNbPart(self, value):
5455 self.Parameters().SetNbPart(value)
5457 ## When big mesh, start tepal in background
5458 def SetBackground(self, value):
5459 self.Parameters().SetBackground(value)
5461 # Public class: Mesh_Hexahedron
5462 # ------------------------------
5464 ## Defines a hexahedron 3D algorithm
5466 # @ingroup l3_algos_basic
5467 class Mesh_Hexahedron(Mesh_Algorithm):
5472 ## Private constructor.
5473 def __init__(self, mesh, algoType=Hexa, geom=0):
5474 Mesh_Algorithm.__init__(self)
5476 self.algoType = algoType
5478 if algoType == Hexa:
5479 self.Create(mesh, geom, "Hexa_3D")
5482 elif algoType == Hexotic:
5483 CheckPlugin(Hexotic)
5484 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5487 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5488 # @ingroup l3_hypos_hexotic
5489 def MinMaxQuad(self, min=3, max=8, quad=True):
5490 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5492 self.params.SetHexesMinLevel(min)
5493 self.params.SetHexesMaxLevel(max)
5494 self.params.SetHexoticQuadrangles(quad)
5497 # Deprecated, only for compatibility!
5498 # Public class: Mesh_Netgen
5499 # ------------------------------
5501 ## Defines a NETGEN-based 2D or 3D algorithm
5502 # that needs no discrete boundary (i.e. independent)
5504 # This class is deprecated, only for compatibility!
5507 # @ingroup l3_algos_basic
5508 class Mesh_Netgen(Mesh_Algorithm):
5512 ## Private constructor.
5513 def __init__(self, mesh, is3D, geom=0):
5514 Mesh_Algorithm.__init__(self)
5520 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5524 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5527 ## Defines the hypothesis containing parameters of the algorithm
5528 def Parameters(self):
5530 hyp = self.Hypothesis("NETGEN_Parameters", [],
5531 "libNETGENEngine.so", UseExisting=0)
5533 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5534 "libNETGENEngine.so", UseExisting=0)
5537 # Public class: Mesh_Projection1D
5538 # ------------------------------
5540 ## Defines a projection 1D algorithm
5541 # @ingroup l3_algos_proj
5543 class Mesh_Projection1D(Mesh_Algorithm):
5545 ## Private constructor.
5546 def __init__(self, mesh, geom=0):
5547 Mesh_Algorithm.__init__(self)
5548 self.Create(mesh, geom, "Projection_1D")
5550 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5551 # a mesh pattern is taken, and, optionally, the association of vertices
5552 # between the source edge and a target edge (to which a hypothesis is assigned)
5553 # @param edge from which nodes distribution is taken
5554 # @param mesh from which nodes distribution is taken (optional)
5555 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5556 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5557 # to associate with \a srcV (optional)
5558 # @param UseExisting if ==true - searches for the existing hypothesis created with
5559 # the same parameters, else (default) - creates a new one
5560 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5561 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5563 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5564 hyp.SetSourceEdge( edge )
5565 if not mesh is None and isinstance(mesh, Mesh):
5566 mesh = mesh.GetMesh()
5567 hyp.SetSourceMesh( mesh )
5568 hyp.SetVertexAssociation( srcV, tgtV )
5571 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5572 #def CompareSourceEdge(self, hyp, args):
5573 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5577 # Public class: Mesh_Projection2D
5578 # ------------------------------
5580 ## Defines a projection 2D algorithm
5581 # @ingroup l3_algos_proj
5583 class Mesh_Projection2D(Mesh_Algorithm):
5585 ## Private constructor.
5586 def __init__(self, mesh, geom=0):
5587 Mesh_Algorithm.__init__(self)
5588 self.Create(mesh, geom, "Projection_2D")
5590 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5591 # a mesh pattern is taken, and, optionally, the association of vertices
5592 # between the source face and the target face (to which a hypothesis is assigned)
5593 # @param face from which the mesh pattern is taken
5594 # @param mesh from which the mesh pattern is taken (optional)
5595 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5596 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5597 # to associate with \a srcV1 (optional)
5598 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5599 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5600 # to associate with \a srcV2 (optional)
5601 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5602 # the same parameters, else (default) - forces the creation a new one
5604 # Note: all association vertices must belong to one edge of a face
5605 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5606 srcV2=None, tgtV2=None, UseExisting=0):
5607 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5609 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5610 hyp.SetSourceFace( face )
5611 if not mesh is None and isinstance(mesh, Mesh):
5612 mesh = mesh.GetMesh()
5613 hyp.SetSourceMesh( mesh )
5614 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5617 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5618 #def CompareSourceFace(self, hyp, args):
5619 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5622 # Public class: Mesh_Projection3D
5623 # ------------------------------
5625 ## Defines a projection 3D algorithm
5626 # @ingroup l3_algos_proj
5628 class Mesh_Projection3D(Mesh_Algorithm):
5630 ## Private constructor.
5631 def __init__(self, mesh, geom=0):
5632 Mesh_Algorithm.__init__(self)
5633 self.Create(mesh, geom, "Projection_3D")
5635 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5636 # the mesh pattern is taken, and, optionally, the association of vertices
5637 # between the source and the target solid (to which a hipothesis is assigned)
5638 # @param solid from where the mesh pattern is taken
5639 # @param mesh from where the mesh pattern is taken (optional)
5640 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5641 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5642 # to associate with \a srcV1 (optional)
5643 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5644 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5645 # to associate with \a srcV2 (optional)
5646 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5647 # the same parameters, else (default) - creates a new one
5649 # Note: association vertices must belong to one edge of a solid
5650 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5651 srcV2=0, tgtV2=0, UseExisting=0):
5652 hyp = self.Hypothesis("ProjectionSource3D",
5653 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5655 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5656 hyp.SetSource3DShape( solid )
5657 if not mesh is None and isinstance(mesh, Mesh):
5658 mesh = mesh.GetMesh()
5659 hyp.SetSourceMesh( mesh )
5660 if srcV1 and srcV2 and tgtV1 and tgtV2:
5661 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5662 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5665 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5666 #def CompareSourceShape3D(self, hyp, args):
5667 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5671 # Public class: Mesh_Prism
5672 # ------------------------
5674 ## Defines a 3D extrusion algorithm
5675 # @ingroup l3_algos_3dextr
5677 class Mesh_Prism3D(Mesh_Algorithm):
5679 ## Private constructor.
5680 def __init__(self, mesh, geom=0):
5681 Mesh_Algorithm.__init__(self)
5682 self.Create(mesh, geom, "Prism_3D")
5684 # Public class: Mesh_RadialPrism
5685 # -------------------------------
5687 ## Defines a Radial Prism 3D algorithm
5688 # @ingroup l3_algos_radialp
5690 class Mesh_RadialPrism3D(Mesh_Algorithm):
5692 ## Private constructor.
5693 def __init__(self, mesh, geom=0):
5694 Mesh_Algorithm.__init__(self)
5695 self.Create(mesh, geom, "RadialPrism_3D")
5697 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5698 self.nbLayers = None
5700 ## Return 3D hypothesis holding the 1D one
5701 def Get3DHypothesis(self):
5702 return self.distribHyp
5704 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5705 # hypothesis. Returns the created hypothesis
5706 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5707 #print "OwnHypothesis",hypType
5708 if not self.nbLayers is None:
5709 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5710 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5711 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5712 self.mesh.smeshpyD.SetCurrentStudy( None )
5713 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5714 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5715 self.distribHyp.SetLayerDistribution( hyp )
5718 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5719 # prisms to build between the inner and outer shells
5720 # @param n number of layers
5721 # @param UseExisting if ==true - searches for the existing hypothesis created with
5722 # the same parameters, else (default) - creates a new one
5723 def NumberOfLayers(self, n, UseExisting=0):
5724 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5725 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5726 CompareMethod=self.CompareNumberOfLayers)
5727 self.nbLayers.SetNumberOfLayers( n )
5728 return self.nbLayers
5730 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5731 def CompareNumberOfLayers(self, hyp, args):
5732 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5734 ## Defines "LocalLength" hypothesis, specifying the segment length
5735 # to build between the inner and the outer shells
5736 # @param l the length of segments
5737 # @param p the precision of rounding
5738 def LocalLength(self, l, p=1e-07):
5739 hyp = self.OwnHypothesis("LocalLength", [l,p])
5744 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5745 # prisms to build between the inner and the outer shells.
5746 # @param n the number of layers
5747 # @param s the scale factor (optional)
5748 def NumberOfSegments(self, n, s=[]):
5750 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5752 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5753 hyp.SetDistrType( 1 )
5754 hyp.SetScaleFactor(s)
5755 hyp.SetNumberOfSegments(n)
5758 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5759 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5760 # @param start the length of the first segment
5761 # @param end the length of the last segment
5762 def Arithmetic1D(self, start, end ):
5763 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5764 hyp.SetLength(start, 1)
5765 hyp.SetLength(end , 0)
5768 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5769 # to build between the inner and the outer shells as geometric length increasing
5770 # @param start for the length of the first segment
5771 # @param end for the length of the last segment
5772 def StartEndLength(self, start, end):
5773 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5774 hyp.SetLength(start, 1)
5775 hyp.SetLength(end , 0)
5778 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5779 # to build between the inner and outer shells
5780 # @param fineness defines the quality of the mesh within the range [0-1]
5781 def AutomaticLength(self, fineness=0):
5782 hyp = self.OwnHypothesis("AutomaticLength")
5783 hyp.SetFineness( fineness )
5786 # Public class: Mesh_RadialQuadrangle1D2D
5787 # -------------------------------
5789 ## Defines a Radial Quadrangle 1D2D algorithm
5790 # @ingroup l2_algos_radialq
5792 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5794 ## Private constructor.
5795 def __init__(self, mesh, geom=0):
5796 Mesh_Algorithm.__init__(self)
5797 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5799 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5800 self.nbLayers = None
5802 ## Return 2D hypothesis holding the 1D one
5803 def Get2DHypothesis(self):
5804 return self.distribHyp
5806 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5807 # hypothesis. Returns the created hypothesis
5808 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5809 #print "OwnHypothesis",hypType
5811 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5812 if self.distribHyp is None:
5813 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5815 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5816 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5817 self.mesh.smeshpyD.SetCurrentStudy( None )
5818 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5819 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5820 self.distribHyp.SetLayerDistribution( hyp )
5823 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5824 # @param n number of layers
5825 # @param UseExisting if ==true - searches for the existing hypothesis created with
5826 # the same parameters, else (default) - creates a new one
5827 def NumberOfLayers(self, n, UseExisting=0):
5829 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5830 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5831 CompareMethod=self.CompareNumberOfLayers)
5832 self.nbLayers.SetNumberOfLayers( n )
5833 return self.nbLayers
5835 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5836 def CompareNumberOfLayers(self, hyp, args):
5837 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5839 ## Defines "LocalLength" hypothesis, specifying the segment length
5840 # @param l the length of segments
5841 # @param p the precision of rounding
5842 def LocalLength(self, l, p=1e-07):
5843 hyp = self.OwnHypothesis("LocalLength", [l,p])
5848 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5849 # @param n the number of layers
5850 # @param s the scale factor (optional)
5851 def NumberOfSegments(self, n, s=[]):
5853 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5855 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5856 hyp.SetDistrType( 1 )
5857 hyp.SetScaleFactor(s)
5858 hyp.SetNumberOfSegments(n)
5861 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5862 # with a length that changes in arithmetic progression
5863 # @param start the length of the first segment
5864 # @param end the length of the last segment
5865 def Arithmetic1D(self, start, end ):
5866 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5867 hyp.SetLength(start, 1)
5868 hyp.SetLength(end , 0)
5871 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5872 # as geometric length increasing
5873 # @param start for the length of the first segment
5874 # @param end for the length of the last segment
5875 def StartEndLength(self, start, end):
5876 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5877 hyp.SetLength(start, 1)
5878 hyp.SetLength(end , 0)
5881 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5882 # @param fineness defines the quality of the mesh within the range [0-1]
5883 def AutomaticLength(self, fineness=0):
5884 hyp = self.OwnHypothesis("AutomaticLength")
5885 hyp.SetFineness( fineness )
5889 # Public class: Mesh_UseExistingElements
5890 # --------------------------------------
5891 ## Defines a Radial Quadrangle 1D2D algorithm
5892 # @ingroup l3_algos_basic
5894 class Mesh_UseExistingElements(Mesh_Algorithm):
5896 def __init__(self, dim, mesh, geom=0):
5898 self.Create(mesh, geom, "Import_1D")
5900 self.Create(mesh, geom, "Import_1D2D")
5903 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5904 # @param groups list of groups of edges
5905 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5906 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5907 # @param UseExisting if ==true - searches for the existing hypothesis created with
5908 # the same parameters, else (default) - creates a new one
5909 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5910 if self.algo.GetName() == "Import_2D":
5911 raise ValueError, "algoritm dimension mismatch"
5912 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5913 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5914 hyp.SetSourceEdges(groups)
5915 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5918 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5919 # @param groups list of groups of faces
5920 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5921 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5922 # @param UseExisting if ==true - searches for the existing hypothesis created with
5923 # the same parameters, else (default) - creates a new one
5924 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5925 if self.algo.GetName() == "Import_1D":
5926 raise ValueError, "algoritm dimension mismatch"
5927 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5928 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5929 hyp.SetSourceFaces(groups)
5930 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5933 def _compareHyp(self,hyp,args):
5934 if hasattr( hyp, "GetSourceEdges"):
5935 entries = hyp.GetSourceEdges()
5937 entries = hyp.GetSourceFaces()
5939 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5940 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5942 study = self.mesh.smeshpyD.GetCurrentStudy()
5945 ior = salome.orb.object_to_string(g)
5946 sobj = study.FindObjectIOR(ior)
5947 if sobj: entries2.append( sobj.GetID() )
5952 return entries == entries2
5956 # Private class: Mesh_UseExisting
5957 # -------------------------------
5958 class Mesh_UseExisting(Mesh_Algorithm):
5960 def __init__(self, dim, mesh, geom=0):
5962 self.Create(mesh, geom, "UseExisting_1D")
5964 self.Create(mesh, geom, "UseExisting_2D")
5967 import salome_notebook
5968 notebook = salome_notebook.notebook
5970 ##Return values of the notebook variables
5971 def ParseParameters(last, nbParams,nbParam, value):
5975 listSize = len(last)
5976 for n in range(0,nbParams):
5978 if counter < listSize:
5979 strResult = strResult + last[counter]
5981 strResult = strResult + ""
5983 if isinstance(value, str):
5984 if notebook.isVariable(value):
5985 result = notebook.get(value)
5986 strResult=strResult+value
5988 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5990 strResult=strResult+str(value)
5992 if nbParams - 1 != counter:
5993 strResult=strResult+var_separator #":"
5995 return result, strResult
5997 #Wrapper class for StdMeshers_LocalLength hypothesis
5998 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
6000 ## Set Length parameter value
6001 # @param length numerical value or name of variable from notebook
6002 def SetLength(self, length):
6003 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6004 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6005 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6007 ## Set Precision parameter value
6008 # @param precision numerical value or name of variable from notebook
6009 def SetPrecision(self, precision):
6010 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6011 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6012 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6014 #Registering the new proxy for LocalLength
6015 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6018 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6019 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6021 def SetLayerDistribution(self, hypo):
6022 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6023 hypo.ClearParameters();
6024 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6026 #Registering the new proxy for LayerDistribution
6027 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6029 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6030 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6032 ## Set Length parameter value
6033 # @param length numerical value or name of variable from notebook
6034 def SetLength(self, length):
6035 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6036 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6037 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6039 #Registering the new proxy for SegmentLengthAroundVertex
6040 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6043 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6044 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6046 ## Set Length parameter value
6047 # @param length numerical value or name of variable from notebook
6048 # @param isStart true is length is Start Length, otherwise false
6049 def SetLength(self, length, isStart):
6053 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6054 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6055 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6057 #Registering the new proxy for Arithmetic1D
6058 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6060 #Wrapper class for StdMeshers_Deflection1D hypothesis
6061 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6063 ## Set Deflection parameter value
6064 # @param deflection numerical value or name of variable from notebook
6065 def SetDeflection(self, deflection):
6066 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6067 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6068 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6070 #Registering the new proxy for Deflection1D
6071 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6073 #Wrapper class for StdMeshers_StartEndLength hypothesis
6074 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6076 ## Set Length parameter value
6077 # @param length numerical value or name of variable from notebook
6078 # @param isStart true is length is Start Length, otherwise false
6079 def SetLength(self, length, isStart):
6083 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6084 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6085 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6087 #Registering the new proxy for StartEndLength
6088 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6090 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6091 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6093 ## Set Max Element Area parameter value
6094 # @param area numerical value or name of variable from notebook
6095 def SetMaxElementArea(self, area):
6096 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6097 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6098 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6100 #Registering the new proxy for MaxElementArea
6101 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6104 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6105 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6107 ## Set Max Element Volume parameter value
6108 # @param volume numerical value or name of variable from notebook
6109 def SetMaxElementVolume(self, volume):
6110 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6111 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6112 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6114 #Registering the new proxy for MaxElementVolume
6115 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6118 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6119 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6121 ## Set Number Of Layers parameter value
6122 # @param nbLayers numerical value or name of variable from notebook
6123 def SetNumberOfLayers(self, nbLayers):
6124 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6125 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6126 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6128 #Registering the new proxy for NumberOfLayers
6129 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6131 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6132 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6134 ## Set Number Of Segments parameter value
6135 # @param nbSeg numerical value or name of variable from notebook
6136 def SetNumberOfSegments(self, nbSeg):
6137 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6138 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6139 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6140 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6142 ## Set Scale Factor parameter value
6143 # @param factor numerical value or name of variable from notebook
6144 def SetScaleFactor(self, factor):
6145 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6146 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6147 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6149 #Registering the new proxy for NumberOfSegments
6150 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6152 if not noNETGENPlugin:
6153 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6154 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6156 ## Set Max Size parameter value
6157 # @param maxsize numerical value or name of variable from notebook
6158 def SetMaxSize(self, maxsize):
6159 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6160 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6161 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6162 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6164 ## Set Growth Rate parameter value
6165 # @param value numerical value or name of variable from notebook
6166 def SetGrowthRate(self, value):
6167 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6168 value, parameters = ParseParameters(lastParameters,4,2,value)
6169 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6170 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6172 ## Set Number of Segments per Edge parameter value
6173 # @param value numerical value or name of variable from notebook
6174 def SetNbSegPerEdge(self, value):
6175 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6176 value, parameters = ParseParameters(lastParameters,4,3,value)
6177 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6178 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6180 ## Set Number of Segments per Radius parameter value
6181 # @param value numerical value or name of variable from notebook
6182 def SetNbSegPerRadius(self, value):
6183 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6184 value, parameters = ParseParameters(lastParameters,4,4,value)
6185 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6186 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6188 #Registering the new proxy for NETGENPlugin_Hypothesis
6189 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6192 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6193 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6196 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6197 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6199 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6200 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6202 ## Set Number of Segments parameter value
6203 # @param nbSeg numerical value or name of variable from notebook
6204 def SetNumberOfSegments(self, nbSeg):
6205 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6206 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6207 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6208 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6210 ## Set Local Length parameter value
6211 # @param length numerical value or name of variable from notebook
6212 def SetLocalLength(self, length):
6213 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6214 length, parameters = ParseParameters(lastParameters,2,1,length)
6215 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6216 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6218 ## Set Max Element Area parameter value
6219 # @param area numerical value or name of variable from notebook
6220 def SetMaxElementArea(self, area):
6221 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6222 area, parameters = ParseParameters(lastParameters,2,2,area)
6223 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6224 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6226 def LengthFromEdges(self):
6227 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6229 value, parameters = ParseParameters(lastParameters,2,2,value)
6230 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6231 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6233 #Registering the new proxy for NETGEN_SimpleParameters_2D
6234 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6237 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6238 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6239 ## Set Max Element Volume parameter value
6240 # @param volume numerical value or name of variable from notebook
6241 def SetMaxElementVolume(self, volume):
6242 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6243 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6244 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6245 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6247 def LengthFromFaces(self):
6248 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6250 value, parameters = ParseParameters(lastParameters,3,3,value)
6251 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6252 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6254 #Registering the new proxy for NETGEN_SimpleParameters_3D
6255 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6257 pass # if not noNETGENPlugin:
6259 class Pattern(SMESH._objref_SMESH_Pattern):
6261 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6263 if isinstance(theNodeIndexOnKeyPoint1,str):
6265 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6267 theNodeIndexOnKeyPoint1 -= 1
6268 theMesh.SetParameters(Parameters)
6269 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6271 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6274 if isinstance(theNode000Index,str):
6276 if isinstance(theNode001Index,str):
6278 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6280 theNode000Index -= 1
6282 theNode001Index -= 1
6283 theMesh.SetParameters(Parameters)
6284 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6286 #Registering the new proxy for Pattern
6287 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)