1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 # Author : Francis KLOSS, OCC
30 ## @defgroup l1_auxiliary Auxiliary methods and structures
31 ## @defgroup l1_creating Creating meshes
33 ## @defgroup l2_impexp Importing and exporting meshes
34 ## @defgroup l2_construct Constructing meshes
35 ## @defgroup l2_algorithms Defining Algorithms
37 ## @defgroup l3_algos_basic Basic meshing algorithms
38 ## @defgroup l3_algos_proj Projection Algorithms
39 ## @defgroup l3_algos_radialp Radial Prism
40 ## @defgroup l3_algos_segmarv Segments around Vertex
41 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
44 ## @defgroup l2_hypotheses Defining hypotheses
46 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
47 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
48 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
49 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
50 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
51 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
52 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
53 ## @defgroup l3_hypos_additi Additional Hypotheses
56 ## @defgroup l2_submeshes Constructing submeshes
57 ## @defgroup l2_compounds Building Compounds
58 ## @defgroup l2_editing Editing Meshes
61 ## @defgroup l1_meshinfo Mesh Information
62 ## @defgroup l1_controls Quality controls and Filtering
63 ## @defgroup l1_grouping Grouping elements
65 ## @defgroup l2_grps_create Creating groups
66 ## @defgroup l2_grps_edit Editing groups
67 ## @defgroup l2_grps_operon Using operations on groups
68 ## @defgroup l2_grps_delete Deleting Groups
71 ## @defgroup l1_modifying Modifying meshes
73 ## @defgroup l2_modif_add Adding nodes and elements
74 ## @defgroup l2_modif_del Removing nodes and elements
75 ## @defgroup l2_modif_edit Modifying nodes and elements
76 ## @defgroup l2_modif_renumber Renumbering nodes and elements
77 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
78 ## @defgroup l2_modif_movenode Moving nodes
79 ## @defgroup l2_modif_throughp Mesh through point
80 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
81 ## @defgroup l2_modif_unitetri Uniting triangles
82 ## @defgroup l2_modif_changori Changing orientation of elements
83 ## @defgroup l2_modif_cutquadr Cutting quadrangles
84 ## @defgroup l2_modif_smooth Smoothing
85 ## @defgroup l2_modif_extrurev Extrusion and Revolution
86 ## @defgroup l2_modif_patterns Pattern mapping
87 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
94 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 # import GHS3DPlugin module if possible
118 # import GHS3DPRLPlugin module if possible
121 import GHS3DPRLPlugin
126 # import HexoticPlugin module if possible
134 # import BLSURFPlugin module if possible
142 ## @addtogroup l1_auxiliary
145 # Types of algorithms
158 NETGEN_1D2D3D = FULL_NETGEN
159 NETGEN_FULL = FULL_NETGEN
167 # MirrorType enumeration
168 POINT = SMESH_MeshEditor.POINT
169 AXIS = SMESH_MeshEditor.AXIS
170 PLANE = SMESH_MeshEditor.PLANE
172 # Smooth_Method enumeration
173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
176 # Fineness enumeration (for NETGEN)
184 # Optimization level of GHS3D
186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
187 # V4.1 (partialy redefines V3.1). Issue 0020574
188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
190 # Topology treatment way of BLSURF
191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
193 # Element size flag of BLSURF
194 DefaultSize, DefaultGeom, Custom = 0,0,1
196 PrecisionConfusion = 1e-07
198 # TopAbs_State enumeration
199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
202 ## Converts an angle from degrees to radians
203 def DegreesToRadians(AngleInDegrees):
205 return AngleInDegrees * pi / 180.0
207 # Salome notebook variable separator
210 # Parametrized substitute for PointStruct
211 class PointStructStr:
220 def __init__(self, xStr, yStr, zStr):
224 if isinstance(xStr, str) and notebook.isVariable(xStr):
225 self.x = notebook.get(xStr)
228 if isinstance(yStr, str) and notebook.isVariable(yStr):
229 self.y = notebook.get(yStr)
232 if isinstance(zStr, str) and notebook.isVariable(zStr):
233 self.z = notebook.get(zStr)
237 # Parametrized substitute for PointStruct (with 6 parameters)
238 class PointStructStr6:
253 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
260 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
261 self.x1 = notebook.get(x1Str)
264 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
265 self.x2 = notebook.get(x2Str)
268 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
269 self.y1 = notebook.get(y1Str)
272 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
273 self.y2 = notebook.get(y2Str)
276 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
277 self.z1 = notebook.get(z1Str)
280 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
281 self.z2 = notebook.get(z2Str)
285 # Parametrized substitute for AxisStruct
301 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
308 if isinstance(xStr, str) and notebook.isVariable(xStr):
309 self.x = notebook.get(xStr)
312 if isinstance(yStr, str) and notebook.isVariable(yStr):
313 self.y = notebook.get(yStr)
316 if isinstance(zStr, str) and notebook.isVariable(zStr):
317 self.z = notebook.get(zStr)
320 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
321 self.dx = notebook.get(dxStr)
324 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
325 self.dy = notebook.get(dyStr)
328 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
329 self.dz = notebook.get(dzStr)
333 # Parametrized substitute for DirStruct
336 def __init__(self, pointStruct):
337 self.pointStruct = pointStruct
339 # Returns list of variable values from salome notebook
340 def ParsePointStruct(Point):
341 Parameters = 2*var_separator
342 if isinstance(Point, PointStructStr):
343 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
344 Point = PointStruct(Point.x, Point.y, Point.z)
345 return Point, Parameters
347 # Returns list of variable values from salome notebook
348 def ParseDirStruct(Dir):
349 Parameters = 2*var_separator
350 if isinstance(Dir, DirStructStr):
351 pntStr = Dir.pointStruct
352 if isinstance(pntStr, PointStructStr6):
353 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
354 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
355 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
356 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
358 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
359 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
360 Dir = DirStruct(Point)
361 return Dir, Parameters
363 # Returns list of variable values from salome notebook
364 def ParseAxisStruct(Axis):
365 Parameters = 5*var_separator
366 if isinstance(Axis, AxisStructStr):
367 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
368 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
369 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
370 return Axis, Parameters
372 ## Return list of variable values from salome notebook
373 def ParseAngles(list):
376 for parameter in list:
377 if isinstance(parameter,str) and notebook.isVariable(parameter):
378 Result.append(DegreesToRadians(notebook.get(parameter)))
381 Result.append(parameter)
384 Parameters = Parameters + str(parameter)
385 Parameters = Parameters + var_separator
387 Parameters = Parameters[:len(Parameters)-1]
388 return Result, Parameters
390 def IsEqual(val1, val2, tol=PrecisionConfusion):
391 if abs(val1 - val2) < tol:
401 if isinstance(obj, SALOMEDS._objref_SObject):
404 ior = salome.orb.object_to_string(obj)
407 studies = salome.myStudyManager.GetOpenStudies()
408 for sname in studies:
409 s = salome.myStudyManager.GetStudyByName(sname)
411 sobj = s.FindObjectIOR(ior)
412 if not sobj: continue
413 return sobj.GetName()
414 if hasattr(obj, "GetName"):
415 # unknown CORBA object, having GetName() method
418 # unknown CORBA object, no GetName() method
421 if hasattr(obj, "GetName"):
422 # unknown non-CORBA object, having GetName() method
425 raise RuntimeError, "Null or invalid object"
427 ## Prints error message if a hypothesis was not assigned.
428 def TreatHypoStatus(status, hypName, geomName, isAlgo):
430 hypType = "algorithm"
432 hypType = "hypothesis"
434 if status == HYP_UNKNOWN_FATAL :
435 reason = "for unknown reason"
436 elif status == HYP_INCOMPATIBLE :
437 reason = "this hypothesis mismatches the algorithm"
438 elif status == HYP_NOTCONFORM :
439 reason = "a non-conform mesh would be built"
440 elif status == HYP_ALREADY_EXIST :
441 reason = hypType + " of the same dimension is already assigned to this shape"
442 elif status == HYP_BAD_DIM :
443 reason = hypType + " mismatches the shape"
444 elif status == HYP_CONCURENT :
445 reason = "there are concurrent hypotheses on sub-shapes"
446 elif status == HYP_BAD_SUBSHAPE :
447 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
448 elif status == HYP_BAD_GEOMETRY:
449 reason = "geometry mismatches the expectation of the algorithm"
450 elif status == HYP_HIDDEN_ALGO:
451 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
452 elif status == HYP_HIDING_ALGO:
453 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
454 elif status == HYP_NEED_SHAPE:
455 reason = "Algorithm can't work without shape"
458 hypName = '"' + hypName + '"'
459 geomName= '"' + geomName+ '"'
460 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
461 print hypName, "was assigned to", geomName,"but", reason
462 elif not geomName == '""':
463 print hypName, "was not assigned to",geomName,":", reason
465 print hypName, "was not assigned:", reason
468 ## Check meshing plugin availability
469 def CheckPlugin(plugin):
470 if plugin == NETGEN and noNETGENPlugin:
471 print "Warning: NETGENPlugin module unavailable"
473 elif plugin == GHS3D and noGHS3DPlugin:
474 print "Warning: GHS3DPlugin module unavailable"
476 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
477 print "Warning: GHS3DPRLPlugin module unavailable"
479 elif plugin == Hexotic and noHexoticPlugin:
480 print "Warning: HexoticPlugin module unavailable"
482 elif plugin == BLSURF and noBLSURFPlugin:
483 print "Warning: BLSURFPlugin module unavailable"
487 # end of l1_auxiliary
490 # All methods of this class are accessible directly from the smesh.py package.
491 class smeshDC(SMESH._objref_SMESH_Gen):
493 ## Sets the current study and Geometry component
494 # @ingroup l1_auxiliary
495 def init_smesh(self,theStudy,geompyD):
496 self.SetCurrentStudy(theStudy,geompyD)
498 ## Creates an empty Mesh. This mesh can have an underlying geometry.
499 # @param obj the Geometrical object on which the mesh is built. If not defined,
500 # the mesh will have no underlying geometry.
501 # @param name the name for the new mesh.
502 # @return an instance of Mesh class.
503 # @ingroup l2_construct
504 def Mesh(self, obj=0, name=0):
505 if isinstance(obj,str):
507 return Mesh(self,self.geompyD,obj,name)
509 ## Returns a long value from enumeration
510 # Should be used for SMESH.FunctorType enumeration
511 # @ingroup l1_controls
512 def EnumToLong(self,theItem):
515 ## Gets PointStruct from vertex
516 # @param theVertex a GEOM object(vertex)
517 # @return SMESH.PointStruct
518 # @ingroup l1_auxiliary
519 def GetPointStruct(self,theVertex):
520 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
521 return PointStruct(x,y,z)
523 ## Gets DirStruct from vector
524 # @param theVector a GEOM object(vector)
525 # @return SMESH.DirStruct
526 # @ingroup l1_auxiliary
527 def GetDirStruct(self,theVector):
528 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
529 if(len(vertices) != 2):
530 print "Error: vector object is incorrect."
532 p1 = self.geompyD.PointCoordinates(vertices[0])
533 p2 = self.geompyD.PointCoordinates(vertices[1])
534 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
535 dirst = DirStruct(pnt)
538 ## Makes DirStruct from a triplet
539 # @param x,y,z vector components
540 # @return SMESH.DirStruct
541 # @ingroup l1_auxiliary
542 def MakeDirStruct(self,x,y,z):
543 pnt = PointStruct(x,y,z)
544 return DirStruct(pnt)
546 ## Get AxisStruct from object
547 # @param theObj a GEOM object (line or plane)
548 # @return SMESH.AxisStruct
549 # @ingroup l1_auxiliary
550 def GetAxisStruct(self,theObj):
551 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
553 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
554 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
555 vertex1 = self.geompyD.PointCoordinates(vertex1)
556 vertex2 = self.geompyD.PointCoordinates(vertex2)
557 vertex3 = self.geompyD.PointCoordinates(vertex3)
558 vertex4 = self.geompyD.PointCoordinates(vertex4)
559 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
560 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
561 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] ]
562 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
564 elif len(edges) == 1:
565 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
566 p1 = self.geompyD.PointCoordinates( vertex1 )
567 p2 = self.geompyD.PointCoordinates( vertex2 )
568 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
572 # From SMESH_Gen interface:
573 # ------------------------
575 ## Sets the given name to the object
576 # @param obj the object to rename
577 # @param name a new object name
578 # @ingroup l1_auxiliary
579 def SetName(self, obj, name):
580 if isinstance( obj, Mesh ):
582 elif isinstance( obj, Mesh_Algorithm ):
583 obj = obj.GetAlgorithm()
584 ior = salome.orb.object_to_string(obj)
585 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
587 ## Sets the current mode
588 # @ingroup l1_auxiliary
589 def SetEmbeddedMode( self,theMode ):
590 #self.SetEmbeddedMode(theMode)
591 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
593 ## Gets the current mode
594 # @ingroup l1_auxiliary
595 def IsEmbeddedMode(self):
596 #return self.IsEmbeddedMode()
597 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
599 ## Sets the current study
600 # @ingroup l1_auxiliary
601 def SetCurrentStudy( self, theStudy, geompyD = None ):
602 #self.SetCurrentStudy(theStudy)
605 geompyD = geompy.geom
608 self.SetGeomEngine(geompyD)
609 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
611 ## Gets the current study
612 # @ingroup l1_auxiliary
613 def GetCurrentStudy(self):
614 #return self.GetCurrentStudy()
615 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
617 ## Creates a Mesh object importing data from the given UNV file
618 # @return an instance of Mesh class
620 def CreateMeshesFromUNV( self,theFileName ):
621 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
622 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
625 ## Creates a Mesh object(s) importing data from the given MED file
626 # @return a list of Mesh class instances
628 def CreateMeshesFromMED( self,theFileName ):
629 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
631 for iMesh in range(len(aSmeshMeshes)) :
632 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
633 aMeshes.append(aMesh)
634 return aMeshes, aStatus
636 ## Creates a Mesh object importing data from the given STL file
637 # @return an instance of Mesh class
639 def CreateMeshesFromSTL( self, theFileName ):
640 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
641 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
644 ## From SMESH_Gen interface
645 # @return the list of integer values
646 # @ingroup l1_auxiliary
647 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
648 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
650 ## From SMESH_Gen interface. Creates a pattern
651 # @return an instance of SMESH_Pattern
653 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
654 # @ingroup l2_modif_patterns
655 def GetPattern(self):
656 return SMESH._objref_SMESH_Gen.GetPattern(self)
658 ## Sets number of segments per diagonal of boundary box of geometry by which
659 # default segment length of appropriate 1D hypotheses is defined.
660 # Default value is 10
661 # @ingroup l1_auxiliary
662 def SetBoundaryBoxSegmentation(self, nbSegments):
663 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
665 ## Concatenate the given meshes into one mesh.
666 # @return an instance of Mesh class
667 # @param meshes the meshes to combine into one mesh
668 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
669 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
670 # @param mergeTolerance tolerance for merging nodes
671 # @param allGroups forces creation of groups of all elements
672 def Concatenate( self, meshes, uniteIdenticalGroups,
673 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
674 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
676 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
677 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
679 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
680 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
681 aSmeshMesh.SetParameters(Parameters)
682 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
685 # Filtering. Auxiliary functions:
686 # ------------------------------
688 ## Creates an empty criterion
689 # @return SMESH.Filter.Criterion
690 # @ingroup l1_controls
691 def GetEmptyCriterion(self):
692 Type = self.EnumToLong(FT_Undefined)
693 Compare = self.EnumToLong(FT_Undefined)
697 UnaryOp = self.EnumToLong(FT_Undefined)
698 BinaryOp = self.EnumToLong(FT_Undefined)
701 Precision = -1 ##@1e-07
702 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
703 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
705 ## Creates a criterion by the given parameters
706 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
707 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
708 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
709 # @param Treshold the threshold value (range of ids as string, shape, numeric)
710 # @param UnaryOp FT_LogicalNOT or FT_Undefined
711 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
712 # FT_Undefined (must be for the last criterion of all criteria)
713 # @return SMESH.Filter.Criterion
714 # @ingroup l1_controls
715 def GetCriterion(self,elementType,
717 Compare = FT_EqualTo,
719 UnaryOp=FT_Undefined,
720 BinaryOp=FT_Undefined):
721 aCriterion = self.GetEmptyCriterion()
722 aCriterion.TypeOfElement = elementType
723 aCriterion.Type = self.EnumToLong(CritType)
727 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
728 aCriterion.Compare = self.EnumToLong(Compare)
729 elif Compare == "=" or Compare == "==":
730 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
732 aCriterion.Compare = self.EnumToLong(FT_LessThan)
734 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
736 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
739 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
740 FT_BelongToCylinder, FT_LyingOnGeom]:
741 # Checks the treshold
742 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
743 aCriterion.ThresholdStr = GetName(aTreshold)
744 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
746 print "Error: The treshold should be a shape."
748 elif CritType == FT_RangeOfIds:
749 # Checks the treshold
750 if isinstance(aTreshold, str):
751 aCriterion.ThresholdStr = aTreshold
753 print "Error: The treshold should be a string."
755 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
756 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
757 # At this point the treshold is unnecessary
758 if aTreshold == FT_LogicalNOT:
759 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
760 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
761 aCriterion.BinaryOp = aTreshold
765 aTreshold = float(aTreshold)
766 aCriterion.Threshold = aTreshold
768 print "Error: The treshold should be a number."
771 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
772 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
774 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
775 aCriterion.BinaryOp = self.EnumToLong(Treshold)
777 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
778 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
780 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
781 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
785 ## Creates a filter with the given parameters
786 # @param elementType the type of elements in the group
787 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
788 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
789 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
790 # @param UnaryOp FT_LogicalNOT or FT_Undefined
791 # @return SMESH_Filter
792 # @ingroup l1_controls
793 def GetFilter(self,elementType,
794 CritType=FT_Undefined,
797 UnaryOp=FT_Undefined):
798 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
799 aFilterMgr = self.CreateFilterManager()
800 aFilter = aFilterMgr.CreateFilter()
802 aCriteria.append(aCriterion)
803 aFilter.SetCriteria(aCriteria)
806 ## Creates a numerical functor by its type
807 # @param theCriterion FT_...; functor type
808 # @return SMESH_NumericalFunctor
809 # @ingroup l1_controls
810 def GetFunctor(self,theCriterion):
811 aFilterMgr = self.CreateFilterManager()
812 if theCriterion == FT_AspectRatio:
813 return aFilterMgr.CreateAspectRatio()
814 elif theCriterion == FT_AspectRatio3D:
815 return aFilterMgr.CreateAspectRatio3D()
816 elif theCriterion == FT_Warping:
817 return aFilterMgr.CreateWarping()
818 elif theCriterion == FT_MinimumAngle:
819 return aFilterMgr.CreateMinimumAngle()
820 elif theCriterion == FT_Taper:
821 return aFilterMgr.CreateTaper()
822 elif theCriterion == FT_Skew:
823 return aFilterMgr.CreateSkew()
824 elif theCriterion == FT_Area:
825 return aFilterMgr.CreateArea()
826 elif theCriterion == FT_Volume3D:
827 return aFilterMgr.CreateVolume3D()
828 elif theCriterion == FT_MultiConnection:
829 return aFilterMgr.CreateMultiConnection()
830 elif theCriterion == FT_MultiConnection2D:
831 return aFilterMgr.CreateMultiConnection2D()
832 elif theCriterion == FT_Length:
833 return aFilterMgr.CreateLength()
834 elif theCriterion == FT_Length2D:
835 return aFilterMgr.CreateLength2D()
837 print "Error: given parameter is not numerucal functor type."
839 ## Creates hypothesis
840 # @param theHType mesh hypothesis type (string)
841 # @param theLibName mesh plug-in library name
842 # @return created hypothesis instance
843 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
844 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
846 ## Gets the mesh stattistic
847 # @return dictionary type element - count of elements
848 # @ingroup l1_meshinfo
849 def GetMeshInfo(self, obj):
850 if isinstance( obj, Mesh ):
853 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
854 values = obj.GetMeshInfo()
855 for i in range(SMESH.Entity_Last._v):
856 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
861 #Registering the new proxy for SMESH_Gen
862 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
868 ## This class allows defining and managing a mesh.
869 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
870 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
871 # new nodes and elements and by changing the existing entities), to get information
872 # about a mesh and to export a mesh into different formats.
881 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
882 # sets the GUI name of this mesh to \a name.
883 # @param smeshpyD an instance of smeshDC class
884 # @param geompyD an instance of geompyDC class
885 # @param obj Shape to be meshed or SMESH_Mesh object
886 # @param name Study name of the mesh
887 # @ingroup l2_construct
888 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
889 self.smeshpyD=smeshpyD
894 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
896 self.mesh = self.smeshpyD.CreateMesh(self.geom)
897 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
900 self.mesh = self.smeshpyD.CreateEmptyMesh()
902 self.smeshpyD.SetName(self.mesh, name)
904 self.smeshpyD.SetName(self.mesh, GetName(obj))
907 self.geom = self.mesh.GetShapeToMesh()
909 self.editor = self.mesh.GetMeshEditor()
911 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
912 # @param theMesh a SMESH_Mesh object
913 # @ingroup l2_construct
914 def SetMesh(self, theMesh):
916 self.geom = self.mesh.GetShapeToMesh()
918 ## Returns the mesh, that is an instance of SMESH_Mesh interface
919 # @return a SMESH_Mesh object
920 # @ingroup l2_construct
924 ## Gets the name of the mesh
925 # @return the name of the mesh as a string
926 # @ingroup l2_construct
928 name = GetName(self.GetMesh())
931 ## Sets a name to the mesh
932 # @param name a new name of the mesh
933 # @ingroup l2_construct
934 def SetName(self, name):
935 self.smeshpyD.SetName(self.GetMesh(), name)
937 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
938 # The subMesh object gives access to the IDs of nodes and elements.
939 # @param theSubObject a geometrical object (shape)
940 # @param theName a name for the submesh
941 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
942 # @ingroup l2_submeshes
943 def GetSubMesh(self, theSubObject, theName):
944 submesh = self.mesh.GetSubMesh(theSubObject, theName)
947 ## Returns the shape associated to the mesh
948 # @return a GEOM_Object
949 # @ingroup l2_construct
953 ## Associates the given shape to the mesh (entails the recreation of the mesh)
954 # @param geom the shape to be meshed (GEOM_Object)
955 # @ingroup l2_construct
956 def SetShape(self, geom):
957 self.mesh = self.smeshpyD.CreateMesh(geom)
959 ## Returns true if the hypotheses are defined well
960 # @param theSubObject a subshape of a mesh shape
961 # @return True or False
962 # @ingroup l2_construct
963 def IsReadyToCompute(self, theSubObject):
964 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
966 ## Returns errors of hypotheses definition.
967 # The list of errors is empty if everything is OK.
968 # @param theSubObject a subshape of a mesh shape
969 # @return a list of errors
970 # @ingroup l2_construct
971 def GetAlgoState(self, theSubObject):
972 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
974 ## Returns a geometrical object on which the given element was built.
975 # The returned geometrical object, if not nil, is either found in the
976 # study or published by this method with the given name
977 # @param theElementID the id of the mesh element
978 # @param theGeomName the user-defined name of the geometrical object
979 # @return GEOM::GEOM_Object instance
980 # @ingroup l2_construct
981 def GetGeometryByMeshElement(self, theElementID, theGeomName):
982 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
984 ## Returns the mesh dimension depending on the dimension of the underlying shape
985 # @return mesh dimension as an integer value [0,3]
986 # @ingroup l1_auxiliary
987 def MeshDimension(self):
988 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
989 if len( shells ) > 0 :
991 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
993 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
999 ## Creates a segment discretization 1D algorithm.
1000 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
1001 # \n If the optional \a geom parameter is not set, this algorithm is global.
1002 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1003 # @param algo the type of the required algorithm. Possible values are:
1005 # - smesh.PYTHON for discretization via a python function,
1006 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
1007 # @param geom If defined is the subshape to be meshed
1008 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
1009 # @ingroup l3_algos_basic
1010 def Segment(self, algo=REGULAR, geom=0):
1011 ## if Segment(geom) is called by mistake
1012 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
1013 algo, geom = geom, algo
1014 if not algo: algo = REGULAR
1017 return Mesh_Segment(self, geom)
1018 elif algo == PYTHON:
1019 return Mesh_Segment_Python(self, geom)
1020 elif algo == COMPOSITE:
1021 return Mesh_CompositeSegment(self, geom)
1023 return Mesh_Segment(self, geom)
1025 ## Enables creation of nodes and segments usable by 2D algoritms.
1026 # The added nodes and segments must be bound to edges and vertices by
1027 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
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 geom the subshape to be manually meshed
1031 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
1032 # @ingroup l3_algos_basic
1033 def UseExistingSegments(self, geom=0):
1034 algo = Mesh_UseExisting(1,self,geom)
1035 return algo.GetAlgorithm()
1037 ## Enables creation of nodes and faces usable by 3D algoritms.
1038 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
1039 # and SetMeshElementOnShape()
1040 # If the optional \a geom parameter is not set, this algorithm is global.
1041 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1042 # @param geom the subshape to be manually meshed
1043 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
1044 # @ingroup l3_algos_basic
1045 def UseExistingFaces(self, geom=0):
1046 algo = Mesh_UseExisting(2,self,geom)
1047 return algo.GetAlgorithm()
1049 ## Creates a triangle 2D algorithm for faces.
1050 # If the optional \a geom parameter is not set, this algorithm is global.
1051 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1052 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
1053 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1054 # @return an instance of Mesh_Triangle algorithm
1055 # @ingroup l3_algos_basic
1056 def Triangle(self, algo=MEFISTO, geom=0):
1057 ## if Triangle(geom) is called by mistake
1058 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
1061 return Mesh_Triangle(self, algo, geom)
1063 ## Creates a quadrangle 2D algorithm for faces.
1064 # If the optional \a geom parameter is not set, this algorithm is global.
1065 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1066 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1067 # @param algo values are: smesh.QUADRANGLE || smesh.RADIAL_QUAD
1068 # @return an instance of Mesh_Quadrangle algorithm
1069 # @ingroup l3_algos_basic
1070 def Quadrangle(self, geom=0, algo=QUADRANGLE):
1071 if algo==RADIAL_QUAD:
1072 return Mesh_RadialQuadrangle1D2D(self,geom)
1074 return Mesh_Quadrangle(self, geom)
1076 ## Creates a tetrahedron 3D algorithm for solids.
1077 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
1078 # If the optional \a geom parameter is not set, this algorithm is global.
1079 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1080 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
1081 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1082 # @return an instance of Mesh_Tetrahedron algorithm
1083 # @ingroup l3_algos_basic
1084 def Tetrahedron(self, algo=NETGEN, geom=0):
1085 ## if Tetrahedron(geom) is called by mistake
1086 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
1087 algo, geom = geom, algo
1088 if not algo: algo = NETGEN
1090 return Mesh_Tetrahedron(self, algo, geom)
1092 ## Creates a hexahedron 3D algorithm for solids.
1093 # If the optional \a geom parameter is not set, this algorithm is global.
1094 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
1095 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
1096 # @param geom If defined, the subshape to be meshed (GEOM_Object)
1097 # @return an instance of Mesh_Hexahedron algorithm
1098 # @ingroup l3_algos_basic
1099 def Hexahedron(self, algo=Hexa, geom=0):
1100 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1101 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1102 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1103 elif geom == 0: algo, geom = Hexa, algo
1104 return Mesh_Hexahedron(self, algo, geom)
1106 ## Deprecated, used only for compatibility!
1107 # @return an instance of Mesh_Netgen algorithm
1108 # @ingroup l3_algos_basic
1109 def Netgen(self, is3D, geom=0):
1110 return Mesh_Netgen(self, is3D, geom)
1112 ## Creates a projection 1D algorithm for edges.
1113 # If the optional \a geom parameter is not set, this algorithm is global.
1114 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1115 # @param geom If defined, the subshape to be meshed
1116 # @return an instance of Mesh_Projection1D algorithm
1117 # @ingroup l3_algos_proj
1118 def Projection1D(self, geom=0):
1119 return Mesh_Projection1D(self, geom)
1121 ## Creates a projection 2D algorithm for faces.
1122 # If the optional \a geom parameter is not set, this algorithm is global.
1123 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1124 # @param geom If defined, the subshape to be meshed
1125 # @return an instance of Mesh_Projection2D algorithm
1126 # @ingroup l3_algos_proj
1127 def Projection2D(self, geom=0):
1128 return Mesh_Projection2D(self, geom)
1130 ## Creates a projection 3D algorithm for solids.
1131 # If the optional \a geom parameter is not set, this algorithm is global.
1132 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1133 # @param geom If defined, the subshape to be meshed
1134 # @return an instance of Mesh_Projection3D algorithm
1135 # @ingroup l3_algos_proj
1136 def Projection3D(self, geom=0):
1137 return Mesh_Projection3D(self, geom)
1139 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1140 # If the optional \a geom parameter is not set, this algorithm is global.
1141 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1142 # @param geom If defined, the subshape to be meshed
1143 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1144 # @ingroup l3_algos_radialp l3_algos_3dextr
1145 def Prism(self, geom=0):
1149 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1150 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1151 if nbSolids == 0 or nbSolids == nbShells:
1152 return Mesh_Prism3D(self, geom)
1153 return Mesh_RadialPrism3D(self, geom)
1155 ## Evaluates size of prospective mesh on a shape
1156 # @return True or False
1157 def Evaluate(self, geom=0):
1158 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1160 geom = self.mesh.GetShapeToMesh()
1163 return self.smeshpyD.Evaluate(self.mesh, geom)
1166 ## Computes the mesh and returns the status of the computation
1167 # @return True or False
1168 # @ingroup l2_construct
1169 def Compute(self, geom=0):
1170 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1172 geom = self.mesh.GetShapeToMesh()
1177 ok = self.smeshpyD.Compute(self.mesh, geom)
1178 except SALOME.SALOME_Exception, ex:
1179 print "Mesh computation failed, exception caught:"
1180 print " ", ex.details.text
1183 print "Mesh computation failed, exception caught:"
1184 traceback.print_exc()
1188 # Treat compute errors
1189 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
1190 for err in computeErrors:
1193 mainIOR = salome.orb.object_to_string(geom)
1194 for sname in salome.myStudyManager.GetOpenStudies():
1195 s = salome.myStudyManager.GetStudyByName(sname)
1197 mainSO = s.FindObjectIOR(mainIOR)
1198 if not mainSO: continue
1199 subIt = s.NewChildIterator(mainSO)
1201 subSO = subIt.Value()
1203 obj = subSO.GetObject()
1204 if not obj: continue
1205 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
1207 ids = go.GetSubShapeIndices()
1208 if len(ids) == 1 and ids[0] == err.subShapeID:
1209 shapeText = '"%s"' % subSO.GetName()
1212 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
1214 shapeText = "%s #%s" % (shape.GetShapeType(), err.subShapeID)
1216 shapeText = "%subshape #%s" % (err.subShapeID)
1218 shapeText = "%subshape #%s" % (err.subShapeID)
1220 stdErrors = ["OK", #COMPERR_OK
1221 "Invalid input mesh", #COMPERR_BAD_INPUT_MESH
1222 "std::exception", #COMPERR_STD_EXCEPTION
1223 "OCC exception", #COMPERR_OCC_EXCEPTION
1224 "SALOME exception", #COMPERR_SLM_EXCEPTION
1225 "Unknown exception", #COMPERR_EXCEPTION
1226 "Memory allocation problem", #COMPERR_MEMORY_PB
1227 "Algorithm failed", #COMPERR_ALGO_FAILED
1228 "Unexpected geometry"]#COMPERR_BAD_SHAPE
1230 if err.code < len(stdErrors): errText = stdErrors[err.code]
1232 errText = "code %s" % -err.code
1233 if errText: errText += ". "
1234 errText += err.comment
1235 if allReasons != "":allReasons += "\n"
1236 allReasons += '"%s" failed on %s. Error: %s' %(err.algoName, shapeText, errText)
1240 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1242 if err.isGlobalAlgo:
1250 reason = '%s %sD algorithm is missing' % (glob, dim)
1251 elif err.state == HYP_MISSING:
1252 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1253 % (glob, dim, name, dim))
1254 elif err.state == HYP_NOTCONFORM:
1255 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1256 elif err.state == HYP_BAD_PARAMETER:
1257 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1258 % ( glob, dim, name ))
1259 elif err.state == HYP_BAD_GEOMETRY:
1260 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1261 'geometry' % ( glob, dim, name ))
1263 reason = "For unknown reason."+\
1264 " Revise Mesh.Compute() implementation in smeshDC.py!"
1266 if allReasons != "":allReasons += "\n"
1267 allReasons += reason
1269 if allReasons != "":
1270 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1274 print '"' + GetName(self.mesh) + '"',"has not been computed."
1277 if salome.sg.hasDesktop():
1278 smeshgui = salome.ImportComponentGUI("SMESH")
1279 smeshgui.Init(self.mesh.GetStudyId())
1280 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1281 salome.sg.updateObjBrowser(1)
1285 ## Return submesh objects list in meshing order
1286 # @return list of list of submesh objects
1287 # @ingroup l2_construct
1288 def GetMeshOrder(self):
1289 return self.mesh.GetMeshOrder()
1291 ## Return submesh objects list in meshing order
1292 # @return list of list of submesh objects
1293 # @ingroup l2_construct
1294 def SetMeshOrder(self, submeshes):
1295 return self.mesh.SetMeshOrder(submeshes)
1297 ## Removes all nodes and elements
1298 # @ingroup l2_construct
1301 if salome.sg.hasDesktop():
1302 smeshgui = salome.ImportComponentGUI("SMESH")
1303 smeshgui.Init(self.mesh.GetStudyId())
1304 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1305 salome.sg.updateObjBrowser(1)
1307 ## Removes all nodes and elements of indicated shape
1308 # @ingroup l2_construct
1309 def ClearSubMesh(self, geomId):
1310 self.mesh.ClearSubMesh(geomId)
1311 if salome.sg.hasDesktop():
1312 smeshgui = salome.ImportComponentGUI("SMESH")
1313 smeshgui.Init(self.mesh.GetStudyId())
1314 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1315 salome.sg.updateObjBrowser(1)
1317 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1318 # @param fineness [0,-1] defines mesh fineness
1319 # @return True or False
1320 # @ingroup l3_algos_basic
1321 def AutomaticTetrahedralization(self, fineness=0):
1322 dim = self.MeshDimension()
1324 self.RemoveGlobalHypotheses()
1325 self.Segment().AutomaticLength(fineness)
1327 self.Triangle().LengthFromEdges()
1330 self.Tetrahedron(NETGEN)
1332 return self.Compute()
1334 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1335 # @param fineness [0,-1] defines mesh fineness
1336 # @return True or False
1337 # @ingroup l3_algos_basic
1338 def AutomaticHexahedralization(self, fineness=0):
1339 dim = self.MeshDimension()
1340 # assign the hypotheses
1341 self.RemoveGlobalHypotheses()
1342 self.Segment().AutomaticLength(fineness)
1349 return self.Compute()
1351 ## Assigns a hypothesis
1352 # @param hyp a hypothesis to assign
1353 # @param geom a subhape of mesh geometry
1354 # @return SMESH.Hypothesis_Status
1355 # @ingroup l2_hypotheses
1356 def AddHypothesis(self, hyp, geom=0):
1357 if isinstance( hyp, Mesh_Algorithm ):
1358 hyp = hyp.GetAlgorithm()
1363 geom = self.mesh.GetShapeToMesh()
1365 status = self.mesh.AddHypothesis(geom, hyp)
1366 isAlgo = hyp._narrow( SMESH_Algo )
1367 hyp_name = GetName( hyp )
1370 geom_name = GetName( geom )
1371 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
1374 ## Unassigns a hypothesis
1375 # @param hyp a hypothesis to unassign
1376 # @param geom a subshape of mesh geometry
1377 # @return SMESH.Hypothesis_Status
1378 # @ingroup l2_hypotheses
1379 def RemoveHypothesis(self, hyp, geom=0):
1380 if isinstance( hyp, Mesh_Algorithm ):
1381 hyp = hyp.GetAlgorithm()
1386 status = self.mesh.RemoveHypothesis(geom, hyp)
1389 ## Gets the list of hypotheses added on a geometry
1390 # @param geom a subshape of mesh geometry
1391 # @return the sequence of SMESH_Hypothesis
1392 # @ingroup l2_hypotheses
1393 def GetHypothesisList(self, geom):
1394 return self.mesh.GetHypothesisList( geom )
1396 ## Removes all global hypotheses
1397 # @ingroup l2_hypotheses
1398 def RemoveGlobalHypotheses(self):
1399 current_hyps = self.mesh.GetHypothesisList( self.geom )
1400 for hyp in current_hyps:
1401 self.mesh.RemoveHypothesis( self.geom, hyp )
1405 ## Creates a mesh group based on the geometric object \a grp
1406 # and gives a \a name, \n if this parameter is not defined
1407 # the name is the same as the geometric group name \n
1408 # Note: Works like GroupOnGeom().
1409 # @param grp a geometric group, a vertex, an edge, a face or a solid
1410 # @param name the name of the mesh group
1411 # @return SMESH_GroupOnGeom
1412 # @ingroup l2_grps_create
1413 def Group(self, grp, name=""):
1414 return self.GroupOnGeom(grp, name)
1416 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1417 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1418 # @param f the file name
1419 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1420 # @param opt boolean parameter for creating/not creating
1421 # the groups Group_On_All_Nodes, Group_On_All_Faces, ...
1422 # @ingroup l2_impexp
1423 def ExportToMED(self, f, version, opt=0):
1424 self.mesh.ExportToMED(f, opt, version)
1426 ## Exports the mesh in a file in MED format
1427 # @param f is the file name
1428 # @param auto_groups boolean parameter for creating/not creating
1429 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1430 # the typical use is auto_groups=false.
1431 # @param version MED format version(MED_V2_1 or MED_V2_2)
1432 # @ingroup l2_impexp
1433 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1434 self.mesh.ExportToMED(f, auto_groups, version)
1436 ## Exports the mesh in a file in DAT format
1437 # @param f the file name
1438 # @ingroup l2_impexp
1439 def ExportDAT(self, f):
1440 self.mesh.ExportDAT(f)
1442 ## Exports the mesh in a file in UNV format
1443 # @param f the file name
1444 # @ingroup l2_impexp
1445 def ExportUNV(self, f):
1446 self.mesh.ExportUNV(f)
1448 ## Export the mesh in a file in STL format
1449 # @param f the file name
1450 # @param ascii defines the file encoding
1451 # @ingroup l2_impexp
1452 def ExportSTL(self, f, ascii=1):
1453 self.mesh.ExportSTL(f, ascii)
1456 # Operations with groups:
1457 # ----------------------
1459 ## Creates an empty mesh group
1460 # @param elementType the type of elements in the group
1461 # @param name the name of the mesh group
1462 # @return SMESH_Group
1463 # @ingroup l2_grps_create
1464 def CreateEmptyGroup(self, elementType, name):
1465 return self.mesh.CreateGroup(elementType, name)
1467 ## Creates a mesh group based on the geometrical object \a grp
1468 # and gives a \a name, \n if this parameter is not defined
1469 # the name is the same as the geometrical group name
1470 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1471 # @param name the name of the mesh group
1472 # @param typ the type of elements in the group. If not set, it is
1473 # automatically detected by the type of the geometry
1474 # @return SMESH_GroupOnGeom
1475 # @ingroup l2_grps_create
1476 def GroupOnGeom(self, grp, name="", typ=None):
1478 name = grp.GetName()
1481 tgeo = str(grp.GetShapeType())
1482 if tgeo == "VERTEX":
1484 elif tgeo == "EDGE":
1486 elif tgeo == "FACE":
1488 elif tgeo == "SOLID":
1490 elif tgeo == "SHELL":
1492 elif tgeo == "COMPOUND":
1493 try: # it raises on a compound of compounds
1494 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1495 print "Mesh.Group: empty geometric group", GetName( grp )
1500 if grp.GetType() == 37: # GEOMImpl_Types.hxx: #define GEOM_GROUP 37
1502 tgeo = self.geompyD.GetType(grp)
1503 if tgeo == geompyDC.ShapeType["VERTEX"]:
1505 elif tgeo == geompyDC.ShapeType["EDGE"]:
1507 elif tgeo == geompyDC.ShapeType["FACE"]:
1509 elif tgeo == geompyDC.ShapeType["SOLID"]:
1515 for elemType, shapeType in [[VOLUME,"SOLID"],[FACE,"FACE"],
1516 [EDGE,"EDGE"],[NODE,"VERTEX"]]:
1517 if self.geompyD.SubShapeAll(grp,geompyDC.ShapeType[shapeType]):
1525 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1528 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1530 ## Creates a mesh group by the given ids of elements
1531 # @param groupName the name of the mesh group
1532 # @param elementType the type of elements in the group
1533 # @param elemIDs the list of ids
1534 # @return SMESH_Group
1535 # @ingroup l2_grps_create
1536 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1537 group = self.mesh.CreateGroup(elementType, groupName)
1541 ## Creates a mesh group by the given conditions
1542 # @param groupName the name of the mesh group
1543 # @param elementType the type of elements in the group
1544 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1545 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1546 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1547 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1548 # @return SMESH_Group
1549 # @ingroup l2_grps_create
1553 CritType=FT_Undefined,
1556 UnaryOp=FT_Undefined):
1557 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1558 group = self.MakeGroupByCriterion(groupName, aCriterion)
1561 ## Creates a mesh group by the given criterion
1562 # @param groupName the name of the mesh group
1563 # @param Criterion the instance of Criterion class
1564 # @return SMESH_Group
1565 # @ingroup l2_grps_create
1566 def MakeGroupByCriterion(self, groupName, Criterion):
1567 aFilterMgr = self.smeshpyD.CreateFilterManager()
1568 aFilter = aFilterMgr.CreateFilter()
1570 aCriteria.append(Criterion)
1571 aFilter.SetCriteria(aCriteria)
1572 group = self.MakeGroupByFilter(groupName, aFilter)
1575 ## Creates a mesh group by the given criteria (list of criteria)
1576 # @param groupName the name of the mesh group
1577 # @param theCriteria the list of criteria
1578 # @return SMESH_Group
1579 # @ingroup l2_grps_create
1580 def MakeGroupByCriteria(self, groupName, theCriteria):
1581 aFilterMgr = self.smeshpyD.CreateFilterManager()
1582 aFilter = aFilterMgr.CreateFilter()
1583 aFilter.SetCriteria(theCriteria)
1584 group = self.MakeGroupByFilter(groupName, aFilter)
1587 ## Creates a mesh group by the given filter
1588 # @param groupName the name of the mesh group
1589 # @param theFilter the instance of Filter class
1590 # @return SMESH_Group
1591 # @ingroup l2_grps_create
1592 def MakeGroupByFilter(self, groupName, theFilter):
1593 anIds = theFilter.GetElementsId(self.mesh)
1594 anElemType = theFilter.GetElementType()
1595 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1598 ## Passes mesh elements through the given filter and return IDs of fitting elements
1599 # @param theFilter SMESH_Filter
1600 # @return a list of ids
1601 # @ingroup l1_controls
1602 def GetIdsFromFilter(self, theFilter):
1603 return theFilter.GetElementsId(self.mesh)
1605 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1606 # Returns a list of special structures (borders).
1607 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1608 # @ingroup l1_controls
1609 def GetFreeBorders(self):
1610 aFilterMgr = self.smeshpyD.CreateFilterManager()
1611 aPredicate = aFilterMgr.CreateFreeEdges()
1612 aPredicate.SetMesh(self.mesh)
1613 aBorders = aPredicate.GetBorders()
1617 # @ingroup l2_grps_delete
1618 def RemoveGroup(self, group):
1619 self.mesh.RemoveGroup(group)
1621 ## Removes a group with its contents
1622 # @ingroup l2_grps_delete
1623 def RemoveGroupWithContents(self, group):
1624 self.mesh.RemoveGroupWithContents(group)
1626 ## Gets the list of groups existing in the mesh
1627 # @return a sequence of SMESH_GroupBase
1628 # @ingroup l2_grps_create
1629 def GetGroups(self):
1630 return self.mesh.GetGroups()
1632 ## Gets the number of groups existing in the mesh
1633 # @return the quantity of groups as an integer value
1634 # @ingroup l2_grps_create
1636 return self.mesh.NbGroups()
1638 ## Gets the list of names of groups existing in the mesh
1639 # @return list of strings
1640 # @ingroup l2_grps_create
1641 def GetGroupNames(self):
1642 groups = self.GetGroups()
1644 for group in groups:
1645 names.append(group.GetName())
1648 ## Produces a union of two groups
1649 # A new group is created. All mesh elements that are
1650 # present in the initial groups are added to the new one
1651 # @return an instance of SMESH_Group
1652 # @ingroup l2_grps_operon
1653 def UnionGroups(self, group1, group2, name):
1654 return self.mesh.UnionGroups(group1, group2, name)
1656 ## Produces a union list of groups
1657 # New group is created. All mesh elements that are present in
1658 # initial groups are added to the new one
1659 # @return an instance of SMESH_Group
1660 # @ingroup l2_grps_operon
1661 def UnionListOfGroups(self, groups, name):
1662 return self.mesh.UnionListOfGroups(groups, name)
1664 ## Prodices an intersection of two groups
1665 # A new group is created. All mesh elements that are common
1666 # for the two initial groups are added to the new one.
1667 # @return an instance of SMESH_Group
1668 # @ingroup l2_grps_operon
1669 def IntersectGroups(self, group1, group2, name):
1670 return self.mesh.IntersectGroups(group1, group2, name)
1672 ## Produces an intersection of groups
1673 # New group is created. All mesh elements that are present in all
1674 # initial groups simultaneously are added to the new one
1675 # @return an instance of SMESH_Group
1676 # @ingroup l2_grps_operon
1677 def IntersectListOfGroups(self, groups, name):
1678 return self.mesh.IntersectListOfGroups(groups, name)
1680 ## Produces a cut of two groups
1681 # A new group is created. All mesh elements that are present in
1682 # the main group but are not present in the tool group are added to the new one
1683 # @return an instance of SMESH_Group
1684 # @ingroup l2_grps_operon
1685 def CutGroups(self, main_group, tool_group, name):
1686 return self.mesh.CutGroups(main_group, tool_group, name)
1688 ## Produces a cut of groups
1689 # A new group is created. All mesh elements that are present in main groups
1690 # but do not present in tool groups are added to the new one
1691 # @return an instance of SMESH_Group
1692 # @ingroup l2_grps_operon
1693 def CutListOfGroups(self, main_groups, tool_groups, name):
1694 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1696 ## Produces a group of elements with specified element type using list of existing groups
1697 # A new group is created. System
1698 # 1) extract all nodes on which groups elements are built
1699 # 2) combine all elements of specified dimension laying on these nodes
1700 # @return an instance of SMESH_Group
1701 # @ingroup l2_grps_operon
1702 def CreateDimGroup(self, groups, elem_type, name):
1703 return self.mesh.CreateDimGroup(groups, elem_type, name)
1706 ## Convert group on geom into standalone group
1707 # @ingroup l2_grps_delete
1708 def ConvertToStandalone(self, group):
1709 return self.mesh.ConvertToStandalone(group)
1711 # Get some info about mesh:
1712 # ------------------------
1714 ## Returns the log of nodes and elements added or removed
1715 # since the previous clear of the log.
1716 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1717 # @return list of log_block structures:
1722 # @ingroup l1_auxiliary
1723 def GetLog(self, clearAfterGet):
1724 return self.mesh.GetLog(clearAfterGet)
1726 ## Clears the log of nodes and elements added or removed since the previous
1727 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1728 # @ingroup l1_auxiliary
1730 self.mesh.ClearLog()
1732 ## Toggles auto color mode on the object.
1733 # @param theAutoColor the flag which toggles auto color mode.
1734 # @ingroup l1_auxiliary
1735 def SetAutoColor(self, theAutoColor):
1736 self.mesh.SetAutoColor(theAutoColor)
1738 ## Gets flag of object auto color mode.
1739 # @return True or False
1740 # @ingroup l1_auxiliary
1741 def GetAutoColor(self):
1742 return self.mesh.GetAutoColor()
1744 ## Gets the internal ID
1745 # @return integer value, which is the internal Id of the mesh
1746 # @ingroup l1_auxiliary
1748 return self.mesh.GetId()
1751 # @return integer value, which is the study Id of the mesh
1752 # @ingroup l1_auxiliary
1753 def GetStudyId(self):
1754 return self.mesh.GetStudyId()
1756 ## Checks the group names for duplications.
1757 # Consider the maximum group name length stored in MED file.
1758 # @return True or False
1759 # @ingroup l1_auxiliary
1760 def HasDuplicatedGroupNamesMED(self):
1761 return self.mesh.HasDuplicatedGroupNamesMED()
1763 ## Obtains the mesh editor tool
1764 # @return an instance of SMESH_MeshEditor
1765 # @ingroup l1_modifying
1766 def GetMeshEditor(self):
1767 return self.mesh.GetMeshEditor()
1770 # @return an instance of SALOME_MED::MESH
1771 # @ingroup l1_auxiliary
1772 def GetMEDMesh(self):
1773 return self.mesh.GetMEDMesh()
1776 # Get informations about mesh contents:
1777 # ------------------------------------
1779 ## Gets the mesh stattistic
1780 # @return dictionary type element - count of elements
1781 # @ingroup l1_meshinfo
1782 def GetMeshInfo(self, obj = None):
1783 if not obj: obj = self.mesh
1784 return self.smeshpyD.GetMeshInfo(obj)
1786 ## Returns the number of nodes in the mesh
1787 # @return an integer value
1788 # @ingroup l1_meshinfo
1790 return self.mesh.NbNodes()
1792 ## Returns the number of elements in the mesh
1793 # @return an integer value
1794 # @ingroup l1_meshinfo
1795 def NbElements(self):
1796 return self.mesh.NbElements()
1798 ## Returns the number of 0d elements in the mesh
1799 # @return an integer value
1800 # @ingroup l1_meshinfo
1801 def Nb0DElements(self):
1802 return self.mesh.Nb0DElements()
1804 ## Returns the number of edges in the mesh
1805 # @return an integer value
1806 # @ingroup l1_meshinfo
1808 return self.mesh.NbEdges()
1810 ## Returns the number of edges with the given order in the mesh
1811 # @param elementOrder the order of elements:
1812 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1813 # @return an integer value
1814 # @ingroup l1_meshinfo
1815 def NbEdgesOfOrder(self, elementOrder):
1816 return self.mesh.NbEdgesOfOrder(elementOrder)
1818 ## Returns the number of faces in the mesh
1819 # @return an integer value
1820 # @ingroup l1_meshinfo
1822 return self.mesh.NbFaces()
1824 ## Returns the number of faces with the given order in the mesh
1825 # @param elementOrder the order of elements:
1826 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1827 # @return an integer value
1828 # @ingroup l1_meshinfo
1829 def NbFacesOfOrder(self, elementOrder):
1830 return self.mesh.NbFacesOfOrder(elementOrder)
1832 ## Returns the number of triangles in the mesh
1833 # @return an integer value
1834 # @ingroup l1_meshinfo
1835 def NbTriangles(self):
1836 return self.mesh.NbTriangles()
1838 ## Returns the number of triangles with the given order in the mesh
1839 # @param elementOrder is the order of elements:
1840 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1841 # @return an integer value
1842 # @ingroup l1_meshinfo
1843 def NbTrianglesOfOrder(self, elementOrder):
1844 return self.mesh.NbTrianglesOfOrder(elementOrder)
1846 ## Returns the number of quadrangles in the mesh
1847 # @return an integer value
1848 # @ingroup l1_meshinfo
1849 def NbQuadrangles(self):
1850 return self.mesh.NbQuadrangles()
1852 ## Returns the number of quadrangles with the given order in the mesh
1853 # @param elementOrder the order of elements:
1854 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1855 # @return an integer value
1856 # @ingroup l1_meshinfo
1857 def NbQuadranglesOfOrder(self, elementOrder):
1858 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1860 ## Returns the number of polygons in the mesh
1861 # @return an integer value
1862 # @ingroup l1_meshinfo
1863 def NbPolygons(self):
1864 return self.mesh.NbPolygons()
1866 ## Returns the number of volumes in the mesh
1867 # @return an integer value
1868 # @ingroup l1_meshinfo
1869 def NbVolumes(self):
1870 return self.mesh.NbVolumes()
1872 ## Returns the number of volumes with the given order in the mesh
1873 # @param elementOrder the order of elements:
1874 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1875 # @return an integer value
1876 # @ingroup l1_meshinfo
1877 def NbVolumesOfOrder(self, elementOrder):
1878 return self.mesh.NbVolumesOfOrder(elementOrder)
1880 ## Returns the number of tetrahedrons in the mesh
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1884 return self.mesh.NbTetras()
1886 ## Returns the number of tetrahedrons with the given order in the mesh
1887 # @param elementOrder the order of elements:
1888 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1889 # @return an integer value
1890 # @ingroup l1_meshinfo
1891 def NbTetrasOfOrder(self, elementOrder):
1892 return self.mesh.NbTetrasOfOrder(elementOrder)
1894 ## Returns the number of hexahedrons in the mesh
1895 # @return an integer value
1896 # @ingroup l1_meshinfo
1898 return self.mesh.NbHexas()
1900 ## Returns the number of hexahedrons with the given order in the mesh
1901 # @param elementOrder the order of elements:
1902 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1903 # @return an integer value
1904 # @ingroup l1_meshinfo
1905 def NbHexasOfOrder(self, elementOrder):
1906 return self.mesh.NbHexasOfOrder(elementOrder)
1908 ## Returns the number of pyramids in the mesh
1909 # @return an integer value
1910 # @ingroup l1_meshinfo
1911 def NbPyramids(self):
1912 return self.mesh.NbPyramids()
1914 ## Returns the number of pyramids with the given order in the mesh
1915 # @param elementOrder the order of elements:
1916 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1917 # @return an integer value
1918 # @ingroup l1_meshinfo
1919 def NbPyramidsOfOrder(self, elementOrder):
1920 return self.mesh.NbPyramidsOfOrder(elementOrder)
1922 ## Returns the number of prisms in the mesh
1923 # @return an integer value
1924 # @ingroup l1_meshinfo
1926 return self.mesh.NbPrisms()
1928 ## Returns the number of prisms with the given order in the mesh
1929 # @param elementOrder the order of elements:
1930 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1931 # @return an integer value
1932 # @ingroup l1_meshinfo
1933 def NbPrismsOfOrder(self, elementOrder):
1934 return self.mesh.NbPrismsOfOrder(elementOrder)
1936 ## Returns the number of polyhedrons in the mesh
1937 # @return an integer value
1938 # @ingroup l1_meshinfo
1939 def NbPolyhedrons(self):
1940 return self.mesh.NbPolyhedrons()
1942 ## Returns the number of submeshes in the mesh
1943 # @return an integer value
1944 # @ingroup l1_meshinfo
1945 def NbSubMesh(self):
1946 return self.mesh.NbSubMesh()
1948 ## Returns the list of mesh elements IDs
1949 # @return the list of integer values
1950 # @ingroup l1_meshinfo
1951 def GetElementsId(self):
1952 return self.mesh.GetElementsId()
1954 ## Returns the list of IDs of mesh elements with the given type
1955 # @param elementType the required type of elements
1956 # @return list of integer values
1957 # @ingroup l1_meshinfo
1958 def GetElementsByType(self, elementType):
1959 return self.mesh.GetElementsByType(elementType)
1961 ## Returns the list of mesh nodes IDs
1962 # @return the list of integer values
1963 # @ingroup l1_meshinfo
1964 def GetNodesId(self):
1965 return self.mesh.GetNodesId()
1967 # Get the information about mesh elements:
1968 # ------------------------------------
1970 ## Returns the type of mesh element
1971 # @return the value from SMESH::ElementType enumeration
1972 # @ingroup l1_meshinfo
1973 def GetElementType(self, id, iselem):
1974 return self.mesh.GetElementType(id, iselem)
1976 ## Returns the geometric type of mesh element
1977 # @return the value from SMESH::EntityType enumeration
1978 # @ingroup l1_meshinfo
1979 def GetElementGeomType(self, id):
1980 return self.mesh.GetElementGeomType(id)
1982 ## Returns the list of submesh elements IDs
1983 # @param Shape a geom object(subshape) IOR
1984 # Shape must be the subshape of a ShapeToMesh()
1985 # @return the list of integer values
1986 # @ingroup l1_meshinfo
1987 def GetSubMeshElementsId(self, Shape):
1988 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1989 ShapeID = Shape.GetSubShapeIndices()[0]
1992 return self.mesh.GetSubMeshElementsId(ShapeID)
1994 ## Returns the list of submesh nodes IDs
1995 # @param Shape a geom object(subshape) IOR
1996 # Shape must be the subshape of a ShapeToMesh()
1997 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1998 # @return the list of integer values
1999 # @ingroup l1_meshinfo
2000 def GetSubMeshNodesId(self, Shape, all):
2001 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2002 ShapeID = Shape.GetSubShapeIndices()[0]
2005 return self.mesh.GetSubMeshNodesId(ShapeID, all)
2007 ## Returns type of elements on given shape
2008 # @param Shape a geom object(subshape) IOR
2009 # Shape must be a subshape of a ShapeToMesh()
2010 # @return element type
2011 # @ingroup l1_meshinfo
2012 def GetSubMeshElementType(self, Shape):
2013 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2014 ShapeID = Shape.GetSubShapeIndices()[0]
2017 return self.mesh.GetSubMeshElementType(ShapeID)
2019 ## Gets the mesh description
2020 # @return string value
2021 # @ingroup l1_meshinfo
2023 return self.mesh.Dump()
2026 # Get the information about nodes and elements of a mesh by its IDs:
2027 # -----------------------------------------------------------
2029 ## Gets XYZ coordinates of a node
2030 # \n If there is no nodes for the given ID - returns an empty list
2031 # @return a list of double precision values
2032 # @ingroup l1_meshinfo
2033 def GetNodeXYZ(self, id):
2034 return self.mesh.GetNodeXYZ(id)
2036 ## Returns list of IDs of inverse elements for the given node
2037 # \n If there is no node for the given ID - returns an empty list
2038 # @return a list of integer values
2039 # @ingroup l1_meshinfo
2040 def GetNodeInverseElements(self, id):
2041 return self.mesh.GetNodeInverseElements(id)
2043 ## @brief Returns the position of a node on the shape
2044 # @return SMESH::NodePosition
2045 # @ingroup l1_meshinfo
2046 def GetNodePosition(self,NodeID):
2047 return self.mesh.GetNodePosition(NodeID)
2049 ## If the given element is a node, returns the ID of shape
2050 # \n If there is no node for the given ID - returns -1
2051 # @return an integer value
2052 # @ingroup l1_meshinfo
2053 def GetShapeID(self, id):
2054 return self.mesh.GetShapeID(id)
2056 ## Returns the ID of the result shape after
2057 # FindShape() from SMESH_MeshEditor for the given element
2058 # \n If there is no element for the given ID - returns -1
2059 # @return an integer value
2060 # @ingroup l1_meshinfo
2061 def GetShapeIDForElem(self,id):
2062 return self.mesh.GetShapeIDForElem(id)
2064 ## Returns the number of nodes for the given element
2065 # \n If there is no element for the given ID - returns -1
2066 # @return an integer value
2067 # @ingroup l1_meshinfo
2068 def GetElemNbNodes(self, id):
2069 return self.mesh.GetElemNbNodes(id)
2071 ## Returns the node ID the given index for the given element
2072 # \n If there is no element for the given ID - returns -1
2073 # \n If there is no node for the given index - returns -2
2074 # @return an integer value
2075 # @ingroup l1_meshinfo
2076 def GetElemNode(self, id, index):
2077 return self.mesh.GetElemNode(id, index)
2079 ## Returns the IDs of nodes of the given element
2080 # @return a list of integer values
2081 # @ingroup l1_meshinfo
2082 def GetElemNodes(self, id):
2083 return self.mesh.GetElemNodes(id)
2085 ## Returns true if the given node is the medium node in the given quadratic element
2086 # @ingroup l1_meshinfo
2087 def IsMediumNode(self, elementID, nodeID):
2088 return self.mesh.IsMediumNode(elementID, nodeID)
2090 ## Returns true if the given node is the medium node in one of quadratic elements
2091 # @ingroup l1_meshinfo
2092 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
2093 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
2095 ## Returns the number of edges for the given element
2096 # @ingroup l1_meshinfo
2097 def ElemNbEdges(self, id):
2098 return self.mesh.ElemNbEdges(id)
2100 ## Returns the number of faces for the given element
2101 # @ingroup l1_meshinfo
2102 def ElemNbFaces(self, id):
2103 return self.mesh.ElemNbFaces(id)
2105 ## Returns nodes of given face (counted from zero) for given volumic element.
2106 # @ingroup l1_meshinfo
2107 def GetElemFaceNodes(self,elemId, faceIndex):
2108 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
2110 ## Returns an element based on all given nodes.
2111 # @ingroup l1_meshinfo
2112 def FindElementByNodes(self,nodes):
2113 return self.mesh.FindElementByNodes(nodes)
2115 ## Returns true if the given element is a polygon
2116 # @ingroup l1_meshinfo
2117 def IsPoly(self, id):
2118 return self.mesh.IsPoly(id)
2120 ## Returns true if the given element is quadratic
2121 # @ingroup l1_meshinfo
2122 def IsQuadratic(self, id):
2123 return self.mesh.IsQuadratic(id)
2125 ## Returns XYZ coordinates of the barycenter of the given element
2126 # \n If there is no element for the given ID - returns an empty list
2127 # @return a list of three double values
2128 # @ingroup l1_meshinfo
2129 def BaryCenter(self, id):
2130 return self.mesh.BaryCenter(id)
2133 # Mesh edition (SMESH_MeshEditor functionality):
2134 # ---------------------------------------------
2136 ## Removes the elements from the mesh by ids
2137 # @param IDsOfElements is a list of ids of elements to remove
2138 # @return True or False
2139 # @ingroup l2_modif_del
2140 def RemoveElements(self, IDsOfElements):
2141 return self.editor.RemoveElements(IDsOfElements)
2143 ## Removes nodes from mesh by ids
2144 # @param IDsOfNodes is a list of ids of nodes to remove
2145 # @return True or False
2146 # @ingroup l2_modif_del
2147 def RemoveNodes(self, IDsOfNodes):
2148 return self.editor.RemoveNodes(IDsOfNodes)
2150 ## Add a node to the mesh by coordinates
2151 # @return Id of the new node
2152 # @ingroup l2_modif_add
2153 def AddNode(self, x, y, z):
2154 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2155 self.mesh.SetParameters(Parameters)
2156 return self.editor.AddNode( x, y, z)
2158 ## Creates a 0D element on a node with given number.
2159 # @param IDOfNode the ID of node for creation of the element.
2160 # @return the Id of the new 0D element
2161 # @ingroup l2_modif_add
2162 def Add0DElement(self, IDOfNode):
2163 return self.editor.Add0DElement(IDOfNode)
2165 ## Creates a linear or quadratic edge (this is determined
2166 # by the number of given nodes).
2167 # @param IDsOfNodes the list of node IDs for creation of the element.
2168 # The order of nodes in this list should correspond to the description
2169 # of MED. \n This description is located by the following link:
2170 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2171 # @return the Id of the new edge
2172 # @ingroup l2_modif_add
2173 def AddEdge(self, IDsOfNodes):
2174 return self.editor.AddEdge(IDsOfNodes)
2176 ## Creates a linear or quadratic face (this is determined
2177 # by the number of given nodes).
2178 # @param IDsOfNodes the list of node IDs for creation of the element.
2179 # The order of nodes in this list should correspond to the description
2180 # of MED. \n This description is located by the following link:
2181 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2182 # @return the Id of the new face
2183 # @ingroup l2_modif_add
2184 def AddFace(self, IDsOfNodes):
2185 return self.editor.AddFace(IDsOfNodes)
2187 ## Adds a polygonal face to the mesh by the list of node IDs
2188 # @param IdsOfNodes the list of node IDs for creation of the element.
2189 # @return the Id of the new face
2190 # @ingroup l2_modif_add
2191 def AddPolygonalFace(self, IdsOfNodes):
2192 return self.editor.AddPolygonalFace(IdsOfNodes)
2194 ## Creates both simple and quadratic volume (this is determined
2195 # by the number of given nodes).
2196 # @param IDsOfNodes the list of node IDs for creation of the element.
2197 # The order of nodes in this list should correspond to the description
2198 # of MED. \n This description is located by the following link:
2199 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2200 # @return the Id of the new volumic element
2201 # @ingroup l2_modif_add
2202 def AddVolume(self, IDsOfNodes):
2203 return self.editor.AddVolume(IDsOfNodes)
2205 ## Creates a volume of many faces, giving nodes for each face.
2206 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2207 # @param Quantities the list of integer values, Quantities[i]
2208 # gives the quantity of nodes in face number i.
2209 # @return the Id of the new volumic element
2210 # @ingroup l2_modif_add
2211 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2212 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2214 ## Creates a volume of many faces, giving the IDs of the existing faces.
2215 # @param IdsOfFaces the list of face IDs for volume creation.
2217 # Note: The created volume will refer only to the nodes
2218 # of the given faces, not to the faces themselves.
2219 # @return the Id of the new volumic element
2220 # @ingroup l2_modif_add
2221 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2222 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2225 ## @brief Binds a node to a vertex
2226 # @param NodeID a node ID
2227 # @param Vertex a vertex or vertex ID
2228 # @return True if succeed else raises an exception
2229 # @ingroup l2_modif_add
2230 def SetNodeOnVertex(self, NodeID, Vertex):
2231 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2232 VertexID = Vertex.GetSubShapeIndices()[0]
2236 self.editor.SetNodeOnVertex(NodeID, VertexID)
2237 except SALOME.SALOME_Exception, inst:
2238 raise ValueError, inst.details.text
2242 ## @brief Stores the node position on an edge
2243 # @param NodeID a node ID
2244 # @param Edge an edge or edge ID
2245 # @param paramOnEdge a parameter on the edge where the node is located
2246 # @return True if succeed else raises an exception
2247 # @ingroup l2_modif_add
2248 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2249 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2250 EdgeID = Edge.GetSubShapeIndices()[0]
2254 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2255 except SALOME.SALOME_Exception, inst:
2256 raise ValueError, inst.details.text
2259 ## @brief Stores node position on a face
2260 # @param NodeID a node ID
2261 # @param Face a face or face ID
2262 # @param u U parameter on the face where the node is located
2263 # @param v V parameter on the face where the node is located
2264 # @return True if succeed else raises an exception
2265 # @ingroup l2_modif_add
2266 def SetNodeOnFace(self, NodeID, Face, u, v):
2267 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2268 FaceID = Face.GetSubShapeIndices()[0]
2272 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2273 except SALOME.SALOME_Exception, inst:
2274 raise ValueError, inst.details.text
2277 ## @brief Binds a node to a solid
2278 # @param NodeID a node ID
2279 # @param Solid a solid or solid ID
2280 # @return True if succeed else raises an exception
2281 # @ingroup l2_modif_add
2282 def SetNodeInVolume(self, NodeID, Solid):
2283 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2284 SolidID = Solid.GetSubShapeIndices()[0]
2288 self.editor.SetNodeInVolume(NodeID, SolidID)
2289 except SALOME.SALOME_Exception, inst:
2290 raise ValueError, inst.details.text
2293 ## @brief Bind an element to a shape
2294 # @param ElementID an element ID
2295 # @param Shape a shape or shape ID
2296 # @return True if succeed else raises an exception
2297 # @ingroup l2_modif_add
2298 def SetMeshElementOnShape(self, ElementID, Shape):
2299 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2300 ShapeID = Shape.GetSubShapeIndices()[0]
2304 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2305 except SALOME.SALOME_Exception, inst:
2306 raise ValueError, inst.details.text
2310 ## Moves the node with the given id
2311 # @param NodeID the id of the node
2312 # @param x a new X coordinate
2313 # @param y a new Y coordinate
2314 # @param z a new Z coordinate
2315 # @return True if succeed else False
2316 # @ingroup l2_modif_movenode
2317 def MoveNode(self, NodeID, x, y, z):
2318 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2319 self.mesh.SetParameters(Parameters)
2320 return self.editor.MoveNode(NodeID, x, y, z)
2322 ## Finds the node closest to a point and moves it to a point location
2323 # @param x the X coordinate of a point
2324 # @param y the Y coordinate of a point
2325 # @param z the Z coordinate of a point
2326 # @param NodeID if specified (>0), the node with this ID is moved,
2327 # otherwise, the node closest to point (@a x,@a y,@a z) is moved
2328 # @return the ID of a node
2329 # @ingroup l2_modif_throughp
2330 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2331 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2332 self.mesh.SetParameters(Parameters)
2333 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2335 ## Finds the node closest to a point
2336 # @param x the X coordinate of a point
2337 # @param y the Y coordinate of a point
2338 # @param z the Z coordinate of a point
2339 # @return the ID of a node
2340 # @ingroup l2_modif_throughp
2341 def FindNodeClosestTo(self, x, y, z):
2342 #preview = self.mesh.GetMeshEditPreviewer()
2343 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2344 return self.editor.FindNodeClosestTo(x, y, z)
2346 ## Finds the elements where a point lays IN or ON
2347 # @param x the X coordinate of a point
2348 # @param y the Y coordinate of a point
2349 # @param z the Z coordinate of a point
2350 # @param elementType type of elements to find (SMESH.ALL type
2351 # means elements of any type excluding nodes and 0D elements)
2352 # @return list of IDs of found elements
2353 # @ingroup l2_modif_throughp
2354 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2355 return self.editor.FindElementsByPoint(x, y, z, elementType)
2357 # Return point state in a closed 2D mesh in terms of TopAbs_State enumeration.
2358 # TopAbs_UNKNOWN state means that either mesh is wrong or the analysis fails.
2360 def GetPointState(self, x, y, z):
2361 return self.editor.GetPointState(x, y, z)
2363 ## Finds the node closest to a point and moves it to a point location
2364 # @param x the X coordinate of a point
2365 # @param y the Y coordinate of a point
2366 # @param z the Z coordinate of a point
2367 # @return the ID of a moved node
2368 # @ingroup l2_modif_throughp
2369 def MeshToPassThroughAPoint(self, x, y, z):
2370 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2372 ## Replaces two neighbour triangles sharing Node1-Node2 link
2373 # with the triangles built on the same 4 nodes but having other common link.
2374 # @param NodeID1 the ID of the first node
2375 # @param NodeID2 the ID of the second node
2376 # @return false if proper faces were not found
2377 # @ingroup l2_modif_invdiag
2378 def InverseDiag(self, NodeID1, NodeID2):
2379 return self.editor.InverseDiag(NodeID1, NodeID2)
2381 ## Replaces two neighbour triangles sharing Node1-Node2 link
2382 # with a quadrangle built on the same 4 nodes.
2383 # @param NodeID1 the ID of the first node
2384 # @param NodeID2 the ID of the second node
2385 # @return false if proper faces were not found
2386 # @ingroup l2_modif_unitetri
2387 def DeleteDiag(self, NodeID1, NodeID2):
2388 return self.editor.DeleteDiag(NodeID1, NodeID2)
2390 ## Reorients elements by ids
2391 # @param IDsOfElements if undefined reorients all mesh elements
2392 # @return True if succeed else False
2393 # @ingroup l2_modif_changori
2394 def Reorient(self, IDsOfElements=None):
2395 if IDsOfElements == None:
2396 IDsOfElements = self.GetElementsId()
2397 return self.editor.Reorient(IDsOfElements)
2399 ## Reorients all elements of the object
2400 # @param theObject mesh, submesh or group
2401 # @return True if succeed else False
2402 # @ingroup l2_modif_changori
2403 def ReorientObject(self, theObject):
2404 if ( isinstance( theObject, Mesh )):
2405 theObject = theObject.GetMesh()
2406 return self.editor.ReorientObject(theObject)
2408 ## Fuses the neighbouring triangles into quadrangles.
2409 # @param IDsOfElements The triangles to be fused,
2410 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2411 # @param MaxAngle is the maximum angle between element normals at which the fusion
2412 # is still performed; theMaxAngle is mesured in radians.
2413 # Also it could be a name of variable which defines angle in degrees.
2414 # @return TRUE in case of success, FALSE otherwise.
2415 # @ingroup l2_modif_unitetri
2416 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2418 if isinstance(MaxAngle,str):
2420 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2422 MaxAngle = DegreesToRadians(MaxAngle)
2423 if IDsOfElements == []:
2424 IDsOfElements = self.GetElementsId()
2425 self.mesh.SetParameters(Parameters)
2427 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2428 Functor = theCriterion
2430 Functor = self.smeshpyD.GetFunctor(theCriterion)
2431 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2433 ## Fuses the neighbouring triangles of the object into quadrangles
2434 # @param theObject is mesh, submesh or group
2435 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2436 # @param MaxAngle a max angle between element normals at which the fusion
2437 # is still performed; theMaxAngle is mesured in radians.
2438 # @return TRUE in case of success, FALSE otherwise.
2439 # @ingroup l2_modif_unitetri
2440 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2441 if ( isinstance( theObject, Mesh )):
2442 theObject = theObject.GetMesh()
2443 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2445 ## Splits quadrangles into triangles.
2446 # @param IDsOfElements the faces to be splitted.
2447 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2448 # @return TRUE in case of success, FALSE otherwise.
2449 # @ingroup l2_modif_cutquadr
2450 def QuadToTri (self, IDsOfElements, theCriterion):
2451 if IDsOfElements == []:
2452 IDsOfElements = self.GetElementsId()
2453 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2455 ## Splits quadrangles into triangles.
2456 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2457 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2458 # @return TRUE in case of success, FALSE otherwise.
2459 # @ingroup l2_modif_cutquadr
2460 def QuadToTriObject (self, theObject, theCriterion):
2461 if ( isinstance( theObject, Mesh )):
2462 theObject = theObject.GetMesh()
2463 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2465 ## Splits quadrangles into triangles.
2466 # @param IDsOfElements the faces to be splitted
2467 # @param Diag13 is used to choose a diagonal for splitting.
2468 # @return TRUE in case of success, FALSE otherwise.
2469 # @ingroup l2_modif_cutquadr
2470 def SplitQuad (self, IDsOfElements, Diag13):
2471 if IDsOfElements == []:
2472 IDsOfElements = self.GetElementsId()
2473 return self.editor.SplitQuad(IDsOfElements, Diag13)
2475 ## Splits quadrangles into triangles.
2476 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2477 # @param Diag13 is used to choose a diagonal for splitting.
2478 # @return TRUE in case of success, FALSE otherwise.
2479 # @ingroup l2_modif_cutquadr
2480 def SplitQuadObject (self, theObject, Diag13):
2481 if ( isinstance( theObject, Mesh )):
2482 theObject = theObject.GetMesh()
2483 return self.editor.SplitQuadObject(theObject, Diag13)
2485 ## Finds a better splitting of the given quadrangle.
2486 # @param IDOfQuad the ID of the quadrangle to be splitted.
2487 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2488 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2489 # diagonal is better, 0 if error occurs.
2490 # @ingroup l2_modif_cutquadr
2491 def BestSplit (self, IDOfQuad, theCriterion):
2492 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2494 ## Splits volumic elements into tetrahedrons
2495 # @param elemIDs either list of elements or mesh or group or submesh
2496 # @param method flags passing splitting method:
2497 # 1 - split the hexahedron into 5 tetrahedrons
2498 # 2 - split the hexahedron into 6 tetrahedrons
2499 # @ingroup l2_modif_cutquadr
2500 def SplitVolumesIntoTetra(self, elemIDs, method=1 ):
2501 if isinstance( elemIDs, Mesh ):
2502 elemIDs = elemIDs.GetMesh()
2503 self.editor.SplitVolumesIntoTetra(elemIDs, method)
2505 ## Splits quadrangle faces near triangular facets of volumes
2507 # @ingroup l1_auxiliary
2508 def SplitQuadsNearTriangularFacets(self):
2509 faces_array = self.GetElementsByType(SMESH.FACE)
2510 for face_id in faces_array:
2511 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2512 quad_nodes = self.mesh.GetElemNodes(face_id)
2513 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2514 isVolumeFound = False
2515 for node1_elem in node1_elems:
2516 if not isVolumeFound:
2517 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2518 nb_nodes = self.GetElemNbNodes(node1_elem)
2519 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2520 volume_elem = node1_elem
2521 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2522 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2523 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2524 isVolumeFound = True
2525 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2526 self.SplitQuad([face_id], False) # diagonal 2-4
2527 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2528 isVolumeFound = True
2529 self.SplitQuad([face_id], True) # diagonal 1-3
2530 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2531 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2532 isVolumeFound = True
2533 self.SplitQuad([face_id], True) # diagonal 1-3
2535 ## @brief Splits hexahedrons into tetrahedrons.
2537 # This operation uses pattern mapping functionality for splitting.
2538 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2539 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2540 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2541 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2542 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2543 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2544 # @return TRUE in case of success, FALSE otherwise.
2545 # @ingroup l1_auxiliary
2546 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2547 # Pattern: 5.---------.6
2552 # (0,0,1) 4.---------.7 * |
2559 # (0,0,0) 0.---------.3
2560 pattern_tetra = "!!! Nb of points: \n 8 \n\
2570 !!! Indices of points of 6 tetras: \n\
2578 pattern = self.smeshpyD.GetPattern()
2579 isDone = pattern.LoadFromFile(pattern_tetra)
2581 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2584 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2585 isDone = pattern.MakeMesh(self.mesh, False, False)
2586 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2588 # split quafrangle faces near triangular facets of volumes
2589 self.SplitQuadsNearTriangularFacets()
2593 ## @brief Split hexahedrons into prisms.
2595 # Uses the pattern mapping functionality for splitting.
2596 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2597 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2598 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2599 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2600 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2601 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2602 # @return TRUE in case of success, FALSE otherwise.
2603 # @ingroup l1_auxiliary
2604 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2605 # Pattern: 5.---------.6
2610 # (0,0,1) 4.---------.7 |
2617 # (0,0,0) 0.---------.3
2618 pattern_prism = "!!! Nb of points: \n 8 \n\
2628 !!! Indices of points of 2 prisms: \n\
2632 pattern = self.smeshpyD.GetPattern()
2633 isDone = pattern.LoadFromFile(pattern_prism)
2635 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2638 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2639 isDone = pattern.MakeMesh(self.mesh, False, False)
2640 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2642 # Splits quafrangle faces near triangular facets of volumes
2643 self.SplitQuadsNearTriangularFacets()
2647 ## Smoothes elements
2648 # @param IDsOfElements the list if ids of elements to smooth
2649 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2650 # Note that nodes built on edges and boundary nodes are always fixed.
2651 # @param MaxNbOfIterations the maximum number of iterations
2652 # @param MaxAspectRatio varies in range [1.0, inf]
2653 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2654 # @return TRUE in case of success, FALSE otherwise.
2655 # @ingroup l2_modif_smooth
2656 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2657 MaxNbOfIterations, MaxAspectRatio, Method):
2658 if IDsOfElements == []:
2659 IDsOfElements = self.GetElementsId()
2660 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2661 self.mesh.SetParameters(Parameters)
2662 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2663 MaxNbOfIterations, MaxAspectRatio, Method)
2665 ## Smoothes elements which belong to the given object
2666 # @param theObject the object to smooth
2667 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2668 # Note that nodes built on edges and boundary nodes are always fixed.
2669 # @param MaxNbOfIterations the maximum number of iterations
2670 # @param MaxAspectRatio varies in range [1.0, inf]
2671 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2672 # @return TRUE in case of success, FALSE otherwise.
2673 # @ingroup l2_modif_smooth
2674 def SmoothObject(self, theObject, IDsOfFixedNodes,
2675 MaxNbOfIterations, MaxAspectRatio, Method):
2676 if ( isinstance( theObject, Mesh )):
2677 theObject = theObject.GetMesh()
2678 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2679 MaxNbOfIterations, MaxAspectRatio, Method)
2681 ## Parametrically smoothes the given elements
2682 # @param IDsOfElements the list if ids of elements to smooth
2683 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2684 # Note that nodes built on edges and boundary nodes are always fixed.
2685 # @param MaxNbOfIterations the maximum number of iterations
2686 # @param MaxAspectRatio varies in range [1.0, inf]
2687 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2688 # @return TRUE in case of success, FALSE otherwise.
2689 # @ingroup l2_modif_smooth
2690 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2691 MaxNbOfIterations, MaxAspectRatio, Method):
2692 if IDsOfElements == []:
2693 IDsOfElements = self.GetElementsId()
2694 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2695 self.mesh.SetParameters(Parameters)
2696 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2697 MaxNbOfIterations, MaxAspectRatio, Method)
2699 ## Parametrically smoothes the elements which belong to the given object
2700 # @param theObject the object to smooth
2701 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2702 # Note that nodes built on edges and boundary nodes are always fixed.
2703 # @param MaxNbOfIterations the maximum number of iterations
2704 # @param MaxAspectRatio varies in range [1.0, inf]
2705 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2706 # @return TRUE in case of success, FALSE otherwise.
2707 # @ingroup l2_modif_smooth
2708 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2709 MaxNbOfIterations, MaxAspectRatio, Method):
2710 if ( isinstance( theObject, Mesh )):
2711 theObject = theObject.GetMesh()
2712 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2713 MaxNbOfIterations, MaxAspectRatio, Method)
2715 ## Converts the mesh to quadratic, deletes old elements, replacing
2716 # them with quadratic with the same id.
2717 # @ingroup l2_modif_tofromqu
2718 def ConvertToQuadratic(self, theForce3d):
2719 self.editor.ConvertToQuadratic(theForce3d)
2721 ## Converts the mesh from quadratic to ordinary,
2722 # deletes old quadratic elements, \n replacing
2723 # them with ordinary mesh elements with the same id.
2724 # @return TRUE in case of success, FALSE otherwise.
2725 # @ingroup l2_modif_tofromqu
2726 def ConvertFromQuadratic(self):
2727 return self.editor.ConvertFromQuadratic()
2729 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2730 # @return TRUE if operation has been completed successfully, FALSE otherwise
2731 # @ingroup l2_modif_edit
2732 def Make2DMeshFrom3D(self):
2733 return self.editor. Make2DMeshFrom3D()
2735 ## Renumber mesh nodes
2736 # @ingroup l2_modif_renumber
2737 def RenumberNodes(self):
2738 self.editor.RenumberNodes()
2740 ## Renumber mesh elements
2741 # @ingroup l2_modif_renumber
2742 def RenumberElements(self):
2743 self.editor.RenumberElements()
2745 ## Generates new elements by rotation of the elements around the axis
2746 # @param IDsOfElements the list of ids of elements to sweep
2747 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2748 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2749 # @param NbOfSteps the number of steps
2750 # @param Tolerance tolerance
2751 # @param MakeGroups forces the generation of new groups from existing ones
2752 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2753 # of all steps, else - size of each step
2754 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2755 # @ingroup l2_modif_extrurev
2756 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2757 MakeGroups=False, TotalAngle=False):
2759 if isinstance(AngleInRadians,str):
2761 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2763 AngleInRadians = DegreesToRadians(AngleInRadians)
2764 if IDsOfElements == []:
2765 IDsOfElements = self.GetElementsId()
2766 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2767 Axis = self.smeshpyD.GetAxisStruct(Axis)
2768 Axis,AxisParameters = ParseAxisStruct(Axis)
2769 if TotalAngle and NbOfSteps:
2770 AngleInRadians /= NbOfSteps
2771 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2772 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2773 self.mesh.SetParameters(Parameters)
2775 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2776 AngleInRadians, NbOfSteps, Tolerance)
2777 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2780 ## Generates new elements by rotation of the elements of object around the axis
2781 # @param theObject object which elements should be sweeped
2782 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2783 # @param AngleInRadians the angle of Rotation
2784 # @param NbOfSteps number of steps
2785 # @param Tolerance tolerance
2786 # @param MakeGroups forces the generation of new groups from existing ones
2787 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2788 # of all steps, else - size of each step
2789 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2790 # @ingroup l2_modif_extrurev
2791 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2792 MakeGroups=False, TotalAngle=False):
2794 if isinstance(AngleInRadians,str):
2796 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2798 AngleInRadians = DegreesToRadians(AngleInRadians)
2799 if ( isinstance( theObject, Mesh )):
2800 theObject = theObject.GetMesh()
2801 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2802 Axis = self.smeshpyD.GetAxisStruct(Axis)
2803 Axis,AxisParameters = ParseAxisStruct(Axis)
2804 if TotalAngle and NbOfSteps:
2805 AngleInRadians /= NbOfSteps
2806 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2807 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2808 self.mesh.SetParameters(Parameters)
2810 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2811 NbOfSteps, Tolerance)
2812 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2815 ## Generates new elements by rotation of the elements of object around the axis
2816 # @param theObject object which elements should be sweeped
2817 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2818 # @param AngleInRadians the angle of Rotation
2819 # @param NbOfSteps number of steps
2820 # @param Tolerance tolerance
2821 # @param MakeGroups forces the generation of new groups from existing ones
2822 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2823 # of all steps, else - size of each step
2824 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2825 # @ingroup l2_modif_extrurev
2826 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2827 MakeGroups=False, TotalAngle=False):
2829 if isinstance(AngleInRadians,str):
2831 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2833 AngleInRadians = DegreesToRadians(AngleInRadians)
2834 if ( isinstance( theObject, Mesh )):
2835 theObject = theObject.GetMesh()
2836 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2837 Axis = self.smeshpyD.GetAxisStruct(Axis)
2838 Axis,AxisParameters = ParseAxisStruct(Axis)
2839 if TotalAngle and NbOfSteps:
2840 AngleInRadians /= NbOfSteps
2841 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2842 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2843 self.mesh.SetParameters(Parameters)
2845 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2846 NbOfSteps, Tolerance)
2847 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2850 ## Generates new elements by rotation of the elements of object around the axis
2851 # @param theObject object which elements should be sweeped
2852 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2853 # @param AngleInRadians the angle of Rotation
2854 # @param NbOfSteps number of steps
2855 # @param Tolerance tolerance
2856 # @param MakeGroups forces the generation of new groups from existing ones
2857 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2858 # of all steps, else - size of each step
2859 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2860 # @ingroup l2_modif_extrurev
2861 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2862 MakeGroups=False, TotalAngle=False):
2864 if isinstance(AngleInRadians,str):
2866 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2868 AngleInRadians = DegreesToRadians(AngleInRadians)
2869 if ( isinstance( theObject, Mesh )):
2870 theObject = theObject.GetMesh()
2871 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2872 Axis = self.smeshpyD.GetAxisStruct(Axis)
2873 Axis,AxisParameters = ParseAxisStruct(Axis)
2874 if TotalAngle and NbOfSteps:
2875 AngleInRadians /= NbOfSteps
2876 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2877 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2878 self.mesh.SetParameters(Parameters)
2880 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2881 NbOfSteps, Tolerance)
2882 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2885 ## Generates new elements by extrusion of the elements with given ids
2886 # @param IDsOfElements the list of elements ids for extrusion
2887 # @param StepVector vector, defining the direction and value of extrusion
2888 # @param NbOfSteps the number of steps
2889 # @param MakeGroups forces the generation of new groups from existing ones
2890 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2891 # @ingroup l2_modif_extrurev
2892 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2893 if IDsOfElements == []:
2894 IDsOfElements = self.GetElementsId()
2895 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2896 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2897 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2898 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2899 Parameters = StepVectorParameters + var_separator + Parameters
2900 self.mesh.SetParameters(Parameters)
2902 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2903 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2906 ## Generates new elements by extrusion of the elements with given ids
2907 # @param IDsOfElements is ids of elements
2908 # @param StepVector vector, defining the direction and value of extrusion
2909 # @param NbOfSteps the number of steps
2910 # @param ExtrFlags sets flags for extrusion
2911 # @param SewTolerance uses for comparing locations of nodes if flag
2912 # EXTRUSION_FLAG_SEW is set
2913 # @param MakeGroups forces the generation of new groups from existing ones
2914 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2915 # @ingroup l2_modif_extrurev
2916 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2917 ExtrFlags, SewTolerance, MakeGroups=False):
2918 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2919 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2921 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2922 ExtrFlags, SewTolerance)
2923 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2924 ExtrFlags, SewTolerance)
2927 ## Generates new elements by extrusion of the elements which belong to the object
2928 # @param theObject the object which elements should be processed
2929 # @param StepVector vector, defining the direction and value of extrusion
2930 # @param NbOfSteps the number of steps
2931 # @param MakeGroups forces the generation of new groups from existing ones
2932 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2933 # @ingroup l2_modif_extrurev
2934 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2935 if ( isinstance( theObject, Mesh )):
2936 theObject = theObject.GetMesh()
2937 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2938 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2939 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2940 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2941 Parameters = StepVectorParameters + var_separator + Parameters
2942 self.mesh.SetParameters(Parameters)
2944 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2945 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2948 ## Generates new elements by extrusion of the elements which belong to the object
2949 # @param theObject object which elements should be processed
2950 # @param StepVector vector, defining the direction and value of extrusion
2951 # @param NbOfSteps the number of steps
2952 # @param MakeGroups to generate new groups from existing ones
2953 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2954 # @ingroup l2_modif_extrurev
2955 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2956 if ( isinstance( theObject, Mesh )):
2957 theObject = theObject.GetMesh()
2958 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2959 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2960 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2961 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2962 Parameters = StepVectorParameters + var_separator + Parameters
2963 self.mesh.SetParameters(Parameters)
2965 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2966 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2969 ## Generates new elements by extrusion of the elements which belong to the object
2970 # @param theObject object which elements should be processed
2971 # @param StepVector vector, defining the direction and value of extrusion
2972 # @param NbOfSteps the number of steps
2973 # @param MakeGroups forces the generation of new groups from existing ones
2974 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2975 # @ingroup l2_modif_extrurev
2976 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2977 if ( isinstance( theObject, Mesh )):
2978 theObject = theObject.GetMesh()
2979 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2980 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2981 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2982 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2983 Parameters = StepVectorParameters + var_separator + Parameters
2984 self.mesh.SetParameters(Parameters)
2986 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2987 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2992 ## Generates new elements by extrusion of the given elements
2993 # The path of extrusion must be a meshed edge.
2994 # @param Base mesh or list of ids of elements for extrusion
2995 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2996 # @param NodeStart the start node from Path. Defines the direction of extrusion
2997 # @param HasAngles allows the shape to be rotated around the path
2998 # to get the resulting mesh in a helical fashion
2999 # @param Angles list of angles in radians
3000 # @param LinearVariation forces the computation of rotation angles as linear
3001 # variation of the given Angles along path steps
3002 # @param HasRefPoint allows using the reference point
3003 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3004 # The User can specify any point as the Reference Point.
3005 # @param MakeGroups forces the generation of new groups from existing ones
3006 # @param ElemType type of elements for extrusion (if param Base is a mesh)
3007 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3008 # only SMESH::Extrusion_Error otherwise
3009 # @ingroup l2_modif_extrurev
3010 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
3011 HasAngles, Angles, LinearVariation,
3012 HasRefPoint, RefPoint, MakeGroups, ElemType):
3013 Angles,AnglesParameters = ParseAngles(Angles)
3014 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3015 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3016 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3018 Parameters = AnglesParameters + var_separator + RefPointParameters
3019 self.mesh.SetParameters(Parameters)
3021 if isinstance(Base,list):
3023 if Base == []: IDsOfElements = self.GetElementsId()
3024 else: IDsOfElements = Base
3025 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
3026 HasAngles, Angles, LinearVariation,
3027 HasRefPoint, RefPoint, MakeGroups, ElemType)
3029 if isinstance(Base,Mesh):
3030 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
3031 HasAngles, Angles, LinearVariation,
3032 HasRefPoint, RefPoint, MakeGroups, ElemType)
3034 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
3037 ## Generates new elements by extrusion of the given elements
3038 # The path of extrusion must be a meshed edge.
3039 # @param IDsOfElements ids of elements
3040 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
3041 # @param PathShape shape(edge) defines the sub-mesh for the path
3042 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3043 # @param HasAngles allows the shape to be rotated around the path
3044 # to get the resulting mesh in a helical fashion
3045 # @param Angles list of angles in radians
3046 # @param HasRefPoint allows using the reference point
3047 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3048 # The User can specify any point as the Reference Point.
3049 # @param MakeGroups forces the generation of new groups from existing ones
3050 # @param LinearVariation forces the computation of rotation angles as linear
3051 # variation of the given Angles along path steps
3052 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3053 # only SMESH::Extrusion_Error otherwise
3054 # @ingroup l2_modif_extrurev
3055 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
3056 HasAngles, Angles, HasRefPoint, RefPoint,
3057 MakeGroups=False, LinearVariation=False):
3058 Angles,AnglesParameters = ParseAngles(Angles)
3059 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3060 if IDsOfElements == []:
3061 IDsOfElements = self.GetElementsId()
3062 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3063 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3065 if ( isinstance( PathMesh, Mesh )):
3066 PathMesh = PathMesh.GetMesh()
3067 if HasAngles and Angles and LinearVariation:
3068 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3070 Parameters = AnglesParameters + var_separator + RefPointParameters
3071 self.mesh.SetParameters(Parameters)
3073 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
3074 PathShape, NodeStart, HasAngles,
3075 Angles, HasRefPoint, RefPoint)
3076 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
3077 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
3079 ## Generates new elements by extrusion of the elements which belong to the object
3080 # The path of extrusion must be a meshed edge.
3081 # @param theObject the object which elements should be processed
3082 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3083 # @param PathShape shape(edge) defines the sub-mesh for the path
3084 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3085 # @param HasAngles allows the shape to be rotated around the path
3086 # to get the resulting mesh in a helical fashion
3087 # @param Angles list of angles
3088 # @param HasRefPoint allows using the reference point
3089 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3090 # The User can specify any point as the Reference Point.
3091 # @param MakeGroups forces the generation of new groups from existing ones
3092 # @param LinearVariation forces the computation of rotation angles as linear
3093 # variation of the given Angles along path steps
3094 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3095 # only SMESH::Extrusion_Error otherwise
3096 # @ingroup l2_modif_extrurev
3097 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
3098 HasAngles, Angles, HasRefPoint, RefPoint,
3099 MakeGroups=False, LinearVariation=False):
3100 Angles,AnglesParameters = ParseAngles(Angles)
3101 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3102 if ( isinstance( theObject, Mesh )):
3103 theObject = theObject.GetMesh()
3104 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3105 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3106 if ( isinstance( PathMesh, Mesh )):
3107 PathMesh = PathMesh.GetMesh()
3108 if HasAngles and Angles and LinearVariation:
3109 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3111 Parameters = AnglesParameters + var_separator + RefPointParameters
3112 self.mesh.SetParameters(Parameters)
3114 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
3115 PathShape, NodeStart, HasAngles,
3116 Angles, HasRefPoint, RefPoint)
3117 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
3118 NodeStart, HasAngles, Angles, HasRefPoint,
3121 ## Generates new elements by extrusion of the elements which belong to the object
3122 # The path of extrusion must be a meshed edge.
3123 # @param theObject the object which elements should be processed
3124 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3125 # @param PathShape shape(edge) defines the sub-mesh for the path
3126 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3127 # @param HasAngles allows the shape to be rotated around the path
3128 # to get the resulting mesh in a helical fashion
3129 # @param Angles list of angles
3130 # @param HasRefPoint allows using the reference point
3131 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3132 # The User can specify any point as the Reference Point.
3133 # @param MakeGroups forces the generation of new groups from existing ones
3134 # @param LinearVariation forces the computation of rotation angles as linear
3135 # variation of the given Angles along path steps
3136 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3137 # only SMESH::Extrusion_Error otherwise
3138 # @ingroup l2_modif_extrurev
3139 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
3140 HasAngles, Angles, HasRefPoint, RefPoint,
3141 MakeGroups=False, LinearVariation=False):
3142 Angles,AnglesParameters = ParseAngles(Angles)
3143 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3144 if ( isinstance( theObject, Mesh )):
3145 theObject = theObject.GetMesh()
3146 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3147 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3148 if ( isinstance( PathMesh, Mesh )):
3149 PathMesh = PathMesh.GetMesh()
3150 if HasAngles and Angles and LinearVariation:
3151 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3153 Parameters = AnglesParameters + var_separator + RefPointParameters
3154 self.mesh.SetParameters(Parameters)
3156 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
3157 PathShape, NodeStart, HasAngles,
3158 Angles, HasRefPoint, RefPoint)
3159 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
3160 NodeStart, HasAngles, Angles, HasRefPoint,
3163 ## Generates new elements by extrusion of the elements which belong to the object
3164 # The path of extrusion must be a meshed edge.
3165 # @param theObject the object which elements should be processed
3166 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
3167 # @param PathShape shape(edge) defines the sub-mesh for the path
3168 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
3169 # @param HasAngles allows the shape to be rotated around the path
3170 # to get the resulting mesh in a helical fashion
3171 # @param Angles list of angles
3172 # @param HasRefPoint allows using the reference point
3173 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
3174 # The User can specify any point as the Reference Point.
3175 # @param MakeGroups forces the generation of new groups from existing ones
3176 # @param LinearVariation forces the computation of rotation angles as linear
3177 # variation of the given Angles along path steps
3178 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
3179 # only SMESH::Extrusion_Error otherwise
3180 # @ingroup l2_modif_extrurev
3181 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
3182 HasAngles, Angles, HasRefPoint, RefPoint,
3183 MakeGroups=False, LinearVariation=False):
3184 Angles,AnglesParameters = ParseAngles(Angles)
3185 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
3186 if ( isinstance( theObject, Mesh )):
3187 theObject = theObject.GetMesh()
3188 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
3189 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
3190 if ( isinstance( PathMesh, Mesh )):
3191 PathMesh = PathMesh.GetMesh()
3192 if HasAngles and Angles and LinearVariation:
3193 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
3195 Parameters = AnglesParameters + var_separator + RefPointParameters
3196 self.mesh.SetParameters(Parameters)
3198 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
3199 PathShape, NodeStart, HasAngles,
3200 Angles, HasRefPoint, RefPoint)
3201 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
3202 NodeStart, HasAngles, Angles, HasRefPoint,
3205 ## Creates a symmetrical copy of mesh elements
3206 # @param IDsOfElements list of elements ids
3207 # @param Mirror is AxisStruct or geom object(point, line, plane)
3208 # @param theMirrorType is POINT, AXIS or PLANE
3209 # If the Mirror is a geom object this parameter is unnecessary
3210 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
3211 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3212 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3213 # @ingroup l2_modif_trsf
3214 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3215 if IDsOfElements == []:
3216 IDsOfElements = self.GetElementsId()
3217 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3218 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3219 Mirror,Parameters = ParseAxisStruct(Mirror)
3220 self.mesh.SetParameters(Parameters)
3221 if Copy and MakeGroups:
3222 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3223 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3226 ## Creates a new mesh by a symmetrical copy of mesh elements
3227 # @param IDsOfElements the list of elements ids
3228 # @param Mirror is AxisStruct or geom object (point, line, plane)
3229 # @param theMirrorType is POINT, AXIS or PLANE
3230 # If the Mirror is a geom object this parameter is unnecessary
3231 # @param MakeGroups to generate new groups from existing ones
3232 # @param NewMeshName a name of the new mesh to create
3233 # @return instance of Mesh class
3234 # @ingroup l2_modif_trsf
3235 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3236 if IDsOfElements == []:
3237 IDsOfElements = self.GetElementsId()
3238 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3239 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3240 Mirror,Parameters = ParseAxisStruct(Mirror)
3241 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3242 MakeGroups, NewMeshName)
3243 mesh.SetParameters(Parameters)
3244 return Mesh(self.smeshpyD,self.geompyD,mesh)
3246 ## Creates a symmetrical copy of the object
3247 # @param theObject mesh, submesh or group
3248 # @param Mirror AxisStruct or geom object (point, line, plane)
3249 # @param theMirrorType is POINT, AXIS or PLANE
3250 # If the Mirror is a geom object this parameter is unnecessary
3251 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3252 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3253 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3254 # @ingroup l2_modif_trsf
3255 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3256 if ( isinstance( theObject, Mesh )):
3257 theObject = theObject.GetMesh()
3258 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3259 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3260 Mirror,Parameters = ParseAxisStruct(Mirror)
3261 self.mesh.SetParameters(Parameters)
3262 if Copy and MakeGroups:
3263 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3264 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3267 ## Creates a new mesh by a symmetrical copy of the object
3268 # @param theObject mesh, submesh or group
3269 # @param Mirror AxisStruct or geom object (point, line, plane)
3270 # @param theMirrorType POINT, AXIS or PLANE
3271 # If the Mirror is a geom object this parameter is unnecessary
3272 # @param MakeGroups forces the generation of new groups from existing ones
3273 # @param NewMeshName the name of the new mesh to create
3274 # @return instance of Mesh class
3275 # @ingroup l2_modif_trsf
3276 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3277 if ( isinstance( theObject, Mesh )):
3278 theObject = theObject.GetMesh()
3279 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3280 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3281 Mirror,Parameters = ParseAxisStruct(Mirror)
3282 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3283 MakeGroups, NewMeshName)
3284 mesh.SetParameters(Parameters)
3285 return Mesh( self.smeshpyD,self.geompyD,mesh )
3287 ## Translates the elements
3288 # @param IDsOfElements list of elements ids
3289 # @param Vector the direction of translation (DirStruct or vector)
3290 # @param Copy allows copying the translated elements
3291 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3292 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3293 # @ingroup l2_modif_trsf
3294 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3295 if IDsOfElements == []:
3296 IDsOfElements = self.GetElementsId()
3297 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3298 Vector = self.smeshpyD.GetDirStruct(Vector)
3299 Vector,Parameters = ParseDirStruct(Vector)
3300 self.mesh.SetParameters(Parameters)
3301 if Copy and MakeGroups:
3302 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3303 self.editor.Translate(IDsOfElements, Vector, Copy)
3306 ## Creates a new mesh of translated elements
3307 # @param IDsOfElements list of elements ids
3308 # @param Vector the direction of translation (DirStruct or vector)
3309 # @param MakeGroups forces the generation of new groups from existing ones
3310 # @param NewMeshName the name of the newly created mesh
3311 # @return instance of Mesh class
3312 # @ingroup l2_modif_trsf
3313 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3314 if IDsOfElements == []:
3315 IDsOfElements = self.GetElementsId()
3316 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3317 Vector = self.smeshpyD.GetDirStruct(Vector)
3318 Vector,Parameters = ParseDirStruct(Vector)
3319 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3320 mesh.SetParameters(Parameters)
3321 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3323 ## Translates the object
3324 # @param theObject the object to translate (mesh, submesh, or group)
3325 # @param Vector direction of translation (DirStruct or geom vector)
3326 # @param Copy allows copying the translated elements
3327 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3328 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3329 # @ingroup l2_modif_trsf
3330 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3331 if ( isinstance( theObject, Mesh )):
3332 theObject = theObject.GetMesh()
3333 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3334 Vector = self.smeshpyD.GetDirStruct(Vector)
3335 Vector,Parameters = ParseDirStruct(Vector)
3336 self.mesh.SetParameters(Parameters)
3337 if Copy and MakeGroups:
3338 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3339 self.editor.TranslateObject(theObject, Vector, Copy)
3342 ## Creates a new mesh from the translated object
3343 # @param theObject the object to translate (mesh, submesh, or group)
3344 # @param Vector the direction of translation (DirStruct or geom vector)
3345 # @param MakeGroups forces the generation of new groups from existing ones
3346 # @param NewMeshName the name of the newly created mesh
3347 # @return instance of Mesh class
3348 # @ingroup l2_modif_trsf
3349 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3350 if (isinstance(theObject, Mesh)):
3351 theObject = theObject.GetMesh()
3352 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3353 Vector = self.smeshpyD.GetDirStruct(Vector)
3354 Vector,Parameters = ParseDirStruct(Vector)
3355 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3356 mesh.SetParameters(Parameters)
3357 return Mesh( self.smeshpyD, self.geompyD, mesh )
3361 ## Scales the object
3362 # @param theObject - the object to translate (mesh, submesh, or group)
3363 # @param thePoint - base point for scale
3364 # @param theScaleFact - scale factors for axises
3365 # @param Copy - allows copying the translated elements
3366 # @param MakeGroups - forces the generation of new groups from existing
3368 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True,
3369 # empty list otherwise
3370 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
3371 if ( isinstance( theObject, Mesh )):
3372 theObject = theObject.GetMesh()
3373 if ( isinstance( theObject, list )):
3374 theObject = self.editor.MakeIDSource(theObject)
3376 thePoint, Parameters = ParsePointStruct(thePoint)
3377 self.mesh.SetParameters(Parameters)
3379 if Copy and MakeGroups:
3380 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
3381 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
3384 ## Creates a new mesh from the translated object
3385 # @param theObject - the object to translate (mesh, submesh, or group)
3386 # @param thePoint - base point for scale
3387 # @param theScaleFact - scale factors for axises
3388 # @param MakeGroups - forces the generation of new groups from existing ones
3389 # @param NewMeshName - the name of the newly created mesh
3390 # @return instance of Mesh class
3391 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
3392 if (isinstance(theObject, Mesh)):
3393 theObject = theObject.GetMesh()
3394 if ( isinstance( theObject, list )):
3395 theObject = self.editor.MakeIDSource(theObject)
3397 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
3398 MakeGroups, NewMeshName)
3399 #mesh.SetParameters(Parameters)
3400 return Mesh( self.smeshpyD, self.geompyD, mesh )
3404 ## Rotates the elements
3405 # @param IDsOfElements list of elements ids
3406 # @param Axis the axis of rotation (AxisStruct or geom line)
3407 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3408 # @param Copy allows copying the rotated elements
3409 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3410 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3411 # @ingroup l2_modif_trsf
3412 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3414 if isinstance(AngleInRadians,str):
3416 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3418 AngleInRadians = DegreesToRadians(AngleInRadians)
3419 if IDsOfElements == []:
3420 IDsOfElements = self.GetElementsId()
3421 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3422 Axis = self.smeshpyD.GetAxisStruct(Axis)
3423 Axis,AxisParameters = ParseAxisStruct(Axis)
3424 Parameters = AxisParameters + var_separator + Parameters
3425 self.mesh.SetParameters(Parameters)
3426 if Copy and MakeGroups:
3427 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3428 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3431 ## Creates a new mesh of rotated elements
3432 # @param IDsOfElements list of element ids
3433 # @param Axis the axis of rotation (AxisStruct or geom line)
3434 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3435 # @param MakeGroups forces the generation of new groups from existing ones
3436 # @param NewMeshName the name of the newly created mesh
3437 # @return instance of Mesh class
3438 # @ingroup l2_modif_trsf
3439 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3441 if isinstance(AngleInRadians,str):
3443 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3445 AngleInRadians = DegreesToRadians(AngleInRadians)
3446 if IDsOfElements == []:
3447 IDsOfElements = self.GetElementsId()
3448 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3449 Axis = self.smeshpyD.GetAxisStruct(Axis)
3450 Axis,AxisParameters = ParseAxisStruct(Axis)
3451 Parameters = AxisParameters + var_separator + Parameters
3452 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3453 MakeGroups, NewMeshName)
3454 mesh.SetParameters(Parameters)
3455 return Mesh( self.smeshpyD, self.geompyD, mesh )
3457 ## Rotates the object
3458 # @param theObject the object to rotate( mesh, submesh, or group)
3459 # @param Axis the axis of rotation (AxisStruct or geom line)
3460 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3461 # @param Copy allows copying the rotated elements
3462 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3463 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3464 # @ingroup l2_modif_trsf
3465 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3467 if isinstance(AngleInRadians,str):
3469 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3471 AngleInRadians = DegreesToRadians(AngleInRadians)
3472 if (isinstance(theObject, Mesh)):
3473 theObject = theObject.GetMesh()
3474 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3475 Axis = self.smeshpyD.GetAxisStruct(Axis)
3476 Axis,AxisParameters = ParseAxisStruct(Axis)
3477 Parameters = AxisParameters + ":" + Parameters
3478 self.mesh.SetParameters(Parameters)
3479 if Copy and MakeGroups:
3480 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3481 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3484 ## Creates a new mesh from the rotated object
3485 # @param theObject the object to rotate (mesh, submesh, or group)
3486 # @param Axis the axis of rotation (AxisStruct or geom line)
3487 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3488 # @param MakeGroups forces the generation of new groups from existing ones
3489 # @param NewMeshName the name of the newly created mesh
3490 # @return instance of Mesh class
3491 # @ingroup l2_modif_trsf
3492 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3494 if isinstance(AngleInRadians,str):
3496 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3498 AngleInRadians = DegreesToRadians(AngleInRadians)
3499 if (isinstance( theObject, Mesh )):
3500 theObject = theObject.GetMesh()
3501 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3502 Axis = self.smeshpyD.GetAxisStruct(Axis)
3503 Axis,AxisParameters = ParseAxisStruct(Axis)
3504 Parameters = AxisParameters + ":" + Parameters
3505 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3506 MakeGroups, NewMeshName)
3507 mesh.SetParameters(Parameters)
3508 return Mesh( self.smeshpyD, self.geompyD, mesh )
3510 ## Finds groups of ajacent nodes within Tolerance.
3511 # @param Tolerance the value of tolerance
3512 # @return the list of groups of nodes
3513 # @ingroup l2_modif_trsf
3514 def FindCoincidentNodes (self, Tolerance):
3515 return self.editor.FindCoincidentNodes(Tolerance)
3517 ## Finds groups of ajacent nodes within Tolerance.
3518 # @param Tolerance the value of tolerance
3519 # @param SubMeshOrGroup SubMesh or Group
3520 # @return the list of groups of nodes
3521 # @ingroup l2_modif_trsf
3522 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3523 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3526 # @param GroupsOfNodes the list of groups of nodes
3527 # @ingroup l2_modif_trsf
3528 def MergeNodes (self, GroupsOfNodes):
3529 self.editor.MergeNodes(GroupsOfNodes)
3531 ## Finds the elements built on the same nodes.
3532 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3533 # @return a list of groups of equal elements
3534 # @ingroup l2_modif_trsf
3535 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3536 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
3537 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
3538 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3540 ## Merges elements in each given group.
3541 # @param GroupsOfElementsID groups of elements for merging
3542 # @ingroup l2_modif_trsf
3543 def MergeElements(self, GroupsOfElementsID):
3544 self.editor.MergeElements(GroupsOfElementsID)
3546 ## Leaves one element and removes all other elements built on the same nodes.
3547 # @ingroup l2_modif_trsf
3548 def MergeEqualElements(self):
3549 self.editor.MergeEqualElements()
3551 ## Sews free borders
3552 # @return SMESH::Sew_Error
3553 # @ingroup l2_modif_trsf
3554 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3555 FirstNodeID2, SecondNodeID2, LastNodeID2,
3556 CreatePolygons, CreatePolyedrs):
3557 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3558 FirstNodeID2, SecondNodeID2, LastNodeID2,
3559 CreatePolygons, CreatePolyedrs)
3561 ## Sews conform free borders
3562 # @return SMESH::Sew_Error
3563 # @ingroup l2_modif_trsf
3564 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3565 FirstNodeID2, SecondNodeID2):
3566 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3567 FirstNodeID2, SecondNodeID2)
3569 ## Sews border to side
3570 # @return SMESH::Sew_Error
3571 # @ingroup l2_modif_trsf
3572 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3573 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3574 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3575 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3577 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3578 # merged with the nodes of elements of Side2.
3579 # The number of elements in theSide1 and in theSide2 must be
3580 # equal and they should have similar nodal connectivity.
3581 # The nodes to merge should belong to side borders and
3582 # the first node should be linked to the second.
3583 # @return SMESH::Sew_Error
3584 # @ingroup l2_modif_trsf
3585 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3586 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3587 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3588 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3589 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3590 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3592 ## Sets new nodes for the given element.
3593 # @param ide the element id
3594 # @param newIDs nodes ids
3595 # @return If the number of nodes does not correspond to the type of element - returns false
3596 # @ingroup l2_modif_edit
3597 def ChangeElemNodes(self, ide, newIDs):
3598 return self.editor.ChangeElemNodes(ide, newIDs)
3600 ## If during the last operation of MeshEditor some nodes were
3601 # created, this method returns the list of their IDs, \n
3602 # if new nodes were not created - returns empty list
3603 # @return the list of integer values (can be empty)
3604 # @ingroup l1_auxiliary
3605 def GetLastCreatedNodes(self):
3606 return self.editor.GetLastCreatedNodes()
3608 ## If during the last operation of MeshEditor some elements were
3609 # created this method returns the list of their IDs, \n
3610 # if new elements were not created - returns empty list
3611 # @return the list of integer values (can be empty)
3612 # @ingroup l1_auxiliary
3613 def GetLastCreatedElems(self):
3614 return self.editor.GetLastCreatedElems()
3616 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3617 # @param theNodes identifiers of nodes to be doubled
3618 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
3619 # nodes. If list of element identifiers is empty then nodes are doubled but
3620 # they not assigned to elements
3621 # @return TRUE if operation has been completed successfully, FALSE otherwise
3622 # @ingroup l2_modif_edit
3623 def DoubleNodes(self, theNodes, theModifiedElems):
3624 return self.editor.DoubleNodes(theNodes, theModifiedElems)
3626 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3627 # This method provided for convenience works as DoubleNodes() described above.
3628 # @param theNodeId identifiers of node to be doubled
3629 # @param theModifiedElems identifiers of elements to be updated
3630 # @return TRUE if operation has been completed successfully, FALSE otherwise
3631 # @ingroup l2_modif_edit
3632 def DoubleNode(self, theNodeId, theModifiedElems):
3633 return self.editor.DoubleNode(theNodeId, theModifiedElems)
3635 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3636 # This method provided for convenience works as DoubleNodes() described above.
3637 # @param theNodes group of nodes to be doubled
3638 # @param theModifiedElems group of elements to be updated.
3639 # @return TRUE if operation has been completed successfully, FALSE otherwise
3640 # @ingroup l2_modif_edit
3641 def DoubleNodeGroup(self, theNodes, theModifiedElems):
3642 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
3644 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3645 # This method provided for convenience works as DoubleNodes() described above.
3646 # @param theNodes list of groups of nodes to be doubled
3647 # @param theModifiedElems list of groups of elements to be updated.
3648 # @return TRUE if operation has been completed successfully, FALSE otherwise
3649 # @ingroup l2_modif_edit
3650 def DoubleNodeGroups(self, theNodes, theModifiedElems):
3651 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
3653 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3654 # @param theElems - the list of elements (edges or faces) to be replicated
3655 # The nodes for duplication could be found from these elements
3656 # @param theNodesNot - list of nodes to NOT replicate
3657 # @param theAffectedElems - the list of elements (cells and edges) to which the
3658 # replicated nodes should be associated to.
3659 # @return TRUE if operation has been completed successfully, FALSE otherwise
3660 # @ingroup l2_modif_edit
3661 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
3662 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
3664 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3665 # @param theElems - the list of elements (edges or faces) to be replicated
3666 # The nodes for duplication could be found from these elements
3667 # @param theNodesNot - list of nodes to NOT replicate
3668 # @param theShape - shape to detect affected elements (element which geometric center
3669 # located on or inside shape).
3670 # The replicated nodes should be associated to affected elements.
3671 # @return TRUE if operation has been completed successfully, FALSE otherwise
3672 # @ingroup l2_modif_edit
3673 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
3674 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
3676 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3677 # This method provided for convenience works as DoubleNodes() described above.
3678 # @param theElems - group of of elements (edges or faces) to be replicated
3679 # @param theNodesNot - group of nodes not to replicated
3680 # @param theAffectedElems - group of elements to which the replicated nodes
3681 # should be associated to.
3682 # @ingroup l2_modif_edit
3683 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems):
3684 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
3686 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3687 # This method provided for convenience works as DoubleNodes() described above.
3688 # @param theElems - group of of elements (edges or faces) to be replicated
3689 # @param theNodesNot - group of nodes not to replicated
3690 # @param theShape - shape to detect affected elements (element which geometric center
3691 # located on or inside shape).
3692 # The replicated nodes should be associated to affected elements.
3693 # @ingroup l2_modif_edit
3694 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
3695 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
3697 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3698 # This method provided for convenience works as DoubleNodes() described above.
3699 # @param theElems - list of groups of elements (edges or faces) to be replicated
3700 # @param theNodesNot - list of groups of nodes not to replicated
3701 # @param theAffectedElems - group of elements to which the replicated nodes
3702 # should be associated to.
3703 # @return TRUE if operation has been completed successfully, FALSE otherwise
3704 # @ingroup l2_modif_edit
3705 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems):
3706 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
3708 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3709 # This method provided for convenience works as DoubleNodes() described above.
3710 # @param theElems - list of groups of elements (edges or faces) to be replicated
3711 # @param theNodesNot - list of groups of nodes not to replicated
3712 # @param theShape - shape to detect affected elements (element which geometric center
3713 # located on or inside shape).
3714 # The replicated nodes should be associated to affected elements.
3715 # @return TRUE if operation has been completed successfully, FALSE otherwise
3716 # @ingroup l2_modif_edit
3717 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
3718 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
3720 ## The mother class to define algorithm, it is not recommended to use it directly.
3723 # @ingroup l2_algorithms
3724 class Mesh_Algorithm:
3725 # @class Mesh_Algorithm
3726 # @brief Class Mesh_Algorithm
3728 #def __init__(self,smesh):
3736 ## Finds a hypothesis in the study by its type name and parameters.
3737 # Finds only the hypotheses created in smeshpyD engine.
3738 # @return SMESH.SMESH_Hypothesis
3739 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3740 study = smeshpyD.GetCurrentStudy()
3741 #to do: find component by smeshpyD object, not by its data type
3742 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3743 if scomp is not None:
3744 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3745 # Check if the root label of the hypotheses exists
3746 if res and hypRoot is not None:
3747 iter = study.NewChildIterator(hypRoot)
3748 # Check all published hypotheses
3750 hypo_so_i = iter.Value()
3751 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3752 if attr is not None:
3753 anIOR = attr.Value()
3754 hypo_o_i = salome.orb.string_to_object(anIOR)
3755 if hypo_o_i is not None:
3756 # Check if this is a hypothesis
3757 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3758 if hypo_i is not None:
3759 # Check if the hypothesis belongs to current engine
3760 if smeshpyD.GetObjectId(hypo_i) > 0:
3761 # Check if this is the required hypothesis
3762 if hypo_i.GetName() == hypname:
3764 if CompareMethod(hypo_i, args):
3778 ## Finds the algorithm in the study by its type name.
3779 # Finds only the algorithms, which have been created in smeshpyD engine.
3780 # @return SMESH.SMESH_Algo
3781 def FindAlgorithm (self, algoname, smeshpyD):
3782 study = smeshpyD.GetCurrentStudy()
3783 #to do: find component by smeshpyD object, not by its data type
3784 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3785 if scomp is not None:
3786 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3787 # Check if the root label of the algorithms exists
3788 if res and hypRoot is not None:
3789 iter = study.NewChildIterator(hypRoot)
3790 # Check all published algorithms
3792 algo_so_i = iter.Value()
3793 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3794 if attr is not None:
3795 anIOR = attr.Value()
3796 algo_o_i = salome.orb.string_to_object(anIOR)
3797 if algo_o_i is not None:
3798 # Check if this is an algorithm
3799 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3800 if algo_i is not None:
3801 # Checks if the algorithm belongs to the current engine
3802 if smeshpyD.GetObjectId(algo_i) > 0:
3803 # Check if this is the required algorithm
3804 if algo_i.GetName() == algoname:
3817 ## If the algorithm is global, returns 0; \n
3818 # else returns the submesh associated to this algorithm.
3819 def GetSubMesh(self):
3822 ## Returns the wrapped mesher.
3823 def GetAlgorithm(self):
3826 ## Gets the list of hypothesis that can be used with this algorithm
3827 def GetCompatibleHypothesis(self):
3830 mylist = self.algo.GetCompatibleHypothesis()
3833 ## Gets the name of the algorithm
3837 ## Sets the name to the algorithm
3838 def SetName(self, name):
3839 self.mesh.smeshpyD.SetName(self.algo, name)
3841 ## Gets the id of the algorithm
3843 return self.algo.GetId()
3846 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3848 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3849 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3851 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3853 self.Assign(algo, mesh, geom)
3857 def Assign(self, algo, mesh, geom):
3859 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3868 name = GetName(geom)
3871 name = mesh.geompyD.SubShapeName(geom, piece)
3872 mesh.geompyD.addToStudyInFather(piece, geom, name)
3874 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3877 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3878 TreatHypoStatus( status, algo.GetName(), name, True )
3880 def CompareHyp (self, hyp, args):
3881 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3884 def CompareEqualHyp (self, hyp, args):
3888 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3889 UseExisting=0, CompareMethod=""):
3892 if CompareMethod == "": CompareMethod = self.CompareHyp
3893 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3896 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3902 a = a + s + str(args[i])
3906 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3908 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3909 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3912 ## Returns entry of the shape to mesh in the study
3913 def MainShapeEntry(self):
3915 if not self.mesh or not self.mesh.GetMesh(): return entry
3916 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3917 study = self.mesh.smeshpyD.GetCurrentStudy()
3918 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3919 sobj = study.FindObjectIOR(ior)
3920 if sobj: entry = sobj.GetID()
3921 if not entry: return ""
3924 # Public class: Mesh_Segment
3925 # --------------------------
3927 ## Class to define a segment 1D algorithm for discretization
3930 # @ingroup l3_algos_basic
3931 class Mesh_Segment(Mesh_Algorithm):
3933 ## Private constructor.
3934 def __init__(self, mesh, geom=0):
3935 Mesh_Algorithm.__init__(self)
3936 self.Create(mesh, geom, "Regular_1D")
3938 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3939 # @param l for the length of segments that cut an edge
3940 # @param UseExisting if ==true - searches for an existing hypothesis created with
3941 # the same parameters, else (default) - creates a new one
3942 # @param p precision, used for calculation of the number of segments.
3943 # The precision should be a positive, meaningful value within the range [0,1].
3944 # In general, the number of segments is calculated with the formula:
3945 # nb = ceil((edge_length / l) - p)
3946 # Function ceil rounds its argument to the higher integer.
3947 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3948 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3949 # p=1 means rounding of (edge_length / l) to the lower integer.
3950 # Default value is 1e-07.
3951 # @return an instance of StdMeshers_LocalLength hypothesis
3952 # @ingroup l3_hypos_1dhyps
3953 def LocalLength(self, l, UseExisting=0, p=1e-07):
3954 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3955 CompareMethod=self.CompareLocalLength)
3961 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3962 def CompareLocalLength(self, hyp, args):
3963 if IsEqual(hyp.GetLength(), args[0]):
3964 return IsEqual(hyp.GetPrecision(), args[1])
3967 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3968 # @param length is optional maximal allowed length of segment, if it is omitted
3969 # the preestimated length is used that depends on geometry size
3970 # @param UseExisting if ==true - searches for an existing hypothesis created with
3971 # the same parameters, else (default) - create a new one
3972 # @return an instance of StdMeshers_MaxLength hypothesis
3973 # @ingroup l3_hypos_1dhyps
3974 def MaxSize(self, length=0.0, UseExisting=0):
3975 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3978 hyp.SetLength(length)
3980 # set preestimated length
3981 gen = self.mesh.smeshpyD
3982 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3983 self.mesh.GetMesh(), self.mesh.GetShape(),
3985 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3987 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3990 hyp.SetUsePreestimatedLength( length == 0.0 )
3993 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3994 # @param n for the number of segments that cut an edge
3995 # @param s for the scale factor (optional)
3996 # @param reversedEdges is a list of edges to mesh using reversed orientation
3997 # @param UseExisting if ==true - searches for an existing hypothesis created with
3998 # the same parameters, else (default) - create a new one
3999 # @return an instance of StdMeshers_NumberOfSegments hypothesis
4000 # @ingroup l3_hypos_1dhyps
4001 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
4002 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4003 reversedEdges, UseExisting = [], reversedEdges
4004 entry = self.MainShapeEntry()
4006 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
4007 UseExisting=UseExisting,
4008 CompareMethod=self.CompareNumberOfSegments)
4010 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
4011 UseExisting=UseExisting,
4012 CompareMethod=self.CompareNumberOfSegments)
4013 hyp.SetDistrType( 1 )
4014 hyp.SetScaleFactor(s)
4015 hyp.SetNumberOfSegments(n)
4016 hyp.SetReversedEdges( reversedEdges )
4017 hyp.SetObjectEntry( entry )
4021 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
4022 def CompareNumberOfSegments(self, hyp, args):
4023 if hyp.GetNumberOfSegments() == args[0]:
4025 if hyp.GetReversedEdges() == args[1]:
4026 if not args[1] or hyp.GetObjectEntry() == args[2]:
4029 if hyp.GetReversedEdges() == args[2]:
4030 if not args[2] or hyp.GetObjectEntry() == args[3]:
4031 if hyp.GetDistrType() == 1:
4032 if IsEqual(hyp.GetScaleFactor(), args[1]):
4036 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
4037 # @param start defines the length of the first segment
4038 # @param end defines the length of the last segment
4039 # @param reversedEdges is a list of edges to mesh using reversed orientation
4040 # @param UseExisting if ==true - searches for an existing hypothesis created with
4041 # the same parameters, else (default) - creates a new one
4042 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4043 # @ingroup l3_hypos_1dhyps
4044 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
4045 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4046 reversedEdges, UseExisting = [], reversedEdges
4047 entry = self.MainShapeEntry()
4048 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
4049 UseExisting=UseExisting,
4050 CompareMethod=self.CompareArithmetic1D)
4051 hyp.SetStartLength(start)
4052 hyp.SetEndLength(end)
4053 hyp.SetReversedEdges( reversedEdges )
4054 hyp.SetObjectEntry( entry )
4058 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
4059 def CompareArithmetic1D(self, hyp, args):
4060 if IsEqual(hyp.GetLength(1), args[0]):
4061 if IsEqual(hyp.GetLength(0), args[1]):
4062 if hyp.GetReversedEdges() == args[2]:
4063 if not args[2] or hyp.GetObjectEntry() == args[3]:
4068 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
4069 # on curve from 0 to 1 (additionally it is neecessary to check
4070 # orientation of edges and create list of reversed edges if it is
4071 # needed) and sets numbers of segments between given points (default
4072 # values are equals 1
4073 # @param points defines the list of parameters on curve
4074 # @param nbSegs defines the list of numbers of segments
4075 # @param reversedEdges is a list of edges to mesh using reversed orientation
4076 # @param UseExisting if ==true - searches for an existing hypothesis created with
4077 # the same parameters, else (default) - creates a new one
4078 # @return an instance of StdMeshers_Arithmetic1D hypothesis
4079 # @ingroup l3_hypos_1dhyps
4080 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
4081 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4082 reversedEdges, UseExisting = [], reversedEdges
4083 if reversedEdges and isinstance( reversedEdges[0], geompyDC.GEOM._objref_GEOM_Object ):
4084 for i in range( len( reversedEdges )):
4085 reversedEdges[i] = self.mesh.geompyD.GetSubShapeID(self.mesh.geom, reversedEdges[i] )
4086 entry = self.MainShapeEntry()
4087 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
4088 UseExisting=UseExisting,
4089 CompareMethod=self.CompareFixedPoints1D)
4090 hyp.SetPoints(points)
4091 hyp.SetNbSegments(nbSegs)
4092 hyp.SetReversedEdges(reversedEdges)
4093 hyp.SetObjectEntry(entry)
4097 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
4098 ## as the given arguments
4099 def CompareFixedPoints1D(self, hyp, args):
4100 if hyp.GetPoints() == args[0]:
4101 if hyp.GetNbSegments() == args[1]:
4102 if hyp.GetReversedEdges() == args[2]:
4103 if not args[2] or hyp.GetObjectEntry() == args[3]:
4109 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
4110 # @param start defines the length of the first segment
4111 # @param end defines the length of the last segment
4112 # @param reversedEdges is a list of edges to mesh using reversed orientation
4113 # @param UseExisting if ==true - searches for an existing hypothesis created with
4114 # the same parameters, else (default) - creates a new one
4115 # @return an instance of StdMeshers_StartEndLength hypothesis
4116 # @ingroup l3_hypos_1dhyps
4117 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
4118 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
4119 reversedEdges, UseExisting = [], reversedEdges
4120 entry = self.MainShapeEntry()
4121 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
4122 UseExisting=UseExisting,
4123 CompareMethod=self.CompareStartEndLength)
4124 hyp.SetStartLength(start)
4125 hyp.SetEndLength(end)
4126 hyp.SetReversedEdges( reversedEdges )
4127 hyp.SetObjectEntry( entry )
4130 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
4131 def CompareStartEndLength(self, hyp, args):
4132 if IsEqual(hyp.GetLength(1), args[0]):
4133 if IsEqual(hyp.GetLength(0), args[1]):
4134 if hyp.GetReversedEdges() == args[2]:
4135 if not args[2] or hyp.GetObjectEntry() == args[3]:
4139 ## Defines "Deflection1D" hypothesis
4140 # @param d for the deflection
4141 # @param UseExisting if ==true - searches for an existing hypothesis created with
4142 # the same parameters, else (default) - create a new one
4143 # @ingroup l3_hypos_1dhyps
4144 def Deflection1D(self, d, UseExisting=0):
4145 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
4146 CompareMethod=self.CompareDeflection1D)
4147 hyp.SetDeflection(d)
4150 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
4151 def CompareDeflection1D(self, hyp, args):
4152 return IsEqual(hyp.GetDeflection(), args[0])
4154 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
4155 # the opposite side in case of quadrangular faces
4156 # @ingroup l3_hypos_additi
4157 def Propagation(self):
4158 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4160 ## Defines "AutomaticLength" hypothesis
4161 # @param fineness for the fineness [0-1]
4162 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4163 # same parameters, else (default) - create a new one
4164 # @ingroup l3_hypos_1dhyps
4165 def AutomaticLength(self, fineness=0, UseExisting=0):
4166 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
4167 CompareMethod=self.CompareAutomaticLength)
4168 hyp.SetFineness( fineness )
4171 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
4172 def CompareAutomaticLength(self, hyp, args):
4173 return IsEqual(hyp.GetFineness(), args[0])
4175 ## Defines "SegmentLengthAroundVertex" hypothesis
4176 # @param length for the segment length
4177 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
4178 # Any other integer value means that the hypothesis will be set on the
4179 # whole 1D shape, where Mesh_Segment algorithm is assigned.
4180 # @param UseExisting if ==true - searches for an existing hypothesis created with
4181 # the same parameters, else (default) - creates a new one
4182 # @ingroup l3_algos_segmarv
4183 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
4185 store_geom = self.geom
4186 if type(vertex) is types.IntType:
4187 if vertex == 0 or vertex == 1:
4188 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
4196 if self.geom is None:
4197 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
4199 name = GetName(self.geom)
4202 piece = self.mesh.geom
4203 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
4204 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
4206 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
4208 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
4210 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
4211 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
4213 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
4214 CompareMethod=self.CompareLengthNearVertex)
4215 self.geom = store_geom
4216 hyp.SetLength( length )
4219 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
4220 # @ingroup l3_algos_segmarv
4221 def CompareLengthNearVertex(self, hyp, args):
4222 return IsEqual(hyp.GetLength(), args[0])
4224 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
4225 # If the 2D mesher sees that all boundary edges are quadratic,
4226 # it generates quadratic faces, else it generates linear faces using
4227 # medium nodes as if they are vertices.
4228 # The 3D mesher generates quadratic volumes only if all boundary faces
4229 # are quadratic, else it fails.
4231 # @ingroup l3_hypos_additi
4232 def QuadraticMesh(self):
4233 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4236 # Public class: Mesh_CompositeSegment
4237 # --------------------------
4239 ## Defines a segment 1D algorithm for discretization
4241 # @ingroup l3_algos_basic
4242 class Mesh_CompositeSegment(Mesh_Segment):
4244 ## Private constructor.
4245 def __init__(self, mesh, geom=0):
4246 self.Create(mesh, geom, "CompositeSegment_1D")
4249 # Public class: Mesh_Segment_Python
4250 # ---------------------------------
4252 ## Defines a segment 1D algorithm for discretization with python function
4254 # @ingroup l3_algos_basic
4255 class Mesh_Segment_Python(Mesh_Segment):
4257 ## Private constructor.
4258 def __init__(self, mesh, geom=0):
4259 import Python1dPlugin
4260 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
4262 ## Defines "PythonSplit1D" hypothesis
4263 # @param n for the number of segments that cut an edge
4264 # @param func for the python function that calculates the length of all segments
4265 # @param UseExisting if ==true - searches for the existing hypothesis created with
4266 # the same parameters, else (default) - creates a new one
4267 # @ingroup l3_hypos_1dhyps
4268 def PythonSplit1D(self, n, func, UseExisting=0):
4269 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
4270 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
4271 hyp.SetNumberOfSegments(n)
4272 hyp.SetPythonLog10RatioFunction(func)
4275 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
4276 def ComparePythonSplit1D(self, hyp, args):
4277 #if hyp.GetNumberOfSegments() == args[0]:
4278 # if hyp.GetPythonLog10RatioFunction() == args[1]:
4282 # Public class: Mesh_Triangle
4283 # ---------------------------
4285 ## Defines a triangle 2D algorithm
4287 # @ingroup l3_algos_basic
4288 class Mesh_Triangle(Mesh_Algorithm):
4297 ## Private constructor.
4298 def __init__(self, mesh, algoType, geom=0):
4299 Mesh_Algorithm.__init__(self)
4301 self.algoType = algoType
4302 if algoType == MEFISTO:
4303 self.Create(mesh, geom, "MEFISTO_2D")
4305 elif algoType == BLSURF:
4307 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4308 #self.SetPhysicalMesh() - PAL19680
4309 elif algoType == NETGEN:
4311 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4313 elif algoType == NETGEN_2D:
4315 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4318 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4319 # @param area for the maximum area of each triangle
4320 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4321 # same parameters, else (default) - creates a new one
4323 # Only for algoType == MEFISTO || NETGEN_2D
4324 # @ingroup l3_hypos_2dhyps
4325 def MaxElementArea(self, area, UseExisting=0):
4326 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4327 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4328 CompareMethod=self.CompareMaxElementArea)
4329 elif self.algoType == NETGEN:
4330 hyp = self.Parameters(SIMPLE)
4331 hyp.SetMaxElementArea(area)
4334 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4335 def CompareMaxElementArea(self, hyp, args):
4336 return IsEqual(hyp.GetMaxElementArea(), args[0])
4338 ## Defines "LengthFromEdges" hypothesis to build triangles
4339 # based on the length of the edges taken from the wire
4341 # Only for algoType == MEFISTO || NETGEN_2D
4342 # @ingroup l3_hypos_2dhyps
4343 def LengthFromEdges(self):
4344 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4345 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4347 elif self.algoType == NETGEN:
4348 hyp = self.Parameters(SIMPLE)
4349 hyp.LengthFromEdges()
4352 ## Sets a way to define size of mesh elements to generate.
4353 # @param thePhysicalMesh is: DefaultSize or Custom.
4354 # @ingroup l3_hypos_blsurf
4355 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4356 # Parameter of BLSURF algo
4357 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4359 ## Sets size of mesh elements to generate.
4360 # @ingroup l3_hypos_blsurf
4361 def SetPhySize(self, theVal):
4362 # Parameter of BLSURF algo
4363 self.SetPhysicalMesh(1) #Custom - else why to set the size?
4364 self.Parameters().SetPhySize(theVal)
4366 ## Sets lower boundary of mesh element size (PhySize).
4367 # @ingroup l3_hypos_blsurf
4368 def SetPhyMin(self, theVal=-1):
4369 # Parameter of BLSURF algo
4370 self.Parameters().SetPhyMin(theVal)
4372 ## Sets upper boundary of mesh element size (PhySize).
4373 # @ingroup l3_hypos_blsurf
4374 def SetPhyMax(self, theVal=-1):
4375 # Parameter of BLSURF algo
4376 self.Parameters().SetPhyMax(theVal)
4378 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4379 # @param theGeometricMesh is: DefaultGeom or Custom
4380 # @ingroup l3_hypos_blsurf
4381 def SetGeometricMesh(self, theGeometricMesh=0):
4382 # Parameter of BLSURF algo
4383 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4384 self.params.SetGeometricMesh(theGeometricMesh)
4386 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4387 # @ingroup l3_hypos_blsurf
4388 def SetAngleMeshS(self, theVal=_angleMeshS):
4389 # Parameter of BLSURF algo
4390 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4391 self.params.SetAngleMeshS(theVal)
4393 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4394 # @ingroup l3_hypos_blsurf
4395 def SetAngleMeshC(self, theVal=_angleMeshS):
4396 # Parameter of BLSURF algo
4397 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4398 self.params.SetAngleMeshC(theVal)
4400 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4401 # @ingroup l3_hypos_blsurf
4402 def SetGeoMin(self, theVal=-1):
4403 # Parameter of BLSURF algo
4404 self.Parameters().SetGeoMin(theVal)
4406 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4407 # @ingroup l3_hypos_blsurf
4408 def SetGeoMax(self, theVal=-1):
4409 # Parameter of BLSURF algo
4410 self.Parameters().SetGeoMax(theVal)
4412 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4413 # @ingroup l3_hypos_blsurf
4414 def SetGradation(self, theVal=_gradation):
4415 # Parameter of BLSURF algo
4416 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4417 self.params.SetGradation(theVal)
4419 ## Sets topology usage way.
4420 # @param way defines how mesh conformity is assured <ul>
4421 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4422 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4423 # @ingroup l3_hypos_blsurf
4424 def SetTopology(self, way):
4425 # Parameter of BLSURF algo
4426 self.Parameters().SetTopology(way)
4428 ## To respect geometrical edges or not.
4429 # @ingroup l3_hypos_blsurf
4430 def SetDecimesh(self, toIgnoreEdges=False):
4431 # Parameter of BLSURF algo
4432 self.Parameters().SetDecimesh(toIgnoreEdges)
4434 ## Sets verbosity level in the range 0 to 100.
4435 # @ingroup l3_hypos_blsurf
4436 def SetVerbosity(self, level):
4437 # Parameter of BLSURF algo
4438 self.Parameters().SetVerbosity(level)
4440 ## Sets advanced option value.
4441 # @ingroup l3_hypos_blsurf
4442 def SetOptionValue(self, optionName, level):
4443 # Parameter of BLSURF algo
4444 self.Parameters().SetOptionValue(optionName,level)
4446 ## Sets QuadAllowed flag.
4447 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4448 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4449 def SetQuadAllowed(self, toAllow=True):
4450 if self.algoType == NETGEN_2D:
4451 if toAllow: # add QuadranglePreference
4452 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4453 else: # remove QuadranglePreference
4454 for hyp in self.mesh.GetHypothesisList( self.geom ):
4455 if hyp.GetName() == "QuadranglePreference":
4456 self.mesh.RemoveHypothesis( self.geom, hyp )
4461 if self.Parameters():
4462 self.params.SetQuadAllowed(toAllow)
4465 ## Defines hypothesis having several parameters
4467 # @ingroup l3_hypos_netgen
4468 def Parameters(self, which=SOLE):
4471 if self.algoType == NETGEN:
4473 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4474 "libNETGENEngine.so", UseExisting=0)
4476 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4477 "libNETGENEngine.so", UseExisting=0)
4479 elif self.algoType == MEFISTO:
4480 print "Mefisto algo support no multi-parameter hypothesis"
4482 elif self.algoType == NETGEN_2D:
4483 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4484 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4486 elif self.algoType == BLSURF:
4487 self.params = self.Hypothesis("BLSURF_Parameters", [],
4488 "libBLSURFEngine.so", UseExisting=0)
4491 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4496 # Only for algoType == NETGEN
4497 # @ingroup l3_hypos_netgen
4498 def SetMaxSize(self, theSize):
4499 if self.Parameters():
4500 self.params.SetMaxSize(theSize)
4502 ## Sets SecondOrder flag
4504 # Only for algoType == NETGEN
4505 # @ingroup l3_hypos_netgen
4506 def SetSecondOrder(self, theVal):
4507 if self.Parameters():
4508 self.params.SetSecondOrder(theVal)
4510 ## Sets Optimize flag
4512 # Only for algoType == NETGEN
4513 # @ingroup l3_hypos_netgen
4514 def SetOptimize(self, theVal):
4515 if self.Parameters():
4516 self.params.SetOptimize(theVal)
4519 # @param theFineness is:
4520 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4522 # Only for algoType == NETGEN
4523 # @ingroup l3_hypos_netgen
4524 def SetFineness(self, theFineness):
4525 if self.Parameters():
4526 self.params.SetFineness(theFineness)
4530 # Only for algoType == NETGEN
4531 # @ingroup l3_hypos_netgen
4532 def SetGrowthRate(self, theRate):
4533 if self.Parameters():
4534 self.params.SetGrowthRate(theRate)
4536 ## Sets NbSegPerEdge
4538 # Only for algoType == NETGEN
4539 # @ingroup l3_hypos_netgen
4540 def SetNbSegPerEdge(self, theVal):
4541 if self.Parameters():
4542 self.params.SetNbSegPerEdge(theVal)
4544 ## Sets NbSegPerRadius
4546 # Only for algoType == NETGEN
4547 # @ingroup l3_hypos_netgen
4548 def SetNbSegPerRadius(self, theVal):
4549 if self.Parameters():
4550 self.params.SetNbSegPerRadius(theVal)
4552 ## Sets number of segments overriding value set by SetLocalLength()
4554 # Only for algoType == NETGEN
4555 # @ingroup l3_hypos_netgen
4556 def SetNumberOfSegments(self, theVal):
4557 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4559 ## Sets number of segments overriding value set by SetNumberOfSegments()
4561 # Only for algoType == NETGEN
4562 # @ingroup l3_hypos_netgen
4563 def SetLocalLength(self, theVal):
4564 self.Parameters(SIMPLE).SetLocalLength(theVal)
4569 # Public class: Mesh_Quadrangle
4570 # -----------------------------
4572 ## Defines a quadrangle 2D algorithm
4574 # @ingroup l3_algos_basic
4575 class Mesh_Quadrangle(Mesh_Algorithm):
4577 ## Private constructor.
4578 def __init__(self, mesh, geom=0):
4579 Mesh_Algorithm.__init__(self)
4580 self.Create(mesh, geom, "Quadrangle_2D")
4582 ## Defines "QuadranglePreference" hypothesis, forcing construction
4583 # of quadrangles if the number of nodes on the opposite edges is not the same
4584 # while the total number of nodes on edges is even
4586 # @ingroup l3_hypos_additi
4587 def QuadranglePreference(self):
4588 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4589 CompareMethod=self.CompareEqualHyp)
4592 ## Defines "TrianglePreference" hypothesis, forcing construction
4593 # of triangles in the refinement area if the number of nodes
4594 # on the opposite edges is not the same
4596 # @ingroup l3_hypos_additi
4597 def TrianglePreference(self):
4598 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4599 CompareMethod=self.CompareEqualHyp)
4602 ## Defines "QuadrangleParams" hypothesis
4603 # @param vertex: vertex of a trilateral geometrical face, around which triangles
4604 # will be created while other elements will be quadrangles.
4605 # Vertex can be either a GEOM_Object or a vertex ID within the
4607 # @param UseExisting: if ==true - searches for the existing hypothesis created with
4608 # the same parameters, else (default) - creates a new one
4610 # @ingroup l3_hypos_additi
4611 def TriangleVertex(self, vertex, UseExisting=0):
4613 if isinstance( vertexID, geompyDC.GEOM._objref_GEOM_Object ):
4614 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, vertex )
4615 hyp = self.Hypothesis("QuadrangleParams", [vertexID], UseExisting = UseExisting,
4616 CompareMethod=lambda hyp,args: hyp.GetTriaVertex()==args[0])
4617 hyp.SetTriaVertex( vertexID )
4621 # Public class: Mesh_Tetrahedron
4622 # ------------------------------
4624 ## Defines a tetrahedron 3D algorithm
4626 # @ingroup l3_algos_basic
4627 class Mesh_Tetrahedron(Mesh_Algorithm):
4632 ## Private constructor.
4633 def __init__(self, mesh, algoType, geom=0):
4634 Mesh_Algorithm.__init__(self)
4636 if algoType == NETGEN:
4638 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4641 elif algoType == FULL_NETGEN:
4643 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4646 elif algoType == GHS3D:
4648 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4651 elif algoType == GHS3DPRL:
4652 CheckPlugin(GHS3DPRL)
4653 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4656 self.algoType = algoType
4658 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4659 # @param vol for the maximum volume of each tetrahedron
4660 # @param UseExisting if ==true - searches for the existing hypothesis created with
4661 # the same parameters, else (default) - creates a new one
4662 # @ingroup l3_hypos_maxvol
4663 def MaxElementVolume(self, vol, UseExisting=0):
4664 if self.algoType == NETGEN:
4665 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4666 CompareMethod=self.CompareMaxElementVolume)
4667 hyp.SetMaxElementVolume(vol)
4669 elif self.algoType == FULL_NETGEN:
4670 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4673 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4674 def CompareMaxElementVolume(self, hyp, args):
4675 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4677 ## Defines hypothesis having several parameters
4679 # @ingroup l3_hypos_netgen
4680 def Parameters(self, which=SOLE):
4684 if self.algoType == FULL_NETGEN:
4686 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4687 "libNETGENEngine.so", UseExisting=0)
4689 self.params = self.Hypothesis("NETGEN_Parameters", [],
4690 "libNETGENEngine.so", UseExisting=0)
4693 if self.algoType == GHS3D:
4694 self.params = self.Hypothesis("GHS3D_Parameters", [],
4695 "libGHS3DEngine.so", UseExisting=0)
4698 if self.algoType == GHS3DPRL:
4699 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4700 "libGHS3DPRLEngine.so", UseExisting=0)
4703 print "Algo supports no multi-parameter hypothesis"
4707 # Parameter of FULL_NETGEN
4708 # @ingroup l3_hypos_netgen
4709 def SetMaxSize(self, theSize):
4710 self.Parameters().SetMaxSize(theSize)
4712 ## Sets SecondOrder flag
4713 # Parameter of FULL_NETGEN
4714 # @ingroup l3_hypos_netgen
4715 def SetSecondOrder(self, theVal):
4716 self.Parameters().SetSecondOrder(theVal)
4718 ## Sets Optimize flag
4719 # Parameter of FULL_NETGEN
4720 # @ingroup l3_hypos_netgen
4721 def SetOptimize(self, theVal):
4722 self.Parameters().SetOptimize(theVal)
4725 # @param theFineness is:
4726 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4727 # Parameter of FULL_NETGEN
4728 # @ingroup l3_hypos_netgen
4729 def SetFineness(self, theFineness):
4730 self.Parameters().SetFineness(theFineness)
4733 # Parameter of FULL_NETGEN
4734 # @ingroup l3_hypos_netgen
4735 def SetGrowthRate(self, theRate):
4736 self.Parameters().SetGrowthRate(theRate)
4738 ## Sets NbSegPerEdge
4739 # Parameter of FULL_NETGEN
4740 # @ingroup l3_hypos_netgen
4741 def SetNbSegPerEdge(self, theVal):
4742 self.Parameters().SetNbSegPerEdge(theVal)
4744 ## Sets NbSegPerRadius
4745 # Parameter of FULL_NETGEN
4746 # @ingroup l3_hypos_netgen
4747 def SetNbSegPerRadius(self, theVal):
4748 self.Parameters().SetNbSegPerRadius(theVal)
4750 ## Sets number of segments overriding value set by SetLocalLength()
4751 # Only for algoType == NETGEN_FULL
4752 # @ingroup l3_hypos_netgen
4753 def SetNumberOfSegments(self, theVal):
4754 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4756 ## Sets number of segments overriding value set by SetNumberOfSegments()
4757 # Only for algoType == NETGEN_FULL
4758 # @ingroup l3_hypos_netgen
4759 def SetLocalLength(self, theVal):
4760 self.Parameters(SIMPLE).SetLocalLength(theVal)
4762 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4763 # Overrides value set by LengthFromEdges()
4764 # Only for algoType == NETGEN_FULL
4765 # @ingroup l3_hypos_netgen
4766 def MaxElementArea(self, area):
4767 self.Parameters(SIMPLE).SetMaxElementArea(area)
4769 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4770 # Overrides value set by MaxElementArea()
4771 # Only for algoType == NETGEN_FULL
4772 # @ingroup l3_hypos_netgen
4773 def LengthFromEdges(self):
4774 self.Parameters(SIMPLE).LengthFromEdges()
4776 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4777 # Overrides value set by MaxElementVolume()
4778 # Only for algoType == NETGEN_FULL
4779 # @ingroup l3_hypos_netgen
4780 def LengthFromFaces(self):
4781 self.Parameters(SIMPLE).LengthFromFaces()
4783 ## To mesh "holes" in a solid or not. Default is to mesh.
4784 # @ingroup l3_hypos_ghs3dh
4785 def SetToMeshHoles(self, toMesh):
4786 # Parameter of GHS3D
4787 self.Parameters().SetToMeshHoles(toMesh)
4789 ## Set Optimization level:
4790 # None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization,
4791 # Strong_Optimization.
4792 # Default is Standard_Optimization
4793 # @ingroup l3_hypos_ghs3dh
4794 def SetOptimizationLevel(self, level):
4795 # Parameter of GHS3D
4796 self.Parameters().SetOptimizationLevel(level)
4798 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4799 # @ingroup l3_hypos_ghs3dh
4800 def SetMaximumMemory(self, MB):
4801 # Advanced parameter of GHS3D
4802 self.Parameters().SetMaximumMemory(MB)
4804 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4805 # automatic memory adjustment mode.
4806 # @ingroup l3_hypos_ghs3dh
4807 def SetInitialMemory(self, MB):
4808 # Advanced parameter of GHS3D
4809 self.Parameters().SetInitialMemory(MB)
4811 ## Path to working directory.
4812 # @ingroup l3_hypos_ghs3dh
4813 def SetWorkingDirectory(self, path):
4814 # Advanced parameter of GHS3D
4815 self.Parameters().SetWorkingDirectory(path)
4817 ## To keep working files or remove them. Log file remains in case of errors anyway.
4818 # @ingroup l3_hypos_ghs3dh
4819 def SetKeepFiles(self, toKeep):
4820 # Advanced parameter of GHS3D and GHS3DPRL
4821 self.Parameters().SetKeepFiles(toKeep)
4823 ## To set verbose level [0-10]. <ul>
4824 #<li> 0 - no standard output,
4825 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4826 # indicates when the final mesh is being saved. In addition the software
4827 # gives indication regarding the CPU time.
4828 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4829 # histogram of the skin mesh, quality statistics histogram together with
4830 # the characteristics of the final mesh.</ul>
4831 # @ingroup l3_hypos_ghs3dh
4832 def SetVerboseLevel(self, level):
4833 # Advanced parameter of GHS3D
4834 self.Parameters().SetVerboseLevel(level)
4836 ## To create new nodes.
4837 # @ingroup l3_hypos_ghs3dh
4838 def SetToCreateNewNodes(self, toCreate):
4839 # Advanced parameter of GHS3D
4840 self.Parameters().SetToCreateNewNodes(toCreate)
4842 ## To use boundary recovery version which tries to create mesh on a very poor
4843 # quality surface mesh.
4844 # @ingroup l3_hypos_ghs3dh
4845 def SetToUseBoundaryRecoveryVersion(self, toUse):
4846 # Advanced parameter of GHS3D
4847 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4849 ## Sets command line option as text.
4850 # @ingroup l3_hypos_ghs3dh
4851 def SetTextOption(self, option):
4852 # Advanced parameter of GHS3D
4853 self.Parameters().SetTextOption(option)
4855 ## Sets MED files name and path.
4856 def SetMEDName(self, value):
4857 self.Parameters().SetMEDName(value)
4859 ## Sets the number of partition of the initial mesh
4860 def SetNbPart(self, value):
4861 self.Parameters().SetNbPart(value)
4863 ## When big mesh, start tepal in background
4864 def SetBackground(self, value):
4865 self.Parameters().SetBackground(value)
4867 # Public class: Mesh_Hexahedron
4868 # ------------------------------
4870 ## Defines a hexahedron 3D algorithm
4872 # @ingroup l3_algos_basic
4873 class Mesh_Hexahedron(Mesh_Algorithm):
4878 ## Private constructor.
4879 def __init__(self, mesh, algoType=Hexa, geom=0):
4880 Mesh_Algorithm.__init__(self)
4882 self.algoType = algoType
4884 if algoType == Hexa:
4885 self.Create(mesh, geom, "Hexa_3D")
4888 elif algoType == Hexotic:
4889 CheckPlugin(Hexotic)
4890 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4893 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4894 # @ingroup l3_hypos_hexotic
4895 def MinMaxQuad(self, min=3, max=8, quad=True):
4896 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4898 self.params.SetHexesMinLevel(min)
4899 self.params.SetHexesMaxLevel(max)
4900 self.params.SetHexoticQuadrangles(quad)
4903 # Deprecated, only for compatibility!
4904 # Public class: Mesh_Netgen
4905 # ------------------------------
4907 ## Defines a NETGEN-based 2D or 3D algorithm
4908 # that needs no discrete boundary (i.e. independent)
4910 # This class is deprecated, only for compatibility!
4913 # @ingroup l3_algos_basic
4914 class Mesh_Netgen(Mesh_Algorithm):
4918 ## Private constructor.
4919 def __init__(self, mesh, is3D, geom=0):
4920 Mesh_Algorithm.__init__(self)
4926 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4930 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4933 ## Defines the hypothesis containing parameters of the algorithm
4934 def Parameters(self):
4936 hyp = self.Hypothesis("NETGEN_Parameters", [],
4937 "libNETGENEngine.so", UseExisting=0)
4939 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4940 "libNETGENEngine.so", UseExisting=0)
4943 # Public class: Mesh_Projection1D
4944 # ------------------------------
4946 ## Defines a projection 1D algorithm
4947 # @ingroup l3_algos_proj
4949 class Mesh_Projection1D(Mesh_Algorithm):
4951 ## Private constructor.
4952 def __init__(self, mesh, geom=0):
4953 Mesh_Algorithm.__init__(self)
4954 self.Create(mesh, geom, "Projection_1D")
4956 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4957 # a mesh pattern is taken, and, optionally, the association of vertices
4958 # between the source edge and a target edge (to which a hypothesis is assigned)
4959 # @param edge from which nodes distribution is taken
4960 # @param mesh from which nodes distribution is taken (optional)
4961 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4962 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4963 # to associate with \a srcV (optional)
4964 # @param UseExisting if ==true - searches for the existing hypothesis created with
4965 # the same parameters, else (default) - creates a new one
4966 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4967 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4969 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4970 hyp.SetSourceEdge( edge )
4971 if not mesh is None and isinstance(mesh, Mesh):
4972 mesh = mesh.GetMesh()
4973 hyp.SetSourceMesh( mesh )
4974 hyp.SetVertexAssociation( srcV, tgtV )
4977 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4978 #def CompareSourceEdge(self, hyp, args):
4979 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4983 # Public class: Mesh_Projection2D
4984 # ------------------------------
4986 ## Defines a projection 2D algorithm
4987 # @ingroup l3_algos_proj
4989 class Mesh_Projection2D(Mesh_Algorithm):
4991 ## Private constructor.
4992 def __init__(self, mesh, geom=0):
4993 Mesh_Algorithm.__init__(self)
4994 self.Create(mesh, geom, "Projection_2D")
4996 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4997 # a mesh pattern is taken, and, optionally, the association of vertices
4998 # between the source face and the target face (to which a hypothesis is assigned)
4999 # @param face from which the mesh pattern is taken
5000 # @param mesh from which the mesh pattern is taken (optional)
5001 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
5002 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
5003 # to associate with \a srcV1 (optional)
5004 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
5005 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
5006 # to associate with \a srcV2 (optional)
5007 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
5008 # the same parameters, else (default) - forces the creation a new one
5010 # Note: all association vertices must belong to one edge of a face
5011 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
5012 srcV2=None, tgtV2=None, UseExisting=0):
5013 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
5015 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
5016 hyp.SetSourceFace( face )
5017 if not mesh is None and isinstance(mesh, Mesh):
5018 mesh = mesh.GetMesh()
5019 hyp.SetSourceMesh( mesh )
5020 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5023 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
5024 #def CompareSourceFace(self, hyp, args):
5025 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
5028 # Public class: Mesh_Projection3D
5029 # ------------------------------
5031 ## Defines a projection 3D algorithm
5032 # @ingroup l3_algos_proj
5034 class Mesh_Projection3D(Mesh_Algorithm):
5036 ## Private constructor.
5037 def __init__(self, mesh, geom=0):
5038 Mesh_Algorithm.__init__(self)
5039 self.Create(mesh, geom, "Projection_3D")
5041 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
5042 # the mesh pattern is taken, and, optionally, the association of vertices
5043 # between the source and the target solid (to which a hipothesis is assigned)
5044 # @param solid from where the mesh pattern is taken
5045 # @param mesh from where the mesh pattern is taken (optional)
5046 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
5047 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
5048 # to associate with \a srcV1 (optional)
5049 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
5050 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
5051 # to associate with \a srcV2 (optional)
5052 # @param UseExisting - if ==true - searches for the existing hypothesis created with
5053 # the same parameters, else (default) - creates a new one
5055 # Note: association vertices must belong to one edge of a solid
5056 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
5057 srcV2=0, tgtV2=0, UseExisting=0):
5058 hyp = self.Hypothesis("ProjectionSource3D",
5059 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
5061 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
5062 hyp.SetSource3DShape( solid )
5063 if not mesh is None and isinstance(mesh, Mesh):
5064 mesh = mesh.GetMesh()
5065 hyp.SetSourceMesh( mesh )
5066 if srcV1 and srcV2 and tgtV1 and tgtV2:
5067 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
5068 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
5071 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
5072 #def CompareSourceShape3D(self, hyp, args):
5073 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
5077 # Public class: Mesh_Prism
5078 # ------------------------
5080 ## Defines a 3D extrusion algorithm
5081 # @ingroup l3_algos_3dextr
5083 class Mesh_Prism3D(Mesh_Algorithm):
5085 ## Private constructor.
5086 def __init__(self, mesh, geom=0):
5087 Mesh_Algorithm.__init__(self)
5088 self.Create(mesh, geom, "Prism_3D")
5090 # Public class: Mesh_RadialPrism
5091 # -------------------------------
5093 ## Defines a Radial Prism 3D algorithm
5094 # @ingroup l3_algos_radialp
5096 class Mesh_RadialPrism3D(Mesh_Algorithm):
5098 ## Private constructor.
5099 def __init__(self, mesh, geom=0):
5100 Mesh_Algorithm.__init__(self)
5101 self.Create(mesh, geom, "RadialPrism_3D")
5103 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
5104 self.nbLayers = None
5106 ## Return 3D hypothesis holding the 1D one
5107 def Get3DHypothesis(self):
5108 return self.distribHyp
5110 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5111 # hypothesis. Returns the created hypothesis
5112 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5113 #print "OwnHypothesis",hypType
5114 if not self.nbLayers is None:
5115 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5116 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5117 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5118 self.mesh.smeshpyD.SetCurrentStudy( None )
5119 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5120 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5121 self.distribHyp.SetLayerDistribution( hyp )
5124 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
5125 # prisms to build between the inner and outer shells
5126 # @param n number of layers
5127 # @param UseExisting if ==true - searches for the existing hypothesis created with
5128 # the same parameters, else (default) - creates a new one
5129 def NumberOfLayers(self, n, UseExisting=0):
5130 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5131 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
5132 CompareMethod=self.CompareNumberOfLayers)
5133 self.nbLayers.SetNumberOfLayers( n )
5134 return self.nbLayers
5136 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5137 def CompareNumberOfLayers(self, hyp, args):
5138 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5140 ## Defines "LocalLength" hypothesis, specifying the segment length
5141 # to build between the inner and the outer shells
5142 # @param l the length of segments
5143 # @param p the precision of rounding
5144 def LocalLength(self, l, p=1e-07):
5145 hyp = self.OwnHypothesis("LocalLength", [l,p])
5150 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
5151 # prisms to build between the inner and the outer shells.
5152 # @param n the number of layers
5153 # @param s the scale factor (optional)
5154 def NumberOfSegments(self, n, s=[]):
5156 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5158 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5159 hyp.SetDistrType( 1 )
5160 hyp.SetScaleFactor(s)
5161 hyp.SetNumberOfSegments(n)
5164 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5165 # to build between the inner and the outer shells with a length that changes in arithmetic progression
5166 # @param start the length of the first segment
5167 # @param end the length of the last segment
5168 def Arithmetic1D(self, start, end ):
5169 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5170 hyp.SetLength(start, 1)
5171 hyp.SetLength(end , 0)
5174 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5175 # to build between the inner and the outer shells as geometric length increasing
5176 # @param start for the length of the first segment
5177 # @param end for the length of the last segment
5178 def StartEndLength(self, start, end):
5179 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5180 hyp.SetLength(start, 1)
5181 hyp.SetLength(end , 0)
5184 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5185 # to build between the inner and outer shells
5186 # @param fineness defines the quality of the mesh within the range [0-1]
5187 def AutomaticLength(self, fineness=0):
5188 hyp = self.OwnHypothesis("AutomaticLength")
5189 hyp.SetFineness( fineness )
5192 # Public class: Mesh_RadialQuadrangle1D2D
5193 # -------------------------------
5195 ## Defines a Radial Quadrangle 1D2D algorithm
5196 # @ingroup l2_algos_radialq
5198 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
5200 ## Private constructor.
5201 def __init__(self, mesh, geom=0):
5202 Mesh_Algorithm.__init__(self)
5203 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
5205 self.distribHyp = None #self.Hypothesis("LayerDistribution2D", UseExisting=0)
5206 self.nbLayers = None
5208 ## Return 2D hypothesis holding the 1D one
5209 def Get2DHypothesis(self):
5210 return self.distribHyp
5212 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
5213 # hypothesis. Returns the created hypothesis
5214 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
5215 #print "OwnHypothesis",hypType
5217 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
5218 if self.distribHyp is None:
5219 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
5221 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
5222 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
5223 self.mesh.smeshpyD.SetCurrentStudy( None )
5224 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
5225 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
5226 self.distribHyp.SetLayerDistribution( hyp )
5229 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers
5230 # @param n number of layers
5231 # @param UseExisting if ==true - searches for the existing hypothesis created with
5232 # the same parameters, else (default) - creates a new one
5233 def NumberOfLayers(self, n, UseExisting=0):
5235 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
5236 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
5237 CompareMethod=self.CompareNumberOfLayers)
5238 self.nbLayers.SetNumberOfLayers( n )
5239 return self.nbLayers
5241 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
5242 def CompareNumberOfLayers(self, hyp, args):
5243 return IsEqual(hyp.GetNumberOfLayers(), args[0])
5245 ## Defines "LocalLength" hypothesis, specifying the segment length
5246 # @param l the length of segments
5247 # @param p the precision of rounding
5248 def LocalLength(self, l, p=1e-07):
5249 hyp = self.OwnHypothesis("LocalLength", [l,p])
5254 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
5255 # @param n the number of layers
5256 # @param s the scale factor (optional)
5257 def NumberOfSegments(self, n, s=[]):
5259 hyp = self.OwnHypothesis("NumberOfSegments", [n])
5261 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
5262 hyp.SetDistrType( 1 )
5263 hyp.SetScaleFactor(s)
5264 hyp.SetNumberOfSegments(n)
5267 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
5268 # with a length that changes in arithmetic progression
5269 # @param start the length of the first segment
5270 # @param end the length of the last segment
5271 def Arithmetic1D(self, start, end ):
5272 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
5273 hyp.SetLength(start, 1)
5274 hyp.SetLength(end , 0)
5277 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
5278 # as geometric length increasing
5279 # @param start for the length of the first segment
5280 # @param end for the length of the last segment
5281 def StartEndLength(self, start, end):
5282 hyp = self.OwnHypothesis("StartEndLength", [start, end])
5283 hyp.SetLength(start, 1)
5284 hyp.SetLength(end , 0)
5287 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
5288 # @param fineness defines the quality of the mesh within the range [0-1]
5289 def AutomaticLength(self, fineness=0):
5290 hyp = self.OwnHypothesis("AutomaticLength")
5291 hyp.SetFineness( fineness )
5295 # Private class: Mesh_UseExisting
5296 # -------------------------------
5297 class Mesh_UseExisting(Mesh_Algorithm):
5299 def __init__(self, dim, mesh, geom=0):
5301 self.Create(mesh, geom, "UseExisting_1D")
5303 self.Create(mesh, geom, "UseExisting_2D")
5306 import salome_notebook
5307 notebook = salome_notebook.notebook
5309 ##Return values of the notebook variables
5310 def ParseParameters(last, nbParams,nbParam, value):
5314 listSize = len(last)
5315 for n in range(0,nbParams):
5317 if counter < listSize:
5318 strResult = strResult + last[counter]
5320 strResult = strResult + ""
5322 if isinstance(value, str):
5323 if notebook.isVariable(value):
5324 result = notebook.get(value)
5325 strResult=strResult+value
5327 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5329 strResult=strResult+str(value)
5331 if nbParams - 1 != counter:
5332 strResult=strResult+var_separator #":"
5334 return result, strResult
5336 #Wrapper class for StdMeshers_LocalLength hypothesis
5337 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5339 ## Set Length parameter value
5340 # @param length numerical value or name of variable from notebook
5341 def SetLength(self, length):
5342 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5343 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5344 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5346 ## Set Precision parameter value
5347 # @param precision numerical value or name of variable from notebook
5348 def SetPrecision(self, precision):
5349 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5350 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5351 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5353 #Registering the new proxy for LocalLength
5354 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5357 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5358 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5360 def SetLayerDistribution(self, hypo):
5361 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5362 hypo.ClearParameters();
5363 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5365 #Registering the new proxy for LayerDistribution
5366 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5368 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5369 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5371 ## Set Length parameter value
5372 # @param length numerical value or name of variable from notebook
5373 def SetLength(self, length):
5374 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5375 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5376 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5378 #Registering the new proxy for SegmentLengthAroundVertex
5379 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5382 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5383 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5385 ## Set Length parameter value
5386 # @param length numerical value or name of variable from notebook
5387 # @param isStart true is length is Start Length, otherwise false
5388 def SetLength(self, length, isStart):
5392 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5393 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5394 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5396 #Registering the new proxy for Arithmetic1D
5397 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5399 #Wrapper class for StdMeshers_Deflection1D hypothesis
5400 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5402 ## Set Deflection parameter value
5403 # @param deflection numerical value or name of variable from notebook
5404 def SetDeflection(self, deflection):
5405 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5406 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5407 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5409 #Registering the new proxy for Deflection1D
5410 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5412 #Wrapper class for StdMeshers_StartEndLength hypothesis
5413 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5415 ## Set Length parameter value
5416 # @param length numerical value or name of variable from notebook
5417 # @param isStart true is length is Start Length, otherwise false
5418 def SetLength(self, length, isStart):
5422 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5423 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5424 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5426 #Registering the new proxy for StartEndLength
5427 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5429 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5430 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5432 ## Set Max Element Area parameter value
5433 # @param area numerical value or name of variable from notebook
5434 def SetMaxElementArea(self, area):
5435 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5436 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5437 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5439 #Registering the new proxy for MaxElementArea
5440 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5443 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5444 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5446 ## Set Max Element Volume parameter value
5447 # @param volume numerical value or name of variable from notebook
5448 def SetMaxElementVolume(self, volume):
5449 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5450 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5451 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5453 #Registering the new proxy for MaxElementVolume
5454 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5457 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5458 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5460 ## Set Number Of Layers parameter value
5461 # @param nbLayers numerical value or name of variable from notebook
5462 def SetNumberOfLayers(self, nbLayers):
5463 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5464 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5465 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5467 #Registering the new proxy for NumberOfLayers
5468 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5470 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5471 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5473 ## Set Number Of Segments parameter value
5474 # @param nbSeg numerical value or name of variable from notebook
5475 def SetNumberOfSegments(self, nbSeg):
5476 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5477 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5478 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5479 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5481 ## Set Scale Factor parameter value
5482 # @param factor numerical value or name of variable from notebook
5483 def SetScaleFactor(self, factor):
5484 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5485 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5486 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5488 #Registering the new proxy for NumberOfSegments
5489 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5491 if not noNETGENPlugin:
5492 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5493 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5495 ## Set Max Size parameter value
5496 # @param maxsize numerical value or name of variable from notebook
5497 def SetMaxSize(self, maxsize):
5498 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5499 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5500 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5501 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5503 ## Set Growth Rate parameter value
5504 # @param value numerical value or name of variable from notebook
5505 def SetGrowthRate(self, value):
5506 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5507 value, parameters = ParseParameters(lastParameters,4,2,value)
5508 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5509 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5511 ## Set Number of Segments per Edge parameter value
5512 # @param value numerical value or name of variable from notebook
5513 def SetNbSegPerEdge(self, value):
5514 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5515 value, parameters = ParseParameters(lastParameters,4,3,value)
5516 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5517 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5519 ## Set Number of Segments per Radius parameter value
5520 # @param value numerical value or name of variable from notebook
5521 def SetNbSegPerRadius(self, value):
5522 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5523 value, parameters = ParseParameters(lastParameters,4,4,value)
5524 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5525 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5527 #Registering the new proxy for NETGENPlugin_Hypothesis
5528 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5531 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5532 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5535 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5536 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5538 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5539 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5541 ## Set Number of Segments parameter value
5542 # @param nbSeg numerical value or name of variable from notebook
5543 def SetNumberOfSegments(self, nbSeg):
5544 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5545 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5546 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5547 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5549 ## Set Local Length parameter value
5550 # @param length numerical value or name of variable from notebook
5551 def SetLocalLength(self, length):
5552 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5553 length, parameters = ParseParameters(lastParameters,2,1,length)
5554 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5555 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5557 ## Set Max Element Area parameter value
5558 # @param area numerical value or name of variable from notebook
5559 def SetMaxElementArea(self, area):
5560 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5561 area, parameters = ParseParameters(lastParameters,2,2,area)
5562 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5563 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5565 def LengthFromEdges(self):
5566 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5568 value, parameters = ParseParameters(lastParameters,2,2,value)
5569 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5570 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5572 #Registering the new proxy for NETGEN_SimpleParameters_2D
5573 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5576 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5577 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5578 ## Set Max Element Volume parameter value
5579 # @param volume numerical value or name of variable from notebook
5580 def SetMaxElementVolume(self, volume):
5581 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5582 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5583 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5584 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5586 def LengthFromFaces(self):
5587 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5589 value, parameters = ParseParameters(lastParameters,3,3,value)
5590 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5591 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5593 #Registering the new proxy for NETGEN_SimpleParameters_3D
5594 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5596 pass # if not noNETGENPlugin:
5598 class Pattern(SMESH._objref_SMESH_Pattern):
5600 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5602 if isinstance(theNodeIndexOnKeyPoint1,str):
5604 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5606 theNodeIndexOnKeyPoint1 -= 1
5607 theMesh.SetParameters(Parameters)
5608 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5610 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5613 if isinstance(theNode000Index,str):
5615 if isinstance(theNode001Index,str):
5617 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5619 theNode000Index -= 1
5621 theNode001Index -= 1
5622 theMesh.SetParameters(Parameters)
5623 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5625 #Registering the new proxy for Pattern
5626 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)