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 self.mesh = self.smeshpyD.CreateMesh(self.geom)
1085 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
1088 self.mesh = self.smeshpyD.CreateEmptyMesh()
1090 self.smeshpyD.SetName(self.mesh, name)
1092 self.smeshpyD.SetName(self.mesh, GetName(obj))
1095 self.geom = self.mesh.GetShapeToMesh()
1097 self.editor = self.mesh.GetMeshEditor()
1099 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
1100 # @param theMesh a SMESH_Mesh object
1101 # @ingroup l2_construct
1102 def SetMesh(self, theMesh):
1104 self.geom = self.mesh.GetShapeToMesh()
1106 ## Returns the mesh, that is an instance of SMESH_Mesh interface
1107 # @return a SMESH_Mesh object
1108 # @ingroup l2_construct
1112 ## Gets the name of the mesh
1113 # @return the name of the mesh as a string
1114 # @ingroup l2_construct
1116 name = GetName(self.GetMesh())
1119 ## Sets a name to the mesh
1120 # @param name a new name of the mesh
1121 # @ingroup l2_construct
1122 def SetName(self, name):
1123 self.smeshpyD.SetName(self.GetMesh(), name)
1125 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
1126 # The subMesh object gives access to the IDs of nodes and elements.
1127 # @param theSubObject a geometrical object (shape)
1128 # @param theName a name for the submesh
1129 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
1130 # @ingroup l2_submeshes
1131 def GetSubMesh(self, theSubObject, theName):
1132 submesh = self.mesh.GetSubMesh(theSubObject, theName)
1135 ## Returns the shape associated to the mesh
1136 # @return a GEOM_Object
1137 # @ingroup l2_construct
1141 ## Associates the given shape to the mesh (entails the recreation of the mesh)
1142 # @param geom the shape to be meshed (GEOM_Object)
1143 # @ingroup l2_construct
1144 def SetShape(self, geom):
1145 self.mesh = self.smeshpyD.CreateMesh(geom)
1147 ## Returns true if the hypotheses are defined well
1148 # @param theSubObject a subshape of a mesh shape
1149 # @return True or False
1150 # @ingroup l2_construct
1151 def IsReadyToCompute(self, theSubObject):
1152 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
1154 ## Returns errors of hypotheses definition.
1155 # The list of errors is empty if everything is OK.
1156 # @param theSubObject a subshape of a mesh shape
1157 # @return a list of errors
1158 # @ingroup l2_construct
1159 def GetAlgoState(self, theSubObject):
1160 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
1162 ## Returns a geometrical object on which the given element was built.
1163 # The returned geometrical object, if not nil, is either found in the
1164 # study or published by this method with the given name
1165 # @param theElementID the id of the mesh element
1166 # @param theGeomName the user-defined name of the geometrical object
1167 # @return GEOM::GEOM_Object instance
1168 # @ingroup l2_construct
1169 def GetGeometryByMeshElement(self, theElementID, theGeomName):
1170 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
1172 ## Returns the mesh dimension depending on the dimension of the underlying shape
1173 # @return mesh dimension as an integer value [0,3]
1174 # @ingroup l1_auxiliary
1175 def MeshDimension(self):
1176 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
1177 if len( shells ) > 0 :
1179 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
1181 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
1187 ## Creates a segment discretization 1D algorithm.
1188 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1189 # \n If the optional \a geom parameter is not set, this algorithm is global.
1190 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1191 # @param algo the type of the required algorithm. Possible values are:
1193 # - smesh.PYTHON for discretization via a python function,
1194 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1195 # @param geom If defined is the subshape to be meshed
1196 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1197 # @ingroup l3_algos_basic
1198 def Segment(self, algo=REGULAR, geom=0):
1199 ## if Segment(geom) is called by mistake
1200 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1201 algo, geom = geom, algo
1202 if not algo: algo = REGULAR
1205 return Mesh_Segment(self, geom)
1206 elif algo == PYTHON:
1207 return Mesh_Segment_Python(self, geom)
1208 elif algo == COMPOSITE:
1209 return Mesh_CompositeSegment(self, geom)
1211 return Mesh_Segment(self, geom)
1213 ## Creates 1D algorithm importing segments conatined in groups of other mesh.
1214 # If the optional \a geom parameter is not set, this algorithm is global.
1215 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1216 # @param geom If defined the subshape is to be meshed
1217 # @return an instance of Mesh_UseExistingElements class
1218 # @ingroup l3_algos_basic
1219 def UseExisting1DElements(self, geom=0):
1220 return Mesh_UseExistingElements(1,self, geom)
1222 ## Creates 2D algorithm importing faces 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 UseExisting2DElements(self, geom=0):
1229 return Mesh_UseExistingElements(2,self, geom)
1231 ## Enables creation of nodes and segments usable by 2D algoritms.
1232 # The added nodes and segments must be bound to edges and vertices by
1233 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1234 # If the optional \a geom parameter is not set, this algorithm is global.
1235 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1236 # @param geom the subshape to be manually meshed
1237 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1238 # @ingroup l3_algos_basic
1239 def UseExistingSegments(self, geom=0):
1240 algo = Mesh_UseExisting(1,self,geom)
1241 return algo.GetAlgorithm()
1243 ## Enables creation of nodes and faces usable by 3D algoritms.
1244 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1245 # and SetMeshElementOnShape()
1246 # If the optional \a geom parameter is not set, this algorithm is global.
1247 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1248 # @param geom the subshape to be manually meshed
1249 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1250 # @ingroup l3_algos_basic
1251 def UseExistingFaces(self, geom=0):
1252 algo = Mesh_UseExisting(2,self,geom)
1253 return algo.GetAlgorithm()
1255 ## Creates a triangle 2D algorithm for faces.
1256 # If the optional \a geom parameter is not set, this algorithm is global.
1257 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1258 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1259 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1260 # @return an instance of Mesh_Triangle algorithm
1261 # @ingroup l3_algos_basic
1262 def Triangle(self, algo=MEFISTO, geom=0):
1263 ## if Triangle(geom) is called by mistake
1264 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1267 return Mesh_Triangle(self, algo, geom)
1269 ## Creates a quadrangle 2D algorithm for faces.
1270 # If the optional \a geom parameter is not set, this algorithm is global.
1271 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1272 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1273 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1274 # @return an instance of Mesh_Quadrangle algorithm
1275 # @ingroup l3_algos_basic
1276 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1277 if algo==RADIAL_QUAD:
1278 return Mesh_RadialQuadrangle1D2D(self,geom)
1280 return Mesh_Quadrangle(self, geom)
1282 ## Creates a tetrahedron 3D algorithm for solids.
1283 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1284 # If the optional \a geom parameter is not set, this algorithm is global.
1285 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1286 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1287 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1288 # @return an instance of Mesh_Tetrahedron algorithm
1289 # @ingroup l3_algos_basic
1290 def Tetrahedron(self, algo=NETGEN, geom=0):
1291 ## if Tetrahedron(geom) is called by mistake
1292 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1293 algo, geom = geom, algo
1294 if not algo: algo = NETGEN
1296 return Mesh_Tetrahedron(self, algo, geom)
1298 ## Creates a hexahedron 3D algorithm for solids.
1299 # If the optional \a geom parameter is not set, this algorithm is global.
1300 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1301 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1302 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1303 # @return an instance of Mesh_Hexahedron algorithm
1304 # @ingroup l3_algos_basic
1305 def Hexahedron(self, algo=Hexa, geom=0):
1306 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1307 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1308 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1309 elif geom == 0: algo, geom = Hexa, algo
1310 return Mesh_Hexahedron(self, algo, geom)
1312 ## Deprecated, used only for compatibility!
1313 # @return an instance of Mesh_Netgen algorithm
1314 # @ingroup l3_algos_basic
1315 def Netgen(self, is3D, geom=0):
1316 return Mesh_Netgen(self, is3D, geom)
1318 ## Creates a projection 1D algorithm for edges.
1319 # If the optional \a geom parameter is not set, this algorithm is global.
1320 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1321 # @param geom If defined, the subshape to be meshed
1322 # @return an instance of Mesh_Projection1D algorithm
1323 # @ingroup l3_algos_proj
1324 def Projection1D(self, geom=0):
1325 return Mesh_Projection1D(self, geom)
1327 ## Creates a projection 2D algorithm for faces.
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_Projection2D algorithm
1332 # @ingroup l3_algos_proj
1333 def Projection2D(self, geom=0):
1334 return Mesh_Projection2D(self, geom)
1336 ## Creates a projection 3D algorithm for solids.
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_Projection3D algorithm
1341 # @ingroup l3_algos_proj
1342 def Projection3D(self, geom=0):
1343 return Mesh_Projection3D(self, geom)
1345 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 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_Prism3D or Mesh_RadialPrism3D algorithm
1350 # @ingroup l3_algos_radialp l3_algos_3dextr
1351 def Prism(self, geom=0):
1355 nbSolids = len( self.geompyD.ExtractShapes( shape, geompyDC.ShapeType["SOLID"] ))
1356 nbShells = len( self.geompyD.ExtractShapes( shape, geompyDC.ShapeType["SHELL"] ))
1357 if nbSolids == 0 or nbSolids == nbShells:
1358 return Mesh_Prism3D(self, geom)
1359 return Mesh_RadialPrism3D(self, geom)
1361 ## Evaluates size of prospective mesh on a shape
1362 # @return a list where i-th element is a number of elements of i-th SMESH.EntityType
1363 # To know predicted number of e.g. edges, inquire it this way
1364 # Evaluate()[ EnumToLong( Entity_Edge )]
1365 def Evaluate(self, geom=0):
1366 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1368 geom = self.mesh.GetShapeToMesh()
1371 return self.smeshpyD.Evaluate(self.mesh, geom)
1374 ## Computes the mesh and returns the status of the computation
1375 # @param geom geomtrical shape on which mesh data should be computed
1376 # @param discardModifs if True and the mesh has been edited since
1377 # a last total re-compute and that may prevent successful partial re-compute,
1378 # then the mesh is cleaned before Compute()
1379 # @return True or False
1380 # @ingroup l2_construct
1381 def Compute(self, geom=0, discardModifs=False):
1382 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1384 geom = self.mesh.GetShapeToMesh()
1389 if discardModifs and self.mesh.HasModificationsToDiscard(): # issue 0020693
1391 ok = self.smeshpyD.Compute(self.mesh, geom)
1392 except SALOME.SALOME_Exception, ex:
1393 print "Mesh computation failed, exception caught:"
1394 print " ", ex.details.text
1397 print "Mesh computation failed, exception caught:"
1398 traceback.print_exc()
1402 # Treat compute errors
1403 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1404 for err in computeErrors:
1406 if self.mesh.HasShapeToMesh():
1408 mainIOR = salome.orb.object_to_string(geom)
1409 for sname in salome.myStudyManager.GetOpenStudies():
1410 s = salome.myStudyManager.GetStudyByName(sname)
1412 mainSO = s.FindObjectIOR(mainIOR)
1413 if not mainSO: continue
1414 if err.subShapeID == 1:
1415 shapeText = ' on "%s"' % mainSO.GetName()
1416 subIt = s.NewChildIterator(mainSO)
1418 subSO = subIt.Value()
1420 obj = subSO.GetObject()
1421 if not obj: continue
1422 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1424 ids = go.GetSubShapeIndices()
1425 if len(ids) == 1 and ids[0] == err.subShapeID:
1426 shapeText = ' on "%s"' % subSO.GetName()
1429 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1431 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
1433 shapeText = " on subshape #%s" % (err.subShapeID)
1435 shapeText = " on subshape #%s" % (err.subShapeID)
1437 stdErrors = ["OK", #COMPERR_OK
1438 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1439 "std::exception", #COMPERR_STD_EXCEPTION
1440 "OCC exception", #COMPERR_OCC_EXCEPTION
1441 "SALOME exception", #COMPERR_SLM_EXCEPTION
1442 "Unknown exception", #COMPERR_EXCEPTION
1443 "Memory allocation problem", #COMPERR_MEMORY_PB
1444 "Algorithm failed", #COMPERR_ALGO_FAILED
1445 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1447 if err.code < len(stdErrors): errText = stdErrors[err.code]
1449 errText = "code %s" % -err.code
1450 if errText: errText += ". "
1451 errText += err.comment
1452 if allReasons != "":allReasons += "\n"
1453 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
1457 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1459 if err.isGlobalAlgo:
1467 reason = '%s %sD algorithm is missing' % (glob, dim)
1468 elif err.state == HYP_MISSING:
1469 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1470 % (glob, dim, name, dim))
1471 elif err.state == HYP_NOTCONFORM:
1472 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1473 elif err.state == HYP_BAD_PARAMETER:
1474 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1475 % ( glob, dim, name ))
1476 elif err.state == HYP_BAD_GEOMETRY:
1477 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1478 'geometry' % ( glob, dim, name ))
1480 reason = "For unknown reason."+\
1481 " Revise Mesh.Compute() implementation in smeshDC.py!"
1483 if allReasons != "":allReasons += "\n"
1484 allReasons += reason
1486 if allReasons != "":
1487 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1491 print '"' + GetName(self.mesh) + '"',"has not been computed."
1494 if salome.sg.hasDesktop():
1495 smeshgui = salome.ImportComponentGUI("SMESH")
1496 smeshgui.Init(self.mesh.GetStudyId())
1497 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1498 salome.sg.updateObjBrowser(1)
1502 ## Return submesh objects list in meshing order
1503 # @return list of list of submesh objects
1504 # @ingroup l2_construct
1505 def GetMeshOrder(self):
1506 return self.mesh.GetMeshOrder()
1508 ## Return submesh objects list in meshing order
1509 # @return list of list of submesh objects
1510 # @ingroup l2_construct
1511 def SetMeshOrder(self, submeshes):
1512 return self.mesh.SetMeshOrder(submeshes)
1514 ## Removes all nodes and elements
1515 # @ingroup l2_construct
1518 if salome.sg.hasDesktop():
1519 smeshgui = salome.ImportComponentGUI("SMESH")
1520 smeshgui.Init(self.mesh.GetStudyId())
1521 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1522 salome.sg.updateObjBrowser(1)
1524 ## Removes all nodes and elements of indicated shape
1525 # @ingroup l2_construct
1526 def ClearSubMesh(self, geomId):
1527 self.mesh.ClearSubMesh(geomId)
1528 if salome.sg.hasDesktop():
1529 smeshgui = salome.ImportComponentGUI("SMESH")
1530 smeshgui.Init(self.mesh.GetStudyId())
1531 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1532 salome.sg.updateObjBrowser(1)
1534 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1535 # @param fineness [0,-1] defines mesh fineness
1536 # @return True or False
1537 # @ingroup l3_algos_basic
1538 def AutomaticTetrahedralization(self, fineness=0):
1539 dim = self.MeshDimension()
1541 self.RemoveGlobalHypotheses()
1542 self.Segment().AutomaticLength(fineness)
1544 self.Triangle().LengthFromEdges()
1547 self.Tetrahedron(NETGEN)
1549 return self.Compute()
1551 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1552 # @param fineness [0,-1] defines mesh fineness
1553 # @return True or False
1554 # @ingroup l3_algos_basic
1555 def AutomaticHexahedralization(self, fineness=0):
1556 dim = self.MeshDimension()
1557 # assign the hypotheses
1558 self.RemoveGlobalHypotheses()
1559 self.Segment().AutomaticLength(fineness)
1566 return self.Compute()
1568 ## Assigns a hypothesis
1569 # @param hyp a hypothesis to assign
1570 # @param geom a subhape of mesh geometry
1571 # @return SMESH.Hypothesis_Status
1572 # @ingroup l2_hypotheses
1573 def AddHypothesis(self, hyp, geom=0):
1574 if isinstance( hyp, Mesh_Algorithm ):
1575 hyp = hyp.GetAlgorithm()
1580 geom = self.mesh.GetShapeToMesh()
1582 status = self.mesh.AddHypothesis(geom, hyp)
1583 isAlgo = hyp._narrow( SMESH_Algo )
1584 hyp_name = GetName( hyp )
1587 geom_name = GetName( geom )
1588 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1591 ## Unassigns a hypothesis
1592 # @param hyp a hypothesis to unassign
1593 # @param geom a subshape of mesh geometry
1594 # @return SMESH.Hypothesis_Status
1595 # @ingroup l2_hypotheses
1596 def RemoveHypothesis(self, hyp, geom=0):
1597 if isinstance( hyp, Mesh_Algorithm ):
1598 hyp = hyp.GetAlgorithm()
1603 status = self.mesh.RemoveHypothesis(geom, hyp)
1606 ## Gets the list of hypotheses added on a geometry
1607 # @param geom a subshape of mesh geometry
1608 # @return the sequence of SMESH_Hypothesis
1609 # @ingroup l2_hypotheses
1610 def GetHypothesisList(self, geom):
1611 return self.mesh.GetHypothesisList( geom )
1613 ## Removes all global hypotheses
1614 # @ingroup l2_hypotheses
1615 def RemoveGlobalHypotheses(self):
1616 current_hyps = self.mesh.GetHypothesisList( self.geom )
1617 for hyp in current_hyps:
1618 self.mesh.RemoveHypothesis( self.geom, hyp )
1622 ## Creates a mesh group based on the geometric object \a grp
1623 # and gives a \a name, \n if this parameter is not defined
1624 # the name is the same as the geometric group name \n
1625 # Note: Works like GroupOnGeom().
1626 # @param grp a geometric group, a vertex, an edge, a face or a solid
1627 # @param name the name of the mesh group
1628 # @return SMESH_GroupOnGeom
1629 # @ingroup l2_grps_create
1630 def Group(self, grp, name=""):
1631 return self.GroupOnGeom(grp, name)
1633 ## Deprecated, used only for compatibility! Please, use ExportToMEDX() method instead.
1634 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1635 ## allowing to overwrite the file if it exists or add the exported data to its contents
1636 # @param f the file name
1637 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1638 # @param opt boolean parameter for creating/not creating
1639 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1640 # @param overwrite boolean parameter for overwriting/not overwriting the file
1641 # @ingroup l2_impexp
1642 def ExportToMED(self, f, version, opt=0, overwrite=1):
1643 self.mesh.ExportToMEDX(f, opt, version, overwrite)
1645 ## Exports the mesh in a file in MED format and chooses the \a version of MED format
1646 ## allowing to overwrite the file if it exists or add the exported data to its contents
1647 # @param f is the file name
1648 # @param auto_groups boolean parameter for creating/not creating
1649 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1650 # the typical use is auto_groups=false.
1651 # @param version MED format version(MED_V2_1 or MED_V2_2)
1652 # @param overwrite boolean parameter for overwriting/not overwriting the file
1653 # @ingroup l2_impexp
1654 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
1655 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
1657 ## Exports the mesh in a file in DAT format
1658 # @param f the file name
1659 # @ingroup l2_impexp
1660 def ExportDAT(self, f):
1661 self.mesh.ExportDAT(f)
1663 ## Exports the mesh in a file in UNV format
1664 # @param f the file name
1665 # @ingroup l2_impexp
1666 def ExportUNV(self, f):
1667 self.mesh.ExportUNV(f)
1669 ## Export the mesh in a file in STL format
1670 # @param f the file name
1671 # @param ascii defines the file encoding
1672 # @ingroup l2_impexp
1673 def ExportSTL(self, f, ascii=1):
1674 self.mesh.ExportSTL(f, ascii)
1677 # Operations with groups:
1678 # ----------------------
1680 ## Creates an empty mesh group
1681 # @param elementType the type of elements in the group
1682 # @param name the name of the mesh group
1683 # @return SMESH_Group
1684 # @ingroup l2_grps_create
1685 def CreateEmptyGroup(self, elementType, name):
1686 return self.mesh.CreateGroup(elementType, name)
1688 ## Creates a mesh group based on the geometrical object \a grp
1689 # and gives a \a name, \n if this parameter is not defined
1690 # the name is the same as the geometrical group name
1691 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1692 # @param name the name of the mesh group
1693 # @param typ the type of elements in the group. If not set, it is
1694 # automatically detected by the type of the geometry
1695 # @return SMESH_GroupOnGeom
1696 # @ingroup l2_grps_create
1697 def GroupOnGeom(self, grp, name="", typ=None):
1699 name = grp.GetName()
1702 tgeo = str(grp.GetShapeType())
1703 if tgeo == "VERTEX":
1705 elif tgeo == "EDGE":
1707 elif tgeo == "FACE":
1709 elif tgeo == "SOLID":
1711 elif tgeo == "SHELL":
1713 elif tgeo == "COMPOUND":
1714 try: # it raises on a compound of compounds
1715 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1716 print "Mesh.Group: empty geometric group", GetName( grp )
1721 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1723 tgeo = self.geompyD.GetType(grp)
1724 if tgeo == geompyDC.ShapeType["VERTEX"]:
1726 elif tgeo == geompyDC.ShapeType["EDGE"]:
1728 elif tgeo == geompyDC.ShapeType["FACE"]:
1730 elif tgeo == geompyDC.ShapeType["SOLID"]:
1736 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1737 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1738 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1746 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1749 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1751 ## Creates a mesh group by the given ids of elements
1752 # @param groupName the name of the mesh group
1753 # @param elementType the type of elements in the group
1754 # @param elemIDs the list of ids
1755 # @return SMESH_Group
1756 # @ingroup l2_grps_create
1757 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1758 group = self.mesh.CreateGroup(elementType, groupName)
1762 ## Creates a mesh group by the given conditions
1763 # @param groupName the name of the mesh group
1764 # @param elementType the type of elements in the group
1765 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1766 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1767 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1768 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1769 # @param Tolerance the tolerance used by FT_BelongToGeom, FT_BelongToSurface,
1770 # FT_LyingOnGeom, FT_CoplanarFaces criteria
1771 # @return SMESH_Group
1772 # @ingroup l2_grps_create
1776 CritType=FT_Undefined,
1779 UnaryOp=FT_Undefined,
1781 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
1782 group = self.MakeGroupByCriterion(groupName, aCriterion)
1785 ## Creates a mesh group by the given criterion
1786 # @param groupName the name of the mesh group
1787 # @param Criterion the instance of Criterion class
1788 # @return SMESH_Group
1789 # @ingroup l2_grps_create
1790 def MakeGroupByCriterion(self, groupName, Criterion):
1791 aFilterMgr = self.smeshpyD.CreateFilterManager()
1792 aFilter = aFilterMgr.CreateFilter()
1794 aCriteria.append(Criterion)
1795 aFilter.SetCriteria(aCriteria)
1796 group = self.MakeGroupByFilter(groupName, aFilter)
1797 aFilterMgr.Destroy()
1800 ## Creates a mesh group by the given criteria (list of criteria)
1801 # @param groupName the name of the mesh group
1802 # @param theCriteria the list of criteria
1803 # @return SMESH_Group
1804 # @ingroup l2_grps_create
1805 def MakeGroupByCriteria(self, groupName, theCriteria):
1806 aFilterMgr = self.smeshpyD.CreateFilterManager()
1807 aFilter = aFilterMgr.CreateFilter()
1808 aFilter.SetCriteria(theCriteria)
1809 group = self.MakeGroupByFilter(groupName, aFilter)
1810 aFilterMgr.Destroy()
1813 ## Creates a mesh group by the given filter
1814 # @param groupName the name of the mesh group
1815 # @param theFilter the instance of Filter class
1816 # @return SMESH_Group
1817 # @ingroup l2_grps_create
1818 def MakeGroupByFilter(self, groupName, theFilter):
1819 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
1820 theFilter.SetMesh( self.mesh )
1821 group.AddFrom( theFilter )
1824 ## Passes mesh elements through the given filter and return IDs of fitting elements
1825 # @param theFilter SMESH_Filter
1826 # @return a list of ids
1827 # @ingroup l1_controls
1828 def GetIdsFromFilter(self, theFilter):
1829 theFilter.SetMesh( self.mesh )
1830 return theFilter.GetIDs()
1832 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1833 # Returns a list of special structures (borders).
1834 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1835 # @ingroup l1_controls
1836 def GetFreeBorders(self):
1837 aFilterMgr = self.smeshpyD.CreateFilterManager()
1838 aPredicate = aFilterMgr.CreateFreeEdges()
1839 aPredicate.SetMesh(self.mesh)
1840 aBorders = aPredicate.GetBorders()
1841 aFilterMgr.Destroy()
1845 # @ingroup l2_grps_delete
1846 def RemoveGroup(self, group):
1847 self.mesh.RemoveGroup(group)
1849 ## Removes a group with its contents
1850 # @ingroup l2_grps_delete
1851 def RemoveGroupWithContents(self, group):
1852 self.mesh.RemoveGroupWithContents(group)
1854 ## Gets the list of groups existing in the mesh
1855 # @return a sequence of SMESH_GroupBase
1856 # @ingroup l2_grps_create
1857 def GetGroups(self):
1858 return self.mesh.GetGroups()
1860 ## Gets the number of groups existing in the mesh
1861 # @return the quantity of groups as an integer value
1862 # @ingroup l2_grps_create
1864 return self.mesh.NbGroups()
1866 ## Gets the list of names of groups existing in the mesh
1867 # @return list of strings
1868 # @ingroup l2_grps_create
1869 def GetGroupNames(self):
1870 groups = self.GetGroups()
1872 for group in groups:
1873 names.append(group.GetName())
1876 ## Produces a union of two groups
1877 # A new group is created. All mesh elements that are
1878 # present in the initial groups are added to the new one
1879 # @return an instance of SMESH_Group
1880 # @ingroup l2_grps_operon
1881 def UnionGroups(self, group1, group2, name):
1882 return self.mesh.UnionGroups(group1, group2, name)
1884 ## Produces a union list of groups
1885 # New group is created. All mesh elements that are present in
1886 # initial groups are added to the new one
1887 # @return an instance of SMESH_Group
1888 # @ingroup l2_grps_operon
1889 def UnionListOfGroups(self, groups, name):
1890 return self.mesh.UnionListOfGroups(groups, name)
1892 ## Prodices an intersection of two groups
1893 # A new group is created. All mesh elements that are common
1894 # for the two initial groups are added to the new one.
1895 # @return an instance of SMESH_Group
1896 # @ingroup l2_grps_operon
1897 def IntersectGroups(self, group1, group2, name):
1898 return self.mesh.IntersectGroups(group1, group2, name)
1900 ## Produces an intersection of groups
1901 # New group is created. All mesh elements that are present in all
1902 # initial groups simultaneously are added to the new one
1903 # @return an instance of SMESH_Group
1904 # @ingroup l2_grps_operon
1905 def IntersectListOfGroups(self, groups, name):
1906 return self.mesh.IntersectListOfGroups(groups, name)
1908 ## Produces a cut of two groups
1909 # A new group is created. All mesh elements that are present in
1910 # the main group but are not present in the tool group are added to the new one
1911 # @return an instance of SMESH_Group
1912 # @ingroup l2_grps_operon
1913 def CutGroups(self, main_group, tool_group, name):
1914 return self.mesh.CutGroups(main_group, tool_group, name)
1916 ## Produces a cut of groups
1917 # A new group is created. All mesh elements that are present in main groups
1918 # but do not present in tool groups are added to the new one
1919 # @return an instance of SMESH_Group
1920 # @ingroup l2_grps_operon
1921 def CutListOfGroups(self, main_groups, tool_groups, name):
1922 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1924 ## Produces a group of elements with specified element type using list of existing groups
1925 # A new group is created. System
1926 # 1) extract all nodes on which groups elements are built
1927 # 2) combine all elements of specified dimension laying on these nodes
1928 # @return an instance of SMESH_Group
1929 # @ingroup l2_grps_operon
1930 def CreateDimGroup(self, groups, elem_type, name):
1931 return self.mesh.CreateDimGroup(groups, elem_type, name)
1934 ## Convert group on geom into standalone group
1935 # @ingroup l2_grps_delete
1936 def ConvertToStandalone(self, group):
1937 return self.mesh.ConvertToStandalone(group)
1939 # Get some info about mesh:
1940 # ------------------------
1942 ## Returns the log of nodes and elements added or removed
1943 # since the previous clear of the log.
1944 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1945 # @return list of log_block structures:
1950 # @ingroup l1_auxiliary
1951 def GetLog(self, clearAfterGet):
1952 return self.mesh.GetLog(clearAfterGet)
1954 ## Clears the log of nodes and elements added or removed since the previous
1955 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1956 # @ingroup l1_auxiliary
1958 self.mesh.ClearLog()
1960 ## Toggles auto color mode on the object.
1961 # @param theAutoColor the flag which toggles auto color mode.
1962 # @ingroup l1_auxiliary
1963 def SetAutoColor(self, theAutoColor):
1964 self.mesh.SetAutoColor(theAutoColor)
1966 ## Gets flag of object auto color mode.
1967 # @return True or False
1968 # @ingroup l1_auxiliary
1969 def GetAutoColor(self):
1970 return self.mesh.GetAutoColor()
1972 ## Gets the internal ID
1973 # @return integer value, which is the internal Id of the mesh
1974 # @ingroup l1_auxiliary
1976 return self.mesh.GetId()
1979 # @return integer value, which is the study Id of the mesh
1980 # @ingroup l1_auxiliary
1981 def GetStudyId(self):
1982 return self.mesh.GetStudyId()
1984 ## Checks the group names for duplications.
1985 # Consider the maximum group name length stored in MED file.
1986 # @return True or False
1987 # @ingroup l1_auxiliary
1988 def HasDuplicatedGroupNamesMED(self):
1989 return self.mesh.HasDuplicatedGroupNamesMED()
1991 ## Obtains the mesh editor tool
1992 # @return an instance of SMESH_MeshEditor
1993 # @ingroup l1_modifying
1994 def GetMeshEditor(self):
1995 return self.mesh.GetMeshEditor()
1997 ## Wrap a list of IDs of elements or nodes into SMESH_IDSource which
1998 # can be passed as argument to accepting mesh, group or sub-mesh
1999 # @return an instance of SMESH_IDSource
2000 # @ingroup l1_auxiliary
2001 def GetIDSource(self, ids, elemType):
2002 return self.GetMeshEditor().MakeIDSource(ids, elemType)
2005 # @return an instance of SALOME_MED::MESH
2006 # @ingroup l1_auxiliary
2007 def GetMEDMesh(self):
2008 return self.mesh.GetMEDMesh()
2011 # Get informations about mesh contents:
2012 # ------------------------------------
2014 ## Gets the mesh stattistic
2015 # @return dictionary type element - count of elements
2016 # @ingroup l1_meshinfo
2017 def GetMeshInfo(self, obj = None):
2018 if not obj: obj = self.mesh
2019 return self.smeshpyD.GetMeshInfo(obj)
2021 ## Returns the number of nodes in the mesh
2022 # @return an integer value
2023 # @ingroup l1_meshinfo
2025 return self.mesh.NbNodes()
2027 ## Returns the number of elements in the mesh
2028 # @return an integer value
2029 # @ingroup l1_meshinfo
2030 def NbElements(self):
2031 return self.mesh.NbElements()
2033 ## Returns the number of 0d elements in the mesh
2034 # @return an integer value
2035 # @ingroup l1_meshinfo
2036 def Nb0DElements(self):
2037 return self.mesh.Nb0DElements()
2039 ## Returns the number of edges in the mesh
2040 # @return an integer value
2041 # @ingroup l1_meshinfo
2043 return self.mesh.NbEdges()
2045 ## Returns the number of edges with the given order in the mesh
2046 # @param elementOrder the order of elements:
2047 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2048 # @return an integer value
2049 # @ingroup l1_meshinfo
2050 def NbEdgesOfOrder(self, elementOrder):
2051 return self.mesh.NbEdgesOfOrder(elementOrder)
2053 ## Returns the number of faces in the mesh
2054 # @return an integer value
2055 # @ingroup l1_meshinfo
2057 return self.mesh.NbFaces()
2059 ## Returns the number of faces with the given order in the mesh
2060 # @param elementOrder the order of elements:
2061 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2062 # @return an integer value
2063 # @ingroup l1_meshinfo
2064 def NbFacesOfOrder(self, elementOrder):
2065 return self.mesh.NbFacesOfOrder(elementOrder)
2067 ## Returns the number of triangles in the mesh
2068 # @return an integer value
2069 # @ingroup l1_meshinfo
2070 def NbTriangles(self):
2071 return self.mesh.NbTriangles()
2073 ## Returns the number of triangles with the given order in the mesh
2074 # @param elementOrder is the order of elements:
2075 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2076 # @return an integer value
2077 # @ingroup l1_meshinfo
2078 def NbTrianglesOfOrder(self, elementOrder):
2079 return self.mesh.NbTrianglesOfOrder(elementOrder)
2081 ## Returns the number of quadrangles in the mesh
2082 # @return an integer value
2083 # @ingroup l1_meshinfo
2084 def NbQuadrangles(self):
2085 return self.mesh.NbQuadrangles()
2087 ## Returns the number of quadrangles with the given order in the mesh
2088 # @param elementOrder the order of elements:
2089 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2090 # @return an integer value
2091 # @ingroup l1_meshinfo
2092 def NbQuadranglesOfOrder(self, elementOrder):
2093 return self.mesh.NbQuadranglesOfOrder(elementOrder)
2095 ## Returns the number of polygons in the mesh
2096 # @return an integer value
2097 # @ingroup l1_meshinfo
2098 def NbPolygons(self):
2099 return self.mesh.NbPolygons()
2101 ## Returns the number of volumes in the mesh
2102 # @return an integer value
2103 # @ingroup l1_meshinfo
2104 def NbVolumes(self):
2105 return self.mesh.NbVolumes()
2107 ## Returns the number of volumes with the given order in the mesh
2108 # @param elementOrder the order of elements:
2109 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2110 # @return an integer value
2111 # @ingroup l1_meshinfo
2112 def NbVolumesOfOrder(self, elementOrder):
2113 return self.mesh.NbVolumesOfOrder(elementOrder)
2115 ## Returns the number of tetrahedrons in the mesh
2116 # @return an integer value
2117 # @ingroup l1_meshinfo
2119 return self.mesh.NbTetras()
2121 ## Returns the number of tetrahedrons with the given order in the mesh
2122 # @param elementOrder the order of elements:
2123 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2124 # @return an integer value
2125 # @ingroup l1_meshinfo
2126 def NbTetrasOfOrder(self, elementOrder):
2127 return self.mesh.NbTetrasOfOrder(elementOrder)
2129 ## Returns the number of hexahedrons in the mesh
2130 # @return an integer value
2131 # @ingroup l1_meshinfo
2133 return self.mesh.NbHexas()
2135 ## Returns the number of hexahedrons with the given order in the mesh
2136 # @param elementOrder the order of elements:
2137 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2138 # @return an integer value
2139 # @ingroup l1_meshinfo
2140 def NbHexasOfOrder(self, elementOrder):
2141 return self.mesh.NbHexasOfOrder(elementOrder)
2143 ## Returns the number of pyramids in the mesh
2144 # @return an integer value
2145 # @ingroup l1_meshinfo
2146 def NbPyramids(self):
2147 return self.mesh.NbPyramids()
2149 ## Returns the number of pyramids with the given order in the mesh
2150 # @param elementOrder the order of elements:
2151 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2152 # @return an integer value
2153 # @ingroup l1_meshinfo
2154 def NbPyramidsOfOrder(self, elementOrder):
2155 return self.mesh.NbPyramidsOfOrder(elementOrder)
2157 ## Returns the number of prisms in the mesh
2158 # @return an integer value
2159 # @ingroup l1_meshinfo
2161 return self.mesh.NbPrisms()
2163 ## Returns the number of prisms with the given order in the mesh
2164 # @param elementOrder the order of elements:
2165 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
2166 # @return an integer value
2167 # @ingroup l1_meshinfo
2168 def NbPrismsOfOrder(self, elementOrder):
2169 return self.mesh.NbPrismsOfOrder(elementOrder)
2171 ## Returns the number of polyhedrons in the mesh
2172 # @return an integer value
2173 # @ingroup l1_meshinfo
2174 def NbPolyhedrons(self):
2175 return self.mesh.NbPolyhedrons()
2177 ## Returns the number of submeshes in the mesh
2178 # @return an integer value
2179 # @ingroup l1_meshinfo
2180 def NbSubMesh(self):
2181 return self.mesh.NbSubMesh()
2183 ## Returns the list of mesh elements IDs
2184 # @return the list of integer values
2185 # @ingroup l1_meshinfo
2186 def GetElementsId(self):
2187 return self.mesh.GetElementsId()
2189 ## Returns the list of IDs of mesh elements with the given type
2190 # @param elementType the required type of elements (SMESH.NODE, SMESH.EDGE, SMESH.FACE or SMESH.VOLUME)
2191 # @return list of integer values
2192 # @ingroup l1_meshinfo
2193 def GetElementsByType(self, elementType):
2194 return self.mesh.GetElementsByType(elementType)
2196 ## Returns the list of mesh nodes IDs
2197 # @return the list of integer values
2198 # @ingroup l1_meshinfo
2199 def GetNodesId(self):
2200 return self.mesh.GetNodesId()
2202 # Get the information about mesh elements:
2203 # ------------------------------------
2205 ## Returns the type of mesh element
2206 # @return the value from SMESH::ElementType enumeration
2207 # @ingroup l1_meshinfo
2208 def GetElementType(self, id, iselem):
2209 return self.mesh.GetElementType(id, iselem)
2211 ## Returns the geometric type of mesh element
2212 # @return the value from SMESH::EntityType enumeration
2213 # @ingroup l1_meshinfo
2214 def GetElementGeomType(self, id):
2215 return self.mesh.GetElementGeomType(id)
2217 ## Returns the list of submesh elements IDs
2218 # @param Shape a geom object(subshape) IOR
2219 # Shape must be the subshape of a ShapeToMesh()
2220 # @return the list of integer values
2221 # @ingroup l1_meshinfo
2222 def GetSubMeshElementsId(self, Shape):
2223 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2224 ShapeID = Shape.GetSubShapeIndices()[0]
2227 return self.mesh.GetSubMeshElementsId(ShapeID)
2229 ## Returns the list of submesh nodes IDs
2230 # @param Shape a geom object(subshape) IOR
2231 # Shape must be the subshape of a ShapeToMesh()
2232 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
2233 # @return the list of integer values
2234 # @ingroup l1_meshinfo
2235 def GetSubMeshNodesId(self, Shape, all):
2236 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2237 ShapeID = Shape.GetSubShapeIndices()[0]
2240 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2242 ## Returns type of elements on given shape
2243 # @param Shape a geom object(subshape) IOR
2244 # Shape must be a subshape of a ShapeToMesh()
2245 # @return element type
2246 # @ingroup l1_meshinfo
2247 def GetSubMeshElementType(self, Shape):
2248 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2249 ShapeID = Shape.GetSubShapeIndices()[0]
2252 return self.mesh.GetSubMeshElementType(ShapeID)
2254 ## Gets the mesh description
2255 # @return string value
2256 # @ingroup l1_meshinfo
2258 return self.mesh.Dump()
2261 # Get the information about nodes and elements of a mesh by its IDs:
2262 # -----------------------------------------------------------
2264 ## Gets XYZ coordinates of a node
2265 # \n If there is no nodes for the given ID - returns an empty list
2266 # @return a list of double precision values
2267 # @ingroup l1_meshinfo
2268 def GetNodeXYZ(self, id):
2269 return self.mesh.GetNodeXYZ(id)
2271 ## Returns list of IDs of inverse elements for the given node
2272 # \n If there is no node for the given ID - returns an empty list
2273 # @return a list of integer values
2274 # @ingroup l1_meshinfo
2275 def GetNodeInverseElements(self, id):
2276 return self.mesh.GetNodeInverseElements(id)
2278 ## @brief Returns the position of a node on the shape
2279 # @return SMESH::NodePosition
2280 # @ingroup l1_meshinfo
2281 def GetNodePosition(self,NodeID):
2282 return self.mesh.GetNodePosition(NodeID)
2284 ## If the given element is a node, returns the ID of shape
2285 # \n If there is no node for the given ID - returns -1
2286 # @return an integer value
2287 # @ingroup l1_meshinfo
2288 def GetShapeID(self, id):
2289 return self.mesh.GetShapeID(id)
2291 ## Returns the ID of the result shape after
2292 # FindShape() from SMESH_MeshEditor for the given element
2293 # \n If there is no element for the given ID - returns -1
2294 # @return an integer value
2295 # @ingroup l1_meshinfo
2296 def GetShapeIDForElem(self,id):
2297 return self.mesh.GetShapeIDForElem(id)
2299 ## Returns the number of nodes for the given element
2300 # \n If there is no element for the given ID - returns -1
2301 # @return an integer value
2302 # @ingroup l1_meshinfo
2303 def GetElemNbNodes(self, id):
2304 return self.mesh.GetElemNbNodes(id)
2306 ## Returns the node ID the given index for the given element
2307 # \n If there is no element for the given ID - returns -1
2308 # \n If there is no node for the given index - returns -2
2309 # @return an integer value
2310 # @ingroup l1_meshinfo
2311 def GetElemNode(self, id, index):
2312 return self.mesh.GetElemNode(id, index)
2314 ## Returns the IDs of nodes of the given element
2315 # @return a list of integer values
2316 # @ingroup l1_meshinfo
2317 def GetElemNodes(self, id):
2318 return self.mesh.GetElemNodes(id)
2320 ## Returns true if the given node is the medium node in the given quadratic element
2321 # @ingroup l1_meshinfo
2322 def IsMediumNode(self, elementID, nodeID):
2323 return self.mesh.IsMediumNode(elementID, nodeID)
2325 ## Returns true if the given node is the medium node in one of quadratic elements
2326 # @ingroup l1_meshinfo
2327 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2328 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2330 ## Returns the number of edges for the given element
2331 # @ingroup l1_meshinfo
2332 def ElemNbEdges(self, id):
2333 return self.mesh.ElemNbEdges(id)
2335 ## Returns the number of faces for the given element
2336 # @ingroup l1_meshinfo
2337 def ElemNbFaces(self, id):
2338 return self.mesh.ElemNbFaces(id)
2340 ## Returns nodes of given face (counted from zero) for given volumic element.
2341 # @ingroup l1_meshinfo
2342 def GetElemFaceNodes(self,elemId, faceIndex):
2343 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2345 ## Returns an element based on all given nodes.
2346 # @ingroup l1_meshinfo
2347 def FindElementByNodes(self,nodes):
2348 return self.mesh.FindElementByNodes(nodes)
2350 ## Returns true if the given element is a polygon
2351 # @ingroup l1_meshinfo
2352 def IsPoly(self, id):
2353 return self.mesh.IsPoly(id)
2355 ## Returns true if the given element is quadratic
2356 # @ingroup l1_meshinfo
2357 def IsQuadratic(self, id):
2358 return self.mesh.IsQuadratic(id)
2360 ## Returns XYZ coordinates of the barycenter of the given element
2361 # \n If there is no element for the given ID - returns an empty list
2362 # @return a list of three double values
2363 # @ingroup l1_meshinfo
2364 def BaryCenter(self, id):
2365 return self.mesh.BaryCenter(id)
2368 # Get mesh measurements information:
2369 # ------------------------------------
2371 ## Get minimum distance between two nodes, elements or distance to the origin
2372 # @param id1 first node/element id
2373 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2374 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2375 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2376 # @return minimum distance value
2377 # @sa GetMinDistance()
2378 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2379 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
2380 return aMeasure.value
2382 ## Get measure structure specifying minimum distance data between two objects
2383 # @param id1 first node/element id
2384 # @param id2 second node/element id (if 0, distance from @a id1 to the origin is computed)
2385 # @param isElem1 @c True if @a id1 is element id, @c False if it is node id
2386 # @param isElem2 @c True if @a id2 is element id, @c False if it is node id
2387 # @return Measure structure
2389 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
2391 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
2393 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
2396 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
2398 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
2403 aMeasurements = self.smeshpyD.CreateMeasurements()
2404 aMeasure = aMeasurements.MinDistance(id1, id2)
2405 aMeasurements.Destroy()
2408 ## Get bounding box of the specified object(s)
2409 # @param objects single source object or list of source objects or list of nodes/elements IDs
2410 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2411 # @c False specifies that @a objects are nodes
2412 # @return tuple of six values (minX, minY, minZ, maxX, maxY, maxZ)
2413 # @sa GetBoundingBox()
2414 def BoundingBox(self, objects=None, isElem=False):
2415 result = self.GetBoundingBox(objects, isElem)
2419 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
2422 ## Get measure structure specifying bounding box data of the specified object(s)
2423 # @param objects single source object or list of source objects or list of nodes/elements IDs
2424 # @param isElem if @a objects is a list of IDs, @c True value in this parameters specifies that @a objects are elements,
2425 # @c False specifies that @a objects are nodes
2426 # @return Measure structure
2428 def GetBoundingBox(self, IDs=None, isElem=False):
2431 elif isinstance(IDs, tuple):
2433 if not isinstance(IDs, list):
2435 if len(IDs) > 0 and isinstance(IDs[0], int):
2439 if isinstance(o, Mesh):
2440 srclist.append(o.mesh)
2441 elif hasattr(o, "_narrow"):
2442 src = o._narrow(SMESH.SMESH_IDSource)
2443 if src: srclist.append(src)
2445 elif isinstance(o, list):
2447 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
2449 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
2452 aMeasurements = self.smeshpyD.CreateMeasurements()
2453 aMeasure = aMeasurements.BoundingBox(srclist)
2454 aMeasurements.Destroy()
2457 # Mesh edition (SMESH_MeshEditor functionality):
2458 # ---------------------------------------------
2460 ## Removes the elements from the mesh by ids
2461 # @param IDsOfElements is a list of ids of elements to remove
2462 # @return True or False
2463 # @ingroup l2_modif_del
2464 def RemoveElements(self, IDsOfElements):
2465 return self.editor.RemoveElements(IDsOfElements)
2467 ## Removes nodes from mesh by ids
2468 # @param IDsOfNodes is a list of ids of nodes to remove
2469 # @return True or False
2470 # @ingroup l2_modif_del
2471 def RemoveNodes(self, IDsOfNodes):
2472 return self.editor.RemoveNodes(IDsOfNodes)
2474 ## Removes all orphan (free) nodes from mesh
2475 # @return number of the removed nodes
2476 # @ingroup l2_modif_del
2477 def RemoveOrphanNodes(self):
2478 return self.editor.RemoveOrphanNodes()
2480 ## Add a node to the mesh by coordinates
2481 # @return Id of the new node
2482 # @ingroup l2_modif_add
2483 def AddNode(self, x, y, z):
2484 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2485 self.mesh.SetParameters(Parameters)
2486 return self.editor.AddNode( x, y, z)
2488 ## Creates a 0D element on a node with given number.
2489 # @param IDOfNode the ID of node for creation of the element.
2490 # @return the Id of the new 0D element
2491 # @ingroup l2_modif_add
2492 def Add0DElement(self, IDOfNode):
2493 return self.editor.Add0DElement(IDOfNode)
2495 ## Creates a linear or quadratic edge (this is determined
2496 # by the number of given nodes).
2497 # @param IDsOfNodes the list of node IDs for creation of the element.
2498 # The order of nodes in this list should correspond to the description
2499 # of MED. \n This description is located by the following link:
2500 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2501 # @return the Id of the new edge
2502 # @ingroup l2_modif_add
2503 def AddEdge(self, IDsOfNodes):
2504 return self.editor.AddEdge(IDsOfNodes)
2506 ## Creates a linear or quadratic face (this is determined
2507 # by the number of given nodes).
2508 # @param IDsOfNodes the list of node IDs for creation of the element.
2509 # The order of nodes in this list should correspond to the description
2510 # of MED. \n This description is located by the following link:
2511 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2512 # @return the Id of the new face
2513 # @ingroup l2_modif_add
2514 def AddFace(self, IDsOfNodes):
2515 return self.editor.AddFace(IDsOfNodes)
2517 ## Adds a polygonal face to the mesh by the list of node IDs
2518 # @param IdsOfNodes the list of node IDs for creation of the element.
2519 # @return the Id of the new face
2520 # @ingroup l2_modif_add
2521 def AddPolygonalFace(self, IdsOfNodes):
2522 return self.editor.AddPolygonalFace(IdsOfNodes)
2524 ## Creates both simple and quadratic volume (this is determined
2525 # by the number of given nodes).
2526 # @param IDsOfNodes the list of node IDs for creation of the element.
2527 # The order of nodes in this list should correspond to the description
2528 # of MED. \n This description is located by the following link:
2529 # http://www.code-aster.org/outils/med/html/modele_de_donnees.html#3.
2530 # @return the Id of the new volumic element
2531 # @ingroup l2_modif_add
2532 def AddVolume(self, IDsOfNodes):
2533 return self.editor.AddVolume(IDsOfNodes)
2535 ## Creates a volume of many faces, giving nodes for each face.
2536 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2537 # @param Quantities the list of integer values, Quantities[i]
2538 # gives the quantity of nodes in face number i.
2539 # @return the Id of the new volumic element
2540 # @ingroup l2_modif_add
2541 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2542 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2544 ## Creates a volume of many faces, giving the IDs of the existing faces.
2545 # @param IdsOfFaces the list of face IDs for volume creation.
2547 # Note: The created volume will refer only to the nodes
2548 # of the given faces, not to the faces themselves.
2549 # @return the Id of the new volumic element
2550 # @ingroup l2_modif_add
2551 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2552 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2555 ## @brief Binds a node to a vertex
2556 # @param NodeID a node ID
2557 # @param Vertex a vertex or vertex ID
2558 # @return True if succeed else raises an exception
2559 # @ingroup l2_modif_add
2560 def SetNodeOnVertex(self, NodeID, Vertex):
2561 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2562 VertexID = Vertex.GetSubShapeIndices()[0]
2566 self.editor.SetNodeOnVertex(NodeID, VertexID)
2567 except SALOME.SALOME_Exception, inst:
2568 raise ValueError, inst.details.text
2572 ## @brief Stores the node position on an edge
2573 # @param NodeID a node ID
2574 # @param Edge an edge or edge ID
2575 # @param paramOnEdge a parameter on the edge where the node is located
2576 # @return True if succeed else raises an exception
2577 # @ingroup l2_modif_add
2578 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2579 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2580 EdgeID = Edge.GetSubShapeIndices()[0]
2584 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2585 except SALOME.SALOME_Exception, inst:
2586 raise ValueError, inst.details.text
2589 ## @brief Stores node position on a face
2590 # @param NodeID a node ID
2591 # @param Face a face or face ID
2592 # @param u U parameter on the face where the node is located
2593 # @param v V parameter on the face where the node is located
2594 # @return True if succeed else raises an exception
2595 # @ingroup l2_modif_add
2596 def SetNodeOnFace(self, NodeID, Face, u, v):
2597 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2598 FaceID = Face.GetSubShapeIndices()[0]
2602 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2603 except SALOME.SALOME_Exception, inst:
2604 raise ValueError, inst.details.text
2607 ## @brief Binds a node to a solid
2608 # @param NodeID a node ID
2609 # @param Solid a solid or solid ID
2610 # @return True if succeed else raises an exception
2611 # @ingroup l2_modif_add
2612 def SetNodeInVolume(self, NodeID, Solid):
2613 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2614 SolidID = Solid.GetSubShapeIndices()[0]
2618 self.editor.SetNodeInVolume(NodeID, SolidID)
2619 except SALOME.SALOME_Exception, inst:
2620 raise ValueError, inst.details.text
2623 ## @brief Bind an element to a shape
2624 # @param ElementID an element ID
2625 # @param Shape a shape or shape ID
2626 # @return True if succeed else raises an exception
2627 # @ingroup l2_modif_add
2628 def SetMeshElementOnShape(self, ElementID, Shape):
2629 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2630 ShapeID = Shape.GetSubShapeIndices()[0]
2634 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2635 except SALOME.SALOME_Exception, inst:
2636 raise ValueError, inst.details.text
2640 ## Moves the node with the given id
2641 # @param NodeID the id of the node
2642 # @param x a new X coordinate
2643 # @param y a new Y coordinate
2644 # @param z a new Z coordinate
2645 # @return True if succeed else False
2646 # @ingroup l2_modif_movenode
2647 def MoveNode(self, NodeID, x, y, z):
2648 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2649 self.mesh.SetParameters(Parameters)
2650 return self.editor.MoveNode(NodeID, x, y, z)
2652 ## Finds the node closest to a point and moves it to a point location
2653 # @param x the X coordinate of a point
2654 # @param y the Y coordinate of a point
2655 # @param z the Z coordinate of a point
2656 # @param NodeID if specified (>0), the node with this ID is moved,
2657 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2658 # @return the ID of a node
2659 # @ingroup l2_modif_throughp
2660 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2661 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2662 self.mesh.SetParameters(Parameters)
2663 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2665 ## Finds the node closest to a point
2666 # @param x the X coordinate of a point
2667 # @param y the Y coordinate of a point
2668 # @param z the Z coordinate of a point
2669 # @return the ID of a node
2670 # @ingroup l2_modif_throughp
2671 def FindNodeClosestTo(self, x, y, z):
2672 #preview = self.mesh.GetMeshEditPreviewer()
2673 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2674 return self.editor.FindNodeClosestTo(x, y, z)
2676 ## Finds the elements where a point lays IN or ON
2677 # @param x the X coordinate of a point
2678 # @param y the Y coordinate of a point
2679 # @param z the Z coordinate of a point
2680 # @param elementType type of elements to find (SMESH.ALL type
2681 # means elements of any type excluding nodes and 0D elements)
2682 # @return list of IDs of found elements
2683 # @ingroup l2_modif_throughp
2684 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2685 return self.editor.FindElementsByPoint(x, y, z, elementType)
2687 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2688 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2690 def GetPointState(self, x, y, z):
2691 return self.editor.GetPointState(x, y, z)
2693 ## Finds the node closest to a point and moves it to a point location
2694 # @param x the X coordinate of a point
2695 # @param y the Y coordinate of a point
2696 # @param z the Z coordinate of a point
2697 # @return the ID of a moved node
2698 # @ingroup l2_modif_throughp
2699 def MeshToPassThroughAPoint(self, x, y, z):
2700 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2702 ## Replaces two neighbour triangles sharing Node1-Node2 link
2703 # with the triangles built on the same 4 nodes but having other common link.
2704 # @param NodeID1 the ID of the first node
2705 # @param NodeID2 the ID of the second node
2706 # @return false if proper faces were not found
2707 # @ingroup l2_modif_invdiag
2708 def InverseDiag(self, NodeID1, NodeID2):
2709 return self.editor.InverseDiag(NodeID1, NodeID2)
2711 ## Replaces two neighbour triangles sharing Node1-Node2 link
2712 # with a quadrangle built on the same 4 nodes.
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_unitetri
2717 def DeleteDiag(self, NodeID1, NodeID2):
2718 return self.editor.DeleteDiag(NodeID1, NodeID2)
2720 ## Reorients elements by ids
2721 # @param IDsOfElements if undefined reorients all mesh elements
2722 # @return True if succeed else False
2723 # @ingroup l2_modif_changori
2724 def Reorient(self, IDsOfElements=None):
2725 if IDsOfElements == None:
2726 IDsOfElements = self.GetElementsId()
2727 return self.editor.Reorient(IDsOfElements)
2729 ## Reorients all elements of the object
2730 # @param theObject mesh, submesh or group
2731 # @return True if succeed else False
2732 # @ingroup l2_modif_changori
2733 def ReorientObject(self, theObject):
2734 if ( isinstance( theObject, Mesh )):
2735 theObject = theObject.GetMesh()
2736 return self.editor.ReorientObject(theObject)
2738 ## Fuses the neighbouring triangles into quadrangles.
2739 # @param IDsOfElements The triangles to be fused,
2740 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2741 # @param MaxAngle is the maximum angle between element normals at which the fusion
2742 # is still performed; theMaxAngle is mesured in radians.
2743 # Also it could be a name of variable which defines angle in degrees.
2744 # @return TRUE in case of success, FALSE otherwise.
2745 # @ingroup l2_modif_unitetri
2746 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2748 if isinstance(MaxAngle,str):
2750 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2752 MaxAngle = DegreesToRadians(MaxAngle)
2753 if IDsOfElements == []:
2754 IDsOfElements = self.GetElementsId()
2755 self.mesh.SetParameters(Parameters)
2757 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2758 Functor = theCriterion
2760 Functor = self.smeshpyD.GetFunctor(theCriterion)
2761 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2763 ## Fuses the neighbouring triangles of the object into quadrangles
2764 # @param theObject is mesh, submesh or group
2765 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2766 # @param MaxAngle a max angle between element normals at which the fusion
2767 # is still performed; theMaxAngle is mesured in radians.
2768 # @return TRUE in case of success, FALSE otherwise.
2769 # @ingroup l2_modif_unitetri
2770 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2771 if ( isinstance( theObject, Mesh )):
2772 theObject = theObject.GetMesh()
2773 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2775 ## Splits quadrangles into triangles.
2776 # @param IDsOfElements the faces to be splitted.
2777 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2778 # @return TRUE in case of success, FALSE otherwise.
2779 # @ingroup l2_modif_cutquadr
2780 def QuadToTri (self, IDsOfElements, theCriterion):
2781 if IDsOfElements == []:
2782 IDsOfElements = self.GetElementsId()
2783 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2785 ## Splits quadrangles into triangles.
2786 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2787 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2788 # @return TRUE in case of success, FALSE otherwise.
2789 # @ingroup l2_modif_cutquadr
2790 def QuadToTriObject (self, theObject, theCriterion):
2791 if ( isinstance( theObject, Mesh )):
2792 theObject = theObject.GetMesh()
2793 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2795 ## Splits quadrangles into triangles.
2796 # @param IDsOfElements the faces to be splitted
2797 # @param Diag13 is used to choose a diagonal for splitting.
2798 # @return TRUE in case of success, FALSE otherwise.
2799 # @ingroup l2_modif_cutquadr
2800 def SplitQuad (self, IDsOfElements, Diag13):
2801 if IDsOfElements == []:
2802 IDsOfElements = self.GetElementsId()
2803 return self.editor.SplitQuad(IDsOfElements, Diag13)
2805 ## Splits quadrangles into triangles.
2806 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2807 # @param Diag13 is used to choose a diagonal for splitting.
2808 # @return TRUE in case of success, FALSE otherwise.
2809 # @ingroup l2_modif_cutquadr
2810 def SplitQuadObject (self, theObject, Diag13):
2811 if ( isinstance( theObject, Mesh )):
2812 theObject = theObject.GetMesh()
2813 return self.editor.SplitQuadObject(theObject, Diag13)
2815 ## Finds a better splitting of the given quadrangle.
2816 # @param IDOfQuad the ID of the quadrangle to be splitted.
2817 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2818 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2819 # diagonal is better, 0 if error occurs.
2820 # @ingroup l2_modif_cutquadr
2821 def BestSplit (self, IDOfQuad, theCriterion):
2822 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2824 ## Splits volumic elements into tetrahedrons
2825 # @param elemIDs either list of elements or mesh or group or submesh
2826 # @param method flags passing splitting method: Hex_5Tet, Hex_6Tet, Hex_24Tet
2827 # Hex_5Tet - split the hexahedron into 5 tetrahedrons, etc
2828 # @ingroup l2_modif_cutquadr
2829 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
2830 if isinstance( elemIDs, Mesh ):
2831 elemIDs = elemIDs.GetMesh()
2832 if ( isinstance( elemIDs, list )):
2833 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
2834 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2836 ## Splits quadrangle faces near triangular facets of volumes
2838 # @ingroup l1_auxiliary
2839 def SplitQuadsNearTriangularFacets(self):
2840 faces_array = self.GetElementsByType(SMESH.FACE)
2841 for face_id in faces_array:
2842 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2843 quad_nodes = self.mesh.GetElemNodes(face_id)
2844 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2845 isVolumeFound = False
2846 for node1_elem in node1_elems:
2847 if not isVolumeFound:
2848 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2849 nb_nodes = self.GetElemNbNodes(node1_elem)
2850 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2851 volume_elem = node1_elem
2852 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2853 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2854 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2855 isVolumeFound = True
2856 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2857 self.SplitQuad([face_id], False) # diagonal 2-4
2858 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2859 isVolumeFound = True
2860 self.SplitQuad([face_id], True) # diagonal 1-3
2861 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2862 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2863 isVolumeFound = True
2864 self.SplitQuad([face_id], True) # diagonal 1-3
2866 ## @brief Splits hexahedrons into tetrahedrons.
2868 # This operation uses pattern mapping functionality for splitting.
2869 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2870 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2871 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2872 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2873 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2874 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2875 # @return TRUE in case of success, FALSE otherwise.
2876 # @ingroup l1_auxiliary
2877 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2878 # Pattern: 5.---------.6
2883 # (0,0,1) 4.---------.7 * |
2890 # (0,0,0) 0.---------.3
2891 pattern_tetra = "!!! Nb of points: \n 8 \n\
2901 !!! Indices of points of 6 tetras: \n\
2909 pattern = self.smeshpyD.GetPattern()
2910 isDone = pattern.LoadFromFile(pattern_tetra)
2912 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2915 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2916 isDone = pattern.MakeMesh(self.mesh, False, False)
2917 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2919 # split quafrangle faces near triangular facets of volumes
2920 self.SplitQuadsNearTriangularFacets()
2924 ## @brief Split hexahedrons into prisms.
2926 # Uses the pattern mapping functionality for splitting.
2927 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2928 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2929 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2930 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2931 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2932 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2933 # @return TRUE in case of success, FALSE otherwise.
2934 # @ingroup l1_auxiliary
2935 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2936 # Pattern: 5.---------.6
2941 # (0,0,1) 4.---------.7 |
2948 # (0,0,0) 0.---------.3
2949 pattern_prism = "!!! Nb of points: \n 8 \n\
2959 !!! Indices of points of 2 prisms: \n\
2963 pattern = self.smeshpyD.GetPattern()
2964 isDone = pattern.LoadFromFile(pattern_prism)
2966 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2969 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2970 isDone = pattern.MakeMesh(self.mesh, False, False)
2971 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2973 # Splits quafrangle faces near triangular facets of volumes
2974 self.SplitQuadsNearTriangularFacets()
2978 ## Smoothes elements
2979 # @param IDsOfElements the list if ids of elements to smooth
2980 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2981 # Note that nodes built on edges and boundary nodes are always fixed.
2982 # @param MaxNbOfIterations the maximum number of iterations
2983 # @param MaxAspectRatio varies in range [1.0, inf]
2984 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2985 # @return TRUE in case of success, FALSE otherwise.
2986 # @ingroup l2_modif_smooth
2987 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2988 MaxNbOfIterations, MaxAspectRatio, Method):
2989 if IDsOfElements == []:
2990 IDsOfElements = self.GetElementsId()
2991 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2992 self.mesh.SetParameters(Parameters)
2993 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2994 MaxNbOfIterations, MaxAspectRatio, Method)
2996 ## Smoothes elements which belong to the given object
2997 # @param theObject the object to smooth
2998 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2999 # Note that nodes built on edges and boundary nodes are always fixed.
3000 # @param MaxNbOfIterations the maximum number of iterations
3001 # @param MaxAspectRatio varies in range [1.0, inf]
3002 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3003 # @return TRUE in case of success, FALSE otherwise.
3004 # @ingroup l2_modif_smooth
3005 def SmoothObject(self, theObject, IDsOfFixedNodes,
3006 MaxNbOfIterations, MaxAspectRatio, Method):
3007 if ( isinstance( theObject, Mesh )):
3008 theObject = theObject.GetMesh()
3009 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
3010 MaxNbOfIterations, MaxAspectRatio, Method)
3012 ## Parametrically smoothes the given elements
3013 # @param IDsOfElements the list if ids of elements to smooth
3014 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3015 # Note that nodes built on edges and boundary nodes are always fixed.
3016 # @param MaxNbOfIterations the maximum number of iterations
3017 # @param MaxAspectRatio varies in range [1.0, inf]
3018 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3019 # @return TRUE in case of success, FALSE otherwise.
3020 # @ingroup l2_modif_smooth
3021 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
3022 MaxNbOfIterations, MaxAspectRatio, Method):
3023 if IDsOfElements == []:
3024 IDsOfElements = self.GetElementsId()
3025 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
3026 self.mesh.SetParameters(Parameters)
3027 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
3028 MaxNbOfIterations, MaxAspectRatio, Method)
3030 ## Parametrically smoothes the elements which belong to the given object
3031 # @param theObject the object to smooth
3032 # @param IDsOfFixedNodes the list of ids of fixed nodes.
3033 # Note that nodes built on edges and boundary nodes are always fixed.
3034 # @param MaxNbOfIterations the maximum number of iterations
3035 # @param MaxAspectRatio varies in range [1.0, inf]
3036 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
3037 # @return TRUE in case of success, FALSE otherwise.
3038 # @ingroup l2_modif_smooth
3039 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
3040 MaxNbOfIterations, MaxAspectRatio, Method):
3041 if ( isinstance( theObject, Mesh )):
3042 theObject = theObject.GetMesh()
3043 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
3044 MaxNbOfIterations, MaxAspectRatio, Method)
3046 ## Converts the mesh to quadratic, deletes old elements, replacing
3047 # them with quadratic with the same id.
3048 # @param theForce3d new node creation method:
3049 # 0 - the medium node lies at the geometrical edge from which the mesh element is built
3050 # 1 - the medium node lies at the middle of the line segments connecting start and end node of a mesh element
3051 # @ingroup l2_modif_tofromqu
3052 def ConvertToQuadratic(self, theForce3d):
3053 self.editor.ConvertToQuadratic(theForce3d)
3055 ## Converts the mesh from quadratic to ordinary,
3056 # deletes old quadratic elements, \n replacing
3057 # them with ordinary mesh elements with the same id.
3058 # @return TRUE in case of success, FALSE otherwise.
3059 # @ingroup l2_modif_tofromqu
3060 def ConvertFromQuadratic(self):
3061 return self.editor.ConvertFromQuadratic()
3063 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
3064 # @return TRUE if operation has been completed successfully, FALSE otherwise
3065 # @ingroup l2_modif_edit
3066 def Make2DMeshFrom3D(self):
3067 return self.editor. Make2DMeshFrom3D()
3069 ## Creates missing boundary elements
3070 # @param elements - elements whose boundary is to be checked:
3071 # mesh, group, sub-mesh or list of elements
3072 # @param dimension - defines type of boundary elements to create:
3073 # SMESH.BND_2DFROM3D, SMESH.BND_1DFROM3D, SMESH.BND_1DFROM2D
3074 # @param groupName - a name of group to store created boundary elements in,
3075 # "" means not to create the group
3076 # @param meshName - a name of new mesh to store created boundary elements in,
3077 # "" means not to create the new mesh
3078 # @param toCopyElements - if true, the checked elements will be copied into the new mesh
3079 # @param toCopyExistingBondary - if true, not only new but also pre-existing
3080 # boundary elements will be copied into the new mesh
3081 # @return tuple (mesh, group) where bondary elements were added to
3082 # @ingroup l2_modif_edit
3083 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
3084 toCopyElements=False, toCopyExistingBondary=False):
3085 if isinstance( elements, Mesh ):
3086 elements = elements.GetMesh()
3087 if ( isinstance( elements, list )):
3088 elemType = SMESH.ALL
3089 if elements: elemType = self.GetElementType( elements[0], iselem=True)
3090 elements = self.editor.MakeIDSource(elements, elemType)
3091 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
3092 toCopyElements,toCopyExistingBondary)
3093 if mesh: mesh = self.smeshpyD.Mesh(mesh)
3096 ## Renumber mesh nodes
3097 # @ingroup l2_modif_renumber
3098 def RenumberNodes(self):
3099 self.editor.RenumberNodes()
3101 ## Renumber mesh elements
3102 # @ingroup l2_modif_renumber
3103 def RenumberElements(self):
3104 self.editor.RenumberElements()
3106 ## Generates new elements by rotation of the elements around the axis
3107 # @param IDsOfElements the list of ids of elements to sweep
3108 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3109 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
3110 # @param NbOfSteps the number of steps
3111 # @param Tolerance tolerance
3112 # @param MakeGroups forces the generation of new groups from existing ones
3113 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3114 # of all steps, else - size of each step
3115 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3116 # @ingroup l2_modif_extrurev
3117 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
3118 MakeGroups=False, TotalAngle=False):
3120 if isinstance(AngleInRadians,str):
3122 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3124 AngleInRadians = DegreesToRadians(AngleInRadians)
3125 if IDsOfElements == []:
3126 IDsOfElements = self.GetElementsId()
3127 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3128 Axis = self.smeshpyD.GetAxisStruct(Axis)
3129 Axis,AxisParameters = ParseAxisStruct(Axis)
3130 if TotalAngle and NbOfSteps:
3131 AngleInRadians /= NbOfSteps
3132 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3133 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3134 self.mesh.SetParameters(Parameters)
3136 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
3137 AngleInRadians, NbOfSteps, Tolerance)
3138 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
3141 ## Generates new elements by rotation of the elements of object around the axis
3142 # @param theObject object which elements should be sweeped.
3143 # It can be a mesh, a sub mesh or a group.
3144 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3145 # @param AngleInRadians the angle of Rotation
3146 # @param NbOfSteps number of steps
3147 # @param Tolerance tolerance
3148 # @param MakeGroups forces the generation of new groups from existing ones
3149 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3150 # of all steps, else - size of each step
3151 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3152 # @ingroup l2_modif_extrurev
3153 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3154 MakeGroups=False, TotalAngle=False):
3156 if isinstance(AngleInRadians,str):
3158 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3160 AngleInRadians = DegreesToRadians(AngleInRadians)
3161 if ( isinstance( theObject, Mesh )):
3162 theObject = theObject.GetMesh()
3163 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3164 Axis = self.smeshpyD.GetAxisStruct(Axis)
3165 Axis,AxisParameters = ParseAxisStruct(Axis)
3166 if TotalAngle and NbOfSteps:
3167 AngleInRadians /= NbOfSteps
3168 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3169 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3170 self.mesh.SetParameters(Parameters)
3172 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
3173 NbOfSteps, Tolerance)
3174 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3177 ## Generates new elements by rotation of the elements of object around the axis
3178 # @param theObject object which elements should be sweeped.
3179 # It can be a mesh, a sub mesh or a group.
3180 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3181 # @param AngleInRadians the angle of Rotation
3182 # @param NbOfSteps number of steps
3183 # @param Tolerance tolerance
3184 # @param MakeGroups forces the generation of new groups from existing ones
3185 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3186 # of all steps, else - size of each step
3187 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3188 # @ingroup l2_modif_extrurev
3189 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3190 MakeGroups=False, TotalAngle=False):
3192 if isinstance(AngleInRadians,str):
3194 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3196 AngleInRadians = DegreesToRadians(AngleInRadians)
3197 if ( isinstance( theObject, Mesh )):
3198 theObject = theObject.GetMesh()
3199 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3200 Axis = self.smeshpyD.GetAxisStruct(Axis)
3201 Axis,AxisParameters = ParseAxisStruct(Axis)
3202 if TotalAngle and NbOfSteps:
3203 AngleInRadians /= NbOfSteps
3204 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3205 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3206 self.mesh.SetParameters(Parameters)
3208 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
3209 NbOfSteps, Tolerance)
3210 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3213 ## Generates new elements by rotation of the elements of object around the axis
3214 # @param theObject object which elements should be sweeped.
3215 # It can be a mesh, a sub mesh or a group.
3216 # @param Axis the axis of rotation, AxisStruct or line(geom object)
3217 # @param AngleInRadians the angle of Rotation
3218 # @param NbOfSteps number of steps
3219 # @param Tolerance tolerance
3220 # @param MakeGroups forces the generation of new groups from existing ones
3221 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
3222 # of all steps, else - size of each step
3223 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3224 # @ingroup l2_modif_extrurev
3225 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
3226 MakeGroups=False, TotalAngle=False):
3228 if isinstance(AngleInRadians,str):
3230 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
3232 AngleInRadians = DegreesToRadians(AngleInRadians)
3233 if ( isinstance( theObject, Mesh )):
3234 theObject = theObject.GetMesh()
3235 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3236 Axis = self.smeshpyD.GetAxisStruct(Axis)
3237 Axis,AxisParameters = ParseAxisStruct(Axis)
3238 if TotalAngle and NbOfSteps:
3239 AngleInRadians /= NbOfSteps
3240 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
3241 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
3242 self.mesh.SetParameters(Parameters)
3244 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
3245 NbOfSteps, Tolerance)
3246 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
3249 ## Generates new elements by extrusion of the elements with given ids
3250 # @param IDsOfElements the list of elements ids for extrusion
3251 # @param StepVector vector or DirStruct, defining the direction and value of extrusion
3252 # @param NbOfSteps the number of steps
3253 # @param MakeGroups forces the generation of new groups from existing ones
3254 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3255 # @ingroup l2_modif_extrurev
3256 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
3257 if IDsOfElements == []:
3258 IDsOfElements = self.GetElementsId()
3259 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3260 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3261 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3262 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3263 Parameters = StepVectorParameters + var_separator + Parameters
3264 self.mesh.SetParameters(Parameters)
3266 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
3267 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
3270 ## Generates new elements by extrusion of the elements with given ids
3271 # @param IDsOfElements is ids of elements
3272 # @param StepVector vector, defining the direction and value of extrusion
3273 # @param NbOfSteps the number of steps
3274 # @param ExtrFlags sets flags for extrusion
3275 # @param SewTolerance uses for comparing locations of nodes if flag
3276 # EXTRUSION_FLAG_SEW is set
3277 # @param MakeGroups forces the generation of new groups from existing ones
3278 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3279 # @ingroup l2_modif_extrurev
3280 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
3281 ExtrFlags, SewTolerance, MakeGroups=False):
3282 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3283 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3285 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
3286 ExtrFlags, SewTolerance)
3287 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
3288 ExtrFlags, SewTolerance)
3291 ## Generates new elements by extrusion of the elements which belong to the object
3292 # @param theObject the object which elements should be processed.
3293 # It can be a mesh, a sub mesh or a group.
3294 # @param StepVector vector, defining the direction and value of extrusion
3295 # @param NbOfSteps the number of steps
3296 # @param MakeGroups forces the generation of new groups from existing ones
3297 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3298 # @ingroup l2_modif_extrurev
3299 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3300 if ( isinstance( theObject, Mesh )):
3301 theObject = theObject.GetMesh()
3302 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3303 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3304 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3305 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3306 Parameters = StepVectorParameters + var_separator + Parameters
3307 self.mesh.SetParameters(Parameters)
3309 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
3310 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
3313 ## Generates new elements by extrusion of the elements which belong to the object
3314 # @param theObject object which elements should be processed.
3315 # It can be a mesh, a sub mesh or a group.
3316 # @param StepVector vector, defining the direction and value of extrusion
3317 # @param NbOfSteps the number of steps
3318 # @param MakeGroups to generate new groups from existing ones
3319 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3320 # @ingroup l2_modif_extrurev
3321 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3322 if ( isinstance( theObject, Mesh )):
3323 theObject = theObject.GetMesh()
3324 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3325 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3326 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3327 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3328 Parameters = StepVectorParameters + var_separator + Parameters
3329 self.mesh.SetParameters(Parameters)
3331 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
3332 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
3335 ## Generates new elements by extrusion of the elements which belong to the object
3336 # @param theObject object which elements should be processed.
3337 # It can be a mesh, a sub mesh or a group.
3338 # @param StepVector vector, defining the direction and value of extrusion
3339 # @param NbOfSteps the number of steps
3340 # @param MakeGroups forces the generation of new groups from existing ones
3341 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3342 # @ingroup l2_modif_extrurev
3343 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
3344 if ( isinstance( theObject, Mesh )):
3345 theObject = theObject.GetMesh()
3346 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
3347 StepVector = self.smeshpyD.GetDirStruct(StepVector)
3348 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
3349 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
3350 Parameters = StepVectorParameters + var_separator + Parameters
3351 self.mesh.SetParameters(Parameters)
3353 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
3354 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
3359 ## Generates new elements by extrusion of the given elements
3360 # The path of extrusion must be a meshed edge.
3361 # @param Base mesh or group, or submesh, or list of ids of elements for extrusion
3362 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
3363 # @param NodeStart the start node from Path. Defines the direction of extrusion
3364 # @param HasAngles allows the shape to be rotated around the path
3365 # to get the resulting mesh in a helical fashion
3366 # @param Angles list of angles in radians
3367 # @param LinearVariation forces the computation of rotation angles as linear
3368 # variation of the given Angles along path steps
3369 # @param HasRefPoint allows using the reference point
3370 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3371 # The User can specify any point as the Reference Point.
3372 # @param MakeGroups forces the generation of new groups from existing ones
3373 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3374 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3375 # only SMESH::Extrusion_Error otherwise
3376 # @ingroup l2_modif_extrurev
3377 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3378 HasAngles, Angles, LinearVariation,
3379 HasRefPoint, RefPoint, MakeGroups, ElemType):
3380 Angles,AnglesParameters = ParseAngles(Angles)
3381 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3382 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3383 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3385 Parameters = AnglesParameters + var_separator + RefPointParameters
3386 self.mesh.SetParameters(Parameters)
3388 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
3390 if isinstance(Base, list):
3392 if Base == []: IDsOfElements = self.GetElementsId()
3393 else: IDsOfElements = Base
3394 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3395 HasAngles, Angles, LinearVariation,
3396 HasRefPoint, RefPoint, MakeGroups, ElemType)
3398 if isinstance(Base, Mesh): Base = Base.GetMesh()
3399 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
3400 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3401 HasAngles, Angles, LinearVariation,
3402 HasRefPoint, RefPoint, MakeGroups, ElemType)
3404 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3407 ## Generates new elements by extrusion of the given elements
3408 # The path of extrusion must be a meshed edge.
3409 # @param IDsOfElements ids of elements
3410 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3411 # @param PathShape shape(edge) defines the sub-mesh for the path
3412 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3413 # @param HasAngles allows the shape to be rotated around the path
3414 # to get the resulting mesh in a helical fashion
3415 # @param Angles list of angles in radians
3416 # @param HasRefPoint allows using the reference point
3417 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3418 # The User can specify any point as the Reference Point.
3419 # @param MakeGroups forces the generation of new groups from existing ones
3420 # @param LinearVariation forces the computation of rotation angles as linear
3421 # variation of the given Angles along path steps
3422 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3423 # only SMESH::Extrusion_Error otherwise
3424 # @ingroup l2_modif_extrurev
3425 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3426 HasAngles, Angles, HasRefPoint, RefPoint,
3427 MakeGroups=False, LinearVariation=False):
3428 Angles,AnglesParameters = ParseAngles(Angles)
3429 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3430 if IDsOfElements == []:
3431 IDsOfElements = self.GetElementsId()
3432 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3433 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3435 if ( isinstance( PathMesh, Mesh )):
3436 PathMesh = PathMesh.GetMesh()
3437 if HasAngles and Angles and LinearVariation:
3438 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3440 Parameters = AnglesParameters + var_separator + RefPointParameters
3441 self.mesh.SetParameters(Parameters)
3443 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3444 PathShape, NodeStart, HasAngles,
3445 Angles, HasRefPoint, RefPoint)
3446 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3447 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3449 ## Generates new elements by extrusion of the elements which belong to the object
3450 # The path of extrusion must be a meshed edge.
3451 # @param theObject the object which elements should be processed.
3452 # It can be a mesh, a sub mesh or a group.
3453 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3454 # @param PathShape shape(edge) defines the sub-mesh for the path
3455 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3456 # @param HasAngles allows the shape to be rotated around the path
3457 # to get the resulting mesh in a helical fashion
3458 # @param Angles list of angles
3459 # @param HasRefPoint allows using the reference point
3460 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3461 # The User can specify any point as the Reference Point.
3462 # @param MakeGroups forces the generation of new groups from existing ones
3463 # @param LinearVariation forces the computation of rotation angles as linear
3464 # variation of the given Angles along path steps
3465 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3466 # only SMESH::Extrusion_Error otherwise
3467 # @ingroup l2_modif_extrurev
3468 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3469 HasAngles, Angles, HasRefPoint, RefPoint,
3470 MakeGroups=False, LinearVariation=False):
3471 Angles,AnglesParameters = ParseAngles(Angles)
3472 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3473 if ( isinstance( theObject, Mesh )):
3474 theObject = theObject.GetMesh()
3475 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3476 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3477 if ( isinstance( PathMesh, Mesh )):
3478 PathMesh = PathMesh.GetMesh()
3479 if HasAngles and Angles and LinearVariation:
3480 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3482 Parameters = AnglesParameters + var_separator + RefPointParameters
3483 self.mesh.SetParameters(Parameters)
3485 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3486 PathShape, NodeStart, HasAngles,
3487 Angles, HasRefPoint, RefPoint)
3488 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3489 NodeStart, HasAngles, Angles, HasRefPoint,
3492 ## Generates new elements by extrusion of the elements which belong to the object
3493 # The path of extrusion must be a meshed edge.
3494 # @param theObject the object which elements should be processed.
3495 # It can be a mesh, a sub mesh or a group.
3496 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3497 # @param PathShape shape(edge) defines the sub-mesh for the path
3498 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3499 # @param HasAngles allows the shape to be rotated around the path
3500 # to get the resulting mesh in a helical fashion
3501 # @param Angles list of angles
3502 # @param HasRefPoint allows using the reference point
3503 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3504 # The User can specify any point as the Reference Point.
3505 # @param MakeGroups forces the generation of new groups from existing ones
3506 # @param LinearVariation forces the computation of rotation angles as linear
3507 # variation of the given Angles along path steps
3508 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3509 # only SMESH::Extrusion_Error otherwise
3510 # @ingroup l2_modif_extrurev
3511 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3512 HasAngles, Angles, HasRefPoint, RefPoint,
3513 MakeGroups=False, LinearVariation=False):
3514 Angles,AnglesParameters = ParseAngles(Angles)
3515 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3516 if ( isinstance( theObject, Mesh )):
3517 theObject = theObject.GetMesh()
3518 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3519 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3520 if ( isinstance( PathMesh, Mesh )):
3521 PathMesh = PathMesh.GetMesh()
3522 if HasAngles and Angles and LinearVariation:
3523 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3525 Parameters = AnglesParameters + var_separator + RefPointParameters
3526 self.mesh.SetParameters(Parameters)
3528 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3529 PathShape, NodeStart, HasAngles,
3530 Angles, HasRefPoint, RefPoint)
3531 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3532 NodeStart, HasAngles, Angles, HasRefPoint,
3535 ## Generates new elements by extrusion of the elements which belong to the object
3536 # The path of extrusion must be a meshed edge.
3537 # @param theObject the object which elements should be processed.
3538 # It can be a mesh, a sub mesh or a group.
3539 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3540 # @param PathShape shape(edge) defines the sub-mesh for the path
3541 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3542 # @param HasAngles allows the shape to be rotated around the path
3543 # to get the resulting mesh in a helical fashion
3544 # @param Angles list of angles
3545 # @param HasRefPoint allows using the reference point
3546 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3547 # The User can specify any point as the Reference Point.
3548 # @param MakeGroups forces the generation of new groups from existing ones
3549 # @param LinearVariation forces the computation of rotation angles as linear
3550 # variation of the given Angles along path steps
3551 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3552 # only SMESH::Extrusion_Error otherwise
3553 # @ingroup l2_modif_extrurev
3554 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3555 HasAngles, Angles, HasRefPoint, RefPoint,
3556 MakeGroups=False, LinearVariation=False):
3557 Angles,AnglesParameters = ParseAngles(Angles)
3558 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3559 if ( isinstance( theObject, Mesh )):
3560 theObject = theObject.GetMesh()
3561 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3562 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3563 if ( isinstance( PathMesh, Mesh )):
3564 PathMesh = PathMesh.GetMesh()
3565 if HasAngles and Angles and LinearVariation:
3566 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3568 Parameters = AnglesParameters + var_separator + RefPointParameters
3569 self.mesh.SetParameters(Parameters)
3571 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3572 PathShape, NodeStart, HasAngles,
3573 Angles, HasRefPoint, RefPoint)
3574 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3575 NodeStart, HasAngles, Angles, HasRefPoint,
3578 ## Creates a symmetrical copy of mesh elements
3579 # @param IDsOfElements list of elements ids
3580 # @param Mirror is AxisStruct or geom object(point, line, plane)
3581 # @param theMirrorType is POINT, AXIS or PLANE
3582 # If the Mirror is a geom object this parameter is unnecessary
3583 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3584 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3585 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3586 # @ingroup l2_modif_trsf
3587 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3588 if IDsOfElements == []:
3589 IDsOfElements = self.GetElementsId()
3590 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3591 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3592 Mirror,Parameters = ParseAxisStruct(Mirror)
3593 self.mesh.SetParameters(Parameters)
3594 if Copy and MakeGroups:
3595 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3596 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3599 ## Creates a new mesh by a symmetrical copy of mesh elements
3600 # @param IDsOfElements the list of elements ids
3601 # @param Mirror is AxisStruct or geom object (point, line, plane)
3602 # @param theMirrorType is POINT, AXIS or PLANE
3603 # If the Mirror is a geom object this parameter is unnecessary
3604 # @param MakeGroups to generate new groups from existing ones
3605 # @param NewMeshName a name of the new mesh to create
3606 # @return instance of Mesh class
3607 # @ingroup l2_modif_trsf
3608 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3609 if IDsOfElements == []:
3610 IDsOfElements = self.GetElementsId()
3611 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3612 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3613 Mirror,Parameters = ParseAxisStruct(Mirror)
3614 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3615 MakeGroups, NewMeshName)
3616 mesh.SetParameters(Parameters)
3617 return Mesh(self.smeshpyD,self.geompyD,mesh)
3619 ## Creates a symmetrical copy of the object
3620 # @param theObject mesh, submesh or group
3621 # @param Mirror AxisStruct or geom object (point, line, plane)
3622 # @param theMirrorType is POINT, AXIS or PLANE
3623 # If the Mirror is a geom object this parameter is unnecessary
3624 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3625 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3626 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3627 # @ingroup l2_modif_trsf
3628 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3629 if ( isinstance( theObject, Mesh )):
3630 theObject = theObject.GetMesh()
3631 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3632 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3633 Mirror,Parameters = ParseAxisStruct(Mirror)
3634 self.mesh.SetParameters(Parameters)
3635 if Copy and MakeGroups:
3636 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3637 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3640 ## Creates a new mesh by a symmetrical copy of the object
3641 # @param theObject mesh, submesh or group
3642 # @param Mirror AxisStruct or geom object (point, line, plane)
3643 # @param theMirrorType POINT, AXIS or PLANE
3644 # If the Mirror is a geom object this parameter is unnecessary
3645 # @param MakeGroups forces the generation of new groups from existing ones
3646 # @param NewMeshName the name of the new mesh to create
3647 # @return instance of Mesh class
3648 # @ingroup l2_modif_trsf
3649 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3650 if ( isinstance( theObject, Mesh )):
3651 theObject = theObject.GetMesh()
3652 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3653 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3654 Mirror,Parameters = ParseAxisStruct(Mirror)
3655 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3656 MakeGroups, NewMeshName)
3657 mesh.SetParameters(Parameters)
3658 return Mesh( self.smeshpyD,self.geompyD,mesh )
3660 ## Translates the elements
3661 # @param IDsOfElements list of elements ids
3662 # @param Vector the direction of translation (DirStruct or vector)
3663 # @param Copy allows copying the translated elements
3664 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3665 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3666 # @ingroup l2_modif_trsf
3667 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3668 if IDsOfElements == []:
3669 IDsOfElements = self.GetElementsId()
3670 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3671 Vector = self.smeshpyD.GetDirStruct(Vector)
3672 Vector,Parameters = ParseDirStruct(Vector)
3673 self.mesh.SetParameters(Parameters)
3674 if Copy and MakeGroups:
3675 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3676 self.editor.Translate(IDsOfElements, Vector, Copy)
3679 ## Creates a new mesh of translated elements
3680 # @param IDsOfElements list of elements ids
3681 # @param Vector the direction of translation (DirStruct or vector)
3682 # @param MakeGroups forces the generation of new groups from existing ones
3683 # @param NewMeshName the name of the newly created mesh
3684 # @return instance of Mesh class
3685 # @ingroup l2_modif_trsf
3686 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3687 if IDsOfElements == []:
3688 IDsOfElements = self.GetElementsId()
3689 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3690 Vector = self.smeshpyD.GetDirStruct(Vector)
3691 Vector,Parameters = ParseDirStruct(Vector)
3692 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3693 mesh.SetParameters(Parameters)
3694 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3696 ## Translates the object
3697 # @param theObject the object to translate (mesh, submesh, or group)
3698 # @param Vector direction of translation (DirStruct or geom vector)
3699 # @param Copy allows copying the translated elements
3700 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3701 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3702 # @ingroup l2_modif_trsf
3703 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3704 if ( isinstance( theObject, Mesh )):
3705 theObject = theObject.GetMesh()
3706 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3707 Vector = self.smeshpyD.GetDirStruct(Vector)
3708 Vector,Parameters = ParseDirStruct(Vector)
3709 self.mesh.SetParameters(Parameters)
3710 if Copy and MakeGroups:
3711 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3712 self.editor.TranslateObject(theObject, Vector, Copy)
3715 ## Creates a new mesh from the translated object
3716 # @param theObject the object to translate (mesh, submesh, or group)
3717 # @param Vector the direction of translation (DirStruct or geom vector)
3718 # @param MakeGroups forces the generation of new groups from existing ones
3719 # @param NewMeshName the name of the newly created mesh
3720 # @return instance of Mesh class
3721 # @ingroup l2_modif_trsf
3722 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3723 if (isinstance(theObject, Mesh)):
3724 theObject = theObject.GetMesh()
3725 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3726 Vector = self.smeshpyD.GetDirStruct(Vector)
3727 Vector,Parameters = ParseDirStruct(Vector)
3728 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3729 mesh.SetParameters(Parameters)
3730 return Mesh( self.smeshpyD, self.geompyD, mesh )
3734 ## Scales the object
3735 # @param theObject - the object to translate (mesh, submesh, or group)
3736 # @param thePoint - base point for scale
3737 # @param theScaleFact - list of 1-3 scale factors for axises
3738 # @param Copy - allows copying the translated elements
3739 # @param MakeGroups - forces the generation of new groups from existing
3741 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3742 # empty list otherwise
3743 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3744 if ( isinstance( theObject, Mesh )):
3745 theObject = theObject.GetMesh()
3746 if ( isinstance( theObject, list )):
3747 theObject = self.GetIDSource(theObject, SMESH.ALL)
3749 thePoint, Parameters = ParsePointStruct(thePoint)
3750 self.mesh.SetParameters(Parameters)
3752 if Copy and MakeGroups:
3753 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3754 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3757 ## Creates a new mesh from the translated object
3758 # @param theObject - the object to translate (mesh, submesh, or group)
3759 # @param thePoint - base point for scale
3760 # @param theScaleFact - list of 1-3 scale factors for axises
3761 # @param MakeGroups - forces the generation of new groups from existing ones
3762 # @param NewMeshName - the name of the newly created mesh
3763 # @return instance of Mesh class
3764 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3765 if (isinstance(theObject, Mesh)):
3766 theObject = theObject.GetMesh()
3767 if ( isinstance( theObject, list )):
3768 theObject = self.GetIDSource(theObject,SMESH.ALL)
3770 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3771 MakeGroups, NewMeshName)
3772 #mesh.SetParameters(Parameters)
3773 return Mesh( self.smeshpyD, self.geompyD, mesh )
3777 ## Rotates the elements
3778 # @param IDsOfElements list of elements ids
3779 # @param Axis the axis of rotation (AxisStruct or geom line)
3780 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3781 # @param Copy allows copying the rotated elements
3782 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3783 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3784 # @ingroup l2_modif_trsf
3785 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3787 if isinstance(AngleInRadians,str):
3789 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3791 AngleInRadians = DegreesToRadians(AngleInRadians)
3792 if IDsOfElements == []:
3793 IDsOfElements = self.GetElementsId()
3794 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3795 Axis = self.smeshpyD.GetAxisStruct(Axis)
3796 Axis,AxisParameters = ParseAxisStruct(Axis)
3797 Parameters = AxisParameters + var_separator + Parameters
3798 self.mesh.SetParameters(Parameters)
3799 if Copy and MakeGroups:
3800 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3801 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3804 ## Creates a new mesh of rotated elements
3805 # @param IDsOfElements list of element ids
3806 # @param Axis the axis of rotation (AxisStruct or geom line)
3807 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3808 # @param MakeGroups forces the generation of new groups from existing ones
3809 # @param NewMeshName the name of the newly created mesh
3810 # @return instance of Mesh class
3811 # @ingroup l2_modif_trsf
3812 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3814 if isinstance(AngleInRadians,str):
3816 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3818 AngleInRadians = DegreesToRadians(AngleInRadians)
3819 if IDsOfElements == []:
3820 IDsOfElements = self.GetElementsId()
3821 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3822 Axis = self.smeshpyD.GetAxisStruct(Axis)
3823 Axis,AxisParameters = ParseAxisStruct(Axis)
3824 Parameters = AxisParameters + var_separator + Parameters
3825 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3826 MakeGroups, NewMeshName)
3827 mesh.SetParameters(Parameters)
3828 return Mesh( self.smeshpyD, self.geompyD, mesh )
3830 ## Rotates the object
3831 # @param theObject the object to rotate( mesh, submesh, or group)
3832 # @param Axis the axis of rotation (AxisStruct or geom line)
3833 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3834 # @param Copy allows copying the rotated elements
3835 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3836 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3837 # @ingroup l2_modif_trsf
3838 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3840 if isinstance(AngleInRadians,str):
3842 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3844 AngleInRadians = DegreesToRadians(AngleInRadians)
3845 if (isinstance(theObject, Mesh)):
3846 theObject = theObject.GetMesh()
3847 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3848 Axis = self.smeshpyD.GetAxisStruct(Axis)
3849 Axis,AxisParameters = ParseAxisStruct(Axis)
3850 Parameters = AxisParameters + ":" + Parameters
3851 self.mesh.SetParameters(Parameters)
3852 if Copy and MakeGroups:
3853 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3854 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3857 ## Creates a new mesh from the rotated object
3858 # @param theObject the object to rotate (mesh, submesh, or group)
3859 # @param Axis the axis of rotation (AxisStruct or geom line)
3860 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3861 # @param MakeGroups forces the generation of new groups from existing ones
3862 # @param NewMeshName the name of the newly created mesh
3863 # @return instance of Mesh class
3864 # @ingroup l2_modif_trsf
3865 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3867 if isinstance(AngleInRadians,str):
3869 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3871 AngleInRadians = DegreesToRadians(AngleInRadians)
3872 if (isinstance( theObject, Mesh )):
3873 theObject = theObject.GetMesh()
3874 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3875 Axis = self.smeshpyD.GetAxisStruct(Axis)
3876 Axis,AxisParameters = ParseAxisStruct(Axis)
3877 Parameters = AxisParameters + ":" + Parameters
3878 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3879 MakeGroups, NewMeshName)
3880 mesh.SetParameters(Parameters)
3881 return Mesh( self.smeshpyD, self.geompyD, mesh )
3883 ## Finds groups of ajacent nodes within Tolerance.
3884 # @param Tolerance the value of tolerance
3885 # @return the list of groups of nodes
3886 # @ingroup l2_modif_trsf
3887 def FindCoincidentNodes (self, Tolerance):
3888 return self.editor.FindCoincidentNodes(Tolerance)
3890 ## Finds groups of ajacent nodes within Tolerance.
3891 # @param Tolerance the value of tolerance
3892 # @param SubMeshOrGroup SubMesh or Group
3893 # @param exceptNodes list of either SubMeshes, Groups or node IDs to exclude from search
3894 # @return the list of groups of nodes
3895 # @ingroup l2_modif_trsf
3896 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
3897 if (isinstance( SubMeshOrGroup, Mesh )):
3898 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
3899 if not isinstance( exceptNodes, list):
3900 exceptNodes = [ exceptNodes ]
3901 if exceptNodes and isinstance( exceptNodes[0], int):
3902 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
3903 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
3906 # @param GroupsOfNodes the list of groups of nodes
3907 # @ingroup l2_modif_trsf
3908 def MergeNodes (self, GroupsOfNodes):
3909 self.editor.MergeNodes(GroupsOfNodes)
3911 ## Finds the elements built on the same nodes.
3912 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3913 # @return a list of groups of equal elements
3914 # @ingroup l2_modif_trsf
3915 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3916 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3917 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3918 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3920 ## Merges elements in each given group.
3921 # @param GroupsOfElementsID groups of elements for merging
3922 # @ingroup l2_modif_trsf
3923 def MergeElements(self, GroupsOfElementsID):
3924 self.editor.MergeElements(GroupsOfElementsID)
3926 ## Leaves one element and removes all other elements built on the same nodes.
3927 # @ingroup l2_modif_trsf
3928 def MergeEqualElements(self):
3929 self.editor.MergeEqualElements()
3931 ## Sews free borders
3932 # @return SMESH::Sew_Error
3933 # @ingroup l2_modif_trsf
3934 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3935 FirstNodeID2, SecondNodeID2, LastNodeID2,
3936 CreatePolygons, CreatePolyedrs):
3937 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3938 FirstNodeID2, SecondNodeID2, LastNodeID2,
3939 CreatePolygons, CreatePolyedrs)
3941 ## Sews conform free borders
3942 # @return SMESH::Sew_Error
3943 # @ingroup l2_modif_trsf
3944 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3945 FirstNodeID2, SecondNodeID2):
3946 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3947 FirstNodeID2, SecondNodeID2)
3949 ## Sews border to side
3950 # @return SMESH::Sew_Error
3951 # @ingroup l2_modif_trsf
3952 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3953 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3954 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3955 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3957 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3958 # merged with the nodes of elements of Side2.
3959 # The number of elements in theSide1 and in theSide2 must be
3960 # equal and they should have similar nodal connectivity.
3961 # The nodes to merge should belong to side borders and
3962 # the first node should be linked to the second.
3963 # @return SMESH::Sew_Error
3964 # @ingroup l2_modif_trsf
3965 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3966 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3967 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3968 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3969 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3970 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3972 ## Sets new nodes for the given element.
3973 # @param ide the element id
3974 # @param newIDs nodes ids
3975 # @return If the number of nodes does not correspond to the type of element - returns false
3976 # @ingroup l2_modif_edit
3977 def ChangeElemNodes(self, ide, newIDs):
3978 return self.editor.ChangeElemNodes(ide, newIDs)
3980 ## If during the last operation of MeshEditor some nodes were
3981 # created, this method returns the list of their IDs, \n
3982 # if new nodes were not created - returns empty list
3983 # @return the list of integer values (can be empty)
3984 # @ingroup l1_auxiliary
3985 def GetLastCreatedNodes(self):
3986 return self.editor.GetLastCreatedNodes()
3988 ## If during the last operation of MeshEditor some elements were
3989 # created this method returns the list of their IDs, \n
3990 # if new elements were not created - returns empty list
3991 # @return the list of integer values (can be empty)
3992 # @ingroup l1_auxiliary
3993 def GetLastCreatedElems(self):
3994 return self.editor.GetLastCreatedElems()
3996 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3997 # @param theNodes identifiers of nodes to be doubled
3998 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3999 # nodes. If list of element identifiers is empty then nodes are doubled but
4000 # they not assigned to elements
4001 # @return TRUE if operation has been completed successfully, FALSE otherwise
4002 # @ingroup l2_modif_edit
4003 def DoubleNodes(self, theNodes, theModifiedElems):
4004 return self.editor.DoubleNodes(theNodes, theModifiedElems)
4006 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4007 # This method provided for convenience works as DoubleNodes() described above.
4008 # @param theNodeId identifiers of node to be doubled
4009 # @param theModifiedElems identifiers of elements to be updated
4010 # @return TRUE if operation has been completed successfully, FALSE otherwise
4011 # @ingroup l2_modif_edit
4012 def DoubleNode(self, theNodeId, theModifiedElems):
4013 return self.editor.DoubleNode(theNodeId, 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 theNodes group of nodes to be doubled
4018 # @param theModifiedElems group of elements to be updated.
4019 # @param theMakeGroup forces the generation of a group containing new nodes.
4020 # @return TRUE or a created group if operation has been completed successfully,
4021 # FALSE or None otherwise
4022 # @ingroup l2_modif_edit
4023 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
4025 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
4026 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
4028 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4029 # This method provided for convenience works as DoubleNodes() described above.
4030 # @param theNodes list of groups of nodes to be doubled
4031 # @param theModifiedElems list of groups of elements to be updated.
4032 # @return TRUE if operation has been completed successfully, FALSE otherwise
4033 # @ingroup l2_modif_edit
4034 def DoubleNodeGroups(self, theNodes, theModifiedElems):
4035 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
4037 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4038 # @param theElems - the list of elements (edges or faces) to be replicated
4039 # The nodes for duplication could be found from these elements
4040 # @param theNodesNot - list of nodes to NOT replicate
4041 # @param theAffectedElems - the list of elements (cells and edges) to which the
4042 # replicated nodes should be associated to.
4043 # @return TRUE if operation has been completed successfully, FALSE otherwise
4044 # @ingroup l2_modif_edit
4045 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
4046 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
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 theShape - shape to detect affected elements (element which geometric center
4053 # located on or inside shape).
4054 # The replicated nodes should be associated to affected elements.
4055 # @return TRUE if operation has been completed successfully, FALSE otherwise
4056 # @ingroup l2_modif_edit
4057 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
4058 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
4060 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4061 # This method provided for convenience works as DoubleNodes() described above.
4062 # @param theElems - group of of elements (edges or faces) to be replicated
4063 # @param theNodesNot - group of nodes not to replicated
4064 # @param theAffectedElems - group of elements to which the replicated nodes
4065 # should be associated to.
4066 # @param theMakeGroup forces the generation of a group containing new elements.
4067 # @ingroup l2_modif_edit
4068 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
4070 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
4071 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
4073 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4074 # This method provided for convenience works as DoubleNodes() described above.
4075 # @param theElems - group of of elements (edges or faces) to be replicated
4076 # @param theNodesNot - group of nodes not to replicated
4077 # @param theShape - shape to detect affected elements (element which geometric center
4078 # located on or inside shape).
4079 # The replicated nodes should be associated to affected elements.
4080 # @ingroup l2_modif_edit
4081 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
4082 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
4084 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4085 # This method provided for convenience works as DoubleNodes() described above.
4086 # @param theElems - list of groups of elements (edges or faces) to be replicated
4087 # @param theNodesNot - list of groups of nodes not to replicated
4088 # @param theAffectedElems - group of elements to which the replicated nodes
4089 # should be associated to.
4090 # @return TRUE if operation has been completed successfully, FALSE otherwise
4091 # @ingroup l2_modif_edit
4092 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
4093 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
4095 ## Creates a hole in a mesh by doubling the nodes of some particular elements
4096 # This method provided for convenience works as DoubleNodes() described above.
4097 # @param theElems - list of groups of elements (edges or faces) to be replicated
4098 # @param theNodesNot - list of groups of nodes not to replicated
4099 # @param theShape - shape to detect affected elements (element which geometric center
4100 # located on or inside shape).
4101 # The replicated nodes should be associated to affected elements.
4102 # @return TRUE if operation has been completed successfully, FALSE otherwise
4103 # @ingroup l2_modif_edit
4104 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
4105 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
4107 ## Double nodes on shared faces between groups of volumes and create flat elements on demand.
4108 # The list of groups must describe a partition of the mesh volumes.
4109 # The nodes of the internal faces at the boundaries of the groups are doubled.
4110 # In option, the internal faces are replaced by flat elements.
4111 # Triangles are transformed in prisms, and quadrangles in hexahedrons.
4112 # @param theDomains - list of groups of volumes
4113 # @param createJointElems - if TRUE, create the elements
4114 # @return TRUE if operation has been completed successfully, FALSE otherwise
4115 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
4116 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
4118 def _valueFromFunctor(self, funcType, elemId):
4119 fn = self.smeshpyD.GetFunctor(funcType)
4120 fn.SetMesh(self.mesh)
4121 if fn.GetElementType() == self.GetElementType(elemId, True):
4122 val = fn.GetValue(elemId)
4127 ## Get length of 1D element.
4128 # @param elemId mesh element ID
4129 # @return element's length value
4130 # @ingroup l1_measurements
4131 def GetLength(self, elemId):
4132 return self._valueFromFunctor(SMESH.FT_Length, elemId)
4134 ## Get area of 2D element.
4135 # @param elemId mesh element ID
4136 # @return element's area value
4137 # @ingroup l1_measurements
4138 def GetArea(self, elemId):
4139 return self._valueFromFunctor(SMESH.FT_Area, elemId)
4141 ## Get volume of 3D element.
4142 # @param elemId mesh element ID
4143 # @return element's volume value
4144 # @ingroup l1_measurements
4145 def GetVolume(self, elemId):
4146 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
4148 ## Get maximum element length.
4149 # @param elemId mesh element ID
4150 # @return element's maximum length value
4151 # @ingroup l1_measurements
4152 def GetMaxElementLength(self, elemId):
4153 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4154 ftype = SMESH.FT_MaxElementLength3D
4156 ftype = SMESH.FT_MaxElementLength2D
4157 return self._valueFromFunctor(ftype, elemId)
4159 ## Get aspect ratio of 2D or 3D element.
4160 # @param elemId mesh element ID
4161 # @return element's aspect ratio value
4162 # @ingroup l1_measurements
4163 def GetAspectRatio(self, elemId):
4164 if self.GetElementType(elemId, True) == SMESH.VOLUME:
4165 ftype = SMESH.FT_AspectRatio3D
4167 ftype = SMESH.FT_AspectRatio
4168 return self._valueFromFunctor(ftype, elemId)
4170 ## Get warping angle of 2D element.
4171 # @param elemId mesh element ID
4172 # @return element's warping angle value
4173 # @ingroup l1_measurements
4174 def GetWarping(self, elemId):
4175 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
4177 ## Get minimum angle of 2D element.
4178 # @param elemId mesh element ID
4179 # @return element's minimum angle value
4180 # @ingroup l1_measurements
4181 def GetMinimumAngle(self, elemId):
4182 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
4184 ## Get taper of 2D element.
4185 # @param elemId mesh element ID
4186 # @return element's taper value
4187 # @ingroup l1_measurements
4188 def GetTaper(self, elemId):
4189 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
4191 ## Get skew of 2D element.
4192 # @param elemId mesh element ID
4193 # @return element's skew value
4194 # @ingroup l1_measurements
4195 def GetSkew(self, elemId):
4196 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
4198 ## The mother class to define algorithm, it is not recommended to use it directly.
4201 # @ingroup l2_algorithms
4202 class Mesh_Algorithm:
4203 # @class Mesh_Algorithm
4204 # @brief Class Mesh_Algorithm
4206 #def __init__(self,smesh):
4214 ## Finds a hypothesis in the study by its type name and parameters.
4215 # Finds only the hypotheses created in smeshpyD engine.
4216 # @return SMESH.SMESH_Hypothesis
4217 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
4218 study = smeshpyD.GetCurrentStudy()
4219 #to do: find component by smeshpyD object, not by its data type
4220 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4221 if scomp is not None:
4222 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
4223 # Check if the root label of the hypotheses exists
4224 if res and hypRoot is not None:
4225 iter = study.NewChildIterator(hypRoot)
4226 # Check all published hypotheses
4228 hypo_so_i = iter.Value()
4229 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
4230 if attr is not None:
4231 anIOR = attr.Value()
4232 hypo_o_i = salome.orb.string_to_object(anIOR)
4233 if hypo_o_i is not None:
4234 # Check if this is a hypothesis
4235 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
4236 if hypo_i is not None:
4237 # Check if the hypothesis belongs to current engine
4238 if smeshpyD.GetObjectId(hypo_i) > 0:
4239 # Check if this is the required hypothesis
4240 if hypo_i.GetName() == hypname:
4242 if CompareMethod(hypo_i, args):
4256 ## Finds the algorithm in the study by its type name.
4257 # Finds only the algorithms, which have been created in smeshpyD engine.
4258 # @return SMESH.SMESH_Algo
4259 def FindAlgorithm (self, algoname, smeshpyD):
4260 study = smeshpyD.GetCurrentStudy()
4261 #to do: find component by smeshpyD object, not by its data type
4262 scomp = study.FindComponent(smeshpyD.ComponentDataType())
4263 if scomp is not None:
4264 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
4265 # Check if the root label of the algorithms exists
4266 if res and hypRoot is not None:
4267 iter = study.NewChildIterator(hypRoot)
4268 # Check all published algorithms
4270 algo_so_i = iter.Value()
4271 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
4272 if attr is not None:
4273 anIOR = attr.Value()
4274 algo_o_i = salome.orb.string_to_object(anIOR)
4275 if algo_o_i is not None:
4276 # Check if this is an algorithm
4277 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
4278 if algo_i is not None:
4279 # Checks if the algorithm belongs to the current engine
4280 if smeshpyD.GetObjectId(algo_i) > 0:
4281 # Check if this is the required algorithm
4282 if algo_i.GetName() == algoname:
4295 ## If the algorithm is global, returns 0; \n
4296 # else returns the submesh associated to this algorithm.
4297 def GetSubMesh(self):
4300 ## Returns the wrapped mesher.
4301 def GetAlgorithm(self):
4304 ## Gets the list of hypothesis that can be used with this algorithm
4305 def GetCompatibleHypothesis(self):
4308 mylist = self.algo.GetCompatibleHypothesis()
4311 ## Gets the name of the algorithm
4315 ## Sets the name to the algorithm
4316 def SetName(self, name):
4317 self.mesh.smeshpyD.SetName(self.algo, name)
4319 ## Gets the id of the algorithm
4321 return self.algo.GetId()
4324 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
4326 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
4327 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
4329 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
4331 self.Assign(algo, mesh, geom)
4335 def Assign(self, algo, mesh, geom):
4337 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
4346 name = GetName(geom)
4349 name = mesh.geompyD.SubShapeName(geom, piece)
4351 name = "%s_%s"%(geom.GetShapeType(), id(geom%1000))
4353 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
4356 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
4357 TreatHypoStatus( status, algo.GetName(), name, True )
4359 def CompareHyp (self, hyp, args):
4360 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
4363 def CompareEqualHyp (self, hyp, args):
4367 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
4368 UseExisting=0, CompareMethod=""):
4371 if CompareMethod == "": CompareMethod = self.CompareHyp
4372 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
4375 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
4381 a = a + s + str(args[i])
4385 self.mesh.smeshpyD.SetName(hypo, hyp + a)
4389 geomName = GetName(self.geom)
4390 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
4391 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
4394 ## Returns entry of the shape to mesh in the study
4395 def MainShapeEntry(self):
4397 if not self.mesh or not self.mesh.GetMesh(): return entry
4398 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
4399 study = self.mesh.smeshpyD.GetCurrentStudy()
4400 ior = salome.orb.object_to_string( self.mesh.GetShape() )
4401 sobj = study.FindObjectIOR(ior)
4402 if sobj: entry = sobj.GetID()
4403 if not entry: return ""
4406 # Public class: Mesh_Segment
4407 # --------------------------
4409 ## Class to define a segment 1D algorithm for discretization
4412 # @ingroup l3_algos_basic
4413 class Mesh_Segment(Mesh_Algorithm):
4415 ## Private constructor.
4416 def __init__(self, mesh, geom=0):
4417 Mesh_Algorithm.__init__(self)
4418 self.Create(mesh, geom, "Regular_1D")
4420 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
4421 # @param l for the length of segments that cut an edge
4422 # @param UseExisting if ==true - searches for an existing hypothesis created with
4423 # the same parameters, else (default) - creates a new one
4424 # @param p precision, used for calculation of the number of segments.
4425 # The precision should be a positive, meaningful value within the range [0,1].
4426 # In general, the number of segments is calculated with the formula:
4427 # nb = ceil((edge_length / l) - p)
4428 # Function ceil rounds its argument to the higher integer.
4429 # So, p=0 means rounding of (edge_length / l) to the higher integer,
4430 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
4431 # p=1 means rounding of (edge_length / l) to the lower integer.
4432 # Default value is 1e-07.
4433 # @return an instance of StdMeshers_LocalLength hypothesis
4434 # @ingroup l3_hypos_1dhyps
4435 def LocalLength(self, l, UseExisting=0, p=1e-07):
4436 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
4437 CompareMethod=self.CompareLocalLength)
4443 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
4444 def CompareLocalLength(self, hyp, args):
4445 if IsEqual(hyp.GetLength(), args[0]):
4446 return IsEqual(hyp.GetPrecision(), args[1])
4449 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
4450 # @param length is optional maximal allowed length of segment, if it is omitted
4451 # the preestimated length is used that depends on geometry size
4452 # @param UseExisting if ==true - searches for an existing hypothesis created with
4453 # the same parameters, else (default) - create a new one
4454 # @return an instance of StdMeshers_MaxLength hypothesis
4455 # @ingroup l3_hypos_1dhyps
4456 def MaxSize(self, length=0.0, UseExisting=0):
4457 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
4460 hyp.SetLength(length)
4462 # set preestimated length
4463 gen = self.mesh.smeshpyD
4464 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
4465 self.mesh.GetMesh(), self.mesh.GetShape(),
4467 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
4469 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
4472 hyp.SetUsePreestimatedLength( length == 0.0 )
4475 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
4476 # @param n for the number of segments that cut an edge
4477 # @param s for the scale factor (optional)
4478 # @param reversedEdges is a list of edges to mesh using reversed orientation
4479 # @param UseExisting if ==true - searches for an existing hypothesis created with
4480 # the same parameters, else (default) - create a new one
4481 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4482 # @ingroup l3_hypos_1dhyps
4483 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4484 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4485 reversedEdges, UseExisting = [], reversedEdges
4486 entry = self.MainShapeEntry()
4487 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4488 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4490 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4491 UseExisting=UseExisting,
4492 CompareMethod=self.CompareNumberOfSegments)
4494 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4495 UseExisting=UseExisting,
4496 CompareMethod=self.CompareNumberOfSegments)
4497 hyp.SetDistrType( 1 )
4498 hyp.SetScaleFactor(s)
4499 hyp.SetNumberOfSegments(n)
4500 hyp.SetReversedEdges( reversedEdges )
4501 hyp.SetObjectEntry( entry )
4505 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4506 def CompareNumberOfSegments(self, hyp, args):
4507 if hyp.GetNumberOfSegments() == args[0]:
4509 if hyp.GetReversedEdges() == args[1]:
4510 if not args[1] or hyp.GetObjectEntry() == args[2]:
4513 if hyp.GetReversedEdges() == args[2]:
4514 if not args[2] or hyp.GetObjectEntry() == args[3]:
4515 if hyp.GetDistrType() == 1:
4516 if IsEqual(hyp.GetScaleFactor(), args[1]):
4520 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4521 # @param start defines the length of the first segment
4522 # @param end defines the length of the last segment
4523 # @param reversedEdges is a list of edges to mesh using reversed orientation
4524 # @param UseExisting if ==true - searches for an existing hypothesis created with
4525 # the same parameters, else (default) - creates a new one
4526 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4527 # @ingroup l3_hypos_1dhyps
4528 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4529 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4530 reversedEdges, UseExisting = [], reversedEdges
4531 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4532 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4533 entry = self.MainShapeEntry()
4534 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4535 UseExisting=UseExisting,
4536 CompareMethod=self.CompareArithmetic1D)
4537 hyp.SetStartLength(start)
4538 hyp.SetEndLength(end)
4539 hyp.SetReversedEdges( reversedEdges )
4540 hyp.SetObjectEntry( entry )
4544 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4545 def CompareArithmetic1D(self, hyp, args):
4546 if IsEqual(hyp.GetLength(1), args[0]):
4547 if IsEqual(hyp.GetLength(0), args[1]):
4548 if hyp.GetReversedEdges() == args[2]:
4549 if not args[2] or hyp.GetObjectEntry() == args[3]:
4554 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4555 # on curve from 0 to 1 (additionally it is neecessary to check
4556 # orientation of edges and create list of reversed edges if it is
4557 # needed) and sets numbers of segments between given points (default
4558 # values are equals 1
4559 # @param points defines the list of parameters on curve
4560 # @param nbSegs defines the list of numbers of segments
4561 # @param reversedEdges is a list of edges to mesh using reversed orientation
4562 # @param UseExisting if ==true - searches for an existing hypothesis created with
4563 # the same parameters, else (default) - creates a new one
4564 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4565 # @ingroup l3_hypos_1dhyps
4566 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4567 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4568 reversedEdges, UseExisting = [], reversedEdges
4569 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4570 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4571 entry = self.MainShapeEntry()
4572 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4573 UseExisting=UseExisting,
4574 CompareMethod=self.CompareFixedPoints1D)
4575 hyp.SetPoints(points)
4576 hyp.SetNbSegments(nbSegs)
4577 hyp.SetReversedEdges(reversedEdges)
4578 hyp.SetObjectEntry(entry)
4582 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4583 ## as the given arguments
4584 def CompareFixedPoints1D(self, hyp, args):
4585 if hyp.GetPoints() == args[0]:
4586 if hyp.GetNbSegments() == args[1]:
4587 if hyp.GetReversedEdges() == args[2]:
4588 if not args[2] or hyp.GetObjectEntry() == args[3]:
4594 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4595 # @param start defines the length of the first segment
4596 # @param end defines the length of the last segment
4597 # @param reversedEdges is a list of edges to mesh using reversed orientation
4598 # @param UseExisting if ==true - searches for an existing hypothesis created with
4599 # the same parameters, else (default) - creates a new one
4600 # @return an instance of StdMeshers_StartEndLength hypothesis
4601 # @ingroup l3_hypos_1dhyps
4602 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4603 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4604 reversedEdges, UseExisting = [], reversedEdges
4605 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
4606 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
4607 entry = self.MainShapeEntry()
4608 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4609 UseExisting=UseExisting,
4610 CompareMethod=self.CompareStartEndLength)
4611 hyp.SetStartLength(start)
4612 hyp.SetEndLength(end)
4613 hyp.SetReversedEdges( reversedEdges )
4614 hyp.SetObjectEntry( entry )
4617 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4618 def CompareStartEndLength(self, hyp, args):
4619 if IsEqual(hyp.GetLength(1), args[0]):
4620 if IsEqual(hyp.GetLength(0), args[1]):
4621 if hyp.GetReversedEdges() == args[2]:
4622 if not args[2] or hyp.GetObjectEntry() == args[3]:
4626 ## Defines "Deflection1D" hypothesis
4627 # @param d for the deflection
4628 # @param UseExisting if ==true - searches for an existing hypothesis created with
4629 # the same parameters, else (default) - create a new one
4630 # @ingroup l3_hypos_1dhyps
4631 def Deflection1D(self, d, UseExisting=0):
4632 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4633 CompareMethod=self.CompareDeflection1D)
4634 hyp.SetDeflection(d)
4637 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4638 def CompareDeflection1D(self, hyp, args):
4639 return IsEqual(hyp.GetDeflection(), args[0])
4641 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4642 # the opposite side in case of quadrangular faces
4643 # @ingroup l3_hypos_additi
4644 def Propagation(self):
4645 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4647 ## Defines "AutomaticLength" hypothesis
4648 # @param fineness for the fineness [0-1]
4649 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4650 # same parameters, else (default) - create a new one
4651 # @ingroup l3_hypos_1dhyps
4652 def AutomaticLength(self, fineness=0, UseExisting=0):
4653 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4654 CompareMethod=self.CompareAutomaticLength)
4655 hyp.SetFineness( fineness )
4658 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4659 def CompareAutomaticLength(self, hyp, args):
4660 return IsEqual(hyp.GetFineness(), args[0])
4662 ## Defines "SegmentLengthAroundVertex" hypothesis
4663 # @param length for the segment length
4664 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4665 # Any other integer value means that the hypothesis will be set on the
4666 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4667 # @param UseExisting if ==true - searches for an existing hypothesis created with
4668 # the same parameters, else (default) - creates a new one
4669 # @ingroup l3_algos_segmarv
4670 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4672 store_geom = self.geom
4673 if type(vertex) is types.IntType:
4674 if vertex == 0 or vertex == 1:
4675 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
4683 if self.geom is None:
4684 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4686 name = GetName(self.geom)
4689 piece = self.mesh.geom
4690 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4691 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4693 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4695 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4697 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4698 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4700 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4701 CompareMethod=self.CompareLengthNearVertex)
4702 self.geom = store_geom
4703 hyp.SetLength( length )
4706 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4707 # @ingroup l3_algos_segmarv
4708 def CompareLengthNearVertex(self, hyp, args):
4709 return IsEqual(hyp.GetLength(), args[0])
4711 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4712 # If the 2D mesher sees that all boundary edges are quadratic,
4713 # it generates quadratic faces, else it generates linear faces using
4714 # medium nodes as if they are vertices.
4715 # The 3D mesher generates quadratic volumes only if all boundary faces
4716 # are quadratic, else it fails.
4718 # @ingroup l3_hypos_additi
4719 def QuadraticMesh(self):
4720 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4723 # Public class: Mesh_CompositeSegment
4724 # --------------------------
4726 ## Defines a segment 1D algorithm for discretization
4728 # @ingroup l3_algos_basic
4729 class Mesh_CompositeSegment(Mesh_Segment):
4731 ## Private constructor.
4732 def __init__(self, mesh, geom=0):
4733 self.Create(mesh, geom, "CompositeSegment_1D")
4736 # Public class: Mesh_Segment_Python
4737 # ---------------------------------
4739 ## Defines a segment 1D algorithm for discretization with python function
4741 # @ingroup l3_algos_basic
4742 class Mesh_Segment_Python(Mesh_Segment):
4744 ## Private constructor.
4745 def __init__(self, mesh, geom=0):
4746 import Python1dPlugin
4747 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4749 ## Defines "PythonSplit1D" hypothesis
4750 # @param n for the number of segments that cut an edge
4751 # @param func for the python function that calculates the length of all segments
4752 # @param UseExisting if ==true - searches for the existing hypothesis created with
4753 # the same parameters, else (default) - creates a new one
4754 # @ingroup l3_hypos_1dhyps
4755 def PythonSplit1D(self, n, func, UseExisting=0):
4756 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4757 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4758 hyp.SetNumberOfSegments(n)
4759 hyp.SetPythonLog10RatioFunction(func)
4762 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4763 def ComparePythonSplit1D(self, hyp, args):
4764 #if hyp.GetNumberOfSegments() == args[0]:
4765 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4769 # Public class: Mesh_Triangle
4770 # ---------------------------
4772 ## Defines a triangle 2D algorithm
4774 # @ingroup l3_algos_basic
4775 class Mesh_Triangle(Mesh_Algorithm):
4784 ## Private constructor.
4785 def __init__(self, mesh, algoType, geom=0):
4786 Mesh_Algorithm.__init__(self)
4788 self.algoType = algoType
4789 if algoType == MEFISTO:
4790 self.Create(mesh, geom, "MEFISTO_2D")
4792 elif algoType == BLSURF:
4794 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4795 #self.SetPhysicalMesh() - PAL19680
4796 elif algoType == NETGEN:
4798 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4800 elif algoType == NETGEN_2D:
4802 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4805 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4806 # @param area for the maximum area of each triangle
4807 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4808 # same parameters, else (default) - creates a new one
4810 # Only for algoType == MEFISTO || NETGEN_2D
4811 # @ingroup l3_hypos_2dhyps
4812 def MaxElementArea(self, area, UseExisting=0):
4813 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4814 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4815 CompareMethod=self.CompareMaxElementArea)
4816 elif self.algoType == NETGEN:
4817 hyp = self.Parameters(SIMPLE)
4818 hyp.SetMaxElementArea(area)
4821 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4822 def CompareMaxElementArea(self, hyp, args):
4823 return IsEqual(hyp.GetMaxElementArea(), args[0])
4825 ## Defines "LengthFromEdges" hypothesis to build triangles
4826 # based on the length of the edges taken from the wire
4828 # Only for algoType == MEFISTO || NETGEN_2D
4829 # @ingroup l3_hypos_2dhyps
4830 def LengthFromEdges(self):
4831 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4832 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4834 elif self.algoType == NETGEN:
4835 hyp = self.Parameters(SIMPLE)
4836 hyp.LengthFromEdges()
4839 ## Sets a way to define size of mesh elements to generate.
4840 # @param thePhysicalMesh is: DefaultSize or Custom.
4841 # @ingroup l3_hypos_blsurf
4842 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4843 # Parameter of BLSURF algo
4844 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4846 ## Sets size of mesh elements to generate.
4847 # @ingroup l3_hypos_blsurf
4848 def SetPhySize(self, theVal):
4849 # Parameter of BLSURF algo
4850 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4851 self.Parameters().SetPhySize(theVal)
4853 ## Sets lower boundary of mesh element size (PhySize).
4854 # @ingroup l3_hypos_blsurf
4855 def SetPhyMin(self, theVal=-1):
4856 # Parameter of BLSURF algo
4857 self.Parameters().SetPhyMin(theVal)
4859 ## Sets upper boundary of mesh element size (PhySize).
4860 # @ingroup l3_hypos_blsurf
4861 def SetPhyMax(self, theVal=-1):
4862 # Parameter of BLSURF algo
4863 self.Parameters().SetPhyMax(theVal)
4865 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4866 # @param theGeometricMesh is: 0 (None) or 1 (Custom)
4867 # @ingroup l3_hypos_blsurf
4868 def SetGeometricMesh(self, theGeometricMesh=0):
4869 # Parameter of BLSURF algo
4870 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4871 self.params.SetGeometricMesh(theGeometricMesh)
4873 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4874 # @ingroup l3_hypos_blsurf
4875 def SetAngleMeshS(self, theVal=_angleMeshS):
4876 # Parameter of BLSURF algo
4877 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4878 self.params.SetAngleMeshS(theVal)
4880 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4881 # @ingroup l3_hypos_blsurf
4882 def SetAngleMeshC(self, theVal=_angleMeshS):
4883 # Parameter of BLSURF algo
4884 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4885 self.params.SetAngleMeshC(theVal)
4887 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4888 # @ingroup l3_hypos_blsurf
4889 def SetGeoMin(self, theVal=-1):
4890 # Parameter of BLSURF algo
4891 self.Parameters().SetGeoMin(theVal)
4893 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4894 # @ingroup l3_hypos_blsurf
4895 def SetGeoMax(self, theVal=-1):
4896 # Parameter of BLSURF algo
4897 self.Parameters().SetGeoMax(theVal)
4899 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4900 # @ingroup l3_hypos_blsurf
4901 def SetGradation(self, theVal=_gradation):
4902 # Parameter of BLSURF algo
4903 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4904 self.params.SetGradation(theVal)
4906 ## Sets topology usage way.
4907 # @param way defines how mesh conformity is assured <ul>
4908 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4909 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4910 # @ingroup l3_hypos_blsurf
4911 def SetTopology(self, way):
4912 # Parameter of BLSURF algo
4913 self.Parameters().SetTopology(way)
4915 ## To respect geometrical edges or not.
4916 # @ingroup l3_hypos_blsurf
4917 def SetDecimesh(self, toIgnoreEdges=False):
4918 # Parameter of BLSURF algo
4919 self.Parameters().SetDecimesh(toIgnoreEdges)
4921 ## Sets verbosity level in the range 0 to 100.
4922 # @ingroup l3_hypos_blsurf
4923 def SetVerbosity(self, level):
4924 # Parameter of BLSURF algo
4925 self.Parameters().SetVerbosity(level)
4927 ## Sets advanced option value.
4928 # @ingroup l3_hypos_blsurf
4929 def SetOptionValue(self, optionName, level):
4930 # Parameter of BLSURF algo
4931 self.Parameters().SetOptionValue(optionName,level)
4933 ## Sets QuadAllowed flag.
4934 # Only for algoType == NETGEN(NETGEN_1D2D) || NETGEN_2D || BLSURF
4935 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4936 def SetQuadAllowed(self, toAllow=True):
4937 if self.algoType == NETGEN_2D:
4940 hasSimpleHyps = False
4941 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
4942 for hyp in self.mesh.GetHypothesisList( self.geom ):
4943 if hyp.GetName() in simpleHyps:
4944 hasSimpleHyps = True
4945 if hyp.GetName() == "QuadranglePreference":
4946 if not toAllow: # remove QuadranglePreference
4947 self.mesh.RemoveHypothesis( self.geom, hyp )
4953 if toAllow: # add QuadranglePreference
4954 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4959 if self.Parameters():
4960 self.params.SetQuadAllowed(toAllow)
4963 ## Defines hypothesis having several parameters
4965 # @ingroup l3_hypos_netgen
4966 def Parameters(self, which=SOLE):
4968 if self.algoType == NETGEN:
4970 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4971 "libNETGENEngine.so", UseExisting=0)
4973 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4974 "libNETGENEngine.so", UseExisting=0)
4975 elif self.algoType == MEFISTO:
4976 print "Mefisto algo support no multi-parameter hypothesis"
4977 elif self.algoType == NETGEN_2D:
4978 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
4979 "libNETGENEngine.so", UseExisting=0)
4980 elif self.algoType == BLSURF:
4981 self.params = self.Hypothesis("BLSURF_Parameters", [],
4982 "libBLSURFEngine.so", UseExisting=0)
4984 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4989 # Only for algoType == NETGEN
4990 # @ingroup l3_hypos_netgen
4991 def SetMaxSize(self, theSize):
4992 if self.Parameters():
4993 self.params.SetMaxSize(theSize)
4995 ## Sets SecondOrder flag
4997 # Only for algoType == NETGEN
4998 # @ingroup l3_hypos_netgen
4999 def SetSecondOrder(self, theVal):
5000 if self.Parameters():
5001 self.params.SetSecondOrder(theVal)
5003 ## Sets Optimize flag
5005 # Only for algoType == NETGEN
5006 # @ingroup l3_hypos_netgen
5007 def SetOptimize(self, theVal):
5008 if self.Parameters():
5009 self.params.SetOptimize(theVal)
5012 # @param theFineness is:
5013 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5015 # Only for algoType == NETGEN
5016 # @ingroup l3_hypos_netgen
5017 def SetFineness(self, theFineness):
5018 if self.Parameters():
5019 self.params.SetFineness(theFineness)
5023 # Only for algoType == NETGEN
5024 # @ingroup l3_hypos_netgen
5025 def SetGrowthRate(self, theRate):
5026 if self.Parameters():
5027 self.params.SetGrowthRate(theRate)
5029 ## Sets NbSegPerEdge
5031 # Only for algoType == NETGEN
5032 # @ingroup l3_hypos_netgen
5033 def SetNbSegPerEdge(self, theVal):
5034 if self.Parameters():
5035 self.params.SetNbSegPerEdge(theVal)
5037 ## Sets NbSegPerRadius
5039 # Only for algoType == NETGEN
5040 # @ingroup l3_hypos_netgen
5041 def SetNbSegPerRadius(self, theVal):
5042 if self.Parameters():
5043 self.params.SetNbSegPerRadius(theVal)
5045 ## Sets number of segments overriding value set by SetLocalLength()
5047 # Only for algoType == NETGEN
5048 # @ingroup l3_hypos_netgen
5049 def SetNumberOfSegments(self, theVal):
5050 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5052 ## Sets number of segments overriding value set by SetNumberOfSegments()
5054 # Only for algoType == NETGEN
5055 # @ingroup l3_hypos_netgen
5056 def SetLocalLength(self, theVal):
5057 self.Parameters(SIMPLE).SetLocalLength(theVal)
5062 # Public class: Mesh_Quadrangle
5063 # -----------------------------
5065 ## Defines a quadrangle 2D algorithm
5067 # @ingroup l3_algos_basic
5068 class Mesh_Quadrangle(Mesh_Algorithm):
5072 ## Private constructor.
5073 def __init__(self, mesh, geom=0):
5074 Mesh_Algorithm.__init__(self)
5075 self.Create(mesh, geom, "Quadrangle_2D")
5078 ## Defines "QuadrangleParameters" hypothesis
5079 # @param quadType defines the algorithm of transition between differently descretized
5080 # sides of a geometrical face:
5081 # - QUAD_STANDARD - both triangles and quadrangles are possible in the transition
5082 # area along the finer meshed sides.
5083 # - QUAD_TRIANGLE_PREF - only triangles are built in the transition area along the
5084 # finer meshed sides.
5085 # - QUAD_QUADRANGLE_PREF - only quadrangles are built in the transition area along
5086 # the finer meshed sides, iff the total quantity of segments on
5087 # all four sides of the face is even (divisible by 2).
5088 # - QUAD_QUADRANGLE_PREF_REVERSED - same as QUAD_QUADRANGLE_PREF but the transition
5089 # area is located along the coarser meshed sides.
5090 # - QUAD_REDUCED - only quadrangles are built and the transition between the sides
5091 # is made gradually, layer by layer. This type has a limitation on
5092 # the number of segments: one pair of opposite sides must have the
5093 # same number of segments, the other pair must have an even difference
5094 # between the numbers of segments on the sides.
5095 # @param triangleVertex: vertex of a trilateral geometrical face, around which triangles
5096 # will be created while other elements will be quadrangles.
5097 # Vertex can be either a GEOM_Object or a vertex ID within the
5099 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5100 # the same parameters, else (default) - creates a new one
5101 # @ingroup l3_hypos_quad
5102 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
5103 vertexID = triangleVertex
5104 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
5105 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
5107 compFun = lambda hyp,args: \
5108 hyp.GetQuadType() == args[0] and \
5109 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
5110 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
5111 UseExisting = UseExisting, CompareMethod=compFun)
5113 if self.params.GetQuadType() != quadType:
5114 self.params.SetQuadType(quadType)
5116 self.params.SetTriaVertex( vertexID )
5119 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5120 # quadrangles are built in the transition area along the finer meshed sides,
5121 # iff the total quantity of segments on all four sides of the face is even.
5122 # @param reversed if True, transition area is located along the coarser meshed sides.
5123 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5124 # the same parameters, else (default) - creates a new one
5125 # @ingroup l3_hypos_quad
5126 def QuadranglePreference(self, reversed=False, UseExisting=0):
5128 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
5129 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
5131 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5132 # triangles are built in the transition area along the finer meshed sides.
5133 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5134 # the same parameters, else (default) - creates a new one
5135 # @ingroup l3_hypos_quad
5136 def TrianglePreference(self, UseExisting=0):
5137 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
5139 ## Defines "QuadrangleParams" hypothesis with a type of quadrangulation that only
5140 # quadrangles are built and the transition between the sides is made gradually,
5141 # layer by layer. This type has a limitation on the number of segments: one pair
5142 # of opposite sides must have the same number of segments, the other pair must
5143 # have an even difference between the numbers of segments on the sides.
5144 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5145 # the same parameters, else (default) - creates a new one
5146 # @ingroup l3_hypos_quad
5147 def Reduced(self, UseExisting=0):
5148 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
5150 ## Defines "QuadrangleParams" hypothesis with QUAD_STANDARD type of quadrangulation
5151 # @param vertex: vertex of a trilateral geometrical face, around which triangles
5152 # will be created while other elements will be quadrangles.
5153 # Vertex can be either a GEOM_Object or a vertex ID within the
5155 # @param UseExisting: if ==true - searches for the existing hypothesis created with
5156 # the same parameters, else (default) - creates a new one
5157 # @ingroup l3_hypos_quad
5158 def TriangleVertex(self, vertex, UseExisting=0):
5159 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
5162 # Public class: Mesh_Tetrahedron
5163 # ------------------------------
5165 ## Defines a tetrahedron 3D algorithm
5167 # @ingroup l3_algos_basic
5168 class Mesh_Tetrahedron(Mesh_Algorithm):
5173 ## Private constructor.
5174 def __init__(self, mesh, algoType, geom=0):
5175 Mesh_Algorithm.__init__(self)
5177 if algoType == NETGEN:
5179 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
5182 elif algoType == FULL_NETGEN:
5184 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5187 elif algoType == GHS3D:
5189 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
5192 elif algoType == GHS3DPRL:
5193 CheckPlugin(GHS3DPRL)
5194 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
5197 self.algoType = algoType
5199 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
5200 # @param vol for the maximum volume of each tetrahedron
5201 # @param UseExisting if ==true - searches for the existing hypothesis created with
5202 # the same parameters, else (default) - creates a new one
5203 # @ingroup l3_hypos_maxvol
5204 def MaxElementVolume(self, vol, UseExisting=0):
5205 if self.algoType == NETGEN:
5206 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
5207 CompareMethod=self.CompareMaxElementVolume)
5208 hyp.SetMaxElementVolume(vol)
5210 elif self.algoType == FULL_NETGEN:
5211 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
5214 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
5215 def CompareMaxElementVolume(self, hyp, args):
5216 return IsEqual(hyp.GetMaxElementVolume(), args[0])
5218 ## Defines hypothesis having several parameters
5220 # @ingroup l3_hypos_netgen
5221 def Parameters(self, which=SOLE):
5224 if self.algoType == FULL_NETGEN:
5226 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
5227 "libNETGENEngine.so", UseExisting=0)
5229 self.params = self.Hypothesis("NETGEN_Parameters", [],
5230 "libNETGENEngine.so", UseExisting=0)
5232 if self.algoType == NETGEN:
5233 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
5234 "libNETGENEngine.so", UseExisting=0)
5236 elif self.algoType == GHS3D:
5237 self.params = self.Hypothesis("GHS3D_Parameters", [],
5238 "libGHS3DEngine.so", UseExisting=0)
5240 elif self.algoType == GHS3DPRL:
5241 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
5242 "libGHS3DPRLEngine.so", UseExisting=0)
5244 print "Algo supports no multi-parameter hypothesis"
5249 # Parameter of FULL_NETGEN and NETGEN
5250 # @ingroup l3_hypos_netgen
5251 def SetMaxSize(self, theSize):
5252 self.Parameters().SetMaxSize(theSize)
5254 ## Sets SecondOrder flag
5255 # Parameter of FULL_NETGEN
5256 # @ingroup l3_hypos_netgen
5257 def SetSecondOrder(self, theVal):
5258 self.Parameters().SetSecondOrder(theVal)
5260 ## Sets Optimize flag
5261 # Parameter of FULL_NETGEN and NETGEN
5262 # @ingroup l3_hypos_netgen
5263 def SetOptimize(self, theVal):
5264 self.Parameters().SetOptimize(theVal)
5267 # @param theFineness is:
5268 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
5269 # Parameter of FULL_NETGEN
5270 # @ingroup l3_hypos_netgen
5271 def SetFineness(self, theFineness):
5272 self.Parameters().SetFineness(theFineness)
5275 # Parameter of FULL_NETGEN
5276 # @ingroup l3_hypos_netgen
5277 def SetGrowthRate(self, theRate):
5278 self.Parameters().SetGrowthRate(theRate)
5280 ## Sets NbSegPerEdge
5281 # Parameter of FULL_NETGEN
5282 # @ingroup l3_hypos_netgen
5283 def SetNbSegPerEdge(self, theVal):
5284 self.Parameters().SetNbSegPerEdge(theVal)
5286 ## Sets NbSegPerRadius
5287 # Parameter of FULL_NETGEN
5288 # @ingroup l3_hypos_netgen
5289 def SetNbSegPerRadius(self, theVal):
5290 self.Parameters().SetNbSegPerRadius(theVal)
5292 ## Sets number of segments overriding value set by SetLocalLength()
5293 # Only for algoType == NETGEN_FULL
5294 # @ingroup l3_hypos_netgen
5295 def SetNumberOfSegments(self, theVal):
5296 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
5298 ## Sets number of segments overriding value set by SetNumberOfSegments()
5299 # Only for algoType == NETGEN_FULL
5300 # @ingroup l3_hypos_netgen
5301 def SetLocalLength(self, theVal):
5302 self.Parameters(SIMPLE).SetLocalLength(theVal)
5304 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
5305 # Overrides value set by LengthFromEdges()
5306 # Only for algoType == NETGEN_FULL
5307 # @ingroup l3_hypos_netgen
5308 def MaxElementArea(self, area):
5309 self.Parameters(SIMPLE).SetMaxElementArea(area)
5311 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
5312 # Overrides value set by MaxElementArea()
5313 # Only for algoType == NETGEN_FULL
5314 # @ingroup l3_hypos_netgen
5315 def LengthFromEdges(self):
5316 self.Parameters(SIMPLE).LengthFromEdges()
5318 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
5319 # Overrides value set by MaxElementVolume()
5320 # Only for algoType == NETGEN_FULL
5321 # @ingroup l3_hypos_netgen
5322 def LengthFromFaces(self):
5323 self.Parameters(SIMPLE).LengthFromFaces()
5325 ## To mesh "holes" in a solid or not. Default is to mesh.
5326 # @ingroup l3_hypos_ghs3dh
5327 def SetToMeshHoles(self, toMesh):
5328 # Parameter of GHS3D
5329 self.Parameters().SetToMeshHoles(toMesh)
5331 ## Set Optimization level:
5332 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
5333 # Strong_Optimization.
5334 # Default is Standard_Optimization
5335 # @ingroup l3_hypos_ghs3dh
5336 def SetOptimizationLevel(self, level):
5337 # Parameter of GHS3D
5338 self.Parameters().SetOptimizationLevel(level)
5340 ## Maximal size of memory to be used by the algorithm (in Megabytes).
5341 # @ingroup l3_hypos_ghs3dh
5342 def SetMaximumMemory(self, MB):
5343 # Advanced parameter of GHS3D
5344 self.Parameters().SetMaximumMemory(MB)
5346 ## Initial size of memory to be used by the algorithm (in Megabytes) in
5347 # automatic memory adjustment mode.
5348 # @ingroup l3_hypos_ghs3dh
5349 def SetInitialMemory(self, MB):
5350 # Advanced parameter of GHS3D
5351 self.Parameters().SetInitialMemory(MB)
5353 ## Path to working directory.
5354 # @ingroup l3_hypos_ghs3dh
5355 def SetWorkingDirectory(self, path):
5356 # Advanced parameter of GHS3D
5357 self.Parameters().SetWorkingDirectory(path)
5359 ## To keep working files or remove them. Log file remains in case of errors anyway.
5360 # @ingroup l3_hypos_ghs3dh
5361 def SetKeepFiles(self, toKeep):
5362 # Advanced parameter of GHS3D and GHS3DPRL
5363 self.Parameters().SetKeepFiles(toKeep)
5365 ## To set verbose level [0-10]. <ul>
5366 #<li> 0 - no standard output,
5367 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
5368 # indicates when the final mesh is being saved. In addition the software
5369 # gives indication regarding the CPU time.
5370 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
5371 # histogram of the skin mesh, quality statistics histogram together with
5372 # the characteristics of the final mesh.</ul>
5373 # @ingroup l3_hypos_ghs3dh
5374 def SetVerboseLevel(self, level):
5375 # Advanced parameter of GHS3D
5376 self.Parameters().SetVerboseLevel(level)
5378 ## To create new nodes.
5379 # @ingroup l3_hypos_ghs3dh
5380 def SetToCreateNewNodes(self, toCreate):
5381 # Advanced parameter of GHS3D
5382 self.Parameters().SetToCreateNewNodes(toCreate)
5384 ## To use boundary recovery version which tries to create mesh on a very poor
5385 # quality surface mesh.
5386 # @ingroup l3_hypos_ghs3dh
5387 def SetToUseBoundaryRecoveryVersion(self, toUse):
5388 # Advanced parameter of GHS3D
5389 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
5391 ## Sets command line option as text.
5392 # @ingroup l3_hypos_ghs3dh
5393 def SetTextOption(self, option):
5394 # Advanced parameter of GHS3D
5395 self.Parameters().SetTextOption(option)
5397 ## Sets MED files name and path.
5398 def SetMEDName(self, value):
5399 self.Parameters().SetMEDName(value)
5401 ## Sets the number of partition of the initial mesh
5402 def SetNbPart(self, value):
5403 self.Parameters().SetNbPart(value)
5405 ## When big mesh, start tepal in background
5406 def SetBackground(self, value):
5407 self.Parameters().SetBackground(value)
5409 # Public class: Mesh_Hexahedron
5410 # ------------------------------
5412 ## Defines a hexahedron 3D algorithm
5414 # @ingroup l3_algos_basic
5415 class Mesh_Hexahedron(Mesh_Algorithm):
5420 ## Private constructor.
5421 def __init__(self, mesh, algoType=Hexa, geom=0):
5422 Mesh_Algorithm.__init__(self)
5424 self.algoType = algoType
5426 if algoType == Hexa:
5427 self.Create(mesh, geom, "Hexa_3D")
5430 elif algoType == Hexotic:
5431 CheckPlugin(Hexotic)
5432 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
5435 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
5436 # @ingroup l3_hypos_hexotic
5437 def MinMaxQuad(self, min=3, max=8, quad=True):
5438 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
5440 self.params.SetHexesMinLevel(min)
5441 self.params.SetHexesMaxLevel(max)
5442 self.params.SetHexoticQuadrangles(quad)
5445 # Deprecated, only for compatibility!
5446 # Public class: Mesh_Netgen
5447 # ------------------------------
5449 ## Defines a NETGEN-based 2D or 3D algorithm
5450 # that needs no discrete boundary (i.e. independent)
5452 # This class is deprecated, only for compatibility!
5455 # @ingroup l3_algos_basic
5456 class Mesh_Netgen(Mesh_Algorithm):
5460 ## Private constructor.
5461 def __init__(self, mesh, is3D, geom=0):
5462 Mesh_Algorithm.__init__(self)
5468 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
5472 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
5475 ## Defines the hypothesis containing parameters of the algorithm
5476 def Parameters(self):
5478 hyp = self.Hypothesis("NETGEN_Parameters", [],
5479 "libNETGENEngine.so", UseExisting=0)
5481 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
5482 "libNETGENEngine.so", UseExisting=0)
5485 # Public class: Mesh_Projection1D
5486 # ------------------------------
5488 ## Defines a projection 1D algorithm
5489 # @ingroup l3_algos_proj
5491 class Mesh_Projection1D(Mesh_Algorithm):
5493 ## Private constructor.
5494 def __init__(self, mesh, geom=0):
5495 Mesh_Algorithm.__init__(self)
5496 self.Create(mesh, geom, "Projection_1D")
5498 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
5499 # a mesh pattern is taken, and, optionally, the association of vertices
5500 # between the source edge and a target edge (to which a hypothesis is assigned)
5501 # @param edge from which nodes distribution is taken
5502 # @param mesh from which nodes distribution is taken (optional)
5503 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
5504 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
5505 # to associate with \a srcV (optional)
5506 # @param UseExisting if ==true - searches for the existing hypothesis created with
5507 # the same parameters, else (default) - creates a new one
5508 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
5509 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
5511 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
5512 hyp.SetSourceEdge( edge )
5513 if not mesh is None and isinstance(mesh, Mesh):
5514 mesh = mesh.GetMesh()
5515 hyp.SetSourceMesh( mesh )
5516 hyp.SetVertexAssociation( srcV, tgtV )
5519 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
5520 #def CompareSourceEdge(self, hyp, args):
5521 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
5525 # Public class: Mesh_Projection2D
5526 # ------------------------------
5528 ## Defines a projection 2D algorithm
5529 # @ingroup l3_algos_proj
5531 class Mesh_Projection2D(Mesh_Algorithm):
5533 ## Private constructor.
5534 def __init__(self, mesh, geom=0):
5535 Mesh_Algorithm.__init__(self)
5536 self.Create(mesh, geom, "Projection_2D")
5538 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
5539 # a mesh pattern is taken, and, optionally, the association of vertices
5540 # between the source face and the target face (to which a hypothesis is assigned)
5541 # @param face from which the mesh pattern is taken
5542 # @param mesh from which the mesh pattern is taken (optional)
5543 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5544 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5545 # to associate with \a srcV1 (optional)
5546 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5547 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5548 # to associate with \a srcV2 (optional)
5549 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5550 # the same parameters, else (default) - forces the creation a new one
5552 # Note: all association vertices must belong to one edge of a face
5553 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5554 srcV2=None, tgtV2=None, UseExisting=0):
5555 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5557 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5558 hyp.SetSourceFace( face )
5559 if not mesh is None and isinstance(mesh, Mesh):
5560 mesh = mesh.GetMesh()
5561 hyp.SetSourceMesh( mesh )
5562 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5565 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5566 #def CompareSourceFace(self, hyp, args):
5567 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5570 # Public class: Mesh_Projection3D
5571 # ------------------------------
5573 ## Defines a projection 3D algorithm
5574 # @ingroup l3_algos_proj
5576 class Mesh_Projection3D(Mesh_Algorithm):
5578 ## Private constructor.
5579 def __init__(self, mesh, geom=0):
5580 Mesh_Algorithm.__init__(self)
5581 self.Create(mesh, geom, "Projection_3D")
5583 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5584 # the mesh pattern is taken, and, optionally, the association of vertices
5585 # between the source and the target solid (to which a hipothesis is assigned)
5586 # @param solid from where the mesh pattern is taken
5587 # @param mesh from where the mesh pattern is taken (optional)
5588 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5589 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5590 # to associate with \a srcV1 (optional)
5591 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5592 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5593 # to associate with \a srcV2 (optional)
5594 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5595 # the same parameters, else (default) - creates a new one
5597 # Note: association vertices must belong to one edge of a solid
5598 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5599 srcV2=0, tgtV2=0, UseExisting=0):
5600 hyp = self.Hypothesis("ProjectionSource3D",
5601 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5603 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5604 hyp.SetSource3DShape( solid )
5605 if not mesh is None and isinstance(mesh, Mesh):
5606 mesh = mesh.GetMesh()
5607 hyp.SetSourceMesh( mesh )
5608 if srcV1 and srcV2 and tgtV1 and tgtV2:
5609 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5610 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5613 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5614 #def CompareSourceShape3D(self, hyp, args):
5615 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5619 # Public class: Mesh_Prism
5620 # ------------------------
5622 ## Defines a 3D extrusion algorithm
5623 # @ingroup l3_algos_3dextr
5625 class Mesh_Prism3D(Mesh_Algorithm):
5627 ## Private constructor.
5628 def __init__(self, mesh, geom=0):
5629 Mesh_Algorithm.__init__(self)
5630 self.Create(mesh, geom, "Prism_3D")
5632 # Public class: Mesh_RadialPrism
5633 # -------------------------------
5635 ## Defines a Radial Prism 3D algorithm
5636 # @ingroup l3_algos_radialp
5638 class Mesh_RadialPrism3D(Mesh_Algorithm):
5640 ## Private constructor.
5641 def __init__(self, mesh, geom=0):
5642 Mesh_Algorithm.__init__(self)
5643 self.Create(mesh, geom, "RadialPrism_3D")
5645 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5646 self.nbLayers = None
5648 ## Return 3D hypothesis holding the 1D one
5649 def Get3DHypothesis(self):
5650 return self.distribHyp
5652 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5653 # hypothesis. Returns the created hypothesis
5654 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5655 #print "OwnHypothesis",hypType
5656 if not self.nbLayers is None:
5657 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5658 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5659 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5660 self.mesh.smeshpyD.SetCurrentStudy( None )
5661 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5662 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5663 self.distribHyp.SetLayerDistribution( hyp )
5666 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5667 # prisms to build between the inner and outer shells
5668 # @param n number of layers
5669 # @param UseExisting if ==true - searches for the existing hypothesis created with
5670 # the same parameters, else (default) - creates a new one
5671 def NumberOfLayers(self, n, UseExisting=0):
5672 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5673 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5674 CompareMethod=self.CompareNumberOfLayers)
5675 self.nbLayers.SetNumberOfLayers( n )
5676 return self.nbLayers
5678 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5679 def CompareNumberOfLayers(self, hyp, args):
5680 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5682 ## Defines "LocalLength" hypothesis, specifying the segment length
5683 # to build between the inner and the outer shells
5684 # @param l the length of segments
5685 # @param p the precision of rounding
5686 def LocalLength(self, l, p=1e-07):
5687 hyp = self.OwnHypothesis("LocalLength", [l,p])
5692 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5693 # prisms to build between the inner and the outer shells.
5694 # @param n the number of layers
5695 # @param s the scale factor (optional)
5696 def NumberOfSegments(self, n, s=[]):
5698 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5700 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5701 hyp.SetDistrType( 1 )
5702 hyp.SetScaleFactor(s)
5703 hyp.SetNumberOfSegments(n)
5706 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5707 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5708 # @param start the length of the first segment
5709 # @param end the length of the last segment
5710 def Arithmetic1D(self, start, end ):
5711 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5712 hyp.SetLength(start, 1)
5713 hyp.SetLength(end , 0)
5716 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5717 # to build between the inner and the outer shells as geometric length increasing
5718 # @param start for the length of the first segment
5719 # @param end for the length of the last segment
5720 def StartEndLength(self, start, end):
5721 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5722 hyp.SetLength(start, 1)
5723 hyp.SetLength(end , 0)
5726 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5727 # to build between the inner and outer shells
5728 # @param fineness defines the quality of the mesh within the range [0-1]
5729 def AutomaticLength(self, fineness=0):
5730 hyp = self.OwnHypothesis("AutomaticLength")
5731 hyp.SetFineness( fineness )
5734 # Public class: Mesh_RadialQuadrangle1D2D
5735 # -------------------------------
5737 ## Defines a Radial Quadrangle 1D2D algorithm
5738 # @ingroup l2_algos_radialq
5740 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5742 ## Private constructor.
5743 def __init__(self, mesh, geom=0):
5744 Mesh_Algorithm.__init__(self)
5745 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5747 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5748 self.nbLayers = None
5750 ## Return 2D hypothesis holding the 1D one
5751 def Get2DHypothesis(self):
5752 return self.distribHyp
5754 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5755 # hypothesis. Returns the created hypothesis
5756 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5757 #print "OwnHypothesis",hypType
5759 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5760 if self.distribHyp is None:
5761 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5763 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5764 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5765 self.mesh.smeshpyD.SetCurrentStudy( None )
5766 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5767 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5768 self.distribHyp.SetLayerDistribution( hyp )
5771 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5772 # @param n number of layers
5773 # @param UseExisting if ==true - searches for the existing hypothesis created with
5774 # the same parameters, else (default) - creates a new one
5775 def NumberOfLayers(self, n, UseExisting=0):
5777 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5778 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5779 CompareMethod=self.CompareNumberOfLayers)
5780 self.nbLayers.SetNumberOfLayers( n )
5781 return self.nbLayers
5783 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5784 def CompareNumberOfLayers(self, hyp, args):
5785 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5787 ## Defines "LocalLength" hypothesis, specifying the segment length
5788 # @param l the length of segments
5789 # @param p the precision of rounding
5790 def LocalLength(self, l, p=1e-07):
5791 hyp = self.OwnHypothesis("LocalLength", [l,p])
5796 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5797 # @param n the number of layers
5798 # @param s the scale factor (optional)
5799 def NumberOfSegments(self, n, s=[]):
5801 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5803 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5804 hyp.SetDistrType( 1 )
5805 hyp.SetScaleFactor(s)
5806 hyp.SetNumberOfSegments(n)
5809 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5810 # with a length that changes in arithmetic progression
5811 # @param start the length of the first segment
5812 # @param end the length of the last segment
5813 def Arithmetic1D(self, start, end ):
5814 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5815 hyp.SetLength(start, 1)
5816 hyp.SetLength(end , 0)
5819 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5820 # as geometric length increasing
5821 # @param start for the length of the first segment
5822 # @param end for the length of the last segment
5823 def StartEndLength(self, start, end):
5824 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5825 hyp.SetLength(start, 1)
5826 hyp.SetLength(end , 0)
5829 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5830 # @param fineness defines the quality of the mesh within the range [0-1]
5831 def AutomaticLength(self, fineness=0):
5832 hyp = self.OwnHypothesis("AutomaticLength")
5833 hyp.SetFineness( fineness )
5837 # Public class: Mesh_UseExistingElements
5838 # --------------------------------------
5839 ## Defines a Radial Quadrangle 1D2D algorithm
5840 # @ingroup l3_algos_basic
5842 class Mesh_UseExistingElements(Mesh_Algorithm):
5844 def __init__(self, dim, mesh, geom=0):
5846 self.Create(mesh, geom, "Import_1D")
5848 self.Create(mesh, geom, "Import_1D2D")
5851 ## Defines "Source edges" hypothesis, specifying groups of edges to import
5852 # @param groups list of groups of edges
5853 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5854 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5855 # @param UseExisting if ==true - searches for the existing hypothesis created with
5856 # the same parameters, else (default) - creates a new one
5857 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5858 if self.algo.GetName() == "Import_2D":
5859 raise ValueError, "algoritm dimension mismatch"
5860 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
5861 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5862 hyp.SetSourceEdges(groups)
5863 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5866 ## Defines "Source faces" hypothesis, specifying groups of faces to import
5867 # @param groups list of groups of faces
5868 # @param toCopyMesh if True, the whole mesh \a groups belong to is imported
5869 # @param toCopyGroups if True, all groups of the mesh \a groups belong to are imported
5870 # @param UseExisting if ==true - searches for the existing hypothesis created with
5871 # the same parameters, else (default) - creates a new one
5872 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
5873 if self.algo.GetName() == "Import_1D":
5874 raise ValueError, "algoritm dimension mismatch"
5875 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
5876 UseExisting=UseExisting, CompareMethod=self._compareHyp)
5877 hyp.SetSourceFaces(groups)
5878 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
5881 def _compareHyp(self,hyp,args):
5882 if hasattr( hyp, "GetSourceEdges"):
5883 entries = hyp.GetSourceEdges()
5885 entries = hyp.GetSourceFaces()
5887 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
5888 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
5890 study = self.mesh.smeshpyD.GetCurrentStudy()
5893 ior = salome.orb.object_to_string(g)
5894 sobj = study.FindObjectIOR(ior)
5895 if sobj: entries2.append( sobj.GetID() )
5900 return entries == entries2
5904 # Private class: Mesh_UseExisting
5905 # -------------------------------
5906 class Mesh_UseExisting(Mesh_Algorithm):
5908 def __init__(self, dim, mesh, geom=0):
5910 self.Create(mesh, geom, "UseExisting_1D")
5912 self.Create(mesh, geom, "UseExisting_2D")
5915 import salome_notebook
5916 notebook = salome_notebook.notebook
5918 ##Return values of the notebook variables
5919 def ParseParameters(last, nbParams,nbParam, value):
5923 listSize = len(last)
5924 for n in range(0,nbParams):
5926 if counter < listSize:
5927 strResult = strResult + last[counter]
5929 strResult = strResult + ""
5931 if isinstance(value, str):
5932 if notebook.isVariable(value):
5933 result = notebook.get(value)
5934 strResult=strResult+value
5936 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5938 strResult=strResult+str(value)
5940 if nbParams - 1 != counter:
5941 strResult=strResult+var_separator #":"
5943 return result, strResult
5945 #Wrapper class for StdMeshers_LocalLength hypothesis
5946 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5948 ## Set Length parameter value
5949 # @param length numerical value or name of variable from notebook
5950 def SetLength(self, length):
5951 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5952 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5953 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5955 ## Set Precision parameter value
5956 # @param precision numerical value or name of variable from notebook
5957 def SetPrecision(self, precision):
5958 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5959 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5960 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5962 #Registering the new proxy for LocalLength
5963 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5966 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5967 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5969 def SetLayerDistribution(self, hypo):
5970 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5971 hypo.ClearParameters();
5972 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5974 #Registering the new proxy for LayerDistribution
5975 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5977 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5978 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5980 ## Set Length parameter value
5981 # @param length numerical value or name of variable from notebook
5982 def SetLength(self, length):
5983 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5984 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5985 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5987 #Registering the new proxy for SegmentLengthAroundVertex
5988 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5991 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5992 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5994 ## Set Length parameter value
5995 # @param length numerical value or name of variable from notebook
5996 # @param isStart true is length is Start Length, otherwise false
5997 def SetLength(self, length, isStart):
6001 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
6002 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
6003 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
6005 #Registering the new proxy for Arithmetic1D
6006 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
6008 #Wrapper class for StdMeshers_Deflection1D hypothesis
6009 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
6011 ## Set Deflection parameter value
6012 # @param deflection numerical value or name of variable from notebook
6013 def SetDeflection(self, deflection):
6014 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
6015 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
6016 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
6018 #Registering the new proxy for Deflection1D
6019 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
6021 #Wrapper class for StdMeshers_StartEndLength hypothesis
6022 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
6024 ## Set Length parameter value
6025 # @param length numerical value or name of variable from notebook
6026 # @param isStart true is length is Start Length, otherwise false
6027 def SetLength(self, length, isStart):
6031 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
6032 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
6033 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
6035 #Registering the new proxy for StartEndLength
6036 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
6038 #Wrapper class for StdMeshers_MaxElementArea hypothesis
6039 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
6041 ## Set Max Element Area parameter value
6042 # @param area numerical value or name of variable from notebook
6043 def SetMaxElementArea(self, area):
6044 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
6045 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
6046 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
6048 #Registering the new proxy for MaxElementArea
6049 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
6052 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
6053 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
6055 ## Set Max Element Volume parameter value
6056 # @param volume numerical value or name of variable from notebook
6057 def SetMaxElementVolume(self, volume):
6058 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
6059 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
6060 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
6062 #Registering the new proxy for MaxElementVolume
6063 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
6066 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
6067 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
6069 ## Set Number Of Layers parameter value
6070 # @param nbLayers numerical value or name of variable from notebook
6071 def SetNumberOfLayers(self, nbLayers):
6072 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
6073 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
6074 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
6076 #Registering the new proxy for NumberOfLayers
6077 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
6079 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
6080 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
6082 ## Set Number Of Segments parameter value
6083 # @param nbSeg numerical value or name of variable from notebook
6084 def SetNumberOfSegments(self, nbSeg):
6085 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
6086 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
6087 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6088 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
6090 ## Set Scale Factor parameter value
6091 # @param factor numerical value or name of variable from notebook
6092 def SetScaleFactor(self, factor):
6093 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
6094 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
6095 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
6097 #Registering the new proxy for NumberOfSegments
6098 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
6100 if not noNETGENPlugin:
6101 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
6102 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
6104 ## Set Max Size parameter value
6105 # @param maxsize numerical value or name of variable from notebook
6106 def SetMaxSize(self, maxsize):
6107 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6108 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
6109 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6110 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
6112 ## Set Growth Rate parameter value
6113 # @param value numerical value or name of variable from notebook
6114 def SetGrowthRate(self, value):
6115 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6116 value, parameters = ParseParameters(lastParameters,4,2,value)
6117 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6118 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
6120 ## Set Number of Segments per Edge parameter value
6121 # @param value numerical value or name of variable from notebook
6122 def SetNbSegPerEdge(self, value):
6123 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6124 value, parameters = ParseParameters(lastParameters,4,3,value)
6125 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6126 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
6128 ## Set Number of Segments per Radius parameter value
6129 # @param value numerical value or name of variable from notebook
6130 def SetNbSegPerRadius(self, value):
6131 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
6132 value, parameters = ParseParameters(lastParameters,4,4,value)
6133 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
6134 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
6136 #Registering the new proxy for NETGENPlugin_Hypothesis
6137 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
6140 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
6141 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
6144 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
6145 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
6147 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
6148 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
6150 ## Set Number of Segments parameter value
6151 # @param nbSeg numerical value or name of variable from notebook
6152 def SetNumberOfSegments(self, nbSeg):
6153 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6154 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
6155 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6156 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
6158 ## Set Local Length parameter value
6159 # @param length numerical value or name of variable from notebook
6160 def SetLocalLength(self, length):
6161 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6162 length, parameters = ParseParameters(lastParameters,2,1,length)
6163 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6164 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
6166 ## Set Max Element Area parameter value
6167 # @param area numerical value or name of variable from notebook
6168 def SetMaxElementArea(self, area):
6169 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6170 area, parameters = ParseParameters(lastParameters,2,2,area)
6171 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6172 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
6174 def LengthFromEdges(self):
6175 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
6177 value, parameters = ParseParameters(lastParameters,2,2,value)
6178 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
6179 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
6181 #Registering the new proxy for NETGEN_SimpleParameters_2D
6182 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
6185 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
6186 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
6187 ## Set Max Element Volume parameter value
6188 # @param volume numerical value or name of variable from notebook
6189 def SetMaxElementVolume(self, volume):
6190 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6191 volume, parameters = ParseParameters(lastParameters,3,3,volume)
6192 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6193 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
6195 def LengthFromFaces(self):
6196 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
6198 value, parameters = ParseParameters(lastParameters,3,3,value)
6199 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
6200 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
6202 #Registering the new proxy for NETGEN_SimpleParameters_3D
6203 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
6205 pass # if not noNETGENPlugin:
6207 class Pattern(SMESH._objref_SMESH_Pattern):
6209 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
6211 if isinstance(theNodeIndexOnKeyPoint1,str):
6213 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
6215 theNodeIndexOnKeyPoint1 -= 1
6216 theMesh.SetParameters(Parameters)
6217 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
6219 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
6222 if isinstance(theNode000Index,str):
6224 if isinstance(theNode001Index,str):
6226 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
6228 theNode000Index -= 1
6230 theNode001Index -= 1
6231 theMesh.SetParameters(Parameters)
6232 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
6234 #Registering the new proxy for Pattern
6235 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)