1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
4 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 # Author : Francis KLOSS, OCC
32 ## @defgroup l1_auxiliary Auxiliary methods and structures
33 ## @defgroup l1_creating Creating meshes
35 ## @defgroup l2_impexp Importing and exporting meshes
36 ## @defgroup l2_construct Constructing meshes
37 ## @defgroup l2_algorithms Defining Algorithms
39 ## @defgroup l3_algos_basic Basic meshing algorithms
40 ## @defgroup l3_algos_proj Projection Algorithms
41 ## @defgroup l3_algos_radialp Radial Prism
42 ## @defgroup l3_algos_segmarv Segments around Vertex
43 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
46 ## @defgroup l2_hypotheses Defining hypotheses
48 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
49 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
50 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
51 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
52 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
53 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
54 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
55 ## @defgroup l3_hypos_additi Additional Hypotheses
58 ## @defgroup l2_submeshes Constructing submeshes
59 ## @defgroup l2_compounds Building Compounds
60 ## @defgroup l2_editing Editing Meshes
63 ## @defgroup l1_meshinfo Mesh Information
64 ## @defgroup l1_controls Quality controls and Filtering
65 ## @defgroup l1_grouping Grouping elements
67 ## @defgroup l2_grps_create Creating groups
68 ## @defgroup l2_grps_edit Editing groups
69 ## @defgroup l2_grps_operon Using operations on groups
70 ## @defgroup l2_grps_delete Deleting Groups
73 ## @defgroup l1_modifying Modifying meshes
75 ## @defgroup l2_modif_add Adding nodes and elements
76 ## @defgroup l2_modif_del Removing nodes and elements
77 ## @defgroup l2_modif_edit Modifying nodes and elements
78 ## @defgroup l2_modif_renumber Renumbering nodes and elements
79 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
80 ## @defgroup l2_modif_movenode Moving nodes
81 ## @defgroup l2_modif_throughp Mesh through point
82 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
83 ## @defgroup l2_modif_unitetri Uniting triangles
84 ## @defgroup l2_modif_changori Changing orientation of elements
85 ## @defgroup l2_modif_cutquadr Cutting quadrangles
86 ## @defgroup l2_modif_smooth Smoothing
87 ## @defgroup l2_modif_extrurev Extrusion and Revolution
88 ## @defgroup l2_modif_patterns Pattern mapping
89 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
96 import SMESH # This is necessary for back compatibility
103 # import NETGENPlugin module if possible
111 ## @addtogroup l1_auxiliary
114 # Types of algorithms
127 NETGEN_1D2D3D = FULL_NETGEN
128 NETGEN_FULL = FULL_NETGEN
134 # MirrorType enumeration
135 POINT = SMESH_MeshEditor.POINT
136 AXIS = SMESH_MeshEditor.AXIS
137 PLANE = SMESH_MeshEditor.PLANE
139 # Smooth_Method enumeration
140 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
141 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
143 # Fineness enumeration (for NETGEN)
151 # Optimization level of GHS3D
152 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
154 # Topology treatment way of BLSURF
155 FromCAD, PreProcess, PreProcessPlus = 0,1,2
157 # Element size flag of BLSURF
158 DefaultSize, DefaultGeom, Custom = 0,0,1
160 PrecisionConfusion = 1e-07
162 ## Converts an angle from degrees to radians
163 def DegreesToRadians(AngleInDegrees):
165 return AngleInDegrees * pi / 180.0
167 # Salome notebook variable separator
170 # Parametrized substitute for PointStruct
171 class PointStructStr:
180 def __init__(self, xStr, yStr, zStr):
184 if isinstance(xStr, str) and notebook.isVariable(xStr):
185 self.x = notebook.get(xStr)
188 if isinstance(yStr, str) and notebook.isVariable(yStr):
189 self.y = notebook.get(yStr)
192 if isinstance(zStr, str) and notebook.isVariable(zStr):
193 self.z = notebook.get(zStr)
197 # Parametrized substitute for PointStruct (with 6 parameters)
198 class PointStructStr6:
213 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
220 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
221 self.x1 = notebook.get(x1Str)
224 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
225 self.x2 = notebook.get(x2Str)
228 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
229 self.y1 = notebook.get(y1Str)
232 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
233 self.y2 = notebook.get(y2Str)
236 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
237 self.z1 = notebook.get(z1Str)
240 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
241 self.z2 = notebook.get(z2Str)
245 # Parametrized substitute for AxisStruct
261 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
268 if isinstance(xStr, str) and notebook.isVariable(xStr):
269 self.x = notebook.get(xStr)
272 if isinstance(yStr, str) and notebook.isVariable(yStr):
273 self.y = notebook.get(yStr)
276 if isinstance(zStr, str) and notebook.isVariable(zStr):
277 self.z = notebook.get(zStr)
280 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
281 self.dx = notebook.get(dxStr)
284 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
285 self.dy = notebook.get(dyStr)
288 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
289 self.dz = notebook.get(dzStr)
293 # Parametrized substitute for DirStruct
296 def __init__(self, pointStruct):
297 self.pointStruct = pointStruct
299 # Returns list of variable values from salome notebook
300 def ParsePointStruct(Point):
301 Parameters = 2*var_separator
302 if isinstance(Point, PointStructStr):
303 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
304 Point = PointStruct(Point.x, Point.y, Point.z)
305 return Point, Parameters
307 # Returns list of variable values from salome notebook
308 def ParseDirStruct(Dir):
309 Parameters = 2*var_separator
310 if isinstance(Dir, DirStructStr):
311 pntStr = Dir.pointStruct
312 if isinstance(pntStr, PointStructStr6):
313 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
314 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
315 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
316 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
318 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
319 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
320 Dir = DirStruct(Point)
321 return Dir, Parameters
323 # Returns list of variable values from salome notebook
324 def ParseAxisStruct(Axis):
325 Parameters = 5*var_separator
326 if isinstance(Axis, AxisStructStr):
327 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
328 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
329 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
330 return Axis, Parameters
332 ## Return list of variable values from salome notebook
333 def ParseAngles(list):
336 for parameter in list:
337 if isinstance(parameter,str) and notebook.isVariable(parameter):
338 Result.append(DegreesToRadians(notebook.get(parameter)))
341 Result.append(parameter)
344 Parameters = Parameters + str(parameter)
345 Parameters = Parameters + var_separator
347 Parameters = Parameters[:len(Parameters)-1]
348 return Result, Parameters
350 def IsEqual(val1, val2, tol=PrecisionConfusion):
351 if abs(val1 - val2) < tol:
359 ior = salome.orb.object_to_string(obj)
360 sobj = salome.myStudy.FindObjectIOR(ior)
364 attr = sobj.FindAttribute("AttributeName")[1]
367 ## Prints error message if a hypothesis was not assigned.
368 def TreatHypoStatus(status, hypName, geomName, isAlgo):
370 hypType = "algorithm"
372 hypType = "hypothesis"
374 if status == HYP_UNKNOWN_FATAL :
375 reason = "for unknown reason"
376 elif status == HYP_INCOMPATIBLE :
377 reason = "this hypothesis mismatches the algorithm"
378 elif status == HYP_NOTCONFORM :
379 reason = "a non-conform mesh would be built"
380 elif status == HYP_ALREADY_EXIST :
381 reason = hypType + " of the same dimension is already assigned to this shape"
382 elif status == HYP_BAD_DIM :
383 reason = hypType + " mismatches the shape"
384 elif status == HYP_CONCURENT :
385 reason = "there are concurrent hypotheses on sub-shapes"
386 elif status == HYP_BAD_SUBSHAPE :
387 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
388 elif status == HYP_BAD_GEOMETRY:
389 reason = "geometry mismatches the expectation of the algorithm"
390 elif status == HYP_HIDDEN_ALGO:
391 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
392 elif status == HYP_HIDING_ALGO:
393 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
394 elif status == HYP_NEED_SHAPE:
395 reason = "Algorithm can't work without shape"
398 hypName = '"' + hypName + '"'
399 geomName= '"' + geomName+ '"'
400 if status < HYP_UNKNOWN_FATAL:
401 print hypName, "was assigned to", geomName,"but", reason
403 print hypName, "was not assigned to",geomName,":", reason
406 # end of l1_auxiliary
409 # All methods of this class are accessible directly from the smesh.py package.
410 class smeshDC(SMESH._objref_SMESH_Gen):
412 ## Sets the current study and Geometry component
413 # @ingroup l1_auxiliary
414 def init_smesh(self,theStudy,geompyD):
415 self.SetCurrentStudy(theStudy,geompyD)
417 ## Creates an empty Mesh. This mesh can have an underlying geometry.
418 # @param obj the Geometrical object on which the mesh is built. If not defined,
419 # the mesh will have no underlying geometry.
420 # @param name the name for the new mesh.
421 # @return an instance of Mesh class.
422 # @ingroup l2_construct
423 def Mesh(self, obj=0, name=0):
424 if isinstance(obj,str):
426 return Mesh(self,self.geompyD,obj,name)
428 ## Returns a long value from enumeration
429 # Should be used for SMESH.FunctorType enumeration
430 # @ingroup l1_controls
431 def EnumToLong(self,theItem):
434 ## Gets PointStruct from vertex
435 # @param theVertex a GEOM object(vertex)
436 # @return SMESH.PointStruct
437 # @ingroup l1_auxiliary
438 def GetPointStruct(self,theVertex):
439 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
440 return PointStruct(x,y,z)
442 ## Gets DirStruct from vector
443 # @param theVector a GEOM object(vector)
444 # @return SMESH.DirStruct
445 # @ingroup l1_auxiliary
446 def GetDirStruct(self,theVector):
447 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
448 if(len(vertices) != 2):
449 print "Error: vector object is incorrect."
451 p1 = self.geompyD.PointCoordinates(vertices[0])
452 p2 = self.geompyD.PointCoordinates(vertices[1])
453 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
454 dirst = DirStruct(pnt)
457 ## Makes DirStruct from a triplet
458 # @param x,y,z vector components
459 # @return SMESH.DirStruct
460 # @ingroup l1_auxiliary
461 def MakeDirStruct(self,x,y,z):
462 pnt = PointStruct(x,y,z)
463 return DirStruct(pnt)
465 ## Get AxisStruct from object
466 # @param theObj a GEOM object (line or plane)
467 # @return SMESH.AxisStruct
468 # @ingroup l1_auxiliary
469 def GetAxisStruct(self,theObj):
470 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
472 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
473 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
474 vertex1 = self.geompyD.PointCoordinates(vertex1)
475 vertex2 = self.geompyD.PointCoordinates(vertex2)
476 vertex3 = self.geompyD.PointCoordinates(vertex3)
477 vertex4 = self.geompyD.PointCoordinates(vertex4)
478 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
479 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
480 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] ]
481 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
483 elif len(edges) == 1:
484 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
485 p1 = self.geompyD.PointCoordinates( vertex1 )
486 p2 = self.geompyD.PointCoordinates( vertex2 )
487 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
491 # From SMESH_Gen interface:
492 # ------------------------
494 ## Sets the given name to the object
495 # @param obj the object to rename
496 # @param name a new object name
497 # @ingroup l1_auxiliary
498 def SetName(self, obj, name):
499 if isinstance( obj, Mesh ):
501 elif isinstance( obj, Mesh_Algorithm ):
502 obj = obj.GetAlgorithm()
503 ior = salome.orb.object_to_string(obj)
504 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
506 ## Sets the current mode
507 # @ingroup l1_auxiliary
508 def SetEmbeddedMode( self,theMode ):
509 #self.SetEmbeddedMode(theMode)
510 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
512 ## Gets the current mode
513 # @ingroup l1_auxiliary
514 def IsEmbeddedMode(self):
515 #return self.IsEmbeddedMode()
516 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
518 ## Sets the current study
519 # @ingroup l1_auxiliary
520 def SetCurrentStudy( self, theStudy, geompyD = None ):
521 #self.SetCurrentStudy(theStudy)
524 geompyD = geompy.geom
527 self.SetGeomEngine(geompyD)
528 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
530 ## Gets the current study
531 # @ingroup l1_auxiliary
532 def GetCurrentStudy(self):
533 #return self.GetCurrentStudy()
534 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
536 ## Creates a Mesh object importing data from the given UNV file
537 # @return an instance of Mesh class
539 def CreateMeshesFromUNV( self,theFileName ):
540 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
541 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
544 ## Creates a Mesh object(s) importing data from the given MED file
545 # @return a list of Mesh class instances
547 def CreateMeshesFromMED( self,theFileName ):
548 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
550 for iMesh in range(len(aSmeshMeshes)) :
551 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
552 aMeshes.append(aMesh)
553 return aMeshes, aStatus
555 ## Creates a Mesh object importing data from the given STL file
556 # @return an instance of Mesh class
558 def CreateMeshesFromSTL( self, theFileName ):
559 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
560 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
563 ## From SMESH_Gen interface
564 # @return the list of integer values
565 # @ingroup l1_auxiliary
566 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
567 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
569 ## From SMESH_Gen interface. Creates a pattern
570 # @return an instance of SMESH_Pattern
572 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
573 # @ingroup l2_modif_patterns
574 def GetPattern(self):
575 return SMESH._objref_SMESH_Gen.GetPattern(self)
577 ## Sets number of segments per diagonal of boundary box of geometry by which
578 # default segment length of appropriate 1D hypotheses is defined.
579 # Default value is 10
580 # @ingroup l1_auxiliary
581 def SetBoundaryBoxSegmentation(self, nbSegments):
582 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
584 ## Concatenate the given meshes into one mesh.
585 # @return an instance of Mesh class
586 # @param meshes the meshes to combine into one mesh
587 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
588 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
589 # @param mergeTolerance tolerance for merging nodes
590 # @param allGroups forces creation of groups of all elements
591 def Concatenate( self, meshes, uniteIdenticalGroups,
592 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
593 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
595 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
596 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
598 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
599 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
600 aSmeshMesh.SetParameters(Parameters)
601 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
604 # Filtering. Auxiliary functions:
605 # ------------------------------
607 ## Creates an empty criterion
608 # @return SMESH.Filter.Criterion
609 # @ingroup l1_controls
610 def GetEmptyCriterion(self):
611 Type = self.EnumToLong(FT_Undefined)
612 Compare = self.EnumToLong(FT_Undefined)
616 UnaryOp = self.EnumToLong(FT_Undefined)
617 BinaryOp = self.EnumToLong(FT_Undefined)
620 Precision = -1 ##@1e-07
621 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
622 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
624 ## Creates a criterion by the given parameters
625 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
626 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
627 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
628 # @param Treshold the threshold value (range of ids as string, shape, numeric)
629 # @param UnaryOp FT_LogicalNOT or FT_Undefined
630 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
631 # FT_Undefined (must be for the last criterion of all criteria)
632 # @return SMESH.Filter.Criterion
633 # @ingroup l1_controls
634 def GetCriterion(self,elementType,
636 Compare = FT_EqualTo,
638 UnaryOp=FT_Undefined,
639 BinaryOp=FT_Undefined):
640 aCriterion = self.GetEmptyCriterion()
641 aCriterion.TypeOfElement = elementType
642 aCriterion.Type = self.EnumToLong(CritType)
646 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
647 aCriterion.Compare = self.EnumToLong(Compare)
648 elif Compare == "=" or Compare == "==":
649 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
651 aCriterion.Compare = self.EnumToLong(FT_LessThan)
653 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
655 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
658 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
659 FT_BelongToCylinder, FT_LyingOnGeom]:
660 # Checks the treshold
661 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
662 aCriterion.ThresholdStr = GetName(aTreshold)
663 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
665 print "Error: The treshold should be a shape."
667 elif CritType == FT_RangeOfIds:
668 # Checks the treshold
669 if isinstance(aTreshold, str):
670 aCriterion.ThresholdStr = aTreshold
672 print "Error: The treshold should be a string."
674 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
675 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
676 # At this point the treshold is unnecessary
677 if aTreshold == FT_LogicalNOT:
678 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
679 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
680 aCriterion.BinaryOp = aTreshold
684 aTreshold = float(aTreshold)
685 aCriterion.Threshold = aTreshold
687 print "Error: The treshold should be a number."
690 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
691 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
693 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
694 aCriterion.BinaryOp = self.EnumToLong(Treshold)
696 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
697 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
699 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
700 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
704 ## Creates a filter with the given parameters
705 # @param elementType the type of elements in the group
706 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
707 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
708 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
709 # @param UnaryOp FT_LogicalNOT or FT_Undefined
710 # @return SMESH_Filter
711 # @ingroup l1_controls
712 def GetFilter(self,elementType,
713 CritType=FT_Undefined,
716 UnaryOp=FT_Undefined):
717 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
718 aFilterMgr = self.CreateFilterManager()
719 aFilter = aFilterMgr.CreateFilter()
721 aCriteria.append(aCriterion)
722 aFilter.SetCriteria(aCriteria)
725 ## Creates a numerical functor by its type
726 # @param theCriterion FT_...; functor type
727 # @return SMESH_NumericalFunctor
728 # @ingroup l1_controls
729 def GetFunctor(self,theCriterion):
730 aFilterMgr = self.CreateFilterManager()
731 if theCriterion == FT_AspectRatio:
732 return aFilterMgr.CreateAspectRatio()
733 elif theCriterion == FT_AspectRatio3D:
734 return aFilterMgr.CreateAspectRatio3D()
735 elif theCriterion == FT_Warping:
736 return aFilterMgr.CreateWarping()
737 elif theCriterion == FT_MinimumAngle:
738 return aFilterMgr.CreateMinimumAngle()
739 elif theCriterion == FT_Taper:
740 return aFilterMgr.CreateTaper()
741 elif theCriterion == FT_Skew:
742 return aFilterMgr.CreateSkew()
743 elif theCriterion == FT_Area:
744 return aFilterMgr.CreateArea()
745 elif theCriterion == FT_Volume3D:
746 return aFilterMgr.CreateVolume3D()
747 elif theCriterion == FT_MultiConnection:
748 return aFilterMgr.CreateMultiConnection()
749 elif theCriterion == FT_MultiConnection2D:
750 return aFilterMgr.CreateMultiConnection2D()
751 elif theCriterion == FT_Length:
752 return aFilterMgr.CreateLength()
753 elif theCriterion == FT_Length2D:
754 return aFilterMgr.CreateLength2D()
756 print "Error: given parameter is not numerucal functor type."
758 ## Creates hypothesis
761 # @return created hypothesis instance
762 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
763 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
766 #Registering the new proxy for SMESH_Gen
767 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
773 ## This class allows defining and managing a mesh.
774 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
775 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
776 # new nodes and elements and by changing the existing entities), to get information
777 # about a mesh and to export a mesh into different formats.
786 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
787 # sets the GUI name of this mesh to \a name.
788 # @param smeshpyD an instance of smeshDC class
789 # @param geompyD an instance of geompyDC class
790 # @param obj Shape to be meshed or SMESH_Mesh object
791 # @param name Study name of the mesh
792 # @ingroup l2_construct
793 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
794 self.smeshpyD=smeshpyD
799 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
801 self.mesh = self.smeshpyD.CreateMesh(self.geom)
802 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
805 self.mesh = self.smeshpyD.CreateEmptyMesh()
807 self.smeshpyD.SetName(self.mesh, name)
809 self.smeshpyD.SetName(self.mesh, GetName(obj))
812 self.geom = self.mesh.GetShapeToMesh()
814 self.editor = self.mesh.GetMeshEditor()
816 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
817 # @param theMesh a SMESH_Mesh object
818 # @ingroup l2_construct
819 def SetMesh(self, theMesh):
821 self.geom = self.mesh.GetShapeToMesh()
823 ## Returns the mesh, that is an instance of SMESH_Mesh interface
824 # @return a SMESH_Mesh object
825 # @ingroup l2_construct
829 ## Gets the name of the mesh
830 # @return the name of the mesh as a string
831 # @ingroup l2_construct
833 name = GetName(self.GetMesh())
836 ## Sets a name to the mesh
837 # @param name a new name of the mesh
838 # @ingroup l2_construct
839 def SetName(self, name):
840 self.smeshpyD.SetName(self.GetMesh(), name)
842 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
843 # The subMesh object gives access to the IDs of nodes and elements.
844 # @param theSubObject a geometrical object (shape)
845 # @param theName a name for the submesh
846 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
847 # @ingroup l2_submeshes
848 def GetSubMesh(self, theSubObject, theName):
849 submesh = self.mesh.GetSubMesh(theSubObject, theName)
852 ## Returns the shape associated to the mesh
853 # @return a GEOM_Object
854 # @ingroup l2_construct
858 ## Associates the given shape to the mesh (entails the recreation of the mesh)
859 # @param geom the shape to be meshed (GEOM_Object)
860 # @ingroup l2_construct
861 def SetShape(self, geom):
862 self.mesh = self.smeshpyD.CreateMesh(geom)
864 ## Returns true if the hypotheses are defined well
865 # @param theSubObject a subshape of a mesh shape
866 # @return True or False
867 # @ingroup l2_construct
868 def IsReadyToCompute(self, theSubObject):
869 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
871 ## Returns errors of hypotheses definition.
872 # The list of errors is empty if everything is OK.
873 # @param theSubObject a subshape of a mesh shape
874 # @return a list of errors
875 # @ingroup l2_construct
876 def GetAlgoState(self, theSubObject):
877 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
879 ## Returns a geometrical object on which the given element was built.
880 # The returned geometrical object, if not nil, is either found in the
881 # study or published by this method with the given name
882 # @param theElementID the id of the mesh element
883 # @param theGeomName the user-defined name of the geometrical object
884 # @return GEOM::GEOM_Object instance
885 # @ingroup l2_construct
886 def GetGeometryByMeshElement(self, theElementID, theGeomName):
887 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
889 ## Returns the mesh dimension depending on the dimension of the underlying shape
890 # @return mesh dimension as an integer value [0,3]
891 # @ingroup l1_auxiliary
892 def MeshDimension(self):
893 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
894 if len( shells ) > 0 :
896 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
898 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
904 ## Creates a segment discretization 1D algorithm.
905 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
906 # \n If the optional \a geom parameter is not set, this algorithm is global.
907 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
908 # @param algo the type of the required algorithm. Possible values are:
910 # - smesh.PYTHON for discretization via a python function,
911 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
912 # @param geom If defined is the subshape to be meshed
913 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
914 # @ingroup l3_algos_basic
915 def Segment(self, algo=REGULAR, geom=0):
916 ## if Segment(geom) is called by mistake
917 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
918 algo, geom = geom, algo
919 if not algo: algo = REGULAR
922 return Mesh_Segment(self, geom)
924 return Mesh_Segment_Python(self, geom)
925 elif algo == COMPOSITE:
926 return Mesh_CompositeSegment(self, geom)
928 return Mesh_Segment(self, geom)
930 ## Enables creation of nodes and segments usable by 2D algoritms.
931 # The added nodes and segments must be bound to edges and vertices by
932 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
933 # If the optional \a geom parameter is not set, this algorithm is global.
934 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
935 # @param geom the subshape to be manually meshed
936 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
937 # @ingroup l3_algos_basic
938 def UseExistingSegments(self, geom=0):
939 algo = Mesh_UseExisting(1,self,geom)
940 return algo.GetAlgorithm()
942 ## Enables creation of nodes and faces usable by 3D algoritms.
943 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
944 # and SetMeshElementOnShape()
945 # If the optional \a geom parameter is not set, this algorithm is global.
946 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
947 # @param geom the subshape to be manually meshed
948 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
949 # @ingroup l3_algos_basic
950 def UseExistingFaces(self, geom=0):
951 algo = Mesh_UseExisting(2,self,geom)
952 return algo.GetAlgorithm()
954 ## Creates a triangle 2D algorithm for faces.
955 # If the optional \a geom parameter is not set, this algorithm is global.
956 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
957 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
958 # @param geom If defined, the subshape to be meshed (GEOM_Object)
959 # @return an instance of Mesh_Triangle algorithm
960 # @ingroup l3_algos_basic
961 def Triangle(self, algo=MEFISTO, geom=0):
962 ## if Triangle(geom) is called by mistake
963 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
967 return Mesh_Triangle(self, algo, geom)
969 ## Creates a quadrangle 2D algorithm for faces.
970 # If the optional \a geom parameter is not set, this algorithm is global.
971 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
972 # @param geom If defined, the subshape to be meshed (GEOM_Object)
973 # @return an instance of Mesh_Quadrangle algorithm
974 # @ingroup l3_algos_basic
975 def Quadrangle(self, geom=0):
976 return Mesh_Quadrangle(self, geom)
978 ## Creates a tetrahedron 3D algorithm for solids.
979 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
980 # If the optional \a geom parameter is not set, this algorithm is global.
981 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
982 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
983 # @param geom If defined, the subshape to be meshed (GEOM_Object)
984 # @return an instance of Mesh_Tetrahedron algorithm
985 # @ingroup l3_algos_basic
986 def Tetrahedron(self, algo=NETGEN, geom=0):
987 ## if Tetrahedron(geom) is called by mistake
988 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
989 algo, geom = geom, algo
990 if not algo: algo = NETGEN
992 return Mesh_Tetrahedron(self, algo, geom)
994 ## Creates a hexahedron 3D algorithm for solids.
995 # If the optional \a geom parameter is not set, this algorithm is global.
996 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
997 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
998 # @param geom If defined, the subshape to be meshed (GEOM_Object)
999 # @return an instance of Mesh_Hexahedron algorithm
1000 # @ingroup l3_algos_basic
1001 def Hexahedron(self, algo=Hexa, geom=0):
1002 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1003 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1004 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1005 elif geom == 0: algo, geom = Hexa, algo
1006 return Mesh_Hexahedron(self, algo, geom)
1008 ## Deprecated, used only for compatibility!
1009 # @return an instance of Mesh_Netgen algorithm
1010 # @ingroup l3_algos_basic
1011 def Netgen(self, is3D, geom=0):
1012 return Mesh_Netgen(self, is3D, geom)
1014 ## Creates a projection 1D algorithm for edges.
1015 # If the optional \a geom parameter is not set, this algorithm is global.
1016 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1017 # @param geom If defined, the subshape to be meshed
1018 # @return an instance of Mesh_Projection1D algorithm
1019 # @ingroup l3_algos_proj
1020 def Projection1D(self, geom=0):
1021 return Mesh_Projection1D(self, geom)
1023 ## Creates a projection 2D algorithm for faces.
1024 # If the optional \a geom parameter is not set, this algorithm is global.
1025 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1026 # @param geom If defined, the subshape to be meshed
1027 # @return an instance of Mesh_Projection2D algorithm
1028 # @ingroup l3_algos_proj
1029 def Projection2D(self, geom=0):
1030 return Mesh_Projection2D(self, geom)
1032 ## Creates a projection 3D algorithm for solids.
1033 # If the optional \a geom parameter is not set, this algorithm is global.
1034 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1035 # @param geom If defined, the subshape to be meshed
1036 # @return an instance of Mesh_Projection3D algorithm
1037 # @ingroup l3_algos_proj
1038 def Projection3D(self, geom=0):
1039 return Mesh_Projection3D(self, geom)
1041 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1042 # If the optional \a geom parameter is not set, this algorithm is global.
1043 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1044 # @param geom If defined, the subshape to be meshed
1045 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1046 # @ingroup l3_algos_radialp l3_algos_3dextr
1047 def Prism(self, geom=0):
1051 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1052 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1053 if nbSolids == 0 or nbSolids == nbShells:
1054 return Mesh_Prism3D(self, geom)
1055 return Mesh_RadialPrism3D(self, geom)
1057 ## Evaluates size of prospective mesh on a shape
1058 # @return True or False
1059 def Evaluate(self, geom=0):
1060 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1062 geom = self.mesh.GetShapeToMesh()
1065 return self.smeshpyD.Evaluate(self.mesh, geom)
1068 ## Computes the mesh and returns the status of the computation
1069 # @return True or False
1070 # @ingroup l2_construct
1071 def Compute(self, geom=0):
1072 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1074 geom = self.mesh.GetShapeToMesh()
1079 ok = self.smeshpyD.Compute(self.mesh, geom)
1080 except SALOME.SALOME_Exception, ex:
1081 print "Mesh computation failed, exception caught:"
1082 print " ", ex.details.text
1085 print "Mesh computation failed, exception caught:"
1086 traceback.print_exc()
1088 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1091 if err.isGlobalAlgo:
1099 reason = '%s %sD algorithm is missing' % (glob, dim)
1100 elif err.state == HYP_MISSING:
1101 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1102 % (glob, dim, name, dim))
1103 elif err.state == HYP_NOTCONFORM:
1104 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1105 elif err.state == HYP_BAD_PARAMETER:
1106 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1107 % ( glob, dim, name ))
1108 elif err.state == HYP_BAD_GEOMETRY:
1109 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1110 'geometry' % ( glob, dim, name ))
1112 reason = "For unknown reason."+\
1113 " Revise Mesh.Compute() implementation in smeshDC.py!"
1115 if allReasons != "":
1118 allReasons += reason
1120 if allReasons != "":
1121 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1125 print '"' + GetName(self.mesh) + '"',"has not been computed."
1128 if salome.sg.hasDesktop():
1129 smeshgui = salome.ImportComponentGUI("SMESH")
1130 smeshgui.Init(self.mesh.GetStudyId())
1131 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1132 salome.sg.updateObjBrowser(1)
1136 ## Removes all nodes and elements
1137 # @ingroup l2_construct
1140 if salome.sg.hasDesktop():
1141 smeshgui = salome.ImportComponentGUI("SMESH")
1142 smeshgui.Init(self.mesh.GetStudyId())
1143 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1144 salome.sg.updateObjBrowser(1)
1146 ## Removes all nodes and elements of indicated shape
1147 # @ingroup l2_construct
1148 def ClearSubMesh(self, geomId):
1149 self.mesh.ClearSubMesh(geomId)
1150 if salome.sg.hasDesktop():
1151 smeshgui = salome.ImportComponentGUI("SMESH")
1152 smeshgui.Init(self.mesh.GetStudyId())
1153 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1154 salome.sg.updateObjBrowser(1)
1156 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1157 # @param fineness [0,-1] defines mesh fineness
1158 # @return True or False
1159 # @ingroup l3_algos_basic
1160 def AutomaticTetrahedralization(self, fineness=0):
1161 dim = self.MeshDimension()
1163 self.RemoveGlobalHypotheses()
1164 self.Segment().AutomaticLength(fineness)
1166 self.Triangle().LengthFromEdges()
1169 self.Tetrahedron(NETGEN)
1171 return self.Compute()
1173 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1174 # @param fineness [0,-1] defines mesh fineness
1175 # @return True or False
1176 # @ingroup l3_algos_basic
1177 def AutomaticHexahedralization(self, fineness=0):
1178 dim = self.MeshDimension()
1179 # assign the hypotheses
1180 self.RemoveGlobalHypotheses()
1181 self.Segment().AutomaticLength(fineness)
1188 return self.Compute()
1190 ## Assigns a hypothesis
1191 # @param hyp a hypothesis to assign
1192 # @param geom a subhape of mesh geometry
1193 # @return SMESH.Hypothesis_Status
1194 # @ingroup l2_hypotheses
1195 def AddHypothesis(self, hyp, geom=0):
1196 if isinstance( hyp, Mesh_Algorithm ):
1197 hyp = hyp.GetAlgorithm()
1202 geom = self.mesh.GetShapeToMesh()
1204 status = self.mesh.AddHypothesis(geom, hyp)
1205 isAlgo = hyp._narrow( SMESH_Algo )
1206 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1209 ## Unassigns a hypothesis
1210 # @param hyp a hypothesis to unassign
1211 # @param geom a subshape of mesh geometry
1212 # @return SMESH.Hypothesis_Status
1213 # @ingroup l2_hypotheses
1214 def RemoveHypothesis(self, hyp, geom=0):
1215 if isinstance( hyp, Mesh_Algorithm ):
1216 hyp = hyp.GetAlgorithm()
1221 status = self.mesh.RemoveHypothesis(geom, hyp)
1224 ## Gets the list of hypotheses added on a geometry
1225 # @param geom a subshape of mesh geometry
1226 # @return the sequence of SMESH_Hypothesis
1227 # @ingroup l2_hypotheses
1228 def GetHypothesisList(self, geom):
1229 return self.mesh.GetHypothesisList( geom )
1231 ## Removes all global hypotheses
1232 # @ingroup l2_hypotheses
1233 def RemoveGlobalHypotheses(self):
1234 current_hyps = self.mesh.GetHypothesisList( self.geom )
1235 for hyp in current_hyps:
1236 self.mesh.RemoveHypothesis( self.geom, hyp )
1240 ## Creates a mesh group based on the geometric object \a grp
1241 # and gives a \a name, \n if this parameter is not defined
1242 # the name is the same as the geometric group name \n
1243 # Note: Works like GroupOnGeom().
1244 # @param grp a geometric group, a vertex, an edge, a face or a solid
1245 # @param name the name of the mesh group
1246 # @return SMESH_GroupOnGeom
1247 # @ingroup l2_grps_create
1248 def Group(self, grp, name=""):
1249 return self.GroupOnGeom(grp, name)
1251 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1252 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1253 # @param f the file name
1254 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1255 # @ingroup l2_impexp
1256 def ExportToMED(self, f, version, opt=0):
1257 self.mesh.ExportToMED(f, opt, version)
1259 ## Exports the mesh in a file in MED format
1260 # @param f is the file name
1261 # @param auto_groups boolean parameter for creating/not creating
1262 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1263 # the typical use is auto_groups=false.
1264 # @param version MED format version(MED_V2_1 or MED_V2_2)
1265 # @ingroup l2_impexp
1266 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1267 self.mesh.ExportToMED(f, auto_groups, version)
1269 ## Exports the mesh in a file in DAT format
1270 # @param f the file name
1271 # @ingroup l2_impexp
1272 def ExportDAT(self, f):
1273 self.mesh.ExportDAT(f)
1275 ## Exports the mesh in a file in UNV format
1276 # @param f the file name
1277 # @ingroup l2_impexp
1278 def ExportUNV(self, f):
1279 self.mesh.ExportUNV(f)
1281 ## Export the mesh in a file in STL format
1282 # @param f the file name
1283 # @param ascii defines the file encoding
1284 # @ingroup l2_impexp
1285 def ExportSTL(self, f, ascii=1):
1286 self.mesh.ExportSTL(f, ascii)
1289 # Operations with groups:
1290 # ----------------------
1292 ## Creates an empty mesh group
1293 # @param elementType the type of elements in the group
1294 # @param name the name of the mesh group
1295 # @return SMESH_Group
1296 # @ingroup l2_grps_create
1297 def CreateEmptyGroup(self, elementType, name):
1298 return self.mesh.CreateGroup(elementType, name)
1300 ## Creates a mesh group based on the geometrical object \a grp
1301 # and gives a \a name, \n if this parameter is not defined
1302 # the name is the same as the geometrical group name
1303 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1304 # @param name the name of the mesh group
1305 # @param typ the type of elements in the group. If not set, it is
1306 # automatically detected by the type of the geometry
1307 # @return SMESH_GroupOnGeom
1308 # @ingroup l2_grps_create
1309 def GroupOnGeom(self, grp, name="", typ=None):
1311 name = grp.GetName()
1314 tgeo = str(grp.GetShapeType())
1315 if tgeo == "VERTEX":
1317 elif tgeo == "EDGE":
1319 elif tgeo == "FACE":
1321 elif tgeo == "SOLID":
1323 elif tgeo == "SHELL":
1325 elif tgeo == "COMPOUND":
1326 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1327 print "Mesh.Group: empty geometric group", GetName( grp )
1329 tgeo = self.geompyD.GetType(grp)
1330 if tgeo == geompyDC.ShapeType["VERTEX"]:
1332 elif tgeo == geompyDC.ShapeType["EDGE"]:
1334 elif tgeo == geompyDC.ShapeType["FACE"]:
1336 elif tgeo == geompyDC.ShapeType["SOLID"]:
1340 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1343 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1345 ## Creates a mesh group by the given ids of elements
1346 # @param groupName the name of the mesh group
1347 # @param elementType the type of elements in the group
1348 # @param elemIDs the list of ids
1349 # @return SMESH_Group
1350 # @ingroup l2_grps_create
1351 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1352 group = self.mesh.CreateGroup(elementType, groupName)
1356 ## Creates a mesh group by the given conditions
1357 # @param groupName the name of the mesh group
1358 # @param elementType the type of elements in the group
1359 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1360 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1361 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1362 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1363 # @return SMESH_Group
1364 # @ingroup l2_grps_create
1368 CritType=FT_Undefined,
1371 UnaryOp=FT_Undefined):
1372 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1373 group = self.MakeGroupByCriterion(groupName, aCriterion)
1376 ## Creates a mesh group by the given criterion
1377 # @param groupName the name of the mesh group
1378 # @param Criterion the instance of Criterion class
1379 # @return SMESH_Group
1380 # @ingroup l2_grps_create
1381 def MakeGroupByCriterion(self, groupName, Criterion):
1382 aFilterMgr = self.smeshpyD.CreateFilterManager()
1383 aFilter = aFilterMgr.CreateFilter()
1385 aCriteria.append(Criterion)
1386 aFilter.SetCriteria(aCriteria)
1387 group = self.MakeGroupByFilter(groupName, aFilter)
1390 ## Creates a mesh group by the given criteria (list of criteria)
1391 # @param groupName the name of the mesh group
1392 # @param theCriteria the list of criteria
1393 # @return SMESH_Group
1394 # @ingroup l2_grps_create
1395 def MakeGroupByCriteria(self, groupName, theCriteria):
1396 aFilterMgr = self.smeshpyD.CreateFilterManager()
1397 aFilter = aFilterMgr.CreateFilter()
1398 aFilter.SetCriteria(theCriteria)
1399 group = self.MakeGroupByFilter(groupName, aFilter)
1402 ## Creates a mesh group by the given filter
1403 # @param groupName the name of the mesh group
1404 # @param theFilter the instance of Filter class
1405 # @return SMESH_Group
1406 # @ingroup l2_grps_create
1407 def MakeGroupByFilter(self, groupName, theFilter):
1408 anIds = theFilter.GetElementsId(self.mesh)
1409 anElemType = theFilter.GetElementType()
1410 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1413 ## Passes mesh elements through the given filter and return IDs of fitting elements
1414 # @param theFilter SMESH_Filter
1415 # @return a list of ids
1416 # @ingroup l1_controls
1417 def GetIdsFromFilter(self, theFilter):
1418 return theFilter.GetElementsId(self.mesh)
1420 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1421 # Returns a list of special structures (borders).
1422 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1423 # @ingroup l1_controls
1424 def GetFreeBorders(self):
1425 aFilterMgr = self.smeshpyD.CreateFilterManager()
1426 aPredicate = aFilterMgr.CreateFreeEdges()
1427 aPredicate.SetMesh(self.mesh)
1428 aBorders = aPredicate.GetBorders()
1432 # @ingroup l2_grps_delete
1433 def RemoveGroup(self, group):
1434 self.mesh.RemoveGroup(group)
1436 ## Removes a group with its contents
1437 # @ingroup l2_grps_delete
1438 def RemoveGroupWithContents(self, group):
1439 self.mesh.RemoveGroupWithContents(group)
1441 ## Gets the list of groups existing in the mesh
1442 # @return a sequence of SMESH_GroupBase
1443 # @ingroup l2_grps_create
1444 def GetGroups(self):
1445 return self.mesh.GetGroups()
1447 ## Gets the number of groups existing in the mesh
1448 # @return the quantity of groups as an integer value
1449 # @ingroup l2_grps_create
1451 return self.mesh.NbGroups()
1453 ## Gets the list of names of groups existing in the mesh
1454 # @return list of strings
1455 # @ingroup l2_grps_create
1456 def GetGroupNames(self):
1457 groups = self.GetGroups()
1459 for group in groups:
1460 names.append(group.GetName())
1463 ## Produces a union of two groups
1464 # A new group is created. All mesh elements that are
1465 # present in the initial groups are added to the new one
1466 # @return an instance of SMESH_Group
1467 # @ingroup l2_grps_operon
1468 def UnionGroups(self, group1, group2, name):
1469 return self.mesh.UnionGroups(group1, group2, name)
1471 ## Produces a union list of groups
1472 # New group is created. All mesh elements that are present in
1473 # initial groups are added to the new one
1474 # @return an instance of SMESH_Group
1475 # @ingroup l2_grps_operon
1476 def UnionListOfGroups(self, groups, name):
1477 return self.mesh.UnionListOfGroups(groups, name)
1479 ## Prodices an intersection of two groups
1480 # A new group is created. All mesh elements that are common
1481 # for the two initial groups are added to the new one.
1482 # @return an instance of SMESH_Group
1483 # @ingroup l2_grps_operon
1484 def IntersectGroups(self, group1, group2, name):
1485 return self.mesh.IntersectGroups(group1, group2, name)
1487 ## Produces an intersection of groups
1488 # New group is created. All mesh elements that are present in all
1489 # initial groups simultaneously are added to the new one
1490 # @return an instance of SMESH_Group
1491 # @ingroup l2_grps_operon
1492 def IntersectListOfGroups(self, groups, name):
1493 return self.mesh.IntersectListOfGroups(groups, name)
1495 ## Produces a cut of two groups
1496 # A new group is created. All mesh elements that are present in
1497 # the main group but are not present in the tool group are added to the new one
1498 # @return an instance of SMESH_Group
1499 # @ingroup l2_grps_operon
1500 def CutGroups(self, main_group, tool_group, name):
1501 return self.mesh.CutGroups(main_group, tool_group, name)
1503 ## Produces a cut of groups
1504 # A new group is created. All mesh elements that are present in main groups
1505 # but do not present in tool groups are added to the new one
1506 # @return an instance of SMESH_Group
1507 # @ingroup l2_grps_operon
1508 def CutListOfGroups(self, main_groups, tool_groups, name):
1509 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1511 ## Produces a group of elements with specified element type using list of existing groups
1512 # A new group is created. System
1513 # 1) extract all nodes on which groups elements are built
1514 # 2) combine all elements of specified dimension laying on these nodes
1515 # @return an instance of SMESH_Group
1516 # @ingroup l2_grps_operon
1517 def CreateDimGroup(self, groups, elem_type, name):
1518 return self.mesh.CreateDimGroup(groups, elem_type, name)
1521 ## Convert group on geom into standalone group
1522 # @ingroup l2_grps_delete
1523 def ConvertToStandalone(self, group):
1524 return self.mesh.ConvertToStandalone(group)
1526 # Get some info about mesh:
1527 # ------------------------
1529 ## Returns the log of nodes and elements added or removed
1530 # since the previous clear of the log.
1531 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1532 # @return list of log_block structures:
1537 # @ingroup l1_auxiliary
1538 def GetLog(self, clearAfterGet):
1539 return self.mesh.GetLog(clearAfterGet)
1541 ## Clears the log of nodes and elements added or removed since the previous
1542 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1543 # @ingroup l1_auxiliary
1545 self.mesh.ClearLog()
1547 ## Toggles auto color mode on the object.
1548 # @param theAutoColor the flag which toggles auto color mode.
1549 # @ingroup l1_auxiliary
1550 def SetAutoColor(self, theAutoColor):
1551 self.mesh.SetAutoColor(theAutoColor)
1553 ## Gets flag of object auto color mode.
1554 # @return True or False
1555 # @ingroup l1_auxiliary
1556 def GetAutoColor(self):
1557 return self.mesh.GetAutoColor()
1559 ## Gets the internal ID
1560 # @return integer value, which is the internal Id of the mesh
1561 # @ingroup l1_auxiliary
1563 return self.mesh.GetId()
1566 # @return integer value, which is the study Id of the mesh
1567 # @ingroup l1_auxiliary
1568 def GetStudyId(self):
1569 return self.mesh.GetStudyId()
1571 ## Checks the group names for duplications.
1572 # Consider the maximum group name length stored in MED file.
1573 # @return True or False
1574 # @ingroup l1_auxiliary
1575 def HasDuplicatedGroupNamesMED(self):
1576 return self.mesh.HasDuplicatedGroupNamesMED()
1578 ## Obtains the mesh editor tool
1579 # @return an instance of SMESH_MeshEditor
1580 # @ingroup l1_modifying
1581 def GetMeshEditor(self):
1582 return self.mesh.GetMeshEditor()
1585 # @return an instance of SALOME_MED::MESH
1586 # @ingroup l1_auxiliary
1587 def GetMEDMesh(self):
1588 return self.mesh.GetMEDMesh()
1591 # Get informations about mesh contents:
1592 # ------------------------------------
1594 ## Gets the mesh stattistic
1595 # @return dictionary type element - count of elements
1596 # @ingroup l1_meshinfo
1597 def GetMeshInfo(self, obj = None):
1598 if not obj: obj = self.mesh
1600 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1601 values = obj.GetMeshInfo()
1602 for i in range(SMESH.Entity_Last._v):
1603 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1607 ## Returns the number of nodes in the mesh
1608 # @return an integer value
1609 # @ingroup l1_meshinfo
1611 return self.mesh.NbNodes()
1613 ## Returns the number of elements in the mesh
1614 # @return an integer value
1615 # @ingroup l1_meshinfo
1616 def NbElements(self):
1617 return self.mesh.NbElements()
1619 ## Returns the number of 0d elements in the mesh
1620 # @return an integer value
1621 # @ingroup l1_meshinfo
1622 def Nb0DElements(self):
1623 return self.mesh.Nb0DElements()
1625 ## Returns the number of edges in the mesh
1626 # @return an integer value
1627 # @ingroup l1_meshinfo
1629 return self.mesh.NbEdges()
1631 ## Returns the number of edges with the given order in the mesh
1632 # @param elementOrder the order of elements:
1633 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1634 # @return an integer value
1635 # @ingroup l1_meshinfo
1636 def NbEdgesOfOrder(self, elementOrder):
1637 return self.mesh.NbEdgesOfOrder(elementOrder)
1639 ## Returns the number of faces in the mesh
1640 # @return an integer value
1641 # @ingroup l1_meshinfo
1643 return self.mesh.NbFaces()
1645 ## Returns the number of faces with the given order in the mesh
1646 # @param elementOrder the order of elements:
1647 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1648 # @return an integer value
1649 # @ingroup l1_meshinfo
1650 def NbFacesOfOrder(self, elementOrder):
1651 return self.mesh.NbFacesOfOrder(elementOrder)
1653 ## Returns the number of triangles in the mesh
1654 # @return an integer value
1655 # @ingroup l1_meshinfo
1656 def NbTriangles(self):
1657 return self.mesh.NbTriangles()
1659 ## Returns the number of triangles with the given order in the mesh
1660 # @param elementOrder is the order of elements:
1661 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1662 # @return an integer value
1663 # @ingroup l1_meshinfo
1664 def NbTrianglesOfOrder(self, elementOrder):
1665 return self.mesh.NbTrianglesOfOrder(elementOrder)
1667 ## Returns the number of quadrangles in the mesh
1668 # @return an integer value
1669 # @ingroup l1_meshinfo
1670 def NbQuadrangles(self):
1671 return self.mesh.NbQuadrangles()
1673 ## Returns the number of quadrangles with the given order in the mesh
1674 # @param elementOrder the order of elements:
1675 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1676 # @return an integer value
1677 # @ingroup l1_meshinfo
1678 def NbQuadranglesOfOrder(self, elementOrder):
1679 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1681 ## Returns the number of polygons in the mesh
1682 # @return an integer value
1683 # @ingroup l1_meshinfo
1684 def NbPolygons(self):
1685 return self.mesh.NbPolygons()
1687 ## Returns the number of volumes in the mesh
1688 # @return an integer value
1689 # @ingroup l1_meshinfo
1690 def NbVolumes(self):
1691 return self.mesh.NbVolumes()
1693 ## Returns the number of volumes with the given order in the mesh
1694 # @param elementOrder the order of elements:
1695 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1696 # @return an integer value
1697 # @ingroup l1_meshinfo
1698 def NbVolumesOfOrder(self, elementOrder):
1699 return self.mesh.NbVolumesOfOrder(elementOrder)
1701 ## Returns the number of tetrahedrons in the mesh
1702 # @return an integer value
1703 # @ingroup l1_meshinfo
1705 return self.mesh.NbTetras()
1707 ## Returns the number of tetrahedrons with the given order in the mesh
1708 # @param elementOrder the order of elements:
1709 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1710 # @return an integer value
1711 # @ingroup l1_meshinfo
1712 def NbTetrasOfOrder(self, elementOrder):
1713 return self.mesh.NbTetrasOfOrder(elementOrder)
1715 ## Returns the number of hexahedrons in the mesh
1716 # @return an integer value
1717 # @ingroup l1_meshinfo
1719 return self.mesh.NbHexas()
1721 ## Returns the number of hexahedrons with the given order in the mesh
1722 # @param elementOrder the order of elements:
1723 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1724 # @return an integer value
1725 # @ingroup l1_meshinfo
1726 def NbHexasOfOrder(self, elementOrder):
1727 return self.mesh.NbHexasOfOrder(elementOrder)
1729 ## Returns the number of pyramids in the mesh
1730 # @return an integer value
1731 # @ingroup l1_meshinfo
1732 def NbPyramids(self):
1733 return self.mesh.NbPyramids()
1735 ## Returns the number of pyramids with the given order in the mesh
1736 # @param elementOrder the order of elements:
1737 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1738 # @return an integer value
1739 # @ingroup l1_meshinfo
1740 def NbPyramidsOfOrder(self, elementOrder):
1741 return self.mesh.NbPyramidsOfOrder(elementOrder)
1743 ## Returns the number of prisms in the mesh
1744 # @return an integer value
1745 # @ingroup l1_meshinfo
1747 return self.mesh.NbPrisms()
1749 ## Returns the number of prisms with the given order in the mesh
1750 # @param elementOrder the order of elements:
1751 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1752 # @return an integer value
1753 # @ingroup l1_meshinfo
1754 def NbPrismsOfOrder(self, elementOrder):
1755 return self.mesh.NbPrismsOfOrder(elementOrder)
1757 ## Returns the number of polyhedrons in the mesh
1758 # @return an integer value
1759 # @ingroup l1_meshinfo
1760 def NbPolyhedrons(self):
1761 return self.mesh.NbPolyhedrons()
1763 ## Returns the number of submeshes in the mesh
1764 # @return an integer value
1765 # @ingroup l1_meshinfo
1766 def NbSubMesh(self):
1767 return self.mesh.NbSubMesh()
1769 ## Returns the list of mesh elements IDs
1770 # @return the list of integer values
1771 # @ingroup l1_meshinfo
1772 def GetElementsId(self):
1773 return self.mesh.GetElementsId()
1775 ## Returns the list of IDs of mesh elements with the given type
1776 # @param elementType the required type of elements
1777 # @return list of integer values
1778 # @ingroup l1_meshinfo
1779 def GetElementsByType(self, elementType):
1780 return self.mesh.GetElementsByType(elementType)
1782 ## Returns the list of mesh nodes IDs
1783 # @return the list of integer values
1784 # @ingroup l1_meshinfo
1785 def GetNodesId(self):
1786 return self.mesh.GetNodesId()
1788 # Get the information about mesh elements:
1789 # ------------------------------------
1791 ## Returns the type of mesh element
1792 # @return the value from SMESH::ElementType enumeration
1793 # @ingroup l1_meshinfo
1794 def GetElementType(self, id, iselem):
1795 return self.mesh.GetElementType(id, iselem)
1797 ## Returns the list of submesh elements IDs
1798 # @param Shape a geom object(subshape) IOR
1799 # Shape must be the subshape of a ShapeToMesh()
1800 # @return the list of integer values
1801 # @ingroup l1_meshinfo
1802 def GetSubMeshElementsId(self, Shape):
1803 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1804 ShapeID = Shape.GetSubShapeIndices()[0]
1807 return self.mesh.GetSubMeshElementsId(ShapeID)
1809 ## Returns the list of submesh nodes IDs
1810 # @param Shape a geom object(subshape) IOR
1811 # Shape must be the subshape of a ShapeToMesh()
1812 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1813 # @return the list of integer values
1814 # @ingroup l1_meshinfo
1815 def GetSubMeshNodesId(self, Shape, all):
1816 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1817 ShapeID = Shape.GetSubShapeIndices()[0]
1820 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1822 ## Returns type of elements on given shape
1823 # @param Shape a geom object(subshape) IOR
1824 # Shape must be a subshape of a ShapeToMesh()
1825 # @return element type
1826 # @ingroup l1_meshinfo
1827 def GetSubMeshElementType(self, Shape):
1828 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1829 ShapeID = Shape.GetSubShapeIndices()[0]
1832 return self.mesh.GetSubMeshElementType(ShapeID)
1834 ## Gets the mesh description
1835 # @return string value
1836 # @ingroup l1_meshinfo
1838 return self.mesh.Dump()
1841 # Get the information about nodes and elements of a mesh by its IDs:
1842 # -----------------------------------------------------------
1844 ## Gets XYZ coordinates of a node
1845 # \n If there is no nodes for the given ID - returns an empty list
1846 # @return a list of double precision values
1847 # @ingroup l1_meshinfo
1848 def GetNodeXYZ(self, id):
1849 return self.mesh.GetNodeXYZ(id)
1851 ## Returns list of IDs of inverse elements for the given node
1852 # \n If there is no node for the given ID - returns an empty list
1853 # @return a list of integer values
1854 # @ingroup l1_meshinfo
1855 def GetNodeInverseElements(self, id):
1856 return self.mesh.GetNodeInverseElements(id)
1858 ## @brief Returns the position of a node on the shape
1859 # @return SMESH::NodePosition
1860 # @ingroup l1_meshinfo
1861 def GetNodePosition(self,NodeID):
1862 return self.mesh.GetNodePosition(NodeID)
1864 ## If the given element is a node, returns the ID of shape
1865 # \n If there is no node for the given ID - returns -1
1866 # @return an integer value
1867 # @ingroup l1_meshinfo
1868 def GetShapeID(self, id):
1869 return self.mesh.GetShapeID(id)
1871 ## Returns the ID of the result shape after
1872 # FindShape() from SMESH_MeshEditor for the given element
1873 # \n If there is no element for the given ID - returns -1
1874 # @return an integer value
1875 # @ingroup l1_meshinfo
1876 def GetShapeIDForElem(self,id):
1877 return self.mesh.GetShapeIDForElem(id)
1879 ## Returns the number of nodes for the given element
1880 # \n If there is no element for the given ID - returns -1
1881 # @return an integer value
1882 # @ingroup l1_meshinfo
1883 def GetElemNbNodes(self, id):
1884 return self.mesh.GetElemNbNodes(id)
1886 ## Returns the node ID the given index for the given element
1887 # \n If there is no element for the given ID - returns -1
1888 # \n If there is no node for the given index - returns -2
1889 # @return an integer value
1890 # @ingroup l1_meshinfo
1891 def GetElemNode(self, id, index):
1892 return self.mesh.GetElemNode(id, index)
1894 ## Returns the IDs of nodes of the given element
1895 # @return a list of integer values
1896 # @ingroup l1_meshinfo
1897 def GetElemNodes(self, id):
1898 return self.mesh.GetElemNodes(id)
1900 ## Returns true if the given node is the medium node in the given quadratic element
1901 # @ingroup l1_meshinfo
1902 def IsMediumNode(self, elementID, nodeID):
1903 return self.mesh.IsMediumNode(elementID, nodeID)
1905 ## Returns true if the given node is the medium node in one of quadratic elements
1906 # @ingroup l1_meshinfo
1907 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1908 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1910 ## Returns the number of edges for the given element
1911 # @ingroup l1_meshinfo
1912 def ElemNbEdges(self, id):
1913 return self.mesh.ElemNbEdges(id)
1915 ## Returns the number of faces for the given element
1916 # @ingroup l1_meshinfo
1917 def ElemNbFaces(self, id):
1918 return self.mesh.ElemNbFaces(id)
1920 ## Returns true if the given element is a polygon
1921 # @ingroup l1_meshinfo
1922 def IsPoly(self, id):
1923 return self.mesh.IsPoly(id)
1925 ## Returns true if the given element is quadratic
1926 # @ingroup l1_meshinfo
1927 def IsQuadratic(self, id):
1928 return self.mesh.IsQuadratic(id)
1930 ## Returns XYZ coordinates of the barycenter of the given element
1931 # \n If there is no element for the given ID - returns an empty list
1932 # @return a list of three double values
1933 # @ingroup l1_meshinfo
1934 def BaryCenter(self, id):
1935 return self.mesh.BaryCenter(id)
1938 # Mesh edition (SMESH_MeshEditor functionality):
1939 # ---------------------------------------------
1941 ## Removes the elements from the mesh by ids
1942 # @param IDsOfElements is a list of ids of elements to remove
1943 # @return True or False
1944 # @ingroup l2_modif_del
1945 def RemoveElements(self, IDsOfElements):
1946 return self.editor.RemoveElements(IDsOfElements)
1948 ## Removes nodes from mesh by ids
1949 # @param IDsOfNodes is a list of ids of nodes to remove
1950 # @return True or False
1951 # @ingroup l2_modif_del
1952 def RemoveNodes(self, IDsOfNodes):
1953 return self.editor.RemoveNodes(IDsOfNodes)
1955 ## Add a node to the mesh by coordinates
1956 # @return Id of the new node
1957 # @ingroup l2_modif_add
1958 def AddNode(self, x, y, z):
1959 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1960 self.mesh.SetParameters(Parameters)
1961 return self.editor.AddNode( x, y, z)
1963 ## Creates a 0D element on a node with given number.
1964 # @param IDOfNode the ID of node for creation of the element.
1965 # @return the Id of the new 0D element
1966 # @ingroup l2_modif_add
1967 def Add0DElement(self, IDOfNode):
1968 return self.editor.Add0DElement(IDOfNode)
1970 ## Creates a linear or quadratic edge (this is determined
1971 # by the number of given nodes).
1972 # @param IDsOfNodes the list of node IDs for creation of the element.
1973 # The order of nodes in this list should correspond to the description
1974 # of MED. \n This description is located by the following link:
1975 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1976 # @return the Id of the new edge
1977 # @ingroup l2_modif_add
1978 def AddEdge(self, IDsOfNodes):
1979 return self.editor.AddEdge(IDsOfNodes)
1981 ## Creates a linear or quadratic face (this is determined
1982 # by the number of given nodes).
1983 # @param IDsOfNodes the list of node IDs for creation of the element.
1984 # The order of nodes in this list should correspond to the description
1985 # of MED. \n This description is located by the following link:
1986 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1987 # @return the Id of the new face
1988 # @ingroup l2_modif_add
1989 def AddFace(self, IDsOfNodes):
1990 return self.editor.AddFace(IDsOfNodes)
1992 ## Adds a polygonal face to the mesh by the list of node IDs
1993 # @param IdsOfNodes the list of node IDs for creation of the element.
1994 # @return the Id of the new face
1995 # @ingroup l2_modif_add
1996 def AddPolygonalFace(self, IdsOfNodes):
1997 return self.editor.AddPolygonalFace(IdsOfNodes)
1999 ## Creates both simple and quadratic volume (this is determined
2000 # by the number of given nodes).
2001 # @param IDsOfNodes the list of node IDs for creation of the element.
2002 # The order of nodes in this list should correspond to the description
2003 # of MED. \n This description is located by the following link:
2004 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2005 # @return the Id of the new volumic element
2006 # @ingroup l2_modif_add
2007 def AddVolume(self, IDsOfNodes):
2008 return self.editor.AddVolume(IDsOfNodes)
2010 ## Creates a volume of many faces, giving nodes for each face.
2011 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2012 # @param Quantities the list of integer values, Quantities[i]
2013 # gives the quantity of nodes in face number i.
2014 # @return the Id of the new volumic element
2015 # @ingroup l2_modif_add
2016 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2017 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2019 ## Creates a volume of many faces, giving the IDs of the existing faces.
2020 # @param IdsOfFaces the list of face IDs for volume creation.
2022 # Note: The created volume will refer only to the nodes
2023 # of the given faces, not to the faces themselves.
2024 # @return the Id of the new volumic element
2025 # @ingroup l2_modif_add
2026 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2027 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2030 ## @brief Binds a node to a vertex
2031 # @param NodeID a node ID
2032 # @param Vertex a vertex or vertex ID
2033 # @return True if succeed else raises an exception
2034 # @ingroup l2_modif_add
2035 def SetNodeOnVertex(self, NodeID, Vertex):
2036 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2037 VertexID = Vertex.GetSubShapeIndices()[0]
2041 self.editor.SetNodeOnVertex(NodeID, VertexID)
2042 except SALOME.SALOME_Exception, inst:
2043 raise ValueError, inst.details.text
2047 ## @brief Stores the node position on an edge
2048 # @param NodeID a node ID
2049 # @param Edge an edge or edge ID
2050 # @param paramOnEdge a parameter on the edge where the node is located
2051 # @return True if succeed else raises an exception
2052 # @ingroup l2_modif_add
2053 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2054 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2055 EdgeID = Edge.GetSubShapeIndices()[0]
2059 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2060 except SALOME.SALOME_Exception, inst:
2061 raise ValueError, inst.details.text
2064 ## @brief Stores node position on a face
2065 # @param NodeID a node ID
2066 # @param Face a face or face ID
2067 # @param u U parameter on the face where the node is located
2068 # @param v V parameter on the face where the node is located
2069 # @return True if succeed else raises an exception
2070 # @ingroup l2_modif_add
2071 def SetNodeOnFace(self, NodeID, Face, u, v):
2072 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2073 FaceID = Face.GetSubShapeIndices()[0]
2077 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2078 except SALOME.SALOME_Exception, inst:
2079 raise ValueError, inst.details.text
2082 ## @brief Binds a node to a solid
2083 # @param NodeID a node ID
2084 # @param Solid a solid or solid ID
2085 # @return True if succeed else raises an exception
2086 # @ingroup l2_modif_add
2087 def SetNodeInVolume(self, NodeID, Solid):
2088 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2089 SolidID = Solid.GetSubShapeIndices()[0]
2093 self.editor.SetNodeInVolume(NodeID, SolidID)
2094 except SALOME.SALOME_Exception, inst:
2095 raise ValueError, inst.details.text
2098 ## @brief Bind an element to a shape
2099 # @param ElementID an element ID
2100 # @param Shape a shape or shape ID
2101 # @return True if succeed else raises an exception
2102 # @ingroup l2_modif_add
2103 def SetMeshElementOnShape(self, ElementID, Shape):
2104 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2105 ShapeID = Shape.GetSubShapeIndices()[0]
2109 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2110 except SALOME.SALOME_Exception, inst:
2111 raise ValueError, inst.details.text
2115 ## Moves the node with the given id
2116 # @param NodeID the id of the node
2117 # @param x a new X coordinate
2118 # @param y a new Y coordinate
2119 # @param z a new Z coordinate
2120 # @return True if succeed else False
2121 # @ingroup l2_modif_movenode
2122 def MoveNode(self, NodeID, x, y, z):
2123 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2124 self.mesh.SetParameters(Parameters)
2125 return self.editor.MoveNode(NodeID, x, y, z)
2127 ## Finds the node closest to a point and moves it to a point location
2128 # @param x the X coordinate of a point
2129 # @param y the Y coordinate of a point
2130 # @param z the Z coordinate of a point
2131 # @return the ID of a node
2132 # @ingroup l2_modif_throughp
2133 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2134 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2135 self.mesh.SetParameters(Parameters)
2136 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2138 ## Finds the node closest to a point
2139 # @param x the X coordinate of a point
2140 # @param y the Y coordinate of a point
2141 # @param z the Z coordinate of a point
2142 # @return the ID of a node
2143 # @ingroup l2_modif_throughp
2144 def FindNodeClosestTo(self, x, y, z):
2145 #preview = self.mesh.GetMeshEditPreviewer()
2146 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2147 return self.editor.FindNodeClosestTo(x, y, z)
2149 ## Finds the elements where a point lays IN or ON
2150 # @param x the X coordinate of a point
2151 # @param y the Y coordinate of a point
2152 # @param z the Z coordinate of a point
2153 # @param elementType type of elements to find (SMESH.ALL type
2154 # means elements of any type excluding nodes and 0D elements)
2155 # @return list of IDs of found elements
2156 # @ingroup l2_modif_throughp
2157 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2158 return self.editor.FindElementsByPoint(x, y, z, elementType)
2161 ## Finds the node closest to a point and moves it to a point location
2162 # @param x the X coordinate of a point
2163 # @param y the Y coordinate of a point
2164 # @param z the Z coordinate of a point
2165 # @return the ID of a moved node
2166 # @ingroup l2_modif_throughp
2167 def MeshToPassThroughAPoint(self, x, y, z):
2168 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2170 ## Replaces two neighbour triangles sharing Node1-Node2 link
2171 # with the triangles built on the same 4 nodes but having other common link.
2172 # @param NodeID1 the ID of the first node
2173 # @param NodeID2 the ID of the second node
2174 # @return false if proper faces were not found
2175 # @ingroup l2_modif_invdiag
2176 def InverseDiag(self, NodeID1, NodeID2):
2177 return self.editor.InverseDiag(NodeID1, NodeID2)
2179 ## Replaces two neighbour triangles sharing Node1-Node2 link
2180 # with a quadrangle built on the same 4 nodes.
2181 # @param NodeID1 the ID of the first node
2182 # @param NodeID2 the ID of the second node
2183 # @return false if proper faces were not found
2184 # @ingroup l2_modif_unitetri
2185 def DeleteDiag(self, NodeID1, NodeID2):
2186 return self.editor.DeleteDiag(NodeID1, NodeID2)
2188 ## Reorients elements by ids
2189 # @param IDsOfElements if undefined reorients all mesh elements
2190 # @return True if succeed else False
2191 # @ingroup l2_modif_changori
2192 def Reorient(self, IDsOfElements=None):
2193 if IDsOfElements == None:
2194 IDsOfElements = self.GetElementsId()
2195 return self.editor.Reorient(IDsOfElements)
2197 ## Reorients all elements of the object
2198 # @param theObject mesh, submesh or group
2199 # @return True if succeed else False
2200 # @ingroup l2_modif_changori
2201 def ReorientObject(self, theObject):
2202 if ( isinstance( theObject, Mesh )):
2203 theObject = theObject.GetMesh()
2204 return self.editor.ReorientObject(theObject)
2206 ## Fuses the neighbouring triangles into quadrangles.
2207 # @param IDsOfElements The triangles to be fused,
2208 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2209 # @param MaxAngle is the maximum angle between element normals at which the fusion
2210 # is still performed; theMaxAngle is mesured in radians.
2211 # Also it could be a name of variable which defines angle in degrees.
2212 # @return TRUE in case of success, FALSE otherwise.
2213 # @ingroup l2_modif_unitetri
2214 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2216 if isinstance(MaxAngle,str):
2218 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2220 MaxAngle = DegreesToRadians(MaxAngle)
2221 if IDsOfElements == []:
2222 IDsOfElements = self.GetElementsId()
2223 self.mesh.SetParameters(Parameters)
2225 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2226 Functor = theCriterion
2228 Functor = self.smeshpyD.GetFunctor(theCriterion)
2229 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2231 ## Fuses the neighbouring triangles of the object into quadrangles
2232 # @param theObject is mesh, submesh or group
2233 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2234 # @param MaxAngle a max angle between element normals at which the fusion
2235 # is still performed; theMaxAngle is mesured in radians.
2236 # @return TRUE in case of success, FALSE otherwise.
2237 # @ingroup l2_modif_unitetri
2238 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2239 if ( isinstance( theObject, Mesh )):
2240 theObject = theObject.GetMesh()
2241 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2243 ## Splits quadrangles into triangles.
2244 # @param IDsOfElements the faces to be splitted.
2245 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2246 # @return TRUE in case of success, FALSE otherwise.
2247 # @ingroup l2_modif_cutquadr
2248 def QuadToTri (self, IDsOfElements, theCriterion):
2249 if IDsOfElements == []:
2250 IDsOfElements = self.GetElementsId()
2251 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2253 ## Splits quadrangles into triangles.
2254 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2255 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2256 # @return TRUE in case of success, FALSE otherwise.
2257 # @ingroup l2_modif_cutquadr
2258 def QuadToTriObject (self, theObject, theCriterion):
2259 if ( isinstance( theObject, Mesh )):
2260 theObject = theObject.GetMesh()
2261 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2263 ## Splits quadrangles into triangles.
2264 # @param IDsOfElements the faces to be splitted
2265 # @param Diag13 is used to choose a diagonal for splitting.
2266 # @return TRUE in case of success, FALSE otherwise.
2267 # @ingroup l2_modif_cutquadr
2268 def SplitQuad (self, IDsOfElements, Diag13):
2269 if IDsOfElements == []:
2270 IDsOfElements = self.GetElementsId()
2271 return self.editor.SplitQuad(IDsOfElements, Diag13)
2273 ## Splits quadrangles into triangles.
2274 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2275 # @param Diag13 is used to choose a diagonal for splitting.
2276 # @return TRUE in case of success, FALSE otherwise.
2277 # @ingroup l2_modif_cutquadr
2278 def SplitQuadObject (self, theObject, Diag13):
2279 if ( isinstance( theObject, Mesh )):
2280 theObject = theObject.GetMesh()
2281 return self.editor.SplitQuadObject(theObject, Diag13)
2283 ## Finds a better splitting of the given quadrangle.
2284 # @param IDOfQuad the ID of the quadrangle to be splitted.
2285 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2286 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2287 # diagonal is better, 0 if error occurs.
2288 # @ingroup l2_modif_cutquadr
2289 def BestSplit (self, IDOfQuad, theCriterion):
2290 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2292 ## Splits quadrangle faces near triangular facets of volumes
2294 # @ingroup l1_auxiliary
2295 def SplitQuadsNearTriangularFacets(self):
2296 faces_array = self.GetElementsByType(SMESH.FACE)
2297 for face_id in faces_array:
2298 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2299 quad_nodes = self.mesh.GetElemNodes(face_id)
2300 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2301 isVolumeFound = False
2302 for node1_elem in node1_elems:
2303 if not isVolumeFound:
2304 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2305 nb_nodes = self.GetElemNbNodes(node1_elem)
2306 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2307 volume_elem = node1_elem
2308 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2309 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2310 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2311 isVolumeFound = True
2312 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2313 self.SplitQuad([face_id], False) # diagonal 2-4
2314 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2315 isVolumeFound = True
2316 self.SplitQuad([face_id], True) # diagonal 1-3
2317 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2318 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2319 isVolumeFound = True
2320 self.SplitQuad([face_id], True) # diagonal 1-3
2322 ## @brief Splits hexahedrons into tetrahedrons.
2324 # This operation uses pattern mapping functionality for splitting.
2325 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2326 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2327 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2328 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2329 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2330 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2331 # @return TRUE in case of success, FALSE otherwise.
2332 # @ingroup l1_auxiliary
2333 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2334 # Pattern: 5.---------.6
2339 # (0,0,1) 4.---------.7 * |
2346 # (0,0,0) 0.---------.3
2347 pattern_tetra = "!!! Nb of points: \n 8 \n\
2357 !!! Indices of points of 6 tetras: \n\
2365 pattern = self.smeshpyD.GetPattern()
2366 isDone = pattern.LoadFromFile(pattern_tetra)
2368 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2371 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2372 isDone = pattern.MakeMesh(self.mesh, False, False)
2373 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2375 # split quafrangle faces near triangular facets of volumes
2376 self.SplitQuadsNearTriangularFacets()
2380 ## @brief Split hexahedrons into prisms.
2382 # Uses the pattern mapping functionality for splitting.
2383 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2384 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2385 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2386 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2387 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2388 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2389 # @return TRUE in case of success, FALSE otherwise.
2390 # @ingroup l1_auxiliary
2391 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2392 # Pattern: 5.---------.6
2397 # (0,0,1) 4.---------.7 |
2404 # (0,0,0) 0.---------.3
2405 pattern_prism = "!!! Nb of points: \n 8 \n\
2415 !!! Indices of points of 2 prisms: \n\
2419 pattern = self.smeshpyD.GetPattern()
2420 isDone = pattern.LoadFromFile(pattern_prism)
2422 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2425 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2426 isDone = pattern.MakeMesh(self.mesh, False, False)
2427 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2429 # Splits quafrangle faces near triangular facets of volumes
2430 self.SplitQuadsNearTriangularFacets()
2434 ## Smoothes elements
2435 # @param IDsOfElements the list if ids of elements to smooth
2436 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2437 # Note that nodes built on edges and boundary nodes are always fixed.
2438 # @param MaxNbOfIterations the maximum number of iterations
2439 # @param MaxAspectRatio varies in range [1.0, inf]
2440 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2441 # @return TRUE in case of success, FALSE otherwise.
2442 # @ingroup l2_modif_smooth
2443 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2444 MaxNbOfIterations, MaxAspectRatio, Method):
2445 if IDsOfElements == []:
2446 IDsOfElements = self.GetElementsId()
2447 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2448 self.mesh.SetParameters(Parameters)
2449 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2450 MaxNbOfIterations, MaxAspectRatio, Method)
2452 ## Smoothes elements which belong to the given object
2453 # @param theObject the object to smooth
2454 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2455 # Note that nodes built on edges and boundary nodes are always fixed.
2456 # @param MaxNbOfIterations the maximum number of iterations
2457 # @param MaxAspectRatio varies in range [1.0, inf]
2458 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2459 # @return TRUE in case of success, FALSE otherwise.
2460 # @ingroup l2_modif_smooth
2461 def SmoothObject(self, theObject, IDsOfFixedNodes,
2462 MaxNbOfIterations, MaxAspectRatio, Method):
2463 if ( isinstance( theObject, Mesh )):
2464 theObject = theObject.GetMesh()
2465 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2466 MaxNbOfIterations, MaxAspectRatio, Method)
2468 ## Parametrically smoothes the given elements
2469 # @param IDsOfElements the list if ids of elements to smooth
2470 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2471 # Note that nodes built on edges and boundary nodes are always fixed.
2472 # @param MaxNbOfIterations the maximum number of iterations
2473 # @param MaxAspectRatio varies in range [1.0, inf]
2474 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2475 # @return TRUE in case of success, FALSE otherwise.
2476 # @ingroup l2_modif_smooth
2477 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2478 MaxNbOfIterations, MaxAspectRatio, Method):
2479 if IDsOfElements == []:
2480 IDsOfElements = self.GetElementsId()
2481 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2482 self.mesh.SetParameters(Parameters)
2483 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2484 MaxNbOfIterations, MaxAspectRatio, Method)
2486 ## Parametrically smoothes the elements which belong to the given object
2487 # @param theObject the object to smooth
2488 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2489 # Note that nodes built on edges and boundary nodes are always fixed.
2490 # @param MaxNbOfIterations the maximum number of iterations
2491 # @param MaxAspectRatio varies in range [1.0, inf]
2492 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2493 # @return TRUE in case of success, FALSE otherwise.
2494 # @ingroup l2_modif_smooth
2495 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2496 MaxNbOfIterations, MaxAspectRatio, Method):
2497 if ( isinstance( theObject, Mesh )):
2498 theObject = theObject.GetMesh()
2499 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2500 MaxNbOfIterations, MaxAspectRatio, Method)
2502 ## Converts the mesh to quadratic, deletes old elements, replacing
2503 # them with quadratic with the same id.
2504 # @ingroup l2_modif_tofromqu
2505 def ConvertToQuadratic(self, theForce3d):
2506 self.editor.ConvertToQuadratic(theForce3d)
2508 ## Converts the mesh from quadratic to ordinary,
2509 # deletes old quadratic elements, \n replacing
2510 # them with ordinary mesh elements with the same id.
2511 # @return TRUE in case of success, FALSE otherwise.
2512 # @ingroup l2_modif_tofromqu
2513 def ConvertFromQuadratic(self):
2514 return self.editor.ConvertFromQuadratic()
2516 ## Creates 2D mesh as skin on boundary faces of a 3D mesh
2517 # @return TRUE if operation has been completed successfully, FALSE otherwise
2518 # @ingroup l2_modif_edit
2519 def Make2DMeshFrom3D(self):
2520 return self.editor. Make2DMeshFrom3D()
2522 ## Renumber mesh nodes
2523 # @ingroup l2_modif_renumber
2524 def RenumberNodes(self):
2525 self.editor.RenumberNodes()
2527 ## Renumber mesh elements
2528 # @ingroup l2_modif_renumber
2529 def RenumberElements(self):
2530 self.editor.RenumberElements()
2532 ## Generates new elements by rotation of the elements around the axis
2533 # @param IDsOfElements the list of ids of elements to sweep
2534 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2535 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2536 # @param NbOfSteps the number of steps
2537 # @param Tolerance tolerance
2538 # @param MakeGroups forces the generation of new groups from existing ones
2539 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2540 # of all steps, else - size of each step
2541 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2542 # @ingroup l2_modif_extrurev
2543 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2544 MakeGroups=False, TotalAngle=False):
2546 if isinstance(AngleInRadians,str):
2548 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2550 AngleInRadians = DegreesToRadians(AngleInRadians)
2551 if IDsOfElements == []:
2552 IDsOfElements = self.GetElementsId()
2553 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2554 Axis = self.smeshpyD.GetAxisStruct(Axis)
2555 Axis,AxisParameters = ParseAxisStruct(Axis)
2556 if TotalAngle and NbOfSteps:
2557 AngleInRadians /= NbOfSteps
2558 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2559 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2560 self.mesh.SetParameters(Parameters)
2562 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2563 AngleInRadians, NbOfSteps, Tolerance)
2564 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2567 ## Generates new elements by rotation of the elements of object around the axis
2568 # @param theObject object which elements should be sweeped
2569 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2570 # @param AngleInRadians the angle of Rotation
2571 # @param NbOfSteps number of steps
2572 # @param Tolerance tolerance
2573 # @param MakeGroups forces the generation of new groups from existing ones
2574 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2575 # of all steps, else - size of each step
2576 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2577 # @ingroup l2_modif_extrurev
2578 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2579 MakeGroups=False, TotalAngle=False):
2581 if isinstance(AngleInRadians,str):
2583 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2585 AngleInRadians = DegreesToRadians(AngleInRadians)
2586 if ( isinstance( theObject, Mesh )):
2587 theObject = theObject.GetMesh()
2588 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2589 Axis = self.smeshpyD.GetAxisStruct(Axis)
2590 Axis,AxisParameters = ParseAxisStruct(Axis)
2591 if TotalAngle and NbOfSteps:
2592 AngleInRadians /= NbOfSteps
2593 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2594 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2595 self.mesh.SetParameters(Parameters)
2597 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2598 NbOfSteps, Tolerance)
2599 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2602 ## Generates new elements by rotation of the elements of object around the axis
2603 # @param theObject object which elements should be sweeped
2604 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2605 # @param AngleInRadians the angle of Rotation
2606 # @param NbOfSteps number of steps
2607 # @param Tolerance tolerance
2608 # @param MakeGroups forces the generation of new groups from existing ones
2609 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2610 # of all steps, else - size of each step
2611 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2612 # @ingroup l2_modif_extrurev
2613 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2614 MakeGroups=False, TotalAngle=False):
2616 if isinstance(AngleInRadians,str):
2618 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2620 AngleInRadians = DegreesToRadians(AngleInRadians)
2621 if ( isinstance( theObject, Mesh )):
2622 theObject = theObject.GetMesh()
2623 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2624 Axis = self.smeshpyD.GetAxisStruct(Axis)
2625 Axis,AxisParameters = ParseAxisStruct(Axis)
2626 if TotalAngle and NbOfSteps:
2627 AngleInRadians /= NbOfSteps
2628 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2629 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2630 self.mesh.SetParameters(Parameters)
2632 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2633 NbOfSteps, Tolerance)
2634 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2637 ## Generates new elements by rotation of the elements of object around the axis
2638 # @param theObject object which elements should be sweeped
2639 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2640 # @param AngleInRadians the angle of Rotation
2641 # @param NbOfSteps number of steps
2642 # @param Tolerance tolerance
2643 # @param MakeGroups forces the generation of new groups from existing ones
2644 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2645 # of all steps, else - size of each step
2646 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2647 # @ingroup l2_modif_extrurev
2648 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2649 MakeGroups=False, TotalAngle=False):
2651 if isinstance(AngleInRadians,str):
2653 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2655 AngleInRadians = DegreesToRadians(AngleInRadians)
2656 if ( isinstance( theObject, Mesh )):
2657 theObject = theObject.GetMesh()
2658 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2659 Axis = self.smeshpyD.GetAxisStruct(Axis)
2660 Axis,AxisParameters = ParseAxisStruct(Axis)
2661 if TotalAngle and NbOfSteps:
2662 AngleInRadians /= NbOfSteps
2663 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2664 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2665 self.mesh.SetParameters(Parameters)
2667 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2668 NbOfSteps, Tolerance)
2669 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2672 ## Generates new elements by extrusion of the elements with given ids
2673 # @param IDsOfElements the list of elements ids for extrusion
2674 # @param StepVector vector, defining the direction and value of extrusion
2675 # @param NbOfSteps the number of steps
2676 # @param MakeGroups forces the generation of new groups from existing ones
2677 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2678 # @ingroup l2_modif_extrurev
2679 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2680 if IDsOfElements == []:
2681 IDsOfElements = self.GetElementsId()
2682 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2683 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2684 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2685 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2686 Parameters = StepVectorParameters + var_separator + Parameters
2687 self.mesh.SetParameters(Parameters)
2689 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2690 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2693 ## Generates new elements by extrusion of the elements with given ids
2694 # @param IDsOfElements is ids of elements
2695 # @param StepVector vector, defining the direction and value of extrusion
2696 # @param NbOfSteps the number of steps
2697 # @param ExtrFlags sets flags for extrusion
2698 # @param SewTolerance uses for comparing locations of nodes if flag
2699 # EXTRUSION_FLAG_SEW is set
2700 # @param MakeGroups forces the generation of new groups from existing ones
2701 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2702 # @ingroup l2_modif_extrurev
2703 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2704 ExtrFlags, SewTolerance, MakeGroups=False):
2705 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2706 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2708 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2709 ExtrFlags, SewTolerance)
2710 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2711 ExtrFlags, SewTolerance)
2714 ## Generates new elements by extrusion of the elements which belong to the object
2715 # @param theObject the object which elements should be processed
2716 # @param StepVector vector, defining the direction and value of extrusion
2717 # @param NbOfSteps the number of steps
2718 # @param MakeGroups forces the generation of new groups from existing ones
2719 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2720 # @ingroup l2_modif_extrurev
2721 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2722 if ( isinstance( theObject, Mesh )):
2723 theObject = theObject.GetMesh()
2724 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2725 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2726 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2727 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2728 Parameters = StepVectorParameters + var_separator + Parameters
2729 self.mesh.SetParameters(Parameters)
2731 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2732 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2735 ## Generates new elements by extrusion of the elements which belong to the object
2736 # @param theObject object which elements should be processed
2737 # @param StepVector vector, defining the direction and value of extrusion
2738 # @param NbOfSteps the number of steps
2739 # @param MakeGroups to generate new groups from existing ones
2740 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2741 # @ingroup l2_modif_extrurev
2742 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2743 if ( isinstance( theObject, Mesh )):
2744 theObject = theObject.GetMesh()
2745 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2746 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2747 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2748 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2749 Parameters = StepVectorParameters + var_separator + Parameters
2750 self.mesh.SetParameters(Parameters)
2752 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2753 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2756 ## Generates new elements by extrusion of the elements which belong to the object
2757 # @param theObject object which elements should be processed
2758 # @param StepVector vector, defining the direction and value of extrusion
2759 # @param NbOfSteps the number of steps
2760 # @param MakeGroups forces the generation of new groups from existing ones
2761 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2762 # @ingroup l2_modif_extrurev
2763 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2764 if ( isinstance( theObject, Mesh )):
2765 theObject = theObject.GetMesh()
2766 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2767 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2768 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2769 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2770 Parameters = StepVectorParameters + var_separator + Parameters
2771 self.mesh.SetParameters(Parameters)
2773 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2774 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2779 ## Generates new elements by extrusion of the given elements
2780 # The path of extrusion must be a meshed edge.
2781 # @param Base mesh or list of ids of elements for extrusion
2782 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2783 # @param NodeStart the start node from Path. Defines the direction of extrusion
2784 # @param HasAngles allows the shape to be rotated around the path
2785 # to get the resulting mesh in a helical fashion
2786 # @param Angles list of angles in radians
2787 # @param LinearVariation forces the computation of rotation angles as linear
2788 # variation of the given Angles along path steps
2789 # @param HasRefPoint allows using the reference point
2790 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2791 # The User can specify any point as the Reference Point.
2792 # @param MakeGroups forces the generation of new groups from existing ones
2793 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2794 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2795 # only SMESH::Extrusion_Error otherwise
2796 # @ingroup l2_modif_extrurev
2797 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2798 HasAngles, Angles, LinearVariation,
2799 HasRefPoint, RefPoint, MakeGroups, ElemType):
2800 Angles,AnglesParameters = ParseAngles(Angles)
2801 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2802 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2803 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2805 Parameters = AnglesParameters + var_separator + RefPointParameters
2806 self.mesh.SetParameters(Parameters)
2808 if isinstance(Base,list):
2810 if Base == []: IDsOfElements = self.GetElementsId()
2811 else: IDsOfElements = Base
2812 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2813 HasAngles, Angles, LinearVariation,
2814 HasRefPoint, RefPoint, MakeGroups, ElemType)
2816 if isinstance(Base,Mesh):
2817 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2818 HasAngles, Angles, LinearVariation,
2819 HasRefPoint, RefPoint, MakeGroups, ElemType)
2821 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2824 ## Generates new elements by extrusion of the given elements
2825 # The path of extrusion must be a meshed edge.
2826 # @param IDsOfElements ids of elements
2827 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2828 # @param PathShape shape(edge) defines the sub-mesh for the path
2829 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2830 # @param HasAngles allows the shape to be rotated around the path
2831 # to get the resulting mesh in a helical fashion
2832 # @param Angles list of angles in radians
2833 # @param HasRefPoint allows using the reference point
2834 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2835 # The User can specify any point as the Reference Point.
2836 # @param MakeGroups forces the generation of new groups from existing ones
2837 # @param LinearVariation forces the computation of rotation angles as linear
2838 # variation of the given Angles along path steps
2839 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2840 # only SMESH::Extrusion_Error otherwise
2841 # @ingroup l2_modif_extrurev
2842 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2843 HasAngles, Angles, HasRefPoint, RefPoint,
2844 MakeGroups=False, LinearVariation=False):
2845 Angles,AnglesParameters = ParseAngles(Angles)
2846 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2847 if IDsOfElements == []:
2848 IDsOfElements = self.GetElementsId()
2849 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2850 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2852 if ( isinstance( PathMesh, Mesh )):
2853 PathMesh = PathMesh.GetMesh()
2854 if HasAngles and Angles and LinearVariation:
2855 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2857 Parameters = AnglesParameters + var_separator + RefPointParameters
2858 self.mesh.SetParameters(Parameters)
2860 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2861 PathShape, NodeStart, HasAngles,
2862 Angles, HasRefPoint, RefPoint)
2863 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2864 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2866 ## Generates new elements by extrusion of the elements which belong to the object
2867 # The path of extrusion must be a meshed edge.
2868 # @param theObject the object which elements should be processed
2869 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2870 # @param PathShape shape(edge) defines the sub-mesh for the path
2871 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2872 # @param HasAngles allows the shape to be rotated around the path
2873 # to get the resulting mesh in a helical fashion
2874 # @param Angles list of angles
2875 # @param HasRefPoint allows using the reference point
2876 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2877 # The User can specify any point as the Reference Point.
2878 # @param MakeGroups forces the generation of new groups from existing ones
2879 # @param LinearVariation forces the computation of rotation angles as linear
2880 # variation of the given Angles along path steps
2881 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2882 # only SMESH::Extrusion_Error otherwise
2883 # @ingroup l2_modif_extrurev
2884 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2885 HasAngles, Angles, HasRefPoint, RefPoint,
2886 MakeGroups=False, LinearVariation=False):
2887 Angles,AnglesParameters = ParseAngles(Angles)
2888 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2889 if ( isinstance( theObject, Mesh )):
2890 theObject = theObject.GetMesh()
2891 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2892 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2893 if ( isinstance( PathMesh, Mesh )):
2894 PathMesh = PathMesh.GetMesh()
2895 if HasAngles and Angles and LinearVariation:
2896 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2898 Parameters = AnglesParameters + var_separator + RefPointParameters
2899 self.mesh.SetParameters(Parameters)
2901 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2902 PathShape, NodeStart, HasAngles,
2903 Angles, HasRefPoint, RefPoint)
2904 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2905 NodeStart, HasAngles, Angles, HasRefPoint,
2908 ## Generates new elements by extrusion of the elements which belong to the object
2909 # The path of extrusion must be a meshed edge.
2910 # @param theObject the object which elements should be processed
2911 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2912 # @param PathShape shape(edge) defines the sub-mesh for the path
2913 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2914 # @param HasAngles allows the shape to be rotated around the path
2915 # to get the resulting mesh in a helical fashion
2916 # @param Angles list of angles
2917 # @param HasRefPoint allows using the reference point
2918 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2919 # The User can specify any point as the Reference Point.
2920 # @param MakeGroups forces the generation of new groups from existing ones
2921 # @param LinearVariation forces the computation of rotation angles as linear
2922 # variation of the given Angles along path steps
2923 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2924 # only SMESH::Extrusion_Error otherwise
2925 # @ingroup l2_modif_extrurev
2926 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2927 HasAngles, Angles, HasRefPoint, RefPoint,
2928 MakeGroups=False, LinearVariation=False):
2929 Angles,AnglesParameters = ParseAngles(Angles)
2930 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2931 if ( isinstance( theObject, Mesh )):
2932 theObject = theObject.GetMesh()
2933 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2934 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2935 if ( isinstance( PathMesh, Mesh )):
2936 PathMesh = PathMesh.GetMesh()
2937 if HasAngles and Angles and LinearVariation:
2938 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2940 Parameters = AnglesParameters + var_separator + RefPointParameters
2941 self.mesh.SetParameters(Parameters)
2943 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2944 PathShape, NodeStart, HasAngles,
2945 Angles, HasRefPoint, RefPoint)
2946 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2947 NodeStart, HasAngles, Angles, HasRefPoint,
2950 ## Generates new elements by extrusion of the elements which belong to the object
2951 # The path of extrusion must be a meshed edge.
2952 # @param theObject the object which elements should be processed
2953 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2954 # @param PathShape shape(edge) defines the sub-mesh for the path
2955 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2956 # @param HasAngles allows the shape to be rotated around the path
2957 # to get the resulting mesh in a helical fashion
2958 # @param Angles list of angles
2959 # @param HasRefPoint allows using the reference point
2960 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2961 # The User can specify any point as the Reference Point.
2962 # @param MakeGroups forces the generation of new groups from existing ones
2963 # @param LinearVariation forces the computation of rotation angles as linear
2964 # variation of the given Angles along path steps
2965 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2966 # only SMESH::Extrusion_Error otherwise
2967 # @ingroup l2_modif_extrurev
2968 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2969 HasAngles, Angles, HasRefPoint, RefPoint,
2970 MakeGroups=False, LinearVariation=False):
2971 Angles,AnglesParameters = ParseAngles(Angles)
2972 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2973 if ( isinstance( theObject, Mesh )):
2974 theObject = theObject.GetMesh()
2975 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2976 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2977 if ( isinstance( PathMesh, Mesh )):
2978 PathMesh = PathMesh.GetMesh()
2979 if HasAngles and Angles and LinearVariation:
2980 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2982 Parameters = AnglesParameters + var_separator + RefPointParameters
2983 self.mesh.SetParameters(Parameters)
2985 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2986 PathShape, NodeStart, HasAngles,
2987 Angles, HasRefPoint, RefPoint)
2988 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2989 NodeStart, HasAngles, Angles, HasRefPoint,
2992 ## Creates a symmetrical copy of mesh elements
2993 # @param IDsOfElements list of elements ids
2994 # @param Mirror is AxisStruct or geom object(point, line, plane)
2995 # @param theMirrorType is POINT, AXIS or PLANE
2996 # If the Mirror is a geom object this parameter is unnecessary
2997 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2998 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2999 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3000 # @ingroup l2_modif_trsf
3001 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3002 if IDsOfElements == []:
3003 IDsOfElements = self.GetElementsId()
3004 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3005 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3006 Mirror,Parameters = ParseAxisStruct(Mirror)
3007 self.mesh.SetParameters(Parameters)
3008 if Copy and MakeGroups:
3009 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3010 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3013 ## Creates a new mesh by a symmetrical copy of mesh elements
3014 # @param IDsOfElements the list of elements ids
3015 # @param Mirror is AxisStruct or geom object (point, line, plane)
3016 # @param theMirrorType is POINT, AXIS or PLANE
3017 # If the Mirror is a geom object this parameter is unnecessary
3018 # @param MakeGroups to generate new groups from existing ones
3019 # @param NewMeshName a name of the new mesh to create
3020 # @return instance of Mesh class
3021 # @ingroup l2_modif_trsf
3022 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3023 if IDsOfElements == []:
3024 IDsOfElements = self.GetElementsId()
3025 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3026 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3027 Mirror,Parameters = ParseAxisStruct(Mirror)
3028 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3029 MakeGroups, NewMeshName)
3030 mesh.SetParameters(Parameters)
3031 return Mesh(self.smeshpyD,self.geompyD,mesh)
3033 ## Creates a symmetrical copy of the object
3034 # @param theObject mesh, submesh or group
3035 # @param Mirror AxisStruct or geom object (point, line, plane)
3036 # @param theMirrorType is POINT, AXIS or PLANE
3037 # If the Mirror is a geom object this parameter is unnecessary
3038 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3039 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3040 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3041 # @ingroup l2_modif_trsf
3042 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3043 if ( isinstance( theObject, Mesh )):
3044 theObject = theObject.GetMesh()
3045 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3046 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3047 Mirror,Parameters = ParseAxisStruct(Mirror)
3048 self.mesh.SetParameters(Parameters)
3049 if Copy and MakeGroups:
3050 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3051 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3054 ## Creates a new mesh by a symmetrical copy of the object
3055 # @param theObject mesh, submesh or group
3056 # @param Mirror AxisStruct or geom object (point, line, plane)
3057 # @param theMirrorType POINT, AXIS or PLANE
3058 # If the Mirror is a geom object this parameter is unnecessary
3059 # @param MakeGroups forces the generation of new groups from existing ones
3060 # @param NewMeshName the name of the new mesh to create
3061 # @return instance of Mesh class
3062 # @ingroup l2_modif_trsf
3063 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3064 if ( isinstance( theObject, Mesh )):
3065 theObject = theObject.GetMesh()
3066 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3067 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3068 Mirror,Parameters = ParseAxisStruct(Mirror)
3069 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3070 MakeGroups, NewMeshName)
3071 mesh.SetParameters(Parameters)
3072 return Mesh( self.smeshpyD,self.geompyD,mesh )
3074 ## Translates the elements
3075 # @param IDsOfElements list of elements ids
3076 # @param Vector the direction of translation (DirStruct or vector)
3077 # @param Copy allows copying the translated elements
3078 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3079 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3080 # @ingroup l2_modif_trsf
3081 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3082 if IDsOfElements == []:
3083 IDsOfElements = self.GetElementsId()
3084 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3085 Vector = self.smeshpyD.GetDirStruct(Vector)
3086 Vector,Parameters = ParseDirStruct(Vector)
3087 self.mesh.SetParameters(Parameters)
3088 if Copy and MakeGroups:
3089 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3090 self.editor.Translate(IDsOfElements, Vector, Copy)
3093 ## Creates a new mesh of translated elements
3094 # @param IDsOfElements list of elements ids
3095 # @param Vector the direction of translation (DirStruct or vector)
3096 # @param MakeGroups forces the generation of new groups from existing ones
3097 # @param NewMeshName the name of the newly created mesh
3098 # @return instance of Mesh class
3099 # @ingroup l2_modif_trsf
3100 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3101 if IDsOfElements == []:
3102 IDsOfElements = self.GetElementsId()
3103 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3104 Vector = self.smeshpyD.GetDirStruct(Vector)
3105 Vector,Parameters = ParseDirStruct(Vector)
3106 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3107 mesh.SetParameters(Parameters)
3108 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3110 ## Translates the object
3111 # @param theObject the object to translate (mesh, submesh, or group)
3112 # @param Vector direction of translation (DirStruct or geom vector)
3113 # @param Copy allows copying the translated elements
3114 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3115 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3116 # @ingroup l2_modif_trsf
3117 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3118 if ( isinstance( theObject, Mesh )):
3119 theObject = theObject.GetMesh()
3120 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3121 Vector = self.smeshpyD.GetDirStruct(Vector)
3122 Vector,Parameters = ParseDirStruct(Vector)
3123 self.mesh.SetParameters(Parameters)
3124 if Copy and MakeGroups:
3125 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3126 self.editor.TranslateObject(theObject, Vector, Copy)
3129 ## Creates a new mesh from the translated object
3130 # @param theObject the object to translate (mesh, submesh, or group)
3131 # @param Vector the direction of translation (DirStruct or geom vector)
3132 # @param MakeGroups forces the generation of new groups from existing ones
3133 # @param NewMeshName the name of the newly created mesh
3134 # @return instance of Mesh class
3135 # @ingroup l2_modif_trsf
3136 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3137 if (isinstance(theObject, Mesh)):
3138 theObject = theObject.GetMesh()
3139 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3140 Vector = self.smeshpyD.GetDirStruct(Vector)
3141 Vector,Parameters = ParseDirStruct(Vector)
3142 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3143 mesh.SetParameters(Parameters)
3144 return Mesh( self.smeshpyD, self.geompyD, mesh )
3146 ## Rotates the elements
3147 # @param IDsOfElements list of elements ids
3148 # @param Axis the axis of rotation (AxisStruct or geom line)
3149 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3150 # @param Copy allows copying the rotated elements
3151 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3152 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3153 # @ingroup l2_modif_trsf
3154 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3156 if isinstance(AngleInRadians,str):
3158 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3160 AngleInRadians = DegreesToRadians(AngleInRadians)
3161 if IDsOfElements == []:
3162 IDsOfElements = self.GetElementsId()
3163 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3164 Axis = self.smeshpyD.GetAxisStruct(Axis)
3165 Axis,AxisParameters = ParseAxisStruct(Axis)
3166 Parameters = AxisParameters + var_separator + Parameters
3167 self.mesh.SetParameters(Parameters)
3168 if Copy and MakeGroups:
3169 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3170 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3173 ## Creates a new mesh of rotated elements
3174 # @param IDsOfElements list of element ids
3175 # @param Axis the axis of rotation (AxisStruct or geom line)
3176 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3177 # @param MakeGroups forces the generation of new groups from existing ones
3178 # @param NewMeshName the name of the newly created mesh
3179 # @return instance of Mesh class
3180 # @ingroup l2_modif_trsf
3181 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3183 if isinstance(AngleInRadians,str):
3185 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3187 AngleInRadians = DegreesToRadians(AngleInRadians)
3188 if IDsOfElements == []:
3189 IDsOfElements = self.GetElementsId()
3190 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3191 Axis = self.smeshpyD.GetAxisStruct(Axis)
3192 Axis,AxisParameters = ParseAxisStruct(Axis)
3193 Parameters = AxisParameters + var_separator + Parameters
3194 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3195 MakeGroups, NewMeshName)
3196 mesh.SetParameters(Parameters)
3197 return Mesh( self.smeshpyD, self.geompyD, mesh )
3199 ## Rotates the object
3200 # @param theObject the object to rotate( mesh, submesh, or group)
3201 # @param Axis the axis of rotation (AxisStruct or geom line)
3202 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3203 # @param Copy allows copying the rotated elements
3204 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3205 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3206 # @ingroup l2_modif_trsf
3207 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3209 if isinstance(AngleInRadians,str):
3211 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3213 AngleInRadians = DegreesToRadians(AngleInRadians)
3214 if (isinstance(theObject, Mesh)):
3215 theObject = theObject.GetMesh()
3216 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3217 Axis = self.smeshpyD.GetAxisStruct(Axis)
3218 Axis,AxisParameters = ParseAxisStruct(Axis)
3219 Parameters = AxisParameters + ":" + Parameters
3220 self.mesh.SetParameters(Parameters)
3221 if Copy and MakeGroups:
3222 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3223 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3226 ## Creates a new mesh from the rotated object
3227 # @param theObject the object to rotate (mesh, submesh, or group)
3228 # @param Axis the axis of rotation (AxisStruct or geom line)
3229 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3230 # @param MakeGroups forces the generation of new groups from existing ones
3231 # @param NewMeshName the name of the newly created mesh
3232 # @return instance of Mesh class
3233 # @ingroup l2_modif_trsf
3234 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3236 if isinstance(AngleInRadians,str):
3238 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3240 AngleInRadians = DegreesToRadians(AngleInRadians)
3241 if (isinstance( theObject, Mesh )):
3242 theObject = theObject.GetMesh()
3243 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3244 Axis = self.smeshpyD.GetAxisStruct(Axis)
3245 Axis,AxisParameters = ParseAxisStruct(Axis)
3246 Parameters = AxisParameters + ":" + Parameters
3247 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3248 MakeGroups, NewMeshName)
3249 mesh.SetParameters(Parameters)
3250 return Mesh( self.smeshpyD, self.geompyD, mesh )
3252 ## Finds groups of ajacent nodes within Tolerance.
3253 # @param Tolerance the value of tolerance
3254 # @return the list of groups of nodes
3255 # @ingroup l2_modif_trsf
3256 def FindCoincidentNodes (self, Tolerance):
3257 return self.editor.FindCoincidentNodes(Tolerance)
3259 ## Finds groups of ajacent nodes within Tolerance.
3260 # @param Tolerance the value of tolerance
3261 # @param SubMeshOrGroup SubMesh or Group
3262 # @return the list of groups of nodes
3263 # @ingroup l2_modif_trsf
3264 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3265 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3268 # @param GroupsOfNodes the list of groups of nodes
3269 # @ingroup l2_modif_trsf
3270 def MergeNodes (self, GroupsOfNodes):
3271 self.editor.MergeNodes(GroupsOfNodes)
3273 ## Finds the elements built on the same nodes.
3274 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3275 # @return a list of groups of equal elements
3276 # @ingroup l2_modif_trsf
3277 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3278 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3280 ## Merges elements in each given group.
3281 # @param GroupsOfElementsID groups of elements for merging
3282 # @ingroup l2_modif_trsf
3283 def MergeElements(self, GroupsOfElementsID):
3284 self.editor.MergeElements(GroupsOfElementsID)
3286 ## Leaves one element and removes all other elements built on the same nodes.
3287 # @ingroup l2_modif_trsf
3288 def MergeEqualElements(self):
3289 self.editor.MergeEqualElements()
3291 ## Sews free borders
3292 # @return SMESH::Sew_Error
3293 # @ingroup l2_modif_trsf
3294 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3295 FirstNodeID2, SecondNodeID2, LastNodeID2,
3296 CreatePolygons, CreatePolyedrs):
3297 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3298 FirstNodeID2, SecondNodeID2, LastNodeID2,
3299 CreatePolygons, CreatePolyedrs)
3301 ## Sews conform free borders
3302 # @return SMESH::Sew_Error
3303 # @ingroup l2_modif_trsf
3304 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3305 FirstNodeID2, SecondNodeID2):
3306 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3307 FirstNodeID2, SecondNodeID2)
3309 ## Sews border to side
3310 # @return SMESH::Sew_Error
3311 # @ingroup l2_modif_trsf
3312 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3313 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3314 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3315 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3317 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3318 # merged with the nodes of elements of Side2.
3319 # The number of elements in theSide1 and in theSide2 must be
3320 # equal and they should have similar nodal connectivity.
3321 # The nodes to merge should belong to side borders and
3322 # the first node should be linked to the second.
3323 # @return SMESH::Sew_Error
3324 # @ingroup l2_modif_trsf
3325 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3326 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3327 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3328 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3329 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3330 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3332 ## Sets new nodes for the given element.
3333 # @param ide the element id
3334 # @param newIDs nodes ids
3335 # @return If the number of nodes does not correspond to the type of element - returns false
3336 # @ingroup l2_modif_edit
3337 def ChangeElemNodes(self, ide, newIDs):
3338 return self.editor.ChangeElemNodes(ide, newIDs)
3340 ## If during the last operation of MeshEditor some nodes were
3341 # created, this method returns the list of their IDs, \n
3342 # if new nodes were not created - returns empty list
3343 # @return the list of integer values (can be empty)
3344 # @ingroup l1_auxiliary
3345 def GetLastCreatedNodes(self):
3346 return self.editor.GetLastCreatedNodes()
3348 ## If during the last operation of MeshEditor some elements were
3349 # created this method returns the list of their IDs, \n
3350 # if new elements were not created - returns empty list
3351 # @return the list of integer values (can be empty)
3352 # @ingroup l1_auxiliary
3353 def GetLastCreatedElems(self):
3354 return self.editor.GetLastCreatedElems()
3356 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3357 # @param theElems - the list of elements (edges or faces) to be replicated
3358 # The nodes for duplication could be found from these elements
3359 # @param theNodesNot - list of nodes to NOT replicate
3360 # @param theAffectedElems - the list of elements (cells and edges) to which the
3361 # replicated nodes should be associated to.
3362 # @return TRUE if operation has been completed successfully, FALSE otherwise
3363 # @ingroup l2_modif_edit
3364 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3365 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3367 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3368 # @param theElems - the list of elements (edges or faces) to be replicated
3369 # The nodes for duplication could be found from these elements
3370 # @param theNodesNot - list of nodes to NOT replicate
3371 # @param theShape - shape to detect affected elements (element which geometric center
3372 # located on or inside shape).
3373 # The replicated nodes should be associated to affected elements.
3374 # @return TRUE if operation has been completed successfully, FALSE otherwise
3375 # @ingroup l2_modif_edit
3376 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3377 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3379 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3380 # This method provided for convenience works as DoubleNodes() described above.
3381 # @param theElems - group of of elements (edges or faces) to be replicated
3382 # @param theNodesNot - group of nodes not to replicated
3383 # @param theAffectedElems - group of elements to which the replicated nodes
3384 # should be associated to.
3385 # @ingroup l2_modif_edit
3386 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3387 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3389 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3390 # This method provided for convenience works as DoubleNodes() described above.
3391 # @param theElems - group of of elements (edges or faces) to be replicated
3392 # @param theNodesNot - group of nodes not to replicated
3393 # @param theShape - shape to detect affected elements (element which geometric center
3394 # located on or inside shape).
3395 # The replicated nodes should be associated to affected elements.
3396 # @ingroup l2_modif_edit
3397 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3398 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3400 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3401 # This method provided for convenience works as DoubleNodes() described above.
3402 # @param theElems - list of groups of elements (edges or faces) to be replicated
3403 # @param theNodesNot - list of groups of nodes not to replicated
3404 # @param theAffectedElems - group of elements to which the replicated nodes
3405 # should be associated to.
3406 # @return TRUE if operation has been completed successfully, FALSE otherwise
3407 # @ingroup l2_modif_edit
3408 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3409 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3411 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3412 # This method provided for convenience works as DoubleNodes() described above.
3413 # @param theElems - list of groups of elements (edges or faces) to be replicated
3414 # @param theNodesNot - list of groups of nodes not to replicated
3415 # @param theShape - shape to detect affected elements (element which geometric center
3416 # located on or inside shape).
3417 # The replicated nodes should be associated to affected elements.
3418 # @return TRUE if operation has been completed successfully, FALSE otherwise
3419 # @ingroup l2_modif_edit
3420 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3421 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3423 ## The mother class to define algorithm, it is not recommended to use it directly.
3426 # @ingroup l2_algorithms
3427 class Mesh_Algorithm:
3428 # @class Mesh_Algorithm
3429 # @brief Class Mesh_Algorithm
3431 #def __init__(self,smesh):
3439 ## Finds a hypothesis in the study by its type name and parameters.
3440 # Finds only the hypotheses created in smeshpyD engine.
3441 # @return SMESH.SMESH_Hypothesis
3442 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3443 study = smeshpyD.GetCurrentStudy()
3444 #to do: find component by smeshpyD object, not by its data type
3445 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3446 if scomp is not None:
3447 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3448 # Check if the root label of the hypotheses exists
3449 if res and hypRoot is not None:
3450 iter = study.NewChildIterator(hypRoot)
3451 # Check all published hypotheses
3453 hypo_so_i = iter.Value()
3454 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3455 if attr is not None:
3456 anIOR = attr.Value()
3457 hypo_o_i = salome.orb.string_to_object(anIOR)
3458 if hypo_o_i is not None:
3459 # Check if this is a hypothesis
3460 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3461 if hypo_i is not None:
3462 # Check if the hypothesis belongs to current engine
3463 if smeshpyD.GetObjectId(hypo_i) > 0:
3464 # Check if this is the required hypothesis
3465 if hypo_i.GetName() == hypname:
3467 if CompareMethod(hypo_i, args):
3481 ## Finds the algorithm in the study by its type name.
3482 # Finds only the algorithms, which have been created in smeshpyD engine.
3483 # @return SMESH.SMESH_Algo
3484 def FindAlgorithm (self, algoname, smeshpyD):
3485 study = smeshpyD.GetCurrentStudy()
3486 #to do: find component by smeshpyD object, not by its data type
3487 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3488 if scomp is not None:
3489 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3490 # Check if the root label of the algorithms exists
3491 if res and hypRoot is not None:
3492 iter = study.NewChildIterator(hypRoot)
3493 # Check all published algorithms
3495 algo_so_i = iter.Value()
3496 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3497 if attr is not None:
3498 anIOR = attr.Value()
3499 algo_o_i = salome.orb.string_to_object(anIOR)
3500 if algo_o_i is not None:
3501 # Check if this is an algorithm
3502 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3503 if algo_i is not None:
3504 # Checks if the algorithm belongs to the current engine
3505 if smeshpyD.GetObjectId(algo_i) > 0:
3506 # Check if this is the required algorithm
3507 if algo_i.GetName() == algoname:
3520 ## If the algorithm is global, returns 0; \n
3521 # else returns the submesh associated to this algorithm.
3522 def GetSubMesh(self):
3525 ## Returns the wrapped mesher.
3526 def GetAlgorithm(self):
3529 ## Gets the list of hypothesis that can be used with this algorithm
3530 def GetCompatibleHypothesis(self):
3533 mylist = self.algo.GetCompatibleHypothesis()
3536 ## Gets the name of the algorithm
3540 ## Sets the name to the algorithm
3541 def SetName(self, name):
3542 self.mesh.smeshpyD.SetName(self.algo, name)
3544 ## Gets the id of the algorithm
3546 return self.algo.GetId()
3549 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3551 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3552 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3554 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3556 self.Assign(algo, mesh, geom)
3560 def Assign(self, algo, mesh, geom):
3562 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3569 name = GetName(geom)
3571 name = mesh.geompyD.SubShapeName(geom, piece)
3572 mesh.geompyD.addToStudyInFather(piece, geom, name)
3573 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3576 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3577 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3579 def CompareHyp (self, hyp, args):
3580 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3583 def CompareEqualHyp (self, hyp, args):
3587 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3588 UseExisting=0, CompareMethod=""):
3591 if CompareMethod == "": CompareMethod = self.CompareHyp
3592 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3595 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3601 a = a + s + str(args[i])
3605 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3607 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3608 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3611 ## Returns entry of the shape to mesh in the study
3612 def MainShapeEntry(self):
3614 if not self.mesh or not self.mesh.GetMesh(): return entry
3615 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3616 study = self.mesh.smeshpyD.GetCurrentStudy()
3617 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3618 sobj = study.FindObjectIOR(ior)
3619 if sobj: entry = sobj.GetID()
3620 if not entry: return ""
3623 # Public class: Mesh_Segment
3624 # --------------------------
3626 ## Class to define a segment 1D algorithm for discretization
3629 # @ingroup l3_algos_basic
3630 class Mesh_Segment(Mesh_Algorithm):
3632 ## Private constructor.
3633 def __init__(self, mesh, geom=0):
3634 Mesh_Algorithm.__init__(self)
3635 self.Create(mesh, geom, "Regular_1D")
3637 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3638 # @param l for the length of segments that cut an edge
3639 # @param UseExisting if ==true - searches for an existing hypothesis created with
3640 # the same parameters, else (default) - creates a new one
3641 # @param p precision, used for calculation of the number of segments.
3642 # The precision should be a positive, meaningful value within the range [0,1].
3643 # In general, the number of segments is calculated with the formula:
3644 # nb = ceil((edge_length / l) - p)
3645 # Function ceil rounds its argument to the higher integer.
3646 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3647 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3648 # p=1 means rounding of (edge_length / l) to the lower integer.
3649 # Default value is 1e-07.
3650 # @return an instance of StdMeshers_LocalLength hypothesis
3651 # @ingroup l3_hypos_1dhyps
3652 def LocalLength(self, l, UseExisting=0, p=1e-07):
3653 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3654 CompareMethod=self.CompareLocalLength)
3660 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3661 def CompareLocalLength(self, hyp, args):
3662 if IsEqual(hyp.GetLength(), args[0]):
3663 return IsEqual(hyp.GetPrecision(), args[1])
3666 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3667 # @param length is optional maximal allowed length of segment, if it is omitted
3668 # the preestimated length is used that depends on geometry size
3669 # @param UseExisting if ==true - searches for an existing hypothesis created with
3670 # the same parameters, else (default) - create a new one
3671 # @return an instance of StdMeshers_MaxLength hypothesis
3672 # @ingroup l3_hypos_1dhyps
3673 def MaxSize(self, length=0.0, UseExisting=0):
3674 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3677 hyp.SetLength(length)
3679 # set preestimated length
3680 gen = self.mesh.smeshpyD
3681 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3682 self.mesh.GetMesh(), self.mesh.GetShape(),
3684 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3686 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3689 hyp.SetUsePreestimatedLength( length == 0.0 )
3692 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3693 # @param n for the number of segments that cut an edge
3694 # @param s for the scale factor (optional)
3695 # @param reversedEdges is a list of edges to mesh using reversed orientation
3696 # @param UseExisting if ==true - searches for an existing hypothesis created with
3697 # the same parameters, else (default) - create a new one
3698 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3699 # @ingroup l3_hypos_1dhyps
3700 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3701 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3702 reversedEdges, UseExisting = [], reversedEdges
3703 entry = self.MainShapeEntry()
3705 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3706 UseExisting=UseExisting,
3707 CompareMethod=self.CompareNumberOfSegments)
3709 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3710 UseExisting=UseExisting,
3711 CompareMethod=self.CompareNumberOfSegments)
3712 hyp.SetDistrType( 1 )
3713 hyp.SetScaleFactor(s)
3714 hyp.SetNumberOfSegments(n)
3715 hyp.SetReversedEdges( reversedEdges )
3716 hyp.SetObjectEntry( entry )
3720 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3721 def CompareNumberOfSegments(self, hyp, args):
3722 if hyp.GetNumberOfSegments() == args[0]:
3724 if hyp.GetReversedEdges() == args[1]:
3725 if not args[1] or hyp.GetObjectEntry() == args[2]:
3728 if hyp.GetReversedEdges() == args[2]:
3729 if not args[2] or hyp.GetObjectEntry() == args[3]:
3730 if hyp.GetDistrType() == 1:
3731 if IsEqual(hyp.GetScaleFactor(), args[1]):
3735 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3736 # @param start defines the length of the first segment
3737 # @param end defines the length of the last segment
3738 # @param reversedEdges is a list of edges to mesh using reversed orientation
3739 # @param UseExisting if ==true - searches for an existing hypothesis created with
3740 # the same parameters, else (default) - creates a new one
3741 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3742 # @ingroup l3_hypos_1dhyps
3743 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3744 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3745 reversedEdges, UseExisting = [], reversedEdges
3746 entry = self.MainShapeEntry()
3747 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3748 UseExisting=UseExisting,
3749 CompareMethod=self.CompareArithmetic1D)
3750 hyp.SetStartLength(start)
3751 hyp.SetEndLength(end)
3752 hyp.SetReversedEdges( reversedEdges )
3753 hyp.SetObjectEntry( entry )
3757 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3758 def CompareArithmetic1D(self, hyp, args):
3759 if IsEqual(hyp.GetLength(1), args[0]):
3760 if IsEqual(hyp.GetLength(0), args[1]):
3761 if hyp.GetReversedEdges() == args[2]:
3762 if not args[2] or hyp.GetObjectEntry() == args[3]:
3767 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3768 # on curve from 0 to 1 (additionally it is neecessary to check
3769 # orientation of edges and create list of reversed edges if it is
3770 # needed) and sets numbers of segments between given points (default
3771 # values are equals 1
3772 # @param points defines the list of parameters on curve
3773 # @param nbSegs defines the list of numbers of segments
3774 # @param reversedEdges is a list of edges to mesh using reversed orientation
3775 # @param UseExisting if ==true - searches for an existing hypothesis created with
3776 # the same parameters, else (default) - creates a new one
3777 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3778 # @ingroup l3_hypos_1dhyps
3779 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3780 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3781 reversedEdges, UseExisting = [], reversedEdges
3782 entry = self.MainShapeEntry()
3783 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3784 UseExisting=UseExisting,
3785 CompareMethod=self.CompareArithmetic1D)
3786 hyp.SetPoints(points)
3787 hyp.SetNbSegments(nbSegs)
3788 hyp.SetReversedEdges(reversedEdges)
3789 hyp.SetObjectEntry(entry)
3793 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3794 ## as the given arguments
3795 def CompareFixedPoints1D(self, hyp, args):
3796 if hyp.GetPoints() == args[0]:
3797 if hyp.GetNbSegments() == args[1]:
3798 if hyp.GetReversedEdges() == args[2]:
3799 if not args[2] or hyp.GetObjectEntry() == args[3]:
3805 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3806 # @param start defines the length of the first segment
3807 # @param end defines the length of the last segment
3808 # @param reversedEdges is a list of edges to mesh using reversed orientation
3809 # @param UseExisting if ==true - searches for an existing hypothesis created with
3810 # the same parameters, else (default) - creates a new one
3811 # @return an instance of StdMeshers_StartEndLength hypothesis
3812 # @ingroup l3_hypos_1dhyps
3813 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3814 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3815 reversedEdges, UseExisting = [], reversedEdges
3816 entry = self.MainShapeEntry()
3817 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3818 UseExisting=UseExisting,
3819 CompareMethod=self.CompareStartEndLength)
3820 hyp.SetStartLength(start)
3821 hyp.SetEndLength(end)
3822 hyp.SetReversedEdges( reversedEdges )
3823 hyp.SetObjectEntry( entry )
3826 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3827 def CompareStartEndLength(self, hyp, args):
3828 if IsEqual(hyp.GetLength(1), args[0]):
3829 if IsEqual(hyp.GetLength(0), args[1]):
3830 if hyp.GetReversedEdges() == args[2]:
3831 if not args[2] or hyp.GetObjectEntry() == args[3]:
3835 ## Defines "Deflection1D" hypothesis
3836 # @param d for the deflection
3837 # @param UseExisting if ==true - searches for an existing hypothesis created with
3838 # the same parameters, else (default) - create a new one
3839 # @ingroup l3_hypos_1dhyps
3840 def Deflection1D(self, d, UseExisting=0):
3841 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3842 CompareMethod=self.CompareDeflection1D)
3843 hyp.SetDeflection(d)
3846 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3847 def CompareDeflection1D(self, hyp, args):
3848 return IsEqual(hyp.GetDeflection(), args[0])
3850 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3851 # the opposite side in case of quadrangular faces
3852 # @ingroup l3_hypos_additi
3853 def Propagation(self):
3854 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3856 ## Defines "AutomaticLength" hypothesis
3857 # @param fineness for the fineness [0-1]
3858 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3859 # same parameters, else (default) - create a new one
3860 # @ingroup l3_hypos_1dhyps
3861 def AutomaticLength(self, fineness=0, UseExisting=0):
3862 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3863 CompareMethod=self.CompareAutomaticLength)
3864 hyp.SetFineness( fineness )
3867 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3868 def CompareAutomaticLength(self, hyp, args):
3869 return IsEqual(hyp.GetFineness(), args[0])
3871 ## Defines "SegmentLengthAroundVertex" hypothesis
3872 # @param length for the segment length
3873 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3874 # Any other integer value means that the hypothesis will be set on the
3875 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3876 # @param UseExisting if ==true - searches for an existing hypothesis created with
3877 # the same parameters, else (default) - creates a new one
3878 # @ingroup l3_algos_segmarv
3879 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3881 store_geom = self.geom
3882 if type(vertex) is types.IntType:
3883 if vertex == 0 or vertex == 1:
3884 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3892 if self.geom is None:
3893 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3894 name = GetName(self.geom)
3896 piece = self.mesh.geom
3897 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3898 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3899 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3901 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3903 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3904 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3906 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3907 CompareMethod=self.CompareLengthNearVertex)
3908 self.geom = store_geom
3909 hyp.SetLength( length )
3912 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3913 # @ingroup l3_algos_segmarv
3914 def CompareLengthNearVertex(self, hyp, args):
3915 return IsEqual(hyp.GetLength(), args[0])
3917 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3918 # If the 2D mesher sees that all boundary edges are quadratic,
3919 # it generates quadratic faces, else it generates linear faces using
3920 # medium nodes as if they are vertices.
3921 # The 3D mesher generates quadratic volumes only if all boundary faces
3922 # are quadratic, else it fails.
3924 # @ingroup l3_hypos_additi
3925 def QuadraticMesh(self):
3926 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3929 # Public class: Mesh_CompositeSegment
3930 # --------------------------
3932 ## Defines a segment 1D algorithm for discretization
3934 # @ingroup l3_algos_basic
3935 class Mesh_CompositeSegment(Mesh_Segment):
3937 ## Private constructor.
3938 def __init__(self, mesh, geom=0):
3939 self.Create(mesh, geom, "CompositeSegment_1D")
3942 # Public class: Mesh_Segment_Python
3943 # ---------------------------------
3945 ## Defines a segment 1D algorithm for discretization with python function
3947 # @ingroup l3_algos_basic
3948 class Mesh_Segment_Python(Mesh_Segment):
3950 ## Private constructor.
3951 def __init__(self, mesh, geom=0):
3952 import Python1dPlugin
3953 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3955 ## Defines "PythonSplit1D" hypothesis
3956 # @param n for the number of segments that cut an edge
3957 # @param func for the python function that calculates the length of all segments
3958 # @param UseExisting if ==true - searches for the existing hypothesis created with
3959 # the same parameters, else (default) - creates a new one
3960 # @ingroup l3_hypos_1dhyps
3961 def PythonSplit1D(self, n, func, UseExisting=0):
3962 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3963 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3964 hyp.SetNumberOfSegments(n)
3965 hyp.SetPythonLog10RatioFunction(func)
3968 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3969 def ComparePythonSplit1D(self, hyp, args):
3970 #if hyp.GetNumberOfSegments() == args[0]:
3971 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3975 # Public class: Mesh_Triangle
3976 # ---------------------------
3978 ## Defines a triangle 2D algorithm
3980 # @ingroup l3_algos_basic
3981 class Mesh_Triangle(Mesh_Algorithm):
3990 ## Private constructor.
3991 def __init__(self, mesh, algoType, geom=0):
3992 Mesh_Algorithm.__init__(self)
3994 self.algoType = algoType
3995 if algoType == MEFISTO:
3996 self.Create(mesh, geom, "MEFISTO_2D")
3998 elif algoType == BLSURF:
4000 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
4001 #self.SetPhysicalMesh() - PAL19680
4002 elif algoType == NETGEN:
4004 print "Warning: NETGENPlugin module unavailable"
4006 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4008 elif algoType == NETGEN_2D:
4010 print "Warning: NETGENPlugin module unavailable"
4012 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4015 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4016 # @param area for the maximum area of each triangle
4017 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4018 # same parameters, else (default) - creates a new one
4020 # Only for algoType == MEFISTO || NETGEN_2D
4021 # @ingroup l3_hypos_2dhyps
4022 def MaxElementArea(self, area, UseExisting=0):
4023 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4024 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4025 CompareMethod=self.CompareMaxElementArea)
4026 elif self.algoType == NETGEN:
4027 hyp = self.Parameters(SIMPLE)
4028 hyp.SetMaxElementArea(area)
4031 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4032 def CompareMaxElementArea(self, hyp, args):
4033 return IsEqual(hyp.GetMaxElementArea(), args[0])
4035 ## Defines "LengthFromEdges" hypothesis to build triangles
4036 # based on the length of the edges taken from the wire
4038 # Only for algoType == MEFISTO || NETGEN_2D
4039 # @ingroup l3_hypos_2dhyps
4040 def LengthFromEdges(self):
4041 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4042 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4044 elif self.algoType == NETGEN:
4045 hyp = self.Parameters(SIMPLE)
4046 hyp.LengthFromEdges()
4049 ## Sets a way to define size of mesh elements to generate.
4050 # @param thePhysicalMesh is: DefaultSize or Custom.
4051 # @ingroup l3_hypos_blsurf
4052 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4053 # Parameter of BLSURF algo
4054 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4056 ## Sets size of mesh elements to generate.
4057 # @ingroup l3_hypos_blsurf
4058 def SetPhySize(self, theVal):
4059 # Parameter of BLSURF algo
4060 self.Parameters().SetPhySize(theVal)
4062 ## Sets lower boundary of mesh element size (PhySize).
4063 # @ingroup l3_hypos_blsurf
4064 def SetPhyMin(self, theVal=-1):
4065 # Parameter of BLSURF algo
4066 self.Parameters().SetPhyMin(theVal)
4068 ## Sets upper boundary of mesh element size (PhySize).
4069 # @ingroup l3_hypos_blsurf
4070 def SetPhyMax(self, theVal=-1):
4071 # Parameter of BLSURF algo
4072 self.Parameters().SetPhyMax(theVal)
4074 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4075 # @param theGeometricMesh is: DefaultGeom or Custom
4076 # @ingroup l3_hypos_blsurf
4077 def SetGeometricMesh(self, theGeometricMesh=0):
4078 # Parameter of BLSURF algo
4079 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4080 self.params.SetGeometricMesh(theGeometricMesh)
4082 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4083 # @ingroup l3_hypos_blsurf
4084 def SetAngleMeshS(self, theVal=_angleMeshS):
4085 # Parameter of BLSURF algo
4086 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4087 self.params.SetAngleMeshS(theVal)
4089 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4090 # @ingroup l3_hypos_blsurf
4091 def SetAngleMeshC(self, theVal=_angleMeshS):
4092 # Parameter of BLSURF algo
4093 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4094 self.params.SetAngleMeshC(theVal)
4096 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4097 # @ingroup l3_hypos_blsurf
4098 def SetGeoMin(self, theVal=-1):
4099 # Parameter of BLSURF algo
4100 self.Parameters().SetGeoMin(theVal)
4102 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4103 # @ingroup l3_hypos_blsurf
4104 def SetGeoMax(self, theVal=-1):
4105 # Parameter of BLSURF algo
4106 self.Parameters().SetGeoMax(theVal)
4108 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4109 # @ingroup l3_hypos_blsurf
4110 def SetGradation(self, theVal=_gradation):
4111 # Parameter of BLSURF algo
4112 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4113 self.params.SetGradation(theVal)
4115 ## Sets topology usage way.
4116 # @param way defines how mesh conformity is assured <ul>
4117 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4118 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4119 # @ingroup l3_hypos_blsurf
4120 def SetTopology(self, way):
4121 # Parameter of BLSURF algo
4122 self.Parameters().SetTopology(way)
4124 ## To respect geometrical edges or not.
4125 # @ingroup l3_hypos_blsurf
4126 def SetDecimesh(self, toIgnoreEdges=False):
4127 # Parameter of BLSURF algo
4128 self.Parameters().SetDecimesh(toIgnoreEdges)
4130 ## Sets verbosity level in the range 0 to 100.
4131 # @ingroup l3_hypos_blsurf
4132 def SetVerbosity(self, level):
4133 # Parameter of BLSURF algo
4134 self.Parameters().SetVerbosity(level)
4136 ## Sets advanced option value.
4137 # @ingroup l3_hypos_blsurf
4138 def SetOptionValue(self, optionName, level):
4139 # Parameter of BLSURF algo
4140 self.Parameters().SetOptionValue(optionName,level)
4142 ## Sets QuadAllowed flag.
4143 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4144 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4145 def SetQuadAllowed(self, toAllow=True):
4146 if self.algoType == NETGEN_2D:
4147 if toAllow: # add QuadranglePreference
4148 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4149 else: # remove QuadranglePreference
4150 for hyp in self.mesh.GetHypothesisList( self.geom ):
4151 if hyp.GetName() == "QuadranglePreference":
4152 self.mesh.RemoveHypothesis( self.geom, hyp )
4157 if self.Parameters():
4158 self.params.SetQuadAllowed(toAllow)
4161 ## Defines hypothesis having several parameters
4163 # @ingroup l3_hypos_netgen
4164 def Parameters(self, which=SOLE):
4167 if self.algoType == NETGEN:
4169 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4170 "libNETGENEngine.so", UseExisting=0)
4172 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4173 "libNETGENEngine.so", UseExisting=0)
4175 elif self.algoType == MEFISTO:
4176 print "Mefisto algo support no multi-parameter hypothesis"
4178 elif self.algoType == NETGEN_2D:
4179 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4180 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4182 elif self.algoType == BLSURF:
4183 self.params = self.Hypothesis("BLSURF_Parameters", [],
4184 "libBLSURFEngine.so", UseExisting=0)
4187 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4192 # Only for algoType == NETGEN
4193 # @ingroup l3_hypos_netgen
4194 def SetMaxSize(self, theSize):
4195 if self.Parameters():
4196 self.params.SetMaxSize(theSize)
4198 ## Sets SecondOrder flag
4200 # Only for algoType == NETGEN
4201 # @ingroup l3_hypos_netgen
4202 def SetSecondOrder(self, theVal):
4203 if self.Parameters():
4204 self.params.SetSecondOrder(theVal)
4206 ## Sets Optimize flag
4208 # Only for algoType == NETGEN
4209 # @ingroup l3_hypos_netgen
4210 def SetOptimize(self, theVal):
4211 if self.Parameters():
4212 self.params.SetOptimize(theVal)
4215 # @param theFineness is:
4216 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4218 # Only for algoType == NETGEN
4219 # @ingroup l3_hypos_netgen
4220 def SetFineness(self, theFineness):
4221 if self.Parameters():
4222 self.params.SetFineness(theFineness)
4226 # Only for algoType == NETGEN
4227 # @ingroup l3_hypos_netgen
4228 def SetGrowthRate(self, theRate):
4229 if self.Parameters():
4230 self.params.SetGrowthRate(theRate)
4232 ## Sets NbSegPerEdge
4234 # Only for algoType == NETGEN
4235 # @ingroup l3_hypos_netgen
4236 def SetNbSegPerEdge(self, theVal):
4237 if self.Parameters():
4238 self.params.SetNbSegPerEdge(theVal)
4240 ## Sets NbSegPerRadius
4242 # Only for algoType == NETGEN
4243 # @ingroup l3_hypos_netgen
4244 def SetNbSegPerRadius(self, theVal):
4245 if self.Parameters():
4246 self.params.SetNbSegPerRadius(theVal)
4248 ## Sets number of segments overriding value set by SetLocalLength()
4250 # Only for algoType == NETGEN
4251 # @ingroup l3_hypos_netgen
4252 def SetNumberOfSegments(self, theVal):
4253 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4255 ## Sets number of segments overriding value set by SetNumberOfSegments()
4257 # Only for algoType == NETGEN
4258 # @ingroup l3_hypos_netgen
4259 def SetLocalLength(self, theVal):
4260 self.Parameters(SIMPLE).SetLocalLength(theVal)
4265 # Public class: Mesh_Quadrangle
4266 # -----------------------------
4268 ## Defines a quadrangle 2D algorithm
4270 # @ingroup l3_algos_basic
4271 class Mesh_Quadrangle(Mesh_Algorithm):
4273 ## Private constructor.
4274 def __init__(self, mesh, geom=0):
4275 Mesh_Algorithm.__init__(self)
4276 self.Create(mesh, geom, "Quadrangle_2D")
4278 ## Defines "QuadranglePreference" hypothesis, forcing construction
4279 # of quadrangles if the number of nodes on the opposite edges is not the same
4280 # while the total number of nodes on edges is even
4282 # @ingroup l3_hypos_additi
4283 def QuadranglePreference(self):
4284 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4285 CompareMethod=self.CompareEqualHyp)
4288 ## Defines "TrianglePreference" hypothesis, forcing construction
4289 # of triangles in the refinement area if the number of nodes
4290 # on the opposite edges is not the same
4292 # @ingroup l3_hypos_additi
4293 def TrianglePreference(self):
4294 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4295 CompareMethod=self.CompareEqualHyp)
4298 # Public class: Mesh_Tetrahedron
4299 # ------------------------------
4301 ## Defines a tetrahedron 3D algorithm
4303 # @ingroup l3_algos_basic
4304 class Mesh_Tetrahedron(Mesh_Algorithm):
4309 ## Private constructor.
4310 def __init__(self, mesh, algoType, geom=0):
4311 Mesh_Algorithm.__init__(self)
4313 if algoType == NETGEN:
4314 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4317 elif algoType == FULL_NETGEN:
4319 print "Warning: NETGENPlugin module has not been imported."
4320 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4323 elif algoType == GHS3D:
4325 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4328 elif algoType == GHS3DPRL:
4329 import GHS3DPRLPlugin
4330 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4333 self.algoType = algoType
4335 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4336 # @param vol for the maximum volume of each tetrahedron
4337 # @param UseExisting if ==true - searches for the existing hypothesis created with
4338 # the same parameters, else (default) - creates a new one
4339 # @ingroup l3_hypos_maxvol
4340 def MaxElementVolume(self, vol, UseExisting=0):
4341 if self.algoType == NETGEN:
4342 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4343 CompareMethod=self.CompareMaxElementVolume)
4344 hyp.SetMaxElementVolume(vol)
4346 elif self.algoType == FULL_NETGEN:
4347 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4350 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4351 def CompareMaxElementVolume(self, hyp, args):
4352 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4354 ## Defines hypothesis having several parameters
4356 # @ingroup l3_hypos_netgen
4357 def Parameters(self, which=SOLE):
4361 if self.algoType == FULL_NETGEN:
4363 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4364 "libNETGENEngine.so", UseExisting=0)
4366 self.params = self.Hypothesis("NETGEN_Parameters", [],
4367 "libNETGENEngine.so", UseExisting=0)
4370 if self.algoType == GHS3D:
4371 self.params = self.Hypothesis("GHS3D_Parameters", [],
4372 "libGHS3DEngine.so", UseExisting=0)
4375 if self.algoType == GHS3DPRL:
4376 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4377 "libGHS3DPRLEngine.so", UseExisting=0)
4380 print "Algo supports no multi-parameter hypothesis"
4384 # Parameter of FULL_NETGEN
4385 # @ingroup l3_hypos_netgen
4386 def SetMaxSize(self, theSize):
4387 self.Parameters().SetMaxSize(theSize)
4389 ## Sets SecondOrder flag
4390 # Parameter of FULL_NETGEN
4391 # @ingroup l3_hypos_netgen
4392 def SetSecondOrder(self, theVal):
4393 self.Parameters().SetSecondOrder(theVal)
4395 ## Sets Optimize flag
4396 # Parameter of FULL_NETGEN
4397 # @ingroup l3_hypos_netgen
4398 def SetOptimize(self, theVal):
4399 self.Parameters().SetOptimize(theVal)
4402 # @param theFineness is:
4403 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4404 # Parameter of FULL_NETGEN
4405 # @ingroup l3_hypos_netgen
4406 def SetFineness(self, theFineness):
4407 self.Parameters().SetFineness(theFineness)
4410 # Parameter of FULL_NETGEN
4411 # @ingroup l3_hypos_netgen
4412 def SetGrowthRate(self, theRate):
4413 self.Parameters().SetGrowthRate(theRate)
4415 ## Sets NbSegPerEdge
4416 # Parameter of FULL_NETGEN
4417 # @ingroup l3_hypos_netgen
4418 def SetNbSegPerEdge(self, theVal):
4419 self.Parameters().SetNbSegPerEdge(theVal)
4421 ## Sets NbSegPerRadius
4422 # Parameter of FULL_NETGEN
4423 # @ingroup l3_hypos_netgen
4424 def SetNbSegPerRadius(self, theVal):
4425 self.Parameters().SetNbSegPerRadius(theVal)
4427 ## Sets number of segments overriding value set by SetLocalLength()
4428 # Only for algoType == NETGEN_FULL
4429 # @ingroup l3_hypos_netgen
4430 def SetNumberOfSegments(self, theVal):
4431 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4433 ## Sets number of segments overriding value set by SetNumberOfSegments()
4434 # Only for algoType == NETGEN_FULL
4435 # @ingroup l3_hypos_netgen
4436 def SetLocalLength(self, theVal):
4437 self.Parameters(SIMPLE).SetLocalLength(theVal)
4439 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4440 # Overrides value set by LengthFromEdges()
4441 # Only for algoType == NETGEN_FULL
4442 # @ingroup l3_hypos_netgen
4443 def MaxElementArea(self, area):
4444 self.Parameters(SIMPLE).SetMaxElementArea(area)
4446 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4447 # Overrides value set by MaxElementArea()
4448 # Only for algoType == NETGEN_FULL
4449 # @ingroup l3_hypos_netgen
4450 def LengthFromEdges(self):
4451 self.Parameters(SIMPLE).LengthFromEdges()
4453 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4454 # Overrides value set by MaxElementVolume()
4455 # Only for algoType == NETGEN_FULL
4456 # @ingroup l3_hypos_netgen
4457 def LengthFromFaces(self):
4458 self.Parameters(SIMPLE).LengthFromFaces()
4460 ## To mesh "holes" in a solid or not. Default is to mesh.
4461 # @ingroup l3_hypos_ghs3dh
4462 def SetToMeshHoles(self, toMesh):
4463 # Parameter of GHS3D
4464 self.Parameters().SetToMeshHoles(toMesh)
4466 ## Set Optimization level:
4467 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4468 # Default is Medium_Optimization
4469 # @ingroup l3_hypos_ghs3dh
4470 def SetOptimizationLevel(self, level):
4471 # Parameter of GHS3D
4472 self.Parameters().SetOptimizationLevel(level)
4474 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4475 # @ingroup l3_hypos_ghs3dh
4476 def SetMaximumMemory(self, MB):
4477 # Advanced parameter of GHS3D
4478 self.Parameters().SetMaximumMemory(MB)
4480 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4481 # automatic memory adjustment mode.
4482 # @ingroup l3_hypos_ghs3dh
4483 def SetInitialMemory(self, MB):
4484 # Advanced parameter of GHS3D
4485 self.Parameters().SetInitialMemory(MB)
4487 ## Path to working directory.
4488 # @ingroup l3_hypos_ghs3dh
4489 def SetWorkingDirectory(self, path):
4490 # Advanced parameter of GHS3D
4491 self.Parameters().SetWorkingDirectory(path)
4493 ## To keep working files or remove them. Log file remains in case of errors anyway.
4494 # @ingroup l3_hypos_ghs3dh
4495 def SetKeepFiles(self, toKeep):
4496 # Advanced parameter of GHS3D and GHS3DPRL
4497 self.Parameters().SetKeepFiles(toKeep)
4499 ## To set verbose level [0-10]. <ul>
4500 #<li> 0 - no standard output,
4501 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4502 # indicates when the final mesh is being saved. In addition the software
4503 # gives indication regarding the CPU time.
4504 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4505 # histogram of the skin mesh, quality statistics histogram together with
4506 # the characteristics of the final mesh.</ul>
4507 # @ingroup l3_hypos_ghs3dh
4508 def SetVerboseLevel(self, level):
4509 # Advanced parameter of GHS3D
4510 self.Parameters().SetVerboseLevel(level)
4512 ## To create new nodes.
4513 # @ingroup l3_hypos_ghs3dh
4514 def SetToCreateNewNodes(self, toCreate):
4515 # Advanced parameter of GHS3D
4516 self.Parameters().SetToCreateNewNodes(toCreate)
4518 ## To use boundary recovery version which tries to create mesh on a very poor
4519 # quality surface mesh.
4520 # @ingroup l3_hypos_ghs3dh
4521 def SetToUseBoundaryRecoveryVersion(self, toUse):
4522 # Advanced parameter of GHS3D
4523 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4525 ## Sets command line option as text.
4526 # @ingroup l3_hypos_ghs3dh
4527 def SetTextOption(self, option):
4528 # Advanced parameter of GHS3D
4529 self.Parameters().SetTextOption(option)
4531 ## Sets MED files name and path.
4532 def SetMEDName(self, value):
4533 self.Parameters().SetMEDName(value)
4535 ## Sets the number of partition of the initial mesh
4536 def SetNbPart(self, value):
4537 self.Parameters().SetNbPart(value)
4539 ## When big mesh, start tepal in background
4540 def SetBackground(self, value):
4541 self.Parameters().SetBackground(value)
4543 # Public class: Mesh_Hexahedron
4544 # ------------------------------
4546 ## Defines a hexahedron 3D algorithm
4548 # @ingroup l3_algos_basic
4549 class Mesh_Hexahedron(Mesh_Algorithm):
4554 ## Private constructor.
4555 def __init__(self, mesh, algoType=Hexa, geom=0):
4556 Mesh_Algorithm.__init__(self)
4558 self.algoType = algoType
4560 if algoType == Hexa:
4561 self.Create(mesh, geom, "Hexa_3D")
4564 elif algoType == Hexotic:
4565 import HexoticPlugin
4566 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4569 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4570 # @ingroup l3_hypos_hexotic
4571 def MinMaxQuad(self, min=3, max=8, quad=True):
4572 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4574 self.params.SetHexesMinLevel(min)
4575 self.params.SetHexesMaxLevel(max)
4576 self.params.SetHexoticQuadrangles(quad)
4579 # Deprecated, only for compatibility!
4580 # Public class: Mesh_Netgen
4581 # ------------------------------
4583 ## Defines a NETGEN-based 2D or 3D algorithm
4584 # that needs no discrete boundary (i.e. independent)
4586 # This class is deprecated, only for compatibility!
4589 # @ingroup l3_algos_basic
4590 class Mesh_Netgen(Mesh_Algorithm):
4594 ## Private constructor.
4595 def __init__(self, mesh, is3D, geom=0):
4596 Mesh_Algorithm.__init__(self)
4599 print "Warning: NETGENPlugin module has not been imported."
4603 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4607 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4610 ## Defines the hypothesis containing parameters of the algorithm
4611 def Parameters(self):
4613 hyp = self.Hypothesis("NETGEN_Parameters", [],
4614 "libNETGENEngine.so", UseExisting=0)
4616 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4617 "libNETGENEngine.so", UseExisting=0)
4620 # Public class: Mesh_Projection1D
4621 # ------------------------------
4623 ## Defines a projection 1D algorithm
4624 # @ingroup l3_algos_proj
4626 class Mesh_Projection1D(Mesh_Algorithm):
4628 ## Private constructor.
4629 def __init__(self, mesh, geom=0):
4630 Mesh_Algorithm.__init__(self)
4631 self.Create(mesh, geom, "Projection_1D")
4633 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4634 # a mesh pattern is taken, and, optionally, the association of vertices
4635 # between the source edge and a target edge (to which a hypothesis is assigned)
4636 # @param edge from which nodes distribution is taken
4637 # @param mesh from which nodes distribution is taken (optional)
4638 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4639 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4640 # to associate with \a srcV (optional)
4641 # @param UseExisting if ==true - searches for the existing hypothesis created with
4642 # the same parameters, else (default) - creates a new one
4643 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4644 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4646 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4647 hyp.SetSourceEdge( edge )
4648 if not mesh is None and isinstance(mesh, Mesh):
4649 mesh = mesh.GetMesh()
4650 hyp.SetSourceMesh( mesh )
4651 hyp.SetVertexAssociation( srcV, tgtV )
4654 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4655 #def CompareSourceEdge(self, hyp, args):
4656 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4660 # Public class: Mesh_Projection2D
4661 # ------------------------------
4663 ## Defines a projection 2D algorithm
4664 # @ingroup l3_algos_proj
4666 class Mesh_Projection2D(Mesh_Algorithm):
4668 ## Private constructor.
4669 def __init__(self, mesh, geom=0):
4670 Mesh_Algorithm.__init__(self)
4671 self.Create(mesh, geom, "Projection_2D")
4673 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4674 # a mesh pattern is taken, and, optionally, the association of vertices
4675 # between the source face and the target face (to which a hypothesis is assigned)
4676 # @param face from which the mesh pattern is taken
4677 # @param mesh from which the mesh pattern is taken (optional)
4678 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4679 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4680 # to associate with \a srcV1 (optional)
4681 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4682 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4683 # to associate with \a srcV2 (optional)
4684 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4685 # the same parameters, else (default) - forces the creation a new one
4687 # Note: all association vertices must belong to one edge of a face
4688 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4689 srcV2=None, tgtV2=None, UseExisting=0):
4690 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4692 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4693 hyp.SetSourceFace( face )
4694 if not mesh is None and isinstance(mesh, Mesh):
4695 mesh = mesh.GetMesh()
4696 hyp.SetSourceMesh( mesh )
4697 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4700 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4701 #def CompareSourceFace(self, hyp, args):
4702 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4705 # Public class: Mesh_Projection3D
4706 # ------------------------------
4708 ## Defines a projection 3D algorithm
4709 # @ingroup l3_algos_proj
4711 class Mesh_Projection3D(Mesh_Algorithm):
4713 ## Private constructor.
4714 def __init__(self, mesh, geom=0):
4715 Mesh_Algorithm.__init__(self)
4716 self.Create(mesh, geom, "Projection_3D")
4718 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4719 # the mesh pattern is taken, and, optionally, the association of vertices
4720 # between the source and the target solid (to which a hipothesis is assigned)
4721 # @param solid from where the mesh pattern is taken
4722 # @param mesh from where the mesh pattern is taken (optional)
4723 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4724 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4725 # to associate with \a srcV1 (optional)
4726 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4727 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4728 # to associate with \a srcV2 (optional)
4729 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4730 # the same parameters, else (default) - creates a new one
4732 # Note: association vertices must belong to one edge of a solid
4733 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4734 srcV2=0, tgtV2=0, UseExisting=0):
4735 hyp = self.Hypothesis("ProjectionSource3D",
4736 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4738 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4739 hyp.SetSource3DShape( solid )
4740 if not mesh is None and isinstance(mesh, Mesh):
4741 mesh = mesh.GetMesh()
4742 hyp.SetSourceMesh( mesh )
4743 if srcV1 and srcV2 and tgtV1 and tgtV2:
4744 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4745 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4748 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4749 #def CompareSourceShape3D(self, hyp, args):
4750 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4754 # Public class: Mesh_Prism
4755 # ------------------------
4757 ## Defines a 3D extrusion algorithm
4758 # @ingroup l3_algos_3dextr
4760 class Mesh_Prism3D(Mesh_Algorithm):
4762 ## Private constructor.
4763 def __init__(self, mesh, geom=0):
4764 Mesh_Algorithm.__init__(self)
4765 self.Create(mesh, geom, "Prism_3D")
4767 # Public class: Mesh_RadialPrism
4768 # -------------------------------
4770 ## Defines a Radial Prism 3D algorithm
4771 # @ingroup l3_algos_radialp
4773 class Mesh_RadialPrism3D(Mesh_Algorithm):
4775 ## Private constructor.
4776 def __init__(self, mesh, geom=0):
4777 Mesh_Algorithm.__init__(self)
4778 self.Create(mesh, geom, "RadialPrism_3D")
4780 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4781 self.nbLayers = None
4783 ## Return 3D hypothesis holding the 1D one
4784 def Get3DHypothesis(self):
4785 return self.distribHyp
4787 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4788 # hypothesis. Returns the created hypothesis
4789 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4790 #print "OwnHypothesis",hypType
4791 if not self.nbLayers is None:
4792 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4793 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4794 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4795 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4796 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4797 self.distribHyp.SetLayerDistribution( hyp )
4800 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4801 # prisms to build between the inner and outer shells
4802 # @param n number of layers
4803 # @param UseExisting if ==true - searches for the existing hypothesis created with
4804 # the same parameters, else (default) - creates a new one
4805 def NumberOfLayers(self, n, UseExisting=0):
4806 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4807 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4808 CompareMethod=self.CompareNumberOfLayers)
4809 self.nbLayers.SetNumberOfLayers( n )
4810 return self.nbLayers
4812 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4813 def CompareNumberOfLayers(self, hyp, args):
4814 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4816 ## Defines "LocalLength" hypothesis, specifying the segment length
4817 # to build between the inner and the outer shells
4818 # @param l the length of segments
4819 # @param p the precision of rounding
4820 def LocalLength(self, l, p=1e-07):
4821 hyp = self.OwnHypothesis("LocalLength", [l,p])
4826 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4827 # prisms to build between the inner and the outer shells.
4828 # @param n the number of layers
4829 # @param s the scale factor (optional)
4830 def NumberOfSegments(self, n, s=[]):
4832 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4834 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4835 hyp.SetDistrType( 1 )
4836 hyp.SetScaleFactor(s)
4837 hyp.SetNumberOfSegments(n)
4840 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4841 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4842 # @param start the length of the first segment
4843 # @param end the length of the last segment
4844 def Arithmetic1D(self, start, end ):
4845 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4846 hyp.SetLength(start, 1)
4847 hyp.SetLength(end , 0)
4850 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4851 # to build between the inner and the outer shells as geometric length increasing
4852 # @param start for the length of the first segment
4853 # @param end for the length of the last segment
4854 def StartEndLength(self, start, end):
4855 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4856 hyp.SetLength(start, 1)
4857 hyp.SetLength(end , 0)
4860 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4861 # to build between the inner and outer shells
4862 # @param fineness defines the quality of the mesh within the range [0-1]
4863 def AutomaticLength(self, fineness=0):
4864 hyp = self.OwnHypothesis("AutomaticLength")
4865 hyp.SetFineness( fineness )
4868 # Public class: Mesh_RadialQuadrangle1D2D
4869 # -------------------------------
4871 ## Defines a Radial Quadrangle 1D2D algorithm
4872 # @ingroup l2_algos_radialq
4874 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4876 ## Private constructor.
4877 def __init__(self, mesh, geom=0):
4878 Mesh_Algorithm.__init__(self)
4879 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4881 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4882 self.nbLayers = None
4884 ## Return 2D hypothesis holding the 1D one
4885 def Get2DHypothesis(self):
4886 return self.distribHyp
4888 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4889 # hypothesis. Returns the created hypothesis
4890 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4891 #print "OwnHypothesis",hypType
4892 if not self.nbLayers is None:
4893 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4894 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4895 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4896 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4897 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4898 self.distribHyp.SetLayerDistribution( hyp )
4901 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4902 # @param n number of layers
4903 # @param UseExisting if ==true - searches for the existing hypothesis created with
4904 # the same parameters, else (default) - creates a new one
4905 def NumberOfLayers2D(self, n, UseExisting=0):
4906 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4907 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4908 CompareMethod=self.CompareNumberOfLayers)
4909 self.nbLayers.SetNumberOfLayers( n )
4910 return self.nbLayers
4912 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4913 def CompareNumberOfLayers(self, hyp, args):
4914 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4916 ## Defines "LocalLength" hypothesis, specifying the segment length
4917 # @param l the length of segments
4918 # @param p the precision of rounding
4919 def LocalLength(self, l, p=1e-07):
4920 hyp = self.OwnHypothesis("LocalLength", [l,p])
4925 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4926 # @param n the number of layers
4927 # @param s the scale factor (optional)
4928 def NumberOfSegments(self, n, s=[]):
4930 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4932 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4933 hyp.SetDistrType( 1 )
4934 hyp.SetScaleFactor(s)
4935 hyp.SetNumberOfSegments(n)
4938 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4939 # with a length that changes in arithmetic progression
4940 # @param start the length of the first segment
4941 # @param end the length of the last segment
4942 def Arithmetic1D(self, start, end ):
4943 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4944 hyp.SetLength(start, 1)
4945 hyp.SetLength(end , 0)
4948 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4949 # as geometric length increasing
4950 # @param start for the length of the first segment
4951 # @param end for the length of the last segment
4952 def StartEndLength(self, start, end):
4953 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4954 hyp.SetLength(start, 1)
4955 hyp.SetLength(end , 0)
4958 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4959 # @param fineness defines the quality of the mesh within the range [0-1]
4960 def AutomaticLength(self, fineness=0):
4961 hyp = self.OwnHypothesis("AutomaticLength")
4962 hyp.SetFineness( fineness )
4966 # Private class: Mesh_UseExisting
4967 # -------------------------------
4968 class Mesh_UseExisting(Mesh_Algorithm):
4970 def __init__(self, dim, mesh, geom=0):
4972 self.Create(mesh, geom, "UseExisting_1D")
4974 self.Create(mesh, geom, "UseExisting_2D")
4977 import salome_notebook
4978 notebook = salome_notebook.notebook
4980 ##Return values of the notebook variables
4981 def ParseParameters(last, nbParams,nbParam, value):
4985 listSize = len(last)
4986 for n in range(0,nbParams):
4988 if counter < listSize:
4989 strResult = strResult + last[counter]
4991 strResult = strResult + ""
4993 if isinstance(value, str):
4994 if notebook.isVariable(value):
4995 result = notebook.get(value)
4996 strResult=strResult+value
4998 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
5000 strResult=strResult+str(value)
5002 if nbParams - 1 != counter:
5003 strResult=strResult+var_separator #":"
5005 return result, strResult
5007 #Wrapper class for StdMeshers_LocalLength hypothesis
5008 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5010 ## Set Length parameter value
5011 # @param length numerical value or name of variable from notebook
5012 def SetLength(self, length):
5013 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5014 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5015 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5017 ## Set Precision parameter value
5018 # @param precision numerical value or name of variable from notebook
5019 def SetPrecision(self, precision):
5020 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5021 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5022 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5024 #Registering the new proxy for LocalLength
5025 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5028 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5029 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5031 def SetLayerDistribution(self, hypo):
5032 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5033 hypo.ClearParameters();
5034 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5036 #Registering the new proxy for LayerDistribution
5037 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5039 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5040 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5042 ## Set Length parameter value
5043 # @param length numerical value or name of variable from notebook
5044 def SetLength(self, length):
5045 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5046 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5047 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5049 #Registering the new proxy for SegmentLengthAroundVertex
5050 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5053 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5054 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5056 ## Set Length parameter value
5057 # @param length numerical value or name of variable from notebook
5058 # @param isStart true is length is Start Length, otherwise false
5059 def SetLength(self, length, isStart):
5063 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5064 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5065 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5067 #Registering the new proxy for Arithmetic1D
5068 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5070 #Wrapper class for StdMeshers_Deflection1D hypothesis
5071 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5073 ## Set Deflection parameter value
5074 # @param deflection numerical value or name of variable from notebook
5075 def SetDeflection(self, deflection):
5076 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5077 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5078 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5080 #Registering the new proxy for Deflection1D
5081 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5083 #Wrapper class for StdMeshers_StartEndLength hypothesis
5084 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5086 ## Set Length parameter value
5087 # @param length numerical value or name of variable from notebook
5088 # @param isStart true is length is Start Length, otherwise false
5089 def SetLength(self, length, isStart):
5093 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5094 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5095 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5097 #Registering the new proxy for StartEndLength
5098 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5100 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5101 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5103 ## Set Max Element Area parameter value
5104 # @param area numerical value or name of variable from notebook
5105 def SetMaxElementArea(self, area):
5106 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5107 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5108 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5110 #Registering the new proxy for MaxElementArea
5111 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5114 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5115 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5117 ## Set Max Element Volume parameter value
5118 # @param area numerical value or name of variable from notebook
5119 def SetMaxElementVolume(self, volume):
5120 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5121 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5122 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5124 #Registering the new proxy for MaxElementVolume
5125 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5128 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5129 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5131 ## Set Number Of Layers parameter value
5132 # @param nbLayers numerical value or name of variable from notebook
5133 def SetNumberOfLayers(self, nbLayers):
5134 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5135 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5136 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5138 #Registering the new proxy for NumberOfLayers
5139 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5141 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5142 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5144 ## Set Number Of Segments parameter value
5145 # @param nbSeg numerical value or name of variable from notebook
5146 def SetNumberOfSegments(self, nbSeg):
5147 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5148 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5149 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5150 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5152 ## Set Scale Factor parameter value
5153 # @param factor numerical value or name of variable from notebook
5154 def SetScaleFactor(self, factor):
5155 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5156 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5157 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5159 #Registering the new proxy for NumberOfSegments
5160 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5163 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5164 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5166 ## Set Max Size parameter value
5167 # @param maxsize numerical value or name of variable from notebook
5168 def SetMaxSize(self, maxsize):
5169 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5170 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5171 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5172 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5174 ## Set Growth Rate parameter value
5175 # @param value numerical value or name of variable from notebook
5176 def SetGrowthRate(self, value):
5177 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5178 value, parameters = ParseParameters(lastParameters,4,2,value)
5179 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5180 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5182 ## Set Number of Segments per Edge parameter value
5183 # @param value numerical value or name of variable from notebook
5184 def SetNbSegPerEdge(self, value):
5185 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5186 value, parameters = ParseParameters(lastParameters,4,3,value)
5187 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5188 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5190 ## Set Number of Segments per Radius parameter value
5191 # @param value numerical value or name of variable from notebook
5192 def SetNbSegPerRadius(self, value):
5193 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5194 value, parameters = ParseParameters(lastParameters,4,4,value)
5195 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5196 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5198 #Registering the new proxy for NETGENPlugin_Hypothesis
5199 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5202 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5203 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5206 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5207 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5209 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5210 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5212 ## Set Number of Segments parameter value
5213 # @param nbSeg numerical value or name of variable from notebook
5214 def SetNumberOfSegments(self, nbSeg):
5215 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5216 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5217 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5218 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5220 ## Set Local Length parameter value
5221 # @param length numerical value or name of variable from notebook
5222 def SetLocalLength(self, length):
5223 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5224 length, parameters = ParseParameters(lastParameters,2,1,length)
5225 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5226 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5228 ## Set Max Element Area parameter value
5229 # @param area numerical value or name of variable from notebook
5230 def SetMaxElementArea(self, area):
5231 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5232 area, parameters = ParseParameters(lastParameters,2,2,area)
5233 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5234 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5236 def LengthFromEdges(self):
5237 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5239 value, parameters = ParseParameters(lastParameters,2,2,value)
5240 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5241 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5243 #Registering the new proxy for NETGEN_SimpleParameters_2D
5244 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5247 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5248 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5249 ## Set Max Element Volume parameter value
5250 # @param volume numerical value or name of variable from notebook
5251 def SetMaxElementVolume(self, volume):
5252 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5253 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5254 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5255 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5257 def LengthFromFaces(self):
5258 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5260 value, parameters = ParseParameters(lastParameters,3,3,value)
5261 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5262 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5264 #Registering the new proxy for NETGEN_SimpleParameters_3D
5265 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5267 class Pattern(SMESH._objref_SMESH_Pattern):
5269 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5271 if isinstance(theNodeIndexOnKeyPoint1,str):
5273 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5275 theNodeIndexOnKeyPoint1 -= 1
5276 theMesh.SetParameters(Parameters)
5277 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5279 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5282 if isinstance(theNode000Index,str):
5284 if isinstance(theNode001Index,str):
5286 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5288 theNode000Index -= 1
5290 theNode001Index -= 1
5291 theMesh.SetParameters(Parameters)
5292 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5294 #Registering the new proxy for Pattern
5295 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)