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 elif CritType == FT_RangeOfIds:
791 # Checks the treshold
792 if isinstance(aTreshold, str):
793 aCriterion.ThresholdStr = aTreshold
795 print "Error: The treshold should be a string."
797 elif CritType == FT_CoplanarFaces:
798 # Checks the treshold
799 if isinstance(aTreshold, int):
800 aCriterion.ThresholdID = "%s"%aTreshold
801 elif isinstance(aTreshold, str):
804 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
805 aCriterion.ThresholdID = aTreshold
808 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
809 elif CritType == FT_ElemGeomType:
810 # Checks the treshold
812 aCriterion.Threshold = self.EnumToLong(aTreshold)
814 if isinstance(aTreshold, int):
815 aCriterion.Threshold = aTreshold
817 print "Error: The treshold should be an integer or SMESH.GeometryType."
821 elif CritType == FT_GroupColor:
822 # Checks the treshold
824 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
826 print "Error: The threshold value should be of SALOMEDS.Color type"
829 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
830 FT_FreeFaces, FT_LinearOrQuadratic,
831 FT_BareBorderFace, FT_BareBorderVolume,
832 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
833 # At this point the treshold is unnecessary
834 if aTreshold == FT_LogicalNOT:
835 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
836 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
837 aCriterion.BinaryOp = aTreshold
841 aTreshold = float(aTreshold)
842 aCriterion.Threshold = aTreshold
844 print "Error: The treshold should be a number."
847 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
848 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
850 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
851 aCriterion.BinaryOp = self.EnumToLong(Treshold)
853 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
854 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
856 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
857 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
861 ## Creates a filter with the given parameters
862 # @param elementType the type of elements in the group
863 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
864 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
865 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
866 # @param UnaryOp FT_LogicalNOT or FT_Undefined
867 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
868 # FT_LyingOnGeom, FT_CoplanarFaces criteria
869 # @return SMESH_Filter
870 # @ingroup l1_controls
871 def GetFilter(self,elementType,
872 CritType=FT_Undefined,
875 UnaryOp=FT_Undefined,
877 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
878 aFilterMgr = self.CreateFilterManager()
879 aFilter = aFilterMgr.CreateFilter()
881 aCriteria.append(aCriterion)
882 aFilter.SetCriteria(aCriteria)
886 ## Creates a numerical functor by its type
887 # @param theCriterion FT_...; functor type
888 # @return SMESH_NumericalFunctor
889 # @ingroup l1_controls
890 def GetFunctor(self,theCriterion):
891 aFilterMgr = self.CreateFilterManager()
892 if theCriterion == FT_AspectRatio:
893 return aFilterMgr.CreateAspectRatio()
894 elif theCriterion == FT_AspectRatio3D:
895 return aFilterMgr.CreateAspectRatio3D()
896 elif theCriterion == FT_Warping:
897 return aFilterMgr.CreateWarping()
898 elif theCriterion == FT_MinimumAngle:
899 return aFilterMgr.CreateMinimumAngle()
900 elif theCriterion == FT_Taper:
901 return aFilterMgr.CreateTaper()
902 elif theCriterion == FT_Skew:
903 return aFilterMgr.CreateSkew()
904 elif theCriterion == FT_Area:
905 return aFilterMgr.CreateArea()
906 elif theCriterion == FT_Volume3D:
907 return aFilterMgr.CreateVolume3D()
908 elif theCriterion == FT_MaxElementLength2D:
909 return aFilterMgr.CreateMaxElementLength2D()
910 elif theCriterion == FT_MaxElementLength3D:
911 return aFilterMgr.CreateMaxElementLength3D()
912 elif theCriterion == FT_MultiConnection:
913 return aFilterMgr.CreateMultiConnection()
914 elif theCriterion == FT_MultiConnection2D:
915 return aFilterMgr.CreateMultiConnection2D()
916 elif theCriterion == FT_Length:
917 return aFilterMgr.CreateLength()
918 elif theCriterion == FT_Length2D:
919 return aFilterMgr.CreateLength2D()
921 print "Error: given parameter is not numerucal functor type."
923 ## Creates hypothesis
924 # @param theHType mesh hypothesis type (string)
925 # @param theLibName mesh plug-in library name
926 # @return created hypothesis instance
927 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
928 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
930 ## Gets the mesh stattistic
931 # @return dictionary type element - count of elements
932 # @ingroup l1_meshinfo
933 def GetMeshInfo(self, obj):
934 if isinstance( obj, Mesh ):
937 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
938 values = obj.GetMeshInfo()
939 for i in range(SMESH.Entity_Last._v):
940 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
944 ## Get minimum distance between two objects
946 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
947 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
949 # @param src1 first source object
950 # @param src2 second source object
951 # @param id1 node/element id from the first source
952 # @param id2 node/element id from the second (or first) source
953 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
954 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
955 # @return minimum distance value
956 # @sa GetMinDistance()
957 # @ingroup l1_measurements
958 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
959 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
963 result = result.value
966 ## Get measure structure specifying minimum distance data between two objects
968 # If @a src2 is None, and @a id2 = 0, distance from @a src1 / @a id1 to the origin is computed.
969 # If @a src2 is None, and @a id2 != 0, it is assumed that both @a id1 and @a id2 belong to @a src1.
971 # @param src1 first source object
972 # @param src2 second source object
973 # @param id1 node/element id from the first source
974 # @param id2 node/element id from the second (or first) source
975 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
976 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
977 # @return Measure structure or None if input data is invalid
979 # @ingroup l1_measurements
980 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
981 if isinstance(src1, Mesh): src1 = src1.mesh
982 if isinstance(src2, Mesh): src2 = src2.mesh
983 if src2 is None and id2 != 0: src2 = src1
984 if not hasattr(src1, "_narrow"): return None
985 src1 = src1._narrow(SMESH.SMESH_IDSource)
986 if not src1: return None
989 e = m.GetMeshEditor()
991 src1 = e.MakeIDSource([id1], SMESH.FACE)
993 src1 = e.MakeIDSource([id1], SMESH.NODE)
995 if hasattr(src2, "_narrow"):
996 src2 = src2._narrow(SMESH.SMESH_IDSource)
997 if src2 and id2 != 0:
999 e = m.GetMeshEditor()
1001 src2 = e.MakeIDSource([id2], SMESH.FACE)
1003 src2 = e.MakeIDSource([id2], SMESH.NODE)
1006 aMeasurements = self.CreateMeasurements()
1007 result = aMeasurements.MinDistance(src1, src2)
1008 aMeasurements.Destroy()
1011 ## Get bounding box of the specified object(s)
1012 # @param objects single source object or list of source objects
1013 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
1014 # @sa GetBoundingBox()
1015 # @ingroup l1_measurements
1016 def BoundingBox(self, objects):
1017 result = self.GetBoundingBox(objects)
1021 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
1024 ## Get measure structure specifying bounding box data of the specified object(s)
1025 # @param objects single source object or list of source objects
1026 # @return Measure structure
1028 # @ingroup l1_measurements
1029 def GetBoundingBox(self, objects):
1030 if isinstance(objects, tuple):
1031 objects = list(objects)
1032 if not isinstance(objects, list):
1036 if isinstance(o, Mesh):
1037 srclist.append(o.mesh)
1038 elif hasattr(o, "_narrow"):
1039 src = o._narrow(SMESH.SMESH_IDSource)
1040 if src: srclist.append(src)
1043 aMeasurements = self.CreateMeasurements()
1044 result = aMeasurements.BoundingBox(srclist)
1045 aMeasurements.Destroy()
1049 #Registering the new proxy for SMESH_Gen
1050 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
1053 # Public class: Mesh
1054 # ==================
1056 ## This class allows defining and managing a mesh.
1057 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
1058 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
1059 # new nodes and elements and by changing the existing entities), to get information
1060 # about a mesh and to export a mesh into different formats.
1069 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
1070 # sets the GUI name of this mesh to \a name.
1071 # @param smeshpyD an instance of smeshDC class
1072 # @param geompyD an instance of geompyDC class
1073 # @param obj Shape to be meshed or SMESH_Mesh object
1074 # @param name Study name of the mesh
1075 # @ingroup l2_construct
1076 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
1077 self.smeshpyD=smeshpyD
1078 self.geompyD=geompyD
1082 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
1084 # publish geom of mesh (issue 0021122)
1085 if not self.geom.GetStudyEntry():
1086 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
1087 if studyID != geompyD.myStudyId:
1088 geompyD.init_geom( smeshpyD.GetCurrentStudy())
1090 name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
1091 geompyD.addToStudy( self.geom, name )
1092 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1094 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1097 self.mesh = self.smeshpyD.CreateEmptyMesh()
1099 self.smeshpyD.SetName(self.mesh, name)
1101 self.smeshpyD.SetName(self.mesh, GetName(obj))
1104 self.geom = self.mesh.GetShapeToMesh()
1106 self.editor = self.mesh.GetMeshEditor()
1108 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1109 # @param theMesh a SMESH_Mesh object
1110 # @ingroup l2_construct
1111 def SetMesh(self, theMesh):
1113 self.geom = self.mesh.GetShapeToMesh()
1115 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1116 # @return a SMESH_Mesh object
1117 # @ingroup l2_construct
1121 ## Gets the name of the mesh
1122 # @return the name of the mesh as a string
1123 # @ingroup l2_construct
1125 name = GetName(self.GetMesh())
1128 ## Sets a name to the mesh
1129 # @param name a new name of the mesh
1130 # @ingroup l2_construct
1131 def SetName(self, name):
1132 self.smeshpyD.SetName(self.GetMesh(), name)
1134 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1135 # The subMesh object gives access to the IDs of nodes and elements.
1136 # @param theSubObject a geometrical object (shape)
1137 # @param theName a name for the submesh
1138 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1139 # @ingroup l2_submeshes
1140 def GetSubMesh(self, theSubObject, theName):
1141 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1144 ## Returns the shape associated to the mesh
1145 # @return a GEOM_Object
1146 # @ingroup l2_construct
1150 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1151 # @param geom the shape to be meshed (GEOM_Object)
1152 # @ingroup l2_construct
1153 def SetShape(self, geom):
1154 self.mesh = self.smeshpyD.CreateMesh(geom)
1156 ## Returns true if the hypotheses are defined well
1157 # @param theSubObject a subshape of a mesh shape
1158 # @return True or False
1159 # @ingroup l2_construct
1160 def IsReadyToCompute(self, theSubObject):
1161 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1163 ## Returns errors of hypotheses definition.
1164 # The list of errors is empty if everything is OK.
1165 # @param theSubObject a subshape of a mesh shape
1166 # @return a list of errors
1167 # @ingroup l2_construct
1168 def GetAlgoState(self, theSubObject):
1169 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1171 ## Returns a geometrical object on which the given element was built.
1172 # The returned geometrical object, if not nil, is either found in the
1173 # study or published by this method with the given name
1174 # @param theElementID the id of the mesh element
1175 # @param theGeomName the user-defined name of the geometrical object
1176 # @return GEOM::GEOM_Object instance
1177 # @ingroup l2_construct
1178 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1179 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1181 ## Returns the mesh dimension depending on the dimension of the underlying shape
1182 # @return mesh dimension as an integer value [0,3]
1183 # @ingroup l1_auxiliary
1184 def MeshDimension(self):
1185 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1186 if len( shells ) > 0 :
1188 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1190 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1196 ## Creates a segment discretization 1D algorithm.
1197 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1198 # \n If the optional \a geom parameter is not set, this algorithm is global.
1199 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1200 # @param algo the type of the required algorithm. Possible values are:
1202 # - smesh.PYTHON for discretization via a python function,
1203 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1204 # @param geom If defined is the subshape to be meshed
1205 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1206 # @ingroup l3_algos_basic
1207 def Segment(self, algo=REGULAR, geom=0):
1208 ## if Segment(geom) is called by mistake
1209 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1210 algo, geom = geom, algo
1211 if not algo: algo = REGULAR
1214 return Mesh_Segment(self, geom)
1215 elif algo == PYTHON:
1216 return Mesh_Segment_Python(self, geom)
1217 elif algo == COMPOSITE:
1218 return Mesh_CompositeSegment(self, geom)
1220 return Mesh_Segment(self, geom)
1222 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1223 # If the optional \a geom parameter is not set, this algorithm is global.
1224 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1225 # @param geom If defined the subshape is to be meshed
1226 # @return an instance of Mesh_UseExistingElements class
1227 # @ingroup l3_algos_basic
1228 def UseExisting1DElements(self, geom=0):
1229 return Mesh_UseExistingElements(1,self, geom)
1231 ## Creates 2D algorithm importing faces conatined in groups of other mesh.
1232 # If the optional \a geom parameter is not set, this algorithm is global.
1233 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1234 # @param geom If defined the subshape is to be meshed
1235 # @return an instance of Mesh_UseExistingElements class
1236 # @ingroup l3_algos_basic
1237 def UseExisting2DElements(self, geom=0):
1238 return Mesh_UseExistingElements(2,self, geom)
1240 ## Enables creation of nodes and segments usable by 2D algoritms.
1241 # The added nodes and segments must be bound to edges and vertices by
1242 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1243 # If the optional \a geom parameter is not set, this algorithm is global.
1244 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1245 # @param geom the subshape to be manually meshed
1246 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1247 # @ingroup l3_algos_basic
1248 def UseExistingSegments(self, geom=0):
1249 algo = Mesh_UseExisting(1,self,geom)
1250 return algo.GetAlgorithm()
1252 ## Enables creation of nodes and faces usable by 3D algoritms.
1253 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1254 # and SetMeshElementOnShape()
1255 # If the optional \a geom parameter is not set, this algorithm is global.
1256 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1257 # @param geom the subshape to be manually meshed
1258 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1259 # @ingroup l3_algos_basic
1260 def UseExistingFaces(self, geom=0):
1261 algo = Mesh_UseExisting(2,self,geom)
1262 return algo.GetAlgorithm()
1264 ## Creates a triangle 2D algorithm for faces.
1265 # If the optional \a geom parameter is not set, this algorithm is global.
1266 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1267 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1268 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1269 # @return an instance of Mesh_Triangle algorithm
1270 # @ingroup l3_algos_basic
1271 def Triangle(self, algo=MEFISTO, geom=0):
1272 ## if Triangle(geom) is called by mistake
1273 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1276 return Mesh_Triangle(self, algo, geom)
1278 ## Creates a quadrangle 2D algorithm for faces.
1279 # If the optional \a geom parameter is not set, this algorithm is global.
1280 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1281 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1282 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1283 # @return an instance of Mesh_Quadrangle algorithm
1284 # @ingroup l3_algos_basic
1285 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1286 if algo==RADIAL_QUAD:
1287 return Mesh_RadialQuadrangle1D2D(self,geom)
1289 return Mesh_Quadrangle(self, geom)
1291 ## Creates a tetrahedron 3D algorithm for solids.
1292 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1293 # If the optional \a geom parameter is not set, this algorithm is global.
1294 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1295 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1296 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1297 # @return an instance of Mesh_Tetrahedron algorithm
1298 # @ingroup l3_algos_basic
1299 def Tetrahedron(self, algo=NETGEN, geom=0):
1300 ## if Tetrahedron(geom) is called by mistake
1301 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1302 algo, geom = geom, algo
1303 if not algo: algo = NETGEN
1305 return Mesh_Tetrahedron(self, algo, geom)
1307 ## Creates a hexahedron 3D algorithm for solids.
1308 # If the optional \a geom parameter is not set, this algorithm is global.
1309 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1310 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1311 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1312 # @return an instance of Mesh_Hexahedron algorithm
1313 # @ingroup l3_algos_basic
1314 def Hexahedron(self, algo=Hexa, geom=0):
1315 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1316 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1317 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1318 elif geom == 0: algo, geom = Hexa, algo
1319 return Mesh_Hexahedron(self, algo, geom)
1321 ## Deprecated, used only for compatibility!
1322 # @return an instance of Mesh_Netgen algorithm
1323 # @ingroup l3_algos_basic
1324 def Netgen(self, is3D, geom=0):
1325 return Mesh_Netgen(self, is3D, geom)
1327 ## Creates a projection 1D algorithm for edges.
1328 # If the optional \a geom parameter is not set, this algorithm is global.
1329 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1330 # @param geom If defined, the subshape to be meshed
1331 # @return an instance of Mesh_Projection1D algorithm
1332 # @ingroup l3_algos_proj
1333 def Projection1D(self, geom=0):
1334 return Mesh_Projection1D(self, geom)
1336 ## Creates a projection 2D algorithm for faces.
1337 # If the optional \a geom parameter is not set, this algorithm is global.
1338 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1339 # @param geom If defined, the subshape to be meshed
1340 # @return an instance of Mesh_Projection2D algorithm
1341 # @ingroup l3_algos_proj
1342 def Projection2D(self, geom=0):
1343 return Mesh_Projection2D(self, geom)
1345 ## Creates a projection 3D algorithm for solids.
1346 # If the optional \a geom parameter is not set, this algorithm is global.
1347 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1348 # @param geom If defined, the subshape to be meshed
1349 # @return an instance of Mesh_Projection3D algorithm
1350 # @ingroup l3_algos_proj
1351 def Projection3D(self, geom=0):
1352 return Mesh_Projection3D(self, geom)
1354 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1355 # If the optional \a geom parameter is not set, this algorithm is global.
1356 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1357 # @param geom If defined, the subshape to be meshed
1358 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1359 # @ingroup l3_algos_radialp l3_algos_3dextr
1360 def Prism(self, geom=0):
1364 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1365 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1366 if nbSolids == 0 or nbSolids == nbShells:
1367 return Mesh_Prism3D(self, geom)
1368 return Mesh_RadialPrism3D(self, geom)
1370 ## Evaluates size of prospective mesh on a shape
1371 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1372 # To know predicted number of e.g. edges, inquire it this way
1373 # Evaluate()[ EnumToLong( Entity_Edge )]
1374 def Evaluate(self, geom=0):
1375 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1377 geom = self.mesh.GetShapeToMesh()
1380 return self.smeshpyD.Evaluate(self.mesh, geom)
1383 ## Computes the mesh and returns the status of the computation
1384 # @param geom geomtrical shape on which mesh data should be computed
1385 # @param discardModifs if True and the mesh has been edited since
1386 # a last total re-compute and that may prevent successful partial re-compute,
1387 # then the mesh is cleaned before Compute()
1388 # @return True or False
1389 # @ingroup l2_construct
1390 def Compute(self, geom=0, discardModifs=False):
1391 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1393 geom = self.mesh.GetShapeToMesh()
1398 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1400 ok = self.smeshpyD.Compute(self.mesh, geom)
1401 except SALOME.SALOME_Exception, ex:
1402 print "Mesh computation failed, exception caught:"
1403 print " ", ex.details.text
1406 print "Mesh computation failed, exception caught:"
1407 traceback.print_exc()
1411 # Treat compute errors
1412 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1413 for err in computeErrors:
1415 if self.mesh.HasShapeToMesh():
1417 mainIOR = salome.orb.object_to_string(geom)
1418 for sname in salome.myStudyManager.GetOpenStudies():
1419 s = salome.myStudyManager.GetStudyByName(sname)
1421 mainSO = s.FindObjectIOR(mainIOR)
1422 if not mainSO: continue
1423 if err.subShapeID == 1:
1424 shapeText = ' on "%s"' % mainSO.GetName()
1425 subIt = s.NewChildIterator(mainSO)
1427 subSO = subIt.Value()
1429 obj = subSO.GetObject()
1430 if not obj: continue
1431 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1433 ids = go.GetSubShapeIndices()
1434 if len(ids) == 1 and ids[0] == err.subShapeID:
1435 shapeText = ' on "%s"' % subSO.GetName()
1438 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1440 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1442 shapeText = " on subshape #%s" % (err.subShapeID)
1444 shapeText = " on subshape #%s" % (err.subShapeID)
1446 stdErrors = ["OK", #COMPERR_OK
1447 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1448 "std::exception", #COMPERR_STD_EXCEPTION
1449 "OCC exception", #COMPERR_OCC_EXCEPTION
1450 "SALOME exception", #COMPERR_SLM_EXCEPTION
1451 "Unknown exception", #COMPERR_EXCEPTION
1452 "Memory allocation problem", #COMPERR_MEMORY_PB
1453 "Algorithm failed", #COMPERR_ALGO_FAILED
1454 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1456 if err.code < len(stdErrors): errText = stdErrors[err.code]
1458 errText = "code %s" % -err.code
1459 if errText: errText += ". "
1460 errText += err.comment
1461 if allReasons != "":allReasons += "\n"
1462 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1466 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1468 if err.isGlobalAlgo:
1476 reason = '%s %sD algorithm is missing' % (glob, dim)
1477 elif err.state == HYP_MISSING:
1478 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1479 % (glob, dim, name, dim))
1480 elif err.state == HYP_NOTCONFORM:
1481 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1482 elif err.state == HYP_BAD_PARAMETER:
1483 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1484 % ( glob, dim, name ))
1485 elif err.state == HYP_BAD_GEOMETRY:
1486 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1487 'geometry' % ( glob, dim, name ))
1489 reason = "For unknown reason."+\
1490 " Revise Mesh.Compute() implementation in smeshDC.py!"
1492 if allReasons != "":allReasons += "\n"
1493 allReasons += reason
1495 if allReasons != "":
1496 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1500 print '"' + GetName(self.mesh) + '"',"has not been computed."
1503 if salome.sg.hasDesktop():
1504 smeshgui = salome.ImportComponentGUI("SMESH")
1505 smeshgui.Init(self.mesh.GetStudyId())
1506 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1507 salome.sg.updateObjBrowser(1)
1511 ## Return submesh objects list in meshing order
1512 # @return list of list of submesh objects
1513 # @ingroup l2_construct
1514 def GetMeshOrder(self):
1515 return self.mesh.GetMeshOrder()
1517 ## Return submesh objects list in meshing order
1518 # @return list of list of submesh objects
1519 # @ingroup l2_construct
1520 def SetMeshOrder(self, submeshes):
1521 return self.mesh.SetMeshOrder(submeshes)
1523 ## Removes all nodes and elements
1524 # @ingroup l2_construct
1527 if salome.sg.hasDesktop():
1528 smeshgui = salome.ImportComponentGUI("SMESH")
1529 smeshgui.Init(self.mesh.GetStudyId())
1530 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1531 salome.sg.updateObjBrowser(1)
1533 ## Removes all nodes and elements of indicated shape
1534 # @ingroup l2_construct
1535 def ClearSubMesh(self, geomId):
1536 self.mesh.ClearSubMesh(geomId)
1537 if salome.sg.hasDesktop():
1538 smeshgui = salome.ImportComponentGUI("SMESH")
1539 smeshgui.Init(self.mesh.GetStudyId())
1540 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1541 salome.sg.updateObjBrowser(1)
1543 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1544 # @param fineness [0,-1] defines mesh fineness
1545 # @return True or False
1546 # @ingroup l3_algos_basic
1547 def AutomaticTetrahedralization(self, fineness=0):
1548 dim = self.MeshDimension()
1550 self.RemoveGlobalHypotheses()
1551 self.Segment().AutomaticLength(fineness)
1553 self.Triangle().LengthFromEdges()
1556 self.Tetrahedron(NETGEN)
1558 return self.Compute()
1560 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1561 # @param fineness [0,-1] defines mesh fineness
1562 # @return True or False
1563 # @ingroup l3_algos_basic
1564 def AutomaticHexahedralization(self, fineness=0):
1565 dim = self.MeshDimension()
1566 # assign the hypotheses
1567 self.RemoveGlobalHypotheses()
1568 self.Segment().AutomaticLength(fineness)
1575 return self.Compute()
1577 ## Assigns a hypothesis
1578 # @param hyp a hypothesis to assign
1579 # @param geom a subhape of mesh geometry
1580 # @return SMESH.Hypothesis_Status
1581 # @ingroup l2_hypotheses
1582 def AddHypothesis(self, hyp, geom=0):
1583 if isinstance( hyp, Mesh_Algorithm ):
1584 hyp = hyp.GetAlgorithm()
1589 geom = self.mesh.GetShapeToMesh()
1591 status = self.mesh.AddHypothesis(geom, hyp)
1592 isAlgo = hyp._narrow( SMESH_Algo )
1593 hyp_name = GetName( hyp )
1596 geom_name = GetName( geom )
1597 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1600 ## Unassigns a hypothesis
1601 # @param hyp a hypothesis to unassign
1602 # @param geom a subshape of mesh geometry
1603 # @return SMESH.Hypothesis_Status
1604 # @ingroup l2_hypotheses
1605 def RemoveHypothesis(self, hyp, geom=0):
1606 if isinstance( hyp, Mesh_Algorithm ):
1607 hyp = hyp.GetAlgorithm()
1612 status = self.mesh.RemoveHypothesis(geom, hyp)
1615 ## Gets the list of hypotheses added on a geometry
1616 # @param geom a subshape of mesh geometry
1617 # @return the sequence of SMESH_Hypothesis
1618 # @ingroup l2_hypotheses
1619 def GetHypothesisList(self, geom):
1620 return self.mesh.GetHypothesisList( geom )
1622 ## Removes all global hypotheses
1623 # @ingroup l2_hypotheses
1624 def RemoveGlobalHypotheses(self):
1625 current_hyps = self.mesh.GetHypothesisList( self.geom )
1626 for hyp in current_hyps:
1627 self.mesh.RemoveHypothesis( self.geom, hyp )
1631 ## Creates a mesh group based on the geometric object \a grp
1632 # and gives a \a name, \n if this parameter is not defined
1633 # the name is the same as the geometric group name \n
1634 # Note: Works like GroupOnGeom().
1635 # @param grp a geometric group, a vertex, an edge, a face or a solid
1636 # @param name the name of the mesh group
1637 # @return SMESH_GroupOnGeom
1638 # @ingroup l2_grps_create
1639 def Group(self, grp, name=""):
1640 return self.GroupOnGeom(grp, name)
1642 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1643 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1644 ## allowing to overwrite the file if it exists or add the exported data to its contents
1645 # @param f the file name
1646 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1647 # @param opt boolean parameter for creating/not creating
1648 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1649 # @param overwrite boolean parameter for overwriting/not overwriting the file
1650 # @ingroup l2_impexp
1651 def ExportToMED(self, f, version, opt=0, overwrite=1):
1652 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1654 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1655 ## allowing to overwrite the file if it exists or add the exported data to its contents
1656 # @param f is the file name
1657 # @param auto_groups boolean parameter for creating/not creating
1658 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1659 # the typical use is auto_groups=false.
1660 # @param version MED format version(MED_V2_1 or MED_V2_2)
1661 # @param overwrite boolean parameter for overwriting/not overwriting the file
1662 # @ingroup l2_impexp
1663 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1664 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1666 ## Exports the mesh in a file in DAT format
1667 # @param f the file name
1668 # @ingroup l2_impexp
1669 def ExportDAT(self, f):
1670 self.mesh.ExportDAT(f)
1672 ## Exports the mesh in a file in UNV format
1673 # @param f the file name
1674 # @ingroup l2_impexp
1675 def ExportUNV(self, f):
1676 self.mesh.ExportUNV(f)
1678 ## Export the mesh in a file in STL format
1679 # @param f the file name
1680 # @param ascii defines the file encoding
1681 # @ingroup l2_impexp
1682 def ExportSTL(self, f, ascii=1):
1683 self.mesh.ExportSTL(f, ascii)
1686 # Operations with groups:
1687 # ----------------------
1689 ## Creates an empty mesh group
1690 # @param elementType the type of elements in the group
1691 # @param name the name of the mesh group
1692 # @return SMESH_Group
1693 # @ingroup l2_grps_create
1694 def CreateEmptyGroup(self, elementType, name):
1695 return self.mesh.CreateGroup(elementType, name)
1697 ## Creates a mesh group based on the geometrical object \a grp
1698 # and gives a \a name, \n if this parameter is not defined
1699 # the name is the same as the geometrical group name
1700 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1701 # @param name the name of the mesh group
1702 # @param typ the type of elements in the group. If not set, it is
1703 # automatically detected by the type of the geometry
1704 # @return SMESH_GroupOnGeom
1705 # @ingroup l2_grps_create
1706 def GroupOnGeom(self, grp, name="", typ=None):
1708 name = grp.GetName()
1711 tgeo = str(grp.GetShapeType())
1712 if tgeo == "VERTEX":
1714 elif tgeo == "EDGE":
1716 elif tgeo == "FACE":
1718 elif tgeo == "SOLID":
1720 elif tgeo == "SHELL":
1722 elif tgeo == "COMPOUND":
1723 try: # it raises on a compound of compounds
1724 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1725 print "Mesh.Group: empty geometric group", GetName( grp )
1730 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1732 tgeo = self.geompyD.GetType(grp)
1733 if tgeo == geompyDC.ShapeType["VERTEX"]:
1735 elif tgeo == geompyDC.ShapeType["EDGE"]:
1737 elif tgeo == geompyDC.ShapeType["FACE"]:
1739 elif tgeo == geompyDC.ShapeType["SOLID"]:
1745 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1746 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1747 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1755 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1758 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1760 ## Creates a mesh group by the given ids of elements
1761 # @param groupName the name of the mesh group
1762 # @param elementType the type of elements in the group
1763 # @param elemIDs the list of ids
1764 # @return SMESH_Group
1765 # @ingroup l2_grps_create
1766 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1767 group = self.mesh.CreateGroup(elementType, groupName)
1771 ## Creates a mesh group by the given conditions
1772 # @param groupName the name of the mesh group
1773 # @param elementType the type of elements in the group
1774 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1775 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1776 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1777 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1778 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1779 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1780 # @return SMESH_Group
1781 # @ingroup l2_grps_create
1785 CritType=FT_Undefined,
1788 UnaryOp=FT_Undefined,
1790 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1791 group = self.MakeGroupByCriterion(groupName, aCriterion)
1794 ## Creates a mesh group by the given criterion
1795 # @param groupName the name of the mesh group
1796 # @param Criterion the instance of Criterion class
1797 # @return SMESH_Group
1798 # @ingroup l2_grps_create
1799 def MakeGroupByCriterion(self, groupName, Criterion):
1800 aFilterMgr = self.smeshpyD.CreateFilterManager()
1801 aFilter = aFilterMgr.CreateFilter()
1803 aCriteria.append(Criterion)
1804 aFilter.SetCriteria(aCriteria)
1805 group = self.MakeGroupByFilter(groupName, aFilter)
1806 aFilterMgr.Destroy()
1809 ## Creates a mesh group by the given criteria (list of criteria)
1810 # @param groupName the name of the mesh group
1811 # @param theCriteria the list of criteria
1812 # @return SMESH_Group
1813 # @ingroup l2_grps_create
1814 def MakeGroupByCriteria(self, groupName, theCriteria):
1815 aFilterMgr = self.smeshpyD.CreateFilterManager()
1816 aFilter = aFilterMgr.CreateFilter()
1817 aFilter.SetCriteria(theCriteria)
1818 group = self.MakeGroupByFilter(groupName, aFilter)
1819 aFilterMgr.Destroy()
1822 ## Creates a mesh group by the given filter
1823 # @param groupName the name of the mesh group
1824 # @param theFilter the instance of Filter class
1825 # @return SMESH_Group
1826 # @ingroup l2_grps_create
1827 def MakeGroupByFilter(self, groupName, theFilter):
1828 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1829 theFilter.SetMesh( self.mesh )
1830 group.AddFrom( theFilter )
1833 ## Passes mesh elements through the given filter and return IDs of fitting elements
1834 # @param theFilter SMESH_Filter
1835 # @return a list of ids
1836 # @ingroup l1_controls
1837 def GetIdsFromFilter(self, theFilter):
1838 theFilter.SetMesh( self.mesh )
1839 return theFilter.GetIDs()
1841 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1842 # Returns a list of special structures (borders).
1843 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1844 # @ingroup l1_controls
1845 def GetFreeBorders(self):
1846 aFilterMgr = self.smeshpyD.CreateFilterManager()
1847 aPredicate = aFilterMgr.CreateFreeEdges()
1848 aPredicate.SetMesh(self.mesh)
1849 aBorders = aPredicate.GetBorders()
1850 aFilterMgr.Destroy()
1854 # @ingroup l2_grps_delete
1855 def RemoveGroup(self, group):
1856 self.mesh.RemoveGroup(group)
1858 ## Removes a group with its contents
1859 # @ingroup l2_grps_delete
1860 def RemoveGroupWithContents(self, group):
1861 self.mesh.RemoveGroupWithContents(group)
1863 ## Gets the list of groups existing in the mesh
1864 # @return a sequence of SMESH_GroupBase
1865 # @ingroup l2_grps_create
1866 def GetGroups(self):
1867 return self.mesh.GetGroups()
1869 ## Gets the number of groups existing in the mesh
1870 # @return the quantity of groups as an integer value
1871 # @ingroup l2_grps_create
1873 return self.mesh.NbGroups()
1875 ## Gets the list of names of groups existing in the mesh
1876 # @return list of strings
1877 # @ingroup l2_grps_create
1878 def GetGroupNames(self):
1879 groups = self.GetGroups()
1881 for group in groups:
1882 names.append(group.GetName())
1885 ## Produces a union of two groups
1886 # A new group is created. All mesh elements that are
1887 # present in the initial groups are added to the new one
1888 # @return an instance of SMESH_Group
1889 # @ingroup l2_grps_operon
1890 def UnionGroups(self, group1, group2, name):
1891 return self.mesh.UnionGroups(group1, group2, name)
1893 ## Produces a union list of groups
1894 # New group is created. All mesh elements that are present in
1895 # initial groups are added to the new one
1896 # @return an instance of SMESH_Group
1897 # @ingroup l2_grps_operon
1898 def UnionListOfGroups(self, groups, name):
1899 return self.mesh.UnionListOfGroups(groups, name)
1901 ## Prodices an intersection of two groups
1902 # A new group is created. All mesh elements that are common
1903 # for the two initial groups are added to the new one.
1904 # @return an instance of SMESH_Group
1905 # @ingroup l2_grps_operon
1906 def IntersectGroups(self, group1, group2, name):
1907 return self.mesh.IntersectGroups(group1, group2, name)
1909 ## Produces an intersection of groups
1910 # New group is created. All mesh elements that are present in all
1911 # initial groups simultaneously are added to the new one
1912 # @return an instance of SMESH_Group
1913 # @ingroup l2_grps_operon
1914 def IntersectListOfGroups(self, groups, name):
1915 return self.mesh.IntersectListOfGroups(groups, name)
1917 ## Produces a cut of two groups
1918 # A new group is created. All mesh elements that are present in
1919 # the main group but are not present in the tool group are added to the new one
1920 # @return an instance of SMESH_Group
1921 # @ingroup l2_grps_operon
1922 def CutGroups(self, main_group, tool_group, name):
1923 return self.mesh.CutGroups(main_group, tool_group, name)
1925 ## Produces a cut of groups
1926 # A new group is created. All mesh elements that are present in main groups
1927 # but do not present in tool groups are added to the new one
1928 # @return an instance of SMESH_Group
1929 # @ingroup l2_grps_operon
1930 def CutListOfGroups(self, main_groups, tool_groups, name):
1931 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1933 ## Produces a group of elements with specified element type using list of existing groups
1934 # A new group is created. System
1935 # 1) extract all nodes on which groups elements are built
1936 # 2) combine all elements of specified dimension laying on these nodes
1937 # @return an instance of SMESH_Group
1938 # @ingroup l2_grps_operon
1939 def CreateDimGroup(self, groups, elem_type, name):
1940 return self.mesh.CreateDimGroup(groups, elem_type, name)
1943 ## Convert group on geom into standalone group
1944 # @ingroup l2_grps_delete
1945 def ConvertToStandalone(self, group):
1946 return self.mesh.ConvertToStandalone(group)
1948 # Get some info about mesh:
1949 # ------------------------
1951 ## Returns the log of nodes and elements added or removed
1952 # since the previous clear of the log.
1953 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1954 # @return list of log_block structures:
1959 # @ingroup l1_auxiliary
1960 def GetLog(self, clearAfterGet):
1961 return self.mesh.GetLog(clearAfterGet)
1963 ## Clears the log of nodes and elements added or removed since the previous
1964 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1965 # @ingroup l1_auxiliary
1967 self.mesh.ClearLog()
1969 ## Toggles auto color mode on the object.
1970 # @param theAutoColor the flag which toggles auto color mode.
1971 # @ingroup l1_auxiliary
1972 def SetAutoColor(self, theAutoColor):
1973 self.mesh.SetAutoColor(theAutoColor)
1975 ## Gets flag of object auto color mode.
1976 # @return True or False
1977 # @ingroup l1_auxiliary
1978 def GetAutoColor(self):
1979 return self.mesh.GetAutoColor()
1981 ## Gets the internal ID
1982 # @return integer value, which is the internal Id of the mesh
1983 # @ingroup l1_auxiliary
1985 return self.mesh.GetId()
1988 # @return integer value, which is the study Id of the mesh
1989 # @ingroup l1_auxiliary
1990 def GetStudyId(self):
1991 return self.mesh.GetStudyId()
1993 ## Checks the group names for duplications.
1994 # Consider the maximum group name length stored in MED file.
1995 # @return True or False
1996 # @ingroup l1_auxiliary
1997 def HasDuplicatedGroupNamesMED(self):
1998 return self.mesh.HasDuplicatedGroupNamesMED()
2000 ## Obtains the mesh editor tool
2001 # @return an instance of SMESH_MeshEditor
2002 # @ingroup l1_modifying
2003 def GetMeshEditor(self):
2004 return self.mesh.GetMeshEditor()
2006 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
2007 # can be passed as argument to accepting mesh, group or sub-mesh
2008 # @return an instance of SMESH_IDSource
2009 # @ingroup l1_auxiliary
2010 def GetIDSource(self, ids, elemType):
2011 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2014 # @return an instance of SALOME_MED::MESH
2015 # @ingroup l1_auxiliary
2016 def GetMEDMesh(self):
2017 return self.mesh.GetMEDMesh()
2020 # Get informations about mesh contents:
2021 # ------------------------------------
2023 ## Gets the mesh stattistic
2024 # @return dictionary type element - count of elements
2025 # @ingroup l1_meshinfo
2026 def GetMeshInfo(self, obj = None):
2027 if not obj: obj = self.mesh
2028 return self.smeshpyD.GetMeshInfo(obj)
2030 ## Returns the number of nodes in the mesh
2031 # @return an integer value
2032 # @ingroup l1_meshinfo
2034 return self.mesh.NbNodes()
2036 ## Returns the number of elements in the mesh
2037 # @return an integer value
2038 # @ingroup l1_meshinfo
2039 def NbElements(self):
2040 return self.mesh.NbElements()
2042 ## Returns the number of 0d elements in the mesh
2043 # @return an integer value
2044 # @ingroup l1_meshinfo
2045 def Nb0DElements(self):
2046 return self.mesh.Nb0DElements()
2048 ## Returns the number of edges in the mesh
2049 # @return an integer value
2050 # @ingroup l1_meshinfo
2052 return self.mesh.NbEdges()
2054 ## Returns the number of edges with the given order in the mesh
2055 # @param elementOrder the order of elements:
2056 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2057 # @return an integer value
2058 # @ingroup l1_meshinfo
2059 def NbEdgesOfOrder(self, elementOrder):
2060 return self.mesh.NbEdgesOfOrder(elementOrder)
2062 ## Returns the number of faces in the mesh
2063 # @return an integer value
2064 # @ingroup l1_meshinfo
2066 return self.mesh.NbFaces()
2068 ## Returns the number of faces with the given order in the mesh
2069 # @param elementOrder the order of elements:
2070 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2071 # @return an integer value
2072 # @ingroup l1_meshinfo
2073 def NbFacesOfOrder(self, elementOrder):
2074 return self.mesh.NbFacesOfOrder(elementOrder)
2076 ## Returns the number of triangles in the mesh
2077 # @return an integer value
2078 # @ingroup l1_meshinfo
2079 def NbTriangles(self):
2080 return self.mesh.NbTriangles()
2082 ## Returns the number of triangles with the given order in the mesh
2083 # @param elementOrder is the order of elements:
2084 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2085 # @return an integer value
2086 # @ingroup l1_meshinfo
2087 def NbTrianglesOfOrder(self, elementOrder):
2088 return self.mesh.NbTrianglesOfOrder(elementOrder)
2090 ## Returns the number of quadrangles in the mesh
2091 # @return an integer value
2092 # @ingroup l1_meshinfo
2093 def NbQuadrangles(self):
2094 return self.mesh.NbQuadrangles()
2096 ## Returns the number of quadrangles with the given order in the mesh
2097 # @param elementOrder the order of elements:
2098 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2099 # @return an integer value
2100 # @ingroup l1_meshinfo
2101 def NbQuadranglesOfOrder(self, elementOrder):
2102 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2104 ## Returns the number of polygons in the mesh
2105 # @return an integer value
2106 # @ingroup l1_meshinfo
2107 def NbPolygons(self):
2108 return self.mesh.NbPolygons()
2110 ## Returns the number of volumes in the mesh
2111 # @return an integer value
2112 # @ingroup l1_meshinfo
2113 def NbVolumes(self):
2114 return self.mesh.NbVolumes()
2116 ## Returns the number of volumes with the given order in the mesh
2117 # @param elementOrder the order of elements:
2118 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2119 # @return an integer value
2120 # @ingroup l1_meshinfo
2121 def NbVolumesOfOrder(self, elementOrder):
2122 return self.mesh.NbVolumesOfOrder(elementOrder)
2124 ## Returns the number of tetrahedrons in the mesh
2125 # @return an integer value
2126 # @ingroup l1_meshinfo
2128 return self.mesh.NbTetras()
2130 ## Returns the number of tetrahedrons with the given order in the mesh
2131 # @param elementOrder the order of elements:
2132 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2133 # @return an integer value
2134 # @ingroup l1_meshinfo
2135 def NbTetrasOfOrder(self, elementOrder):
2136 return self.mesh.NbTetrasOfOrder(elementOrder)
2138 ## Returns the number of hexahedrons in the mesh
2139 # @return an integer value
2140 # @ingroup l1_meshinfo
2142 return self.mesh.NbHexas()
2144 ## Returns the number of hexahedrons with the given order in the mesh
2145 # @param elementOrder the order of elements:
2146 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2147 # @return an integer value
2148 # @ingroup l1_meshinfo
2149 def NbHexasOfOrder(self, elementOrder):
2150 return self.mesh.NbHexasOfOrder(elementOrder)
2152 ## Returns the number of pyramids in the mesh
2153 # @return an integer value
2154 # @ingroup l1_meshinfo
2155 def NbPyramids(self):
2156 return self.mesh.NbPyramids()
2158 ## Returns the number of pyramids with the given order in the mesh
2159 # @param elementOrder the order of elements:
2160 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2161 # @return an integer value
2162 # @ingroup l1_meshinfo
2163 def NbPyramidsOfOrder(self, elementOrder):
2164 return self.mesh.NbPyramidsOfOrder(elementOrder)
2166 ## Returns the number of prisms in the mesh
2167 # @return an integer value
2168 # @ingroup l1_meshinfo
2170 return self.mesh.NbPrisms()
2172 ## Returns the number of prisms with the given order in the mesh
2173 # @param elementOrder the order of elements:
2174 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2175 # @return an integer value
2176 # @ingroup l1_meshinfo
2177 def NbPrismsOfOrder(self, elementOrder):
2178 return self.mesh.NbPrismsOfOrder(elementOrder)
2180 ## Returns the number of polyhedrons in the mesh
2181 # @return an integer value
2182 # @ingroup l1_meshinfo
2183 def NbPolyhedrons(self):
2184 return self.mesh.NbPolyhedrons()
2186 ## Returns the number of submeshes in the mesh
2187 # @return an integer value
2188 # @ingroup l1_meshinfo
2189 def NbSubMesh(self):
2190 return self.mesh.NbSubMesh()
2192 ## Returns the list of mesh elements IDs
2193 # @return the list of integer values
2194 # @ingroup l1_meshinfo
2195 def GetElementsId(self):
2196 return self.mesh.GetElementsId()
2198 ## Returns the list of IDs of mesh elements with the given type
2199 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2200 # @return list of integer values
2201 # @ingroup l1_meshinfo
2202 def GetElementsByType(self, elementType):
2203 return self.mesh.GetElementsByType(elementType)
2205 ## Returns the list of mesh nodes IDs
2206 # @return the list of integer values
2207 # @ingroup l1_meshinfo
2208 def GetNodesId(self):
2209 return self.mesh.GetNodesId()
2211 # Get the information about mesh elements:
2212 # ------------------------------------
2214 ## Returns the type of mesh element
2215 # @return the value from SMESH::ElementType enumeration
2216 # @ingroup l1_meshinfo
2217 def GetElementType(self, id, iselem):
2218 return self.mesh.GetElementType(id, iselem)
2220 ## Returns the geometric type of mesh element
2221 # @return the value from SMESH::EntityType enumeration
2222 # @ingroup l1_meshinfo
2223 def GetElementGeomType(self, id):
2224 return self.mesh.GetElementGeomType(id)
2226 ## Returns the list of submesh elements IDs
2227 # @param Shape a geom object(subshape) IOR
2228 # Shape must be the subshape of a ShapeToMesh()
2229 # @return the list of integer values
2230 # @ingroup l1_meshinfo
2231 def GetSubMeshElementsId(self, Shape):
2232 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2233 ShapeID = Shape.GetSubShapeIndices()[0]
2236 return self.mesh.GetSubMeshElementsId(ShapeID)
2238 ## Returns the list of submesh nodes IDs
2239 # @param Shape a geom object(subshape) IOR
2240 # Shape must be the subshape of a ShapeToMesh()
2241 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2242 # @return the list of integer values
2243 # @ingroup l1_meshinfo
2244 def GetSubMeshNodesId(self, Shape, all):
2245 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2246 ShapeID = Shape.GetSubShapeIndices()[0]
2249 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2251 ## Returns type of elements on given shape
2252 # @param Shape a geom object(subshape) IOR
2253 # Shape must be a subshape of a ShapeToMesh()
2254 # @return element type
2255 # @ingroup l1_meshinfo
2256 def GetSubMeshElementType(self, Shape):
2257 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2258 ShapeID = Shape.GetSubShapeIndices()[0]
2261 return self.mesh.GetSubMeshElementType(ShapeID)
2263 ## Gets the mesh description
2264 # @return string value
2265 # @ingroup l1_meshinfo
2267 return self.mesh.Dump()
2270 # Get the information about nodes and elements of a mesh by its IDs:
2271 # -----------------------------------------------------------
2273 ## Gets XYZ coordinates of a node
2274 # \n If there is no nodes for the given ID - returns an empty list
2275 # @return a list of double precision values
2276 # @ingroup l1_meshinfo
2277 def GetNodeXYZ(self, id):
2278 return self.mesh.GetNodeXYZ(id)
2280 ## Returns list of IDs of inverse elements for the given node
2281 # \n If there is no node for the given ID - returns an empty list
2282 # @return a list of integer values
2283 # @ingroup l1_meshinfo
2284 def GetNodeInverseElements(self, id):
2285 return self.mesh.GetNodeInverseElements(id)
2287 ## @brief Returns the position of a node on the shape
2288 # @return SMESH::NodePosition
2289 # @ingroup l1_meshinfo
2290 def GetNodePosition(self,NodeID):
2291 return self.mesh.GetNodePosition(NodeID)
2293 ## If the given element is a node, returns the ID of shape
2294 # \n If there is no node for the given ID - returns -1
2295 # @return an integer value
2296 # @ingroup l1_meshinfo
2297 def GetShapeID(self, id):
2298 return self.mesh.GetShapeID(id)
2300 ## Returns the ID of the result shape after
2301 # FindShape() from SMESH_MeshEditor for the given element
2302 # \n If there is no element for the given ID - returns -1
2303 # @return an integer value
2304 # @ingroup l1_meshinfo
2305 def GetShapeIDForElem(self,id):
2306 return self.mesh.GetShapeIDForElem(id)
2308 ## Returns the number of nodes for the given element
2309 # \n If there is no element for the given ID - returns -1
2310 # @return an integer value
2311 # @ingroup l1_meshinfo
2312 def GetElemNbNodes(self, id):
2313 return self.mesh.GetElemNbNodes(id)
2315 ## Returns the node ID the given index for the given element
2316 # \n If there is no element for the given ID - returns -1
2317 # \n If there is no node for the given index - returns -2
2318 # @return an integer value
2319 # @ingroup l1_meshinfo
2320 def GetElemNode(self, id, index):
2321 return self.mesh.GetElemNode(id, index)
2323 ## Returns the IDs of nodes of the given element
2324 # @return a list of integer values
2325 # @ingroup l1_meshinfo
2326 def GetElemNodes(self, id):
2327 return self.mesh.GetElemNodes(id)
2329 ## Returns true if the given node is the medium node in the given quadratic element
2330 # @ingroup l1_meshinfo
2331 def IsMediumNode(self, elementID, nodeID):
2332 return self.mesh.IsMediumNode(elementID, nodeID)
2334 ## Returns true if the given node is the medium node in one of quadratic elements
2335 # @ingroup l1_meshinfo
2336 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2337 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2339 ## Returns the number of edges for the given element
2340 # @ingroup l1_meshinfo
2341 def ElemNbEdges(self, id):
2342 return self.mesh.ElemNbEdges(id)
2344 ## Returns the number of faces for the given element
2345 # @ingroup l1_meshinfo
2346 def ElemNbFaces(self, id):
2347 return self.mesh.ElemNbFaces(id)
2349 ## Returns nodes of given face (counted from zero) for given volumic element.
2350 # @ingroup l1_meshinfo
2351 def GetElemFaceNodes(self,elemId, faceIndex):
2352 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2354 ## Returns an element based on all given nodes.
2355 # @ingroup l1_meshinfo
2356 def FindElementByNodes(self,nodes):
2357 return self.mesh.FindElementByNodes(nodes)
2359 ## Returns true if the given element is a polygon
2360 # @ingroup l1_meshinfo
2361 def IsPoly(self, id):
2362 return self.mesh.IsPoly(id)
2364 ## Returns true if the given element is quadratic
2365 # @ingroup l1_meshinfo
2366 def IsQuadratic(self, id):
2367 return self.mesh.IsQuadratic(id)
2369 ## Returns XYZ coordinates of the barycenter of the given element
2370 # \n If there is no element for the given ID - returns an empty list
2371 # @return a list of three double values
2372 # @ingroup l1_meshinfo
2373 def BaryCenter(self, id):
2374 return self.mesh.BaryCenter(id)
2377 # Get mesh measurements information:
2378 # ------------------------------------
2380 ## Get minimum distance between two nodes, elements or distance to the origin
2381 # @param id1 first node/element id
2382 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2383 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2384 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2385 # @return minimum distance value
2386 # @sa GetMinDistance()
2387 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2388 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2389 return aMeasure.value
2391 ## Get measure structure specifying minimum distance data between two objects
2392 # @param id1 first node/element id
2393 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2394 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2395 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2396 # @return Measure structure
2398 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2400 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2402 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2405 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2407 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2412 aMeasurements = self.smeshpyD.CreateMeasurements()
2413 aMeasure = aMeasurements.MinDistance(id1, id2)
2414 aMeasurements.Destroy()
2417 ## Get bounding box of the specified object(s)
2418 # @param objects single source object or list of source objects or list of nodes/elements IDs
2419 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2420 # @c False specifies that @a objects are nodes
2421 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2422 # @sa GetBoundingBox()
2423 def BoundingBox(self, objects=None, isElem=False):
2424 result = self.GetBoundingBox(objects, isElem)
2428 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2431 ## Get measure structure specifying bounding box data of the specified object(s)
2432 # @param objects single source object or list of source objects or list of nodes/elements IDs
2433 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2434 # @c False specifies that @a objects are nodes
2435 # @return Measure structure
2437 def GetBoundingBox(self, IDs=None, isElem=False):
2440 elif isinstance(IDs, tuple):
2442 if not isinstance(IDs, list):
2444 if len(IDs) > 0 and isinstance(IDs[0], int):
2448 if isinstance(o, Mesh):
2449 srclist.append(o.mesh)
2450 elif hasattr(o, "_narrow"):
2451 src = o._narrow(SMESH.SMESH_IDSource)
2452 if src: srclist.append(src)
2454 elif isinstance(o, list):
2456 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2458 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2461 aMeasurements = self.smeshpyD.CreateMeasurements()
2462 aMeasure = aMeasurements.BoundingBox(srclist)
2463 aMeasurements.Destroy()
2466 # Mesh edition (SMESH_MeshEditor functionality):
2467 # ---------------------------------------------
2469 ## Removes the elements from the mesh by ids
2470 # @param IDsOfElements is a list of ids of elements to remove
2471 # @return True or False
2472 # @ingroup l2_modif_del
2473 def RemoveElements(self, IDsOfElements):
2474 return self.editor.RemoveElements(IDsOfElements)
2476 ## Removes nodes from mesh by ids
2477 # @param IDsOfNodes is a list of ids of nodes to remove
2478 # @return True or False
2479 # @ingroup l2_modif_del
2480 def RemoveNodes(self, IDsOfNodes):
2481 return self.editor.RemoveNodes(IDsOfNodes)
2483 ## Removes all orphan (free) nodes from mesh
2484 # @return number of the removed nodes
2485 # @ingroup l2_modif_del
2486 def RemoveOrphanNodes(self):
2487 return self.editor.RemoveOrphanNodes()
2489 ## Add a node to the mesh by coordinates
2490 # @return Id of the new node
2491 # @ingroup l2_modif_add
2492 def AddNode(self, x, y, z):
2493 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2494 self.mesh.SetParameters(Parameters)
2495 return self.editor.AddNode( x, y, z)
2497 ## Creates a 0D element on a node with given number.
2498 # @param IDOfNode the ID of node for creation of the element.
2499 # @return the Id of the new 0D element
2500 # @ingroup l2_modif_add
2501 def Add0DElement(self, IDOfNode):
2502 return self.editor.Add0DElement(IDOfNode)
2504 ## Creates a linear or quadratic edge (this is determined
2505 # by the number of given nodes).
2506 # @param IDsOfNodes the list of node IDs for creation of the element.
2507 # The order of nodes in this list should correspond to the description
2508 # of MED. \n This description is located by the following link:
2509 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2510 # @return the Id of the new edge
2511 # @ingroup l2_modif_add
2512 def AddEdge(self, IDsOfNodes):
2513 return self.editor.AddEdge(IDsOfNodes)
2515 ## Creates a linear or quadratic face (this is determined
2516 # by the number of given nodes).
2517 # @param IDsOfNodes the list of node IDs for creation of the element.
2518 # The order of nodes in this list should correspond to the description
2519 # of MED. \n This description is located by the following link:
2520 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2521 # @return the Id of the new face
2522 # @ingroup l2_modif_add
2523 def AddFace(self, IDsOfNodes):
2524 return self.editor.AddFace(IDsOfNodes)
2526 ## Adds a polygonal face to the mesh by the list of node IDs
2527 # @param IdsOfNodes the list of node IDs for creation of the element.
2528 # @return the Id of the new face
2529 # @ingroup l2_modif_add
2530 def AddPolygonalFace(self, IdsOfNodes):
2531 return self.editor.AddPolygonalFace(IdsOfNodes)
2533 ## Creates both simple and quadratic volume (this is determined
2534 # by the number of given nodes).
2535 # @param IDsOfNodes the list of node IDs for creation of the element.
2536 # The order of nodes in this list should correspond to the description
2537 # of MED. \n This description is located by the following link:
2538 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2539 # @return the Id of the new volumic element
2540 # @ingroup l2_modif_add
2541 def AddVolume(self, IDsOfNodes):
2542 return self.editor.AddVolume(IDsOfNodes)
2544 ## Creates a volume of many faces, giving nodes for each face.
2545 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2546 # @param Quantities the list of integer values, Quantities[i]
2547 # gives the quantity of nodes in face number i.
2548 # @return the Id of the new volumic element
2549 # @ingroup l2_modif_add
2550 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2551 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2553 ## Creates a volume of many faces, giving the IDs of the existing faces.
2554 # @param IdsOfFaces the list of face IDs for volume creation.
2556 # Note: The created volume will refer only to the nodes
2557 # of the given faces, not to the faces themselves.
2558 # @return the Id of the new volumic element
2559 # @ingroup l2_modif_add
2560 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2561 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2564 ## @brief Binds a node to a vertex
2565 # @param NodeID a node ID
2566 # @param Vertex a vertex or vertex ID
2567 # @return True if succeed else raises an exception
2568 # @ingroup l2_modif_add
2569 def SetNodeOnVertex(self, NodeID, Vertex):
2570 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2571 VertexID = Vertex.GetSubShapeIndices()[0]
2575 self.editor.SetNodeOnVertex(NodeID, VertexID)
2576 except SALOME.SALOME_Exception, inst:
2577 raise ValueError, inst.details.text
2581 ## @brief Stores the node position on an edge
2582 # @param NodeID a node ID
2583 # @param Edge an edge or edge ID
2584 # @param paramOnEdge a parameter on the edge where the node is located
2585 # @return True if succeed else raises an exception
2586 # @ingroup l2_modif_add
2587 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2588 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2589 EdgeID = Edge.GetSubShapeIndices()[0]
2593 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2594 except SALOME.SALOME_Exception, inst:
2595 raise ValueError, inst.details.text
2598 ## @brief Stores node position on a face
2599 # @param NodeID a node ID
2600 # @param Face a face or face ID
2601 # @param u U parameter on the face where the node is located
2602 # @param v V parameter on the face where the node is located
2603 # @return True if succeed else raises an exception
2604 # @ingroup l2_modif_add
2605 def SetNodeOnFace(self, NodeID, Face, u, v):
2606 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2607 FaceID = Face.GetSubShapeIndices()[0]
2611 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2612 except SALOME.SALOME_Exception, inst:
2613 raise ValueError, inst.details.text
2616 ## @brief Binds a node to a solid
2617 # @param NodeID a node ID
2618 # @param Solid a solid or solid ID
2619 # @return True if succeed else raises an exception
2620 # @ingroup l2_modif_add
2621 def SetNodeInVolume(self, NodeID, Solid):
2622 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2623 SolidID = Solid.GetSubShapeIndices()[0]
2627 self.editor.SetNodeInVolume(NodeID, SolidID)
2628 except SALOME.SALOME_Exception, inst:
2629 raise ValueError, inst.details.text
2632 ## @brief Bind an element to a shape
2633 # @param ElementID an element ID
2634 # @param Shape a shape or shape ID
2635 # @return True if succeed else raises an exception
2636 # @ingroup l2_modif_add
2637 def SetMeshElementOnShape(self, ElementID, Shape):
2638 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2639 ShapeID = Shape.GetSubShapeIndices()[0]
2643 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2644 except SALOME.SALOME_Exception, inst:
2645 raise ValueError, inst.details.text
2649 ## Moves the node with the given id
2650 # @param NodeID the id of the node
2651 # @param x a new X coordinate
2652 # @param y a new Y coordinate
2653 # @param z a new Z coordinate
2654 # @return True if succeed else False
2655 # @ingroup l2_modif_movenode
2656 def MoveNode(self, NodeID, x, y, z):
2657 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2658 self.mesh.SetParameters(Parameters)
2659 return self.editor.MoveNode(NodeID, x, y, z)
2661 ## Finds the node closest to a point and moves it to a point location
2662 # @param x the X coordinate of a point
2663 # @param y the Y coordinate of a point
2664 # @param z the Z coordinate of a point
2665 # @param NodeID if specified (>0), the node with this ID is moved,
2666 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2667 # @return the ID of a node
2668 # @ingroup l2_modif_throughp
2669 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2670 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2671 self.mesh.SetParameters(Parameters)
2672 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2674 ## Finds the node closest to a point
2675 # @param x the X coordinate of a point
2676 # @param y the Y coordinate of a point
2677 # @param z the Z coordinate of a point
2678 # @return the ID of a node
2679 # @ingroup l2_modif_throughp
2680 def FindNodeClosestTo(self, x, y, z):
2681 #preview = self.mesh.GetMeshEditPreviewer()
2682 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2683 return self.editor.FindNodeClosestTo(x, y, z)
2685 ## Finds the elements where a point lays IN or ON
2686 # @param x the X coordinate of a point
2687 # @param y the Y coordinate of a point
2688 # @param z the Z coordinate of a point
2689 # @param elementType type of elements to find (SMESH.ALL type
2690 # means elements of any type excluding nodes and 0D elements)
2691 # @return list of IDs of found elements
2692 # @ingroup l2_modif_throughp
2693 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2694 return self.editor.FindElementsByPoint(x, y, z, elementType)
2696 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2697 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2699 def GetPointState(self, x, y, z):
2700 return self.editor.GetPointState(x, y, z)
2702 ## Finds the node closest to a point and moves it to a point location
2703 # @param x the X coordinate of a point
2704 # @param y the Y coordinate of a point
2705 # @param z the Z coordinate of a point
2706 # @return the ID of a moved node
2707 # @ingroup l2_modif_throughp
2708 def MeshToPassThroughAPoint(self, x, y, z):
2709 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2711 ## Replaces two neighbour triangles sharing Node1-Node2 link
2712 # with the triangles built on the same 4 nodes but having other common link.
2713 # @param NodeID1 the ID of the first node
2714 # @param NodeID2 the ID of the second node
2715 # @return false if proper faces were not found
2716 # @ingroup l2_modif_invdiag
2717 def InverseDiag(self, NodeID1, NodeID2):
2718 return self.editor.InverseDiag(NodeID1, NodeID2)
2720 ## Replaces two neighbour triangles sharing Node1-Node2 link
2721 # with a quadrangle built on the same 4 nodes.
2722 # @param NodeID1 the ID of the first node
2723 # @param NodeID2 the ID of the second node
2724 # @return false if proper faces were not found
2725 # @ingroup l2_modif_unitetri
2726 def DeleteDiag(self, NodeID1, NodeID2):
2727 return self.editor.DeleteDiag(NodeID1, NodeID2)
2729 ## Reorients elements by ids
2730 # @param IDsOfElements if undefined reorients all mesh elements
2731 # @return True if succeed else False
2732 # @ingroup l2_modif_changori
2733 def Reorient(self, IDsOfElements=None):
2734 if IDsOfElements == None:
2735 IDsOfElements = self.GetElementsId()
2736 return self.editor.Reorient(IDsOfElements)
2738 ## Reorients all elements of the object
2739 # @param theObject mesh, submesh or group
2740 # @return True if succeed else False
2741 # @ingroup l2_modif_changori
2742 def ReorientObject(self, theObject):
2743 if ( isinstance( theObject, Mesh )):
2744 theObject = theObject.GetMesh()
2745 return self.editor.ReorientObject(theObject)
2747 ## Fuses the neighbouring triangles into quadrangles.
2748 # @param IDsOfElements The triangles to be fused,
2749 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2750 # @param MaxAngle is the maximum angle between element normals at which the fusion
2751 # is still performed; theMaxAngle is mesured in radians.
2752 # Also it could be a name of variable which defines angle in degrees.
2753 # @return TRUE in case of success, FALSE otherwise.
2754 # @ingroup l2_modif_unitetri
2755 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2757 if isinstance(MaxAngle,str):
2759 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2761 MaxAngle = DegreesToRadians(MaxAngle)
2762 if IDsOfElements == []:
2763 IDsOfElements = self.GetElementsId()
2764 self.mesh.SetParameters(Parameters)
2766 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2767 Functor = theCriterion
2769 Functor = self.smeshpyD.GetFunctor(theCriterion)
2770 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2772 ## Fuses the neighbouring triangles of the object into quadrangles
2773 # @param theObject is mesh, submesh or group
2774 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2775 # @param MaxAngle a max angle between element normals at which the fusion
2776 # is still performed; theMaxAngle is mesured in radians.
2777 # @return TRUE in case of success, FALSE otherwise.
2778 # @ingroup l2_modif_unitetri
2779 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2780 if ( isinstance( theObject, Mesh )):
2781 theObject = theObject.GetMesh()
2782 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2784 ## Splits quadrangles into triangles.
2785 # @param IDsOfElements the faces to be splitted.
2786 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2787 # @return TRUE in case of success, FALSE otherwise.
2788 # @ingroup l2_modif_cutquadr
2789 def QuadToTri (self, IDsOfElements, theCriterion):
2790 if IDsOfElements == []:
2791 IDsOfElements = self.GetElementsId()
2792 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2794 ## Splits quadrangles into triangles.
2795 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2796 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2797 # @return TRUE in case of success, FALSE otherwise.
2798 # @ingroup l2_modif_cutquadr
2799 def QuadToTriObject (self, theObject, theCriterion):
2800 if ( isinstance( theObject, Mesh )):
2801 theObject = theObject.GetMesh()
2802 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2804 ## Splits quadrangles into triangles.
2805 # @param IDsOfElements the faces to be splitted
2806 # @param Diag13 is used to choose a diagonal for splitting.
2807 # @return TRUE in case of success, FALSE otherwise.
2808 # @ingroup l2_modif_cutquadr
2809 def SplitQuad (self, IDsOfElements, Diag13):
2810 if IDsOfElements == []:
2811 IDsOfElements = self.GetElementsId()
2812 return self.editor.SplitQuad(IDsOfElements, Diag13)
2814 ## Splits quadrangles into triangles.
2815 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2816 # @param Diag13 is used to choose a diagonal for splitting.
2817 # @return TRUE in case of success, FALSE otherwise.
2818 # @ingroup l2_modif_cutquadr
2819 def SplitQuadObject (self, theObject, Diag13):
2820 if ( isinstance( theObject, Mesh )):
2821 theObject = theObject.GetMesh()
2822 return self.editor.SplitQuadObject(theObject, Diag13)
2824 ## Finds a better splitting of the given quadrangle.
2825 # @param IDOfQuad the ID of the quadrangle to be splitted.
2826 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2827 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2828 # diagonal is better, 0 if error occurs.
2829 # @ingroup l2_modif_cutquadr
2830 def BestSplit (self, IDOfQuad, theCriterion):
2831 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2833 ## Splits volumic elements into tetrahedrons
2834 # @param elemIDs either list of elements or mesh or group or submesh
2835 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2836 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2837 # @ingroup l2_modif_cutquadr
2838 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2839 if isinstance( elemIDs, Mesh ):
2840 elemIDs = elemIDs.GetMesh()
2841 if ( isinstance( elemIDs, list )):
2842 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2843 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2845 ## Splits quadrangle faces near triangular facets of volumes
2847 # @ingroup l1_auxiliary
2848 def SplitQuadsNearTriangularFacets(self):
2849 faces_array = self.GetElementsByType(SMESH.FACE)
2850 for face_id in faces_array:
2851 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2852 quad_nodes = self.mesh.GetElemNodes(face_id)
2853 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2854 isVolumeFound = False
2855 for node1_elem in node1_elems:
2856 if not isVolumeFound:
2857 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2858 nb_nodes = self.GetElemNbNodes(node1_elem)
2859 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2860 volume_elem = node1_elem
2861 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2862 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2863 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2864 isVolumeFound = True
2865 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2866 self.SplitQuad([face_id], False) # diagonal 2-4
2867 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2868 isVolumeFound = True
2869 self.SplitQuad([face_id], True) # diagonal 1-3
2870 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2871 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2872 isVolumeFound = True
2873 self.SplitQuad([face_id], True) # diagonal 1-3
2875 ## @brief Splits hexahedrons into tetrahedrons.
2877 # This operation uses pattern mapping functionality for splitting.
2878 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2879 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2880 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2881 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2882 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2883 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2884 # @return TRUE in case of success, FALSE otherwise.
2885 # @ingroup l1_auxiliary
2886 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2887 # Pattern: 5.---------.6
2892 # (0,0,1) 4.---------.7 * |
2899 # (0,0,0) 0.---------.3
2900 pattern_tetra = "!!! Nb of points: \n 8 \n\
2910 !!! Indices of points of 6 tetras: \n\
2918 pattern = self.smeshpyD.GetPattern()
2919 isDone = pattern.LoadFromFile(pattern_tetra)
2921 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2924 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2925 isDone = pattern.MakeMesh(self.mesh, False, False)
2926 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2928 # split quafrangle faces near triangular facets of volumes
2929 self.SplitQuadsNearTriangularFacets()
2933 ## @brief Split hexahedrons into prisms.
2935 # Uses the pattern mapping functionality for splitting.
2936 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2937 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2938 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2939 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2940 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2941 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2942 # @return TRUE in case of success, FALSE otherwise.
2943 # @ingroup l1_auxiliary
2944 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2945 # Pattern: 5.---------.6
2950 # (0,0,1) 4.---------.7 |
2957 # (0,0,0) 0.---------.3
2958 pattern_prism = "!!! Nb of points: \n 8 \n\
2968 !!! Indices of points of 2 prisms: \n\
2972 pattern = self.smeshpyD.GetPattern()
2973 isDone = pattern.LoadFromFile(pattern_prism)
2975 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2978 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2979 isDone = pattern.MakeMesh(self.mesh, False, False)
2980 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2982 # Splits quafrangle faces near triangular facets of volumes
2983 self.SplitQuadsNearTriangularFacets()
2987 ## Smoothes elements
2988 # @param IDsOfElements the list if ids of elements to smooth
2989 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2990 # Note that nodes built on edges and boundary nodes are always fixed.
2991 # @param MaxNbOfIterations the maximum number of iterations
2992 # @param MaxAspectRatio varies in range [1.0, inf]
2993 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2994 # @return TRUE in case of success, FALSE otherwise.
2995 # @ingroup l2_modif_smooth
2996 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2997 MaxNbOfIterations, MaxAspectRatio, Method):
2998 if IDsOfElements == []:
2999 IDsOfElements = self.GetElementsId()
3000 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3001 self.mesh.SetParameters(Parameters)
3002 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
3003 MaxNbOfIterations, MaxAspectRatio, Method)
3005 ## Smoothes elements which belong to the given object
3006 # @param theObject the object to smooth
3007 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3008 # Note that nodes built on edges and boundary nodes are always fixed.
3009 # @param MaxNbOfIterations the maximum number of iterations
3010 # @param MaxAspectRatio varies in range [1.0, inf]
3011 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3012 # @return TRUE in case of success, FALSE otherwise.
3013 # @ingroup l2_modif_smooth
3014 def SmoothObject(self, theObject, IDsOfFixedNodes,
3015 MaxNbOfIterations, MaxAspectRatio, Method):
3016 if ( isinstance( theObject, Mesh )):
3017 theObject = theObject.GetMesh()
3018 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3019 MaxNbOfIterations, MaxAspectRatio, Method)
3021 ## Parametrically smoothes the given elements
3022 # @param IDsOfElements the list if ids of elements to smooth
3023 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3024 # Note that nodes built on edges and boundary nodes are always fixed.
3025 # @param MaxNbOfIterations the maximum number of iterations
3026 # @param MaxAspectRatio varies in range [1.0, inf]
3027 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3028 # @return TRUE in case of success, FALSE otherwise.
3029 # @ingroup l2_modif_smooth
3030 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3031 MaxNbOfIterations, MaxAspectRatio, Method):
3032 if IDsOfElements == []:
3033 IDsOfElements = self.GetElementsId()
3034 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3035 self.mesh.SetParameters(Parameters)
3036 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3037 MaxNbOfIterations, MaxAspectRatio, Method)
3039 ## Parametrically smoothes the elements which belong to the given object
3040 # @param theObject the object to smooth
3041 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3042 # Note that nodes built on edges and boundary nodes are always fixed.
3043 # @param MaxNbOfIterations the maximum number of iterations
3044 # @param MaxAspectRatio varies in range [1.0, inf]
3045 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3046 # @return TRUE in case of success, FALSE otherwise.
3047 # @ingroup l2_modif_smooth
3048 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3049 MaxNbOfIterations, MaxAspectRatio, Method):
3050 if ( isinstance( theObject, Mesh )):
3051 theObject = theObject.GetMesh()
3052 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3053 MaxNbOfIterations, MaxAspectRatio, Method)
3055 ## Converts the mesh to quadratic, deletes old elements, replacing
3056 # them with quadratic with the same id.
3057 # @param theForce3d new node creation method:
3058 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
3059 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3060 # @ingroup l2_modif_tofromqu
3061 def ConvertToQuadratic(self, theForce3d):
3062 self.editor.ConvertToQuadratic(theForce3d)
3064 ## Converts the mesh from quadratic to ordinary,
3065 # deletes old quadratic elements, \n replacing
3066 # them with ordinary mesh elements with the same id.
3067 # @return TRUE in case of success, FALSE otherwise.
3068 # @ingroup l2_modif_tofromqu
3069 def ConvertFromQuadratic(self):
3070 return self.editor.ConvertFromQuadratic()
3072 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3073 # @return TRUE if operation has been completed successfully, FALSE otherwise
3074 # @ingroup l2_modif_edit
3075 def Make2DMeshFrom3D(self):
3076 return self.editor. Make2DMeshFrom3D()
3078 ## Creates missing boundary elements
3079 # @param elements - elements whose boundary is to be checked:
3080 # mesh, group, sub-mesh or list of elements
3081 # @param dimension - defines type of boundary elements to create:
3082 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3083 # @param groupName - a name of group to store created boundary elements in,
3084 # "" means not to create the group
3085 # @param meshName - a name of new mesh to store created boundary elements in,
3086 # "" means not to create the new mesh
3087 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
3088 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3089 # boundary elements will be copied into the new mesh
3090 # @return tuple (mesh, group) where bondary elements were added to
3091 # @ingroup l2_modif_edit
3092 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3093 toCopyElements=False, toCopyExistingBondary=False):
3094 if isinstance( elements, Mesh ):
3095 elements = elements.GetMesh()
3096 if ( isinstance( elements, list )):
3097 elemType = SMESH.ALL
3098 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3099 elements = self.editor.MakeIDSource(elements, elemType)
3100 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3101 toCopyElements,toCopyExistingBondary)
3102 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3105 ## Renumber mesh nodes
3106 # @ingroup l2_modif_renumber
3107 def RenumberNodes(self):
3108 self.editor.RenumberNodes()
3110 ## Renumber mesh elements
3111 # @ingroup l2_modif_renumber
3112 def RenumberElements(self):
3113 self.editor.RenumberElements()
3115 ## Generates new elements by rotation of the elements around the axis
3116 # @param IDsOfElements the list of ids of elements to sweep
3117 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3118 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3119 # @param NbOfSteps the number of steps
3120 # @param Tolerance tolerance
3121 # @param MakeGroups forces the generation of new groups from existing ones
3122 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3123 # of all steps, else - size of each step
3124 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3125 # @ingroup l2_modif_extrurev
3126 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3127 MakeGroups=False, TotalAngle=False):
3129 if isinstance(AngleInRadians,str):
3131 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3133 AngleInRadians = DegreesToRadians(AngleInRadians)
3134 if IDsOfElements == []:
3135 IDsOfElements = self.GetElementsId()
3136 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3137 Axis = self.smeshpyD.GetAxisStruct(Axis)
3138 Axis,AxisParameters = ParseAxisStruct(Axis)
3139 if TotalAngle and NbOfSteps:
3140 AngleInRadians /= NbOfSteps
3141 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3142 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3143 self.mesh.SetParameters(Parameters)
3145 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3146 AngleInRadians, NbOfSteps, Tolerance)
3147 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3150 ## Generates new elements by rotation of the elements of object around the axis
3151 # @param theObject object which elements should be sweeped.
3152 # It can be a mesh, a sub mesh or a group.
3153 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3154 # @param AngleInRadians the angle of Rotation
3155 # @param NbOfSteps number of steps
3156 # @param Tolerance tolerance
3157 # @param MakeGroups forces the generation of new groups from existing ones
3158 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3159 # of all steps, else - size of each step
3160 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3161 # @ingroup l2_modif_extrurev
3162 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3163 MakeGroups=False, TotalAngle=False):
3165 if isinstance(AngleInRadians,str):
3167 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3169 AngleInRadians = DegreesToRadians(AngleInRadians)
3170 if ( isinstance( theObject, Mesh )):
3171 theObject = theObject.GetMesh()
3172 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3173 Axis = self.smeshpyD.GetAxisStruct(Axis)
3174 Axis,AxisParameters = ParseAxisStruct(Axis)
3175 if TotalAngle and NbOfSteps:
3176 AngleInRadians /= NbOfSteps
3177 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3178 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3179 self.mesh.SetParameters(Parameters)
3181 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3182 NbOfSteps, Tolerance)
3183 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3186 ## Generates new elements by rotation of the elements of object around the axis
3187 # @param theObject object which elements should be sweeped.
3188 # It can be a mesh, a sub mesh or a group.
3189 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3190 # @param AngleInRadians the angle of Rotation
3191 # @param NbOfSteps number of steps
3192 # @param Tolerance tolerance
3193 # @param MakeGroups forces the generation of new groups from existing ones
3194 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3195 # of all steps, else - size of each step
3196 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3197 # @ingroup l2_modif_extrurev
3198 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3199 MakeGroups=False, TotalAngle=False):
3201 if isinstance(AngleInRadians,str):
3203 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3205 AngleInRadians = DegreesToRadians(AngleInRadians)
3206 if ( isinstance( theObject, Mesh )):
3207 theObject = theObject.GetMesh()
3208 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3209 Axis = self.smeshpyD.GetAxisStruct(Axis)
3210 Axis,AxisParameters = ParseAxisStruct(Axis)
3211 if TotalAngle and NbOfSteps:
3212 AngleInRadians /= NbOfSteps
3213 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3214 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3215 self.mesh.SetParameters(Parameters)
3217 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3218 NbOfSteps, Tolerance)
3219 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3222 ## Generates new elements by rotation of the elements of object around the axis
3223 # @param theObject object which elements should be sweeped.
3224 # It can be a mesh, a sub mesh or a group.
3225 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3226 # @param AngleInRadians the angle of Rotation
3227 # @param NbOfSteps number of steps
3228 # @param Tolerance tolerance
3229 # @param MakeGroups forces the generation of new groups from existing ones
3230 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3231 # of all steps, else - size of each step
3232 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3233 # @ingroup l2_modif_extrurev
3234 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3235 MakeGroups=False, TotalAngle=False):
3237 if isinstance(AngleInRadians,str):
3239 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3241 AngleInRadians = DegreesToRadians(AngleInRadians)
3242 if ( isinstance( theObject, Mesh )):
3243 theObject = theObject.GetMesh()
3244 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3245 Axis = self.smeshpyD.GetAxisStruct(Axis)
3246 Axis,AxisParameters = ParseAxisStruct(Axis)
3247 if TotalAngle and NbOfSteps:
3248 AngleInRadians /= NbOfSteps
3249 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3250 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3251 self.mesh.SetParameters(Parameters)
3253 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3254 NbOfSteps, Tolerance)
3255 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3258 ## Generates new elements by extrusion of the elements with given ids
3259 # @param IDsOfElements the list of elements ids for extrusion
3260 # @param StepVector vector or DirStruct, defining the direction and value of extrusion
3261 # @param NbOfSteps the number of steps
3262 # @param MakeGroups forces the generation of new groups from existing ones
3263 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3264 # @ingroup l2_modif_extrurev
3265 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3266 if IDsOfElements == []:
3267 IDsOfElements = self.GetElementsId()
3268 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3269 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3270 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3271 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3272 Parameters = StepVectorParameters + var_separator + Parameters
3273 self.mesh.SetParameters(Parameters)
3275 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3276 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3279 ## Generates new elements by extrusion of the elements with given ids
3280 # @param IDsOfElements is ids of elements
3281 # @param StepVector vector, defining the direction and value of extrusion
3282 # @param NbOfSteps the number of steps
3283 # @param ExtrFlags sets flags for extrusion
3284 # @param SewTolerance uses for comparing locations of nodes if flag
3285 # EXTRUSION_FLAG_SEW is set
3286 # @param MakeGroups forces the generation of new groups from existing ones
3287 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3288 # @ingroup l2_modif_extrurev
3289 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3290 ExtrFlags, SewTolerance, MakeGroups=False):
3291 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3292 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3294 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3295 ExtrFlags, SewTolerance)
3296 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3297 ExtrFlags, SewTolerance)
3300 ## Generates new elements by extrusion of the elements which belong to the object
3301 # @param theObject the object which elements should be processed.
3302 # It can be a mesh, a sub mesh or a group.
3303 # @param StepVector vector, defining the direction and value of extrusion
3304 # @param NbOfSteps the number of steps
3305 # @param MakeGroups forces the generation of new groups from existing ones
3306 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3307 # @ingroup l2_modif_extrurev
3308 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3309 if ( isinstance( theObject, Mesh )):
3310 theObject = theObject.GetMesh()
3311 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3312 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3313 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3314 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3315 Parameters = StepVectorParameters + var_separator + Parameters
3316 self.mesh.SetParameters(Parameters)
3318 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3319 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3322 ## Generates new elements by extrusion of the elements which belong to the object
3323 # @param theObject object which elements should be processed.
3324 # It can be a mesh, a sub mesh or a group.
3325 # @param StepVector vector, defining the direction and value of extrusion
3326 # @param NbOfSteps the number of steps
3327 # @param MakeGroups to generate new groups from existing ones
3328 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3329 # @ingroup l2_modif_extrurev
3330 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3331 if ( isinstance( theObject, Mesh )):
3332 theObject = theObject.GetMesh()
3333 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3334 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3335 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3336 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3337 Parameters = StepVectorParameters + var_separator + Parameters
3338 self.mesh.SetParameters(Parameters)
3340 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3341 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3344 ## Generates new elements by extrusion of the elements which belong to the object
3345 # @param theObject object which elements should be processed.
3346 # It can be a mesh, a sub mesh or a group.
3347 # @param StepVector vector, defining the direction and value of extrusion
3348 # @param NbOfSteps the number of steps
3349 # @param MakeGroups forces the generation of new groups from existing ones
3350 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3351 # @ingroup l2_modif_extrurev
3352 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3353 if ( isinstance( theObject, Mesh )):
3354 theObject = theObject.GetMesh()
3355 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3356 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3357 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3358 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3359 Parameters = StepVectorParameters + var_separator + Parameters
3360 self.mesh.SetParameters(Parameters)
3362 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3363 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3368 ## Generates new elements by extrusion of the given elements
3369 # The path of extrusion must be a meshed edge.
3370 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3371 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3372 # @param NodeStart the start node from Path. Defines the direction of extrusion
3373 # @param HasAngles allows the shape to be rotated around the path
3374 # to get the resulting mesh in a helical fashion
3375 # @param Angles list of angles in radians
3376 # @param LinearVariation forces the computation of rotation angles as linear
3377 # variation of the given Angles along path steps
3378 # @param HasRefPoint allows using the reference point
3379 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3380 # The User can specify any point as the Reference Point.
3381 # @param MakeGroups forces the generation of new groups from existing ones
3382 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3383 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3384 # only SMESH::Extrusion_Error otherwise
3385 # @ingroup l2_modif_extrurev
3386 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3387 HasAngles, Angles, LinearVariation,
3388 HasRefPoint, RefPoint, MakeGroups, ElemType):
3389 Angles,AnglesParameters = ParseAngles(Angles)
3390 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3391 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3392 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3394 Parameters = AnglesParameters + var_separator + RefPointParameters
3395 self.mesh.SetParameters(Parameters)
3397 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3399 if isinstance(Base, list):
3401 if Base == []: IDsOfElements = self.GetElementsId()
3402 else: IDsOfElements = Base
3403 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3404 HasAngles, Angles, LinearVariation,
3405 HasRefPoint, RefPoint, MakeGroups, ElemType)
3407 if isinstance(Base, Mesh): Base = Base.GetMesh()
3408 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3409 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3410 HasAngles, Angles, LinearVariation,
3411 HasRefPoint, RefPoint, MakeGroups, ElemType)
3413 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3416 ## Generates new elements by extrusion of the given elements
3417 # The path of extrusion must be a meshed edge.
3418 # @param IDsOfElements ids of elements
3419 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3420 # @param PathShape shape(edge) defines the sub-mesh for the path
3421 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3422 # @param HasAngles allows the shape to be rotated around the path
3423 # to get the resulting mesh in a helical fashion
3424 # @param Angles list of angles in radians
3425 # @param HasRefPoint allows using the reference point
3426 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3427 # The User can specify any point as the Reference Point.
3428 # @param MakeGroups forces the generation of new groups from existing ones
3429 # @param LinearVariation forces the computation of rotation angles as linear
3430 # variation of the given Angles along path steps
3431 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3432 # only SMESH::Extrusion_Error otherwise
3433 # @ingroup l2_modif_extrurev
3434 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3435 HasAngles, Angles, HasRefPoint, RefPoint,
3436 MakeGroups=False, LinearVariation=False):
3437 Angles,AnglesParameters = ParseAngles(Angles)
3438 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3439 if IDsOfElements == []:
3440 IDsOfElements = self.GetElementsId()
3441 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3442 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3444 if ( isinstance( PathMesh, Mesh )):
3445 PathMesh = PathMesh.GetMesh()
3446 if HasAngles and Angles and LinearVariation:
3447 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3449 Parameters = AnglesParameters + var_separator + RefPointParameters
3450 self.mesh.SetParameters(Parameters)
3452 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3453 PathShape, NodeStart, HasAngles,
3454 Angles, HasRefPoint, RefPoint)
3455 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3456 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3458 ## Generates new elements by extrusion of the elements which belong to the object
3459 # The path of extrusion must be a meshed edge.
3460 # @param theObject the object which elements should be processed.
3461 # It can be a mesh, a sub mesh or a group.
3462 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3463 # @param PathShape shape(edge) defines the sub-mesh for the path
3464 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3465 # @param HasAngles allows the shape to be rotated around the path
3466 # to get the resulting mesh in a helical fashion
3467 # @param Angles list of angles
3468 # @param HasRefPoint allows using the reference point
3469 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3470 # The User can specify any point as the Reference Point.
3471 # @param MakeGroups forces the generation of new groups from existing ones
3472 # @param LinearVariation forces the computation of rotation angles as linear
3473 # variation of the given Angles along path steps
3474 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3475 # only SMESH::Extrusion_Error otherwise
3476 # @ingroup l2_modif_extrurev
3477 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3478 HasAngles, Angles, HasRefPoint, RefPoint,
3479 MakeGroups=False, LinearVariation=False):
3480 Angles,AnglesParameters = ParseAngles(Angles)
3481 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3482 if ( isinstance( theObject, Mesh )):
3483 theObject = theObject.GetMesh()
3484 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3485 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3486 if ( isinstance( PathMesh, Mesh )):
3487 PathMesh = PathMesh.GetMesh()
3488 if HasAngles and Angles and LinearVariation:
3489 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3491 Parameters = AnglesParameters + var_separator + RefPointParameters
3492 self.mesh.SetParameters(Parameters)
3494 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3495 PathShape, NodeStart, HasAngles,
3496 Angles, HasRefPoint, RefPoint)
3497 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3498 NodeStart, HasAngles, Angles, HasRefPoint,
3501 ## Generates new elements by extrusion of the elements which belong to the object
3502 # The path of extrusion must be a meshed edge.
3503 # @param theObject the object which elements should be processed.
3504 # It can be a mesh, a sub mesh or a group.
3505 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3506 # @param PathShape shape(edge) defines the sub-mesh for the path
3507 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3508 # @param HasAngles allows the shape to be rotated around the path
3509 # to get the resulting mesh in a helical fashion
3510 # @param Angles list of angles
3511 # @param HasRefPoint allows using the reference point
3512 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3513 # The User can specify any point as the Reference Point.
3514 # @param MakeGroups forces the generation of new groups from existing ones
3515 # @param LinearVariation forces the computation of rotation angles as linear
3516 # variation of the given Angles along path steps
3517 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3518 # only SMESH::Extrusion_Error otherwise
3519 # @ingroup l2_modif_extrurev
3520 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3521 HasAngles, Angles, HasRefPoint, RefPoint,
3522 MakeGroups=False, LinearVariation=False):
3523 Angles,AnglesParameters = ParseAngles(Angles)
3524 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3525 if ( isinstance( theObject, Mesh )):
3526 theObject = theObject.GetMesh()
3527 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3528 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3529 if ( isinstance( PathMesh, Mesh )):
3530 PathMesh = PathMesh.GetMesh()
3531 if HasAngles and Angles and LinearVariation:
3532 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3534 Parameters = AnglesParameters + var_separator + RefPointParameters
3535 self.mesh.SetParameters(Parameters)
3537 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3538 PathShape, NodeStart, HasAngles,
3539 Angles, HasRefPoint, RefPoint)
3540 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3541 NodeStart, HasAngles, Angles, HasRefPoint,
3544 ## Generates new elements by extrusion of the elements which belong to the object
3545 # The path of extrusion must be a meshed edge.
3546 # @param theObject the object which elements should be processed.
3547 # It can be a mesh, a sub mesh or a group.
3548 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3549 # @param PathShape shape(edge) defines the sub-mesh for the path
3550 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3551 # @param HasAngles allows the shape to be rotated around the path
3552 # to get the resulting mesh in a helical fashion
3553 # @param Angles list of angles
3554 # @param HasRefPoint allows using the reference point
3555 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3556 # The User can specify any point as the Reference Point.
3557 # @param MakeGroups forces the generation of new groups from existing ones
3558 # @param LinearVariation forces the computation of rotation angles as linear
3559 # variation of the given Angles along path steps
3560 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3561 # only SMESH::Extrusion_Error otherwise
3562 # @ingroup l2_modif_extrurev
3563 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3564 HasAngles, Angles, HasRefPoint, RefPoint,
3565 MakeGroups=False, LinearVariation=False):
3566 Angles,AnglesParameters = ParseAngles(Angles)
3567 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3568 if ( isinstance( theObject, Mesh )):
3569 theObject = theObject.GetMesh()
3570 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3571 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3572 if ( isinstance( PathMesh, Mesh )):
3573 PathMesh = PathMesh.GetMesh()
3574 if HasAngles and Angles and LinearVariation:
3575 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3577 Parameters = AnglesParameters + var_separator + RefPointParameters
3578 self.mesh.SetParameters(Parameters)
3580 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3581 PathShape, NodeStart, HasAngles,
3582 Angles, HasRefPoint, RefPoint)
3583 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3584 NodeStart, HasAngles, Angles, HasRefPoint,
3587 ## Creates a symmetrical copy of mesh elements
3588 # @param IDsOfElements list of elements ids
3589 # @param Mirror is AxisStruct or geom object(point, line, plane)
3590 # @param theMirrorType is POINT, AXIS or PLANE
3591 # If the Mirror is a geom object this parameter is unnecessary
3592 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3593 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3594 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3595 # @ingroup l2_modif_trsf
3596 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3597 if IDsOfElements == []:
3598 IDsOfElements = self.GetElementsId()
3599 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3600 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3601 Mirror,Parameters = ParseAxisStruct(Mirror)
3602 self.mesh.SetParameters(Parameters)
3603 if Copy and MakeGroups:
3604 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3605 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3608 ## Creates a new mesh by a symmetrical copy of mesh elements
3609 # @param IDsOfElements the list of elements ids
3610 # @param Mirror is AxisStruct or geom object (point, line, plane)
3611 # @param theMirrorType is POINT, AXIS or PLANE
3612 # If the Mirror is a geom object this parameter is unnecessary
3613 # @param MakeGroups to generate new groups from existing ones
3614 # @param NewMeshName a name of the new mesh to create
3615 # @return instance of Mesh class
3616 # @ingroup l2_modif_trsf
3617 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3618 if IDsOfElements == []:
3619 IDsOfElements = self.GetElementsId()
3620 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3621 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3622 Mirror,Parameters = ParseAxisStruct(Mirror)
3623 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3624 MakeGroups, NewMeshName)
3625 mesh.SetParameters(Parameters)
3626 return Mesh(self.smeshpyD,self.geompyD,mesh)
3628 ## Creates a symmetrical copy of the object
3629 # @param theObject mesh, submesh or group
3630 # @param Mirror AxisStruct or geom object (point, line, plane)
3631 # @param theMirrorType is POINT, AXIS or PLANE
3632 # If the Mirror is a geom object this parameter is unnecessary
3633 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3634 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3635 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3636 # @ingroup l2_modif_trsf
3637 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3638 if ( isinstance( theObject, Mesh )):
3639 theObject = theObject.GetMesh()
3640 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3641 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3642 Mirror,Parameters = ParseAxisStruct(Mirror)
3643 self.mesh.SetParameters(Parameters)
3644 if Copy and MakeGroups:
3645 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3646 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3649 ## Creates a new mesh by a symmetrical copy of the object
3650 # @param theObject mesh, submesh or group
3651 # @param Mirror AxisStruct or geom object (point, line, plane)
3652 # @param theMirrorType POINT, AXIS or PLANE
3653 # If the Mirror is a geom object this parameter is unnecessary
3654 # @param MakeGroups forces the generation of new groups from existing ones
3655 # @param NewMeshName the name of the new mesh to create
3656 # @return instance of Mesh class
3657 # @ingroup l2_modif_trsf
3658 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3659 if ( isinstance( theObject, Mesh )):
3660 theObject = theObject.GetMesh()
3661 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3662 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3663 Mirror,Parameters = ParseAxisStruct(Mirror)
3664 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3665 MakeGroups, NewMeshName)
3666 mesh.SetParameters(Parameters)
3667 return Mesh( self.smeshpyD,self.geompyD,mesh )
3669 ## Translates the elements
3670 # @param IDsOfElements list of elements ids
3671 # @param Vector the direction of translation (DirStruct or vector)
3672 # @param Copy allows copying the translated elements
3673 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3674 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3675 # @ingroup l2_modif_trsf
3676 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3677 if IDsOfElements == []:
3678 IDsOfElements = self.GetElementsId()
3679 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3680 Vector = self.smeshpyD.GetDirStruct(Vector)
3681 Vector,Parameters = ParseDirStruct(Vector)
3682 self.mesh.SetParameters(Parameters)
3683 if Copy and MakeGroups:
3684 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3685 self.editor.Translate(IDsOfElements, Vector, Copy)
3688 ## Creates a new mesh of translated elements
3689 # @param IDsOfElements list of elements ids
3690 # @param Vector the direction of translation (DirStruct or vector)
3691 # @param MakeGroups forces the generation of new groups from existing ones
3692 # @param NewMeshName the name of the newly created mesh
3693 # @return instance of Mesh class
3694 # @ingroup l2_modif_trsf
3695 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3696 if IDsOfElements == []:
3697 IDsOfElements = self.GetElementsId()
3698 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3699 Vector = self.smeshpyD.GetDirStruct(Vector)
3700 Vector,Parameters = ParseDirStruct(Vector)
3701 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3702 mesh.SetParameters(Parameters)
3703 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3705 ## Translates the object
3706 # @param theObject the object to translate (mesh, submesh, or group)
3707 # @param Vector direction of translation (DirStruct or geom vector)
3708 # @param Copy allows copying the translated elements
3709 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3710 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3711 # @ingroup l2_modif_trsf
3712 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3713 if ( isinstance( theObject, Mesh )):
3714 theObject = theObject.GetMesh()
3715 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3716 Vector = self.smeshpyD.GetDirStruct(Vector)
3717 Vector,Parameters = ParseDirStruct(Vector)
3718 self.mesh.SetParameters(Parameters)
3719 if Copy and MakeGroups:
3720 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3721 self.editor.TranslateObject(theObject, Vector, Copy)
3724 ## Creates a new mesh from the translated object
3725 # @param theObject the object to translate (mesh, submesh, or group)
3726 # @param Vector the direction of translation (DirStruct or geom vector)
3727 # @param MakeGroups forces the generation of new groups from existing ones
3728 # @param NewMeshName the name of the newly created mesh
3729 # @return instance of Mesh class
3730 # @ingroup l2_modif_trsf
3731 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3732 if (isinstance(theObject, Mesh)):
3733 theObject = theObject.GetMesh()
3734 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3735 Vector = self.smeshpyD.GetDirStruct(Vector)
3736 Vector,Parameters = ParseDirStruct(Vector)
3737 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3738 mesh.SetParameters(Parameters)
3739 return Mesh( self.smeshpyD, self.geompyD, mesh )
3743 ## Scales the object
3744 # @param theObject - the object to translate (mesh, submesh, or group)
3745 # @param thePoint - base point for scale
3746 # @param theScaleFact - list of 1-3 scale factors for axises
3747 # @param Copy - allows copying the translated elements
3748 # @param MakeGroups - forces the generation of new groups from existing
3750 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3751 # empty list otherwise
3752 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3753 if ( isinstance( theObject, Mesh )):
3754 theObject = theObject.GetMesh()
3755 if ( isinstance( theObject, list )):
3756 theObject = self.GetIDSource(theObject, SMESH.ALL)
3758 thePoint, Parameters = ParsePointStruct(thePoint)
3759 self.mesh.SetParameters(Parameters)
3761 if Copy and MakeGroups:
3762 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3763 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3766 ## Creates a new mesh from the translated object
3767 # @param theObject - the object to translate (mesh, submesh, or group)
3768 # @param thePoint - base point for scale
3769 # @param theScaleFact - list of 1-3 scale factors for axises
3770 # @param MakeGroups - forces the generation of new groups from existing ones
3771 # @param NewMeshName - the name of the newly created mesh
3772 # @return instance of Mesh class
3773 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3774 if (isinstance(theObject, Mesh)):
3775 theObject = theObject.GetMesh()
3776 if ( isinstance( theObject, list )):
3777 theObject = self.GetIDSource(theObject,SMESH.ALL)
3779 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3780 MakeGroups, NewMeshName)
3781 #mesh.SetParameters(Parameters)
3782 return Mesh( self.smeshpyD, self.geompyD, mesh )
3786 ## Rotates the elements
3787 # @param IDsOfElements list of elements ids
3788 # @param Axis the axis of rotation (AxisStruct or geom line)
3789 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3790 # @param Copy allows copying the rotated elements
3791 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3792 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3793 # @ingroup l2_modif_trsf
3794 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3796 if isinstance(AngleInRadians,str):
3798 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3800 AngleInRadians = DegreesToRadians(AngleInRadians)
3801 if IDsOfElements == []:
3802 IDsOfElements = self.GetElementsId()
3803 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3804 Axis = self.smeshpyD.GetAxisStruct(Axis)
3805 Axis,AxisParameters = ParseAxisStruct(Axis)
3806 Parameters = AxisParameters + var_separator + Parameters
3807 self.mesh.SetParameters(Parameters)
3808 if Copy and MakeGroups:
3809 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3810 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3813 ## Creates a new mesh of rotated elements
3814 # @param IDsOfElements list of element ids
3815 # @param Axis the axis of rotation (AxisStruct or geom line)
3816 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3817 # @param MakeGroups forces the generation of new groups from existing ones
3818 # @param NewMeshName the name of the newly created mesh
3819 # @return instance of Mesh class
3820 # @ingroup l2_modif_trsf
3821 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3823 if isinstance(AngleInRadians,str):
3825 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3827 AngleInRadians = DegreesToRadians(AngleInRadians)
3828 if IDsOfElements == []:
3829 IDsOfElements = self.GetElementsId()
3830 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3831 Axis = self.smeshpyD.GetAxisStruct(Axis)
3832 Axis,AxisParameters = ParseAxisStruct(Axis)
3833 Parameters = AxisParameters + var_separator + Parameters
3834 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3835 MakeGroups, NewMeshName)
3836 mesh.SetParameters(Parameters)
3837 return Mesh( self.smeshpyD, self.geompyD, mesh )
3839 ## Rotates the object
3840 # @param theObject the object to rotate( mesh, submesh, or group)
3841 # @param Axis the axis of rotation (AxisStruct or geom line)
3842 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3843 # @param Copy allows copying the rotated elements
3844 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3845 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3846 # @ingroup l2_modif_trsf
3847 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3849 if isinstance(AngleInRadians,str):
3851 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3853 AngleInRadians = DegreesToRadians(AngleInRadians)
3854 if (isinstance(theObject, Mesh)):
3855 theObject = theObject.GetMesh()
3856 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3857 Axis = self.smeshpyD.GetAxisStruct(Axis)
3858 Axis,AxisParameters = ParseAxisStruct(Axis)
3859 Parameters = AxisParameters + ":" + Parameters
3860 self.mesh.SetParameters(Parameters)
3861 if Copy and MakeGroups:
3862 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3863 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3866 ## Creates a new mesh from the rotated object
3867 # @param theObject the object to rotate (mesh, submesh, or group)
3868 # @param Axis the axis of rotation (AxisStruct or geom line)
3869 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3870 # @param MakeGroups forces the generation of new groups from existing ones
3871 # @param NewMeshName the name of the newly created mesh
3872 # @return instance of Mesh class
3873 # @ingroup l2_modif_trsf
3874 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3876 if isinstance(AngleInRadians,str):
3878 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3880 AngleInRadians = DegreesToRadians(AngleInRadians)
3881 if (isinstance( theObject, Mesh )):
3882 theObject = theObject.GetMesh()
3883 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3884 Axis = self.smeshpyD.GetAxisStruct(Axis)
3885 Axis,AxisParameters = ParseAxisStruct(Axis)
3886 Parameters = AxisParameters + ":" + Parameters
3887 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3888 MakeGroups, NewMeshName)
3889 mesh.SetParameters(Parameters)
3890 return Mesh( self.smeshpyD, self.geompyD, mesh )
3892 ## Finds groups of ajacent nodes within Tolerance.
3893 # @param Tolerance the value of tolerance
3894 # @return the list of groups of nodes
3895 # @ingroup l2_modif_trsf
3896 def FindCoincidentNodes (self, Tolerance):
3897 return self.editor.FindCoincidentNodes(Tolerance)
3899 ## Finds groups of ajacent nodes within Tolerance.
3900 # @param Tolerance the value of tolerance
3901 # @param SubMeshOrGroup SubMesh or Group
3902 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3903 # @return the list of groups of nodes
3904 # @ingroup l2_modif_trsf
3905 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3906 if (isinstance( SubMeshOrGroup, Mesh )):
3907 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3908 if not isinstance( exceptNodes, list):
3909 exceptNodes = [ exceptNodes ]
3910 if exceptNodes and isinstance( exceptNodes[0], int):
3911 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3912 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3915 # @param GroupsOfNodes the list of groups of nodes
3916 # @ingroup l2_modif_trsf
3917 def MergeNodes (self, GroupsOfNodes):
3918 self.editor.MergeNodes(GroupsOfNodes)
3920 ## Finds the elements built on the same nodes.
3921 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3922 # @return a list of groups of equal elements
3923 # @ingroup l2_modif_trsf
3924 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3925 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3926 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3927 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3929 ## Merges elements in each given group.
3930 # @param GroupsOfElementsID groups of elements for merging
3931 # @ingroup l2_modif_trsf
3932 def MergeElements(self, GroupsOfElementsID):
3933 self.editor.MergeElements(GroupsOfElementsID)
3935 ## Leaves one element and removes all other elements built on the same nodes.
3936 # @ingroup l2_modif_trsf
3937 def MergeEqualElements(self):
3938 self.editor.MergeEqualElements()
3940 ## Sews free borders
3941 # @return SMESH::Sew_Error
3942 # @ingroup l2_modif_trsf
3943 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3944 FirstNodeID2, SecondNodeID2, LastNodeID2,
3945 CreatePolygons, CreatePolyedrs):
3946 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3947 FirstNodeID2, SecondNodeID2, LastNodeID2,
3948 CreatePolygons, CreatePolyedrs)
3950 ## Sews conform free borders
3951 # @return SMESH::Sew_Error
3952 # @ingroup l2_modif_trsf
3953 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3954 FirstNodeID2, SecondNodeID2):
3955 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3956 FirstNodeID2, SecondNodeID2)
3958 ## Sews border to side
3959 # @return SMESH::Sew_Error
3960 # @ingroup l2_modif_trsf
3961 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3962 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3963 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3964 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3966 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3967 # merged with the nodes of elements of Side2.
3968 # The number of elements in theSide1 and in theSide2 must be
3969 # equal and they should have similar nodal connectivity.
3970 # The nodes to merge should belong to side borders and
3971 # the first node should be linked to the second.
3972 # @return SMESH::Sew_Error
3973 # @ingroup l2_modif_trsf
3974 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3975 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3976 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3977 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3978 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3979 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3981 ## Sets new nodes for the given element.
3982 # @param ide the element id
3983 # @param newIDs nodes ids
3984 # @return If the number of nodes does not correspond to the type of element - returns false
3985 # @ingroup l2_modif_edit
3986 def ChangeElemNodes(self, ide, newIDs):
3987 return self.editor.ChangeElemNodes(ide, newIDs)
3989 ## If during the last operation of MeshEditor some nodes were
3990 # created, this method returns the list of their IDs, \n
3991 # if new nodes were not created - returns empty list
3992 # @return the list of integer values (can be empty)
3993 # @ingroup l1_auxiliary
3994 def GetLastCreatedNodes(self):
3995 return self.editor.GetLastCreatedNodes()
3997 ## If during the last operation of MeshEditor some elements were
3998 # created this method returns the list of their IDs, \n
3999 # if new elements were not created - returns empty list
4000 # @return the list of integer values (can be empty)
4001 # @ingroup l1_auxiliary
4002 def GetLastCreatedElems(self):
4003 return self.editor.GetLastCreatedElems()
4005 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4006 # @param theNodes identifiers of nodes to be doubled
4007 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
4008 # nodes. If list of element identifiers is empty then nodes are doubled but
4009 # they not assigned to elements
4010 # @return TRUE if operation has been completed successfully, FALSE otherwise
4011 # @ingroup l2_modif_edit
4012 def DoubleNodes(self, theNodes, theModifiedElems):
4013 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4015 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4016 # This method provided for convenience works as DoubleNodes() described above.
4017 # @param theNodeId identifiers of node to be doubled
4018 # @param theModifiedElems identifiers of elements to be updated
4019 # @return TRUE if operation has been completed successfully, FALSE otherwise
4020 # @ingroup l2_modif_edit
4021 def DoubleNode(self, theNodeId, theModifiedElems):
4022 return self.editor.DoubleNode(theNodeId, theModifiedElems)
4024 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4025 # This method provided for convenience works as DoubleNodes() described above.
4026 # @param theNodes group of nodes to be doubled
4027 # @param theModifiedElems group of elements to be updated.
4028 # @param theMakeGroup forces the generation of a group containing new nodes.
4029 # @return TRUE or a created group if operation has been completed successfully,
4030 # FALSE or None otherwise
4031 # @ingroup l2_modif_edit
4032 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4034 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4035 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4037 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4038 # This method provided for convenience works as DoubleNodes() described above.
4039 # @param theNodes list of groups of nodes to be doubled
4040 # @param theModifiedElems list of groups of elements to be updated.
4041 # @return TRUE if operation has been completed successfully, FALSE otherwise
4042 # @ingroup l2_modif_edit
4043 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
4045 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
4046 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4048 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4049 # @param theElems - the list of elements (edges or faces) to be replicated
4050 # The nodes for duplication could be found from these elements
4051 # @param theNodesNot - list of nodes to NOT replicate
4052 # @param theAffectedElems - the list of elements (cells and edges) to which the
4053 # replicated nodes should be associated to.
4054 # @return TRUE if operation has been completed successfully, FALSE otherwise
4055 # @ingroup l2_modif_edit
4056 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4057 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
4059 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4060 # @param theElems - the list of elements (edges or faces) to be replicated
4061 # The nodes for duplication could be found from these elements
4062 # @param theNodesNot - list of nodes to NOT replicate
4063 # @param theShape - shape to detect affected elements (element which geometric center
4064 # located on or inside shape).
4065 # The replicated nodes should be associated to affected elements.
4066 # @return TRUE if operation has been completed successfully, FALSE otherwise
4067 # @ingroup l2_modif_edit
4068 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4069 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4071 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4072 # This method provided for convenience works as DoubleNodes() described above.
4073 # @param theElems - group of of elements (edges or faces) to be replicated
4074 # @param theNodesNot - group of nodes not to replicated
4075 # @param theAffectedElems - group of elements to which the replicated nodes
4076 # should be associated to.
4077 # @param theMakeGroup forces the generation of a group containing new elements.
4078 # @return TRUE or a created group if operation has been completed successfully,
4079 # FALSE or None otherwise
4080 # @ingroup l2_modif_edit
4081 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4083 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4084 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4086 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4087 # This method provided for convenience works as DoubleNodes() described above.
4088 # @param theElems - group of of elements (edges or faces) to be replicated
4089 # @param theNodesNot - group of nodes not to replicated
4090 # @param theShape - shape to detect affected elements (element which geometric center
4091 # located on or inside shape).
4092 # The replicated nodes should be associated to affected elements.
4093 # @ingroup l2_modif_edit
4094 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4095 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4097 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4098 # This method provided for convenience works as DoubleNodes() described above.
4099 # @param theElems - list of groups of elements (edges or faces) to be replicated
4100 # @param theNodesNot - list of groups of nodes not to replicated
4101 # @param theAffectedElems - group of elements to which the replicated nodes
4102 # should be associated to.
4103 # @param theMakeGroup forces the generation of a group containing new elements.
4104 # @return TRUE or a created group if operation has been completed successfully,
4105 # FALSE or None otherwise
4106 # @ingroup l2_modif_edit
4107 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4109 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
4110 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4112 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4113 # This method provided for convenience works as DoubleNodes() described above.
4114 # @param theElems - list of groups of elements (edges or faces) to be replicated
4115 # @param theNodesNot - list of groups of nodes not to replicated
4116 # @param theShape - shape to detect affected elements (element which geometric center
4117 # located on or inside shape).
4118 # The replicated nodes should be associated to affected elements.
4119 # @return TRUE if operation has been completed successfully, FALSE otherwise
4120 # @ingroup l2_modif_edit
4121 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4122 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4124 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4125 # The list of groups must describe a partition of the mesh volumes.
4126 # The nodes of the internal faces at the boundaries of the groups are doubled.
4127 # In option, the internal faces are replaced by flat elements.
4128 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4129 # @param theDomains - list of groups of volumes
4130 # @param createJointElems - if TRUE, create the elements
4131 # @return TRUE if operation has been completed successfully, FALSE otherwise
4132 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4133 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4135 def _valueFromFunctor(self, funcType, elemId):
4136 fn = self.smeshpyD.GetFunctor(funcType)
4137 fn.SetMesh(self.mesh)
4138 if fn.GetElementType() == self.GetElementType(elemId, True):
4139 val = fn.GetValue(elemId)
4144 ## Get length of 1D element.
4145 # @param elemId mesh element ID
4146 # @return element's length value
4147 # @ingroup l1_measurements
4148 def GetLength(self, elemId):
4149 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4151 ## Get area of 2D element.
4152 # @param elemId mesh element ID
4153 # @return element's area value
4154 # @ingroup l1_measurements
4155 def GetArea(self, elemId):
4156 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4158 ## Get volume of 3D element.
4159 # @param elemId mesh element ID
4160 # @return element's volume value
4161 # @ingroup l1_measurements
4162 def GetVolume(self, elemId):
4163 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4165 ## Get maximum element length.
4166 # @param elemId mesh element ID
4167 # @return element's maximum length value
4168 # @ingroup l1_measurements
4169 def GetMaxElementLength(self, elemId):
4170 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4171 ftype = SMESH.FT_MaxElementLength3D
4173 ftype = SMESH.FT_MaxElementLength2D
4174 return self._valueFromFunctor(ftype, elemId)
4176 ## Get aspect ratio of 2D or 3D element.
4177 # @param elemId mesh element ID
4178 # @return element's aspect ratio value
4179 # @ingroup l1_measurements
4180 def GetAspectRatio(self, elemId):
4181 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4182 ftype = SMESH.FT_AspectRatio3D
4184 ftype = SMESH.FT_AspectRatio
4185 return self._valueFromFunctor(ftype, elemId)
4187 ## Get warping angle of 2D element.
4188 # @param elemId mesh element ID
4189 # @return element's warping angle value
4190 # @ingroup l1_measurements
4191 def GetWarping(self, elemId):
4192 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4194 ## Get minimum angle of 2D element.
4195 # @param elemId mesh element ID
4196 # @return element's minimum angle value
4197 # @ingroup l1_measurements
4198 def GetMinimumAngle(self, elemId):
4199 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4201 ## Get taper of 2D element.
4202 # @param elemId mesh element ID
4203 # @return element's taper value
4204 # @ingroup l1_measurements
4205 def GetTaper(self, elemId):
4206 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4208 ## Get skew of 2D element.
4209 # @param elemId mesh element ID
4210 # @return element's skew value
4211 # @ingroup l1_measurements
4212 def GetSkew(self, elemId):
4213 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4215 ## The mother class to define algorithm, it is not recommended to use it directly.
4218 # @ingroup l2_algorithms
4219 class Mesh_Algorithm:
4220 # @class Mesh_Algorithm
4221 # @brief Class Mesh_Algorithm
4223 #def __init__(self,smesh):
4231 ## Finds a hypothesis in the study by its type name and parameters.
4232 # Finds only the hypotheses created in smeshpyD engine.
4233 # @return SMESH.SMESH_Hypothesis
4234 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4235 study = smeshpyD.GetCurrentStudy()
4236 #to do: find component by smeshpyD object, not by its data type
4237 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4238 if scomp is not None:
4239 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4240 # Check if the root label of the hypotheses exists
4241 if res and hypRoot is not None:
4242 iter = study.NewChildIterator(hypRoot)
4243 # Check all published hypotheses
4245 hypo_so_i = iter.Value()
4246 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4247 if attr is not None:
4248 anIOR = attr.Value()
4249 hypo_o_i = salome.orb.string_to_object(anIOR)
4250 if hypo_o_i is not None:
4251 # Check if this is a hypothesis
4252 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4253 if hypo_i is not None:
4254 # Check if the hypothesis belongs to current engine
4255 if smeshpyD.GetObjectId(hypo_i) > 0:
4256 # Check if this is the required hypothesis
4257 if hypo_i.GetName() == hypname:
4259 if CompareMethod(hypo_i, args):
4273 ## Finds the algorithm in the study by its type name.
4274 # Finds only the algorithms, which have been created in smeshpyD engine.
4275 # @return SMESH.SMESH_Algo
4276 def FindAlgorithm (self, algoname, smeshpyD):
4277 study = smeshpyD.GetCurrentStudy()
4278 #to do: find component by smeshpyD object, not by its data type
4279 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4280 if scomp is not None:
4281 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4282 # Check if the root label of the algorithms exists
4283 if res and hypRoot is not None:
4284 iter = study.NewChildIterator(hypRoot)
4285 # Check all published algorithms
4287 algo_so_i = iter.Value()
4288 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4289 if attr is not None:
4290 anIOR = attr.Value()
4291 algo_o_i = salome.orb.string_to_object(anIOR)
4292 if algo_o_i is not None:
4293 # Check if this is an algorithm
4294 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4295 if algo_i is not None:
4296 # Checks if the algorithm belongs to the current engine
4297 if smeshpyD.GetObjectId(algo_i) > 0:
4298 # Check if this is the required algorithm
4299 if algo_i.GetName() == algoname:
4312 ## If the algorithm is global, returns 0; \n
4313 # else returns the submesh associated to this algorithm.
4314 def GetSubMesh(self):
4317 ## Returns the wrapped mesher.
4318 def GetAlgorithm(self):
4321 ## Gets the list of hypothesis that can be used with this algorithm
4322 def GetCompatibleHypothesis(self):
4325 mylist = self.algo.GetCompatibleHypothesis()
4328 ## Gets the name of the algorithm
4332 ## Sets the name to the algorithm
4333 def SetName(self, name):
4334 self.mesh.smeshpyD.SetName(self.algo, name)
4336 ## Gets the id of the algorithm
4338 return self.algo.GetId()
4341 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4343 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4344 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4346 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4348 self.Assign(algo, mesh, geom)
4352 def Assign(self, algo, mesh, geom):
4354 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4363 name = GetName(geom)
4367 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
4368 # for all groups SubShapeName() returns "Compound_-1"
4369 name = mesh.geompyD.SubShapeName(geom, piece)
4371 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
4372 # publish geom of sub-mesh (issue 0021122)
4373 if not self.geom.IsSame( self.mesh.geom ) and not self.geom.GetStudyEntry():
4374 studyID = self.mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
4375 if studyID != self.mesh.geompyD.myStudyId:
4376 self.mesh.geompyD.init_geom( self.mesh.smeshpyD.GetCurrentStudy())
4377 self.mesh.geompyD.addToStudyInFather( self.mesh.geom, self.geom, name )
4379 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4381 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4382 TreatHypoStatus( status, algo.GetName(), name, True )
4384 def CompareHyp (self, hyp, args):
4385 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4388 def CompareEqualHyp (self, hyp, args):
4392 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4393 UseExisting=0, CompareMethod=""):
4396 if CompareMethod == "": CompareMethod = self.CompareHyp
4397 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4400 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4406 a = a + s + str(args[i])
4410 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4414 geomName = GetName(self.geom)
4415 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4416 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4419 ## Returns entry of the shape to mesh in the study
4420 def MainShapeEntry(self):
4422 if not self.mesh or not self.mesh.GetMesh(): return entry
4423 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4424 study = self.mesh.smeshpyD.GetCurrentStudy()
4425 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4426 sobj = study.FindObjectIOR(ior)
4427 if sobj: entry = sobj.GetID()
4428 if not entry: return ""
4431 ## Defines "ViscousLayers" hypothesis to give parameters of layers of prisms to build
4432 # near mesh boundary. This hypothesis can be used by several 3D algorithms:
4433 # NETGEN 3D, GHS3D, Hexahedron(i,j,k)
4434 # @param thickness total thickness of layers of prisms
4435 # @param numberOfLayers number of layers of prisms
4436 # @param stretchFactor factor (>1.0) of growth of layer thickness towards inside of mesh
4437 # @param ignoreFaces geometrical face (or their ids) not to generate layers on
4438 # @ingroup l3_hypos_additi
4439 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
4440 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
4441 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
4442 if not "ViscousLayers" in self.GetCompatibleHypothesis():
4443 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
4444 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
4445 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
4446 hyp = self.Hypothesis("ViscousLayers",
4447 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
4448 hyp.SetTotalThickness(thickness)
4449 hyp.SetNumberLayers(numberOfLayers)
4450 hyp.SetStretchFactor(stretchFactor)
4451 hyp.SetIgnoreFaces(ignoreFaces)
4454 # Public class: Mesh_Segment
4455 # --------------------------
4457 ## Class to define a segment 1D algorithm for discretization
4460 # @ingroup l3_algos_basic
4461 class Mesh_Segment(Mesh_Algorithm):
4463 ## Private constructor.
4464 def __init__(self, mesh, geom=0):
4465 Mesh_Algorithm.__init__(self)
4466 self.Create(mesh, geom, "Regular_1D")
4468 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4469 # @param l for the length of segments that cut an edge
4470 # @param UseExisting if ==true - searches for an existing hypothesis created with
4471 # the same parameters, else (default) - creates a new one
4472 # @param p precision, used for calculation of the number of segments.
4473 # The precision should be a positive, meaningful value within the range [0,1].
4474 # In general, the number of segments is calculated with the formula:
4475 # nb = ceil((edge_length / l) - p)
4476 # Function ceil rounds its argument to the higher integer.
4477 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4478 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4479 # p=1 means rounding of (edge_length / l) to the lower integer.
4480 # Default value is 1e-07.
4481 # @return an instance of StdMeshers_LocalLength hypothesis
4482 # @ingroup l3_hypos_1dhyps
4483 def LocalLength(self, l, UseExisting=0, p=1e-07):
4484 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4485 CompareMethod=self.CompareLocalLength)
4491 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4492 def CompareLocalLength(self, hyp, args):
4493 if IsEqual(hyp.GetLength(), args[0]):
4494 return IsEqual(hyp.GetPrecision(), args[1])
4497 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4498 # @param length is optional maximal allowed length of segment, if it is omitted
4499 # the preestimated length is used that depends on geometry size
4500 # @param UseExisting if ==true - searches for an existing hypothesis created with
4501 # the same parameters, else (default) - create a new one
4502 # @return an instance of StdMeshers_MaxLength hypothesis
4503 # @ingroup l3_hypos_1dhyps
4504 def MaxSize(self, length=0.0, UseExisting=0):
4505 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4508 hyp.SetLength(length)
4510 # set preestimated length
4511 gen = self.mesh.smeshpyD
4512 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4513 self.mesh.GetMesh(), self.mesh.GetShape(),
4515 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4517 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4520 hyp.SetUsePreestimatedLength( length == 0.0 )
4523 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4524 # @param n for the number of segments that cut an edge
4525 # @param s for the scale factor (optional)
4526 # @param reversedEdges is a list of edges to mesh using reversed orientation
4527 # @param UseExisting if ==true - searches for an existing hypothesis created with
4528 # the same parameters, else (default) - create a new one
4529 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4530 # @ingroup l3_hypos_1dhyps
4531 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4532 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4533 reversedEdges, UseExisting = [], reversedEdges
4534 entry = self.MainShapeEntry()
4535 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4536 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4538 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4539 UseExisting=UseExisting,
4540 CompareMethod=self.CompareNumberOfSegments)
4542 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4543 UseExisting=UseExisting,
4544 CompareMethod=self.CompareNumberOfSegments)
4545 hyp.SetDistrType( 1 )
4546 hyp.SetScaleFactor(s)
4547 hyp.SetNumberOfSegments(n)
4548 hyp.SetReversedEdges( reversedEdges )
4549 hyp.SetObjectEntry( entry )
4553 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4554 def CompareNumberOfSegments(self, hyp, args):
4555 if hyp.GetNumberOfSegments() == args[0]:
4557 if hyp.GetReversedEdges() == args[1]:
4558 if not args[1] or hyp.GetObjectEntry() == args[2]:
4561 if hyp.GetReversedEdges() == args[2]:
4562 if not args[2] or hyp.GetObjectEntry() == args[3]:
4563 if hyp.GetDistrType() == 1:
4564 if IsEqual(hyp.GetScaleFactor(), args[1]):
4568 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4569 # @param start defines the length of the first segment
4570 # @param end defines the length of the last segment
4571 # @param reversedEdges is a list of edges to mesh using reversed orientation
4572 # @param UseExisting if ==true - searches for an existing hypothesis created with
4573 # the same parameters, else (default) - creates a new one
4574 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4575 # @ingroup l3_hypos_1dhyps
4576 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4577 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4578 reversedEdges, UseExisting = [], reversedEdges
4579 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4580 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4581 entry = self.MainShapeEntry()
4582 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4583 UseExisting=UseExisting,
4584 CompareMethod=self.CompareArithmetic1D)
4585 hyp.SetStartLength(start)
4586 hyp.SetEndLength(end)
4587 hyp.SetReversedEdges( reversedEdges )
4588 hyp.SetObjectEntry( entry )
4592 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4593 def CompareArithmetic1D(self, hyp, args):
4594 if IsEqual(hyp.GetLength(1), args[0]):
4595 if IsEqual(hyp.GetLength(0), args[1]):
4596 if hyp.GetReversedEdges() == args[2]:
4597 if not args[2] or hyp.GetObjectEntry() == args[3]:
4602 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4603 # on curve from 0 to 1 (additionally it is neecessary to check
4604 # orientation of edges and create list of reversed edges if it is
4605 # needed) and sets numbers of segments between given points (default
4606 # values are equals 1
4607 # @param points defines the list of parameters on curve
4608 # @param nbSegs defines the list of numbers of segments
4609 # @param reversedEdges is a list of edges to mesh using reversed orientation
4610 # @param UseExisting if ==true - searches for an existing hypothesis created with
4611 # the same parameters, else (default) - creates a new one
4612 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4613 # @ingroup l3_hypos_1dhyps
4614 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4615 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4616 reversedEdges, UseExisting = [], reversedEdges
4617 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4618 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4619 entry = self.MainShapeEntry()
4620 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4621 UseExisting=UseExisting,
4622 CompareMethod=self.CompareFixedPoints1D)
4623 hyp.SetPoints(points)
4624 hyp.SetNbSegments(nbSegs)
4625 hyp.SetReversedEdges(reversedEdges)
4626 hyp.SetObjectEntry(entry)
4630 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4631 ## as the given arguments
4632 def CompareFixedPoints1D(self, hyp, args):
4633 if hyp.GetPoints() == args[0]:
4634 if hyp.GetNbSegments() == args[1]:
4635 if hyp.GetReversedEdges() == args[2]:
4636 if not args[2] or hyp.GetObjectEntry() == args[3]:
4642 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4643 # @param start defines the length of the first segment
4644 # @param end defines the length of the last segment
4645 # @param reversedEdges is a list of edges to mesh using reversed orientation
4646 # @param UseExisting if ==true - searches for an existing hypothesis created with
4647 # the same parameters, else (default) - creates a new one
4648 # @return an instance of StdMeshers_StartEndLength hypothesis
4649 # @ingroup l3_hypos_1dhyps
4650 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4651 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4652 reversedEdges, UseExisting = [], reversedEdges
4653 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4654 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4655 entry = self.MainShapeEntry()
4656 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4657 UseExisting=UseExisting,
4658 CompareMethod=self.CompareStartEndLength)
4659 hyp.SetStartLength(start)
4660 hyp.SetEndLength(end)
4661 hyp.SetReversedEdges( reversedEdges )
4662 hyp.SetObjectEntry( entry )
4665 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4666 def CompareStartEndLength(self, hyp, args):
4667 if IsEqual(hyp.GetLength(1), args[0]):
4668 if IsEqual(hyp.GetLength(0), args[1]):
4669 if hyp.GetReversedEdges() == args[2]:
4670 if not args[2] or hyp.GetObjectEntry() == args[3]:
4674 ## Defines "Deflection1D" hypothesis
4675 # @param d for the deflection
4676 # @param UseExisting if ==true - searches for an existing hypothesis created with
4677 # the same parameters, else (default) - create a new one
4678 # @ingroup l3_hypos_1dhyps
4679 def Deflection1D(self, d, UseExisting=0):
4680 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4681 CompareMethod=self.CompareDeflection1D)
4682 hyp.SetDeflection(d)
4685 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4686 def CompareDeflection1D(self, hyp, args):
4687 return IsEqual(hyp.GetDeflection(), args[0])
4689 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4690 # the opposite side in case of quadrangular faces
4691 # @ingroup l3_hypos_additi
4692 def Propagation(self):
4693 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4695 ## Defines "AutomaticLength" hypothesis
4696 # @param fineness for the fineness [0-1]
4697 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4698 # same parameters, else (default) - create a new one
4699 # @ingroup l3_hypos_1dhyps
4700 def AutomaticLength(self, fineness=0, UseExisting=0):
4701 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4702 CompareMethod=self.CompareAutomaticLength)
4703 hyp.SetFineness( fineness )
4706 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4707 def CompareAutomaticLength(self, hyp, args):
4708 return IsEqual(hyp.GetFineness(), args[0])
4710 ## Defines "SegmentLengthAroundVertex" hypothesis
4711 # @param length for the segment length
4712 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4713 # Any other integer value means that the hypothesis will be set on the
4714 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4715 # @param UseExisting if ==true - searches for an existing hypothesis created with
4716 # the same parameters, else (default) - creates a new one
4717 # @ingroup l3_algos_segmarv
4718 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4720 store_geom = self.geom
4721 if type(vertex) is types.IntType:
4722 if vertex == 0 or vertex == 1:
4723 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4731 if self.geom is None:
4732 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4734 name = GetName(self.geom)
4737 piece = self.mesh.geom
4738 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4739 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4741 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4743 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4745 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4746 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4748 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4749 CompareMethod=self.CompareLengthNearVertex)
4750 self.geom = store_geom
4751 hyp.SetLength( length )
4754 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4755 # @ingroup l3_algos_segmarv
4756 def CompareLengthNearVertex(self, hyp, args):
4757 return IsEqual(hyp.GetLength(), args[0])
4759 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4760 # If the 2D mesher sees that all boundary edges are quadratic,
4761 # it generates quadratic faces, else it generates linear faces using
4762 # medium nodes as if they are vertices.
4763 # The 3D mesher generates quadratic volumes only if all boundary faces
4764 # are quadratic, else it fails.
4766 # @ingroup l3_hypos_additi
4767 def QuadraticMesh(self):
4768 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4771 # Public class: Mesh_CompositeSegment
4772 # --------------------------
4774 ## Defines a segment 1D algorithm for discretization
4776 # @ingroup l3_algos_basic
4777 class Mesh_CompositeSegment(Mesh_Segment):
4779 ## Private constructor.
4780 def __init__(self, mesh, geom=0):
4781 self.Create(mesh, geom, "CompositeSegment_1D")
4784 # Public class: Mesh_Segment_Python
4785 # ---------------------------------
4787 ## Defines a segment 1D algorithm for discretization with python function
4789 # @ingroup l3_algos_basic
4790 class Mesh_Segment_Python(Mesh_Segment):
4792 ## Private constructor.
4793 def __init__(self, mesh, geom=0):
4794 import Python1dPlugin
4795 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4797 ## Defines "PythonSplit1D" hypothesis
4798 # @param n for the number of segments that cut an edge
4799 # @param func for the python function that calculates the length of all segments
4800 # @param UseExisting if ==true - searches for the existing hypothesis created with
4801 # the same parameters, else (default) - creates a new one
4802 # @ingroup l3_hypos_1dhyps
4803 def PythonSplit1D(self, n, func, UseExisting=0):
4804 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4805 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4806 hyp.SetNumberOfSegments(n)
4807 hyp.SetPythonLog10RatioFunction(func)
4810 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4811 def ComparePythonSplit1D(self, hyp, args):
4812 #if hyp.GetNumberOfSegments() == args[0]:
4813 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4817 # Public class: Mesh_Triangle
4818 # ---------------------------
4820 ## Defines a triangle 2D algorithm
4822 # @ingroup l3_algos_basic
4823 class Mesh_Triangle(Mesh_Algorithm):
4832 ## Private constructor.
4833 def __init__(self, mesh, algoType, geom=0):
4834 Mesh_Algorithm.__init__(self)
4836 self.algoType = algoType
4837 if algoType == MEFISTO:
4838 self.Create(mesh, geom, "MEFISTO_2D")
4840 elif algoType == BLSURF:
4842 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4843 #self.SetPhysicalMesh() - PAL19680
4844 elif algoType == NETGEN:
4846 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4848 elif algoType == NETGEN_2D:
4850 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4853 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4854 # @param area for the maximum area of each triangle
4855 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4856 # same parameters, else (default) - creates a new one
4858 # Only for algoType == MEFISTO || NETGEN_2D
4859 # @ingroup l3_hypos_2dhyps
4860 def MaxElementArea(self, area, UseExisting=0):
4861 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4862 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4863 CompareMethod=self.CompareMaxElementArea)
4864 elif self.algoType == NETGEN:
4865 hyp = self.Parameters(SIMPLE)
4866 hyp.SetMaxElementArea(area)
4869 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4870 def CompareMaxElementArea(self, hyp, args):
4871 return IsEqual(hyp.GetMaxElementArea(), args[0])
4873 ## Defines "LengthFromEdges" hypothesis to build triangles
4874 # based on the length of the edges taken from the wire
4876 # Only for algoType == MEFISTO || NETGEN_2D
4877 # @ingroup l3_hypos_2dhyps
4878 def LengthFromEdges(self):
4879 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4880 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4882 elif self.algoType == NETGEN:
4883 hyp = self.Parameters(SIMPLE)
4884 hyp.LengthFromEdges()
4887 ## Sets a way to define size of mesh elements to generate.
4888 # @param thePhysicalMesh is: DefaultSize or Custom.
4889 # @ingroup l3_hypos_blsurf
4890 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4891 # Parameter of BLSURF algo
4892 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4894 ## Sets size of mesh elements to generate.
4895 # @ingroup l3_hypos_blsurf
4896 def SetPhySize(self, theVal):
4897 # Parameter of BLSURF algo
4898 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4899 self.Parameters().SetPhySize(theVal)
4901 ## Sets lower boundary of mesh element size (PhySize).
4902 # @ingroup l3_hypos_blsurf
4903 def SetPhyMin(self, theVal=-1):
4904 # Parameter of BLSURF algo
4905 self.Parameters().SetPhyMin(theVal)
4907 ## Sets upper boundary of mesh element size (PhySize).
4908 # @ingroup l3_hypos_blsurf
4909 def SetPhyMax(self, theVal=-1):
4910 # Parameter of BLSURF algo
4911 self.Parameters().SetPhyMax(theVal)
4913 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4914 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4915 # @ingroup l3_hypos_blsurf
4916 def SetGeometricMesh(self, theGeometricMesh=0):
4917 # Parameter of BLSURF algo
4918 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4919 self.params.SetGeometricMesh(theGeometricMesh)
4921 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4922 # @ingroup l3_hypos_blsurf
4923 def SetAngleMeshS(self, theVal=_angleMeshS):
4924 # Parameter of BLSURF algo
4925 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4926 self.params.SetAngleMeshS(theVal)
4928 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4929 # @ingroup l3_hypos_blsurf
4930 def SetAngleMeshC(self, theVal=_angleMeshS):
4931 # Parameter of BLSURF algo
4932 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4933 self.params.SetAngleMeshC(theVal)
4935 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4936 # @ingroup l3_hypos_blsurf
4937 def SetGeoMin(self, theVal=-1):
4938 # Parameter of BLSURF algo
4939 self.Parameters().SetGeoMin(theVal)
4941 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4942 # @ingroup l3_hypos_blsurf
4943 def SetGeoMax(self, theVal=-1):
4944 # Parameter of BLSURF algo
4945 self.Parameters().SetGeoMax(theVal)
4947 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4948 # @ingroup l3_hypos_blsurf
4949 def SetGradation(self, theVal=_gradation):
4950 # Parameter of BLSURF algo
4951 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4952 self.params.SetGradation(theVal)
4954 ## Sets topology usage way.
4955 # @param way defines how mesh conformity is assured <ul>
4956 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4957 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4958 # @ingroup l3_hypos_blsurf
4959 def SetTopology(self, way):
4960 # Parameter of BLSURF algo
4961 self.Parameters().SetTopology(way)
4963 ## To respect geometrical edges or not.
4964 # @ingroup l3_hypos_blsurf
4965 def SetDecimesh(self, toIgnoreEdges=False):
4966 # Parameter of BLSURF algo
4967 self.Parameters().SetDecimesh(toIgnoreEdges)
4969 ## Sets verbosity level in the range 0 to 100.
4970 # @ingroup l3_hypos_blsurf
4971 def SetVerbosity(self, level):
4972 # Parameter of BLSURF algo
4973 self.Parameters().SetVerbosity(level)
4975 ## Sets advanced option value.
4976 # @ingroup l3_hypos_blsurf
4977 def SetOptionValue(self, optionName, level):
4978 # Parameter of BLSURF algo
4979 self.Parameters().SetOptionValue(optionName,level)
4981 ## Sets QuadAllowed flag.
4982 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
4983 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4984 def SetQuadAllowed(self, toAllow=True):
4985 if self.algoType == NETGEN_2D:
4988 hasSimpleHyps = False
4989 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
4990 for hyp in self.mesh.GetHypothesisList( self.geom ):
4991 if hyp.GetName() in simpleHyps:
4992 hasSimpleHyps = True
4993 if hyp.GetName() == "QuadranglePreference":
4994 if not toAllow: # remove QuadranglePreference
4995 self.mesh.RemoveHypothesis( self.geom, hyp )
5001 if toAllow: # add QuadranglePreference
5002 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
5007 if self.Parameters():
5008 self.params.SetQuadAllowed(toAllow)
5011 ## Defines hypothesis having several parameters
5013 # @ingroup l3_hypos_netgen
5014 def Parameters(self, which=SOLE):
5016 if self.algoType == NETGEN:
5018 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
5019 "libNETGENEngine.so", UseExisting=0)
5021 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
5022 "libNETGENEngine.so", UseExisting=0)
5023 elif self.algoType == MEFISTO:
5024 print "Mefisto algo support no multi-parameter hypothesis"
5025 elif self.algoType == NETGEN_2D:
5026 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
5027 "libNETGENEngine.so", UseExisting=0)
5028 elif self.algoType == BLSURF:
5029 self.params = self.Hypothesis("BLSURF_Parameters", [],
5030 "libBLSURFEngine.so", UseExisting=0)
5032 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
5037 # Only for algoType == NETGEN
5038 # @ingroup l3_hypos_netgen
5039 def SetMaxSize(self, theSize):
5040 if self.Parameters():
5041 self.params.SetMaxSize(theSize)
5043 ## Sets SecondOrder flag
5045 # Only for algoType == NETGEN
5046 # @ingroup l3_hypos_netgen
5047 def SetSecondOrder(self, theVal):
5048 if self.Parameters():
5049 self.params.SetSecondOrder(theVal)
5051 ## Sets Optimize flag
5053 # Only for algoType == NETGEN
5054 # @ingroup l3_hypos_netgen
5055 def SetOptimize(self, theVal):
5056 if self.Parameters():
5057 self.params.SetOptimize(theVal)
5060 # @param theFineness is:
5061 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5063 # Only for algoType == NETGEN
5064 # @ingroup l3_hypos_netgen
5065 def SetFineness(self, theFineness):
5066 if self.Parameters():
5067 self.params.SetFineness(theFineness)
5071 # Only for algoType == NETGEN
5072 # @ingroup l3_hypos_netgen
5073 def SetGrowthRate(self, theRate):
5074 if self.Parameters():
5075 self.params.SetGrowthRate(theRate)
5077 ## Sets NbSegPerEdge
5079 # Only for algoType == NETGEN
5080 # @ingroup l3_hypos_netgen
5081 def SetNbSegPerEdge(self, theVal):
5082 if self.Parameters():
5083 self.params.SetNbSegPerEdge(theVal)
5085 ## Sets NbSegPerRadius
5087 # Only for algoType == NETGEN
5088 # @ingroup l3_hypos_netgen
5089 def SetNbSegPerRadius(self, theVal):
5090 if self.Parameters():
5091 self.params.SetNbSegPerRadius(theVal)
5093 ## Sets number of segments overriding value set by SetLocalLength()
5095 # Only for algoType == NETGEN
5096 # @ingroup l3_hypos_netgen
5097 def SetNumberOfSegments(self, theVal):
5098 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5100 ## Sets number of segments overriding value set by SetNumberOfSegments()
5102 # Only for algoType == NETGEN
5103 # @ingroup l3_hypos_netgen
5104 def SetLocalLength(self, theVal):
5105 self.Parameters(SIMPLE).SetLocalLength(theVal)
5110 # Public class: Mesh_Quadrangle
5111 # -----------------------------
5113 ## Defines a quadrangle 2D algorithm
5115 # @ingroup l3_algos_basic
5116 class Mesh_Quadrangle(Mesh_Algorithm):
5120 ## Private constructor.
5121 def __init__(self, mesh, geom=0):
5122 Mesh_Algorithm.__init__(self)
5123 self.Create(mesh, geom, "Quadrangle_2D")
5126 ## Defines "QuadrangleParameters" hypothesis
5127 # @param quadType defines the algorithm of transition between differently descretized
5128 # sides of a geometrical face:
5129 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5130 # area along the finer meshed sides.
5131 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5132 # finer meshed sides.
5133 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5134 # the finer meshed sides, iff the total quantity of segments on
5135 # all four sides of the face is even (divisible by 2).
5136 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5137 # area is located along the coarser meshed sides.
5138 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5139 # is made gradually, layer by layer. This type has a limitation on
5140 # the number of segments: one pair of opposite sides must have the
5141 # same number of segments, the other pair must have an even difference
5142 # between the numbers of segments on the sides.
5143 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5144 # will be created while other elements will be quadrangles.
5145 # Vertex can be either a GEOM_Object or a vertex ID within the
5147 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5148 # the same parameters, else (default) - creates a new one
5149 # @ingroup l3_hypos_quad
5150 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5151 vertexID = triangleVertex
5152 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5153 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5155 compFun = lambda hyp,args: \
5156 hyp.GetQuadType() == args[0] and \
5157 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5158 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5159 UseExisting = UseExisting, CompareMethod=compFun)
5161 if self.params.GetQuadType() != quadType:
5162 self.params.SetQuadType(quadType)
5164 self.params.SetTriaVertex( vertexID )
5167 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5168 # quadrangles are built in the transition area along the finer meshed sides,
5169 # iff the total quantity of segments on all four sides of the face is even.
5170 # @param reversed if True, transition area is located along the coarser meshed sides.
5171 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5172 # the same parameters, else (default) - creates a new one
5173 # @ingroup l3_hypos_quad
5174 def QuadranglePreference(self, reversed=False, UseExisting=0):
5176 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5177 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5179 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5180 # triangles are built in the transition area along the finer meshed sides.
5181 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5182 # the same parameters, else (default) - creates a new one
5183 # @ingroup l3_hypos_quad
5184 def TrianglePreference(self, UseExisting=0):
5185 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5187 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5188 # quadrangles are built and the transition between the sides is made gradually,
5189 # layer by layer. This type has a limitation on the number of segments: one pair
5190 # of opposite sides must have the same number of segments, the other pair must
5191 # have an even difference between the numbers of segments on the sides.
5192 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5193 # the same parameters, else (default) - creates a new one
5194 # @ingroup l3_hypos_quad
5195 def Reduced(self, UseExisting=0):
5196 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5198 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5199 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5200 # will be created while other elements will be quadrangles.
5201 # Vertex can be either a GEOM_Object or a vertex ID within the
5203 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5204 # the same parameters, else (default) - creates a new one
5205 # @ingroup l3_hypos_quad
5206 def TriangleVertex(self, vertex, UseExisting=0):
5207 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5210 # Public class: Mesh_Tetrahedron
5211 # ------------------------------
5213 ## Defines a tetrahedron 3D algorithm
5215 # @ingroup l3_algos_basic
5216 class Mesh_Tetrahedron(Mesh_Algorithm):
5221 ## Private constructor.
5222 def __init__(self, mesh, algoType, geom=0):
5223 Mesh_Algorithm.__init__(self)
5225 if algoType == NETGEN:
5227 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5230 elif algoType == FULL_NETGEN:
5232 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5235 elif algoType == GHS3D:
5237 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5240 elif algoType == GHS3DPRL:
5241 CheckPlugin(GHS3DPRL)
5242 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5245 self.algoType = algoType
5247 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5248 # @param vol for the maximum volume of each tetrahedron
5249 # @param UseExisting if ==true - searches for the existing hypothesis created with
5250 # the same parameters, else (default) - creates a new one
5251 # @ingroup l3_hypos_maxvol
5252 def MaxElementVolume(self, vol, UseExisting=0):
5253 if self.algoType == NETGEN:
5254 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5255 CompareMethod=self.CompareMaxElementVolume)
5256 hyp.SetMaxElementVolume(vol)
5258 elif self.algoType == FULL_NETGEN:
5259 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5262 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5263 def CompareMaxElementVolume(self, hyp, args):
5264 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5266 ## Defines hypothesis having several parameters
5268 # @ingroup l3_hypos_netgen
5269 def Parameters(self, which=SOLE):
5272 if self.algoType == FULL_NETGEN:
5274 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5275 "libNETGENEngine.so", UseExisting=0)
5277 self.params = self.Hypothesis("NETGEN_Parameters", [],
5278 "libNETGENEngine.so", UseExisting=0)
5280 if self.algoType == NETGEN:
5281 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5282 "libNETGENEngine.so", UseExisting=0)
5284 elif self.algoType == GHS3D:
5285 self.params = self.Hypothesis("GHS3D_Parameters", [],
5286 "libGHS3DEngine.so", UseExisting=0)
5288 elif self.algoType == GHS3DPRL:
5289 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5290 "libGHS3DPRLEngine.so", UseExisting=0)
5292 print "Algo supports no multi-parameter hypothesis"
5297 # Parameter of FULL_NETGEN and NETGEN
5298 # @ingroup l3_hypos_netgen
5299 def SetMaxSize(self, theSize):
5300 self.Parameters().SetMaxSize(theSize)
5302 ## Sets SecondOrder flag
5303 # Parameter of FULL_NETGEN
5304 # @ingroup l3_hypos_netgen
5305 def SetSecondOrder(self, theVal):
5306 self.Parameters().SetSecondOrder(theVal)
5308 ## Sets Optimize flag
5309 # Parameter of FULL_NETGEN and NETGEN
5310 # @ingroup l3_hypos_netgen
5311 def SetOptimize(self, theVal):
5312 self.Parameters().SetOptimize(theVal)
5315 # @param theFineness is:
5316 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5317 # Parameter of FULL_NETGEN
5318 # @ingroup l3_hypos_netgen
5319 def SetFineness(self, theFineness):
5320 self.Parameters().SetFineness(theFineness)
5323 # Parameter of FULL_NETGEN
5324 # @ingroup l3_hypos_netgen
5325 def SetGrowthRate(self, theRate):
5326 self.Parameters().SetGrowthRate(theRate)
5328 ## Sets NbSegPerEdge
5329 # Parameter of FULL_NETGEN
5330 # @ingroup l3_hypos_netgen
5331 def SetNbSegPerEdge(self, theVal):
5332 self.Parameters().SetNbSegPerEdge(theVal)
5334 ## Sets NbSegPerRadius
5335 # Parameter of FULL_NETGEN
5336 # @ingroup l3_hypos_netgen
5337 def SetNbSegPerRadius(self, theVal):
5338 self.Parameters().SetNbSegPerRadius(theVal)
5340 ## Sets number of segments overriding value set by SetLocalLength()
5341 # Only for algoType == NETGEN_FULL
5342 # @ingroup l3_hypos_netgen
5343 def SetNumberOfSegments(self, theVal):
5344 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5346 ## Sets number of segments overriding value set by SetNumberOfSegments()
5347 # Only for algoType == NETGEN_FULL
5348 # @ingroup l3_hypos_netgen
5349 def SetLocalLength(self, theVal):
5350 self.Parameters(SIMPLE).SetLocalLength(theVal)
5352 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5353 # Overrides value set by LengthFromEdges()
5354 # Only for algoType == NETGEN_FULL
5355 # @ingroup l3_hypos_netgen
5356 def MaxElementArea(self, area):
5357 self.Parameters(SIMPLE).SetMaxElementArea(area)
5359 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5360 # Overrides value set by MaxElementArea()
5361 # Only for algoType == NETGEN_FULL
5362 # @ingroup l3_hypos_netgen
5363 def LengthFromEdges(self):
5364 self.Parameters(SIMPLE).LengthFromEdges()
5366 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5367 # Overrides value set by MaxElementVolume()
5368 # Only for algoType == NETGEN_FULL
5369 # @ingroup l3_hypos_netgen
5370 def LengthFromFaces(self):
5371 self.Parameters(SIMPLE).LengthFromFaces()
5373 ## To mesh "holes" in a solid or not. Default is to mesh.
5374 # @ingroup l3_hypos_ghs3dh
5375 def SetToMeshHoles(self, toMesh):
5376 # Parameter of GHS3D
5377 self.Parameters().SetToMeshHoles(toMesh)
5379 ## Set Optimization level:
5380 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5381 # Strong_Optimization.
5382 # Default is Standard_Optimization
5383 # @ingroup l3_hypos_ghs3dh
5384 def SetOptimizationLevel(self, level):
5385 # Parameter of GHS3D
5386 self.Parameters().SetOptimizationLevel(level)
5388 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5389 # @ingroup l3_hypos_ghs3dh
5390 def SetMaximumMemory(self, MB):
5391 # Advanced parameter of GHS3D
5392 self.Parameters().SetMaximumMemory(MB)
5394 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5395 # automatic memory adjustment mode.
5396 # @ingroup l3_hypos_ghs3dh
5397 def SetInitialMemory(self, MB):
5398 # Advanced parameter of GHS3D
5399 self.Parameters().SetInitialMemory(MB)
5401 ## Path to working directory.
5402 # @ingroup l3_hypos_ghs3dh
5403 def SetWorkingDirectory(self, path):
5404 # Advanced parameter of GHS3D
5405 self.Parameters().SetWorkingDirectory(path)
5407 ## To keep working files or remove them. Log file remains in case of errors anyway.
5408 # @ingroup l3_hypos_ghs3dh
5409 def SetKeepFiles(self, toKeep):
5410 # Advanced parameter of GHS3D and GHS3DPRL
5411 self.Parameters().SetKeepFiles(toKeep)
5413 ## To set verbose level [0-10]. <ul>
5414 #<li> 0 - no standard output,
5415 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5416 # indicates when the final mesh is being saved. In addition the software
5417 # gives indication regarding the CPU time.
5418 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5419 # histogram of the skin mesh, quality statistics histogram together with
5420 # the characteristics of the final mesh.</ul>
5421 # @ingroup l3_hypos_ghs3dh
5422 def SetVerboseLevel(self, level):
5423 # Advanced parameter of GHS3D
5424 self.Parameters().SetVerboseLevel(level)
5426 ## To create new nodes.
5427 # @ingroup l3_hypos_ghs3dh
5428 def SetToCreateNewNodes(self, toCreate):
5429 # Advanced parameter of GHS3D
5430 self.Parameters().SetToCreateNewNodes(toCreate)
5432 ## To use boundary recovery version which tries to create mesh on a very poor
5433 # quality surface mesh.
5434 # @ingroup l3_hypos_ghs3dh
5435 def SetToUseBoundaryRecoveryVersion(self, toUse):
5436 # Advanced parameter of GHS3D
5437 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5439 ## Sets command line option as text.
5440 # @ingroup l3_hypos_ghs3dh
5441 def SetTextOption(self, option):
5442 # Advanced parameter of GHS3D
5443 self.Parameters().SetTextOption(option)
5445 ## Sets MED files name and path.
5446 def SetMEDName(self, value):
5447 self.Parameters().SetMEDName(value)
5449 ## Sets the number of partition of the initial mesh
5450 def SetNbPart(self, value):
5451 self.Parameters().SetNbPart(value)
5453 ## When big mesh, start tepal in background
5454 def SetBackground(self, value):
5455 self.Parameters().SetBackground(value)
5457 # Public class: Mesh_Hexahedron
5458 # ------------------------------
5460 ## Defines a hexahedron 3D algorithm
5462 # @ingroup l3_algos_basic
5463 class Mesh_Hexahedron(Mesh_Algorithm):
5468 ## Private constructor.
5469 def __init__(self, mesh, algoType=Hexa, geom=0):
5470 Mesh_Algorithm.__init__(self)
5472 self.algoType = algoType
5474 if algoType == Hexa:
5475 self.Create(mesh, geom, "Hexa_3D")
5478 elif algoType == Hexotic:
5479 CheckPlugin(Hexotic)
5480 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5483 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5484 # @ingroup l3_hypos_hexotic
5485 def MinMaxQuad(self, min=3, max=8, quad=True):
5486 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5488 self.params.SetHexesMinLevel(min)
5489 self.params.SetHexesMaxLevel(max)
5490 self.params.SetHexoticQuadrangles(quad)
5493 # Deprecated, only for compatibility!
5494 # Public class: Mesh_Netgen
5495 # ------------------------------
5497 ## Defines a NETGEN-based 2D or 3D algorithm
5498 # that needs no discrete boundary (i.e. independent)
5500 # This class is deprecated, only for compatibility!
5503 # @ingroup l3_algos_basic
5504 class Mesh_Netgen(Mesh_Algorithm):
5508 ## Private constructor.
5509 def __init__(self, mesh, is3D, geom=0):
5510 Mesh_Algorithm.__init__(self)
5516 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5520 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5523 ## Defines the hypothesis containing parameters of the algorithm
5524 def Parameters(self):
5526 hyp = self.Hypothesis("NETGEN_Parameters", [],
5527 "libNETGENEngine.so", UseExisting=0)
5529 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5530 "libNETGENEngine.so", UseExisting=0)
5533 # Public class: Mesh_Projection1D
5534 # ------------------------------
5536 ## Defines a projection 1D algorithm
5537 # @ingroup l3_algos_proj
5539 class Mesh_Projection1D(Mesh_Algorithm):
5541 ## Private constructor.
5542 def __init__(self, mesh, geom=0):
5543 Mesh_Algorithm.__init__(self)
5544 self.Create(mesh, geom, "Projection_1D")
5546 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5547 # a mesh pattern is taken, and, optionally, the association of vertices
5548 # between the source edge and a target edge (to which a hypothesis is assigned)
5549 # @param edge from which nodes distribution is taken
5550 # @param mesh from which nodes distribution is taken (optional)
5551 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5552 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5553 # to associate with \a srcV (optional)
5554 # @param UseExisting if ==true - searches for the existing hypothesis created with
5555 # the same parameters, else (default) - creates a new one
5556 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5557 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5559 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5560 hyp.SetSourceEdge( edge )
5561 if not mesh is None and isinstance(mesh, Mesh):
5562 mesh = mesh.GetMesh()
5563 hyp.SetSourceMesh( mesh )
5564 hyp.SetVertexAssociation( srcV, tgtV )
5567 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5568 #def CompareSourceEdge(self, hyp, args):
5569 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5573 # Public class: Mesh_Projection2D
5574 # ------------------------------
5576 ## Defines a projection 2D algorithm
5577 # @ingroup l3_algos_proj
5579 class Mesh_Projection2D(Mesh_Algorithm):
5581 ## Private constructor.
5582 def __init__(self, mesh, geom=0):
5583 Mesh_Algorithm.__init__(self)
5584 self.Create(mesh, geom, "Projection_2D")
5586 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5587 # a mesh pattern is taken, and, optionally, the association of vertices
5588 # between the source face and the target face (to which a hypothesis is assigned)
5589 # @param face from which the mesh pattern is taken
5590 # @param mesh from which the mesh pattern is taken (optional)
5591 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5592 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5593 # to associate with \a srcV1 (optional)
5594 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5595 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5596 # to associate with \a srcV2 (optional)
5597 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5598 # the same parameters, else (default) - forces the creation a new one
5600 # Note: all association vertices must belong to one edge of a face
5601 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5602 srcV2=None, tgtV2=None, UseExisting=0):
5603 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5605 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5606 hyp.SetSourceFace( face )
5607 if not mesh is None and isinstance(mesh, Mesh):
5608 mesh = mesh.GetMesh()
5609 hyp.SetSourceMesh( mesh )
5610 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5613 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5614 #def CompareSourceFace(self, hyp, args):
5615 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5618 # Public class: Mesh_Projection3D
5619 # ------------------------------
5621 ## Defines a projection 3D algorithm
5622 # @ingroup l3_algos_proj
5624 class Mesh_Projection3D(Mesh_Algorithm):
5626 ## Private constructor.
5627 def __init__(self, mesh, geom=0):
5628 Mesh_Algorithm.__init__(self)
5629 self.Create(mesh, geom, "Projection_3D")
5631 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5632 # the mesh pattern is taken, and, optionally, the association of vertices
5633 # between the source and the target solid (to which a hipothesis is assigned)
5634 # @param solid from where the mesh pattern is taken
5635 # @param mesh from where the mesh pattern is taken (optional)
5636 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5637 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5638 # to associate with \a srcV1 (optional)
5639 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5640 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5641 # to associate with \a srcV2 (optional)
5642 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5643 # the same parameters, else (default) - creates a new one
5645 # Note: association vertices must belong to one edge of a solid
5646 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5647 srcV2=0, tgtV2=0, UseExisting=0):
5648 hyp = self.Hypothesis("ProjectionSource3D",
5649 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5651 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5652 hyp.SetSource3DShape( solid )
5653 if not mesh is None and isinstance(mesh, Mesh):
5654 mesh = mesh.GetMesh()
5655 hyp.SetSourceMesh( mesh )
5656 if srcV1 and srcV2 and tgtV1 and tgtV2:
5657 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5658 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5661 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5662 #def CompareSourceShape3D(self, hyp, args):
5663 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5667 # Public class: Mesh_Prism
5668 # ------------------------
5670 ## Defines a 3D extrusion algorithm
5671 # @ingroup l3_algos_3dextr
5673 class Mesh_Prism3D(Mesh_Algorithm):
5675 ## Private constructor.
5676 def __init__(self, mesh, geom=0):
5677 Mesh_Algorithm.__init__(self)
5678 self.Create(mesh, geom, "Prism_3D")
5680 # Public class: Mesh_RadialPrism
5681 # -------------------------------
5683 ## Defines a Radial Prism 3D algorithm
5684 # @ingroup l3_algos_radialp
5686 class Mesh_RadialPrism3D(Mesh_Algorithm):
5688 ## Private constructor.
5689 def __init__(self, mesh, geom=0):
5690 Mesh_Algorithm.__init__(self)
5691 self.Create(mesh, geom, "RadialPrism_3D")
5693 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5694 self.nbLayers = None
5696 ## Return 3D hypothesis holding the 1D one
5697 def Get3DHypothesis(self):
5698 return self.distribHyp
5700 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5701 # hypothesis. Returns the created hypothesis
5702 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5703 #print "OwnHypothesis",hypType
5704 if not self.nbLayers is None:
5705 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5706 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5707 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5708 self.mesh.smeshpyD.SetCurrentStudy( None )
5709 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5710 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5711 self.distribHyp.SetLayerDistribution( hyp )
5714 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5715 # prisms to build between the inner and outer shells
5716 # @param n number of layers
5717 # @param UseExisting if ==true - searches for the existing hypothesis created with
5718 # the same parameters, else (default) - creates a new one
5719 def NumberOfLayers(self, n, UseExisting=0):
5720 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5721 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5722 CompareMethod=self.CompareNumberOfLayers)
5723 self.nbLayers.SetNumberOfLayers( n )
5724 return self.nbLayers
5726 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5727 def CompareNumberOfLayers(self, hyp, args):
5728 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5730 ## Defines "LocalLength" hypothesis, specifying the segment length
5731 # to build between the inner and the outer shells
5732 # @param l the length of segments
5733 # @param p the precision of rounding
5734 def LocalLength(self, l, p=1e-07):
5735 hyp = self.OwnHypothesis("LocalLength", [l,p])
5740 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5741 # prisms to build between the inner and the outer shells.
5742 # @param n the number of layers
5743 # @param s the scale factor (optional)
5744 def NumberOfSegments(self, n, s=[]):
5746 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5748 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5749 hyp.SetDistrType( 1 )
5750 hyp.SetScaleFactor(s)
5751 hyp.SetNumberOfSegments(n)
5754 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5755 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5756 # @param start the length of the first segment
5757 # @param end the length of the last segment
5758 def Arithmetic1D(self, start, end ):
5759 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5760 hyp.SetLength(start, 1)
5761 hyp.SetLength(end , 0)
5764 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5765 # to build between the inner and the outer shells as geometric length increasing
5766 # @param start for the length of the first segment
5767 # @param end for the length of the last segment
5768 def StartEndLength(self, start, end):
5769 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5770 hyp.SetLength(start, 1)
5771 hyp.SetLength(end , 0)
5774 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5775 # to build between the inner and outer shells
5776 # @param fineness defines the quality of the mesh within the range [0-1]
5777 def AutomaticLength(self, fineness=0):
5778 hyp = self.OwnHypothesis("AutomaticLength")
5779 hyp.SetFineness( fineness )
5782 # Public class: Mesh_RadialQuadrangle1D2D
5783 # -------------------------------
5785 ## Defines a Radial Quadrangle 1D2D algorithm
5786 # @ingroup l2_algos_radialq
5788 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5790 ## Private constructor.
5791 def __init__(self, mesh, geom=0):
5792 Mesh_Algorithm.__init__(self)
5793 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5795 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5796 self.nbLayers = None
5798 ## Return 2D hypothesis holding the 1D one
5799 def Get2DHypothesis(self):
5800 return self.distribHyp
5802 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5803 # hypothesis. Returns the created hypothesis
5804 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5805 #print "OwnHypothesis",hypType
5807 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5808 if self.distribHyp is None:
5809 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5811 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5812 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5813 self.mesh.smeshpyD.SetCurrentStudy( None )
5814 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5815 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5816 self.distribHyp.SetLayerDistribution( hyp )
5819 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5820 # @param n number of layers
5821 # @param UseExisting if ==true - searches for the existing hypothesis created with
5822 # the same parameters, else (default) - creates a new one
5823 def NumberOfLayers(self, n, UseExisting=0):
5825 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5826 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5827 CompareMethod=self.CompareNumberOfLayers)
5828 self.nbLayers.SetNumberOfLayers( n )
5829 return self.nbLayers
5831 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5832 def CompareNumberOfLayers(self, hyp, args):
5833 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5835 ## Defines "LocalLength" hypothesis, specifying the segment length
5836 # @param l the length of segments
5837 # @param p the precision of rounding
5838 def LocalLength(self, l, p=1e-07):
5839 hyp = self.OwnHypothesis("LocalLength", [l,p])
5844 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5845 # @param n the number of layers
5846 # @param s the scale factor (optional)
5847 def NumberOfSegments(self, n, s=[]):
5849 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5851 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5852 hyp.SetDistrType( 1 )
5853 hyp.SetScaleFactor(s)
5854 hyp.SetNumberOfSegments(n)
5857 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5858 # with a length that changes in arithmetic progression
5859 # @param start the length of the first segment
5860 # @param end the length of the last segment
5861 def Arithmetic1D(self, start, end ):
5862 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5863 hyp.SetLength(start, 1)
5864 hyp.SetLength(end , 0)
5867 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5868 # as geometric length increasing
5869 # @param start for the length of the first segment
5870 # @param end for the length of the last segment
5871 def StartEndLength(self, start, end):
5872 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5873 hyp.SetLength(start, 1)
5874 hyp.SetLength(end , 0)
5877 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5878 # @param fineness defines the quality of the mesh within the range [0-1]
5879 def AutomaticLength(self, fineness=0):
5880 hyp = self.OwnHypothesis("AutomaticLength")
5881 hyp.SetFineness( fineness )
5885 # Public class: Mesh_UseExistingElements
5886 # --------------------------------------
5887 ## Defines a Radial Quadrangle 1D2D algorithm
5888 # @ingroup l3_algos_basic
5890 class Mesh_UseExistingElements(Mesh_Algorithm):
5892 def __init__(self, dim, mesh, geom=0):
5894 self.Create(mesh, geom, "Import_1D")
5896 self.Create(mesh, geom, "Import_1D2D")
5899 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5900 # @param groups list of groups of edges
5901 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5902 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5903 # @param UseExisting if ==true - searches for the existing hypothesis created with
5904 # the same parameters, else (default) - creates a new one
5905 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5906 if self.algo.GetName() == "Import_2D":
5907 raise ValueError, "algoritm dimension mismatch"
5908 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5909 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5910 hyp.SetSourceEdges(groups)
5911 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5914 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5915 # @param groups list of groups of faces
5916 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5917 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5918 # @param UseExisting if ==true - searches for the existing hypothesis created with
5919 # the same parameters, else (default) - creates a new one
5920 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5921 if self.algo.GetName() == "Import_1D":
5922 raise ValueError, "algoritm dimension mismatch"
5923 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5924 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5925 hyp.SetSourceFaces(groups)
5926 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5929 def _compareHyp(self,hyp,args):
5930 if hasattr( hyp, "GetSourceEdges"):
5931 entries = hyp.GetSourceEdges()
5933 entries = hyp.GetSourceFaces()
5935 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5936 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5938 study = self.mesh.smeshpyD.GetCurrentStudy()
5941 ior = salome.orb.object_to_string(g)
5942 sobj = study.FindObjectIOR(ior)
5943 if sobj: entries2.append( sobj.GetID() )
5948 return entries == entries2
5952 # Private class: Mesh_UseExisting
5953 # -------------------------------
5954 class Mesh_UseExisting(Mesh_Algorithm):
5956 def __init__(self, dim, mesh, geom=0):
5958 self.Create(mesh, geom, "UseExisting_1D")
5960 self.Create(mesh, geom, "UseExisting_2D")
5963 import salome_notebook
5964 notebook = salome_notebook.notebook
5966 ##Return values of the notebook variables
5967 def ParseParameters(last, nbParams,nbParam, value):
5971 listSize = len(last)
5972 for n in range(0,nbParams):
5974 if counter < listSize:
5975 strResult = strResult + last[counter]
5977 strResult = strResult + ""
5979 if isinstance(value, str):
5980 if notebook.isVariable(value):
5981 result = notebook.get(value)
5982 strResult=strResult+value
5984 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5986 strResult=strResult+str(value)
5988 if nbParams - 1 != counter:
5989 strResult=strResult+var_separator #":"
5991 return result, strResult
5993 #Wrapper class for StdMeshers_LocalLength hypothesis
5994 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5996 ## Set Length parameter value
5997 # @param length numerical value or name of variable from notebook
5998 def SetLength(self, length):
5999 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
6000 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6001 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
6003 ## Set Precision parameter value
6004 # @param precision numerical value or name of variable from notebook
6005 def SetPrecision(self, precision):
6006 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
6007 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
6008 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
6010 #Registering the new proxy for LocalLength
6011 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
6014 #Wrapper class for StdMeshers_LayerDistribution hypothesis
6015 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
6017 def SetLayerDistribution(self, hypo):
6018 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
6019 hypo.ClearParameters();
6020 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
6022 #Registering the new proxy for LayerDistribution
6023 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
6025 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
6026 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
6028 ## Set Length parameter value
6029 # @param length numerical value or name of variable from notebook
6030 def SetLength(self, length):
6031 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
6032 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
6033 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
6035 #Registering the new proxy for SegmentLengthAroundVertex
6036 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
6039 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
6040 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
6042 ## Set Length parameter value
6043 # @param length numerical value or name of variable from notebook
6044 # @param isStart true is length is Start Length, otherwise false
6045 def SetLength(self, length, isStart):
6049 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6050 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6051 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6053 #Registering the new proxy for Arithmetic1D
6054 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6056 #Wrapper class for StdMeshers_Deflection1D hypothesis
6057 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6059 ## Set Deflection parameter value
6060 # @param deflection numerical value or name of variable from notebook
6061 def SetDeflection(self, deflection):
6062 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6063 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6064 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6066 #Registering the new proxy for Deflection1D
6067 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6069 #Wrapper class for StdMeshers_StartEndLength hypothesis
6070 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6072 ## Set Length parameter value
6073 # @param length numerical value or name of variable from notebook
6074 # @param isStart true is length is Start Length, otherwise false
6075 def SetLength(self, length, isStart):
6079 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6080 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6081 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6083 #Registering the new proxy for StartEndLength
6084 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6086 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6087 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6089 ## Set Max Element Area parameter value
6090 # @param area numerical value or name of variable from notebook
6091 def SetMaxElementArea(self, area):
6092 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6093 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6094 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6096 #Registering the new proxy for MaxElementArea
6097 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6100 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6101 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6103 ## Set Max Element Volume parameter value
6104 # @param volume numerical value or name of variable from notebook
6105 def SetMaxElementVolume(self, volume):
6106 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6107 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6108 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6110 #Registering the new proxy for MaxElementVolume
6111 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6114 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6115 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6117 ## Set Number Of Layers parameter value
6118 # @param nbLayers numerical value or name of variable from notebook
6119 def SetNumberOfLayers(self, nbLayers):
6120 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6121 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6122 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6124 #Registering the new proxy for NumberOfLayers
6125 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6127 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6128 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6130 ## Set Number Of Segments parameter value
6131 # @param nbSeg numerical value or name of variable from notebook
6132 def SetNumberOfSegments(self, nbSeg):
6133 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6134 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6135 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6136 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6138 ## Set Scale Factor parameter value
6139 # @param factor numerical value or name of variable from notebook
6140 def SetScaleFactor(self, factor):
6141 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6142 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6143 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6145 #Registering the new proxy for NumberOfSegments
6146 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6148 if not noNETGENPlugin:
6149 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6150 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6152 ## Set Max Size parameter value
6153 # @param maxsize numerical value or name of variable from notebook
6154 def SetMaxSize(self, maxsize):
6155 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6156 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6157 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6158 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6160 ## Set Growth Rate parameter value
6161 # @param value numerical value or name of variable from notebook
6162 def SetGrowthRate(self, value):
6163 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6164 value, parameters = ParseParameters(lastParameters,4,2,value)
6165 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6166 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6168 ## Set Number of Segments per Edge parameter value
6169 # @param value numerical value or name of variable from notebook
6170 def SetNbSegPerEdge(self, value):
6171 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6172 value, parameters = ParseParameters(lastParameters,4,3,value)
6173 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6174 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6176 ## Set Number of Segments per Radius parameter value
6177 # @param value numerical value or name of variable from notebook
6178 def SetNbSegPerRadius(self, value):
6179 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6180 value, parameters = ParseParameters(lastParameters,4,4,value)
6181 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6182 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6184 #Registering the new proxy for NETGENPlugin_Hypothesis
6185 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6188 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6189 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6192 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6193 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6195 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6196 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6198 ## Set Number of Segments parameter value
6199 # @param nbSeg numerical value or name of variable from notebook
6200 def SetNumberOfSegments(self, nbSeg):
6201 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6202 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6203 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6204 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6206 ## Set Local Length parameter value
6207 # @param length numerical value or name of variable from notebook
6208 def SetLocalLength(self, length):
6209 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6210 length, parameters = ParseParameters(lastParameters,2,1,length)
6211 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6212 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6214 ## Set Max Element Area parameter value
6215 # @param area numerical value or name of variable from notebook
6216 def SetMaxElementArea(self, area):
6217 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6218 area, parameters = ParseParameters(lastParameters,2,2,area)
6219 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6220 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6222 def LengthFromEdges(self):
6223 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6225 value, parameters = ParseParameters(lastParameters,2,2,value)
6226 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6227 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6229 #Registering the new proxy for NETGEN_SimpleParameters_2D
6230 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6233 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6234 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6235 ## Set Max Element Volume parameter value
6236 # @param volume numerical value or name of variable from notebook
6237 def SetMaxElementVolume(self, volume):
6238 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6239 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6240 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6241 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6243 def LengthFromFaces(self):
6244 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6246 value, parameters = ParseParameters(lastParameters,3,3,value)
6247 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6248 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6250 #Registering the new proxy for NETGEN_SimpleParameters_3D
6251 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6253 pass # if not noNETGENPlugin:
6255 class Pattern(SMESH._objref_SMESH_Pattern):
6257 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6259 if isinstance(theNodeIndexOnKeyPoint1,str):
6261 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6263 theNodeIndexOnKeyPoint1 -= 1
6264 theMesh.SetParameters(Parameters)
6265 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6267 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6270 if isinstance(theNode000Index,str):
6272 if isinstance(theNode001Index,str):
6274 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6276 theNode000Index -= 1
6278 theNode001Index -= 1
6279 theMesh.SetParameters(Parameters)
6280 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6282 #Registering the new proxy for Pattern
6283 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)