1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 import SMESH # This is necessary for back compatibility
104 # import NETGENPlugin module if possible
112 # import GHS3DPlugin module if possible
120 # import GHS3DPRLPlugin module if possible
123 import GHS3DPRLPlugin
128 # import HexoticPlugin module if possible
136 # import BLSURFPlugin module if possible
144 ## @addtogroup l1_auxiliary
147 # Types of algorithms
160 NETGEN_1D2D3D = FULL_NETGEN
161 NETGEN_FULL = FULL_NETGEN
169 # MirrorType enumeration
170 POINT = SMESH_MeshEditor.POINT
171 AXIS = SMESH_MeshEditor.AXIS
172 PLANE = SMESH_MeshEditor.PLANE
174 # Smooth_Method enumeration
175 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
176 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
178 # Fineness enumeration (for NETGEN)
186 # Optimization level of GHS3D
188 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
189 # V4.1 (partialy redefines V3.1). Issue 0020574
190 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
192 # Topology treatment way of BLSURF
193 FromCAD, PreProcess, PreProcessPlus = 0,1,2
195 # Element size flag of BLSURF
196 DefaultSize, DefaultGeom, Custom = 0,0,1
198 PrecisionConfusion = 1e-07
200 ## Converts an angle from degrees to radians
201 def DegreesToRadians(AngleInDegrees):
203 return AngleInDegrees * pi / 180.0
205 # Salome notebook variable separator
208 # Parametrized substitute for PointStruct
209 class PointStructStr:
218 def __init__(self, xStr, yStr, zStr):
222 if isinstance(xStr, str) and notebook.isVariable(xStr):
223 self.x = notebook.get(xStr)
226 if isinstance(yStr, str) and notebook.isVariable(yStr):
227 self.y = notebook.get(yStr)
230 if isinstance(zStr, str) and notebook.isVariable(zStr):
231 self.z = notebook.get(zStr)
235 # Parametrized substitute for PointStruct (with 6 parameters)
236 class PointStructStr6:
251 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
258 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
259 self.x1 = notebook.get(x1Str)
262 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
263 self.x2 = notebook.get(x2Str)
266 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
267 self.y1 = notebook.get(y1Str)
270 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
271 self.y2 = notebook.get(y2Str)
274 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
275 self.z1 = notebook.get(z1Str)
278 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
279 self.z2 = notebook.get(z2Str)
283 # Parametrized substitute for AxisStruct
299 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
306 if isinstance(xStr, str) and notebook.isVariable(xStr):
307 self.x = notebook.get(xStr)
310 if isinstance(yStr, str) and notebook.isVariable(yStr):
311 self.y = notebook.get(yStr)
314 if isinstance(zStr, str) and notebook.isVariable(zStr):
315 self.z = notebook.get(zStr)
318 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
319 self.dx = notebook.get(dxStr)
322 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
323 self.dy = notebook.get(dyStr)
326 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
327 self.dz = notebook.get(dzStr)
331 # Parametrized substitute for DirStruct
334 def __init__(self, pointStruct):
335 self.pointStruct = pointStruct
337 # Returns list of variable values from salome notebook
338 def ParsePointStruct(Point):
339 Parameters = 2*var_separator
340 if isinstance(Point, PointStructStr):
341 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
342 Point = PointStruct(Point.x, Point.y, Point.z)
343 return Point, Parameters
345 # Returns list of variable values from salome notebook
346 def ParseDirStruct(Dir):
347 Parameters = 2*var_separator
348 if isinstance(Dir, DirStructStr):
349 pntStr = Dir.pointStruct
350 if isinstance(pntStr, PointStructStr6):
351 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
352 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
353 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
354 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
356 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
357 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
358 Dir = DirStruct(Point)
359 return Dir, Parameters
361 # Returns list of variable values from salome notebook
362 def ParseAxisStruct(Axis):
363 Parameters = 5*var_separator
364 if isinstance(Axis, AxisStructStr):
365 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
366 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
367 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
368 return Axis, Parameters
370 ## Return list of variable values from salome notebook
371 def ParseAngles(list):
374 for parameter in list:
375 if isinstance(parameter,str) and notebook.isVariable(parameter):
376 Result.append(DegreesToRadians(notebook.get(parameter)))
379 Result.append(parameter)
382 Parameters = Parameters + str(parameter)
383 Parameters = Parameters + var_separator
385 Parameters = Parameters[:len(Parameters)-1]
386 return Result, Parameters
388 def IsEqual(val1, val2, tol=PrecisionConfusion):
389 if abs(val1 - val2) < tol:
395 if isinstance(obj, SALOMEDS._objref_SObject):
397 ior = salome.orb.object_to_string(obj)
398 studies = salome.myStudyManager.GetOpenStudies()
399 for sname in studies:
400 s = salome.myStudyManager.GetStudyByName(sname)
402 sobj = s.FindObjectIOR(ior)
403 if not sobj: continue
404 return sobj.GetName()
405 raise RuntimeError, "Null or invalid object"
407 ## Prints error message if a hypothesis was not assigned.
408 def TreatHypoStatus(status, hypName, geomName, isAlgo):
410 hypType = "algorithm"
412 hypType = "hypothesis"
414 if status == HYP_UNKNOWN_FATAL :
415 reason = "for unknown reason"
416 elif status == HYP_INCOMPATIBLE :
417 reason = "this hypothesis mismatches the algorithm"
418 elif status == HYP_NOTCONFORM :
419 reason = "a non-conform mesh would be built"
420 elif status == HYP_ALREADY_EXIST :
421 reason = hypType + " of the same dimension is already assigned to this shape"
422 elif status == HYP_BAD_DIM :
423 reason = hypType + " mismatches the shape"
424 elif status == HYP_CONCURENT :
425 reason = "there are concurrent hypotheses on sub-shapes"
426 elif status == HYP_BAD_SUBSHAPE :
427 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
428 elif status == HYP_BAD_GEOMETRY:
429 reason = "geometry mismatches the expectation of the algorithm"
430 elif status == HYP_HIDDEN_ALGO:
431 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
432 elif status == HYP_HIDING_ALGO:
433 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
434 elif status == HYP_NEED_SHAPE:
435 reason = "Algorithm can't work without shape"
438 hypName = '"' + hypName + '"'
439 geomName= '"' + geomName+ '"'
440 if status < HYP_UNKNOWN_FATAL:
441 print hypName, "was assigned to", geomName,"but", reason
443 print hypName, "was not assigned to",geomName,":", reason
446 ## Check meshing plugin availability
447 def CheckPlugin(plugin):
448 if plugin == NETGEN and noNETGENPlugin:
449 print "Warning: NETGENPlugin module unavailable"
451 elif plugin == GHS3D and noGHS3DPlugin:
452 print "Warning: GHS3DPlugin module unavailable"
454 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
455 print "Warning: GHS3DPRLPlugin module unavailable"
457 elif plugin == Hexotic and noHexoticPlugin:
458 print "Warning: HexoticPlugin module unavailable"
460 elif plugin == BLSURF and noBLSURFPlugin:
461 print "Warning: BLSURFPlugin module unavailable"
465 # end of l1_auxiliary
468 # All methods of this class are accessible directly from the smesh.py package.
469 class smeshDC(SMESH._objref_SMESH_Gen):
471 ## Sets the current study and Geometry component
472 # @ingroup l1_auxiliary
473 def init_smesh(self,theStudy,geompyD):
474 self.SetCurrentStudy(theStudy,geompyD)
476 ## Creates an empty Mesh. This mesh can have an underlying geometry.
477 # @param obj the Geometrical object on which the mesh is built. If not defined,
478 # the mesh will have no underlying geometry.
479 # @param name the name for the new mesh.
480 # @return an instance of Mesh class.
481 # @ingroup l2_construct
482 def Mesh(self, obj=0, name=0):
483 if isinstance(obj,str):
485 return Mesh(self,self.geompyD,obj,name)
487 ## Returns a long value from enumeration
488 # Should be used for SMESH.FunctorType enumeration
489 # @ingroup l1_controls
490 def EnumToLong(self,theItem):
493 ## Gets PointStruct from vertex
494 # @param theVertex a GEOM object(vertex)
495 # @return SMESH.PointStruct
496 # @ingroup l1_auxiliary
497 def GetPointStruct(self,theVertex):
498 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
499 return PointStruct(x,y,z)
501 ## Gets DirStruct from vector
502 # @param theVector a GEOM object(vector)
503 # @return SMESH.DirStruct
504 # @ingroup l1_auxiliary
505 def GetDirStruct(self,theVector):
506 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
507 if(len(vertices) != 2):
508 print "Error: vector object is incorrect."
510 p1 = self.geompyD.PointCoordinates(vertices[0])
511 p2 = self.geompyD.PointCoordinates(vertices[1])
512 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
513 dirst = DirStruct(pnt)
516 ## Makes DirStruct from a triplet
517 # @param x,y,z vector components
518 # @return SMESH.DirStruct
519 # @ingroup l1_auxiliary
520 def MakeDirStruct(self,x,y,z):
521 pnt = PointStruct(x,y,z)
522 return DirStruct(pnt)
524 ## Get AxisStruct from object
525 # @param theObj a GEOM object (line or plane)
526 # @return SMESH.AxisStruct
527 # @ingroup l1_auxiliary
528 def GetAxisStruct(self,theObj):
529 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
531 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
532 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
533 vertex1 = self.geompyD.PointCoordinates(vertex1)
534 vertex2 = self.geompyD.PointCoordinates(vertex2)
535 vertex3 = self.geompyD.PointCoordinates(vertex3)
536 vertex4 = self.geompyD.PointCoordinates(vertex4)
537 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
538 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
539 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] ]
540 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
542 elif len(edges) == 1:
543 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
544 p1 = self.geompyD.PointCoordinates( vertex1 )
545 p2 = self.geompyD.PointCoordinates( vertex2 )
546 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
550 # From SMESH_Gen interface:
551 # ------------------------
553 ## Sets the given name to the object
554 # @param obj the object to rename
555 # @param name a new object name
556 # @ingroup l1_auxiliary
557 def SetName(self, obj, name):
558 if isinstance( obj, Mesh ):
560 elif isinstance( obj, Mesh_Algorithm ):
561 obj = obj.GetAlgorithm()
562 ior = salome.orb.object_to_string(obj)
563 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
565 ## Sets the current mode
566 # @ingroup l1_auxiliary
567 def SetEmbeddedMode( self,theMode ):
568 #self.SetEmbeddedMode(theMode)
569 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
571 ## Gets the current mode
572 # @ingroup l1_auxiliary
573 def IsEmbeddedMode(self):
574 #return self.IsEmbeddedMode()
575 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
577 ## Sets the current study
578 # @ingroup l1_auxiliary
579 def SetCurrentStudy( self, theStudy, geompyD = None ):
580 #self.SetCurrentStudy(theStudy)
583 geompyD = geompy.geom
586 self.SetGeomEngine(geompyD)
587 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
589 ## Gets the current study
590 # @ingroup l1_auxiliary
591 def GetCurrentStudy(self):
592 #return self.GetCurrentStudy()
593 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
595 ## Creates a Mesh object importing data from the given UNV file
596 # @return an instance of Mesh class
598 def CreateMeshesFromUNV( self,theFileName ):
599 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
600 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
603 ## Creates a Mesh object(s) importing data from the given MED file
604 # @return a list of Mesh class instances
606 def CreateMeshesFromMED( self,theFileName ):
607 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
609 for iMesh in range(len(aSmeshMeshes)) :
610 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
611 aMeshes.append(aMesh)
612 return aMeshes, aStatus
614 ## Creates a Mesh object importing data from the given STL file
615 # @return an instance of Mesh class
617 def CreateMeshesFromSTL( self, theFileName ):
618 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
619 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
622 ## From SMESH_Gen interface
623 # @return the list of integer values
624 # @ingroup l1_auxiliary
625 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
626 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
628 ## From SMESH_Gen interface. Creates a pattern
629 # @return an instance of SMESH_Pattern
631 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
632 # @ingroup l2_modif_patterns
633 def GetPattern(self):
634 return SMESH._objref_SMESH_Gen.GetPattern(self)
636 ## Sets number of segments per diagonal of boundary box of geometry by which
637 # default segment length of appropriate 1D hypotheses is defined.
638 # Default value is 10
639 # @ingroup l1_auxiliary
640 def SetBoundaryBoxSegmentation(self, nbSegments):
641 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
643 ## Concatenate the given meshes into one mesh.
644 # @return an instance of Mesh class
645 # @param meshes the meshes to combine into one mesh
646 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
647 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
648 # @param mergeTolerance tolerance for merging nodes
649 # @param allGroups forces creation of groups of all elements
650 def Concatenate( self, meshes, uniteIdenticalGroups,
651 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
652 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
654 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
655 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
657 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
658 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
659 aSmeshMesh.SetParameters(Parameters)
660 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
663 # Filtering. Auxiliary functions:
664 # ------------------------------
666 ## Creates an empty criterion
667 # @return SMESH.Filter.Criterion
668 # @ingroup l1_controls
669 def GetEmptyCriterion(self):
670 Type = self.EnumToLong(FT_Undefined)
671 Compare = self.EnumToLong(FT_Undefined)
675 UnaryOp = self.EnumToLong(FT_Undefined)
676 BinaryOp = self.EnumToLong(FT_Undefined)
679 Precision = -1 ##@1e-07
680 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
681 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
683 ## Creates a criterion by the given parameters
684 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
685 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
686 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
687 # @param Treshold the threshold value (range of ids as string, shape, numeric)
688 # @param UnaryOp FT_LogicalNOT or FT_Undefined
689 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
690 # FT_Undefined (must be for the last criterion of all criteria)
691 # @return SMESH.Filter.Criterion
692 # @ingroup l1_controls
693 def GetCriterion(self,elementType,
695 Compare = FT_EqualTo,
697 UnaryOp=FT_Undefined,
698 BinaryOp=FT_Undefined):
699 aCriterion = self.GetEmptyCriterion()
700 aCriterion.TypeOfElement = elementType
701 aCriterion.Type = self.EnumToLong(CritType)
705 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
706 aCriterion.Compare = self.EnumToLong(Compare)
707 elif Compare == "=" or Compare == "==":
708 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
710 aCriterion.Compare = self.EnumToLong(FT_LessThan)
712 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
714 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
717 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
718 FT_BelongToCylinder, FT_LyingOnGeom]:
719 # Checks the treshold
720 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
721 aCriterion.ThresholdStr = GetName(aTreshold)
722 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
724 print "Error: The treshold should be a shape."
726 elif CritType == FT_RangeOfIds:
727 # Checks the treshold
728 if isinstance(aTreshold, str):
729 aCriterion.ThresholdStr = aTreshold
731 print "Error: The treshold should be a string."
733 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
734 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
735 # At this point the treshold is unnecessary
736 if aTreshold == FT_LogicalNOT:
737 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
738 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
739 aCriterion.BinaryOp = aTreshold
743 aTreshold = float(aTreshold)
744 aCriterion.Threshold = aTreshold
746 print "Error: The treshold should be a number."
749 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
750 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
752 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
753 aCriterion.BinaryOp = self.EnumToLong(Treshold)
755 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
756 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
758 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
759 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
763 ## Creates a filter with the given parameters
764 # @param elementType the type of elements in the group
765 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
766 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
767 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
768 # @param UnaryOp FT_LogicalNOT or FT_Undefined
769 # @return SMESH_Filter
770 # @ingroup l1_controls
771 def GetFilter(self,elementType,
772 CritType=FT_Undefined,
775 UnaryOp=FT_Undefined):
776 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
777 aFilterMgr = self.CreateFilterManager()
778 aFilter = aFilterMgr.CreateFilter()
780 aCriteria.append(aCriterion)
781 aFilter.SetCriteria(aCriteria)
784 ## Creates a numerical functor by its type
785 # @param theCriterion FT_...; functor type
786 # @return SMESH_NumericalFunctor
787 # @ingroup l1_controls
788 def GetFunctor(self,theCriterion):
789 aFilterMgr = self.CreateFilterManager()
790 if theCriterion == FT_AspectRatio:
791 return aFilterMgr.CreateAspectRatio()
792 elif theCriterion == FT_AspectRatio3D:
793 return aFilterMgr.CreateAspectRatio3D()
794 elif theCriterion == FT_Warping:
795 return aFilterMgr.CreateWarping()
796 elif theCriterion == FT_MinimumAngle:
797 return aFilterMgr.CreateMinimumAngle()
798 elif theCriterion == FT_Taper:
799 return aFilterMgr.CreateTaper()
800 elif theCriterion == FT_Skew:
801 return aFilterMgr.CreateSkew()
802 elif theCriterion == FT_Area:
803 return aFilterMgr.CreateArea()
804 elif theCriterion == FT_Volume3D:
805 return aFilterMgr.CreateVolume3D()
806 elif theCriterion == FT_MultiConnection:
807 return aFilterMgr.CreateMultiConnection()
808 elif theCriterion == FT_MultiConnection2D:
809 return aFilterMgr.CreateMultiConnection2D()
810 elif theCriterion == FT_Length:
811 return aFilterMgr.CreateLength()
812 elif theCriterion == FT_Length2D:
813 return aFilterMgr.CreateLength2D()
815 print "Error: given parameter is not numerucal functor type."
817 ## Creates hypothesis
818 # @param theHType mesh hypothesis type (string)
819 # @param theLibName mesh plug-in library name
820 # @return created hypothesis instance
821 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
822 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
824 ## Gets the mesh stattistic
825 # @return dictionary type element - count of elements
826 # @ingroup l1_meshinfo
827 def GetMeshInfo(self, obj):
828 if isinstance( obj, Mesh ):
831 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
832 values = obj.GetMeshInfo()
833 for i in range(SMESH.Entity_Last._v):
834 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
839 #Registering the new proxy for SMESH_Gen
840 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
846 ## This class allows defining and managing a mesh.
847 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
848 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
849 # new nodes and elements and by changing the existing entities), to get information
850 # about a mesh and to export a mesh into different formats.
859 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
860 # sets the GUI name of this mesh to \a name.
861 # @param smeshpyD an instance of smeshDC class
862 # @param geompyD an instance of geompyDC class
863 # @param obj Shape to be meshed or SMESH_Mesh object
864 # @param name Study name of the mesh
865 # @ingroup l2_construct
866 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
867 self.smeshpyD=smeshpyD
872 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
874 self.mesh = self.smeshpyD.CreateMesh(self.geom)
875 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
878 self.mesh = self.smeshpyD.CreateEmptyMesh()
880 self.smeshpyD.SetName(self.mesh, name)
882 self.smeshpyD.SetName(self.mesh, GetName(obj))
885 self.geom = self.mesh.GetShapeToMesh()
887 self.editor = self.mesh.GetMeshEditor()
889 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
890 # @param theMesh a SMESH_Mesh object
891 # @ingroup l2_construct
892 def SetMesh(self, theMesh):
894 self.geom = self.mesh.GetShapeToMesh()
896 ## Returns the mesh, that is an instance of SMESH_Mesh interface
897 # @return a SMESH_Mesh object
898 # @ingroup l2_construct
902 ## Gets the name of the mesh
903 # @return the name of the mesh as a string
904 # @ingroup l2_construct
906 name = GetName(self.GetMesh())
909 ## Sets a name to the mesh
910 # @param name a new name of the mesh
911 # @ingroup l2_construct
912 def SetName(self, name):
913 self.smeshpyD.SetName(self.GetMesh(), name)
915 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
916 # The subMesh object gives access to the IDs of nodes and elements.
917 # @param theSubObject a geometrical object (shape)
918 # @param theName a name for the submesh
919 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
920 # @ingroup l2_submeshes
921 def GetSubMesh(self, theSubObject, theName):
922 submesh = self.mesh.GetSubMesh(theSubObject, theName)
925 ## Returns the shape associated to the mesh
926 # @return a GEOM_Object
927 # @ingroup l2_construct
931 ## Associates the given shape to the mesh (entails the recreation of the mesh)
932 # @param geom the shape to be meshed (GEOM_Object)
933 # @ingroup l2_construct
934 def SetShape(self, geom):
935 self.mesh = self.smeshpyD.CreateMesh(geom)
937 ## Returns true if the hypotheses are defined well
938 # @param theSubObject a subshape of a mesh shape
939 # @return True or False
940 # @ingroup l2_construct
941 def IsReadyToCompute(self, theSubObject):
942 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
944 ## Returns errors of hypotheses definition.
945 # The list of errors is empty if everything is OK.
946 # @param theSubObject a subshape of a mesh shape
947 # @return a list of errors
948 # @ingroup l2_construct
949 def GetAlgoState(self, theSubObject):
950 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
952 ## Returns a geometrical object on which the given element was built.
953 # The returned geometrical object, if not nil, is either found in the
954 # study or published by this method with the given name
955 # @param theElementID the id of the mesh element
956 # @param theGeomName the user-defined name of the geometrical object
957 # @return GEOM::GEOM_Object instance
958 # @ingroup l2_construct
959 def GetGeometryByMeshElement(self, theElementID, theGeomName):
960 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
962 ## Returns the mesh dimension depending on the dimension of the underlying shape
963 # @return mesh dimension as an integer value [0,3]
964 # @ingroup l1_auxiliary
965 def MeshDimension(self):
966 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
967 if len( shells ) > 0 :
969 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
971 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
977 ## Creates a segment discretization 1D algorithm.
978 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
979 # \n If the optional \a geom parameter is not set, this algorithm is global.
980 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
981 # @param algo the type of the required algorithm. Possible values are:
983 # - smesh.PYTHON for discretization via a python function,
984 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
985 # @param geom If defined is the subshape to be meshed
986 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
987 # @ingroup l3_algos_basic
988 def Segment(self, algo=REGULAR, geom=0):
989 ## if Segment(geom) is called by mistake
990 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
991 algo, geom = geom, algo
992 if not algo: algo = REGULAR
995 return Mesh_Segment(self, geom)
997 return Mesh_Segment_Python(self, geom)
998 elif algo == COMPOSITE:
999 return Mesh_CompositeSegment(self, geom)
1001 return Mesh_Segment(self, geom)
1003 ## Enables creation of nodes and segments usable by 2D algoritms.
1004 # The added nodes and segments must be bound to edges and vertices by
1005 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
1006 # If the optional \a geom parameter is not set, this algorithm is global.
1007 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1008 # @param geom the subshape to be manually meshed
1009 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1010 # @ingroup l3_algos_basic
1011 def UseExistingSegments(self, geom=0):
1012 algo = Mesh_UseExisting(1,self,geom)
1013 return algo.GetAlgorithm()
1015 ## Enables creation of nodes and faces usable by 3D algoritms.
1016 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1017 # and SetMeshElementOnShape()
1018 # If the optional \a geom parameter is not set, this algorithm is global.
1019 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1020 # @param geom the subshape to be manually meshed
1021 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1022 # @ingroup l3_algos_basic
1023 def UseExistingFaces(self, geom=0):
1024 algo = Mesh_UseExisting(2,self,geom)
1025 return algo.GetAlgorithm()
1027 ## Creates a triangle 2D algorithm for faces.
1028 # If the optional \a geom parameter is not set, this algorithm is global.
1029 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1030 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1031 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1032 # @return an instance of Mesh_Triangle algorithm
1033 # @ingroup l3_algos_basic
1034 def Triangle(self, algo=MEFISTO, geom=0):
1035 ## if Triangle(geom) is called by mistake
1036 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1039 return Mesh_Triangle(self, algo, geom)
1041 ## Creates a quadrangle 2D algorithm for faces.
1042 # If the optional \a geom parameter is not set, this algorithm is global.
1043 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1044 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1045 # @param algo values are: smesh.QUARDANGLE || smesh.RADIAL_QUAD
1046 # @return an instance of Mesh_Quadrangle algorithm
1047 # @ingroup l3_algos_basic
1048 def Quadrangle(self, geom=0, algo=QUARDANGLE):
1049 if algo==RADIAL_QUAD:
1050 return Mesh_RadialQuadrangle1D2D(self,geom)
1052 return Mesh_Quadrangle(self, geom)
1054 ## Creates a tetrahedron 3D algorithm for solids.
1055 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1056 # If the optional \a geom parameter is not set, this algorithm is global.
1057 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1058 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1059 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1060 # @return an instance of Mesh_Tetrahedron algorithm
1061 # @ingroup l3_algos_basic
1062 def Tetrahedron(self, algo=NETGEN, geom=0):
1063 ## if Tetrahedron(geom) is called by mistake
1064 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1065 algo, geom = geom, algo
1066 if not algo: algo = NETGEN
1068 return Mesh_Tetrahedron(self, algo, geom)
1070 ## Creates a hexahedron 3D algorithm for solids.
1071 # If the optional \a geom parameter is not set, this algorithm is global.
1072 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1073 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1074 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1075 # @return an instance of Mesh_Hexahedron algorithm
1076 # @ingroup l3_algos_basic
1077 def Hexahedron(self, algo=Hexa, geom=0):
1078 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1079 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1080 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1081 elif geom == 0: algo, geom = Hexa, algo
1082 return Mesh_Hexahedron(self, algo, geom)
1084 ## Deprecated, used only for compatibility!
1085 # @return an instance of Mesh_Netgen algorithm
1086 # @ingroup l3_algos_basic
1087 def Netgen(self, is3D, geom=0):
1088 return Mesh_Netgen(self, is3D, geom)
1090 ## Creates a projection 1D algorithm for edges.
1091 # If the optional \a geom parameter is not set, this algorithm is global.
1092 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1093 # @param geom If defined, the subshape to be meshed
1094 # @return an instance of Mesh_Projection1D algorithm
1095 # @ingroup l3_algos_proj
1096 def Projection1D(self, geom=0):
1097 return Mesh_Projection1D(self, geom)
1099 ## Creates a projection 2D algorithm for faces.
1100 # If the optional \a geom parameter is not set, this algorithm is global.
1101 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1102 # @param geom If defined, the subshape to be meshed
1103 # @return an instance of Mesh_Projection2D algorithm
1104 # @ingroup l3_algos_proj
1105 def Projection2D(self, geom=0):
1106 return Mesh_Projection2D(self, geom)
1108 ## Creates a projection 3D algorithm for solids.
1109 # If the optional \a geom parameter is not set, this algorithm is global.
1110 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1111 # @param geom If defined, the subshape to be meshed
1112 # @return an instance of Mesh_Projection3D algorithm
1113 # @ingroup l3_algos_proj
1114 def Projection3D(self, geom=0):
1115 return Mesh_Projection3D(self, geom)
1117 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1118 # If the optional \a geom parameter is not set, this algorithm is global.
1119 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1120 # @param geom If defined, the subshape to be meshed
1121 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1122 # @ingroup l3_algos_radialp l3_algos_3dextr
1123 def Prism(self, geom=0):
1127 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1128 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1129 if nbSolids == 0 or nbSolids == nbShells:
1130 return Mesh_Prism3D(self, geom)
1131 return Mesh_RadialPrism3D(self, geom)
1133 ## Evaluates size of prospective mesh on a shape
1134 # @return True or False
1135 def Evaluate(self, geom=0):
1136 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1138 geom = self.mesh.GetShapeToMesh()
1141 return self.smeshpyD.Evaluate(self.mesh, geom)
1144 ## Computes the mesh and returns the status of the computation
1145 # @return True or False
1146 # @ingroup l2_construct
1147 def Compute(self, geom=0):
1148 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1150 geom = self.mesh.GetShapeToMesh()
1155 ok = self.smeshpyD.Compute(self.mesh, geom)
1156 except SALOME.SALOME_Exception, ex:
1157 print "Mesh computation failed, exception caught:"
1158 print " ", ex.details.text
1161 print "Mesh computation failed, exception caught:"
1162 traceback.print_exc()
1164 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1167 if err.isGlobalAlgo:
1175 reason = '%s %sD algorithm is missing' % (glob, dim)
1176 elif err.state == HYP_MISSING:
1177 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1178 % (glob, dim, name, dim))
1179 elif err.state == HYP_NOTCONFORM:
1180 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1181 elif err.state == HYP_BAD_PARAMETER:
1182 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1183 % ( glob, dim, name ))
1184 elif err.state == HYP_BAD_GEOMETRY:
1185 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1186 'geometry' % ( glob, dim, name ))
1188 reason = "For unknown reason."+\
1189 " Revise Mesh.Compute() implementation in smeshDC.py!"
1191 if allReasons != "":
1194 allReasons += reason
1196 if allReasons != "":
1197 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1201 print '"' + GetName(self.mesh) + '"',"has not been computed."
1204 if salome.sg.hasDesktop():
1205 smeshgui = salome.ImportComponentGUI("SMESH")
1206 smeshgui.Init(self.mesh.GetStudyId())
1207 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1208 salome.sg.updateObjBrowser(1)
1212 ## Return submesh objects list in meshing order
1213 # @return list of list of submesh objects
1214 # @ingroup l2_construct
1215 def GetMeshOrder(self):
1216 return self.mesh.GetMeshOrder()
1218 ## Return submesh objects list in meshing order
1219 # @return list of list of submesh objects
1220 # @ingroup l2_construct
1221 def SetMeshOrder(self, submeshes):
1222 return self.mesh.SetMeshOrder(submeshes)
1224 ## Removes all nodes and elements
1225 # @ingroup l2_construct
1228 if salome.sg.hasDesktop():
1229 smeshgui = salome.ImportComponentGUI("SMESH")
1230 smeshgui.Init(self.mesh.GetStudyId())
1231 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1232 salome.sg.updateObjBrowser(1)
1234 ## Removes all nodes and elements of indicated shape
1235 # @ingroup l2_construct
1236 def ClearSubMesh(self, geomId):
1237 self.mesh.ClearSubMesh(geomId)
1238 if salome.sg.hasDesktop():
1239 smeshgui = salome.ImportComponentGUI("SMESH")
1240 smeshgui.Init(self.mesh.GetStudyId())
1241 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1242 salome.sg.updateObjBrowser(1)
1244 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1245 # @param fineness [0,-1] defines mesh fineness
1246 # @return True or False
1247 # @ingroup l3_algos_basic
1248 def AutomaticTetrahedralization(self, fineness=0):
1249 dim = self.MeshDimension()
1251 self.RemoveGlobalHypotheses()
1252 self.Segment().AutomaticLength(fineness)
1254 self.Triangle().LengthFromEdges()
1257 self.Tetrahedron(NETGEN)
1259 return self.Compute()
1261 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1262 # @param fineness [0,-1] defines mesh fineness
1263 # @return True or False
1264 # @ingroup l3_algos_basic
1265 def AutomaticHexahedralization(self, fineness=0):
1266 dim = self.MeshDimension()
1267 # assign the hypotheses
1268 self.RemoveGlobalHypotheses()
1269 self.Segment().AutomaticLength(fineness)
1276 return self.Compute()
1278 ## Assigns a hypothesis
1279 # @param hyp a hypothesis to assign
1280 # @param geom a subhape of mesh geometry
1281 # @return SMESH.Hypothesis_Status
1282 # @ingroup l2_hypotheses
1283 def AddHypothesis(self, hyp, geom=0):
1284 if isinstance( hyp, Mesh_Algorithm ):
1285 hyp = hyp.GetAlgorithm()
1290 geom = self.mesh.GetShapeToMesh()
1292 status = self.mesh.AddHypothesis(geom, hyp)
1293 isAlgo = hyp._narrow( SMESH_Algo )
1294 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1297 ## Unassigns a hypothesis
1298 # @param hyp a hypothesis to unassign
1299 # @param geom a subshape of mesh geometry
1300 # @return SMESH.Hypothesis_Status
1301 # @ingroup l2_hypotheses
1302 def RemoveHypothesis(self, hyp, geom=0):
1303 if isinstance( hyp, Mesh_Algorithm ):
1304 hyp = hyp.GetAlgorithm()
1309 status = self.mesh.RemoveHypothesis(geom, hyp)
1312 ## Gets the list of hypotheses added on a geometry
1313 # @param geom a subshape of mesh geometry
1314 # @return the sequence of SMESH_Hypothesis
1315 # @ingroup l2_hypotheses
1316 def GetHypothesisList(self, geom):
1317 return self.mesh.GetHypothesisList( geom )
1319 ## Removes all global hypotheses
1320 # @ingroup l2_hypotheses
1321 def RemoveGlobalHypotheses(self):
1322 current_hyps = self.mesh.GetHypothesisList( self.geom )
1323 for hyp in current_hyps:
1324 self.mesh.RemoveHypothesis( self.geom, hyp )
1328 ## Creates a mesh group based on the geometric object \a grp
1329 # and gives a \a name, \n if this parameter is not defined
1330 # the name is the same as the geometric group name \n
1331 # Note: Works like GroupOnGeom().
1332 # @param grp a geometric group, a vertex, an edge, a face or a solid
1333 # @param name the name of the mesh group
1334 # @return SMESH_GroupOnGeom
1335 # @ingroup l2_grps_create
1336 def Group(self, grp, name=""):
1337 return self.GroupOnGeom(grp, name)
1339 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1340 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1341 # @param f the file name
1342 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1343 # @param opt boolean parameter for creating/not creating
1344 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1345 # @ingroup l2_impexp
1346 def ExportToMED(self, f, version, opt=0):
1347 self.mesh.ExportToMED(f, opt, version)
1349 ## Exports the mesh in a file in MED format
1350 # @param f is the file name
1351 # @param auto_groups boolean parameter for creating/not creating
1352 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1353 # the typical use is auto_groups=false.
1354 # @param version MED format version(MED_V2_1 or MED_V2_2)
1355 # @ingroup l2_impexp
1356 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1357 self.mesh.ExportToMED(f, auto_groups, version)
1359 ## Exports the mesh in a file in DAT format
1360 # @param f the file name
1361 # @ingroup l2_impexp
1362 def ExportDAT(self, f):
1363 self.mesh.ExportDAT(f)
1365 ## Exports the mesh in a file in UNV format
1366 # @param f the file name
1367 # @ingroup l2_impexp
1368 def ExportUNV(self, f):
1369 self.mesh.ExportUNV(f)
1371 ## Export the mesh in a file in STL format
1372 # @param f the file name
1373 # @param ascii defines the file encoding
1374 # @ingroup l2_impexp
1375 def ExportSTL(self, f, ascii=1):
1376 self.mesh.ExportSTL(f, ascii)
1379 # Operations with groups:
1380 # ----------------------
1382 ## Creates an empty mesh group
1383 # @param elementType the type of elements in the group
1384 # @param name the name of the mesh group
1385 # @return SMESH_Group
1386 # @ingroup l2_grps_create
1387 def CreateEmptyGroup(self, elementType, name):
1388 return self.mesh.CreateGroup(elementType, name)
1390 ## Creates a mesh group based on the geometrical object \a grp
1391 # and gives a \a name, \n if this parameter is not defined
1392 # the name is the same as the geometrical group name
1393 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1394 # @param name the name of the mesh group
1395 # @param typ the type of elements in the group. If not set, it is
1396 # automatically detected by the type of the geometry
1397 # @return SMESH_GroupOnGeom
1398 # @ingroup l2_grps_create
1399 def GroupOnGeom(self, grp, name="", typ=None):
1401 name = grp.GetName()
1404 tgeo = str(grp.GetShapeType())
1405 if tgeo == "VERTEX":
1407 elif tgeo == "EDGE":
1409 elif tgeo == "FACE":
1411 elif tgeo == "SOLID":
1413 elif tgeo == "SHELL":
1415 elif tgeo == "COMPOUND":
1416 try: # it raises on a compound of compounds
1417 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1418 print "Mesh.Group: empty geometric group", GetName( grp )
1423 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1425 tgeo = self.geompyD.GetType(grp)
1426 if tgeo == geompyDC.ShapeType["VERTEX"]:
1428 elif tgeo == geompyDC.ShapeType["EDGE"]:
1430 elif tgeo == geompyDC.ShapeType["FACE"]:
1432 elif tgeo == geompyDC.ShapeType["SOLID"]:
1438 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1439 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1440 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1448 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1451 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1453 ## Creates a mesh group by the given ids of elements
1454 # @param groupName the name of the mesh group
1455 # @param elementType the type of elements in the group
1456 # @param elemIDs the list of ids
1457 # @return SMESH_Group
1458 # @ingroup l2_grps_create
1459 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1460 group = self.mesh.CreateGroup(elementType, groupName)
1464 ## Creates a mesh group by the given conditions
1465 # @param groupName the name of the mesh group
1466 # @param elementType the type of elements in the group
1467 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1468 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1469 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1470 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1471 # @return SMESH_Group
1472 # @ingroup l2_grps_create
1476 CritType=FT_Undefined,
1479 UnaryOp=FT_Undefined):
1480 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1481 group = self.MakeGroupByCriterion(groupName, aCriterion)
1484 ## Creates a mesh group by the given criterion
1485 # @param groupName the name of the mesh group
1486 # @param Criterion the instance of Criterion class
1487 # @return SMESH_Group
1488 # @ingroup l2_grps_create
1489 def MakeGroupByCriterion(self, groupName, Criterion):
1490 aFilterMgr = self.smeshpyD.CreateFilterManager()
1491 aFilter = aFilterMgr.CreateFilter()
1493 aCriteria.append(Criterion)
1494 aFilter.SetCriteria(aCriteria)
1495 group = self.MakeGroupByFilter(groupName, aFilter)
1498 ## Creates a mesh group by the given criteria (list of criteria)
1499 # @param groupName the name of the mesh group
1500 # @param theCriteria the list of criteria
1501 # @return SMESH_Group
1502 # @ingroup l2_grps_create
1503 def MakeGroupByCriteria(self, groupName, theCriteria):
1504 aFilterMgr = self.smeshpyD.CreateFilterManager()
1505 aFilter = aFilterMgr.CreateFilter()
1506 aFilter.SetCriteria(theCriteria)
1507 group = self.MakeGroupByFilter(groupName, aFilter)
1510 ## Creates a mesh group by the given filter
1511 # @param groupName the name of the mesh group
1512 # @param theFilter the instance of Filter class
1513 # @return SMESH_Group
1514 # @ingroup l2_grps_create
1515 def MakeGroupByFilter(self, groupName, theFilter):
1516 anIds = theFilter.GetElementsId(self.mesh)
1517 anElemType = theFilter.GetElementType()
1518 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1521 ## Passes mesh elements through the given filter and return IDs of fitting elements
1522 # @param theFilter SMESH_Filter
1523 # @return a list of ids
1524 # @ingroup l1_controls
1525 def GetIdsFromFilter(self, theFilter):
1526 return theFilter.GetElementsId(self.mesh)
1528 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1529 # Returns a list of special structures (borders).
1530 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1531 # @ingroup l1_controls
1532 def GetFreeBorders(self):
1533 aFilterMgr = self.smeshpyD.CreateFilterManager()
1534 aPredicate = aFilterMgr.CreateFreeEdges()
1535 aPredicate.SetMesh(self.mesh)
1536 aBorders = aPredicate.GetBorders()
1540 # @ingroup l2_grps_delete
1541 def RemoveGroup(self, group):
1542 self.mesh.RemoveGroup(group)
1544 ## Removes a group with its contents
1545 # @ingroup l2_grps_delete
1546 def RemoveGroupWithContents(self, group):
1547 self.mesh.RemoveGroupWithContents(group)
1549 ## Gets the list of groups existing in the mesh
1550 # @return a sequence of SMESH_GroupBase
1551 # @ingroup l2_grps_create
1552 def GetGroups(self):
1553 return self.mesh.GetGroups()
1555 ## Gets the number of groups existing in the mesh
1556 # @return the quantity of groups as an integer value
1557 # @ingroup l2_grps_create
1559 return self.mesh.NbGroups()
1561 ## Gets the list of names of groups existing in the mesh
1562 # @return list of strings
1563 # @ingroup l2_grps_create
1564 def GetGroupNames(self):
1565 groups = self.GetGroups()
1567 for group in groups:
1568 names.append(group.GetName())
1571 ## Produces a union of two groups
1572 # A new group is created. All mesh elements that are
1573 # present in the initial groups are added to the new one
1574 # @return an instance of SMESH_Group
1575 # @ingroup l2_grps_operon
1576 def UnionGroups(self, group1, group2, name):
1577 return self.mesh.UnionGroups(group1, group2, name)
1579 ## Produces a union list of groups
1580 # New group is created. All mesh elements that are present in
1581 # initial groups are added to the new one
1582 # @return an instance of SMESH_Group
1583 # @ingroup l2_grps_operon
1584 def UnionListOfGroups(self, groups, name):
1585 return self.mesh.UnionListOfGroups(groups, name)
1587 ## Prodices an intersection of two groups
1588 # A new group is created. All mesh elements that are common
1589 # for the two initial groups are added to the new one.
1590 # @return an instance of SMESH_Group
1591 # @ingroup l2_grps_operon
1592 def IntersectGroups(self, group1, group2, name):
1593 return self.mesh.IntersectGroups(group1, group2, name)
1595 ## Produces an intersection of groups
1596 # New group is created. All mesh elements that are present in all
1597 # initial groups simultaneously are added to the new one
1598 # @return an instance of SMESH_Group
1599 # @ingroup l2_grps_operon
1600 def IntersectListOfGroups(self, groups, name):
1601 return self.mesh.IntersectListOfGroups(groups, name)
1603 ## Produces a cut of two groups
1604 # A new group is created. All mesh elements that are present in
1605 # the main group but are not present in the tool group are added to the new one
1606 # @return an instance of SMESH_Group
1607 # @ingroup l2_grps_operon
1608 def CutGroups(self, main_group, tool_group, name):
1609 return self.mesh.CutGroups(main_group, tool_group, name)
1611 ## Produces a cut of groups
1612 # A new group is created. All mesh elements that are present in main groups
1613 # but do not present in tool groups are added to the new one
1614 # @return an instance of SMESH_Group
1615 # @ingroup l2_grps_operon
1616 def CutListOfGroups(self, main_groups, tool_groups, name):
1617 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1619 ## Produces a group of elements with specified element type using list of existing groups
1620 # A new group is created. System
1621 # 1) extract all nodes on which groups elements are built
1622 # 2) combine all elements of specified dimension laying on these nodes
1623 # @return an instance of SMESH_Group
1624 # @ingroup l2_grps_operon
1625 def CreateDimGroup(self, groups, elem_type, name):
1626 return self.mesh.CreateDimGroup(groups, elem_type, name)
1629 ## Convert group on geom into standalone group
1630 # @ingroup l2_grps_delete
1631 def ConvertToStandalone(self, group):
1632 return self.mesh.ConvertToStandalone(group)
1634 # Get some info about mesh:
1635 # ------------------------
1637 ## Returns the log of nodes and elements added or removed
1638 # since the previous clear of the log.
1639 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1640 # @return list of log_block structures:
1645 # @ingroup l1_auxiliary
1646 def GetLog(self, clearAfterGet):
1647 return self.mesh.GetLog(clearAfterGet)
1649 ## Clears the log of nodes and elements added or removed since the previous
1650 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1651 # @ingroup l1_auxiliary
1653 self.mesh.ClearLog()
1655 ## Toggles auto color mode on the object.
1656 # @param theAutoColor the flag which toggles auto color mode.
1657 # @ingroup l1_auxiliary
1658 def SetAutoColor(self, theAutoColor):
1659 self.mesh.SetAutoColor(theAutoColor)
1661 ## Gets flag of object auto color mode.
1662 # @return True or False
1663 # @ingroup l1_auxiliary
1664 def GetAutoColor(self):
1665 return self.mesh.GetAutoColor()
1667 ## Gets the internal ID
1668 # @return integer value, which is the internal Id of the mesh
1669 # @ingroup l1_auxiliary
1671 return self.mesh.GetId()
1674 # @return integer value, which is the study Id of the mesh
1675 # @ingroup l1_auxiliary
1676 def GetStudyId(self):
1677 return self.mesh.GetStudyId()
1679 ## Checks the group names for duplications.
1680 # Consider the maximum group name length stored in MED file.
1681 # @return True or False
1682 # @ingroup l1_auxiliary
1683 def HasDuplicatedGroupNamesMED(self):
1684 return self.mesh.HasDuplicatedGroupNamesMED()
1686 ## Obtains the mesh editor tool
1687 # @return an instance of SMESH_MeshEditor
1688 # @ingroup l1_modifying
1689 def GetMeshEditor(self):
1690 return self.mesh.GetMeshEditor()
1693 # @return an instance of SALOME_MED::MESH
1694 # @ingroup l1_auxiliary
1695 def GetMEDMesh(self):
1696 return self.mesh.GetMEDMesh()
1699 # Get informations about mesh contents:
1700 # ------------------------------------
1702 ## Gets the mesh stattistic
1703 # @return dictionary type element - count of elements
1704 # @ingroup l1_meshinfo
1705 def GetMeshInfo(self, obj = None):
1706 if not obj: obj = self.mesh
1707 return self.smeshpyD.GetMeshInfo(obj)
1709 ## Returns the number of nodes in the mesh
1710 # @return an integer value
1711 # @ingroup l1_meshinfo
1713 return self.mesh.NbNodes()
1715 ## Returns the number of elements in the mesh
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1718 def NbElements(self):
1719 return self.mesh.NbElements()
1721 ## Returns the number of 0d elements in the mesh
1722 # @return an integer value
1723 # @ingroup l1_meshinfo
1724 def Nb0DElements(self):
1725 return self.mesh.Nb0DElements()
1727 ## Returns the number of edges in the mesh
1728 # @return an integer value
1729 # @ingroup l1_meshinfo
1731 return self.mesh.NbEdges()
1733 ## Returns the number of edges with the given order in the mesh
1734 # @param elementOrder the order of elements:
1735 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1736 # @return an integer value
1737 # @ingroup l1_meshinfo
1738 def NbEdgesOfOrder(self, elementOrder):
1739 return self.mesh.NbEdgesOfOrder(elementOrder)
1741 ## Returns the number of faces in the mesh
1742 # @return an integer value
1743 # @ingroup l1_meshinfo
1745 return self.mesh.NbFaces()
1747 ## Returns the number of faces with the given order in the mesh
1748 # @param elementOrder the order of elements:
1749 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1750 # @return an integer value
1751 # @ingroup l1_meshinfo
1752 def NbFacesOfOrder(self, elementOrder):
1753 return self.mesh.NbFacesOfOrder(elementOrder)
1755 ## Returns the number of triangles in the mesh
1756 # @return an integer value
1757 # @ingroup l1_meshinfo
1758 def NbTriangles(self):
1759 return self.mesh.NbTriangles()
1761 ## Returns the number of triangles with the given order in the mesh
1762 # @param elementOrder is the order of elements:
1763 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1764 # @return an integer value
1765 # @ingroup l1_meshinfo
1766 def NbTrianglesOfOrder(self, elementOrder):
1767 return self.mesh.NbTrianglesOfOrder(elementOrder)
1769 ## Returns the number of quadrangles in the mesh
1770 # @return an integer value
1771 # @ingroup l1_meshinfo
1772 def NbQuadrangles(self):
1773 return self.mesh.NbQuadrangles()
1775 ## Returns the number of quadrangles with the given order in the mesh
1776 # @param elementOrder the order of elements:
1777 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1778 # @return an integer value
1779 # @ingroup l1_meshinfo
1780 def NbQuadranglesOfOrder(self, elementOrder):
1781 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1783 ## Returns the number of polygons in the mesh
1784 # @return an integer value
1785 # @ingroup l1_meshinfo
1786 def NbPolygons(self):
1787 return self.mesh.NbPolygons()
1789 ## Returns the number of volumes in the mesh
1790 # @return an integer value
1791 # @ingroup l1_meshinfo
1792 def NbVolumes(self):
1793 return self.mesh.NbVolumes()
1795 ## Returns the number of volumes with the given order in the mesh
1796 # @param elementOrder the order of elements:
1797 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1798 # @return an integer value
1799 # @ingroup l1_meshinfo
1800 def NbVolumesOfOrder(self, elementOrder):
1801 return self.mesh.NbVolumesOfOrder(elementOrder)
1803 ## Returns the number of tetrahedrons in the mesh
1804 # @return an integer value
1805 # @ingroup l1_meshinfo
1807 return self.mesh.NbTetras()
1809 ## Returns the number of tetrahedrons with the given order in the mesh
1810 # @param elementOrder the order of elements:
1811 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1812 # @return an integer value
1813 # @ingroup l1_meshinfo
1814 def NbTetrasOfOrder(self, elementOrder):
1815 return self.mesh.NbTetrasOfOrder(elementOrder)
1817 ## Returns the number of hexahedrons in the mesh
1818 # @return an integer value
1819 # @ingroup l1_meshinfo
1821 return self.mesh.NbHexas()
1823 ## Returns the number of hexahedrons with the given order in the mesh
1824 # @param elementOrder the order of elements:
1825 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1826 # @return an integer value
1827 # @ingroup l1_meshinfo
1828 def NbHexasOfOrder(self, elementOrder):
1829 return self.mesh.NbHexasOfOrder(elementOrder)
1831 ## Returns the number of pyramids in the mesh
1832 # @return an integer value
1833 # @ingroup l1_meshinfo
1834 def NbPyramids(self):
1835 return self.mesh.NbPyramids()
1837 ## Returns the number of pyramids with the given order in the mesh
1838 # @param elementOrder the order of elements:
1839 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1840 # @return an integer value
1841 # @ingroup l1_meshinfo
1842 def NbPyramidsOfOrder(self, elementOrder):
1843 return self.mesh.NbPyramidsOfOrder(elementOrder)
1845 ## Returns the number of prisms in the mesh
1846 # @return an integer value
1847 # @ingroup l1_meshinfo
1849 return self.mesh.NbPrisms()
1851 ## Returns the number of prisms with the given order in the mesh
1852 # @param elementOrder the order of elements:
1853 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1854 # @return an integer value
1855 # @ingroup l1_meshinfo
1856 def NbPrismsOfOrder(self, elementOrder):
1857 return self.mesh.NbPrismsOfOrder(elementOrder)
1859 ## Returns the number of polyhedrons in the mesh
1860 # @return an integer value
1861 # @ingroup l1_meshinfo
1862 def NbPolyhedrons(self):
1863 return self.mesh.NbPolyhedrons()
1865 ## Returns the number of submeshes in the mesh
1866 # @return an integer value
1867 # @ingroup l1_meshinfo
1868 def NbSubMesh(self):
1869 return self.mesh.NbSubMesh()
1871 ## Returns the list of mesh elements IDs
1872 # @return the list of integer values
1873 # @ingroup l1_meshinfo
1874 def GetElementsId(self):
1875 return self.mesh.GetElementsId()
1877 ## Returns the list of IDs of mesh elements with the given type
1878 # @param elementType the required type of elements
1879 # @return list of integer values
1880 # @ingroup l1_meshinfo
1881 def GetElementsByType(self, elementType):
1882 return self.mesh.GetElementsByType(elementType)
1884 ## Returns the list of mesh nodes IDs
1885 # @return the list of integer values
1886 # @ingroup l1_meshinfo
1887 def GetNodesId(self):
1888 return self.mesh.GetNodesId()
1890 # Get the information about mesh elements:
1891 # ------------------------------------
1893 ## Returns the type of mesh element
1894 # @return the value from SMESH::ElementType enumeration
1895 # @ingroup l1_meshinfo
1896 def GetElementType(self, id, iselem):
1897 return self.mesh.GetElementType(id, iselem)
1899 ## Returns the list of submesh elements IDs
1900 # @param Shape a geom object(subshape) IOR
1901 # Shape must be the subshape of a ShapeToMesh()
1902 # @return the list of integer values
1903 # @ingroup l1_meshinfo
1904 def GetSubMeshElementsId(self, Shape):
1905 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1906 ShapeID = Shape.GetSubShapeIndices()[0]
1909 return self.mesh.GetSubMeshElementsId(ShapeID)
1911 ## Returns the list of submesh nodes IDs
1912 # @param Shape a geom object(subshape) IOR
1913 # Shape must be the subshape of a ShapeToMesh()
1914 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1915 # @return the list of integer values
1916 # @ingroup l1_meshinfo
1917 def GetSubMeshNodesId(self, Shape, all):
1918 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1919 ShapeID = Shape.GetSubShapeIndices()[0]
1922 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1924 ## Returns type of elements on given shape
1925 # @param Shape a geom object(subshape) IOR
1926 # Shape must be a subshape of a ShapeToMesh()
1927 # @return element type
1928 # @ingroup l1_meshinfo
1929 def GetSubMeshElementType(self, Shape):
1930 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1931 ShapeID = Shape.GetSubShapeIndices()[0]
1934 return self.mesh.GetSubMeshElementType(ShapeID)
1936 ## Gets the mesh description
1937 # @return string value
1938 # @ingroup l1_meshinfo
1940 return self.mesh.Dump()
1943 # Get the information about nodes and elements of a mesh by its IDs:
1944 # -----------------------------------------------------------
1946 ## Gets XYZ coordinates of a node
1947 # \n If there is no nodes for the given ID - returns an empty list
1948 # @return a list of double precision values
1949 # @ingroup l1_meshinfo
1950 def GetNodeXYZ(self, id):
1951 return self.mesh.GetNodeXYZ(id)
1953 ## Returns list of IDs of inverse elements for the given node
1954 # \n If there is no node for the given ID - returns an empty list
1955 # @return a list of integer values
1956 # @ingroup l1_meshinfo
1957 def GetNodeInverseElements(self, id):
1958 return self.mesh.GetNodeInverseElements(id)
1960 ## @brief Returns the position of a node on the shape
1961 # @return SMESH::NodePosition
1962 # @ingroup l1_meshinfo
1963 def GetNodePosition(self,NodeID):
1964 return self.mesh.GetNodePosition(NodeID)
1966 ## If the given element is a node, returns the ID of shape
1967 # \n If there is no node for the given ID - returns -1
1968 # @return an integer value
1969 # @ingroup l1_meshinfo
1970 def GetShapeID(self, id):
1971 return self.mesh.GetShapeID(id)
1973 ## Returns the ID of the result shape after
1974 # FindShape() from SMESH_MeshEditor for the given element
1975 # \n If there is no element for the given ID - returns -1
1976 # @return an integer value
1977 # @ingroup l1_meshinfo
1978 def GetShapeIDForElem(self,id):
1979 return self.mesh.GetShapeIDForElem(id)
1981 ## Returns the number of nodes for the given element
1982 # \n If there is no element for the given ID - returns -1
1983 # @return an integer value
1984 # @ingroup l1_meshinfo
1985 def GetElemNbNodes(self, id):
1986 return self.mesh.GetElemNbNodes(id)
1988 ## Returns the node ID the given index for the given element
1989 # \n If there is no element for the given ID - returns -1
1990 # \n If there is no node for the given index - returns -2
1991 # @return an integer value
1992 # @ingroup l1_meshinfo
1993 def GetElemNode(self, id, index):
1994 return self.mesh.GetElemNode(id, index)
1996 ## Returns the IDs of nodes of the given element
1997 # @return a list of integer values
1998 # @ingroup l1_meshinfo
1999 def GetElemNodes(self, id):
2000 return self.mesh.GetElemNodes(id)
2002 ## Returns true if the given node is the medium node in the given quadratic element
2003 # @ingroup l1_meshinfo
2004 def IsMediumNode(self, elementID, nodeID):
2005 return self.mesh.IsMediumNode(elementID, nodeID)
2007 ## Returns true if the given node is the medium node in one of quadratic elements
2008 # @ingroup l1_meshinfo
2009 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2010 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2012 ## Returns the number of edges for the given element
2013 # @ingroup l1_meshinfo
2014 def ElemNbEdges(self, id):
2015 return self.mesh.ElemNbEdges(id)
2017 ## Returns the number of faces for the given element
2018 # @ingroup l1_meshinfo
2019 def ElemNbFaces(self, id):
2020 return self.mesh.ElemNbFaces(id)
2022 ## Returns true if the given element is a polygon
2023 # @ingroup l1_meshinfo
2024 def IsPoly(self, id):
2025 return self.mesh.IsPoly(id)
2027 ## Returns true if the given element is quadratic
2028 # @ingroup l1_meshinfo
2029 def IsQuadratic(self, id):
2030 return self.mesh.IsQuadratic(id)
2032 ## Returns XYZ coordinates of the barycenter of the given element
2033 # \n If there is no element for the given ID - returns an empty list
2034 # @return a list of three double values
2035 # @ingroup l1_meshinfo
2036 def BaryCenter(self, id):
2037 return self.mesh.BaryCenter(id)
2040 # Mesh edition (SMESH_MeshEditor functionality):
2041 # ---------------------------------------------
2043 ## Removes the elements from the mesh by ids
2044 # @param IDsOfElements is a list of ids of elements to remove
2045 # @return True or False
2046 # @ingroup l2_modif_del
2047 def RemoveElements(self, IDsOfElements):
2048 return self.editor.RemoveElements(IDsOfElements)
2050 ## Removes nodes from mesh by ids
2051 # @param IDsOfNodes is a list of ids of nodes to remove
2052 # @return True or False
2053 # @ingroup l2_modif_del
2054 def RemoveNodes(self, IDsOfNodes):
2055 return self.editor.RemoveNodes(IDsOfNodes)
2057 ## Add a node to the mesh by coordinates
2058 # @return Id of the new node
2059 # @ingroup l2_modif_add
2060 def AddNode(self, x, y, z):
2061 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2062 self.mesh.SetParameters(Parameters)
2063 return self.editor.AddNode( x, y, z)
2065 ## Creates a 0D element on a node with given number.
2066 # @param IDOfNode the ID of node for creation of the element.
2067 # @return the Id of the new 0D element
2068 # @ingroup l2_modif_add
2069 def Add0DElement(self, IDOfNode):
2070 return self.editor.Add0DElement(IDOfNode)
2072 ## Creates a linear or quadratic edge (this is determined
2073 # by the number of given nodes).
2074 # @param IDsOfNodes the list of node IDs for creation of the element.
2075 # The order of nodes in this list should correspond to the description
2076 # of MED. \n This description is located by the following link:
2077 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2078 # @return the Id of the new edge
2079 # @ingroup l2_modif_add
2080 def AddEdge(self, IDsOfNodes):
2081 return self.editor.AddEdge(IDsOfNodes)
2083 ## Creates a linear or quadratic face (this is determined
2084 # by the number of given nodes).
2085 # @param IDsOfNodes the list of node IDs for creation of the element.
2086 # The order of nodes in this list should correspond to the description
2087 # of MED. \n This description is located by the following link:
2088 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2089 # @return the Id of the new face
2090 # @ingroup l2_modif_add
2091 def AddFace(self, IDsOfNodes):
2092 return self.editor.AddFace(IDsOfNodes)
2094 ## Adds a polygonal face to the mesh by the list of node IDs
2095 # @param IdsOfNodes the list of node IDs for creation of the element.
2096 # @return the Id of the new face
2097 # @ingroup l2_modif_add
2098 def AddPolygonalFace(self, IdsOfNodes):
2099 return self.editor.AddPolygonalFace(IdsOfNodes)
2101 ## Creates both simple and quadratic volume (this is determined
2102 # by the number of given nodes).
2103 # @param IDsOfNodes the list of node IDs for creation of the element.
2104 # The order of nodes in this list should correspond to the description
2105 # of MED. \n This description is located by the following link:
2106 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2107 # @return the Id of the new volumic element
2108 # @ingroup l2_modif_add
2109 def AddVolume(self, IDsOfNodes):
2110 return self.editor.AddVolume(IDsOfNodes)
2112 ## Creates a volume of many faces, giving nodes for each face.
2113 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2114 # @param Quantities the list of integer values, Quantities[i]
2115 # gives the quantity of nodes in face number i.
2116 # @return the Id of the new volumic element
2117 # @ingroup l2_modif_add
2118 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2119 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2121 ## Creates a volume of many faces, giving the IDs of the existing faces.
2122 # @param IdsOfFaces the list of face IDs for volume creation.
2124 # Note: The created volume will refer only to the nodes
2125 # of the given faces, not to the faces themselves.
2126 # @return the Id of the new volumic element
2127 # @ingroup l2_modif_add
2128 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2129 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2132 ## @brief Binds a node to a vertex
2133 # @param NodeID a node ID
2134 # @param Vertex a vertex or vertex ID
2135 # @return True if succeed else raises an exception
2136 # @ingroup l2_modif_add
2137 def SetNodeOnVertex(self, NodeID, Vertex):
2138 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2139 VertexID = Vertex.GetSubShapeIndices()[0]
2143 self.editor.SetNodeOnVertex(NodeID, VertexID)
2144 except SALOME.SALOME_Exception, inst:
2145 raise ValueError, inst.details.text
2149 ## @brief Stores the node position on an edge
2150 # @param NodeID a node ID
2151 # @param Edge an edge or edge ID
2152 # @param paramOnEdge a parameter on the edge where the node is located
2153 # @return True if succeed else raises an exception
2154 # @ingroup l2_modif_add
2155 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2156 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2157 EdgeID = Edge.GetSubShapeIndices()[0]
2161 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2162 except SALOME.SALOME_Exception, inst:
2163 raise ValueError, inst.details.text
2166 ## @brief Stores node position on a face
2167 # @param NodeID a node ID
2168 # @param Face a face or face ID
2169 # @param u U parameter on the face where the node is located
2170 # @param v V parameter on the face where the node is located
2171 # @return True if succeed else raises an exception
2172 # @ingroup l2_modif_add
2173 def SetNodeOnFace(self, NodeID, Face, u, v):
2174 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2175 FaceID = Face.GetSubShapeIndices()[0]
2179 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2180 except SALOME.SALOME_Exception, inst:
2181 raise ValueError, inst.details.text
2184 ## @brief Binds a node to a solid
2185 # @param NodeID a node ID
2186 # @param Solid a solid or solid ID
2187 # @return True if succeed else raises an exception
2188 # @ingroup l2_modif_add
2189 def SetNodeInVolume(self, NodeID, Solid):
2190 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2191 SolidID = Solid.GetSubShapeIndices()[0]
2195 self.editor.SetNodeInVolume(NodeID, SolidID)
2196 except SALOME.SALOME_Exception, inst:
2197 raise ValueError, inst.details.text
2200 ## @brief Bind an element to a shape
2201 # @param ElementID an element ID
2202 # @param Shape a shape or shape ID
2203 # @return True if succeed else raises an exception
2204 # @ingroup l2_modif_add
2205 def SetMeshElementOnShape(self, ElementID, Shape):
2206 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2207 ShapeID = Shape.GetSubShapeIndices()[0]
2211 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2212 except SALOME.SALOME_Exception, inst:
2213 raise ValueError, inst.details.text
2217 ## Moves the node with the given id
2218 # @param NodeID the id of the node
2219 # @param x a new X coordinate
2220 # @param y a new Y coordinate
2221 # @param z a new Z coordinate
2222 # @return True if succeed else False
2223 # @ingroup l2_modif_movenode
2224 def MoveNode(self, NodeID, x, y, z):
2225 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2226 self.mesh.SetParameters(Parameters)
2227 return self.editor.MoveNode(NodeID, x, y, z)
2229 ## Finds the node closest to a point and moves it to a point location
2230 # @param x the X coordinate of a point
2231 # @param y the Y coordinate of a point
2232 # @param z the Z coordinate of a point
2233 # @param NodeID if specified (>0), the node with this ID is moved,
2234 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2235 # @return the ID of a node
2236 # @ingroup l2_modif_throughp
2237 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2238 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2239 self.mesh.SetParameters(Parameters)
2240 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2242 ## Finds the node closest to a point
2243 # @param x the X coordinate of a point
2244 # @param y the Y coordinate of a point
2245 # @param z the Z coordinate of a point
2246 # @return the ID of a node
2247 # @ingroup l2_modif_throughp
2248 def FindNodeClosestTo(self, x, y, z):
2249 #preview = self.mesh.GetMeshEditPreviewer()
2250 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2251 return self.editor.FindNodeClosestTo(x, y, z)
2253 ## Finds the elements where a point lays IN or ON
2254 # @param x the X coordinate of a point
2255 # @param y the Y coordinate of a point
2256 # @param z the Z coordinate of a point
2257 # @param elementType type of elements to find (SMESH.ALL type
2258 # means elements of any type excluding nodes and 0D elements)
2259 # @return list of IDs of found elements
2260 # @ingroup l2_modif_throughp
2261 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2262 return self.editor.FindElementsByPoint(x, y, z, elementType)
2265 ## Finds the node closest to a point and moves it to a point location
2266 # @param x the X coordinate of a point
2267 # @param y the Y coordinate of a point
2268 # @param z the Z coordinate of a point
2269 # @return the ID of a moved node
2270 # @ingroup l2_modif_throughp
2271 def MeshToPassThroughAPoint(self, x, y, z):
2272 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2274 ## Replaces two neighbour triangles sharing Node1-Node2 link
2275 # with the triangles built on the same 4 nodes but having other common link.
2276 # @param NodeID1 the ID of the first node
2277 # @param NodeID2 the ID of the second node
2278 # @return false if proper faces were not found
2279 # @ingroup l2_modif_invdiag
2280 def InverseDiag(self, NodeID1, NodeID2):
2281 return self.editor.InverseDiag(NodeID1, NodeID2)
2283 ## Replaces two neighbour triangles sharing Node1-Node2 link
2284 # with a quadrangle built on the same 4 nodes.
2285 # @param NodeID1 the ID of the first node
2286 # @param NodeID2 the ID of the second node
2287 # @return false if proper faces were not found
2288 # @ingroup l2_modif_unitetri
2289 def DeleteDiag(self, NodeID1, NodeID2):
2290 return self.editor.DeleteDiag(NodeID1, NodeID2)
2292 ## Reorients elements by ids
2293 # @param IDsOfElements if undefined reorients all mesh elements
2294 # @return True if succeed else False
2295 # @ingroup l2_modif_changori
2296 def Reorient(self, IDsOfElements=None):
2297 if IDsOfElements == None:
2298 IDsOfElements = self.GetElementsId()
2299 return self.editor.Reorient(IDsOfElements)
2301 ## Reorients all elements of the object
2302 # @param theObject mesh, submesh or group
2303 # @return True if succeed else False
2304 # @ingroup l2_modif_changori
2305 def ReorientObject(self, theObject):
2306 if ( isinstance( theObject, Mesh )):
2307 theObject = theObject.GetMesh()
2308 return self.editor.ReorientObject(theObject)
2310 ## Fuses the neighbouring triangles into quadrangles.
2311 # @param IDsOfElements The triangles to be fused,
2312 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2313 # @param MaxAngle is the maximum angle between element normals at which the fusion
2314 # is still performed; theMaxAngle is mesured in radians.
2315 # Also it could be a name of variable which defines angle in degrees.
2316 # @return TRUE in case of success, FALSE otherwise.
2317 # @ingroup l2_modif_unitetri
2318 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2320 if isinstance(MaxAngle,str):
2322 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2324 MaxAngle = DegreesToRadians(MaxAngle)
2325 if IDsOfElements == []:
2326 IDsOfElements = self.GetElementsId()
2327 self.mesh.SetParameters(Parameters)
2329 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2330 Functor = theCriterion
2332 Functor = self.smeshpyD.GetFunctor(theCriterion)
2333 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2335 ## Fuses the neighbouring triangles of the object into quadrangles
2336 # @param theObject is mesh, submesh or group
2337 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2338 # @param MaxAngle a max angle between element normals at which the fusion
2339 # is still performed; theMaxAngle is mesured in radians.
2340 # @return TRUE in case of success, FALSE otherwise.
2341 # @ingroup l2_modif_unitetri
2342 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2343 if ( isinstance( theObject, Mesh )):
2344 theObject = theObject.GetMesh()
2345 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2347 ## Splits quadrangles into triangles.
2348 # @param IDsOfElements the faces to be splitted.
2349 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2350 # @return TRUE in case of success, FALSE otherwise.
2351 # @ingroup l2_modif_cutquadr
2352 def QuadToTri (self, IDsOfElements, theCriterion):
2353 if IDsOfElements == []:
2354 IDsOfElements = self.GetElementsId()
2355 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2357 ## Splits quadrangles into triangles.
2358 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2359 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2360 # @return TRUE in case of success, FALSE otherwise.
2361 # @ingroup l2_modif_cutquadr
2362 def QuadToTriObject (self, theObject, theCriterion):
2363 if ( isinstance( theObject, Mesh )):
2364 theObject = theObject.GetMesh()
2365 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2367 ## Splits quadrangles into triangles.
2368 # @param IDsOfElements the faces to be splitted
2369 # @param Diag13 is used to choose a diagonal for splitting.
2370 # @return TRUE in case of success, FALSE otherwise.
2371 # @ingroup l2_modif_cutquadr
2372 def SplitQuad (self, IDsOfElements, Diag13):
2373 if IDsOfElements == []:
2374 IDsOfElements = self.GetElementsId()
2375 return self.editor.SplitQuad(IDsOfElements, Diag13)
2377 ## Splits quadrangles into triangles.
2378 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2379 # @param Diag13 is used to choose a diagonal for splitting.
2380 # @return TRUE in case of success, FALSE otherwise.
2381 # @ingroup l2_modif_cutquadr
2382 def SplitQuadObject (self, theObject, Diag13):
2383 if ( isinstance( theObject, Mesh )):
2384 theObject = theObject.GetMesh()
2385 return self.editor.SplitQuadObject(theObject, Diag13)
2387 ## Finds a better splitting of the given quadrangle.
2388 # @param IDOfQuad the ID of the quadrangle to be splitted.
2389 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2390 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2391 # diagonal is better, 0 if error occurs.
2392 # @ingroup l2_modif_cutquadr
2393 def BestSplit (self, IDOfQuad, theCriterion):
2394 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2396 ## Splits quadrangle faces near triangular facets of volumes
2398 # @ingroup l1_auxiliary
2399 def SplitQuadsNearTriangularFacets(self):
2400 faces_array = self.GetElementsByType(SMESH.FACE)
2401 for face_id in faces_array:
2402 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2403 quad_nodes = self.mesh.GetElemNodes(face_id)
2404 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2405 isVolumeFound = False
2406 for node1_elem in node1_elems:
2407 if not isVolumeFound:
2408 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2409 nb_nodes = self.GetElemNbNodes(node1_elem)
2410 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2411 volume_elem = node1_elem
2412 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2413 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2414 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2415 isVolumeFound = True
2416 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2417 self.SplitQuad([face_id], False) # diagonal 2-4
2418 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2419 isVolumeFound = True
2420 self.SplitQuad([face_id], True) # diagonal 1-3
2421 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2422 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2423 isVolumeFound = True
2424 self.SplitQuad([face_id], True) # diagonal 1-3
2426 ## @brief Splits hexahedrons into tetrahedrons.
2428 # This operation uses pattern mapping functionality for splitting.
2429 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2430 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2431 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2432 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2433 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2434 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2435 # @return TRUE in case of success, FALSE otherwise.
2436 # @ingroup l1_auxiliary
2437 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2438 # Pattern: 5.---------.6
2443 # (0,0,1) 4.---------.7 * |
2450 # (0,0,0) 0.---------.3
2451 pattern_tetra = "!!! Nb of points: \n 8 \n\
2461 !!! Indices of points of 6 tetras: \n\
2469 pattern = self.smeshpyD.GetPattern()
2470 isDone = pattern.LoadFromFile(pattern_tetra)
2472 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2475 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2476 isDone = pattern.MakeMesh(self.mesh, False, False)
2477 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2479 # split quafrangle faces near triangular facets of volumes
2480 self.SplitQuadsNearTriangularFacets()
2484 ## @brief Split hexahedrons into prisms.
2486 # Uses the pattern mapping functionality for splitting.
2487 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2488 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2489 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2490 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2491 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2492 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2493 # @return TRUE in case of success, FALSE otherwise.
2494 # @ingroup l1_auxiliary
2495 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2496 # Pattern: 5.---------.6
2501 # (0,0,1) 4.---------.7 |
2508 # (0,0,0) 0.---------.3
2509 pattern_prism = "!!! Nb of points: \n 8 \n\
2519 !!! Indices of points of 2 prisms: \n\
2523 pattern = self.smeshpyD.GetPattern()
2524 isDone = pattern.LoadFromFile(pattern_prism)
2526 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2529 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2530 isDone = pattern.MakeMesh(self.mesh, False, False)
2531 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2533 # Splits quafrangle faces near triangular facets of volumes
2534 self.SplitQuadsNearTriangularFacets()
2538 ## Smoothes elements
2539 # @param IDsOfElements the list if ids of elements to smooth
2540 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2541 # Note that nodes built on edges and boundary nodes are always fixed.
2542 # @param MaxNbOfIterations the maximum number of iterations
2543 # @param MaxAspectRatio varies in range [1.0, inf]
2544 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2545 # @return TRUE in case of success, FALSE otherwise.
2546 # @ingroup l2_modif_smooth
2547 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2548 MaxNbOfIterations, MaxAspectRatio, Method):
2549 if IDsOfElements == []:
2550 IDsOfElements = self.GetElementsId()
2551 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2552 self.mesh.SetParameters(Parameters)
2553 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2554 MaxNbOfIterations, MaxAspectRatio, Method)
2556 ## Smoothes elements which belong to the given object
2557 # @param theObject the object to smooth
2558 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2559 # Note that nodes built on edges and boundary nodes are always fixed.
2560 # @param MaxNbOfIterations the maximum number of iterations
2561 # @param MaxAspectRatio varies in range [1.0, inf]
2562 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2563 # @return TRUE in case of success, FALSE otherwise.
2564 # @ingroup l2_modif_smooth
2565 def SmoothObject(self, theObject, IDsOfFixedNodes,
2566 MaxNbOfIterations, MaxAspectRatio, Method):
2567 if ( isinstance( theObject, Mesh )):
2568 theObject = theObject.GetMesh()
2569 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2570 MaxNbOfIterations, MaxAspectRatio, Method)
2572 ## Parametrically smoothes the given elements
2573 # @param IDsOfElements the list if ids of elements to smooth
2574 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2575 # Note that nodes built on edges and boundary nodes are always fixed.
2576 # @param MaxNbOfIterations the maximum number of iterations
2577 # @param MaxAspectRatio varies in range [1.0, inf]
2578 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2579 # @return TRUE in case of success, FALSE otherwise.
2580 # @ingroup l2_modif_smooth
2581 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2582 MaxNbOfIterations, MaxAspectRatio, Method):
2583 if IDsOfElements == []:
2584 IDsOfElements = self.GetElementsId()
2585 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2586 self.mesh.SetParameters(Parameters)
2587 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2588 MaxNbOfIterations, MaxAspectRatio, Method)
2590 ## Parametrically smoothes the elements which belong to the given object
2591 # @param theObject the object to smooth
2592 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2593 # Note that nodes built on edges and boundary nodes are always fixed.
2594 # @param MaxNbOfIterations the maximum number of iterations
2595 # @param MaxAspectRatio varies in range [1.0, inf]
2596 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2597 # @return TRUE in case of success, FALSE otherwise.
2598 # @ingroup l2_modif_smooth
2599 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2600 MaxNbOfIterations, MaxAspectRatio, Method):
2601 if ( isinstance( theObject, Mesh )):
2602 theObject = theObject.GetMesh()
2603 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2604 MaxNbOfIterations, MaxAspectRatio, Method)
2606 ## Converts the mesh to quadratic, deletes old elements, replacing
2607 # them with quadratic with the same id.
2608 # @ingroup l2_modif_tofromqu
2609 def ConvertToQuadratic(self, theForce3d):
2610 self.editor.ConvertToQuadratic(theForce3d)
2612 ## Converts the mesh from quadratic to ordinary,
2613 # deletes old quadratic elements, \n replacing
2614 # them with ordinary mesh elements with the same id.
2615 # @return TRUE in case of success, FALSE otherwise.
2616 # @ingroup l2_modif_tofromqu
2617 def ConvertFromQuadratic(self):
2618 return self.editor.ConvertFromQuadratic()
2620 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2621 # @return TRUE if operation has been completed successfully, FALSE otherwise
2622 # @ingroup l2_modif_edit
2623 def Make2DMeshFrom3D(self):
2624 return self.editor. Make2DMeshFrom3D()
2626 ## Renumber mesh nodes
2627 # @ingroup l2_modif_renumber
2628 def RenumberNodes(self):
2629 self.editor.RenumberNodes()
2631 ## Renumber mesh elements
2632 # @ingroup l2_modif_renumber
2633 def RenumberElements(self):
2634 self.editor.RenumberElements()
2636 ## Generates new elements by rotation of the elements around the axis
2637 # @param IDsOfElements the list of ids of elements to sweep
2638 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2639 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2640 # @param NbOfSteps the number of steps
2641 # @param Tolerance tolerance
2642 # @param MakeGroups forces the generation of new groups from existing ones
2643 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2644 # of all steps, else - size of each step
2645 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2646 # @ingroup l2_modif_extrurev
2647 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2648 MakeGroups=False, TotalAngle=False):
2650 if isinstance(AngleInRadians,str):
2652 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2654 AngleInRadians = DegreesToRadians(AngleInRadians)
2655 if IDsOfElements == []:
2656 IDsOfElements = self.GetElementsId()
2657 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2658 Axis = self.smeshpyD.GetAxisStruct(Axis)
2659 Axis,AxisParameters = ParseAxisStruct(Axis)
2660 if TotalAngle and NbOfSteps:
2661 AngleInRadians /= NbOfSteps
2662 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2663 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2664 self.mesh.SetParameters(Parameters)
2666 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2667 AngleInRadians, NbOfSteps, Tolerance)
2668 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2671 ## Generates new elements by rotation of the elements of object around the axis
2672 # @param theObject object which elements should be sweeped
2673 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2674 # @param AngleInRadians the angle of Rotation
2675 # @param NbOfSteps number of steps
2676 # @param Tolerance tolerance
2677 # @param MakeGroups forces the generation of new groups from existing ones
2678 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2679 # of all steps, else - size of each step
2680 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2681 # @ingroup l2_modif_extrurev
2682 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2683 MakeGroups=False, TotalAngle=False):
2685 if isinstance(AngleInRadians,str):
2687 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2689 AngleInRadians = DegreesToRadians(AngleInRadians)
2690 if ( isinstance( theObject, Mesh )):
2691 theObject = theObject.GetMesh()
2692 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2693 Axis = self.smeshpyD.GetAxisStruct(Axis)
2694 Axis,AxisParameters = ParseAxisStruct(Axis)
2695 if TotalAngle and NbOfSteps:
2696 AngleInRadians /= NbOfSteps
2697 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2698 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2699 self.mesh.SetParameters(Parameters)
2701 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2702 NbOfSteps, Tolerance)
2703 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2706 ## Generates new elements by rotation of the elements of object around the axis
2707 # @param theObject object which elements should be sweeped
2708 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2709 # @param AngleInRadians the angle of Rotation
2710 # @param NbOfSteps number of steps
2711 # @param Tolerance tolerance
2712 # @param MakeGroups forces the generation of new groups from existing ones
2713 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2714 # of all steps, else - size of each step
2715 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2716 # @ingroup l2_modif_extrurev
2717 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2718 MakeGroups=False, TotalAngle=False):
2720 if isinstance(AngleInRadians,str):
2722 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2724 AngleInRadians = DegreesToRadians(AngleInRadians)
2725 if ( isinstance( theObject, Mesh )):
2726 theObject = theObject.GetMesh()
2727 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2728 Axis = self.smeshpyD.GetAxisStruct(Axis)
2729 Axis,AxisParameters = ParseAxisStruct(Axis)
2730 if TotalAngle and NbOfSteps:
2731 AngleInRadians /= NbOfSteps
2732 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2733 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2734 self.mesh.SetParameters(Parameters)
2736 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2737 NbOfSteps, Tolerance)
2738 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2741 ## Generates new elements by rotation of the elements of object around the axis
2742 # @param theObject object which elements should be sweeped
2743 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2744 # @param AngleInRadians the angle of Rotation
2745 # @param NbOfSteps number of steps
2746 # @param Tolerance tolerance
2747 # @param MakeGroups forces the generation of new groups from existing ones
2748 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2749 # of all steps, else - size of each step
2750 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2751 # @ingroup l2_modif_extrurev
2752 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2753 MakeGroups=False, TotalAngle=False):
2755 if isinstance(AngleInRadians,str):
2757 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2759 AngleInRadians = DegreesToRadians(AngleInRadians)
2760 if ( isinstance( theObject, Mesh )):
2761 theObject = theObject.GetMesh()
2762 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2763 Axis = self.smeshpyD.GetAxisStruct(Axis)
2764 Axis,AxisParameters = ParseAxisStruct(Axis)
2765 if TotalAngle and NbOfSteps:
2766 AngleInRadians /= NbOfSteps
2767 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2768 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2769 self.mesh.SetParameters(Parameters)
2771 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2772 NbOfSteps, Tolerance)
2773 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2776 ## Generates new elements by extrusion of the elements with given ids
2777 # @param IDsOfElements the list of elements ids for extrusion
2778 # @param StepVector vector, defining the direction and value of extrusion
2779 # @param NbOfSteps the number of steps
2780 # @param MakeGroups forces the generation of new groups from existing ones
2781 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2782 # @ingroup l2_modif_extrurev
2783 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2784 if IDsOfElements == []:
2785 IDsOfElements = self.GetElementsId()
2786 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2787 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2788 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2789 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2790 Parameters = StepVectorParameters + var_separator + Parameters
2791 self.mesh.SetParameters(Parameters)
2793 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2794 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2797 ## Generates new elements by extrusion of the elements with given ids
2798 # @param IDsOfElements is ids of elements
2799 # @param StepVector vector, defining the direction and value of extrusion
2800 # @param NbOfSteps the number of steps
2801 # @param ExtrFlags sets flags for extrusion
2802 # @param SewTolerance uses for comparing locations of nodes if flag
2803 # EXTRUSION_FLAG_SEW is set
2804 # @param MakeGroups forces the generation of new groups from existing ones
2805 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2806 # @ingroup l2_modif_extrurev
2807 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2808 ExtrFlags, SewTolerance, MakeGroups=False):
2809 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2810 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2812 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2813 ExtrFlags, SewTolerance)
2814 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2815 ExtrFlags, SewTolerance)
2818 ## Generates new elements by extrusion of the elements which belong to the object
2819 # @param theObject the object which elements should be processed
2820 # @param StepVector vector, defining the direction and value of extrusion
2821 # @param NbOfSteps the number of steps
2822 # @param MakeGroups forces the generation of new groups from existing ones
2823 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2824 # @ingroup l2_modif_extrurev
2825 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2826 if ( isinstance( theObject, Mesh )):
2827 theObject = theObject.GetMesh()
2828 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2829 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2830 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2831 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2832 Parameters = StepVectorParameters + var_separator + Parameters
2833 self.mesh.SetParameters(Parameters)
2835 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2836 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2839 ## Generates new elements by extrusion of the elements which belong to the object
2840 # @param theObject object which elements should be processed
2841 # @param StepVector vector, defining the direction and value of extrusion
2842 # @param NbOfSteps the number of steps
2843 # @param MakeGroups to generate new groups from existing ones
2844 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2845 # @ingroup l2_modif_extrurev
2846 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2847 if ( isinstance( theObject, Mesh )):
2848 theObject = theObject.GetMesh()
2849 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2850 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2851 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2852 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2853 Parameters = StepVectorParameters + var_separator + Parameters
2854 self.mesh.SetParameters(Parameters)
2856 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2857 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2860 ## Generates new elements by extrusion of the elements which belong to the object
2861 # @param theObject object which elements should be processed
2862 # @param StepVector vector, defining the direction and value of extrusion
2863 # @param NbOfSteps the number of steps
2864 # @param MakeGroups forces the generation of new groups from existing ones
2865 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2866 # @ingroup l2_modif_extrurev
2867 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2868 if ( isinstance( theObject, Mesh )):
2869 theObject = theObject.GetMesh()
2870 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2871 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2872 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2873 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2874 Parameters = StepVectorParameters + var_separator + Parameters
2875 self.mesh.SetParameters(Parameters)
2877 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2878 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2883 ## Generates new elements by extrusion of the given elements
2884 # The path of extrusion must be a meshed edge.
2885 # @param Base mesh or list of ids of elements for extrusion
2886 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2887 # @param NodeStart the start node from Path. Defines the direction of extrusion
2888 # @param HasAngles allows the shape to be rotated around the path
2889 # to get the resulting mesh in a helical fashion
2890 # @param Angles list of angles in radians
2891 # @param LinearVariation forces the computation of rotation angles as linear
2892 # variation of the given Angles along path steps
2893 # @param HasRefPoint allows using the reference point
2894 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2895 # The User can specify any point as the Reference Point.
2896 # @param MakeGroups forces the generation of new groups from existing ones
2897 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2898 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2899 # only SMESH::Extrusion_Error otherwise
2900 # @ingroup l2_modif_extrurev
2901 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2902 HasAngles, Angles, LinearVariation,
2903 HasRefPoint, RefPoint, MakeGroups, ElemType):
2904 Angles,AnglesParameters = ParseAngles(Angles)
2905 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2906 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2907 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2909 Parameters = AnglesParameters + var_separator + RefPointParameters
2910 self.mesh.SetParameters(Parameters)
2912 if isinstance(Base,list):
2914 if Base == []: IDsOfElements = self.GetElementsId()
2915 else: IDsOfElements = Base
2916 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2917 HasAngles, Angles, LinearVariation,
2918 HasRefPoint, RefPoint, MakeGroups, ElemType)
2920 if isinstance(Base,Mesh):
2921 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
2922 HasAngles, Angles, LinearVariation,
2923 HasRefPoint, RefPoint, MakeGroups, ElemType)
2925 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2928 ## Generates new elements by extrusion of the given elements
2929 # The path of extrusion must be a meshed edge.
2930 # @param IDsOfElements ids of elements
2931 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2932 # @param PathShape shape(edge) defines the sub-mesh for the path
2933 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2934 # @param HasAngles allows the shape to be rotated around the path
2935 # to get the resulting mesh in a helical fashion
2936 # @param Angles list of angles in radians
2937 # @param HasRefPoint allows using the reference point
2938 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2939 # The User can specify any point as the Reference Point.
2940 # @param MakeGroups forces the generation of new groups from existing ones
2941 # @param LinearVariation forces the computation of rotation angles as linear
2942 # variation of the given Angles along path steps
2943 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2944 # only SMESH::Extrusion_Error otherwise
2945 # @ingroup l2_modif_extrurev
2946 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2947 HasAngles, Angles, HasRefPoint, RefPoint,
2948 MakeGroups=False, LinearVariation=False):
2949 Angles,AnglesParameters = ParseAngles(Angles)
2950 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2951 if IDsOfElements == []:
2952 IDsOfElements = self.GetElementsId()
2953 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2954 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2956 if ( isinstance( PathMesh, Mesh )):
2957 PathMesh = PathMesh.GetMesh()
2958 if HasAngles and Angles and LinearVariation:
2959 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2961 Parameters = AnglesParameters + var_separator + RefPointParameters
2962 self.mesh.SetParameters(Parameters)
2964 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2965 PathShape, NodeStart, HasAngles,
2966 Angles, HasRefPoint, RefPoint)
2967 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2968 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2970 ## Generates new elements by extrusion of the elements which belong to the object
2971 # The path of extrusion must be a meshed edge.
2972 # @param theObject the object which elements should be processed
2973 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2974 # @param PathShape shape(edge) defines the sub-mesh for the path
2975 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2976 # @param HasAngles allows the shape to be rotated around the path
2977 # to get the resulting mesh in a helical fashion
2978 # @param Angles list of angles
2979 # @param HasRefPoint allows using the reference point
2980 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2981 # The User can specify any point as the Reference Point.
2982 # @param MakeGroups forces the generation of new groups from existing ones
2983 # @param LinearVariation forces the computation of rotation angles as linear
2984 # variation of the given Angles along path steps
2985 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2986 # only SMESH::Extrusion_Error otherwise
2987 # @ingroup l2_modif_extrurev
2988 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2989 HasAngles, Angles, HasRefPoint, RefPoint,
2990 MakeGroups=False, LinearVariation=False):
2991 Angles,AnglesParameters = ParseAngles(Angles)
2992 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2993 if ( isinstance( theObject, Mesh )):
2994 theObject = theObject.GetMesh()
2995 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2996 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2997 if ( isinstance( PathMesh, Mesh )):
2998 PathMesh = PathMesh.GetMesh()
2999 if HasAngles and Angles and LinearVariation:
3000 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3002 Parameters = AnglesParameters + var_separator + RefPointParameters
3003 self.mesh.SetParameters(Parameters)
3005 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3006 PathShape, NodeStart, HasAngles,
3007 Angles, HasRefPoint, RefPoint)
3008 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3009 NodeStart, HasAngles, Angles, HasRefPoint,
3012 ## Generates new elements by extrusion of the elements which belong to the object
3013 # The path of extrusion must be a meshed edge.
3014 # @param theObject the object which elements should be processed
3015 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3016 # @param PathShape shape(edge) defines the sub-mesh for the path
3017 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3018 # @param HasAngles allows the shape to be rotated around the path
3019 # to get the resulting mesh in a helical fashion
3020 # @param Angles list of angles
3021 # @param HasRefPoint allows using the reference point
3022 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3023 # The User can specify any point as the Reference Point.
3024 # @param MakeGroups forces the generation of new groups from existing ones
3025 # @param LinearVariation forces the computation of rotation angles as linear
3026 # variation of the given Angles along path steps
3027 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3028 # only SMESH::Extrusion_Error otherwise
3029 # @ingroup l2_modif_extrurev
3030 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3031 HasAngles, Angles, HasRefPoint, RefPoint,
3032 MakeGroups=False, LinearVariation=False):
3033 Angles,AnglesParameters = ParseAngles(Angles)
3034 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3035 if ( isinstance( theObject, Mesh )):
3036 theObject = theObject.GetMesh()
3037 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3038 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3039 if ( isinstance( PathMesh, Mesh )):
3040 PathMesh = PathMesh.GetMesh()
3041 if HasAngles and Angles and LinearVariation:
3042 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3044 Parameters = AnglesParameters + var_separator + RefPointParameters
3045 self.mesh.SetParameters(Parameters)
3047 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3048 PathShape, NodeStart, HasAngles,
3049 Angles, HasRefPoint, RefPoint)
3050 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3051 NodeStart, HasAngles, Angles, HasRefPoint,
3054 ## Generates new elements by extrusion of the elements which belong to the object
3055 # The path of extrusion must be a meshed edge.
3056 # @param theObject the object which elements should be processed
3057 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3058 # @param PathShape shape(edge) defines the sub-mesh for the path
3059 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3060 # @param HasAngles allows the shape to be rotated around the path
3061 # to get the resulting mesh in a helical fashion
3062 # @param Angles list of angles
3063 # @param HasRefPoint allows using the reference point
3064 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3065 # The User can specify any point as the Reference Point.
3066 # @param MakeGroups forces the generation of new groups from existing ones
3067 # @param LinearVariation forces the computation of rotation angles as linear
3068 # variation of the given Angles along path steps
3069 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3070 # only SMESH::Extrusion_Error otherwise
3071 # @ingroup l2_modif_extrurev
3072 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3073 HasAngles, Angles, HasRefPoint, RefPoint,
3074 MakeGroups=False, LinearVariation=False):
3075 Angles,AnglesParameters = ParseAngles(Angles)
3076 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3077 if ( isinstance( theObject, Mesh )):
3078 theObject = theObject.GetMesh()
3079 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3080 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3081 if ( isinstance( PathMesh, Mesh )):
3082 PathMesh = PathMesh.GetMesh()
3083 if HasAngles and Angles and LinearVariation:
3084 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3086 Parameters = AnglesParameters + var_separator + RefPointParameters
3087 self.mesh.SetParameters(Parameters)
3089 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3090 PathShape, NodeStart, HasAngles,
3091 Angles, HasRefPoint, RefPoint)
3092 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3093 NodeStart, HasAngles, Angles, HasRefPoint,
3096 ## Creates a symmetrical copy of mesh elements
3097 # @param IDsOfElements list of elements ids
3098 # @param Mirror is AxisStruct or geom object(point, line, plane)
3099 # @param theMirrorType is POINT, AXIS or PLANE
3100 # If the Mirror is a geom object this parameter is unnecessary
3101 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3102 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3103 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3104 # @ingroup l2_modif_trsf
3105 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3106 if IDsOfElements == []:
3107 IDsOfElements = self.GetElementsId()
3108 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3109 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3110 Mirror,Parameters = ParseAxisStruct(Mirror)
3111 self.mesh.SetParameters(Parameters)
3112 if Copy and MakeGroups:
3113 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3114 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3117 ## Creates a new mesh by a symmetrical copy of mesh elements
3118 # @param IDsOfElements the list of elements ids
3119 # @param Mirror is AxisStruct or geom object (point, line, plane)
3120 # @param theMirrorType is POINT, AXIS or PLANE
3121 # If the Mirror is a geom object this parameter is unnecessary
3122 # @param MakeGroups to generate new groups from existing ones
3123 # @param NewMeshName a name of the new mesh to create
3124 # @return instance of Mesh class
3125 # @ingroup l2_modif_trsf
3126 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3127 if IDsOfElements == []:
3128 IDsOfElements = self.GetElementsId()
3129 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3130 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3131 Mirror,Parameters = ParseAxisStruct(Mirror)
3132 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3133 MakeGroups, NewMeshName)
3134 mesh.SetParameters(Parameters)
3135 return Mesh(self.smeshpyD,self.geompyD,mesh)
3137 ## Creates a symmetrical copy of the object
3138 # @param theObject mesh, submesh or group
3139 # @param Mirror AxisStruct or geom object (point, line, plane)
3140 # @param theMirrorType is POINT, AXIS or PLANE
3141 # If the Mirror is a geom object this parameter is unnecessary
3142 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3143 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3144 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3145 # @ingroup l2_modif_trsf
3146 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3147 if ( isinstance( theObject, Mesh )):
3148 theObject = theObject.GetMesh()
3149 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3150 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3151 Mirror,Parameters = ParseAxisStruct(Mirror)
3152 self.mesh.SetParameters(Parameters)
3153 if Copy and MakeGroups:
3154 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3155 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3158 ## Creates a new mesh by a symmetrical copy of the object
3159 # @param theObject mesh, submesh or group
3160 # @param Mirror AxisStruct or geom object (point, line, plane)
3161 # @param theMirrorType POINT, AXIS or PLANE
3162 # If the Mirror is a geom object this parameter is unnecessary
3163 # @param MakeGroups forces the generation of new groups from existing ones
3164 # @param NewMeshName the name of the new mesh to create
3165 # @return instance of Mesh class
3166 # @ingroup l2_modif_trsf
3167 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3168 if ( isinstance( theObject, Mesh )):
3169 theObject = theObject.GetMesh()
3170 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3171 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3172 Mirror,Parameters = ParseAxisStruct(Mirror)
3173 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3174 MakeGroups, NewMeshName)
3175 mesh.SetParameters(Parameters)
3176 return Mesh( self.smeshpyD,self.geompyD,mesh )
3178 ## Translates the elements
3179 # @param IDsOfElements list of elements ids
3180 # @param Vector the direction of translation (DirStruct or vector)
3181 # @param Copy allows copying the translated elements
3182 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3183 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3184 # @ingroup l2_modif_trsf
3185 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3186 if IDsOfElements == []:
3187 IDsOfElements = self.GetElementsId()
3188 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3189 Vector = self.smeshpyD.GetDirStruct(Vector)
3190 Vector,Parameters = ParseDirStruct(Vector)
3191 self.mesh.SetParameters(Parameters)
3192 if Copy and MakeGroups:
3193 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3194 self.editor.Translate(IDsOfElements, Vector, Copy)
3197 ## Creates a new mesh of translated elements
3198 # @param IDsOfElements list of elements ids
3199 # @param Vector the direction of translation (DirStruct or vector)
3200 # @param MakeGroups forces the generation of new groups from existing ones
3201 # @param NewMeshName the name of the newly created mesh
3202 # @return instance of Mesh class
3203 # @ingroup l2_modif_trsf
3204 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3205 if IDsOfElements == []:
3206 IDsOfElements = self.GetElementsId()
3207 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3208 Vector = self.smeshpyD.GetDirStruct(Vector)
3209 Vector,Parameters = ParseDirStruct(Vector)
3210 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3211 mesh.SetParameters(Parameters)
3212 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3214 ## Translates the object
3215 # @param theObject the object to translate (mesh, submesh, or group)
3216 # @param Vector direction of translation (DirStruct or geom vector)
3217 # @param Copy allows copying the translated elements
3218 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3219 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3220 # @ingroup l2_modif_trsf
3221 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3222 if ( isinstance( theObject, Mesh )):
3223 theObject = theObject.GetMesh()
3224 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3225 Vector = self.smeshpyD.GetDirStruct(Vector)
3226 Vector,Parameters = ParseDirStruct(Vector)
3227 self.mesh.SetParameters(Parameters)
3228 if Copy and MakeGroups:
3229 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3230 self.editor.TranslateObject(theObject, Vector, Copy)
3233 ## Creates a new mesh from the translated object
3234 # @param theObject the object to translate (mesh, submesh, or group)
3235 # @param Vector the direction of translation (DirStruct or geom vector)
3236 # @param MakeGroups forces the generation of new groups from existing ones
3237 # @param NewMeshName the name of the newly created mesh
3238 # @return instance of Mesh class
3239 # @ingroup l2_modif_trsf
3240 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3241 if (isinstance(theObject, Mesh)):
3242 theObject = theObject.GetMesh()
3243 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3244 Vector = self.smeshpyD.GetDirStruct(Vector)
3245 Vector,Parameters = ParseDirStruct(Vector)
3246 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3247 mesh.SetParameters(Parameters)
3248 return Mesh( self.smeshpyD, self.geompyD, mesh )
3250 ## Rotates the elements
3251 # @param IDsOfElements list of elements ids
3252 # @param Axis the axis of rotation (AxisStruct or geom line)
3253 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3254 # @param Copy allows copying the rotated elements
3255 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3256 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3257 # @ingroup l2_modif_trsf
3258 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3260 if isinstance(AngleInRadians,str):
3262 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3264 AngleInRadians = DegreesToRadians(AngleInRadians)
3265 if IDsOfElements == []:
3266 IDsOfElements = self.GetElementsId()
3267 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3268 Axis = self.smeshpyD.GetAxisStruct(Axis)
3269 Axis,AxisParameters = ParseAxisStruct(Axis)
3270 Parameters = AxisParameters + var_separator + Parameters
3271 self.mesh.SetParameters(Parameters)
3272 if Copy and MakeGroups:
3273 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3274 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3277 ## Creates a new mesh of rotated elements
3278 # @param IDsOfElements list of element ids
3279 # @param Axis the axis of rotation (AxisStruct or geom line)
3280 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3281 # @param MakeGroups forces the generation of new groups from existing ones
3282 # @param NewMeshName the name of the newly created mesh
3283 # @return instance of Mesh class
3284 # @ingroup l2_modif_trsf
3285 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3287 if isinstance(AngleInRadians,str):
3289 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3291 AngleInRadians = DegreesToRadians(AngleInRadians)
3292 if IDsOfElements == []:
3293 IDsOfElements = self.GetElementsId()
3294 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3295 Axis = self.smeshpyD.GetAxisStruct(Axis)
3296 Axis,AxisParameters = ParseAxisStruct(Axis)
3297 Parameters = AxisParameters + var_separator + Parameters
3298 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3299 MakeGroups, NewMeshName)
3300 mesh.SetParameters(Parameters)
3301 return Mesh( self.smeshpyD, self.geompyD, mesh )
3303 ## Rotates the object
3304 # @param theObject the object to rotate( mesh, submesh, or group)
3305 # @param Axis the axis of rotation (AxisStruct or geom line)
3306 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3307 # @param Copy allows copying the rotated elements
3308 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3309 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3310 # @ingroup l2_modif_trsf
3311 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3313 if isinstance(AngleInRadians,str):
3315 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3317 AngleInRadians = DegreesToRadians(AngleInRadians)
3318 if (isinstance(theObject, Mesh)):
3319 theObject = theObject.GetMesh()
3320 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3321 Axis = self.smeshpyD.GetAxisStruct(Axis)
3322 Axis,AxisParameters = ParseAxisStruct(Axis)
3323 Parameters = AxisParameters + ":" + Parameters
3324 self.mesh.SetParameters(Parameters)
3325 if Copy and MakeGroups:
3326 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3327 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3330 ## Creates a new mesh from the rotated object
3331 # @param theObject the object to rotate (mesh, submesh, or group)
3332 # @param Axis the axis of rotation (AxisStruct or geom line)
3333 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3334 # @param MakeGroups forces the generation of new groups from existing ones
3335 # @param NewMeshName the name of the newly created mesh
3336 # @return instance of Mesh class
3337 # @ingroup l2_modif_trsf
3338 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3340 if isinstance(AngleInRadians,str):
3342 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3344 AngleInRadians = DegreesToRadians(AngleInRadians)
3345 if (isinstance( theObject, Mesh )):
3346 theObject = theObject.GetMesh()
3347 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3348 Axis = self.smeshpyD.GetAxisStruct(Axis)
3349 Axis,AxisParameters = ParseAxisStruct(Axis)
3350 Parameters = AxisParameters + ":" + Parameters
3351 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3352 MakeGroups, NewMeshName)
3353 mesh.SetParameters(Parameters)
3354 return Mesh( self.smeshpyD, self.geompyD, mesh )
3356 ## Finds groups of ajacent nodes within Tolerance.
3357 # @param Tolerance the value of tolerance
3358 # @return the list of groups of nodes
3359 # @ingroup l2_modif_trsf
3360 def FindCoincidentNodes (self, Tolerance):
3361 return self.editor.FindCoincidentNodes(Tolerance)
3363 ## Finds groups of ajacent nodes within Tolerance.
3364 # @param Tolerance the value of tolerance
3365 # @param SubMeshOrGroup SubMesh or Group
3366 # @return the list of groups of nodes
3367 # @ingroup l2_modif_trsf
3368 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3369 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3372 # @param GroupsOfNodes the list of groups of nodes
3373 # @ingroup l2_modif_trsf
3374 def MergeNodes (self, GroupsOfNodes):
3375 self.editor.MergeNodes(GroupsOfNodes)
3377 ## Finds the elements built on the same nodes.
3378 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3379 # @return a list of groups of equal elements
3380 # @ingroup l2_modif_trsf
3381 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3382 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3383 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3384 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3386 ## Merges elements in each given group.
3387 # @param GroupsOfElementsID groups of elements for merging
3388 # @ingroup l2_modif_trsf
3389 def MergeElements(self, GroupsOfElementsID):
3390 self.editor.MergeElements(GroupsOfElementsID)
3392 ## Leaves one element and removes all other elements built on the same nodes.
3393 # @ingroup l2_modif_trsf
3394 def MergeEqualElements(self):
3395 self.editor.MergeEqualElements()
3397 ## Sews free borders
3398 # @return SMESH::Sew_Error
3399 # @ingroup l2_modif_trsf
3400 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3401 FirstNodeID2, SecondNodeID2, LastNodeID2,
3402 CreatePolygons, CreatePolyedrs):
3403 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3404 FirstNodeID2, SecondNodeID2, LastNodeID2,
3405 CreatePolygons, CreatePolyedrs)
3407 ## Sews conform free borders
3408 # @return SMESH::Sew_Error
3409 # @ingroup l2_modif_trsf
3410 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3411 FirstNodeID2, SecondNodeID2):
3412 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3413 FirstNodeID2, SecondNodeID2)
3415 ## Sews border to side
3416 # @return SMESH::Sew_Error
3417 # @ingroup l2_modif_trsf
3418 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3419 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3420 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3421 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3423 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3424 # merged with the nodes of elements of Side2.
3425 # The number of elements in theSide1 and in theSide2 must be
3426 # equal and they should have similar nodal connectivity.
3427 # The nodes to merge should belong to side borders and
3428 # the first node should be linked to the second.
3429 # @return SMESH::Sew_Error
3430 # @ingroup l2_modif_trsf
3431 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3432 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3433 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3434 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3435 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3436 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3438 ## Sets new nodes for the given element.
3439 # @param ide the element id
3440 # @param newIDs nodes ids
3441 # @return If the number of nodes does not correspond to the type of element - returns false
3442 # @ingroup l2_modif_edit
3443 def ChangeElemNodes(self, ide, newIDs):
3444 return self.editor.ChangeElemNodes(ide, newIDs)
3446 ## If during the last operation of MeshEditor some nodes were
3447 # created, this method returns the list of their IDs, \n
3448 # if new nodes were not created - returns empty list
3449 # @return the list of integer values (can be empty)
3450 # @ingroup l1_auxiliary
3451 def GetLastCreatedNodes(self):
3452 return self.editor.GetLastCreatedNodes()
3454 ## If during the last operation of MeshEditor some elements were
3455 # created this method returns the list of their IDs, \n
3456 # if new elements were not created - returns empty list
3457 # @return the list of integer values (can be empty)
3458 # @ingroup l1_auxiliary
3459 def GetLastCreatedElems(self):
3460 return self.editor.GetLastCreatedElems()
3462 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3463 # @param theNodes identifiers of nodes to be doubled
3464 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3465 # nodes. If list of element identifiers is empty then nodes are doubled but
3466 # they not assigned to elements
3467 # @return TRUE if operation has been completed successfully, FALSE otherwise
3468 # @ingroup l2_modif_edit
3469 def DoubleNodes(self, theNodes, theModifiedElems):
3470 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3472 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3473 # This method provided for convenience works as DoubleNodes() described above.
3474 # @param theNodes identifiers of node to be doubled
3475 # @param theModifiedElems identifiers of elements to be updated
3476 # @return TRUE if operation has been completed successfully, FALSE otherwise
3477 # @ingroup l2_modif_edit
3478 def DoubleNode(self, theNodeId, theModifiedElems):
3479 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3481 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3482 # This method provided for convenience works as DoubleNodes() described above.
3483 # @param theNodes group of nodes to be doubled
3484 # @param theModifiedElems group of elements to be updated.
3485 # @return TRUE if operation has been completed successfully, FALSE otherwise
3486 # @ingroup l2_modif_edit
3487 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3488 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3490 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3491 # This method provided for convenience works as DoubleNodes() described above.
3492 # @param theNodes list of groups of nodes to be doubled
3493 # @param theModifiedElems list of groups of elements to be updated.
3494 # @return TRUE if operation has been completed successfully, FALSE otherwise
3495 # @ingroup l2_modif_edit
3496 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3497 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3499 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3500 # @param theElems - the list of elements (edges or faces) to be replicated
3501 # The nodes for duplication could be found from these elements
3502 # @param theNodesNot - list of nodes to NOT replicate
3503 # @param theAffectedElems - the list of elements (cells and edges) to which the
3504 # replicated nodes should be associated to.
3505 # @return TRUE if operation has been completed successfully, FALSE otherwise
3506 # @ingroup l2_modif_edit
3507 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3508 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3510 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3511 # @param theElems - the list of elements (edges or faces) to be replicated
3512 # The nodes for duplication could be found from these elements
3513 # @param theNodesNot - list of nodes to NOT replicate
3514 # @param theShape - shape to detect affected elements (element which geometric center
3515 # located on or inside shape).
3516 # The replicated nodes should be associated to affected elements.
3517 # @return TRUE if operation has been completed successfully, FALSE otherwise
3518 # @ingroup l2_modif_edit
3519 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3520 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3522 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3523 # This method provided for convenience works as DoubleNodes() described above.
3524 # @param theElems - group of of elements (edges or faces) to be replicated
3525 # @param theNodesNot - group of nodes not to replicated
3526 # @param theAffectedElems - group of elements to which the replicated nodes
3527 # should be associated to.
3528 # @ingroup l2_modif_edit
3529 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3530 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3532 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3533 # This method provided for convenience works as DoubleNodes() described above.
3534 # @param theElems - group of of elements (edges or faces) to be replicated
3535 # @param theNodesNot - group of nodes not to replicated
3536 # @param theShape - shape to detect affected elements (element which geometric center
3537 # located on or inside shape).
3538 # The replicated nodes should be associated to affected elements.
3539 # @ingroup l2_modif_edit
3540 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3541 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3543 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3544 # This method provided for convenience works as DoubleNodes() described above.
3545 # @param theElems - list of groups of elements (edges or faces) to be replicated
3546 # @param theNodesNot - list of groups of nodes not to replicated
3547 # @param theAffectedElems - group of elements to which the replicated nodes
3548 # should be associated to.
3549 # @return TRUE if operation has been completed successfully, FALSE otherwise
3550 # @ingroup l2_modif_edit
3551 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3552 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3554 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3555 # This method provided for convenience works as DoubleNodes() described above.
3556 # @param theElems - list of groups of elements (edges or faces) to be replicated
3557 # @param theNodesNot - list of groups of nodes not to replicated
3558 # @param theShape - shape to detect affected elements (element which geometric center
3559 # located on or inside shape).
3560 # The replicated nodes should be associated to affected elements.
3561 # @return TRUE if operation has been completed successfully, FALSE otherwise
3562 # @ingroup l2_modif_edit
3563 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3564 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3566 ## The mother class to define algorithm, it is not recommended to use it directly.
3569 # @ingroup l2_algorithms
3570 class Mesh_Algorithm:
3571 # @class Mesh_Algorithm
3572 # @brief Class Mesh_Algorithm
3574 #def __init__(self,smesh):
3582 ## Finds a hypothesis in the study by its type name and parameters.
3583 # Finds only the hypotheses created in smeshpyD engine.
3584 # @return SMESH.SMESH_Hypothesis
3585 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3586 study = smeshpyD.GetCurrentStudy()
3587 #to do: find component by smeshpyD object, not by its data type
3588 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3589 if scomp is not None:
3590 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3591 # Check if the root label of the hypotheses exists
3592 if res and hypRoot is not None:
3593 iter = study.NewChildIterator(hypRoot)
3594 # Check all published hypotheses
3596 hypo_so_i = iter.Value()
3597 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3598 if attr is not None:
3599 anIOR = attr.Value()
3600 hypo_o_i = salome.orb.string_to_object(anIOR)
3601 if hypo_o_i is not None:
3602 # Check if this is a hypothesis
3603 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3604 if hypo_i is not None:
3605 # Check if the hypothesis belongs to current engine
3606 if smeshpyD.GetObjectId(hypo_i) > 0:
3607 # Check if this is the required hypothesis
3608 if hypo_i.GetName() == hypname:
3610 if CompareMethod(hypo_i, args):
3624 ## Finds the algorithm in the study by its type name.
3625 # Finds only the algorithms, which have been created in smeshpyD engine.
3626 # @return SMESH.SMESH_Algo
3627 def FindAlgorithm (self, algoname, smeshpyD):
3628 study = smeshpyD.GetCurrentStudy()
3629 #to do: find component by smeshpyD object, not by its data type
3630 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3631 if scomp is not None:
3632 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3633 # Check if the root label of the algorithms exists
3634 if res and hypRoot is not None:
3635 iter = study.NewChildIterator(hypRoot)
3636 # Check all published algorithms
3638 algo_so_i = iter.Value()
3639 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3640 if attr is not None:
3641 anIOR = attr.Value()
3642 algo_o_i = salome.orb.string_to_object(anIOR)
3643 if algo_o_i is not None:
3644 # Check if this is an algorithm
3645 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3646 if algo_i is not None:
3647 # Checks if the algorithm belongs to the current engine
3648 if smeshpyD.GetObjectId(algo_i) > 0:
3649 # Check if this is the required algorithm
3650 if algo_i.GetName() == algoname:
3663 ## If the algorithm is global, returns 0; \n
3664 # else returns the submesh associated to this algorithm.
3665 def GetSubMesh(self):
3668 ## Returns the wrapped mesher.
3669 def GetAlgorithm(self):
3672 ## Gets the list of hypothesis that can be used with this algorithm
3673 def GetCompatibleHypothesis(self):
3676 mylist = self.algo.GetCompatibleHypothesis()
3679 ## Gets the name of the algorithm
3683 ## Sets the name to the algorithm
3684 def SetName(self, name):
3685 self.mesh.smeshpyD.SetName(self.algo, name)
3687 ## Gets the id of the algorithm
3689 return self.algo.GetId()
3692 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3694 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3695 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3697 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3699 self.Assign(algo, mesh, geom)
3703 def Assign(self, algo, mesh, geom):
3705 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3713 name = GetName(geom)
3716 name = mesh.geompyD.SubShapeName(geom, piece)
3717 mesh.geompyD.addToStudyInFather(piece, geom, name)
3719 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3722 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3723 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3725 def CompareHyp (self, hyp, args):
3726 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3729 def CompareEqualHyp (self, hyp, args):
3733 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3734 UseExisting=0, CompareMethod=""):
3737 if CompareMethod == "": CompareMethod = self.CompareHyp
3738 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3741 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3747 a = a + s + str(args[i])
3751 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3753 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3754 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3757 ## Returns entry of the shape to mesh in the study
3758 def MainShapeEntry(self):
3760 if not self.mesh or not self.mesh.GetMesh(): return entry
3761 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3762 study = self.mesh.smeshpyD.GetCurrentStudy()
3763 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3764 sobj = study.FindObjectIOR(ior)
3765 if sobj: entry = sobj.GetID()
3766 if not entry: return ""
3769 # Public class: Mesh_Segment
3770 # --------------------------
3772 ## Class to define a segment 1D algorithm for discretization
3775 # @ingroup l3_algos_basic
3776 class Mesh_Segment(Mesh_Algorithm):
3778 ## Private constructor.
3779 def __init__(self, mesh, geom=0):
3780 Mesh_Algorithm.__init__(self)
3781 self.Create(mesh, geom, "Regular_1D")
3783 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3784 # @param l for the length of segments that cut an edge
3785 # @param UseExisting if ==true - searches for an existing hypothesis created with
3786 # the same parameters, else (default) - creates a new one
3787 # @param p precision, used for calculation of the number of segments.
3788 # The precision should be a positive, meaningful value within the range [0,1].
3789 # In general, the number of segments is calculated with the formula:
3790 # nb = ceil((edge_length / l) - p)
3791 # Function ceil rounds its argument to the higher integer.
3792 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3793 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3794 # p=1 means rounding of (edge_length / l) to the lower integer.
3795 # Default value is 1e-07.
3796 # @return an instance of StdMeshers_LocalLength hypothesis
3797 # @ingroup l3_hypos_1dhyps
3798 def LocalLength(self, l, UseExisting=0, p=1e-07):
3799 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3800 CompareMethod=self.CompareLocalLength)
3806 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3807 def CompareLocalLength(self, hyp, args):
3808 if IsEqual(hyp.GetLength(), args[0]):
3809 return IsEqual(hyp.GetPrecision(), args[1])
3812 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3813 # @param length is optional maximal allowed length of segment, if it is omitted
3814 # the preestimated length is used that depends on geometry size
3815 # @param UseExisting if ==true - searches for an existing hypothesis created with
3816 # the same parameters, else (default) - create a new one
3817 # @return an instance of StdMeshers_MaxLength hypothesis
3818 # @ingroup l3_hypos_1dhyps
3819 def MaxSize(self, length=0.0, UseExisting=0):
3820 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3823 hyp.SetLength(length)
3825 # set preestimated length
3826 gen = self.mesh.smeshpyD
3827 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3828 self.mesh.GetMesh(), self.mesh.GetShape(),
3830 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3832 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3835 hyp.SetUsePreestimatedLength( length == 0.0 )
3838 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3839 # @param n for the number of segments that cut an edge
3840 # @param s for the scale factor (optional)
3841 # @param reversedEdges is a list of edges to mesh using reversed orientation
3842 # @param UseExisting if ==true - searches for an existing hypothesis created with
3843 # the same parameters, else (default) - create a new one
3844 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3845 # @ingroup l3_hypos_1dhyps
3846 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3847 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3848 reversedEdges, UseExisting = [], reversedEdges
3849 entry = self.MainShapeEntry()
3851 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3852 UseExisting=UseExisting,
3853 CompareMethod=self.CompareNumberOfSegments)
3855 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3856 UseExisting=UseExisting,
3857 CompareMethod=self.CompareNumberOfSegments)
3858 hyp.SetDistrType( 1 )
3859 hyp.SetScaleFactor(s)
3860 hyp.SetNumberOfSegments(n)
3861 hyp.SetReversedEdges( reversedEdges )
3862 hyp.SetObjectEntry( entry )
3866 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3867 def CompareNumberOfSegments(self, hyp, args):
3868 if hyp.GetNumberOfSegments() == args[0]:
3870 if hyp.GetReversedEdges() == args[1]:
3871 if not args[1] or hyp.GetObjectEntry() == args[2]:
3874 if hyp.GetReversedEdges() == args[2]:
3875 if not args[2] or hyp.GetObjectEntry() == args[3]:
3876 if hyp.GetDistrType() == 1:
3877 if IsEqual(hyp.GetScaleFactor(), args[1]):
3881 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3882 # @param start defines the length of the first segment
3883 # @param end defines the length of the last segment
3884 # @param reversedEdges is a list of edges to mesh using reversed orientation
3885 # @param UseExisting if ==true - searches for an existing hypothesis created with
3886 # the same parameters, else (default) - creates a new one
3887 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3888 # @ingroup l3_hypos_1dhyps
3889 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3890 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3891 reversedEdges, UseExisting = [], reversedEdges
3892 entry = self.MainShapeEntry()
3893 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3894 UseExisting=UseExisting,
3895 CompareMethod=self.CompareArithmetic1D)
3896 hyp.SetStartLength(start)
3897 hyp.SetEndLength(end)
3898 hyp.SetReversedEdges( reversedEdges )
3899 hyp.SetObjectEntry( entry )
3903 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3904 def CompareArithmetic1D(self, hyp, args):
3905 if IsEqual(hyp.GetLength(1), args[0]):
3906 if IsEqual(hyp.GetLength(0), args[1]):
3907 if hyp.GetReversedEdges() == args[2]:
3908 if not args[2] or hyp.GetObjectEntry() == args[3]:
3913 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3914 # on curve from 0 to 1 (additionally it is neecessary to check
3915 # orientation of edges and create list of reversed edges if it is
3916 # needed) and sets numbers of segments between given points (default
3917 # values are equals 1
3918 # @param points defines the list of parameters on curve
3919 # @param nbSegs defines the list of numbers of segments
3920 # @param reversedEdges is a list of edges to mesh using reversed orientation
3921 # @param UseExisting if ==true - searches for an existing hypothesis created with
3922 # the same parameters, else (default) - creates a new one
3923 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3924 # @ingroup l3_hypos_1dhyps
3925 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3926 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3927 reversedEdges, UseExisting = [], reversedEdges
3928 entry = self.MainShapeEntry()
3929 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3930 UseExisting=UseExisting,
3931 CompareMethod=self.CompareArithmetic1D)
3932 hyp.SetPoints(points)
3933 hyp.SetNbSegments(nbSegs)
3934 hyp.SetReversedEdges(reversedEdges)
3935 hyp.SetObjectEntry(entry)
3939 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3940 ## as the given arguments
3941 def CompareFixedPoints1D(self, hyp, args):
3942 if hyp.GetPoints() == args[0]:
3943 if hyp.GetNbSegments() == args[1]:
3944 if hyp.GetReversedEdges() == args[2]:
3945 if not args[2] or hyp.GetObjectEntry() == args[3]:
3951 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3952 # @param start defines the length of the first segment
3953 # @param end defines the length of the last segment
3954 # @param reversedEdges is a list of edges to mesh using reversed orientation
3955 # @param UseExisting if ==true - searches for an existing hypothesis created with
3956 # the same parameters, else (default) - creates a new one
3957 # @return an instance of StdMeshers_StartEndLength hypothesis
3958 # @ingroup l3_hypos_1dhyps
3959 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3960 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3961 reversedEdges, UseExisting = [], reversedEdges
3962 entry = self.MainShapeEntry()
3963 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3964 UseExisting=UseExisting,
3965 CompareMethod=self.CompareStartEndLength)
3966 hyp.SetStartLength(start)
3967 hyp.SetEndLength(end)
3968 hyp.SetReversedEdges( reversedEdges )
3969 hyp.SetObjectEntry( entry )
3972 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3973 def CompareStartEndLength(self, hyp, args):
3974 if IsEqual(hyp.GetLength(1), args[0]):
3975 if IsEqual(hyp.GetLength(0), args[1]):
3976 if hyp.GetReversedEdges() == args[2]:
3977 if not args[2] or hyp.GetObjectEntry() == args[3]:
3981 ## Defines "Deflection1D" hypothesis
3982 # @param d for the deflection
3983 # @param UseExisting if ==true - searches for an existing hypothesis created with
3984 # the same parameters, else (default) - create a new one
3985 # @ingroup l3_hypos_1dhyps
3986 def Deflection1D(self, d, UseExisting=0):
3987 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3988 CompareMethod=self.CompareDeflection1D)
3989 hyp.SetDeflection(d)
3992 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3993 def CompareDeflection1D(self, hyp, args):
3994 return IsEqual(hyp.GetDeflection(), args[0])
3996 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3997 # the opposite side in case of quadrangular faces
3998 # @ingroup l3_hypos_additi
3999 def Propagation(self):
4000 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4002 ## Defines "AutomaticLength" hypothesis
4003 # @param fineness for the fineness [0-1]
4004 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4005 # same parameters, else (default) - create a new one
4006 # @ingroup l3_hypos_1dhyps
4007 def AutomaticLength(self, fineness=0, UseExisting=0):
4008 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4009 CompareMethod=self.CompareAutomaticLength)
4010 hyp.SetFineness( fineness )
4013 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4014 def CompareAutomaticLength(self, hyp, args):
4015 return IsEqual(hyp.GetFineness(), args[0])
4017 ## Defines "SegmentLengthAroundVertex" hypothesis
4018 # @param length for the segment length
4019 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4020 # Any other integer value means that the hypothesis will be set on the
4021 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4022 # @param UseExisting if ==true - searches for an existing hypothesis created with
4023 # the same parameters, else (default) - creates a new one
4024 # @ingroup l3_algos_segmarv
4025 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4027 store_geom = self.geom
4028 if type(vertex) is types.IntType:
4029 if vertex == 0 or vertex == 1:
4030 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4038 if self.geom is None:
4039 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4041 name = GetName(self.geom)
4044 piece = self.mesh.geom
4045 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4046 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4048 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4050 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4052 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4053 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4055 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4056 CompareMethod=self.CompareLengthNearVertex)
4057 self.geom = store_geom
4058 hyp.SetLength( length )
4061 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4062 # @ingroup l3_algos_segmarv
4063 def CompareLengthNearVertex(self, hyp, args):
4064 return IsEqual(hyp.GetLength(), args[0])
4066 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4067 # If the 2D mesher sees that all boundary edges are quadratic,
4068 # it generates quadratic faces, else it generates linear faces using
4069 # medium nodes as if they are vertices.
4070 # The 3D mesher generates quadratic volumes only if all boundary faces
4071 # are quadratic, else it fails.
4073 # @ingroup l3_hypos_additi
4074 def QuadraticMesh(self):
4075 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4078 # Public class: Mesh_CompositeSegment
4079 # --------------------------
4081 ## Defines a segment 1D algorithm for discretization
4083 # @ingroup l3_algos_basic
4084 class Mesh_CompositeSegment(Mesh_Segment):
4086 ## Private constructor.
4087 def __init__(self, mesh, geom=0):
4088 self.Create(mesh, geom, "CompositeSegment_1D")
4091 # Public class: Mesh_Segment_Python
4092 # ---------------------------------
4094 ## Defines a segment 1D algorithm for discretization with python function
4096 # @ingroup l3_algos_basic
4097 class Mesh_Segment_Python(Mesh_Segment):
4099 ## Private constructor.
4100 def __init__(self, mesh, geom=0):
4101 import Python1dPlugin
4102 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4104 ## Defines "PythonSplit1D" hypothesis
4105 # @param n for the number of segments that cut an edge
4106 # @param func for the python function that calculates the length of all segments
4107 # @param UseExisting if ==true - searches for the existing hypothesis created with
4108 # the same parameters, else (default) - creates a new one
4109 # @ingroup l3_hypos_1dhyps
4110 def PythonSplit1D(self, n, func, UseExisting=0):
4111 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4112 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4113 hyp.SetNumberOfSegments(n)
4114 hyp.SetPythonLog10RatioFunction(func)
4117 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4118 def ComparePythonSplit1D(self, hyp, args):
4119 #if hyp.GetNumberOfSegments() == args[0]:
4120 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4124 # Public class: Mesh_Triangle
4125 # ---------------------------
4127 ## Defines a triangle 2D algorithm
4129 # @ingroup l3_algos_basic
4130 class Mesh_Triangle(Mesh_Algorithm):
4139 ## Private constructor.
4140 def __init__(self, mesh, algoType, geom=0):
4141 Mesh_Algorithm.__init__(self)
4143 self.algoType = algoType
4144 if algoType == MEFISTO:
4145 self.Create(mesh, geom, "MEFISTO_2D")
4147 elif algoType == BLSURF:
4149 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4150 #self.SetPhysicalMesh() - PAL19680
4151 elif algoType == NETGEN:
4153 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4155 elif algoType == NETGEN_2D:
4157 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4160 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4161 # @param area for the maximum area of each triangle
4162 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4163 # same parameters, else (default) - creates a new one
4165 # Only for algoType == MEFISTO || NETGEN_2D
4166 # @ingroup l3_hypos_2dhyps
4167 def MaxElementArea(self, area, UseExisting=0):
4168 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4169 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4170 CompareMethod=self.CompareMaxElementArea)
4171 elif self.algoType == NETGEN:
4172 hyp = self.Parameters(SIMPLE)
4173 hyp.SetMaxElementArea(area)
4176 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4177 def CompareMaxElementArea(self, hyp, args):
4178 return IsEqual(hyp.GetMaxElementArea(), args[0])
4180 ## Defines "LengthFromEdges" hypothesis to build triangles
4181 # based on the length of the edges taken from the wire
4183 # Only for algoType == MEFISTO || NETGEN_2D
4184 # @ingroup l3_hypos_2dhyps
4185 def LengthFromEdges(self):
4186 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4187 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4189 elif self.algoType == NETGEN:
4190 hyp = self.Parameters(SIMPLE)
4191 hyp.LengthFromEdges()
4194 ## Sets a way to define size of mesh elements to generate.
4195 # @param thePhysicalMesh is: DefaultSize or Custom.
4196 # @ingroup l3_hypos_blsurf
4197 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4198 # Parameter of BLSURF algo
4199 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4201 ## Sets size of mesh elements to generate.
4202 # @ingroup l3_hypos_blsurf
4203 def SetPhySize(self, theVal):
4204 # Parameter of BLSURF algo
4205 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4206 self.Parameters().SetPhySize(theVal)
4208 ## Sets lower boundary of mesh element size (PhySize).
4209 # @ingroup l3_hypos_blsurf
4210 def SetPhyMin(self, theVal=-1):
4211 # Parameter of BLSURF algo
4212 self.Parameters().SetPhyMin(theVal)
4214 ## Sets upper boundary of mesh element size (PhySize).
4215 # @ingroup l3_hypos_blsurf
4216 def SetPhyMax(self, theVal=-1):
4217 # Parameter of BLSURF algo
4218 self.Parameters().SetPhyMax(theVal)
4220 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4221 # @param theGeometricMesh is: DefaultGeom or Custom
4222 # @ingroup l3_hypos_blsurf
4223 def SetGeometricMesh(self, theGeometricMesh=0):
4224 # Parameter of BLSURF algo
4225 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4226 self.params.SetGeometricMesh(theGeometricMesh)
4228 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4229 # @ingroup l3_hypos_blsurf
4230 def SetAngleMeshS(self, theVal=_angleMeshS):
4231 # Parameter of BLSURF algo
4232 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4233 self.params.SetAngleMeshS(theVal)
4235 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4236 # @ingroup l3_hypos_blsurf
4237 def SetAngleMeshC(self, theVal=_angleMeshS):
4238 # Parameter of BLSURF algo
4239 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4240 self.params.SetAngleMeshC(theVal)
4242 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4243 # @ingroup l3_hypos_blsurf
4244 def SetGeoMin(self, theVal=-1):
4245 # Parameter of BLSURF algo
4246 self.Parameters().SetGeoMin(theVal)
4248 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4249 # @ingroup l3_hypos_blsurf
4250 def SetGeoMax(self, theVal=-1):
4251 # Parameter of BLSURF algo
4252 self.Parameters().SetGeoMax(theVal)
4254 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4255 # @ingroup l3_hypos_blsurf
4256 def SetGradation(self, theVal=_gradation):
4257 # Parameter of BLSURF algo
4258 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4259 self.params.SetGradation(theVal)
4261 ## Sets topology usage way.
4262 # @param way defines how mesh conformity is assured <ul>
4263 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4264 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4265 # @ingroup l3_hypos_blsurf
4266 def SetTopology(self, way):
4267 # Parameter of BLSURF algo
4268 self.Parameters().SetTopology(way)
4270 ## To respect geometrical edges or not.
4271 # @ingroup l3_hypos_blsurf
4272 def SetDecimesh(self, toIgnoreEdges=False):
4273 # Parameter of BLSURF algo
4274 self.Parameters().SetDecimesh(toIgnoreEdges)
4276 ## Sets verbosity level in the range 0 to 100.
4277 # @ingroup l3_hypos_blsurf
4278 def SetVerbosity(self, level):
4279 # Parameter of BLSURF algo
4280 self.Parameters().SetVerbosity(level)
4282 ## Sets advanced option value.
4283 # @ingroup l3_hypos_blsurf
4284 def SetOptionValue(self, optionName, level):
4285 # Parameter of BLSURF algo
4286 self.Parameters().SetOptionValue(optionName,level)
4288 ## Sets QuadAllowed flag.
4289 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4290 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4291 def SetQuadAllowed(self, toAllow=True):
4292 if self.algoType == NETGEN_2D:
4293 if toAllow: # add QuadranglePreference
4294 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4295 else: # remove QuadranglePreference
4296 for hyp in self.mesh.GetHypothesisList( self.geom ):
4297 if hyp.GetName() == "QuadranglePreference":
4298 self.mesh.RemoveHypothesis( self.geom, hyp )
4303 if self.Parameters():
4304 self.params.SetQuadAllowed(toAllow)
4307 ## Defines hypothesis having several parameters
4309 # @ingroup l3_hypos_netgen
4310 def Parameters(self, which=SOLE):
4313 if self.algoType == NETGEN:
4315 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4316 "libNETGENEngine.so", UseExisting=0)
4318 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4319 "libNETGENEngine.so", UseExisting=0)
4321 elif self.algoType == MEFISTO:
4322 print "Mefisto algo support no multi-parameter hypothesis"
4324 elif self.algoType == NETGEN_2D:
4325 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4326 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4328 elif self.algoType == BLSURF:
4329 self.params = self.Hypothesis("BLSURF_Parameters", [],
4330 "libBLSURFEngine.so", UseExisting=0)
4333 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4338 # Only for algoType == NETGEN
4339 # @ingroup l3_hypos_netgen
4340 def SetMaxSize(self, theSize):
4341 if self.Parameters():
4342 self.params.SetMaxSize(theSize)
4344 ## Sets SecondOrder flag
4346 # Only for algoType == NETGEN
4347 # @ingroup l3_hypos_netgen
4348 def SetSecondOrder(self, theVal):
4349 if self.Parameters():
4350 self.params.SetSecondOrder(theVal)
4352 ## Sets Optimize flag
4354 # Only for algoType == NETGEN
4355 # @ingroup l3_hypos_netgen
4356 def SetOptimize(self, theVal):
4357 if self.Parameters():
4358 self.params.SetOptimize(theVal)
4361 # @param theFineness is:
4362 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4364 # Only for algoType == NETGEN
4365 # @ingroup l3_hypos_netgen
4366 def SetFineness(self, theFineness):
4367 if self.Parameters():
4368 self.params.SetFineness(theFineness)
4372 # Only for algoType == NETGEN
4373 # @ingroup l3_hypos_netgen
4374 def SetGrowthRate(self, theRate):
4375 if self.Parameters():
4376 self.params.SetGrowthRate(theRate)
4378 ## Sets NbSegPerEdge
4380 # Only for algoType == NETGEN
4381 # @ingroup l3_hypos_netgen
4382 def SetNbSegPerEdge(self, theVal):
4383 if self.Parameters():
4384 self.params.SetNbSegPerEdge(theVal)
4386 ## Sets NbSegPerRadius
4388 # Only for algoType == NETGEN
4389 # @ingroup l3_hypos_netgen
4390 def SetNbSegPerRadius(self, theVal):
4391 if self.Parameters():
4392 self.params.SetNbSegPerRadius(theVal)
4394 ## Sets number of segments overriding value set by SetLocalLength()
4396 # Only for algoType == NETGEN
4397 # @ingroup l3_hypos_netgen
4398 def SetNumberOfSegments(self, theVal):
4399 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4401 ## Sets number of segments overriding value set by SetNumberOfSegments()
4403 # Only for algoType == NETGEN
4404 # @ingroup l3_hypos_netgen
4405 def SetLocalLength(self, theVal):
4406 self.Parameters(SIMPLE).SetLocalLength(theVal)
4411 # Public class: Mesh_Quadrangle
4412 # -----------------------------
4414 ## Defines a quadrangle 2D algorithm
4416 # @ingroup l3_algos_basic
4417 class Mesh_Quadrangle(Mesh_Algorithm):
4419 ## Private constructor.
4420 def __init__(self, mesh, geom=0):
4421 Mesh_Algorithm.__init__(self)
4422 self.Create(mesh, geom, "Quadrangle_2D")
4424 ## Defines "QuadranglePreference" hypothesis, forcing construction
4425 # of quadrangles if the number of nodes on the opposite edges is not the same
4426 # while the total number of nodes on edges is even
4428 # @ingroup l3_hypos_additi
4429 def QuadranglePreference(self):
4430 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4431 CompareMethod=self.CompareEqualHyp)
4434 ## Defines "TrianglePreference" hypothesis, forcing construction
4435 # of triangles in the refinement area if the number of nodes
4436 # on the opposite edges is not the same
4438 # @ingroup l3_hypos_additi
4439 def TrianglePreference(self):
4440 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4441 CompareMethod=self.CompareEqualHyp)
4444 # Public class: Mesh_Tetrahedron
4445 # ------------------------------
4447 ## Defines a tetrahedron 3D algorithm
4449 # @ingroup l3_algos_basic
4450 class Mesh_Tetrahedron(Mesh_Algorithm):
4455 ## Private constructor.
4456 def __init__(self, mesh, algoType, geom=0):
4457 Mesh_Algorithm.__init__(self)
4459 if algoType == NETGEN:
4461 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4464 elif algoType == FULL_NETGEN:
4466 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4469 elif algoType == GHS3D:
4471 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4474 elif algoType == GHS3DPRL:
4475 CheckPlugin(GHS3DPRL)
4476 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4479 self.algoType = algoType
4481 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4482 # @param vol for the maximum volume of each tetrahedron
4483 # @param UseExisting if ==true - searches for the existing hypothesis created with
4484 # the same parameters, else (default) - creates a new one
4485 # @ingroup l3_hypos_maxvol
4486 def MaxElementVolume(self, vol, UseExisting=0):
4487 if self.algoType == NETGEN:
4488 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4489 CompareMethod=self.CompareMaxElementVolume)
4490 hyp.SetMaxElementVolume(vol)
4492 elif self.algoType == FULL_NETGEN:
4493 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4496 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4497 def CompareMaxElementVolume(self, hyp, args):
4498 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4500 ## Defines hypothesis having several parameters
4502 # @ingroup l3_hypos_netgen
4503 def Parameters(self, which=SOLE):
4507 if self.algoType == FULL_NETGEN:
4509 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4510 "libNETGENEngine.so", UseExisting=0)
4512 self.params = self.Hypothesis("NETGEN_Parameters", [],
4513 "libNETGENEngine.so", UseExisting=0)
4516 if self.algoType == GHS3D:
4517 self.params = self.Hypothesis("GHS3D_Parameters", [],
4518 "libGHS3DEngine.so", UseExisting=0)
4521 if self.algoType == GHS3DPRL:
4522 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4523 "libGHS3DPRLEngine.so", UseExisting=0)
4526 print "Algo supports no multi-parameter hypothesis"
4530 # Parameter of FULL_NETGEN
4531 # @ingroup l3_hypos_netgen
4532 def SetMaxSize(self, theSize):
4533 self.Parameters().SetMaxSize(theSize)
4535 ## Sets SecondOrder flag
4536 # Parameter of FULL_NETGEN
4537 # @ingroup l3_hypos_netgen
4538 def SetSecondOrder(self, theVal):
4539 self.Parameters().SetSecondOrder(theVal)
4541 ## Sets Optimize flag
4542 # Parameter of FULL_NETGEN
4543 # @ingroup l3_hypos_netgen
4544 def SetOptimize(self, theVal):
4545 self.Parameters().SetOptimize(theVal)
4548 # @param theFineness is:
4549 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4550 # Parameter of FULL_NETGEN
4551 # @ingroup l3_hypos_netgen
4552 def SetFineness(self, theFineness):
4553 self.Parameters().SetFineness(theFineness)
4556 # Parameter of FULL_NETGEN
4557 # @ingroup l3_hypos_netgen
4558 def SetGrowthRate(self, theRate):
4559 self.Parameters().SetGrowthRate(theRate)
4561 ## Sets NbSegPerEdge
4562 # Parameter of FULL_NETGEN
4563 # @ingroup l3_hypos_netgen
4564 def SetNbSegPerEdge(self, theVal):
4565 self.Parameters().SetNbSegPerEdge(theVal)
4567 ## Sets NbSegPerRadius
4568 # Parameter of FULL_NETGEN
4569 # @ingroup l3_hypos_netgen
4570 def SetNbSegPerRadius(self, theVal):
4571 self.Parameters().SetNbSegPerRadius(theVal)
4573 ## Sets number of segments overriding value set by SetLocalLength()
4574 # Only for algoType == NETGEN_FULL
4575 # @ingroup l3_hypos_netgen
4576 def SetNumberOfSegments(self, theVal):
4577 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4579 ## Sets number of segments overriding value set by SetNumberOfSegments()
4580 # Only for algoType == NETGEN_FULL
4581 # @ingroup l3_hypos_netgen
4582 def SetLocalLength(self, theVal):
4583 self.Parameters(SIMPLE).SetLocalLength(theVal)
4585 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4586 # Overrides value set by LengthFromEdges()
4587 # Only for algoType == NETGEN_FULL
4588 # @ingroup l3_hypos_netgen
4589 def MaxElementArea(self, area):
4590 self.Parameters(SIMPLE).SetMaxElementArea(area)
4592 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4593 # Overrides value set by MaxElementArea()
4594 # Only for algoType == NETGEN_FULL
4595 # @ingroup l3_hypos_netgen
4596 def LengthFromEdges(self):
4597 self.Parameters(SIMPLE).LengthFromEdges()
4599 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4600 # Overrides value set by MaxElementVolume()
4601 # Only for algoType == NETGEN_FULL
4602 # @ingroup l3_hypos_netgen
4603 def LengthFromFaces(self):
4604 self.Parameters(SIMPLE).LengthFromFaces()
4606 ## To mesh "holes" in a solid or not. Default is to mesh.
4607 # @ingroup l3_hypos_ghs3dh
4608 def SetToMeshHoles(self, toMesh):
4609 # Parameter of GHS3D
4610 self.Parameters().SetToMeshHoles(toMesh)
4612 ## Set Optimization level:
4613 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4614 # Strong_Optimization.
4615 # Default is Standard_Optimization
4616 # @ingroup l3_hypos_ghs3dh
4617 def SetOptimizationLevel(self, level):
4618 # Parameter of GHS3D
4619 self.Parameters().SetOptimizationLevel(level)
4621 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4622 # @ingroup l3_hypos_ghs3dh
4623 def SetMaximumMemory(self, MB):
4624 # Advanced parameter of GHS3D
4625 self.Parameters().SetMaximumMemory(MB)
4627 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4628 # automatic memory adjustment mode.
4629 # @ingroup l3_hypos_ghs3dh
4630 def SetInitialMemory(self, MB):
4631 # Advanced parameter of GHS3D
4632 self.Parameters().SetInitialMemory(MB)
4634 ## Path to working directory.
4635 # @ingroup l3_hypos_ghs3dh
4636 def SetWorkingDirectory(self, path):
4637 # Advanced parameter of GHS3D
4638 self.Parameters().SetWorkingDirectory(path)
4640 ## To keep working files or remove them. Log file remains in case of errors anyway.
4641 # @ingroup l3_hypos_ghs3dh
4642 def SetKeepFiles(self, toKeep):
4643 # Advanced parameter of GHS3D and GHS3DPRL
4644 self.Parameters().SetKeepFiles(toKeep)
4646 ## To set verbose level [0-10]. <ul>
4647 #<li> 0 - no standard output,
4648 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4649 # indicates when the final mesh is being saved. In addition the software
4650 # gives indication regarding the CPU time.
4651 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4652 # histogram of the skin mesh, quality statistics histogram together with
4653 # the characteristics of the final mesh.</ul>
4654 # @ingroup l3_hypos_ghs3dh
4655 def SetVerboseLevel(self, level):
4656 # Advanced parameter of GHS3D
4657 self.Parameters().SetVerboseLevel(level)
4659 ## To create new nodes.
4660 # @ingroup l3_hypos_ghs3dh
4661 def SetToCreateNewNodes(self, toCreate):
4662 # Advanced parameter of GHS3D
4663 self.Parameters().SetToCreateNewNodes(toCreate)
4665 ## To use boundary recovery version which tries to create mesh on a very poor
4666 # quality surface mesh.
4667 # @ingroup l3_hypos_ghs3dh
4668 def SetToUseBoundaryRecoveryVersion(self, toUse):
4669 # Advanced parameter of GHS3D
4670 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4672 ## Sets command line option as text.
4673 # @ingroup l3_hypos_ghs3dh
4674 def SetTextOption(self, option):
4675 # Advanced parameter of GHS3D
4676 self.Parameters().SetTextOption(option)
4678 ## Sets MED files name and path.
4679 def SetMEDName(self, value):
4680 self.Parameters().SetMEDName(value)
4682 ## Sets the number of partition of the initial mesh
4683 def SetNbPart(self, value):
4684 self.Parameters().SetNbPart(value)
4686 ## When big mesh, start tepal in background
4687 def SetBackground(self, value):
4688 self.Parameters().SetBackground(value)
4690 # Public class: Mesh_Hexahedron
4691 # ------------------------------
4693 ## Defines a hexahedron 3D algorithm
4695 # @ingroup l3_algos_basic
4696 class Mesh_Hexahedron(Mesh_Algorithm):
4701 ## Private constructor.
4702 def __init__(self, mesh, algoType=Hexa, geom=0):
4703 Mesh_Algorithm.__init__(self)
4705 self.algoType = algoType
4707 if algoType == Hexa:
4708 self.Create(mesh, geom, "Hexa_3D")
4711 elif algoType == Hexotic:
4712 CheckPlugin(Hexotic)
4713 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4716 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4717 # @ingroup l3_hypos_hexotic
4718 def MinMaxQuad(self, min=3, max=8, quad=True):
4719 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4721 self.params.SetHexesMinLevel(min)
4722 self.params.SetHexesMaxLevel(max)
4723 self.params.SetHexoticQuadrangles(quad)
4726 # Deprecated, only for compatibility!
4727 # Public class: Mesh_Netgen
4728 # ------------------------------
4730 ## Defines a NETGEN-based 2D or 3D algorithm
4731 # that needs no discrete boundary (i.e. independent)
4733 # This class is deprecated, only for compatibility!
4736 # @ingroup l3_algos_basic
4737 class Mesh_Netgen(Mesh_Algorithm):
4741 ## Private constructor.
4742 def __init__(self, mesh, is3D, geom=0):
4743 Mesh_Algorithm.__init__(self)
4749 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4753 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4756 ## Defines the hypothesis containing parameters of the algorithm
4757 def Parameters(self):
4759 hyp = self.Hypothesis("NETGEN_Parameters", [],
4760 "libNETGENEngine.so", UseExisting=0)
4762 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4763 "libNETGENEngine.so", UseExisting=0)
4766 # Public class: Mesh_Projection1D
4767 # ------------------------------
4769 ## Defines a projection 1D algorithm
4770 # @ingroup l3_algos_proj
4772 class Mesh_Projection1D(Mesh_Algorithm):
4774 ## Private constructor.
4775 def __init__(self, mesh, geom=0):
4776 Mesh_Algorithm.__init__(self)
4777 self.Create(mesh, geom, "Projection_1D")
4779 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4780 # a mesh pattern is taken, and, optionally, the association of vertices
4781 # between the source edge and a target edge (to which a hypothesis is assigned)
4782 # @param edge from which nodes distribution is taken
4783 # @param mesh from which nodes distribution is taken (optional)
4784 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4785 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4786 # to associate with \a srcV (optional)
4787 # @param UseExisting if ==true - searches for the existing hypothesis created with
4788 # the same parameters, else (default) - creates a new one
4789 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4790 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4792 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4793 hyp.SetSourceEdge( edge )
4794 if not mesh is None and isinstance(mesh, Mesh):
4795 mesh = mesh.GetMesh()
4796 hyp.SetSourceMesh( mesh )
4797 hyp.SetVertexAssociation( srcV, tgtV )
4800 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4801 #def CompareSourceEdge(self, hyp, args):
4802 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4806 # Public class: Mesh_Projection2D
4807 # ------------------------------
4809 ## Defines a projection 2D algorithm
4810 # @ingroup l3_algos_proj
4812 class Mesh_Projection2D(Mesh_Algorithm):
4814 ## Private constructor.
4815 def __init__(self, mesh, geom=0):
4816 Mesh_Algorithm.__init__(self)
4817 self.Create(mesh, geom, "Projection_2D")
4819 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4820 # a mesh pattern is taken, and, optionally, the association of vertices
4821 # between the source face and the target face (to which a hypothesis is assigned)
4822 # @param face from which the mesh pattern is taken
4823 # @param mesh from which the mesh pattern is taken (optional)
4824 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4825 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4826 # to associate with \a srcV1 (optional)
4827 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4828 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4829 # to associate with \a srcV2 (optional)
4830 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4831 # the same parameters, else (default) - forces the creation a new one
4833 # Note: all association vertices must belong to one edge of a face
4834 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4835 srcV2=None, tgtV2=None, UseExisting=0):
4836 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4838 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4839 hyp.SetSourceFace( face )
4840 if not mesh is None and isinstance(mesh, Mesh):
4841 mesh = mesh.GetMesh()
4842 hyp.SetSourceMesh( mesh )
4843 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4846 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4847 #def CompareSourceFace(self, hyp, args):
4848 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4851 # Public class: Mesh_Projection3D
4852 # ------------------------------
4854 ## Defines a projection 3D algorithm
4855 # @ingroup l3_algos_proj
4857 class Mesh_Projection3D(Mesh_Algorithm):
4859 ## Private constructor.
4860 def __init__(self, mesh, geom=0):
4861 Mesh_Algorithm.__init__(self)
4862 self.Create(mesh, geom, "Projection_3D")
4864 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4865 # the mesh pattern is taken, and, optionally, the association of vertices
4866 # between the source and the target solid (to which a hipothesis is assigned)
4867 # @param solid from where the mesh pattern is taken
4868 # @param mesh from where the mesh pattern is taken (optional)
4869 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4870 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4871 # to associate with \a srcV1 (optional)
4872 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4873 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4874 # to associate with \a srcV2 (optional)
4875 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4876 # the same parameters, else (default) - creates a new one
4878 # Note: association vertices must belong to one edge of a solid
4879 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4880 srcV2=0, tgtV2=0, UseExisting=0):
4881 hyp = self.Hypothesis("ProjectionSource3D",
4882 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4884 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4885 hyp.SetSource3DShape( solid )
4886 if not mesh is None and isinstance(mesh, Mesh):
4887 mesh = mesh.GetMesh()
4888 hyp.SetSourceMesh( mesh )
4889 if srcV1 and srcV2 and tgtV1 and tgtV2:
4890 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4891 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4894 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4895 #def CompareSourceShape3D(self, hyp, args):
4896 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4900 # Public class: Mesh_Prism
4901 # ------------------------
4903 ## Defines a 3D extrusion algorithm
4904 # @ingroup l3_algos_3dextr
4906 class Mesh_Prism3D(Mesh_Algorithm):
4908 ## Private constructor.
4909 def __init__(self, mesh, geom=0):
4910 Mesh_Algorithm.__init__(self)
4911 self.Create(mesh, geom, "Prism_3D")
4913 # Public class: Mesh_RadialPrism
4914 # -------------------------------
4916 ## Defines a Radial Prism 3D algorithm
4917 # @ingroup l3_algos_radialp
4919 class Mesh_RadialPrism3D(Mesh_Algorithm):
4921 ## Private constructor.
4922 def __init__(self, mesh, geom=0):
4923 Mesh_Algorithm.__init__(self)
4924 self.Create(mesh, geom, "RadialPrism_3D")
4926 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4927 self.nbLayers = None
4929 ## Return 3D hypothesis holding the 1D one
4930 def Get3DHypothesis(self):
4931 return self.distribHyp
4933 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4934 # hypothesis. Returns the created hypothesis
4935 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4936 #print "OwnHypothesis",hypType
4937 if not self.nbLayers is None:
4938 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4939 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4940 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4941 self.mesh.smeshpyD.SetCurrentStudy( None )
4942 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4943 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4944 self.distribHyp.SetLayerDistribution( hyp )
4947 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4948 # prisms to build between the inner and outer shells
4949 # @param n number of layers
4950 # @param UseExisting if ==true - searches for the existing hypothesis created with
4951 # the same parameters, else (default) - creates a new one
4952 def NumberOfLayers(self, n, UseExisting=0):
4953 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4954 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4955 CompareMethod=self.CompareNumberOfLayers)
4956 self.nbLayers.SetNumberOfLayers( n )
4957 return self.nbLayers
4959 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4960 def CompareNumberOfLayers(self, hyp, args):
4961 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4963 ## Defines "LocalLength" hypothesis, specifying the segment length
4964 # to build between the inner and the outer shells
4965 # @param l the length of segments
4966 # @param p the precision of rounding
4967 def LocalLength(self, l, p=1e-07):
4968 hyp = self.OwnHypothesis("LocalLength", [l,p])
4973 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4974 # prisms to build between the inner and the outer shells.
4975 # @param n the number of layers
4976 # @param s the scale factor (optional)
4977 def NumberOfSegments(self, n, s=[]):
4979 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4981 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4982 hyp.SetDistrType( 1 )
4983 hyp.SetScaleFactor(s)
4984 hyp.SetNumberOfSegments(n)
4987 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4988 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4989 # @param start the length of the first segment
4990 # @param end the length of the last segment
4991 def Arithmetic1D(self, start, end ):
4992 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4993 hyp.SetLength(start, 1)
4994 hyp.SetLength(end , 0)
4997 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4998 # to build between the inner and the outer shells as geometric length increasing
4999 # @param start for the length of the first segment
5000 # @param end for the length of the last segment
5001 def StartEndLength(self, start, end):
5002 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5003 hyp.SetLength(start, 1)
5004 hyp.SetLength(end , 0)
5007 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5008 # to build between the inner and outer shells
5009 # @param fineness defines the quality of the mesh within the range [0-1]
5010 def AutomaticLength(self, fineness=0):
5011 hyp = self.OwnHypothesis("AutomaticLength")
5012 hyp.SetFineness( fineness )
5015 # Public class: Mesh_RadialQuadrangle1D2D
5016 # -------------------------------
5018 ## Defines a Radial Quadrangle 1D2D algorithm
5019 # @ingroup l2_algos_radialq
5021 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5023 ## Private constructor.
5024 def __init__(self, mesh, geom=0):
5025 Mesh_Algorithm.__init__(self)
5026 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5028 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5029 self.nbLayers = None
5031 ## Return 2D hypothesis holding the 1D one
5032 def Get2DHypothesis(self):
5033 return self.distribHyp
5035 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5036 # hypothesis. Returns the created hypothesis
5037 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5038 #print "OwnHypothesis",hypType
5040 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5041 if self.distribHyp is None:
5042 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5044 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5045 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5046 self.mesh.smeshpyD.SetCurrentStudy( None )
5047 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5048 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5049 self.distribHyp.SetLayerDistribution( hyp )
5052 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5053 # @param n number of layers
5054 # @param UseExisting if ==true - searches for the existing hypothesis created with
5055 # the same parameters, else (default) - creates a new one
5056 def NumberOfLayers(self, n, UseExisting=0):
5058 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5059 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5060 CompareMethod=self.CompareNumberOfLayers)
5061 self.nbLayers.SetNumberOfLayers( n )
5062 return self.nbLayers
5064 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5065 def CompareNumberOfLayers(self, hyp, args):
5066 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5068 ## Defines "LocalLength" hypothesis, specifying the segment length
5069 # @param l the length of segments
5070 # @param p the precision of rounding
5071 def LocalLength(self, l, p=1e-07):
5072 hyp = self.OwnHypothesis("LocalLength", [l,p])
5077 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5078 # @param n the number of layers
5079 # @param s the scale factor (optional)
5080 def NumberOfSegments(self, n, s=[]):
5082 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5084 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5085 hyp.SetDistrType( 1 )
5086 hyp.SetScaleFactor(s)
5087 hyp.SetNumberOfSegments(n)
5090 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5091 # with a length that changes in arithmetic progression
5092 # @param start the length of the first segment
5093 # @param end the length of the last segment
5094 def Arithmetic1D(self, start, end ):
5095 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5096 hyp.SetLength(start, 1)
5097 hyp.SetLength(end , 0)
5100 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5101 # as geometric length increasing
5102 # @param start for the length of the first segment
5103 # @param end for the length of the last segment
5104 def StartEndLength(self, start, end):
5105 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5106 hyp.SetLength(start, 1)
5107 hyp.SetLength(end , 0)
5110 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5111 # @param fineness defines the quality of the mesh within the range [0-1]
5112 def AutomaticLength(self, fineness=0):
5113 hyp = self.OwnHypothesis("AutomaticLength")
5114 hyp.SetFineness( fineness )
5118 # Private class: Mesh_UseExisting
5119 # -------------------------------
5120 class Mesh_UseExisting(Mesh_Algorithm):
5122 def __init__(self, dim, mesh, geom=0):
5124 self.Create(mesh, geom, "UseExisting_1D")
5126 self.Create(mesh, geom, "UseExisting_2D")
5129 import salome_notebook
5130 notebook = salome_notebook.notebook
5132 ##Return values of the notebook variables
5133 def ParseParameters(last, nbParams,nbParam, value):
5137 listSize = len(last)
5138 for n in range(0,nbParams):
5140 if counter < listSize:
5141 strResult = strResult + last[counter]
5143 strResult = strResult + ""
5145 if isinstance(value, str):
5146 if notebook.isVariable(value):
5147 result = notebook.get(value)
5148 strResult=strResult+value
5150 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5152 strResult=strResult+str(value)
5154 if nbParams - 1 != counter:
5155 strResult=strResult+var_separator #":"
5157 return result, strResult
5159 #Wrapper class for StdMeshers_LocalLength hypothesis
5160 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5162 ## Set Length parameter value
5163 # @param length numerical value or name of variable from notebook
5164 def SetLength(self, length):
5165 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5166 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5167 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5169 ## Set Precision parameter value
5170 # @param precision numerical value or name of variable from notebook
5171 def SetPrecision(self, precision):
5172 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5173 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5174 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5176 #Registering the new proxy for LocalLength
5177 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5180 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5181 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5183 def SetLayerDistribution(self, hypo):
5184 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5185 hypo.ClearParameters();
5186 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5188 #Registering the new proxy for LayerDistribution
5189 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5191 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5192 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5194 ## Set Length parameter value
5195 # @param length numerical value or name of variable from notebook
5196 def SetLength(self, length):
5197 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5198 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5199 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5201 #Registering the new proxy for SegmentLengthAroundVertex
5202 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5205 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5206 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5208 ## Set Length parameter value
5209 # @param length numerical value or name of variable from notebook
5210 # @param isStart true is length is Start Length, otherwise false
5211 def SetLength(self, length, isStart):
5215 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5216 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5217 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5219 #Registering the new proxy for Arithmetic1D
5220 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5222 #Wrapper class for StdMeshers_Deflection1D hypothesis
5223 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5225 ## Set Deflection parameter value
5226 # @param deflection numerical value or name of variable from notebook
5227 def SetDeflection(self, deflection):
5228 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5229 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5230 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5232 #Registering the new proxy for Deflection1D
5233 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5235 #Wrapper class for StdMeshers_StartEndLength hypothesis
5236 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5238 ## Set Length parameter value
5239 # @param length numerical value or name of variable from notebook
5240 # @param isStart true is length is Start Length, otherwise false
5241 def SetLength(self, length, isStart):
5245 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5246 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5247 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5249 #Registering the new proxy for StartEndLength
5250 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5252 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5253 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5255 ## Set Max Element Area parameter value
5256 # @param area numerical value or name of variable from notebook
5257 def SetMaxElementArea(self, area):
5258 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5259 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5260 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5262 #Registering the new proxy for MaxElementArea
5263 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5266 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5267 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5269 ## Set Max Element Volume parameter value
5270 # @param volume numerical value or name of variable from notebook
5271 def SetMaxElementVolume(self, volume):
5272 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5273 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5274 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5276 #Registering the new proxy for MaxElementVolume
5277 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5280 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5281 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5283 ## Set Number Of Layers parameter value
5284 # @param nbLayers numerical value or name of variable from notebook
5285 def SetNumberOfLayers(self, nbLayers):
5286 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5287 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5288 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5290 #Registering the new proxy for NumberOfLayers
5291 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5293 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5294 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5296 ## Set Number Of Segments parameter value
5297 # @param nbSeg numerical value or name of variable from notebook
5298 def SetNumberOfSegments(self, nbSeg):
5299 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5300 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5301 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5302 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5304 ## Set Scale Factor parameter value
5305 # @param factor numerical value or name of variable from notebook
5306 def SetScaleFactor(self, factor):
5307 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5308 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5309 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5311 #Registering the new proxy for NumberOfSegments
5312 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5314 if not noNETGENPlugin:
5315 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5316 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5318 ## Set Max Size parameter value
5319 # @param maxsize numerical value or name of variable from notebook
5320 def SetMaxSize(self, maxsize):
5321 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5322 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5323 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5324 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5326 ## Set Growth Rate parameter value
5327 # @param value numerical value or name of variable from notebook
5328 def SetGrowthRate(self, value):
5329 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5330 value, parameters = ParseParameters(lastParameters,4,2,value)
5331 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5332 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5334 ## Set Number of Segments per Edge parameter value
5335 # @param value numerical value or name of variable from notebook
5336 def SetNbSegPerEdge(self, value):
5337 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5338 value, parameters = ParseParameters(lastParameters,4,3,value)
5339 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5340 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5342 ## Set Number of Segments per Radius parameter value
5343 # @param value numerical value or name of variable from notebook
5344 def SetNbSegPerRadius(self, value):
5345 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5346 value, parameters = ParseParameters(lastParameters,4,4,value)
5347 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5348 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5350 #Registering the new proxy for NETGENPlugin_Hypothesis
5351 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5354 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5355 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5358 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5359 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5361 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5362 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5364 ## Set Number of Segments parameter value
5365 # @param nbSeg numerical value or name of variable from notebook
5366 def SetNumberOfSegments(self, nbSeg):
5367 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5368 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5369 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5370 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5372 ## Set Local Length parameter value
5373 # @param length numerical value or name of variable from notebook
5374 def SetLocalLength(self, length):
5375 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5376 length, parameters = ParseParameters(lastParameters,2,1,length)
5377 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5378 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5380 ## Set Max Element Area parameter value
5381 # @param area numerical value or name of variable from notebook
5382 def SetMaxElementArea(self, area):
5383 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5384 area, parameters = ParseParameters(lastParameters,2,2,area)
5385 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5386 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5388 def LengthFromEdges(self):
5389 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5391 value, parameters = ParseParameters(lastParameters,2,2,value)
5392 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5393 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5395 #Registering the new proxy for NETGEN_SimpleParameters_2D
5396 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5399 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5400 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5401 ## Set Max Element Volume parameter value
5402 # @param volume numerical value or name of variable from notebook
5403 def SetMaxElementVolume(self, volume):
5404 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5405 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5406 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5407 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5409 def LengthFromFaces(self):
5410 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5412 value, parameters = ParseParameters(lastParameters,3,3,value)
5413 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5414 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5416 #Registering the new proxy for NETGEN_SimpleParameters_3D
5417 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5419 pass # if not noNETGENPlugin:
5421 class Pattern(SMESH._objref_SMESH_Pattern):
5423 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5425 if isinstance(theNodeIndexOnKeyPoint1,str):
5427 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5429 theNodeIndexOnKeyPoint1 -= 1
5430 theMesh.SetParameters(Parameters)
5431 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5433 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5436 if isinstance(theNode000Index,str):
5438 if isinstance(theNode001Index,str):
5440 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5442 theNode000Index -= 1
5444 theNode001Index -= 1
5445 theMesh.SetParameters(Parameters)
5446 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5448 #Registering the new proxy for Pattern
5449 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)