1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Author : Francis KLOSS, OCC
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating Creating meshes
34 ## @defgroup l2_impexp Importing and exporting meshes
35 ## @defgroup l2_construct Constructing meshes
36 ## @defgroup l2_algorithms Defining Algorithms
38 ## @defgroup l3_algos_basic Basic meshing algorithms
39 ## @defgroup l3_algos_proj Projection Algorithms
40 ## @defgroup l3_algos_radialp Radial Prism
41 ## @defgroup l3_algos_segmarv Segments around Vertex
42 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
45 ## @defgroup l2_hypotheses Defining hypotheses
47 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
95 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 ## @addtogroup l1_auxiliary
113 # Types of algorithms
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL = FULL_NETGEN
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS = SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
142 # Fineness enumeration (for NETGEN)
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
159 PrecisionConfusion = 1e-07
161 ## Converts an angle from degrees to radians
162 def DegreesToRadians(AngleInDegrees):
164 return AngleInDegrees * pi / 180.0
166 # Salome notebook variable separator
169 # Parametrized substitute for PointStruct
170 class PointStructStr:
179 def __init__(self, xStr, yStr, zStr):
183 if isinstance(xStr, str) and notebook.isVariable(xStr):
184 self.x = notebook.get(xStr)
187 if isinstance(yStr, str) and notebook.isVariable(yStr):
188 self.y = notebook.get(yStr)
191 if isinstance(zStr, str) and notebook.isVariable(zStr):
192 self.z = notebook.get(zStr)
196 # Parametrized substitute for PointStruct (with 6 parameters)
197 class PointStructStr6:
212 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
219 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
220 self.x1 = notebook.get(x1Str)
223 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
224 self.x2 = notebook.get(x2Str)
227 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
228 self.y1 = notebook.get(y1Str)
231 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
232 self.y2 = notebook.get(y2Str)
235 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
236 self.z1 = notebook.get(z1Str)
239 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
240 self.z2 = notebook.get(z2Str)
244 # Parametrized substitute for AxisStruct
260 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
267 if isinstance(xStr, str) and notebook.isVariable(xStr):
268 self.x = notebook.get(xStr)
271 if isinstance(yStr, str) and notebook.isVariable(yStr):
272 self.y = notebook.get(yStr)
275 if isinstance(zStr, str) and notebook.isVariable(zStr):
276 self.z = notebook.get(zStr)
279 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
280 self.dx = notebook.get(dxStr)
283 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
284 self.dy = notebook.get(dyStr)
287 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
288 self.dz = notebook.get(dzStr)
292 # Parametrized substitute for DirStruct
295 def __init__(self, pointStruct):
296 self.pointStruct = pointStruct
298 # Returns list of variable values from salome notebook
299 def ParsePointStruct(Point):
300 Parameters = 2*var_separator
301 if isinstance(Point, PointStructStr):
302 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
303 Point = PointStruct(Point.x, Point.y, Point.z)
304 return Point, Parameters
306 # Returns list of variable values from salome notebook
307 def ParseDirStruct(Dir):
308 Parameters = 2*var_separator
309 if isinstance(Dir, DirStructStr):
310 pntStr = Dir.pointStruct
311 if isinstance(pntStr, PointStructStr6):
312 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
313 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
314 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
315 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
317 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
318 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
319 Dir = DirStruct(Point)
320 return Dir, Parameters
322 # Returns list of variable values from salome notebook
323 def ParseAxisStruct(Axis):
324 Parameters = 5*var_separator
325 if isinstance(Axis, AxisStructStr):
326 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
327 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
328 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
329 return Axis, Parameters
331 ## Return list of variable values from salome notebook
332 def ParseAngles(list):
335 for parameter in list:
336 if isinstance(parameter,str) and notebook.isVariable(parameter):
337 Result.append(DegreesToRadians(notebook.get(parameter)))
340 Result.append(parameter)
343 Parameters = Parameters + str(parameter)
344 Parameters = Parameters + var_separator
346 Parameters = Parameters[:len(Parameters)-1]
347 return Result, Parameters
349 def IsEqual(val1, val2, tol=PrecisionConfusion):
350 if abs(val1 - val2) < tol:
358 ior = salome.orb.object_to_string(obj)
359 sobj = salome.myStudy.FindObjectIOR(ior)
363 attr = sobj.FindAttribute("AttributeName")[1]
366 ## Prints error message if a hypothesis was not assigned.
367 def TreatHypoStatus(status, hypName, geomName, isAlgo):
369 hypType = "algorithm"
371 hypType = "hypothesis"
373 if status == HYP_UNKNOWN_FATAL :
374 reason = "for unknown reason"
375 elif status == HYP_INCOMPATIBLE :
376 reason = "this hypothesis mismatches the algorithm"
377 elif status == HYP_NOTCONFORM :
378 reason = "a non-conform mesh would be built"
379 elif status == HYP_ALREADY_EXIST :
380 reason = hypType + " of the same dimension is already assigned to this shape"
381 elif status == HYP_BAD_DIM :
382 reason = hypType + " mismatches the shape"
383 elif status == HYP_CONCURENT :
384 reason = "there are concurrent hypotheses on sub-shapes"
385 elif status == HYP_BAD_SUBSHAPE :
386 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
387 elif status == HYP_BAD_GEOMETRY:
388 reason = "geometry mismatches the expectation of the algorithm"
389 elif status == HYP_HIDDEN_ALGO:
390 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
391 elif status == HYP_HIDING_ALGO:
392 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
393 elif status == HYP_NEED_SHAPE:
394 reason = "Algorithm can't work without shape"
397 hypName = '"' + hypName + '"'
398 geomName= '"' + geomName+ '"'
399 if status < HYP_UNKNOWN_FATAL:
400 print hypName, "was assigned to", geomName,"but", reason
402 print hypName, "was not assigned to",geomName,":", reason
405 # end of l1_auxiliary
408 # All methods of this class are accessible directly from the smesh.py package.
409 class smeshDC(SMESH._objref_SMESH_Gen):
411 ## Sets the current study and Geometry component
412 # @ingroup l1_auxiliary
413 def init_smesh(self,theStudy,geompyD):
414 self.SetCurrentStudy(theStudy,geompyD)
416 ## Creates an empty Mesh. This mesh can have an underlying geometry.
417 # @param obj the Geometrical object on which the mesh is built. If not defined,
418 # the mesh will have no underlying geometry.
419 # @param name the name for the new mesh.
420 # @return an instance of Mesh class.
421 # @ingroup l2_construct
422 def Mesh(self, obj=0, name=0):
423 if isinstance(obj,str):
425 return Mesh(self,self.geompyD,obj,name)
427 ## Returns a long value from enumeration
428 # Should be used for SMESH.FunctorType enumeration
429 # @ingroup l1_controls
430 def EnumToLong(self,theItem):
433 ## Gets PointStruct from vertex
434 # @param theVertex a GEOM object(vertex)
435 # @return SMESH.PointStruct
436 # @ingroup l1_auxiliary
437 def GetPointStruct(self,theVertex):
438 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
439 return PointStruct(x,y,z)
441 ## Gets DirStruct from vector
442 # @param theVector a GEOM object(vector)
443 # @return SMESH.DirStruct
444 # @ingroup l1_auxiliary
445 def GetDirStruct(self,theVector):
446 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
447 if(len(vertices) != 2):
448 print "Error: vector object is incorrect."
450 p1 = self.geompyD.PointCoordinates(vertices[0])
451 p2 = self.geompyD.PointCoordinates(vertices[1])
452 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
453 dirst = DirStruct(pnt)
456 ## Makes DirStruct from a triplet
457 # @param x,y,z vector components
458 # @return SMESH.DirStruct
459 # @ingroup l1_auxiliary
460 def MakeDirStruct(self,x,y,z):
461 pnt = PointStruct(x,y,z)
462 return DirStruct(pnt)
464 ## Get AxisStruct from object
465 # @param theObj a GEOM object (line or plane)
466 # @return SMESH.AxisStruct
467 # @ingroup l1_auxiliary
468 def GetAxisStruct(self,theObj):
469 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
471 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
472 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
473 vertex1 = self.geompyD.PointCoordinates(vertex1)
474 vertex2 = self.geompyD.PointCoordinates(vertex2)
475 vertex3 = self.geompyD.PointCoordinates(vertex3)
476 vertex4 = self.geompyD.PointCoordinates(vertex4)
477 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
478 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
479 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] ]
480 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
482 elif len(edges) == 1:
483 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
484 p1 = self.geompyD.PointCoordinates( vertex1 )
485 p2 = self.geompyD.PointCoordinates( vertex2 )
486 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
490 # From SMESH_Gen interface:
491 # ------------------------
493 ## Sets the given name to the object
494 # @param obj the object to rename
495 # @param name a new object name
496 # @ingroup l1_auxiliary
497 def SetName(self, obj, name):
498 if isinstance( obj, Mesh ):
500 elif isinstance( obj, Mesh_Algorithm ):
501 obj = obj.GetAlgorithm()
502 ior = salome.orb.object_to_string(obj)
503 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
505 ## Sets the current mode
506 # @ingroup l1_auxiliary
507 def SetEmbeddedMode( self,theMode ):
508 #self.SetEmbeddedMode(theMode)
509 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
511 ## Gets the current mode
512 # @ingroup l1_auxiliary
513 def IsEmbeddedMode(self):
514 #return self.IsEmbeddedMode()
515 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
517 ## Sets the current study
518 # @ingroup l1_auxiliary
519 def SetCurrentStudy( self, theStudy, geompyD = None ):
520 #self.SetCurrentStudy(theStudy)
523 geompyD = geompy.geom
526 self.SetGeomEngine(geompyD)
527 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
529 ## Gets the current study
530 # @ingroup l1_auxiliary
531 def GetCurrentStudy(self):
532 #return self.GetCurrentStudy()
533 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
535 ## Creates a Mesh object importing data from the given UNV file
536 # @return an instance of Mesh class
538 def CreateMeshesFromUNV( self,theFileName ):
539 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
540 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
543 ## Creates a Mesh object(s) importing data from the given MED file
544 # @return a list of Mesh class instances
546 def CreateMeshesFromMED( self,theFileName ):
547 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
549 for iMesh in range(len(aSmeshMeshes)) :
550 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
551 aMeshes.append(aMesh)
552 return aMeshes, aStatus
554 ## Creates a Mesh object importing data from the given STL file
555 # @return an instance of Mesh class
557 def CreateMeshesFromSTL( self, theFileName ):
558 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
559 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
562 ## From SMESH_Gen interface
563 # @return the list of integer values
564 # @ingroup l1_auxiliary
565 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
566 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
568 ## From SMESH_Gen interface. Creates a pattern
569 # @return an instance of SMESH_Pattern
571 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
572 # @ingroup l2_modif_patterns
573 def GetPattern(self):
574 return SMESH._objref_SMESH_Gen.GetPattern(self)
576 ## Sets number of segments per diagonal of boundary box of geometry by which
577 # default segment length of appropriate 1D hypotheses is defined.
578 # Default value is 10
579 # @ingroup l1_auxiliary
580 def SetBoundaryBoxSegmentation(self, nbSegments):
581 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
583 ## Concatenate the given meshes into one mesh.
584 # @return an instance of Mesh class
585 # @param meshes the meshes to combine into one mesh
586 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
587 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
588 # @param mergeTolerance tolerance for merging nodes
589 # @param allGroups forces creation of groups of all elements
590 def Concatenate( self, meshes, uniteIdenticalGroups,
591 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
592 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
594 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
595 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
597 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
598 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
599 aSmeshMesh.SetParameters(Parameters)
600 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
603 # Filtering. Auxiliary functions:
604 # ------------------------------
606 ## Creates an empty criterion
607 # @return SMESH.Filter.Criterion
608 # @ingroup l1_controls
609 def GetEmptyCriterion(self):
610 Type = self.EnumToLong(FT_Undefined)
611 Compare = self.EnumToLong(FT_Undefined)
615 UnaryOp = self.EnumToLong(FT_Undefined)
616 BinaryOp = self.EnumToLong(FT_Undefined)
619 Precision = -1 ##@1e-07
620 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
621 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
623 ## Creates a criterion by the given parameters
624 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
625 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
626 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
627 # @param Treshold the threshold value (range of ids as string, shape, numeric)
628 # @param UnaryOp FT_LogicalNOT or FT_Undefined
629 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
630 # FT_Undefined (must be for the last criterion of all criteria)
631 # @return SMESH.Filter.Criterion
632 # @ingroup l1_controls
633 def GetCriterion(self,elementType,
635 Compare = FT_EqualTo,
637 UnaryOp=FT_Undefined,
638 BinaryOp=FT_Undefined):
639 aCriterion = self.GetEmptyCriterion()
640 aCriterion.TypeOfElement = elementType
641 aCriterion.Type = self.EnumToLong(CritType)
645 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
646 aCriterion.Compare = self.EnumToLong(Compare)
647 elif Compare == "=" or Compare == "==":
648 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
650 aCriterion.Compare = self.EnumToLong(FT_LessThan)
652 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
654 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
657 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
658 FT_BelongToCylinder, FT_LyingOnGeom]:
659 # Checks the treshold
660 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
661 aCriterion.ThresholdStr = GetName(aTreshold)
662 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
664 print "Error: The treshold should be a shape."
666 elif CritType == FT_RangeOfIds:
667 # Checks the treshold
668 if isinstance(aTreshold, str):
669 aCriterion.ThresholdStr = aTreshold
671 print "Error: The treshold should be a string."
673 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
674 FT_FreeFaces, FT_ElemGeomType, FT_GroupColor]:
675 # At this point the treshold is unnecessary
676 if aTreshold == FT_LogicalNOT:
677 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
678 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
679 aCriterion.BinaryOp = aTreshold
683 aTreshold = float(aTreshold)
684 aCriterion.Threshold = aTreshold
686 print "Error: The treshold should be a number."
689 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
690 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
692 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
693 aCriterion.BinaryOp = self.EnumToLong(Treshold)
695 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
696 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
698 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
699 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
703 ## Creates a filter with the given parameters
704 # @param elementType the type of elements in the group
705 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
706 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
707 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
708 # @param UnaryOp FT_LogicalNOT or FT_Undefined
709 # @return SMESH_Filter
710 # @ingroup l1_controls
711 def GetFilter(self,elementType,
712 CritType=FT_Undefined,
715 UnaryOp=FT_Undefined):
716 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
717 aFilterMgr = self.CreateFilterManager()
718 aFilter = aFilterMgr.CreateFilter()
720 aCriteria.append(aCriterion)
721 aFilter.SetCriteria(aCriteria)
724 ## Creates a numerical functor by its type
725 # @param theCriterion FT_...; functor type
726 # @return SMESH_NumericalFunctor
727 # @ingroup l1_controls
728 def GetFunctor(self,theCriterion):
729 aFilterMgr = self.CreateFilterManager()
730 if theCriterion == FT_AspectRatio:
731 return aFilterMgr.CreateAspectRatio()
732 elif theCriterion == FT_AspectRatio3D:
733 return aFilterMgr.CreateAspectRatio3D()
734 elif theCriterion == FT_Warping:
735 return aFilterMgr.CreateWarping()
736 elif theCriterion == FT_MinimumAngle:
737 return aFilterMgr.CreateMinimumAngle()
738 elif theCriterion == FT_Taper:
739 return aFilterMgr.CreateTaper()
740 elif theCriterion == FT_Skew:
741 return aFilterMgr.CreateSkew()
742 elif theCriterion == FT_Area:
743 return aFilterMgr.CreateArea()
744 elif theCriterion == FT_Volume3D:
745 return aFilterMgr.CreateVolume3D()
746 elif theCriterion == FT_MultiConnection:
747 return aFilterMgr.CreateMultiConnection()
748 elif theCriterion == FT_MultiConnection2D:
749 return aFilterMgr.CreateMultiConnection2D()
750 elif theCriterion == FT_Length:
751 return aFilterMgr.CreateLength()
752 elif theCriterion == FT_Length2D:
753 return aFilterMgr.CreateLength2D()
755 print "Error: given parameter is not numerucal functor type."
757 ## Creates hypothesis
760 # @return created hypothesis instance
761 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
762 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
765 #Registering the new proxy for SMESH_Gen
766 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
772 ## This class allows defining and managing a mesh.
773 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
774 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
775 # new nodes and elements and by changing the existing entities), to get information
776 # about a mesh and to export a mesh into different formats.
785 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
786 # sets the GUI name of this mesh to \a name.
787 # @param smeshpyD an instance of smeshDC class
788 # @param geompyD an instance of geompyDC class
789 # @param obj Shape to be meshed or SMESH_Mesh object
790 # @param name Study name of the mesh
791 # @ingroup l2_construct
792 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
793 self.smeshpyD=smeshpyD
798 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
800 self.mesh = self.smeshpyD.CreateMesh(self.geom)
801 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
804 self.mesh = self.smeshpyD.CreateEmptyMesh()
806 self.smeshpyD.SetName(self.mesh, name)
808 self.smeshpyD.SetName(self.mesh, GetName(obj))
811 self.geom = self.mesh.GetShapeToMesh()
813 self.editor = self.mesh.GetMeshEditor()
815 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
816 # @param theMesh a SMESH_Mesh object
817 # @ingroup l2_construct
818 def SetMesh(self, theMesh):
820 self.geom = self.mesh.GetShapeToMesh()
822 ## Returns the mesh, that is an instance of SMESH_Mesh interface
823 # @return a SMESH_Mesh object
824 # @ingroup l2_construct
828 ## Gets the name of the mesh
829 # @return the name of the mesh as a string
830 # @ingroup l2_construct
832 name = GetName(self.GetMesh())
835 ## Sets a name to the mesh
836 # @param name a new name of the mesh
837 # @ingroup l2_construct
838 def SetName(self, name):
839 self.smeshpyD.SetName(self.GetMesh(), name)
841 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
842 # The subMesh object gives access to the IDs of nodes and elements.
843 # @param theSubObject a geometrical object (shape)
844 # @param theName a name for the submesh
845 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
846 # @ingroup l2_submeshes
847 def GetSubMesh(self, theSubObject, theName):
848 submesh = self.mesh.GetSubMesh(theSubObject, theName)
851 ## Returns the shape associated to the mesh
852 # @return a GEOM_Object
853 # @ingroup l2_construct
857 ## Associates the given shape to the mesh (entails the recreation of the mesh)
858 # @param geom the shape to be meshed (GEOM_Object)
859 # @ingroup l2_construct
860 def SetShape(self, geom):
861 self.mesh = self.smeshpyD.CreateMesh(geom)
863 ## Returns true if the hypotheses are defined well
864 # @param theSubObject a subshape of a mesh shape
865 # @return True or False
866 # @ingroup l2_construct
867 def IsReadyToCompute(self, theSubObject):
868 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
870 ## Returns errors of hypotheses definition.
871 # The list of errors is empty if everything is OK.
872 # @param theSubObject a subshape of a mesh shape
873 # @return a list of errors
874 # @ingroup l2_construct
875 def GetAlgoState(self, theSubObject):
876 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
878 ## Returns a geometrical object on which the given element was built.
879 # The returned geometrical object, if not nil, is either found in the
880 # study or published by this method with the given name
881 # @param theElementID the id of the mesh element
882 # @param theGeomName the user-defined name of the geometrical object
883 # @return GEOM::GEOM_Object instance
884 # @ingroup l2_construct
885 def GetGeometryByMeshElement(self, theElementID, theGeomName):
886 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
888 ## Returns the mesh dimension depending on the dimension of the underlying shape
889 # @return mesh dimension as an integer value [0,3]
890 # @ingroup l1_auxiliary
891 def MeshDimension(self):
892 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
893 if len( shells ) > 0 :
895 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
897 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
903 ## Creates a segment discretization 1D algorithm.
904 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
905 # \n If the optional \a geom parameter is not set, this algorithm is global.
906 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
907 # @param algo the type of the required algorithm. Possible values are:
909 # - smesh.PYTHON for discretization via a python function,
910 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
911 # @param geom If defined is the subshape to be meshed
912 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
913 # @ingroup l3_algos_basic
914 def Segment(self, algo=REGULAR, geom=0):
915 ## if Segment(geom) is called by mistake
916 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
917 algo, geom = geom, algo
918 if not algo: algo = REGULAR
921 return Mesh_Segment(self, geom)
923 return Mesh_Segment_Python(self, geom)
924 elif algo == COMPOSITE:
925 return Mesh_CompositeSegment(self, geom)
927 return Mesh_Segment(self, geom)
929 ## Enables creation of nodes and segments usable by 2D algoritms.
930 # The added nodes and segments must be bound to edges and vertices by
931 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
932 # If the optional \a geom parameter is not set, this algorithm is global.
933 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
934 # @param geom the subshape to be manually meshed
935 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
936 # @ingroup l3_algos_basic
937 def UseExistingSegments(self, geom=0):
938 algo = Mesh_UseExisting(1,self,geom)
939 return algo.GetAlgorithm()
941 ## Enables creation of nodes and faces usable by 3D algoritms.
942 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
943 # and SetMeshElementOnShape()
944 # If the optional \a geom parameter is not set, this algorithm is global.
945 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
946 # @param geom the subshape to be manually meshed
947 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
948 # @ingroup l3_algos_basic
949 def UseExistingFaces(self, geom=0):
950 algo = Mesh_UseExisting(2,self,geom)
951 return algo.GetAlgorithm()
953 ## Creates a triangle 2D algorithm for faces.
954 # If the optional \a geom parameter is not set, this algorithm is global.
955 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
956 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
957 # @param geom If defined, the subshape to be meshed (GEOM_Object)
958 # @return an instance of Mesh_Triangle algorithm
959 # @ingroup l3_algos_basic
960 def Triangle(self, algo=MEFISTO, geom=0):
961 ## if Triangle(geom) is called by mistake
962 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
966 return Mesh_Triangle(self, algo, geom)
968 ## Creates a quadrangle 2D algorithm for faces.
969 # If the optional \a geom parameter is not set, this algorithm is global.
970 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
971 # @param geom If defined, the subshape to be meshed (GEOM_Object)
972 # @return an instance of Mesh_Quadrangle algorithm
973 # @ingroup l3_algos_basic
974 def Quadrangle(self, geom=0):
975 return Mesh_Quadrangle(self, geom)
977 ## Creates a tetrahedron 3D algorithm for solids.
978 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
979 # If the optional \a geom parameter is not set, this algorithm is global.
980 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
981 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
982 # @param geom If defined, the subshape to be meshed (GEOM_Object)
983 # @return an instance of Mesh_Tetrahedron algorithm
984 # @ingroup l3_algos_basic
985 def Tetrahedron(self, algo=NETGEN, geom=0):
986 ## if Tetrahedron(geom) is called by mistake
987 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
988 algo, geom = geom, algo
989 if not algo: algo = NETGEN
991 return Mesh_Tetrahedron(self, algo, geom)
993 ## Creates a hexahedron 3D algorithm for solids.
994 # If the optional \a geom parameter is not set, this algorithm is global.
995 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
996 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
997 # @param geom If defined, the subshape to be meshed (GEOM_Object)
998 # @return an instance of Mesh_Hexahedron algorithm
999 # @ingroup l3_algos_basic
1000 def Hexahedron(self, algo=Hexa, geom=0):
1001 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
1002 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
1003 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
1004 elif geom == 0: algo, geom = Hexa, algo
1005 return Mesh_Hexahedron(self, algo, geom)
1007 ## Deprecated, used only for compatibility!
1008 # @return an instance of Mesh_Netgen algorithm
1009 # @ingroup l3_algos_basic
1010 def Netgen(self, is3D, geom=0):
1011 return Mesh_Netgen(self, is3D, geom)
1013 ## Creates a projection 1D algorithm for edges.
1014 # If the optional \a geom parameter is not set, this algorithm is global.
1015 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1016 # @param geom If defined, the subshape to be meshed
1017 # @return an instance of Mesh_Projection1D algorithm
1018 # @ingroup l3_algos_proj
1019 def Projection1D(self, geom=0):
1020 return Mesh_Projection1D(self, geom)
1022 ## Creates a projection 2D algorithm for faces.
1023 # If the optional \a geom parameter is not set, this algorithm is global.
1024 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1025 # @param geom If defined, the subshape to be meshed
1026 # @return an instance of Mesh_Projection2D algorithm
1027 # @ingroup l3_algos_proj
1028 def Projection2D(self, geom=0):
1029 return Mesh_Projection2D(self, geom)
1031 ## Creates a projection 3D algorithm for solids.
1032 # If the optional \a geom parameter is not set, this algorithm is global.
1033 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1034 # @param geom If defined, the subshape to be meshed
1035 # @return an instance of Mesh_Projection3D algorithm
1036 # @ingroup l3_algos_proj
1037 def Projection3D(self, geom=0):
1038 return Mesh_Projection3D(self, geom)
1040 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
1041 # If the optional \a geom parameter is not set, this algorithm is global.
1042 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
1043 # @param geom If defined, the subshape to be meshed
1044 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
1045 # @ingroup l3_algos_radialp l3_algos_3dextr
1046 def Prism(self, geom=0):
1050 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
1051 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
1052 if nbSolids == 0 or nbSolids == nbShells:
1053 return Mesh_Prism3D(self, geom)
1054 return Mesh_RadialPrism3D(self, geom)
1056 ## Evaluates size of prospective mesh on a shape
1057 # @return True or False
1058 def Evaluate(self, geom=0):
1059 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1061 geom = self.mesh.GetShapeToMesh()
1064 return self.smeshpyD.Evaluate(self.mesh, geom)
1067 ## Computes the mesh and returns the status of the computation
1068 # @return True or False
1069 # @ingroup l2_construct
1070 def Compute(self, geom=0):
1071 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
1073 geom = self.mesh.GetShapeToMesh()
1078 ok = self.smeshpyD.Compute(self.mesh, geom)
1079 except SALOME.SALOME_Exception, ex:
1080 print "Mesh computation failed, exception caught:"
1081 print " ", ex.details.text
1084 print "Mesh computation failed, exception caught:"
1085 traceback.print_exc()
1087 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
1090 if err.isGlobalAlgo:
1098 reason = '%s %sD algorithm is missing' % (glob, dim)
1099 elif err.state == HYP_MISSING:
1100 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
1101 % (glob, dim, name, dim))
1102 elif err.state == HYP_NOTCONFORM:
1103 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
1104 elif err.state == HYP_BAD_PARAMETER:
1105 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
1106 % ( glob, dim, name ))
1107 elif err.state == HYP_BAD_GEOMETRY:
1108 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
1109 'geometry' % ( glob, dim, name ))
1111 reason = "For unknown reason."+\
1112 " Revise Mesh.Compute() implementation in smeshDC.py!"
1114 if allReasons != "":
1117 allReasons += reason
1119 if allReasons != "":
1120 print '"' + GetName(self.mesh) + '"',"has not been computed:"
1124 print '"' + GetName(self.mesh) + '"',"has not been computed."
1127 if salome.sg.hasDesktop():
1128 smeshgui = salome.ImportComponentGUI("SMESH")
1129 smeshgui.Init(self.mesh.GetStudyId())
1130 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
1131 salome.sg.updateObjBrowser(1)
1135 ## Removes all nodes and elements
1136 # @ingroup l2_construct
1139 if salome.sg.hasDesktop():
1140 smeshgui = salome.ImportComponentGUI("SMESH")
1141 smeshgui.Init(self.mesh.GetStudyId())
1142 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1143 salome.sg.updateObjBrowser(1)
1145 ## Removes all nodes and elements of indicated shape
1146 # @ingroup l2_construct
1147 def ClearSubMesh(self, geomId):
1148 self.mesh.ClearSubMesh(geomId)
1149 if salome.sg.hasDesktop():
1150 smeshgui = salome.ImportComponentGUI("SMESH")
1151 smeshgui.Init(self.mesh.GetStudyId())
1152 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
1153 salome.sg.updateObjBrowser(1)
1155 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
1156 # @param fineness [0,-1] defines mesh fineness
1157 # @return True or False
1158 # @ingroup l3_algos_basic
1159 def AutomaticTetrahedralization(self, fineness=0):
1160 dim = self.MeshDimension()
1162 self.RemoveGlobalHypotheses()
1163 self.Segment().AutomaticLength(fineness)
1165 self.Triangle().LengthFromEdges()
1168 self.Tetrahedron(NETGEN)
1170 return self.Compute()
1172 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
1173 # @param fineness [0,-1] defines mesh fineness
1174 # @return True or False
1175 # @ingroup l3_algos_basic
1176 def AutomaticHexahedralization(self, fineness=0):
1177 dim = self.MeshDimension()
1178 # assign the hypotheses
1179 self.RemoveGlobalHypotheses()
1180 self.Segment().AutomaticLength(fineness)
1187 return self.Compute()
1189 ## Assigns a hypothesis
1190 # @param hyp a hypothesis to assign
1191 # @param geom a subhape of mesh geometry
1192 # @return SMESH.Hypothesis_Status
1193 # @ingroup l2_hypotheses
1194 def AddHypothesis(self, hyp, geom=0):
1195 if isinstance( hyp, Mesh_Algorithm ):
1196 hyp = hyp.GetAlgorithm()
1201 geom = self.mesh.GetShapeToMesh()
1203 status = self.mesh.AddHypothesis(geom, hyp)
1204 isAlgo = hyp._narrow( SMESH_Algo )
1205 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1208 ## Unassigns a hypothesis
1209 # @param hyp a hypothesis to unassign
1210 # @param geom a subshape of mesh geometry
1211 # @return SMESH.Hypothesis_Status
1212 # @ingroup l2_hypotheses
1213 def RemoveHypothesis(self, hyp, geom=0):
1214 if isinstance( hyp, Mesh_Algorithm ):
1215 hyp = hyp.GetAlgorithm()
1220 status = self.mesh.RemoveHypothesis(geom, hyp)
1223 ## Gets the list of hypotheses added on a geometry
1224 # @param geom a subshape of mesh geometry
1225 # @return the sequence of SMESH_Hypothesis
1226 # @ingroup l2_hypotheses
1227 def GetHypothesisList(self, geom):
1228 return self.mesh.GetHypothesisList( geom )
1230 ## Removes all global hypotheses
1231 # @ingroup l2_hypotheses
1232 def RemoveGlobalHypotheses(self):
1233 current_hyps = self.mesh.GetHypothesisList( self.geom )
1234 for hyp in current_hyps:
1235 self.mesh.RemoveHypothesis( self.geom, hyp )
1239 ## Creates a mesh group based on the geometric object \a grp
1240 # and gives a \a name, \n if this parameter is not defined
1241 # the name is the same as the geometric group name \n
1242 # Note: Works like GroupOnGeom().
1243 # @param grp a geometric group, a vertex, an edge, a face or a solid
1244 # @param name the name of the mesh group
1245 # @return SMESH_GroupOnGeom
1246 # @ingroup l2_grps_create
1247 def Group(self, grp, name=""):
1248 return self.GroupOnGeom(grp, name)
1250 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1251 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1252 # @param f the file name
1253 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1254 # @ingroup l2_impexp
1255 def ExportToMED(self, f, version, opt=0):
1256 self.mesh.ExportToMED(f, opt, version)
1258 ## Exports the mesh in a file in MED format
1259 # @param f is the file name
1260 # @param auto_groups boolean parameter for creating/not creating
1261 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1262 # the typical use is auto_groups=false.
1263 # @param version MED format version(MED_V2_1 or MED_V2_2)
1264 # @ingroup l2_impexp
1265 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1266 self.mesh.ExportToMED(f, auto_groups, version)
1268 ## Exports the mesh in a file in DAT format
1269 # @param f the file name
1270 # @ingroup l2_impexp
1271 def ExportDAT(self, f):
1272 self.mesh.ExportDAT(f)
1274 ## Exports the mesh in a file in UNV format
1275 # @param f the file name
1276 # @ingroup l2_impexp
1277 def ExportUNV(self, f):
1278 self.mesh.ExportUNV(f)
1280 ## Export the mesh in a file in STL format
1281 # @param f the file name
1282 # @param ascii defines the file encoding
1283 # @ingroup l2_impexp
1284 def ExportSTL(self, f, ascii=1):
1285 self.mesh.ExportSTL(f, ascii)
1288 # Operations with groups:
1289 # ----------------------
1291 ## Creates an empty mesh group
1292 # @param elementType the type of elements in the group
1293 # @param name the name of the mesh group
1294 # @return SMESH_Group
1295 # @ingroup l2_grps_create
1296 def CreateEmptyGroup(self, elementType, name):
1297 return self.mesh.CreateGroup(elementType, name)
1299 ## Creates a mesh group based on the geometrical object \a grp
1300 # and gives a \a name, \n if this parameter is not defined
1301 # the name is the same as the geometrical group name
1302 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1303 # @param name the name of the mesh group
1304 # @param typ the type of elements in the group. If not set, it is
1305 # automatically detected by the type of the geometry
1306 # @return SMESH_GroupOnGeom
1307 # @ingroup l2_grps_create
1308 def GroupOnGeom(self, grp, name="", typ=None):
1310 name = grp.GetName()
1313 tgeo = str(grp.GetShapeType())
1314 if tgeo == "VERTEX":
1316 elif tgeo == "EDGE":
1318 elif tgeo == "FACE":
1320 elif tgeo == "SOLID":
1322 elif tgeo == "SHELL":
1324 elif tgeo == "COMPOUND":
1325 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1326 print "Mesh.Group: empty geometric group", GetName( grp )
1328 tgeo = self.geompyD.GetType(grp)
1329 if tgeo == geompyDC.ShapeType["VERTEX"]:
1331 elif tgeo == geompyDC.ShapeType["EDGE"]:
1333 elif tgeo == geompyDC.ShapeType["FACE"]:
1335 elif tgeo == geompyDC.ShapeType["SOLID"]:
1339 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1342 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1344 ## Creates a mesh group by the given ids of elements
1345 # @param groupName the name of the mesh group
1346 # @param elementType the type of elements in the group
1347 # @param elemIDs the list of ids
1348 # @return SMESH_Group
1349 # @ingroup l2_grps_create
1350 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1351 group = self.mesh.CreateGroup(elementType, groupName)
1355 ## Creates a mesh group by the given conditions
1356 # @param groupName the name of the mesh group
1357 # @param elementType the type of elements in the group
1358 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1359 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1360 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1361 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1362 # @return SMESH_Group
1363 # @ingroup l2_grps_create
1367 CritType=FT_Undefined,
1370 UnaryOp=FT_Undefined):
1371 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1372 group = self.MakeGroupByCriterion(groupName, aCriterion)
1375 ## Creates a mesh group by the given criterion
1376 # @param groupName the name of the mesh group
1377 # @param Criterion the instance of Criterion class
1378 # @return SMESH_Group
1379 # @ingroup l2_grps_create
1380 def MakeGroupByCriterion(self, groupName, Criterion):
1381 aFilterMgr = self.smeshpyD.CreateFilterManager()
1382 aFilter = aFilterMgr.CreateFilter()
1384 aCriteria.append(Criterion)
1385 aFilter.SetCriteria(aCriteria)
1386 group = self.MakeGroupByFilter(groupName, aFilter)
1389 ## Creates a mesh group by the given criteria (list of criteria)
1390 # @param groupName the name of the mesh group
1391 # @param theCriteria the list of criteria
1392 # @return SMESH_Group
1393 # @ingroup l2_grps_create
1394 def MakeGroupByCriteria(self, groupName, theCriteria):
1395 aFilterMgr = self.smeshpyD.CreateFilterManager()
1396 aFilter = aFilterMgr.CreateFilter()
1397 aFilter.SetCriteria(theCriteria)
1398 group = self.MakeGroupByFilter(groupName, aFilter)
1401 ## Creates a mesh group by the given filter
1402 # @param groupName the name of the mesh group
1403 # @param theFilter the instance of Filter class
1404 # @return SMESH_Group
1405 # @ingroup l2_grps_create
1406 def MakeGroupByFilter(self, groupName, theFilter):
1407 anIds = theFilter.GetElementsId(self.mesh)
1408 anElemType = theFilter.GetElementType()
1409 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1412 ## Passes mesh elements through the given filter and return IDs of fitting elements
1413 # @param theFilter SMESH_Filter
1414 # @return a list of ids
1415 # @ingroup l1_controls
1416 def GetIdsFromFilter(self, theFilter):
1417 return theFilter.GetElementsId(self.mesh)
1419 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1420 # Returns a list of special structures (borders).
1421 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1422 # @ingroup l1_controls
1423 def GetFreeBorders(self):
1424 aFilterMgr = self.smeshpyD.CreateFilterManager()
1425 aPredicate = aFilterMgr.CreateFreeEdges()
1426 aPredicate.SetMesh(self.mesh)
1427 aBorders = aPredicate.GetBorders()
1431 # @ingroup l2_grps_delete
1432 def RemoveGroup(self, group):
1433 self.mesh.RemoveGroup(group)
1435 ## Removes a group with its contents
1436 # @ingroup l2_grps_delete
1437 def RemoveGroupWithContents(self, group):
1438 self.mesh.RemoveGroupWithContents(group)
1440 ## Gets the list of groups existing in the mesh
1441 # @return a sequence of SMESH_GroupBase
1442 # @ingroup l2_grps_create
1443 def GetGroups(self):
1444 return self.mesh.GetGroups()
1446 ## Gets the number of groups existing in the mesh
1447 # @return the quantity of groups as an integer value
1448 # @ingroup l2_grps_create
1450 return self.mesh.NbGroups()
1452 ## Gets the list of names of groups existing in the mesh
1453 # @return list of strings
1454 # @ingroup l2_grps_create
1455 def GetGroupNames(self):
1456 groups = self.GetGroups()
1458 for group in groups:
1459 names.append(group.GetName())
1462 ## Produces a union of two groups
1463 # A new group is created. All mesh elements that are
1464 # present in the initial groups are added to the new one
1465 # @return an instance of SMESH_Group
1466 # @ingroup l2_grps_operon
1467 def UnionGroups(self, group1, group2, name):
1468 return self.mesh.UnionGroups(group1, group2, name)
1470 ## Produces a union list of groups
1471 # New group is created. All mesh elements that are present in
1472 # initial groups are added to the new one
1473 # @return an instance of SMESH_Group
1474 # @ingroup l2_grps_operon
1475 def UnionListOfGroups(self, groups, name):
1476 return self.mesh.UnionListOfGroups(groups, name)
1478 ## Prodices an intersection of two groups
1479 # A new group is created. All mesh elements that are common
1480 # for the two initial groups are added to the new one.
1481 # @return an instance of SMESH_Group
1482 # @ingroup l2_grps_operon
1483 def IntersectGroups(self, group1, group2, name):
1484 return self.mesh.IntersectGroups(group1, group2, name)
1486 ## Produces an intersection of groups
1487 # New group is created. All mesh elements that are present in all
1488 # initial groups simultaneously are added to the new one
1489 # @return an instance of SMESH_Group
1490 # @ingroup l2_grps_operon
1491 def IntersectListOfGroups(self, groups, name):
1492 return self.mesh.IntersectListOfGroups(groups, name)
1494 ## Produces a cut of two groups
1495 # A new group is created. All mesh elements that are present in
1496 # the main group but are not present in the tool group are added to the new one
1497 # @return an instance of SMESH_Group
1498 # @ingroup l2_grps_operon
1499 def CutGroups(self, main_group, tool_group, name):
1500 return self.mesh.CutGroups(main_group, tool_group, name)
1502 ## Produces a cut of groups
1503 # A new group is created. All mesh elements that are present in main groups
1504 # but do not present in tool groups are added to the new one
1505 # @return an instance of SMESH_Group
1506 # @ingroup l2_grps_operon
1507 def CutListOfGroups(self, main_groups, tool_groups, name):
1508 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1510 ## Produces a group of elements with specified element type using list of existing groups
1511 # A new group is created. System
1512 # 1) extract all nodes on which groups elements are built
1513 # 2) combine all elements of specified dimension laying on these nodes
1514 # @return an instance of SMESH_Group
1515 # @ingroup l2_grps_operon
1516 def CreateDimGroup(self, groups, elem_type, name):
1517 return self.mesh.CreateDimGroup(groups, elem_type, name)
1520 ## Convert group on geom into standalone group
1521 # @ingroup l2_grps_delete
1522 def ConvertToStandalone(self, group):
1523 return self.mesh.ConvertToStandalone(group)
1525 # Get some info about mesh:
1526 # ------------------------
1528 ## Returns the log of nodes and elements added or removed
1529 # since the previous clear of the log.
1530 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1531 # @return list of log_block structures:
1536 # @ingroup l1_auxiliary
1537 def GetLog(self, clearAfterGet):
1538 return self.mesh.GetLog(clearAfterGet)
1540 ## Clears the log of nodes and elements added or removed since the previous
1541 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1542 # @ingroup l1_auxiliary
1544 self.mesh.ClearLog()
1546 ## Toggles auto color mode on the object.
1547 # @param theAutoColor the flag which toggles auto color mode.
1548 # @ingroup l1_auxiliary
1549 def SetAutoColor(self, theAutoColor):
1550 self.mesh.SetAutoColor(theAutoColor)
1552 ## Gets flag of object auto color mode.
1553 # @return True or False
1554 # @ingroup l1_auxiliary
1555 def GetAutoColor(self):
1556 return self.mesh.GetAutoColor()
1558 ## Gets the internal ID
1559 # @return integer value, which is the internal Id of the mesh
1560 # @ingroup l1_auxiliary
1562 return self.mesh.GetId()
1565 # @return integer value, which is the study Id of the mesh
1566 # @ingroup l1_auxiliary
1567 def GetStudyId(self):
1568 return self.mesh.GetStudyId()
1570 ## Checks the group names for duplications.
1571 # Consider the maximum group name length stored in MED file.
1572 # @return True or False
1573 # @ingroup l1_auxiliary
1574 def HasDuplicatedGroupNamesMED(self):
1575 return self.mesh.HasDuplicatedGroupNamesMED()
1577 ## Obtains the mesh editor tool
1578 # @return an instance of SMESH_MeshEditor
1579 # @ingroup l1_modifying
1580 def GetMeshEditor(self):
1581 return self.mesh.GetMeshEditor()
1584 # @return an instance of SALOME_MED::MESH
1585 # @ingroup l1_auxiliary
1586 def GetMEDMesh(self):
1587 return self.mesh.GetMEDMesh()
1590 # Get informations about mesh contents:
1591 # ------------------------------------
1593 ## Gets the mesh stattistic
1594 # @return dictionary type element - count of elements
1595 # @ingroup l1_meshinfo
1596 def GetMeshInfo(self, obj = None):
1597 if not obj: obj = self.mesh
1599 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
1600 values = obj.GetMeshInfo()
1601 for i in range(SMESH.Entity_Last._v):
1602 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
1606 ## Returns the number of nodes in the mesh
1607 # @return an integer value
1608 # @ingroup l1_meshinfo
1610 return self.mesh.NbNodes()
1612 ## Returns the number of elements in the mesh
1613 # @return an integer value
1614 # @ingroup l1_meshinfo
1615 def NbElements(self):
1616 return self.mesh.NbElements()
1618 ## Returns the number of 0d elements in the mesh
1619 # @return an integer value
1620 # @ingroup l1_meshinfo
1621 def Nb0DElements(self):
1622 return self.mesh.Nb0DElements()
1624 ## Returns the number of edges in the mesh
1625 # @return an integer value
1626 # @ingroup l1_meshinfo
1628 return self.mesh.NbEdges()
1630 ## Returns the number of edges with the given order in the mesh
1631 # @param elementOrder the order of elements:
1632 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1633 # @return an integer value
1634 # @ingroup l1_meshinfo
1635 def NbEdgesOfOrder(self, elementOrder):
1636 return self.mesh.NbEdgesOfOrder(elementOrder)
1638 ## Returns the number of faces in the mesh
1639 # @return an integer value
1640 # @ingroup l1_meshinfo
1642 return self.mesh.NbFaces()
1644 ## Returns the number of faces with the given order in the mesh
1645 # @param elementOrder the order of elements:
1646 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1647 # @return an integer value
1648 # @ingroup l1_meshinfo
1649 def NbFacesOfOrder(self, elementOrder):
1650 return self.mesh.NbFacesOfOrder(elementOrder)
1652 ## Returns the number of triangles in the mesh
1653 # @return an integer value
1654 # @ingroup l1_meshinfo
1655 def NbTriangles(self):
1656 return self.mesh.NbTriangles()
1658 ## Returns the number of triangles with the given order in the mesh
1659 # @param elementOrder is the order of elements:
1660 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1661 # @return an integer value
1662 # @ingroup l1_meshinfo
1663 def NbTrianglesOfOrder(self, elementOrder):
1664 return self.mesh.NbTrianglesOfOrder(elementOrder)
1666 ## Returns the number of quadrangles in the mesh
1667 # @return an integer value
1668 # @ingroup l1_meshinfo
1669 def NbQuadrangles(self):
1670 return self.mesh.NbQuadrangles()
1672 ## Returns the number of quadrangles with the given order in the mesh
1673 # @param elementOrder the order of elements:
1674 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1675 # @return an integer value
1676 # @ingroup l1_meshinfo
1677 def NbQuadranglesOfOrder(self, elementOrder):
1678 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1680 ## Returns the number of polygons in the mesh
1681 # @return an integer value
1682 # @ingroup l1_meshinfo
1683 def NbPolygons(self):
1684 return self.mesh.NbPolygons()
1686 ## Returns the number of volumes in the mesh
1687 # @return an integer value
1688 # @ingroup l1_meshinfo
1689 def NbVolumes(self):
1690 return self.mesh.NbVolumes()
1692 ## Returns the number of volumes with the given order in the mesh
1693 # @param elementOrder the order of elements:
1694 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1695 # @return an integer value
1696 # @ingroup l1_meshinfo
1697 def NbVolumesOfOrder(self, elementOrder):
1698 return self.mesh.NbVolumesOfOrder(elementOrder)
1700 ## Returns the number of tetrahedrons in the mesh
1701 # @return an integer value
1702 # @ingroup l1_meshinfo
1704 return self.mesh.NbTetras()
1706 ## Returns the number of tetrahedrons with the given order in the mesh
1707 # @param elementOrder the order of elements:
1708 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1709 # @return an integer value
1710 # @ingroup l1_meshinfo
1711 def NbTetrasOfOrder(self, elementOrder):
1712 return self.mesh.NbTetrasOfOrder(elementOrder)
1714 ## Returns the number of hexahedrons in the mesh
1715 # @return an integer value
1716 # @ingroup l1_meshinfo
1718 return self.mesh.NbHexas()
1720 ## Returns the number of hexahedrons with the given order in the mesh
1721 # @param elementOrder the order of elements:
1722 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1723 # @return an integer value
1724 # @ingroup l1_meshinfo
1725 def NbHexasOfOrder(self, elementOrder):
1726 return self.mesh.NbHexasOfOrder(elementOrder)
1728 ## Returns the number of pyramids in the mesh
1729 # @return an integer value
1730 # @ingroup l1_meshinfo
1731 def NbPyramids(self):
1732 return self.mesh.NbPyramids()
1734 ## Returns the number of pyramids with the given order in the mesh
1735 # @param elementOrder the order of elements:
1736 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1737 # @return an integer value
1738 # @ingroup l1_meshinfo
1739 def NbPyramidsOfOrder(self, elementOrder):
1740 return self.mesh.NbPyramidsOfOrder(elementOrder)
1742 ## Returns the number of prisms in the mesh
1743 # @return an integer value
1744 # @ingroup l1_meshinfo
1746 return self.mesh.NbPrisms()
1748 ## Returns the number of prisms with the given order in the mesh
1749 # @param elementOrder the order of elements:
1750 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1751 # @return an integer value
1752 # @ingroup l1_meshinfo
1753 def NbPrismsOfOrder(self, elementOrder):
1754 return self.mesh.NbPrismsOfOrder(elementOrder)
1756 ## Returns the number of polyhedrons in the mesh
1757 # @return an integer value
1758 # @ingroup l1_meshinfo
1759 def NbPolyhedrons(self):
1760 return self.mesh.NbPolyhedrons()
1762 ## Returns the number of submeshes in the mesh
1763 # @return an integer value
1764 # @ingroup l1_meshinfo
1765 def NbSubMesh(self):
1766 return self.mesh.NbSubMesh()
1768 ## Returns the list of mesh elements IDs
1769 # @return the list of integer values
1770 # @ingroup l1_meshinfo
1771 def GetElementsId(self):
1772 return self.mesh.GetElementsId()
1774 ## Returns the list of IDs of mesh elements with the given type
1775 # @param elementType the required type of elements
1776 # @return list of integer values
1777 # @ingroup l1_meshinfo
1778 def GetElementsByType(self, elementType):
1779 return self.mesh.GetElementsByType(elementType)
1781 ## Returns the list of mesh nodes IDs
1782 # @return the list of integer values
1783 # @ingroup l1_meshinfo
1784 def GetNodesId(self):
1785 return self.mesh.GetNodesId()
1787 # Get the information about mesh elements:
1788 # ------------------------------------
1790 ## Returns the type of mesh element
1791 # @return the value from SMESH::ElementType enumeration
1792 # @ingroup l1_meshinfo
1793 def GetElementType(self, id, iselem):
1794 return self.mesh.GetElementType(id, iselem)
1796 ## Returns the list of submesh elements IDs
1797 # @param Shape a geom object(subshape) IOR
1798 # Shape must be the subshape of a ShapeToMesh()
1799 # @return the list of integer values
1800 # @ingroup l1_meshinfo
1801 def GetSubMeshElementsId(self, Shape):
1802 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1803 ShapeID = Shape.GetSubShapeIndices()[0]
1806 return self.mesh.GetSubMeshElementsId(ShapeID)
1808 ## Returns the list of submesh nodes IDs
1809 # @param Shape a geom object(subshape) IOR
1810 # Shape must be the subshape of a ShapeToMesh()
1811 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1812 # @return the list of integer values
1813 # @ingroup l1_meshinfo
1814 def GetSubMeshNodesId(self, Shape, all):
1815 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1816 ShapeID = Shape.GetSubShapeIndices()[0]
1819 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1821 ## Returns type of elements on given shape
1822 # @param Shape a geom object(subshape) IOR
1823 # Shape must be a subshape of a ShapeToMesh()
1824 # @return element type
1825 # @ingroup l1_meshinfo
1826 def GetSubMeshElementType(self, Shape):
1827 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1828 ShapeID = Shape.GetSubShapeIndices()[0]
1831 return self.mesh.GetSubMeshElementType(ShapeID)
1833 ## Gets the mesh description
1834 # @return string value
1835 # @ingroup l1_meshinfo
1837 return self.mesh.Dump()
1840 # Get the information about nodes and elements of a mesh by its IDs:
1841 # -----------------------------------------------------------
1843 ## Gets XYZ coordinates of a node
1844 # \n If there is no nodes for the given ID - returns an empty list
1845 # @return a list of double precision values
1846 # @ingroup l1_meshinfo
1847 def GetNodeXYZ(self, id):
1848 return self.mesh.GetNodeXYZ(id)
1850 ## Returns list of IDs of inverse elements for the given node
1851 # \n If there is no node for the given ID - returns an empty list
1852 # @return a list of integer values
1853 # @ingroup l1_meshinfo
1854 def GetNodeInverseElements(self, id):
1855 return self.mesh.GetNodeInverseElements(id)
1857 ## @brief Returns the position of a node on the shape
1858 # @return SMESH::NodePosition
1859 # @ingroup l1_meshinfo
1860 def GetNodePosition(self,NodeID):
1861 return self.mesh.GetNodePosition(NodeID)
1863 ## If the given element is a node, returns the ID of shape
1864 # \n If there is no node for the given ID - returns -1
1865 # @return an integer value
1866 # @ingroup l1_meshinfo
1867 def GetShapeID(self, id):
1868 return self.mesh.GetShapeID(id)
1870 ## Returns the ID of the result shape after
1871 # FindShape() from SMESH_MeshEditor for the given element
1872 # \n If there is no element for the given ID - returns -1
1873 # @return an integer value
1874 # @ingroup l1_meshinfo
1875 def GetShapeIDForElem(self,id):
1876 return self.mesh.GetShapeIDForElem(id)
1878 ## Returns the number of nodes for the given element
1879 # \n If there is no element for the given ID - returns -1
1880 # @return an integer value
1881 # @ingroup l1_meshinfo
1882 def GetElemNbNodes(self, id):
1883 return self.mesh.GetElemNbNodes(id)
1885 ## Returns the node ID the given index for the given element
1886 # \n If there is no element for the given ID - returns -1
1887 # \n If there is no node for the given index - returns -2
1888 # @return an integer value
1889 # @ingroup l1_meshinfo
1890 def GetElemNode(self, id, index):
1891 return self.mesh.GetElemNode(id, index)
1893 ## Returns the IDs of nodes of the given element
1894 # @return a list of integer values
1895 # @ingroup l1_meshinfo
1896 def GetElemNodes(self, id):
1897 return self.mesh.GetElemNodes(id)
1899 ## Returns true if the given node is the medium node in the given quadratic element
1900 # @ingroup l1_meshinfo
1901 def IsMediumNode(self, elementID, nodeID):
1902 return self.mesh.IsMediumNode(elementID, nodeID)
1904 ## Returns true if the given node is the medium node in one of quadratic elements
1905 # @ingroup l1_meshinfo
1906 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1907 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1909 ## Returns the number of edges for the given element
1910 # @ingroup l1_meshinfo
1911 def ElemNbEdges(self, id):
1912 return self.mesh.ElemNbEdges(id)
1914 ## Returns the number of faces for the given element
1915 # @ingroup l1_meshinfo
1916 def ElemNbFaces(self, id):
1917 return self.mesh.ElemNbFaces(id)
1919 ## Returns true if the given element is a polygon
1920 # @ingroup l1_meshinfo
1921 def IsPoly(self, id):
1922 return self.mesh.IsPoly(id)
1924 ## Returns true if the given element is quadratic
1925 # @ingroup l1_meshinfo
1926 def IsQuadratic(self, id):
1927 return self.mesh.IsQuadratic(id)
1929 ## Returns XYZ coordinates of the barycenter of the given element
1930 # \n If there is no element for the given ID - returns an empty list
1931 # @return a list of three double values
1932 # @ingroup l1_meshinfo
1933 def BaryCenter(self, id):
1934 return self.mesh.BaryCenter(id)
1937 # Mesh edition (SMESH_MeshEditor functionality):
1938 # ---------------------------------------------
1940 ## Removes the elements from the mesh by ids
1941 # @param IDsOfElements is a list of ids of elements to remove
1942 # @return True or False
1943 # @ingroup l2_modif_del
1944 def RemoveElements(self, IDsOfElements):
1945 return self.editor.RemoveElements(IDsOfElements)
1947 ## Removes nodes from mesh by ids
1948 # @param IDsOfNodes is a list of ids of nodes to remove
1949 # @return True or False
1950 # @ingroup l2_modif_del
1951 def RemoveNodes(self, IDsOfNodes):
1952 return self.editor.RemoveNodes(IDsOfNodes)
1954 ## Add a node to the mesh by coordinates
1955 # @return Id of the new node
1956 # @ingroup l2_modif_add
1957 def AddNode(self, x, y, z):
1958 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
1959 self.mesh.SetParameters(Parameters)
1960 return self.editor.AddNode( x, y, z)
1962 ## Creates a 0D element on a node with given number.
1963 # @param IDOfNode the ID of node for creation of the element.
1964 # @return the Id of the new 0D element
1965 # @ingroup l2_modif_add
1966 def Add0DElement(self, IDOfNode):
1967 return self.editor.Add0DElement(IDOfNode)
1969 ## Creates a linear or quadratic edge (this is determined
1970 # by the number of given nodes).
1971 # @param IDsOfNodes the list of node IDs for creation of the element.
1972 # The order of nodes in this list should correspond to the description
1973 # of MED. \n This description is located by the following link:
1974 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1975 # @return the Id of the new edge
1976 # @ingroup l2_modif_add
1977 def AddEdge(self, IDsOfNodes):
1978 return self.editor.AddEdge(IDsOfNodes)
1980 ## Creates a linear or quadratic face (this is determined
1981 # by the number of given nodes).
1982 # @param IDsOfNodes the list of node IDs for creation of the element.
1983 # The order of nodes in this list should correspond to the description
1984 # of MED. \n This description is located by the following link:
1985 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1986 # @return the Id of the new face
1987 # @ingroup l2_modif_add
1988 def AddFace(self, IDsOfNodes):
1989 return self.editor.AddFace(IDsOfNodes)
1991 ## Adds a polygonal face to the mesh by the list of node IDs
1992 # @param IdsOfNodes the list of node IDs for creation of the element.
1993 # @return the Id of the new face
1994 # @ingroup l2_modif_add
1995 def AddPolygonalFace(self, IdsOfNodes):
1996 return self.editor.AddPolygonalFace(IdsOfNodes)
1998 ## Creates both simple and quadratic volume (this is determined
1999 # by the number of given nodes).
2000 # @param IDsOfNodes the list of node IDs for creation of the element.
2001 # The order of nodes in this list should correspond to the description
2002 # of MED. \n This description is located by the following link:
2003 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
2004 # @return the Id of the new volumic element
2005 # @ingroup l2_modif_add
2006 def AddVolume(self, IDsOfNodes):
2007 return self.editor.AddVolume(IDsOfNodes)
2009 ## Creates a volume of many faces, giving nodes for each face.
2010 # @param IdsOfNodes the list of node IDs for volume creation face by face.
2011 # @param Quantities the list of integer values, Quantities[i]
2012 # gives the quantity of nodes in face number i.
2013 # @return the Id of the new volumic element
2014 # @ingroup l2_modif_add
2015 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
2016 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
2018 ## Creates a volume of many faces, giving the IDs of the existing faces.
2019 # @param IdsOfFaces the list of face IDs for volume creation.
2021 # Note: The created volume will refer only to the nodes
2022 # of the given faces, not to the faces themselves.
2023 # @return the Id of the new volumic element
2024 # @ingroup l2_modif_add
2025 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
2026 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
2029 ## @brief Binds a node to a vertex
2030 # @param NodeID a node ID
2031 # @param Vertex a vertex or vertex ID
2032 # @return True if succeed else raises an exception
2033 # @ingroup l2_modif_add
2034 def SetNodeOnVertex(self, NodeID, Vertex):
2035 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
2036 VertexID = Vertex.GetSubShapeIndices()[0]
2040 self.editor.SetNodeOnVertex(NodeID, VertexID)
2041 except SALOME.SALOME_Exception, inst:
2042 raise ValueError, inst.details.text
2046 ## @brief Stores the node position on an edge
2047 # @param NodeID a node ID
2048 # @param Edge an edge or edge ID
2049 # @param paramOnEdge a parameter on the edge where the node is located
2050 # @return True if succeed else raises an exception
2051 # @ingroup l2_modif_add
2052 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
2053 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
2054 EdgeID = Edge.GetSubShapeIndices()[0]
2058 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
2059 except SALOME.SALOME_Exception, inst:
2060 raise ValueError, inst.details.text
2063 ## @brief Stores node position on a face
2064 # @param NodeID a node ID
2065 # @param Face a face or face ID
2066 # @param u U parameter on the face where the node is located
2067 # @param v V parameter on the face where the node is located
2068 # @return True if succeed else raises an exception
2069 # @ingroup l2_modif_add
2070 def SetNodeOnFace(self, NodeID, Face, u, v):
2071 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
2072 FaceID = Face.GetSubShapeIndices()[0]
2076 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
2077 except SALOME.SALOME_Exception, inst:
2078 raise ValueError, inst.details.text
2081 ## @brief Binds a node to a solid
2082 # @param NodeID a node ID
2083 # @param Solid a solid or solid ID
2084 # @return True if succeed else raises an exception
2085 # @ingroup l2_modif_add
2086 def SetNodeInVolume(self, NodeID, Solid):
2087 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
2088 SolidID = Solid.GetSubShapeIndices()[0]
2092 self.editor.SetNodeInVolume(NodeID, SolidID)
2093 except SALOME.SALOME_Exception, inst:
2094 raise ValueError, inst.details.text
2097 ## @brief Bind an element to a shape
2098 # @param ElementID an element ID
2099 # @param Shape a shape or shape ID
2100 # @return True if succeed else raises an exception
2101 # @ingroup l2_modif_add
2102 def SetMeshElementOnShape(self, ElementID, Shape):
2103 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
2104 ShapeID = Shape.GetSubShapeIndices()[0]
2108 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
2109 except SALOME.SALOME_Exception, inst:
2110 raise ValueError, inst.details.text
2114 ## Moves the node with the given id
2115 # @param NodeID the id of the node
2116 # @param x a new X coordinate
2117 # @param y a new Y coordinate
2118 # @param z a new Z coordinate
2119 # @return True if succeed else False
2120 # @ingroup l2_modif_movenode
2121 def MoveNode(self, NodeID, x, y, z):
2122 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2123 self.mesh.SetParameters(Parameters)
2124 return self.editor.MoveNode(NodeID, x, y, z)
2126 ## Finds the node closest to a point and moves it to a point location
2127 # @param x the X coordinate of a point
2128 # @param y the Y coordinate of a point
2129 # @param z the Z coordinate of a point
2130 # @return the ID of a node
2131 # @ingroup l2_modif_throughp
2132 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
2133 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
2134 self.mesh.SetParameters(Parameters)
2135 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
2137 ## Finds the node closest to a point
2138 # @param x the X coordinate of a point
2139 # @param y the Y coordinate of a point
2140 # @param z the Z coordinate of a point
2141 # @return the ID of a node
2142 # @ingroup l2_modif_throughp
2143 def FindNodeClosestTo(self, x, y, z):
2144 #preview = self.mesh.GetMeshEditPreviewer()
2145 #return preview.MoveClosestNodeToPoint(x, y, z, -1)
2146 return self.editor.FindNodeClosestTo(x, y, z)
2148 ## Finds the elements where a point lays IN or ON
2149 # @param x the X coordinate of a point
2150 # @param y the Y coordinate of a point
2151 # @param z the Z coordinate of a point
2152 # @param elementType type of elements to find (SMESH.ALL type
2153 # means elements of any type excluding nodes and 0D elements)
2154 # @return list of IDs of found elements
2155 # @ingroup l2_modif_throughp
2156 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
2157 return self.editor.FindElementsByPoint(x, y, z, elementType)
2160 ## Finds the node closest to a point and moves it to a point location
2161 # @param x the X coordinate of a point
2162 # @param y the Y coordinate of a point
2163 # @param z the Z coordinate of a point
2164 # @return the ID of a moved node
2165 # @ingroup l2_modif_throughp
2166 def MeshToPassThroughAPoint(self, x, y, z):
2167 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
2169 ## Replaces two neighbour triangles sharing Node1-Node2 link
2170 # with the triangles built on the same 4 nodes but having other common link.
2171 # @param NodeID1 the ID of the first node
2172 # @param NodeID2 the ID of the second node
2173 # @return false if proper faces were not found
2174 # @ingroup l2_modif_invdiag
2175 def InverseDiag(self, NodeID1, NodeID2):
2176 return self.editor.InverseDiag(NodeID1, NodeID2)
2178 ## Replaces two neighbour triangles sharing Node1-Node2 link
2179 # with a quadrangle built on the same 4 nodes.
2180 # @param NodeID1 the ID of the first node
2181 # @param NodeID2 the ID of the second node
2182 # @return false if proper faces were not found
2183 # @ingroup l2_modif_unitetri
2184 def DeleteDiag(self, NodeID1, NodeID2):
2185 return self.editor.DeleteDiag(NodeID1, NodeID2)
2187 ## Reorients elements by ids
2188 # @param IDsOfElements if undefined reorients all mesh elements
2189 # @return True if succeed else False
2190 # @ingroup l2_modif_changori
2191 def Reorient(self, IDsOfElements=None):
2192 if IDsOfElements == None:
2193 IDsOfElements = self.GetElementsId()
2194 return self.editor.Reorient(IDsOfElements)
2196 ## Reorients all elements of the object
2197 # @param theObject mesh, submesh or group
2198 # @return True if succeed else False
2199 # @ingroup l2_modif_changori
2200 def ReorientObject(self, theObject):
2201 if ( isinstance( theObject, Mesh )):
2202 theObject = theObject.GetMesh()
2203 return self.editor.ReorientObject(theObject)
2205 ## Fuses the neighbouring triangles into quadrangles.
2206 # @param IDsOfElements The triangles to be fused,
2207 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2208 # @param MaxAngle is the maximum angle between element normals at which the fusion
2209 # is still performed; theMaxAngle is mesured in radians.
2210 # Also it could be a name of variable which defines angle in degrees.
2211 # @return TRUE in case of success, FALSE otherwise.
2212 # @ingroup l2_modif_unitetri
2213 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
2215 if isinstance(MaxAngle,str):
2217 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
2219 MaxAngle = DegreesToRadians(MaxAngle)
2220 if IDsOfElements == []:
2221 IDsOfElements = self.GetElementsId()
2222 self.mesh.SetParameters(Parameters)
2224 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
2225 Functor = theCriterion
2227 Functor = self.smeshpyD.GetFunctor(theCriterion)
2228 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
2230 ## Fuses the neighbouring triangles of the object into quadrangles
2231 # @param theObject is mesh, submesh or group
2232 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
2233 # @param MaxAngle a max angle between element normals at which the fusion
2234 # is still performed; theMaxAngle is mesured in radians.
2235 # @return TRUE in case of success, FALSE otherwise.
2236 # @ingroup l2_modif_unitetri
2237 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
2238 if ( isinstance( theObject, Mesh )):
2239 theObject = theObject.GetMesh()
2240 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
2242 ## Splits quadrangles into triangles.
2243 # @param IDsOfElements the faces to be splitted.
2244 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2245 # @return TRUE in case of success, FALSE otherwise.
2246 # @ingroup l2_modif_cutquadr
2247 def QuadToTri (self, IDsOfElements, theCriterion):
2248 if IDsOfElements == []:
2249 IDsOfElements = self.GetElementsId()
2250 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
2252 ## Splits quadrangles into triangles.
2253 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2254 # @param theCriterion FT_...; used to choose a diagonal for splitting.
2255 # @return TRUE in case of success, FALSE otherwise.
2256 # @ingroup l2_modif_cutquadr
2257 def QuadToTriObject (self, theObject, theCriterion):
2258 if ( isinstance( theObject, Mesh )):
2259 theObject = theObject.GetMesh()
2260 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
2262 ## Splits quadrangles into triangles.
2263 # @param IDsOfElements the faces to be splitted
2264 # @param Diag13 is used to choose a diagonal for splitting.
2265 # @return TRUE in case of success, FALSE otherwise.
2266 # @ingroup l2_modif_cutquadr
2267 def SplitQuad (self, IDsOfElements, Diag13):
2268 if IDsOfElements == []:
2269 IDsOfElements = self.GetElementsId()
2270 return self.editor.SplitQuad(IDsOfElements, Diag13)
2272 ## Splits quadrangles into triangles.
2273 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2274 # @param Diag13 is used to choose a diagonal for splitting.
2275 # @return TRUE in case of success, FALSE otherwise.
2276 # @ingroup l2_modif_cutquadr
2277 def SplitQuadObject (self, theObject, Diag13):
2278 if ( isinstance( theObject, Mesh )):
2279 theObject = theObject.GetMesh()
2280 return self.editor.SplitQuadObject(theObject, Diag13)
2282 ## Finds a better splitting of the given quadrangle.
2283 # @param IDOfQuad the ID of the quadrangle to be splitted.
2284 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2285 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2286 # diagonal is better, 0 if error occurs.
2287 # @ingroup l2_modif_cutquadr
2288 def BestSplit (self, IDOfQuad, theCriterion):
2289 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2291 ## Splits quadrangle faces near triangular facets of volumes
2293 # @ingroup l1_auxiliary
2294 def SplitQuadsNearTriangularFacets(self):
2295 faces_array = self.GetElementsByType(SMESH.FACE)
2296 for face_id in faces_array:
2297 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2298 quad_nodes = self.mesh.GetElemNodes(face_id)
2299 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2300 isVolumeFound = False
2301 for node1_elem in node1_elems:
2302 if not isVolumeFound:
2303 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2304 nb_nodes = self.GetElemNbNodes(node1_elem)
2305 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2306 volume_elem = node1_elem
2307 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2308 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2309 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2310 isVolumeFound = True
2311 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2312 self.SplitQuad([face_id], False) # diagonal 2-4
2313 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2314 isVolumeFound = True
2315 self.SplitQuad([face_id], True) # diagonal 1-3
2316 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2317 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2318 isVolumeFound = True
2319 self.SplitQuad([face_id], True) # diagonal 1-3
2321 ## @brief Splits hexahedrons into tetrahedrons.
2323 # This operation uses pattern mapping functionality for splitting.
2324 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2325 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2326 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2327 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2328 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2329 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2330 # @return TRUE in case of success, FALSE otherwise.
2331 # @ingroup l1_auxiliary
2332 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2333 # Pattern: 5.---------.6
2338 # (0,0,1) 4.---------.7 * |
2345 # (0,0,0) 0.---------.3
2346 pattern_tetra = "!!! Nb of points: \n 8 \n\
2356 !!! Indices of points of 6 tetras: \n\
2364 pattern = self.smeshpyD.GetPattern()
2365 isDone = pattern.LoadFromFile(pattern_tetra)
2367 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2370 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2371 isDone = pattern.MakeMesh(self.mesh, False, False)
2372 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2374 # split quafrangle faces near triangular facets of volumes
2375 self.SplitQuadsNearTriangularFacets()
2379 ## @brief Split hexahedrons into prisms.
2381 # Uses the pattern mapping functionality for splitting.
2382 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2383 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2384 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2385 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2386 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2387 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2388 # @return TRUE in case of success, FALSE otherwise.
2389 # @ingroup l1_auxiliary
2390 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2391 # Pattern: 5.---------.6
2396 # (0,0,1) 4.---------.7 |
2403 # (0,0,0) 0.---------.3
2404 pattern_prism = "!!! Nb of points: \n 8 \n\
2414 !!! Indices of points of 2 prisms: \n\
2418 pattern = self.smeshpyD.GetPattern()
2419 isDone = pattern.LoadFromFile(pattern_prism)
2421 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2424 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2425 isDone = pattern.MakeMesh(self.mesh, False, False)
2426 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2428 # Splits quafrangle faces near triangular facets of volumes
2429 self.SplitQuadsNearTriangularFacets()
2433 ## Smoothes elements
2434 # @param IDsOfElements the list if ids of elements to smooth
2435 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2436 # Note that nodes built on edges and boundary nodes are always fixed.
2437 # @param MaxNbOfIterations the maximum number of iterations
2438 # @param MaxAspectRatio varies in range [1.0, inf]
2439 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2440 # @return TRUE in case of success, FALSE otherwise.
2441 # @ingroup l2_modif_smooth
2442 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2443 MaxNbOfIterations, MaxAspectRatio, Method):
2444 if IDsOfElements == []:
2445 IDsOfElements = self.GetElementsId()
2446 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2447 self.mesh.SetParameters(Parameters)
2448 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2449 MaxNbOfIterations, MaxAspectRatio, Method)
2451 ## Smoothes elements which belong to the given object
2452 # @param theObject the object to smooth
2453 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2454 # Note that nodes built on edges and boundary nodes are always fixed.
2455 # @param MaxNbOfIterations the maximum number of iterations
2456 # @param MaxAspectRatio varies in range [1.0, inf]
2457 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2458 # @return TRUE in case of success, FALSE otherwise.
2459 # @ingroup l2_modif_smooth
2460 def SmoothObject(self, theObject, IDsOfFixedNodes,
2461 MaxNbOfIterations, MaxAspectRatio, Method):
2462 if ( isinstance( theObject, Mesh )):
2463 theObject = theObject.GetMesh()
2464 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2465 MaxNbOfIterations, MaxAspectRatio, Method)
2467 ## Parametrically smoothes the given elements
2468 # @param IDsOfElements the list if ids of elements to smooth
2469 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2470 # Note that nodes built on edges and boundary nodes are always fixed.
2471 # @param MaxNbOfIterations the maximum number of iterations
2472 # @param MaxAspectRatio varies in range [1.0, inf]
2473 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2474 # @return TRUE in case of success, FALSE otherwise.
2475 # @ingroup l2_modif_smooth
2476 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2477 MaxNbOfIterations, MaxAspectRatio, Method):
2478 if IDsOfElements == []:
2479 IDsOfElements = self.GetElementsId()
2480 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
2481 self.mesh.SetParameters(Parameters)
2482 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2483 MaxNbOfIterations, MaxAspectRatio, Method)
2485 ## Parametrically smoothes the elements which belong to the given object
2486 # @param theObject the object to smooth
2487 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2488 # Note that nodes built on edges and boundary nodes are always fixed.
2489 # @param MaxNbOfIterations the maximum number of iterations
2490 # @param MaxAspectRatio varies in range [1.0, inf]
2491 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2492 # @return TRUE in case of success, FALSE otherwise.
2493 # @ingroup l2_modif_smooth
2494 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2495 MaxNbOfIterations, MaxAspectRatio, Method):
2496 if ( isinstance( theObject, Mesh )):
2497 theObject = theObject.GetMesh()
2498 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2499 MaxNbOfIterations, MaxAspectRatio, Method)
2501 ## Converts the mesh to quadratic, deletes old elements, replacing
2502 # them with quadratic with the same id.
2503 # @ingroup l2_modif_tofromqu
2504 def ConvertToQuadratic(self, theForce3d):
2505 self.editor.ConvertToQuadratic(theForce3d)
2507 ## Converts the mesh from quadratic to ordinary,
2508 # deletes old quadratic elements, \n replacing
2509 # them with ordinary mesh elements with the same id.
2510 # @return TRUE in case of success, FALSE otherwise.
2511 # @ingroup l2_modif_tofromqu
2512 def ConvertFromQuadratic(self):
2513 return self.editor.ConvertFromQuadratic()
2515 ## Renumber mesh nodes
2516 # @ingroup l2_modif_renumber
2517 def RenumberNodes(self):
2518 self.editor.RenumberNodes()
2520 ## Renumber mesh elements
2521 # @ingroup l2_modif_renumber
2522 def RenumberElements(self):
2523 self.editor.RenumberElements()
2525 ## Generates new elements by rotation of the elements around the axis
2526 # @param IDsOfElements the list of ids of elements to sweep
2527 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2528 # @param AngleInRadians the angle of Rotation (in radians) or a name of variable which defines angle in degrees
2529 # @param NbOfSteps the number of steps
2530 # @param Tolerance tolerance
2531 # @param MakeGroups forces the generation of new groups from existing ones
2532 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2533 # of all steps, else - size of each step
2534 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2535 # @ingroup l2_modif_extrurev
2536 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2537 MakeGroups=False, TotalAngle=False):
2539 if isinstance(AngleInRadians,str):
2541 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2543 AngleInRadians = DegreesToRadians(AngleInRadians)
2544 if IDsOfElements == []:
2545 IDsOfElements = self.GetElementsId()
2546 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2547 Axis = self.smeshpyD.GetAxisStruct(Axis)
2548 Axis,AxisParameters = ParseAxisStruct(Axis)
2549 if TotalAngle and NbOfSteps:
2550 AngleInRadians /= NbOfSteps
2551 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2552 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2553 self.mesh.SetParameters(Parameters)
2555 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2556 AngleInRadians, NbOfSteps, Tolerance)
2557 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2560 ## Generates new elements by rotation of the elements of object around the axis
2561 # @param theObject object which elements should be sweeped
2562 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2563 # @param AngleInRadians the angle of Rotation
2564 # @param NbOfSteps number of steps
2565 # @param Tolerance tolerance
2566 # @param MakeGroups forces the generation of new groups from existing ones
2567 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2568 # of all steps, else - size of each step
2569 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2570 # @ingroup l2_modif_extrurev
2571 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2572 MakeGroups=False, TotalAngle=False):
2574 if isinstance(AngleInRadians,str):
2576 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2578 AngleInRadians = DegreesToRadians(AngleInRadians)
2579 if ( isinstance( theObject, Mesh )):
2580 theObject = theObject.GetMesh()
2581 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2582 Axis = self.smeshpyD.GetAxisStruct(Axis)
2583 Axis,AxisParameters = ParseAxisStruct(Axis)
2584 if TotalAngle and NbOfSteps:
2585 AngleInRadians /= NbOfSteps
2586 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2587 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2588 self.mesh.SetParameters(Parameters)
2590 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2591 NbOfSteps, Tolerance)
2592 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2595 ## Generates new elements by rotation of the elements of object around the axis
2596 # @param theObject object which elements should be sweeped
2597 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2598 # @param AngleInRadians the angle of Rotation
2599 # @param NbOfSteps number of steps
2600 # @param Tolerance tolerance
2601 # @param MakeGroups forces the generation of new groups from existing ones
2602 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2603 # of all steps, else - size of each step
2604 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2605 # @ingroup l2_modif_extrurev
2606 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2607 MakeGroups=False, TotalAngle=False):
2609 if isinstance(AngleInRadians,str):
2611 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2613 AngleInRadians = DegreesToRadians(AngleInRadians)
2614 if ( isinstance( theObject, Mesh )):
2615 theObject = theObject.GetMesh()
2616 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2617 Axis = self.smeshpyD.GetAxisStruct(Axis)
2618 Axis,AxisParameters = ParseAxisStruct(Axis)
2619 if TotalAngle and NbOfSteps:
2620 AngleInRadians /= NbOfSteps
2621 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2622 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2623 self.mesh.SetParameters(Parameters)
2625 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
2626 NbOfSteps, Tolerance)
2627 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2630 ## Generates new elements by rotation of the elements of object around the axis
2631 # @param theObject object which elements should be sweeped
2632 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2633 # @param AngleInRadians the angle of Rotation
2634 # @param NbOfSteps number of steps
2635 # @param Tolerance tolerance
2636 # @param MakeGroups forces the generation of new groups from existing ones
2637 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2638 # of all steps, else - size of each step
2639 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2640 # @ingroup l2_modif_extrurev
2641 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2642 MakeGroups=False, TotalAngle=False):
2644 if isinstance(AngleInRadians,str):
2646 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
2648 AngleInRadians = DegreesToRadians(AngleInRadians)
2649 if ( isinstance( theObject, Mesh )):
2650 theObject = theObject.GetMesh()
2651 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2652 Axis = self.smeshpyD.GetAxisStruct(Axis)
2653 Axis,AxisParameters = ParseAxisStruct(Axis)
2654 if TotalAngle and NbOfSteps:
2655 AngleInRadians /= NbOfSteps
2656 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
2657 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
2658 self.mesh.SetParameters(Parameters)
2660 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
2661 NbOfSteps, Tolerance)
2662 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2665 ## Generates new elements by extrusion of the elements with given ids
2666 # @param IDsOfElements the list of elements ids for extrusion
2667 # @param StepVector vector, defining the direction and value of extrusion
2668 # @param NbOfSteps the number of steps
2669 # @param MakeGroups forces the generation of new groups from existing ones
2670 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2671 # @ingroup l2_modif_extrurev
2672 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2673 if IDsOfElements == []:
2674 IDsOfElements = self.GetElementsId()
2675 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2676 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2677 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2678 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2679 Parameters = StepVectorParameters + var_separator + Parameters
2680 self.mesh.SetParameters(Parameters)
2682 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2683 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2686 ## Generates new elements by extrusion of the elements with given ids
2687 # @param IDsOfElements is ids of elements
2688 # @param StepVector vector, defining the direction and value of extrusion
2689 # @param NbOfSteps the number of steps
2690 # @param ExtrFlags sets flags for extrusion
2691 # @param SewTolerance uses for comparing locations of nodes if flag
2692 # EXTRUSION_FLAG_SEW is set
2693 # @param MakeGroups forces the generation of new groups from existing ones
2694 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2695 # @ingroup l2_modif_extrurev
2696 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2697 ExtrFlags, SewTolerance, MakeGroups=False):
2698 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2699 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2701 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2702 ExtrFlags, SewTolerance)
2703 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2704 ExtrFlags, SewTolerance)
2707 ## Generates new elements by extrusion of the elements which belong to the object
2708 # @param theObject the object which elements should be processed
2709 # @param StepVector vector, defining the direction and value of extrusion
2710 # @param NbOfSteps the number of steps
2711 # @param MakeGroups forces the generation of new groups from existing ones
2712 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2713 # @ingroup l2_modif_extrurev
2714 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2715 if ( isinstance( theObject, Mesh )):
2716 theObject = theObject.GetMesh()
2717 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2718 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2719 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2720 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2721 Parameters = StepVectorParameters + var_separator + Parameters
2722 self.mesh.SetParameters(Parameters)
2724 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2725 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2728 ## Generates new elements by extrusion of the elements which belong to the object
2729 # @param theObject object which elements should be processed
2730 # @param StepVector vector, defining the direction and value of extrusion
2731 # @param NbOfSteps the number of steps
2732 # @param MakeGroups to generate new groups from existing ones
2733 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2734 # @ingroup l2_modif_extrurev
2735 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2736 if ( isinstance( theObject, Mesh )):
2737 theObject = theObject.GetMesh()
2738 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2739 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2740 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2741 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2742 Parameters = StepVectorParameters + var_separator + Parameters
2743 self.mesh.SetParameters(Parameters)
2745 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2746 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2749 ## Generates new elements by extrusion of the elements which belong to the object
2750 # @param theObject object which elements should be processed
2751 # @param StepVector vector, defining the direction and value of extrusion
2752 # @param NbOfSteps the number of steps
2753 # @param MakeGroups forces the generation of new groups from existing ones
2754 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2755 # @ingroup l2_modif_extrurev
2756 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2757 if ( isinstance( theObject, Mesh )):
2758 theObject = theObject.GetMesh()
2759 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2760 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2761 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
2762 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
2763 Parameters = StepVectorParameters + var_separator + Parameters
2764 self.mesh.SetParameters(Parameters)
2766 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2767 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2772 ## Generates new elements by extrusion of the given elements
2773 # The path of extrusion must be a meshed edge.
2774 # @param Base mesh or list of ids of elements for extrusion
2775 # @param Path - 1D mesh or 1D sub-mesh, along which proceeds the extrusion
2776 # @param NodeStart the start node from Path. Defines the direction of extrusion
2777 # @param HasAngles allows the shape to be rotated around the path
2778 # to get the resulting mesh in a helical fashion
2779 # @param Angles list of angles in radians
2780 # @param LinearVariation forces the computation of rotation angles as linear
2781 # variation of the given Angles along path steps
2782 # @param HasRefPoint allows using the reference point
2783 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2784 # The User can specify any point as the Reference Point.
2785 # @param MakeGroups forces the generation of new groups from existing ones
2786 # @param ElemType type of elements for extrusion (if param Base is a mesh)
2787 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2788 # only SMESH::Extrusion_Error otherwise
2789 # @ingroup l2_modif_extrurev
2790 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
2791 HasAngles, Angles, LinearVariation,
2792 HasRefPoint, RefPoint, MakeGroups, ElemType):
2793 Angles,AnglesParameters = ParseAngles(Angles)
2794 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2795 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2796 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2798 Parameters = AnglesParameters + var_separator + RefPointParameters
2799 self.mesh.SetParameters(Parameters)
2801 if isinstance(Base,list):
2803 if Base == []: IDsOfElements = self.GetElementsId()
2804 else: IDsOfElements = Base
2805 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
2806 HasAngles, Angles, LinearVariation,
2807 HasRefPoint, RefPoint, MakeGroups, ElemType)
2809 if isinstance(Base,Mesh):
2810 return self.editor.ExtrusionAlongPathObjX(Base.GetMesh(), Path, NodeStart,
2811 HasAngles, Angles, LinearVariation,
2812 HasRefPoint, RefPoint, MakeGroups, ElemType)
2814 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
2817 ## Generates new elements by extrusion of the given elements
2818 # The path of extrusion must be a meshed edge.
2819 # @param IDsOfElements ids of elements
2820 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2821 # @param PathShape shape(edge) defines the sub-mesh for the path
2822 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2823 # @param HasAngles allows the shape to be rotated around the path
2824 # to get the resulting mesh in a helical fashion
2825 # @param Angles list of angles in radians
2826 # @param HasRefPoint allows using the reference point
2827 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2828 # The User can specify any point as the Reference Point.
2829 # @param MakeGroups forces the generation of new groups from existing ones
2830 # @param LinearVariation forces the computation of rotation angles as linear
2831 # variation of the given Angles along path steps
2832 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2833 # only SMESH::Extrusion_Error otherwise
2834 # @ingroup l2_modif_extrurev
2835 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2836 HasAngles, Angles, HasRefPoint, RefPoint,
2837 MakeGroups=False, LinearVariation=False):
2838 Angles,AnglesParameters = ParseAngles(Angles)
2839 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2840 if IDsOfElements == []:
2841 IDsOfElements = self.GetElementsId()
2842 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2843 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2845 if ( isinstance( PathMesh, Mesh )):
2846 PathMesh = PathMesh.GetMesh()
2847 if HasAngles and Angles and LinearVariation:
2848 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2850 Parameters = AnglesParameters + var_separator + RefPointParameters
2851 self.mesh.SetParameters(Parameters)
2853 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2854 PathShape, NodeStart, HasAngles,
2855 Angles, HasRefPoint, RefPoint)
2856 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2857 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2859 ## Generates new elements by extrusion of the elements which belong to the object
2860 # The path of extrusion must be a meshed edge.
2861 # @param theObject the object which elements should be processed
2862 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2863 # @param PathShape shape(edge) defines the sub-mesh for the path
2864 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2865 # @param HasAngles allows the shape to be rotated around the path
2866 # to get the resulting mesh in a helical fashion
2867 # @param Angles list of angles
2868 # @param HasRefPoint allows using the reference point
2869 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2870 # The User can specify any point as the Reference Point.
2871 # @param MakeGroups forces the generation of new groups from existing ones
2872 # @param LinearVariation forces the computation of rotation angles as linear
2873 # variation of the given Angles along path steps
2874 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2875 # only SMESH::Extrusion_Error otherwise
2876 # @ingroup l2_modif_extrurev
2877 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2878 HasAngles, Angles, HasRefPoint, RefPoint,
2879 MakeGroups=False, LinearVariation=False):
2880 Angles,AnglesParameters = ParseAngles(Angles)
2881 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2882 if ( isinstance( theObject, Mesh )):
2883 theObject = theObject.GetMesh()
2884 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2885 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2886 if ( isinstance( PathMesh, Mesh )):
2887 PathMesh = PathMesh.GetMesh()
2888 if HasAngles and Angles and LinearVariation:
2889 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2891 Parameters = AnglesParameters + var_separator + RefPointParameters
2892 self.mesh.SetParameters(Parameters)
2894 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2895 PathShape, NodeStart, HasAngles,
2896 Angles, HasRefPoint, RefPoint)
2897 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2898 NodeStart, HasAngles, Angles, HasRefPoint,
2901 ## Generates new elements by extrusion of the elements which belong to the object
2902 # The path of extrusion must be a meshed edge.
2903 # @param theObject the object which elements should be processed
2904 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2905 # @param PathShape shape(edge) defines the sub-mesh for the path
2906 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2907 # @param HasAngles allows the shape to be rotated around the path
2908 # to get the resulting mesh in a helical fashion
2909 # @param Angles list of angles
2910 # @param HasRefPoint allows using the reference point
2911 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2912 # The User can specify any point as the Reference Point.
2913 # @param MakeGroups forces the generation of new groups from existing ones
2914 # @param LinearVariation forces the computation of rotation angles as linear
2915 # variation of the given Angles along path steps
2916 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2917 # only SMESH::Extrusion_Error otherwise
2918 # @ingroup l2_modif_extrurev
2919 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
2920 HasAngles, Angles, HasRefPoint, RefPoint,
2921 MakeGroups=False, LinearVariation=False):
2922 Angles,AnglesParameters = ParseAngles(Angles)
2923 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2924 if ( isinstance( theObject, Mesh )):
2925 theObject = theObject.GetMesh()
2926 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2927 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2928 if ( isinstance( PathMesh, Mesh )):
2929 PathMesh = PathMesh.GetMesh()
2930 if HasAngles and Angles and LinearVariation:
2931 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2933 Parameters = AnglesParameters + var_separator + RefPointParameters
2934 self.mesh.SetParameters(Parameters)
2936 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
2937 PathShape, NodeStart, HasAngles,
2938 Angles, HasRefPoint, RefPoint)
2939 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
2940 NodeStart, HasAngles, Angles, HasRefPoint,
2943 ## Generates new elements by extrusion of the elements which belong to the object
2944 # The path of extrusion must be a meshed edge.
2945 # @param theObject the object which elements should be processed
2946 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2947 # @param PathShape shape(edge) defines the sub-mesh for the path
2948 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2949 # @param HasAngles allows the shape to be rotated around the path
2950 # to get the resulting mesh in a helical fashion
2951 # @param Angles list of angles
2952 # @param HasRefPoint allows using the reference point
2953 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2954 # The User can specify any point as the Reference Point.
2955 # @param MakeGroups forces the generation of new groups from existing ones
2956 # @param LinearVariation forces the computation of rotation angles as linear
2957 # variation of the given Angles along path steps
2958 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2959 # only SMESH::Extrusion_Error otherwise
2960 # @ingroup l2_modif_extrurev
2961 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
2962 HasAngles, Angles, HasRefPoint, RefPoint,
2963 MakeGroups=False, LinearVariation=False):
2964 Angles,AnglesParameters = ParseAngles(Angles)
2965 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
2966 if ( isinstance( theObject, Mesh )):
2967 theObject = theObject.GetMesh()
2968 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2969 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2970 if ( isinstance( PathMesh, Mesh )):
2971 PathMesh = PathMesh.GetMesh()
2972 if HasAngles and Angles and LinearVariation:
2973 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2975 Parameters = AnglesParameters + var_separator + RefPointParameters
2976 self.mesh.SetParameters(Parameters)
2978 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
2979 PathShape, NodeStart, HasAngles,
2980 Angles, HasRefPoint, RefPoint)
2981 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
2982 NodeStart, HasAngles, Angles, HasRefPoint,
2985 ## Creates a symmetrical copy of mesh elements
2986 # @param IDsOfElements list of elements ids
2987 # @param Mirror is AxisStruct or geom object(point, line, plane)
2988 # @param theMirrorType is POINT, AXIS or PLANE
2989 # If the Mirror is a geom object this parameter is unnecessary
2990 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2991 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2992 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2993 # @ingroup l2_modif_trsf
2994 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2995 if IDsOfElements == []:
2996 IDsOfElements = self.GetElementsId()
2997 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2998 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2999 Mirror,Parameters = ParseAxisStruct(Mirror)
3000 self.mesh.SetParameters(Parameters)
3001 if Copy and MakeGroups:
3002 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
3003 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
3006 ## Creates a new mesh by a symmetrical copy of mesh elements
3007 # @param IDsOfElements the list of elements ids
3008 # @param Mirror is AxisStruct or geom object (point, line, plane)
3009 # @param theMirrorType is POINT, AXIS or PLANE
3010 # If the Mirror is a geom object this parameter is unnecessary
3011 # @param MakeGroups to generate new groups from existing ones
3012 # @param NewMeshName a name of the new mesh to create
3013 # @return instance of Mesh class
3014 # @ingroup l2_modif_trsf
3015 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
3016 if IDsOfElements == []:
3017 IDsOfElements = self.GetElementsId()
3018 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3019 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3020 Mirror,Parameters = ParseAxisStruct(Mirror)
3021 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
3022 MakeGroups, NewMeshName)
3023 mesh.SetParameters(Parameters)
3024 return Mesh(self.smeshpyD,self.geompyD,mesh)
3026 ## Creates a symmetrical copy of the object
3027 # @param theObject mesh, submesh or group
3028 # @param Mirror AxisStruct or geom object (point, line, plane)
3029 # @param theMirrorType is POINT, AXIS or PLANE
3030 # If the Mirror is a geom object this parameter is unnecessary
3031 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
3032 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3033 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3034 # @ingroup l2_modif_trsf
3035 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
3036 if ( isinstance( theObject, Mesh )):
3037 theObject = theObject.GetMesh()
3038 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3039 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3040 Mirror,Parameters = ParseAxisStruct(Mirror)
3041 self.mesh.SetParameters(Parameters)
3042 if Copy and MakeGroups:
3043 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
3044 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
3047 ## Creates a new mesh by a symmetrical copy of the object
3048 # @param theObject mesh, submesh or group
3049 # @param Mirror AxisStruct or geom object (point, line, plane)
3050 # @param theMirrorType POINT, AXIS or PLANE
3051 # If the Mirror is a geom object this parameter is unnecessary
3052 # @param MakeGroups forces the generation of new groups from existing ones
3053 # @param NewMeshName the name of the new mesh to create
3054 # @return instance of Mesh class
3055 # @ingroup l2_modif_trsf
3056 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
3057 if ( isinstance( theObject, Mesh )):
3058 theObject = theObject.GetMesh()
3059 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
3060 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
3061 Mirror,Parameters = ParseAxisStruct(Mirror)
3062 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
3063 MakeGroups, NewMeshName)
3064 mesh.SetParameters(Parameters)
3065 return Mesh( self.smeshpyD,self.geompyD,mesh )
3067 ## Translates the elements
3068 # @param IDsOfElements list of elements ids
3069 # @param Vector the direction of translation (DirStruct or vector)
3070 # @param Copy allows copying the translated elements
3071 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3072 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3073 # @ingroup l2_modif_trsf
3074 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
3075 if IDsOfElements == []:
3076 IDsOfElements = self.GetElementsId()
3077 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3078 Vector = self.smeshpyD.GetDirStruct(Vector)
3079 Vector,Parameters = ParseDirStruct(Vector)
3080 self.mesh.SetParameters(Parameters)
3081 if Copy and MakeGroups:
3082 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
3083 self.editor.Translate(IDsOfElements, Vector, Copy)
3086 ## Creates a new mesh of translated elements
3087 # @param IDsOfElements list of elements ids
3088 # @param Vector the direction of translation (DirStruct or vector)
3089 # @param MakeGroups forces the generation of new groups from existing ones
3090 # @param NewMeshName the name of the newly created mesh
3091 # @return instance of Mesh class
3092 # @ingroup l2_modif_trsf
3093 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
3094 if IDsOfElements == []:
3095 IDsOfElements = self.GetElementsId()
3096 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3097 Vector = self.smeshpyD.GetDirStruct(Vector)
3098 Vector,Parameters = ParseDirStruct(Vector)
3099 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
3100 mesh.SetParameters(Parameters)
3101 return Mesh ( self.smeshpyD, self.geompyD, mesh )
3103 ## Translates the object
3104 # @param theObject the object to translate (mesh, submesh, or group)
3105 # @param Vector direction of translation (DirStruct or geom vector)
3106 # @param Copy allows copying the translated elements
3107 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3108 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3109 # @ingroup l2_modif_trsf
3110 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
3111 if ( isinstance( theObject, Mesh )):
3112 theObject = theObject.GetMesh()
3113 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
3114 Vector = self.smeshpyD.GetDirStruct(Vector)
3115 Vector,Parameters = ParseDirStruct(Vector)
3116 self.mesh.SetParameters(Parameters)
3117 if Copy and MakeGroups:
3118 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
3119 self.editor.TranslateObject(theObject, Vector, Copy)
3122 ## Creates a new mesh from the translated object
3123 # @param theObject the object to translate (mesh, submesh, or group)
3124 # @param Vector the direction of translation (DirStruct or geom vector)
3125 # @param MakeGroups forces the generation of new groups from existing ones
3126 # @param NewMeshName the name of the newly created mesh
3127 # @return instance of Mesh class
3128 # @ingroup l2_modif_trsf
3129 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
3130 if (isinstance(theObject, Mesh)):
3131 theObject = theObject.GetMesh()
3132 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
3133 Vector = self.smeshpyD.GetDirStruct(Vector)
3134 Vector,Parameters = ParseDirStruct(Vector)
3135 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
3136 mesh.SetParameters(Parameters)
3137 return Mesh( self.smeshpyD, self.geompyD, mesh )
3139 ## Rotates the elements
3140 # @param IDsOfElements list of elements ids
3141 # @param Axis the axis of rotation (AxisStruct or geom line)
3142 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3143 # @param Copy allows copying the rotated elements
3144 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3145 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3146 # @ingroup l2_modif_trsf
3147 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
3149 if isinstance(AngleInRadians,str):
3151 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3153 AngleInRadians = DegreesToRadians(AngleInRadians)
3154 if IDsOfElements == []:
3155 IDsOfElements = self.GetElementsId()
3156 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3157 Axis = self.smeshpyD.GetAxisStruct(Axis)
3158 Axis,AxisParameters = ParseAxisStruct(Axis)
3159 Parameters = AxisParameters + var_separator + Parameters
3160 self.mesh.SetParameters(Parameters)
3161 if Copy and MakeGroups:
3162 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
3163 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
3166 ## Creates a new mesh of rotated elements
3167 # @param IDsOfElements list of element ids
3168 # @param Axis the axis of rotation (AxisStruct or geom line)
3169 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3170 # @param MakeGroups forces the generation of new groups from existing ones
3171 # @param NewMeshName the name of the newly created mesh
3172 # @return instance of Mesh class
3173 # @ingroup l2_modif_trsf
3174 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
3176 if isinstance(AngleInRadians,str):
3178 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3180 AngleInRadians = DegreesToRadians(AngleInRadians)
3181 if IDsOfElements == []:
3182 IDsOfElements = self.GetElementsId()
3183 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
3184 Axis = self.smeshpyD.GetAxisStruct(Axis)
3185 Axis,AxisParameters = ParseAxisStruct(Axis)
3186 Parameters = AxisParameters + var_separator + Parameters
3187 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
3188 MakeGroups, NewMeshName)
3189 mesh.SetParameters(Parameters)
3190 return Mesh( self.smeshpyD, self.geompyD, mesh )
3192 ## Rotates the object
3193 # @param theObject the object to rotate( mesh, submesh, or group)
3194 # @param Axis the axis of rotation (AxisStruct or geom line)
3195 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3196 # @param Copy allows copying the rotated elements
3197 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
3198 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
3199 # @ingroup l2_modif_trsf
3200 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
3202 if isinstance(AngleInRadians,str):
3204 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3206 AngleInRadians = DegreesToRadians(AngleInRadians)
3207 if (isinstance(theObject, Mesh)):
3208 theObject = theObject.GetMesh()
3209 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3210 Axis = self.smeshpyD.GetAxisStruct(Axis)
3211 Axis,AxisParameters = ParseAxisStruct(Axis)
3212 Parameters = AxisParameters + ":" + Parameters
3213 self.mesh.SetParameters(Parameters)
3214 if Copy and MakeGroups:
3215 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
3216 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
3219 ## Creates a new mesh from the rotated object
3220 # @param theObject the object to rotate (mesh, submesh, or group)
3221 # @param Axis the axis of rotation (AxisStruct or geom line)
3222 # @param AngleInRadians the angle of rotation (in radians) or a name of variable which defines angle in degrees
3223 # @param MakeGroups forces the generation of new groups from existing ones
3224 # @param NewMeshName the name of the newly created mesh
3225 # @return instance of Mesh class
3226 # @ingroup l2_modif_trsf
3227 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
3229 if isinstance(AngleInRadians,str):
3231 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
3233 AngleInRadians = DegreesToRadians(AngleInRadians)
3234 if (isinstance( theObject, Mesh )):
3235 theObject = theObject.GetMesh()
3236 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
3237 Axis = self.smeshpyD.GetAxisStruct(Axis)
3238 Axis,AxisParameters = ParseAxisStruct(Axis)
3239 Parameters = AxisParameters + ":" + Parameters
3240 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
3241 MakeGroups, NewMeshName)
3242 mesh.SetParameters(Parameters)
3243 return Mesh( self.smeshpyD, self.geompyD, mesh )
3245 ## Finds groups of ajacent nodes within Tolerance.
3246 # @param Tolerance the value of tolerance
3247 # @return the list of groups of nodes
3248 # @ingroup l2_modif_trsf
3249 def FindCoincidentNodes (self, Tolerance):
3250 return self.editor.FindCoincidentNodes(Tolerance)
3252 ## Finds groups of ajacent nodes within Tolerance.
3253 # @param Tolerance the value of tolerance
3254 # @param SubMeshOrGroup SubMesh or Group
3255 # @return the list of groups of nodes
3256 # @ingroup l2_modif_trsf
3257 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
3258 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
3261 # @param GroupsOfNodes the list of groups of nodes
3262 # @ingroup l2_modif_trsf
3263 def MergeNodes (self, GroupsOfNodes):
3264 self.editor.MergeNodes(GroupsOfNodes)
3266 ## Finds the elements built on the same nodes.
3267 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
3268 # @return a list of groups of equal elements
3269 # @ingroup l2_modif_trsf
3270 def FindEqualElements (self, MeshOrSubMeshOrGroup):
3271 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
3273 ## Merges elements in each given group.
3274 # @param GroupsOfElementsID groups of elements for merging
3275 # @ingroup l2_modif_trsf
3276 def MergeElements(self, GroupsOfElementsID):
3277 self.editor.MergeElements(GroupsOfElementsID)
3279 ## Leaves one element and removes all other elements built on the same nodes.
3280 # @ingroup l2_modif_trsf
3281 def MergeEqualElements(self):
3282 self.editor.MergeEqualElements()
3284 ## Sews free borders
3285 # @return SMESH::Sew_Error
3286 # @ingroup l2_modif_trsf
3287 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3288 FirstNodeID2, SecondNodeID2, LastNodeID2,
3289 CreatePolygons, CreatePolyedrs):
3290 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3291 FirstNodeID2, SecondNodeID2, LastNodeID2,
3292 CreatePolygons, CreatePolyedrs)
3294 ## Sews conform free borders
3295 # @return SMESH::Sew_Error
3296 # @ingroup l2_modif_trsf
3297 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
3298 FirstNodeID2, SecondNodeID2):
3299 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
3300 FirstNodeID2, SecondNodeID2)
3302 ## Sews border to side
3303 # @return SMESH::Sew_Error
3304 # @ingroup l2_modif_trsf
3305 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3306 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
3307 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
3308 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
3310 ## Sews two sides of a mesh. The nodes belonging to Side1 are
3311 # merged with the nodes of elements of Side2.
3312 # The number of elements in theSide1 and in theSide2 must be
3313 # equal and they should have similar nodal connectivity.
3314 # The nodes to merge should belong to side borders and
3315 # the first node should be linked to the second.
3316 # @return SMESH::Sew_Error
3317 # @ingroup l2_modif_trsf
3318 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
3319 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3320 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
3321 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
3322 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
3323 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
3325 ## Sets new nodes for the given element.
3326 # @param ide the element id
3327 # @param newIDs nodes ids
3328 # @return If the number of nodes does not correspond to the type of element - returns false
3329 # @ingroup l2_modif_edit
3330 def ChangeElemNodes(self, ide, newIDs):
3331 return self.editor.ChangeElemNodes(ide, newIDs)
3333 ## If during the last operation of MeshEditor some nodes were
3334 # created, this method returns the list of their IDs, \n
3335 # if new nodes were not created - returns empty list
3336 # @return the list of integer values (can be empty)
3337 # @ingroup l1_auxiliary
3338 def GetLastCreatedNodes(self):
3339 return self.editor.GetLastCreatedNodes()
3341 ## If during the last operation of MeshEditor some elements were
3342 # created this method returns the list of their IDs, \n
3343 # if new elements were not created - returns empty list
3344 # @return the list of integer values (can be empty)
3345 # @ingroup l1_auxiliary
3346 def GetLastCreatedElems(self):
3347 return self.editor.GetLastCreatedElems()
3349 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3350 # @param theElems - the list of elements (edges or faces) to be replicated
3351 # The nodes for duplication could be found from these elements
3352 # @param theNodesNot - list of nodes to NOT replicate
3353 # @param theAffectedElems - the list of elements (cells and edges) to which the
3354 # replicated nodes should be associated to.
3355 # @return TRUE if operation has been completed successfully, FALSE otherwise
3356 # @ingroup l2_modif_edit
3357 def DoubleNodes(self, theElems, theNodesNot, theAffectedElems):
3358 return self.editor.DoubleNodes(theElems, theNodesNot, theAffectedElems)
3360 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3361 # @param theElems - the list of elements (edges or faces) to be replicated
3362 # The nodes for duplication could be found from these elements
3363 # @param theNodesNot - list of nodes to NOT replicate
3364 # @param theShape - shape to detect affected elements (element which geometric center
3365 # located on or inside shape).
3366 # The replicated nodes should be associated to affected elements.
3367 # @return TRUE if operation has been completed successfully, FALSE otherwise
3368 # @ingroup l2_modif_edit
3369 def DoubleNodesInRegion(self, theElems, theNodesNot, theShape):
3370 return self.editor.DoubleNodesInRegion(theElems, theNodesNot, theShape)
3372 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3373 # This method provided for convenience works as DoubleNodes() described above.
3374 # @param theElems - group of of elements (edges or faces) to be replicated
3375 # @param theNodesNot - group of nodes not to replicated
3376 # @param theAffectedElems - group of elements to which the replicated nodes
3377 # should be associated to.
3378 # @ingroup l2_modif_edit
3379 def DoubleNodeGroup(self, theElems, theNodesNot, theAffectedElems):
3380 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theAffectedElems)
3382 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3383 # This method provided for convenience works as DoubleNodes() described above.
3384 # @param theElems - group of of elements (edges or faces) to be replicated
3385 # @param theNodesNot - group of nodes not to replicated
3386 # @param theShape - shape to detect affected elements (element which geometric center
3387 # located on or inside shape).
3388 # The replicated nodes should be associated to affected elements.
3389 # @ingroup l2_modif_edit
3390 def DoubleNodeGroupInRegion(self, theElems, theNodesNot, theShape):
3391 return self.editor.DoubleNodeGroup(theElems, theNodesNot, theShape)
3393 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3394 # This method provided for convenience works as DoubleNodes() described above.
3395 # @param theElems - list of groups of elements (edges or faces) to be replicated
3396 # @param theNodesNot - list of groups of nodes not to replicated
3397 # @param theAffectedElems - group of elements to which the replicated nodes
3398 # should be associated to.
3399 # @return TRUE if operation has been completed successfully, FALSE otherwise
3400 # @ingroup l2_modif_edit
3401 def DoubleNodeGroups(self, theElems, theNodesNot, theAffectedElems):
3402 return self.editor.DoubleNodeGroups(theElems, theNodesNot, theAffectedElems)
3404 ## Creates a hole in a mesh by doubling the nodes of some particular elements
3405 # This method provided for convenience works as DoubleNodes() described above.
3406 # @param theElems - list of groups of elements (edges or faces) to be replicated
3407 # @param theNodesNot - list of groups of nodes not to replicated
3408 # @param theShape - shape to detect affected elements (element which geometric center
3409 # located on or inside shape).
3410 # The replicated nodes should be associated to affected elements.
3411 # @return TRUE if operation has been completed successfully, FALSE otherwise
3412 # @ingroup l2_modif_edit
3413 def DoubleNodeGroupsInRegion(self, theElems, theNodesNot, theShape):
3414 return self.editor.DoubleNodeGroupsInRegion(theElems, theNodesNot, theShape)
3416 ## The mother class to define algorithm, it is not recommended to use it directly.
3419 # @ingroup l2_algorithms
3420 class Mesh_Algorithm:
3421 # @class Mesh_Algorithm
3422 # @brief Class Mesh_Algorithm
3424 #def __init__(self,smesh):
3432 ## Finds a hypothesis in the study by its type name and parameters.
3433 # Finds only the hypotheses created in smeshpyD engine.
3434 # @return SMESH.SMESH_Hypothesis
3435 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
3436 study = smeshpyD.GetCurrentStudy()
3437 #to do: find component by smeshpyD object, not by its data type
3438 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3439 if scomp is not None:
3440 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
3441 # Check if the root label of the hypotheses exists
3442 if res and hypRoot is not None:
3443 iter = study.NewChildIterator(hypRoot)
3444 # Check all published hypotheses
3446 hypo_so_i = iter.Value()
3447 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
3448 if attr is not None:
3449 anIOR = attr.Value()
3450 hypo_o_i = salome.orb.string_to_object(anIOR)
3451 if hypo_o_i is not None:
3452 # Check if this is a hypothesis
3453 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
3454 if hypo_i is not None:
3455 # Check if the hypothesis belongs to current engine
3456 if smeshpyD.GetObjectId(hypo_i) > 0:
3457 # Check if this is the required hypothesis
3458 if hypo_i.GetName() == hypname:
3460 if CompareMethod(hypo_i, args):
3474 ## Finds the algorithm in the study by its type name.
3475 # Finds only the algorithms, which have been created in smeshpyD engine.
3476 # @return SMESH.SMESH_Algo
3477 def FindAlgorithm (self, algoname, smeshpyD):
3478 study = smeshpyD.GetCurrentStudy()
3479 #to do: find component by smeshpyD object, not by its data type
3480 scomp = study.FindComponent(smeshpyD.ComponentDataType())
3481 if scomp is not None:
3482 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
3483 # Check if the root label of the algorithms exists
3484 if res and hypRoot is not None:
3485 iter = study.NewChildIterator(hypRoot)
3486 # Check all published algorithms
3488 algo_so_i = iter.Value()
3489 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
3490 if attr is not None:
3491 anIOR = attr.Value()
3492 algo_o_i = salome.orb.string_to_object(anIOR)
3493 if algo_o_i is not None:
3494 # Check if this is an algorithm
3495 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
3496 if algo_i is not None:
3497 # Checks if the algorithm belongs to the current engine
3498 if smeshpyD.GetObjectId(algo_i) > 0:
3499 # Check if this is the required algorithm
3500 if algo_i.GetName() == algoname:
3513 ## If the algorithm is global, returns 0; \n
3514 # else returns the submesh associated to this algorithm.
3515 def GetSubMesh(self):
3518 ## Returns the wrapped mesher.
3519 def GetAlgorithm(self):
3522 ## Gets the list of hypothesis that can be used with this algorithm
3523 def GetCompatibleHypothesis(self):
3526 mylist = self.algo.GetCompatibleHypothesis()
3529 ## Gets the name of the algorithm
3533 ## Sets the name to the algorithm
3534 def SetName(self, name):
3535 self.mesh.smeshpyD.SetName(self.algo, name)
3537 ## Gets the id of the algorithm
3539 return self.algo.GetId()
3542 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
3544 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
3545 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
3547 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
3549 self.Assign(algo, mesh, geom)
3553 def Assign(self, algo, mesh, geom):
3555 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
3562 name = GetName(geom)
3564 name = mesh.geompyD.SubShapeName(geom, piece)
3565 mesh.geompyD.addToStudyInFather(piece, geom, name)
3566 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
3569 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
3570 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
3572 def CompareHyp (self, hyp, args):
3573 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
3576 def CompareEqualHyp (self, hyp, args):
3580 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
3581 UseExisting=0, CompareMethod=""):
3584 if CompareMethod == "": CompareMethod = self.CompareHyp
3585 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
3588 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
3594 a = a + s + str(args[i])
3598 self.mesh.smeshpyD.SetName(hypo, hyp + a)
3600 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
3601 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3604 ## Returns entry of the shape to mesh in the study
3605 def MainShapeEntry(self):
3607 if not self.mesh or not self.mesh.GetMesh(): return entry
3608 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
3609 study = self.mesh.smeshpyD.GetCurrentStudy()
3610 ior = salome.orb.object_to_string( self.mesh.GetShape() )
3611 sobj = study.FindObjectIOR(ior)
3612 if sobj: entry = sobj.GetID()
3613 if not entry: return ""
3616 # Public class: Mesh_Segment
3617 # --------------------------
3619 ## Class to define a segment 1D algorithm for discretization
3622 # @ingroup l3_algos_basic
3623 class Mesh_Segment(Mesh_Algorithm):
3625 ## Private constructor.
3626 def __init__(self, mesh, geom=0):
3627 Mesh_Algorithm.__init__(self)
3628 self.Create(mesh, geom, "Regular_1D")
3630 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3631 # @param l for the length of segments that cut an edge
3632 # @param UseExisting if ==true - searches for an existing hypothesis created with
3633 # the same parameters, else (default) - creates a new one
3634 # @param p precision, used for calculation of the number of segments.
3635 # The precision should be a positive, meaningful value within the range [0,1].
3636 # In general, the number of segments is calculated with the formula:
3637 # nb = ceil((edge_length / l) - p)
3638 # Function ceil rounds its argument to the higher integer.
3639 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3640 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3641 # p=1 means rounding of (edge_length / l) to the lower integer.
3642 # Default value is 1e-07.
3643 # @return an instance of StdMeshers_LocalLength hypothesis
3644 # @ingroup l3_hypos_1dhyps
3645 def LocalLength(self, l, UseExisting=0, p=1e-07):
3646 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3647 CompareMethod=self.CompareLocalLength)
3653 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3654 def CompareLocalLength(self, hyp, args):
3655 if IsEqual(hyp.GetLength(), args[0]):
3656 return IsEqual(hyp.GetPrecision(), args[1])
3659 ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value
3660 # @param length is optional maximal allowed length of segment, if it is omitted
3661 # the preestimated length is used that depends on geometry size
3662 # @param UseExisting if ==true - searches for an existing hypothesis created with
3663 # the same parameters, else (default) - create a new one
3664 # @return an instance of StdMeshers_MaxLength hypothesis
3665 # @ingroup l3_hypos_1dhyps
3666 def MaxSize(self, length=0.0, UseExisting=0):
3667 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
3670 hyp.SetLength(length)
3672 # set preestimated length
3673 gen = self.mesh.smeshpyD
3674 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
3675 self.mesh.GetMesh(), self.mesh.GetShape(),
3677 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
3679 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
3682 hyp.SetUsePreestimatedLength( length == 0.0 )
3685 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3686 # @param n for the number of segments that cut an edge
3687 # @param s for the scale factor (optional)
3688 # @param reversedEdges is a list of edges to mesh using reversed orientation
3689 # @param UseExisting if ==true - searches for an existing hypothesis created with
3690 # the same parameters, else (default) - create a new one
3691 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3692 # @ingroup l3_hypos_1dhyps
3693 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
3694 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3695 reversedEdges, UseExisting = [], reversedEdges
3696 entry = self.MainShapeEntry()
3698 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
3699 UseExisting=UseExisting,
3700 CompareMethod=self.CompareNumberOfSegments)
3702 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
3703 UseExisting=UseExisting,
3704 CompareMethod=self.CompareNumberOfSegments)
3705 hyp.SetDistrType( 1 )
3706 hyp.SetScaleFactor(s)
3707 hyp.SetNumberOfSegments(n)
3708 hyp.SetReversedEdges( reversedEdges )
3709 hyp.SetObjectEntry( entry )
3713 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3714 def CompareNumberOfSegments(self, hyp, args):
3715 if hyp.GetNumberOfSegments() == args[0]:
3717 if hyp.GetReversedEdges() == args[1]:
3718 if not args[1] or hyp.GetObjectEntry() == args[2]:
3721 if hyp.GetReversedEdges() == args[2]:
3722 if not args[2] or hyp.GetObjectEntry() == args[3]:
3723 if hyp.GetDistrType() == 1:
3724 if IsEqual(hyp.GetScaleFactor(), args[1]):
3728 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3729 # @param start defines the length of the first segment
3730 # @param end defines the length of the last segment
3731 # @param reversedEdges is a list of edges to mesh using reversed orientation
3732 # @param UseExisting if ==true - searches for an existing hypothesis created with
3733 # the same parameters, else (default) - creates a new one
3734 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3735 # @ingroup l3_hypos_1dhyps
3736 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
3737 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3738 reversedEdges, UseExisting = [], reversedEdges
3739 entry = self.MainShapeEntry()
3740 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
3741 UseExisting=UseExisting,
3742 CompareMethod=self.CompareArithmetic1D)
3743 hyp.SetStartLength(start)
3744 hyp.SetEndLength(end)
3745 hyp.SetReversedEdges( reversedEdges )
3746 hyp.SetObjectEntry( entry )
3750 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3751 def CompareArithmetic1D(self, hyp, args):
3752 if IsEqual(hyp.GetLength(1), args[0]):
3753 if IsEqual(hyp.GetLength(0), args[1]):
3754 if hyp.GetReversedEdges() == args[2]:
3755 if not args[2] or hyp.GetObjectEntry() == args[3]:
3760 ## Defines "FixedPoints1D" hypothesis to cut an edge using parameter
3761 # on curve from 0 to 1 (additionally it is neecessary to check
3762 # orientation of edges and create list of reversed edges if it is
3763 # needed) and sets numbers of segments between given points (default
3764 # values are equals 1
3765 # @param points defines the list of parameters on curve
3766 # @param nbSegs defines the list of numbers of segments
3767 # @param reversedEdges is a list of edges to mesh using reversed orientation
3768 # @param UseExisting if ==true - searches for an existing hypothesis created with
3769 # the same parameters, else (default) - creates a new one
3770 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3771 # @ingroup l3_hypos_1dhyps
3772 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
3773 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3774 reversedEdges, UseExisting = [], reversedEdges
3775 entry = self.MainShapeEntry()
3776 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
3777 UseExisting=UseExisting,
3778 CompareMethod=self.CompareArithmetic1D)
3779 hyp.SetPoints(points)
3780 hyp.SetNbSegments(nbSegs)
3781 hyp.SetReversedEdges(reversedEdges)
3782 hyp.SetObjectEntry(entry)
3786 ## Check if the given "FixedPoints1D" hypothesis has the same parameters
3787 ## as the given arguments
3788 def CompareFixedPoints1D(self, hyp, args):
3789 if hyp.GetPoints() == args[0]:
3790 if hyp.GetNbSegments() == args[1]:
3791 if hyp.GetReversedEdges() == args[2]:
3792 if not args[2] or hyp.GetObjectEntry() == args[3]:
3798 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3799 # @param start defines the length of the first segment
3800 # @param end defines the length of the last segment
3801 # @param reversedEdges is a list of edges to mesh using reversed orientation
3802 # @param UseExisting if ==true - searches for an existing hypothesis created with
3803 # the same parameters, else (default) - creates a new one
3804 # @return an instance of StdMeshers_StartEndLength hypothesis
3805 # @ingroup l3_hypos_1dhyps
3806 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
3807 if not isinstance(reversedEdges,list): #old version script, before adding reversedEdges
3808 reversedEdges, UseExisting = [], reversedEdges
3809 entry = self.MainShapeEntry()
3810 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
3811 UseExisting=UseExisting,
3812 CompareMethod=self.CompareStartEndLength)
3813 hyp.SetStartLength(start)
3814 hyp.SetEndLength(end)
3815 hyp.SetReversedEdges( reversedEdges )
3816 hyp.SetObjectEntry( entry )
3819 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3820 def CompareStartEndLength(self, hyp, args):
3821 if IsEqual(hyp.GetLength(1), args[0]):
3822 if IsEqual(hyp.GetLength(0), args[1]):
3823 if hyp.GetReversedEdges() == args[2]:
3824 if not args[2] or hyp.GetObjectEntry() == args[3]:
3828 ## Defines "Deflection1D" hypothesis
3829 # @param d for the deflection
3830 # @param UseExisting if ==true - searches for an existing hypothesis created with
3831 # the same parameters, else (default) - create a new one
3832 # @ingroup l3_hypos_1dhyps
3833 def Deflection1D(self, d, UseExisting=0):
3834 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3835 CompareMethod=self.CompareDeflection1D)
3836 hyp.SetDeflection(d)
3839 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3840 def CompareDeflection1D(self, hyp, args):
3841 return IsEqual(hyp.GetDeflection(), args[0])
3843 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3844 # the opposite side in case of quadrangular faces
3845 # @ingroup l3_hypos_additi
3846 def Propagation(self):
3847 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3849 ## Defines "AutomaticLength" hypothesis
3850 # @param fineness for the fineness [0-1]
3851 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3852 # same parameters, else (default) - create a new one
3853 # @ingroup l3_hypos_1dhyps
3854 def AutomaticLength(self, fineness=0, UseExisting=0):
3855 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3856 CompareMethod=self.CompareAutomaticLength)
3857 hyp.SetFineness( fineness )
3860 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3861 def CompareAutomaticLength(self, hyp, args):
3862 return IsEqual(hyp.GetFineness(), args[0])
3864 ## Defines "SegmentLengthAroundVertex" hypothesis
3865 # @param length for the segment length
3866 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3867 # Any other integer value means that the hypothesis will be set on the
3868 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3869 # @param UseExisting if ==true - searches for an existing hypothesis created with
3870 # the same parameters, else (default) - creates a new one
3871 # @ingroup l3_algos_segmarv
3872 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3874 store_geom = self.geom
3875 if type(vertex) is types.IntType:
3876 if vertex == 0 or vertex == 1:
3877 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3885 if self.geom is None:
3886 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3887 name = GetName(self.geom)
3889 piece = self.mesh.geom
3890 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3891 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3892 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3894 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3896 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3897 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3899 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3900 CompareMethod=self.CompareLengthNearVertex)
3901 self.geom = store_geom
3902 hyp.SetLength( length )
3905 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3906 # @ingroup l3_algos_segmarv
3907 def CompareLengthNearVertex(self, hyp, args):
3908 return IsEqual(hyp.GetLength(), args[0])
3910 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3911 # If the 2D mesher sees that all boundary edges are quadratic,
3912 # it generates quadratic faces, else it generates linear faces using
3913 # medium nodes as if they are vertices.
3914 # The 3D mesher generates quadratic volumes only if all boundary faces
3915 # are quadratic, else it fails.
3917 # @ingroup l3_hypos_additi
3918 def QuadraticMesh(self):
3919 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3922 # Public class: Mesh_CompositeSegment
3923 # --------------------------
3925 ## Defines a segment 1D algorithm for discretization
3927 # @ingroup l3_algos_basic
3928 class Mesh_CompositeSegment(Mesh_Segment):
3930 ## Private constructor.
3931 def __init__(self, mesh, geom=0):
3932 self.Create(mesh, geom, "CompositeSegment_1D")
3935 # Public class: Mesh_Segment_Python
3936 # ---------------------------------
3938 ## Defines a segment 1D algorithm for discretization with python function
3940 # @ingroup l3_algos_basic
3941 class Mesh_Segment_Python(Mesh_Segment):
3943 ## Private constructor.
3944 def __init__(self, mesh, geom=0):
3945 import Python1dPlugin
3946 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3948 ## Defines "PythonSplit1D" hypothesis
3949 # @param n for the number of segments that cut an edge
3950 # @param func for the python function that calculates the length of all segments
3951 # @param UseExisting if ==true - searches for the existing hypothesis created with
3952 # the same parameters, else (default) - creates a new one
3953 # @ingroup l3_hypos_1dhyps
3954 def PythonSplit1D(self, n, func, UseExisting=0):
3955 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3956 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3957 hyp.SetNumberOfSegments(n)
3958 hyp.SetPythonLog10RatioFunction(func)
3961 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3962 def ComparePythonSplit1D(self, hyp, args):
3963 #if hyp.GetNumberOfSegments() == args[0]:
3964 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3968 # Public class: Mesh_Triangle
3969 # ---------------------------
3971 ## Defines a triangle 2D algorithm
3973 # @ingroup l3_algos_basic
3974 class Mesh_Triangle(Mesh_Algorithm):
3983 ## Private constructor.
3984 def __init__(self, mesh, algoType, geom=0):
3985 Mesh_Algorithm.__init__(self)
3987 self.algoType = algoType
3988 if algoType == MEFISTO:
3989 self.Create(mesh, geom, "MEFISTO_2D")
3991 elif algoType == BLSURF:
3993 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3994 #self.SetPhysicalMesh() - PAL19680
3995 elif algoType == NETGEN:
3997 print "Warning: NETGENPlugin module unavailable"
3999 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4001 elif algoType == NETGEN_2D:
4003 print "Warning: NETGENPlugin module unavailable"
4005 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
4008 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
4009 # @param area for the maximum area of each triangle
4010 # @param UseExisting if ==true - searches for an existing hypothesis created with the
4011 # same parameters, else (default) - creates a new one
4013 # Only for algoType == MEFISTO || NETGEN_2D
4014 # @ingroup l3_hypos_2dhyps
4015 def MaxElementArea(self, area, UseExisting=0):
4016 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4017 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
4018 CompareMethod=self.CompareMaxElementArea)
4019 elif self.algoType == NETGEN:
4020 hyp = self.Parameters(SIMPLE)
4021 hyp.SetMaxElementArea(area)
4024 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
4025 def CompareMaxElementArea(self, hyp, args):
4026 return IsEqual(hyp.GetMaxElementArea(), args[0])
4028 ## Defines "LengthFromEdges" hypothesis to build triangles
4029 # based on the length of the edges taken from the wire
4031 # Only for algoType == MEFISTO || NETGEN_2D
4032 # @ingroup l3_hypos_2dhyps
4033 def LengthFromEdges(self):
4034 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
4035 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4037 elif self.algoType == NETGEN:
4038 hyp = self.Parameters(SIMPLE)
4039 hyp.LengthFromEdges()
4042 ## Sets a way to define size of mesh elements to generate.
4043 # @param thePhysicalMesh is: DefaultSize or Custom.
4044 # @ingroup l3_hypos_blsurf
4045 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
4046 # Parameter of BLSURF algo
4047 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
4049 ## Sets size of mesh elements to generate.
4050 # @ingroup l3_hypos_blsurf
4051 def SetPhySize(self, theVal):
4052 # Parameter of BLSURF algo
4053 self.Parameters().SetPhySize(theVal)
4055 ## Sets lower boundary of mesh element size (PhySize).
4056 # @ingroup l3_hypos_blsurf
4057 def SetPhyMin(self, theVal=-1):
4058 # Parameter of BLSURF algo
4059 self.Parameters().SetPhyMin(theVal)
4061 ## Sets upper boundary of mesh element size (PhySize).
4062 # @ingroup l3_hypos_blsurf
4063 def SetPhyMax(self, theVal=-1):
4064 # Parameter of BLSURF algo
4065 self.Parameters().SetPhyMax(theVal)
4067 ## Sets a way to define maximum angular deflection of mesh from CAD model.
4068 # @param theGeometricMesh is: DefaultGeom or Custom
4069 # @ingroup l3_hypos_blsurf
4070 def SetGeometricMesh(self, theGeometricMesh=0):
4071 # Parameter of BLSURF algo
4072 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
4073 self.params.SetGeometricMesh(theGeometricMesh)
4075 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
4076 # @ingroup l3_hypos_blsurf
4077 def SetAngleMeshS(self, theVal=_angleMeshS):
4078 # Parameter of BLSURF algo
4079 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4080 self.params.SetAngleMeshS(theVal)
4082 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
4083 # @ingroup l3_hypos_blsurf
4084 def SetAngleMeshC(self, theVal=_angleMeshS):
4085 # Parameter of BLSURF algo
4086 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
4087 self.params.SetAngleMeshC(theVal)
4089 ## Sets lower boundary of mesh element size computed to respect angular deflection.
4090 # @ingroup l3_hypos_blsurf
4091 def SetGeoMin(self, theVal=-1):
4092 # Parameter of BLSURF algo
4093 self.Parameters().SetGeoMin(theVal)
4095 ## Sets upper boundary of mesh element size computed to respect angular deflection.
4096 # @ingroup l3_hypos_blsurf
4097 def SetGeoMax(self, theVal=-1):
4098 # Parameter of BLSURF algo
4099 self.Parameters().SetGeoMax(theVal)
4101 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
4102 # @ingroup l3_hypos_blsurf
4103 def SetGradation(self, theVal=_gradation):
4104 # Parameter of BLSURF algo
4105 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
4106 self.params.SetGradation(theVal)
4108 ## Sets topology usage way.
4109 # @param way defines how mesh conformity is assured <ul>
4110 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
4111 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
4112 # @ingroup l3_hypos_blsurf
4113 def SetTopology(self, way):
4114 # Parameter of BLSURF algo
4115 self.Parameters().SetTopology(way)
4117 ## To respect geometrical edges or not.
4118 # @ingroup l3_hypos_blsurf
4119 def SetDecimesh(self, toIgnoreEdges=False):
4120 # Parameter of BLSURF algo
4121 self.Parameters().SetDecimesh(toIgnoreEdges)
4123 ## Sets verbosity level in the range 0 to 100.
4124 # @ingroup l3_hypos_blsurf
4125 def SetVerbosity(self, level):
4126 # Parameter of BLSURF algo
4127 self.Parameters().SetVerbosity(level)
4129 ## Sets advanced option value.
4130 # @ingroup l3_hypos_blsurf
4131 def SetOptionValue(self, optionName, level):
4132 # Parameter of BLSURF algo
4133 self.Parameters().SetOptionValue(optionName,level)
4135 ## Sets QuadAllowed flag.
4136 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
4137 # @ingroup l3_hypos_netgen l3_hypos_blsurf
4138 def SetQuadAllowed(self, toAllow=True):
4139 if self.algoType == NETGEN_2D:
4140 if toAllow: # add QuadranglePreference
4141 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
4142 else: # remove QuadranglePreference
4143 for hyp in self.mesh.GetHypothesisList( self.geom ):
4144 if hyp.GetName() == "QuadranglePreference":
4145 self.mesh.RemoveHypothesis( self.geom, hyp )
4150 if self.Parameters():
4151 self.params.SetQuadAllowed(toAllow)
4154 ## Defines hypothesis having several parameters
4156 # @ingroup l3_hypos_netgen
4157 def Parameters(self, which=SOLE):
4160 if self.algoType == NETGEN:
4162 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
4163 "libNETGENEngine.so", UseExisting=0)
4165 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
4166 "libNETGENEngine.so", UseExisting=0)
4168 elif self.algoType == MEFISTO:
4169 print "Mefisto algo support no multi-parameter hypothesis"
4171 elif self.algoType == NETGEN_2D:
4172 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
4173 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
4175 elif self.algoType == BLSURF:
4176 self.params = self.Hypothesis("BLSURF_Parameters", [],
4177 "libBLSURFEngine.so", UseExisting=0)
4180 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
4185 # Only for algoType == NETGEN
4186 # @ingroup l3_hypos_netgen
4187 def SetMaxSize(self, theSize):
4188 if self.Parameters():
4189 self.params.SetMaxSize(theSize)
4191 ## Sets SecondOrder flag
4193 # Only for algoType == NETGEN
4194 # @ingroup l3_hypos_netgen
4195 def SetSecondOrder(self, theVal):
4196 if self.Parameters():
4197 self.params.SetSecondOrder(theVal)
4199 ## Sets Optimize flag
4201 # Only for algoType == NETGEN
4202 # @ingroup l3_hypos_netgen
4203 def SetOptimize(self, theVal):
4204 if self.Parameters():
4205 self.params.SetOptimize(theVal)
4208 # @param theFineness is:
4209 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4211 # Only for algoType == NETGEN
4212 # @ingroup l3_hypos_netgen
4213 def SetFineness(self, theFineness):
4214 if self.Parameters():
4215 self.params.SetFineness(theFineness)
4219 # Only for algoType == NETGEN
4220 # @ingroup l3_hypos_netgen
4221 def SetGrowthRate(self, theRate):
4222 if self.Parameters():
4223 self.params.SetGrowthRate(theRate)
4225 ## Sets NbSegPerEdge
4227 # Only for algoType == NETGEN
4228 # @ingroup l3_hypos_netgen
4229 def SetNbSegPerEdge(self, theVal):
4230 if self.Parameters():
4231 self.params.SetNbSegPerEdge(theVal)
4233 ## Sets NbSegPerRadius
4235 # Only for algoType == NETGEN
4236 # @ingroup l3_hypos_netgen
4237 def SetNbSegPerRadius(self, theVal):
4238 if self.Parameters():
4239 self.params.SetNbSegPerRadius(theVal)
4241 ## Sets number of segments overriding value set by SetLocalLength()
4243 # Only for algoType == NETGEN
4244 # @ingroup l3_hypos_netgen
4245 def SetNumberOfSegments(self, theVal):
4246 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4248 ## Sets number of segments overriding value set by SetNumberOfSegments()
4250 # Only for algoType == NETGEN
4251 # @ingroup l3_hypos_netgen
4252 def SetLocalLength(self, theVal):
4253 self.Parameters(SIMPLE).SetLocalLength(theVal)
4258 # Public class: Mesh_Quadrangle
4259 # -----------------------------
4261 ## Defines a quadrangle 2D algorithm
4263 # @ingroup l3_algos_basic
4264 class Mesh_Quadrangle(Mesh_Algorithm):
4266 ## Private constructor.
4267 def __init__(self, mesh, geom=0):
4268 Mesh_Algorithm.__init__(self)
4269 self.Create(mesh, geom, "Quadrangle_2D")
4271 ## Defines "QuadranglePreference" hypothesis, forcing construction
4272 # of quadrangles if the number of nodes on the opposite edges is not the same
4273 # while the total number of nodes on edges is even
4275 # @ingroup l3_hypos_additi
4276 def QuadranglePreference(self):
4277 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
4278 CompareMethod=self.CompareEqualHyp)
4281 ## Defines "TrianglePreference" hypothesis, forcing construction
4282 # of triangles in the refinement area if the number of nodes
4283 # on the opposite edges is not the same
4285 # @ingroup l3_hypos_additi
4286 def TrianglePreference(self):
4287 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
4288 CompareMethod=self.CompareEqualHyp)
4291 # Public class: Mesh_Tetrahedron
4292 # ------------------------------
4294 ## Defines a tetrahedron 3D algorithm
4296 # @ingroup l3_algos_basic
4297 class Mesh_Tetrahedron(Mesh_Algorithm):
4302 ## Private constructor.
4303 def __init__(self, mesh, algoType, geom=0):
4304 Mesh_Algorithm.__init__(self)
4306 if algoType == NETGEN:
4307 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
4310 elif algoType == FULL_NETGEN:
4312 print "Warning: NETGENPlugin module has not been imported."
4313 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4316 elif algoType == GHS3D:
4318 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
4321 elif algoType == GHS3DPRL:
4322 import GHS3DPRLPlugin
4323 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
4326 self.algoType = algoType
4328 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
4329 # @param vol for the maximum volume of each tetrahedron
4330 # @param UseExisting if ==true - searches for the existing hypothesis created with
4331 # the same parameters, else (default) - creates a new one
4332 # @ingroup l3_hypos_maxvol
4333 def MaxElementVolume(self, vol, UseExisting=0):
4334 if self.algoType == NETGEN:
4335 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
4336 CompareMethod=self.CompareMaxElementVolume)
4337 hyp.SetMaxElementVolume(vol)
4339 elif self.algoType == FULL_NETGEN:
4340 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
4343 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
4344 def CompareMaxElementVolume(self, hyp, args):
4345 return IsEqual(hyp.GetMaxElementVolume(), args[0])
4347 ## Defines hypothesis having several parameters
4349 # @ingroup l3_hypos_netgen
4350 def Parameters(self, which=SOLE):
4354 if self.algoType == FULL_NETGEN:
4356 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
4357 "libNETGENEngine.so", UseExisting=0)
4359 self.params = self.Hypothesis("NETGEN_Parameters", [],
4360 "libNETGENEngine.so", UseExisting=0)
4363 if self.algoType == GHS3D:
4364 self.params = self.Hypothesis("GHS3D_Parameters", [],
4365 "libGHS3DEngine.so", UseExisting=0)
4368 if self.algoType == GHS3DPRL:
4369 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
4370 "libGHS3DPRLEngine.so", UseExisting=0)
4373 print "Algo supports no multi-parameter hypothesis"
4377 # Parameter of FULL_NETGEN
4378 # @ingroup l3_hypos_netgen
4379 def SetMaxSize(self, theSize):
4380 self.Parameters().SetMaxSize(theSize)
4382 ## Sets SecondOrder flag
4383 # Parameter of FULL_NETGEN
4384 # @ingroup l3_hypos_netgen
4385 def SetSecondOrder(self, theVal):
4386 self.Parameters().SetSecondOrder(theVal)
4388 ## Sets Optimize flag
4389 # Parameter of FULL_NETGEN
4390 # @ingroup l3_hypos_netgen
4391 def SetOptimize(self, theVal):
4392 self.Parameters().SetOptimize(theVal)
4395 # @param theFineness is:
4396 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
4397 # Parameter of FULL_NETGEN
4398 # @ingroup l3_hypos_netgen
4399 def SetFineness(self, theFineness):
4400 self.Parameters().SetFineness(theFineness)
4403 # Parameter of FULL_NETGEN
4404 # @ingroup l3_hypos_netgen
4405 def SetGrowthRate(self, theRate):
4406 self.Parameters().SetGrowthRate(theRate)
4408 ## Sets NbSegPerEdge
4409 # Parameter of FULL_NETGEN
4410 # @ingroup l3_hypos_netgen
4411 def SetNbSegPerEdge(self, theVal):
4412 self.Parameters().SetNbSegPerEdge(theVal)
4414 ## Sets NbSegPerRadius
4415 # Parameter of FULL_NETGEN
4416 # @ingroup l3_hypos_netgen
4417 def SetNbSegPerRadius(self, theVal):
4418 self.Parameters().SetNbSegPerRadius(theVal)
4420 ## Sets number of segments overriding value set by SetLocalLength()
4421 # Only for algoType == NETGEN_FULL
4422 # @ingroup l3_hypos_netgen
4423 def SetNumberOfSegments(self, theVal):
4424 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
4426 ## Sets number of segments overriding value set by SetNumberOfSegments()
4427 # Only for algoType == NETGEN_FULL
4428 # @ingroup l3_hypos_netgen
4429 def SetLocalLength(self, theVal):
4430 self.Parameters(SIMPLE).SetLocalLength(theVal)
4432 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
4433 # Overrides value set by LengthFromEdges()
4434 # Only for algoType == NETGEN_FULL
4435 # @ingroup l3_hypos_netgen
4436 def MaxElementArea(self, area):
4437 self.Parameters(SIMPLE).SetMaxElementArea(area)
4439 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
4440 # Overrides value set by MaxElementArea()
4441 # Only for algoType == NETGEN_FULL
4442 # @ingroup l3_hypos_netgen
4443 def LengthFromEdges(self):
4444 self.Parameters(SIMPLE).LengthFromEdges()
4446 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
4447 # Overrides value set by MaxElementVolume()
4448 # Only for algoType == NETGEN_FULL
4449 # @ingroup l3_hypos_netgen
4450 def LengthFromFaces(self):
4451 self.Parameters(SIMPLE).LengthFromFaces()
4453 ## To mesh "holes" in a solid or not. Default is to mesh.
4454 # @ingroup l3_hypos_ghs3dh
4455 def SetToMeshHoles(self, toMesh):
4456 # Parameter of GHS3D
4457 self.Parameters().SetToMeshHoles(toMesh)
4459 ## Set Optimization level:
4460 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
4461 # Default is Medium_Optimization
4462 # @ingroup l3_hypos_ghs3dh
4463 def SetOptimizationLevel(self, level):
4464 # Parameter of GHS3D
4465 self.Parameters().SetOptimizationLevel(level)
4467 ## Maximal size of memory to be used by the algorithm (in Megabytes).
4468 # @ingroup l3_hypos_ghs3dh
4469 def SetMaximumMemory(self, MB):
4470 # Advanced parameter of GHS3D
4471 self.Parameters().SetMaximumMemory(MB)
4473 ## Initial size of memory to be used by the algorithm (in Megabytes) in
4474 # automatic memory adjustment mode.
4475 # @ingroup l3_hypos_ghs3dh
4476 def SetInitialMemory(self, MB):
4477 # Advanced parameter of GHS3D
4478 self.Parameters().SetInitialMemory(MB)
4480 ## Path to working directory.
4481 # @ingroup l3_hypos_ghs3dh
4482 def SetWorkingDirectory(self, path):
4483 # Advanced parameter of GHS3D
4484 self.Parameters().SetWorkingDirectory(path)
4486 ## To keep working files or remove them. Log file remains in case of errors anyway.
4487 # @ingroup l3_hypos_ghs3dh
4488 def SetKeepFiles(self, toKeep):
4489 # Advanced parameter of GHS3D and GHS3DPRL
4490 self.Parameters().SetKeepFiles(toKeep)
4492 ## To set verbose level [0-10]. <ul>
4493 #<li> 0 - no standard output,
4494 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
4495 # indicates when the final mesh is being saved. In addition the software
4496 # gives indication regarding the CPU time.
4497 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
4498 # histogram of the skin mesh, quality statistics histogram together with
4499 # the characteristics of the final mesh.</ul>
4500 # @ingroup l3_hypos_ghs3dh
4501 def SetVerboseLevel(self, level):
4502 # Advanced parameter of GHS3D
4503 self.Parameters().SetVerboseLevel(level)
4505 ## To create new nodes.
4506 # @ingroup l3_hypos_ghs3dh
4507 def SetToCreateNewNodes(self, toCreate):
4508 # Advanced parameter of GHS3D
4509 self.Parameters().SetToCreateNewNodes(toCreate)
4511 ## To use boundary recovery version which tries to create mesh on a very poor
4512 # quality surface mesh.
4513 # @ingroup l3_hypos_ghs3dh
4514 def SetToUseBoundaryRecoveryVersion(self, toUse):
4515 # Advanced parameter of GHS3D
4516 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
4518 ## Sets command line option as text.
4519 # @ingroup l3_hypos_ghs3dh
4520 def SetTextOption(self, option):
4521 # Advanced parameter of GHS3D
4522 self.Parameters().SetTextOption(option)
4524 ## Sets MED files name and path.
4525 def SetMEDName(self, value):
4526 self.Parameters().SetMEDName(value)
4528 ## Sets the number of partition of the initial mesh
4529 def SetNbPart(self, value):
4530 self.Parameters().SetNbPart(value)
4532 ## When big mesh, start tepal in background
4533 def SetBackground(self, value):
4534 self.Parameters().SetBackground(value)
4536 # Public class: Mesh_Hexahedron
4537 # ------------------------------
4539 ## Defines a hexahedron 3D algorithm
4541 # @ingroup l3_algos_basic
4542 class Mesh_Hexahedron(Mesh_Algorithm):
4547 ## Private constructor.
4548 def __init__(self, mesh, algoType=Hexa, geom=0):
4549 Mesh_Algorithm.__init__(self)
4551 self.algoType = algoType
4553 if algoType == Hexa:
4554 self.Create(mesh, geom, "Hexa_3D")
4557 elif algoType == Hexotic:
4558 import HexoticPlugin
4559 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
4562 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
4563 # @ingroup l3_hypos_hexotic
4564 def MinMaxQuad(self, min=3, max=8, quad=True):
4565 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
4567 self.params.SetHexesMinLevel(min)
4568 self.params.SetHexesMaxLevel(max)
4569 self.params.SetHexoticQuadrangles(quad)
4572 # Deprecated, only for compatibility!
4573 # Public class: Mesh_Netgen
4574 # ------------------------------
4576 ## Defines a NETGEN-based 2D or 3D algorithm
4577 # that needs no discrete boundary (i.e. independent)
4579 # This class is deprecated, only for compatibility!
4582 # @ingroup l3_algos_basic
4583 class Mesh_Netgen(Mesh_Algorithm):
4587 ## Private constructor.
4588 def __init__(self, mesh, is3D, geom=0):
4589 Mesh_Algorithm.__init__(self)
4592 print "Warning: NETGENPlugin module has not been imported."
4596 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
4600 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
4603 ## Defines the hypothesis containing parameters of the algorithm
4604 def Parameters(self):
4606 hyp = self.Hypothesis("NETGEN_Parameters", [],
4607 "libNETGENEngine.so", UseExisting=0)
4609 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
4610 "libNETGENEngine.so", UseExisting=0)
4613 # Public class: Mesh_Projection1D
4614 # ------------------------------
4616 ## Defines a projection 1D algorithm
4617 # @ingroup l3_algos_proj
4619 class Mesh_Projection1D(Mesh_Algorithm):
4621 ## Private constructor.
4622 def __init__(self, mesh, geom=0):
4623 Mesh_Algorithm.__init__(self)
4624 self.Create(mesh, geom, "Projection_1D")
4626 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
4627 # a mesh pattern is taken, and, optionally, the association of vertices
4628 # between the source edge and a target edge (to which a hypothesis is assigned)
4629 # @param edge from which nodes distribution is taken
4630 # @param mesh from which nodes distribution is taken (optional)
4631 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
4632 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
4633 # to associate with \a srcV (optional)
4634 # @param UseExisting if ==true - searches for the existing hypothesis created with
4635 # the same parameters, else (default) - creates a new one
4636 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
4637 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
4639 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
4640 hyp.SetSourceEdge( edge )
4641 if not mesh is None and isinstance(mesh, Mesh):
4642 mesh = mesh.GetMesh()
4643 hyp.SetSourceMesh( mesh )
4644 hyp.SetVertexAssociation( srcV, tgtV )
4647 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
4648 #def CompareSourceEdge(self, hyp, args):
4649 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
4653 # Public class: Mesh_Projection2D
4654 # ------------------------------
4656 ## Defines a projection 2D algorithm
4657 # @ingroup l3_algos_proj
4659 class Mesh_Projection2D(Mesh_Algorithm):
4661 ## Private constructor.
4662 def __init__(self, mesh, geom=0):
4663 Mesh_Algorithm.__init__(self)
4664 self.Create(mesh, geom, "Projection_2D")
4666 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
4667 # a mesh pattern is taken, and, optionally, the association of vertices
4668 # between the source face and the target face (to which a hypothesis is assigned)
4669 # @param face from which the mesh pattern is taken
4670 # @param mesh from which the mesh pattern is taken (optional)
4671 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
4672 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
4673 # to associate with \a srcV1 (optional)
4674 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
4675 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
4676 # to associate with \a srcV2 (optional)
4677 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
4678 # the same parameters, else (default) - forces the creation a new one
4680 # Note: all association vertices must belong to one edge of a face
4681 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
4682 srcV2=None, tgtV2=None, UseExisting=0):
4683 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
4685 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
4686 hyp.SetSourceFace( face )
4687 if not mesh is None and isinstance(mesh, Mesh):
4688 mesh = mesh.GetMesh()
4689 hyp.SetSourceMesh( mesh )
4690 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4693 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
4694 #def CompareSourceFace(self, hyp, args):
4695 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
4698 # Public class: Mesh_Projection3D
4699 # ------------------------------
4701 ## Defines a projection 3D algorithm
4702 # @ingroup l3_algos_proj
4704 class Mesh_Projection3D(Mesh_Algorithm):
4706 ## Private constructor.
4707 def __init__(self, mesh, geom=0):
4708 Mesh_Algorithm.__init__(self)
4709 self.Create(mesh, geom, "Projection_3D")
4711 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
4712 # the mesh pattern is taken, and, optionally, the association of vertices
4713 # between the source and the target solid (to which a hipothesis is assigned)
4714 # @param solid from where the mesh pattern is taken
4715 # @param mesh from where the mesh pattern is taken (optional)
4716 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
4717 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
4718 # to associate with \a srcV1 (optional)
4719 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
4720 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
4721 # to associate with \a srcV2 (optional)
4722 # @param UseExisting - if ==true - searches for the existing hypothesis created with
4723 # the same parameters, else (default) - creates a new one
4725 # Note: association vertices must belong to one edge of a solid
4726 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
4727 srcV2=0, tgtV2=0, UseExisting=0):
4728 hyp = self.Hypothesis("ProjectionSource3D",
4729 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
4731 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
4732 hyp.SetSource3DShape( solid )
4733 if not mesh is None and isinstance(mesh, Mesh):
4734 mesh = mesh.GetMesh()
4735 hyp.SetSourceMesh( mesh )
4736 if srcV1 and srcV2 and tgtV1 and tgtV2:
4737 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4738 #elif srcV1 or srcV2 or tgtV1 or tgtV2:
4741 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4742 #def CompareSourceShape3D(self, hyp, args):
4743 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4747 # Public class: Mesh_Prism
4748 # ------------------------
4750 ## Defines a 3D extrusion algorithm
4751 # @ingroup l3_algos_3dextr
4753 class Mesh_Prism3D(Mesh_Algorithm):
4755 ## Private constructor.
4756 def __init__(self, mesh, geom=0):
4757 Mesh_Algorithm.__init__(self)
4758 self.Create(mesh, geom, "Prism_3D")
4760 # Public class: Mesh_RadialPrism
4761 # -------------------------------
4763 ## Defines a Radial Prism 3D algorithm
4764 # @ingroup l3_algos_radialp
4766 class Mesh_RadialPrism3D(Mesh_Algorithm):
4768 ## Private constructor.
4769 def __init__(self, mesh, geom=0):
4770 Mesh_Algorithm.__init__(self)
4771 self.Create(mesh, geom, "RadialPrism_3D")
4773 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4774 self.nbLayers = None
4776 ## Return 3D hypothesis holding the 1D one
4777 def Get3DHypothesis(self):
4778 return self.distribHyp
4780 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4781 # hypothesis. Returns the created hypothesis
4782 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4783 #print "OwnHypothesis",hypType
4784 if not self.nbLayers is None:
4785 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4786 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4787 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4788 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4789 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4790 self.distribHyp.SetLayerDistribution( hyp )
4793 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4794 # prisms to build between the inner and outer shells
4795 # @param n number of layers
4796 # @param UseExisting if ==true - searches for the existing hypothesis created with
4797 # the same parameters, else (default) - creates a new one
4798 def NumberOfLayers(self, n, UseExisting=0):
4799 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4800 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4801 CompareMethod=self.CompareNumberOfLayers)
4802 self.nbLayers.SetNumberOfLayers( n )
4803 return self.nbLayers
4805 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4806 def CompareNumberOfLayers(self, hyp, args):
4807 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4809 ## Defines "LocalLength" hypothesis, specifying the segment length
4810 # to build between the inner and the outer shells
4811 # @param l the length of segments
4812 # @param p the precision of rounding
4813 def LocalLength(self, l, p=1e-07):
4814 hyp = self.OwnHypothesis("LocalLength", [l,p])
4819 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4820 # prisms to build between the inner and the outer shells.
4821 # @param n the number of layers
4822 # @param s the scale factor (optional)
4823 def NumberOfSegments(self, n, s=[]):
4825 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4827 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4828 hyp.SetDistrType( 1 )
4829 hyp.SetScaleFactor(s)
4830 hyp.SetNumberOfSegments(n)
4833 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4834 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4835 # @param start the length of the first segment
4836 # @param end the length of the last segment
4837 def Arithmetic1D(self, start, end ):
4838 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4839 hyp.SetLength(start, 1)
4840 hyp.SetLength(end , 0)
4843 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4844 # to build between the inner and the outer shells as geometric length increasing
4845 # @param start for the length of the first segment
4846 # @param end for the length of the last segment
4847 def StartEndLength(self, start, end):
4848 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4849 hyp.SetLength(start, 1)
4850 hyp.SetLength(end , 0)
4853 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4854 # to build between the inner and outer shells
4855 # @param fineness defines the quality of the mesh within the range [0-1]
4856 def AutomaticLength(self, fineness=0):
4857 hyp = self.OwnHypothesis("AutomaticLength")
4858 hyp.SetFineness( fineness )
4861 # Public class: Mesh_RadialQuadrangle1D2D
4862 # -------------------------------
4864 ## Defines a Radial Quadrangle 1D2D algorithm
4865 # @ingroup l2_algos_radialq
4867 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
4869 ## Private constructor.
4870 def __init__(self, mesh, geom=0):
4871 Mesh_Algorithm.__init__(self)
4872 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
4874 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
4875 self.nbLayers = None
4877 ## Return 2D hypothesis holding the 1D one
4878 def Get2DHypothesis(self):
4879 return self.distribHyp
4881 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4882 # hypothesis. Returns the created hypothesis
4883 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4884 #print "OwnHypothesis",hypType
4885 if not self.nbLayers is None:
4886 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4887 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4888 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4889 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4890 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4891 self.distribHyp.SetLayerDistribution( hyp )
4894 ## Defines "NumberOfLayers2D" hypothesis, specifying the number of layers
4895 # @param n number of layers
4896 # @param UseExisting if ==true - searches for the existing hypothesis created with
4897 # the same parameters, else (default) - creates a new one
4898 def NumberOfLayers2D(self, n, UseExisting=0):
4899 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4900 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
4901 CompareMethod=self.CompareNumberOfLayers)
4902 self.nbLayers.SetNumberOfLayers( n )
4903 return self.nbLayers
4905 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4906 def CompareNumberOfLayers(self, hyp, args):
4907 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4909 ## Defines "LocalLength" hypothesis, specifying the segment length
4910 # @param l the length of segments
4911 # @param p the precision of rounding
4912 def LocalLength(self, l, p=1e-07):
4913 hyp = self.OwnHypothesis("LocalLength", [l,p])
4918 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers
4919 # @param n the number of layers
4920 # @param s the scale factor (optional)
4921 def NumberOfSegments(self, n, s=[]):
4923 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4925 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4926 hyp.SetDistrType( 1 )
4927 hyp.SetScaleFactor(s)
4928 hyp.SetNumberOfSegments(n)
4931 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4932 # with a length that changes in arithmetic progression
4933 # @param start the length of the first segment
4934 # @param end the length of the last segment
4935 def Arithmetic1D(self, start, end ):
4936 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4937 hyp.SetLength(start, 1)
4938 hyp.SetLength(end , 0)
4941 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4942 # as geometric length increasing
4943 # @param start for the length of the first segment
4944 # @param end for the length of the last segment
4945 def StartEndLength(self, start, end):
4946 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4947 hyp.SetLength(start, 1)
4948 hyp.SetLength(end , 0)
4951 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4952 # @param fineness defines the quality of the mesh within the range [0-1]
4953 def AutomaticLength(self, fineness=0):
4954 hyp = self.OwnHypothesis("AutomaticLength")
4955 hyp.SetFineness( fineness )
4959 # Private class: Mesh_UseExisting
4960 # -------------------------------
4961 class Mesh_UseExisting(Mesh_Algorithm):
4963 def __init__(self, dim, mesh, geom=0):
4965 self.Create(mesh, geom, "UseExisting_1D")
4967 self.Create(mesh, geom, "UseExisting_2D")
4970 import salome_notebook
4971 notebook = salome_notebook.notebook
4973 ##Return values of the notebook variables
4974 def ParseParameters(last, nbParams,nbParam, value):
4978 listSize = len(last)
4979 for n in range(0,nbParams):
4981 if counter < listSize:
4982 strResult = strResult + last[counter]
4984 strResult = strResult + ""
4986 if isinstance(value, str):
4987 if notebook.isVariable(value):
4988 result = notebook.get(value)
4989 strResult=strResult+value
4991 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
4993 strResult=strResult+str(value)
4995 if nbParams - 1 != counter:
4996 strResult=strResult+var_separator #":"
4998 return result, strResult
5000 #Wrapper class for StdMeshers_LocalLength hypothesis
5001 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
5003 ## Set Length parameter value
5004 # @param length numerical value or name of variable from notebook
5005 def SetLength(self, length):
5006 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
5007 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5008 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
5010 ## Set Precision parameter value
5011 # @param precision numerical value or name of variable from notebook
5012 def SetPrecision(self, precision):
5013 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
5014 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
5015 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
5017 #Registering the new proxy for LocalLength
5018 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
5021 #Wrapper class for StdMeshers_LayerDistribution hypothesis
5022 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
5024 def SetLayerDistribution(self, hypo):
5025 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
5026 hypo.ClearParameters();
5027 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
5029 #Registering the new proxy for LayerDistribution
5030 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
5032 #Wrapper class for StdMeshers_SegmentLengthAroundVertex hypothesis
5033 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
5035 ## Set Length parameter value
5036 # @param length numerical value or name of variable from notebook
5037 def SetLength(self, length):
5038 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
5039 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
5040 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
5042 #Registering the new proxy for SegmentLengthAroundVertex
5043 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
5046 #Wrapper class for StdMeshers_Arithmetic1D hypothesis
5047 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
5049 ## Set Length parameter value
5050 # @param length numerical value or name of variable from notebook
5051 # @param isStart true is length is Start Length, otherwise false
5052 def SetLength(self, length, isStart):
5056 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
5057 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
5058 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
5060 #Registering the new proxy for Arithmetic1D
5061 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
5063 #Wrapper class for StdMeshers_Deflection1D hypothesis
5064 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
5066 ## Set Deflection parameter value
5067 # @param deflection numerical value or name of variable from notebook
5068 def SetDeflection(self, deflection):
5069 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
5070 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
5071 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
5073 #Registering the new proxy for Deflection1D
5074 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
5076 #Wrapper class for StdMeshers_StartEndLength hypothesis
5077 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
5079 ## Set Length parameter value
5080 # @param length numerical value or name of variable from notebook
5081 # @param isStart true is length is Start Length, otherwise false
5082 def SetLength(self, length, isStart):
5086 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
5087 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
5088 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
5090 #Registering the new proxy for StartEndLength
5091 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
5093 #Wrapper class for StdMeshers_MaxElementArea hypothesis
5094 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
5096 ## Set Max Element Area parameter value
5097 # @param area numerical value or name of variable from notebook
5098 def SetMaxElementArea(self, area):
5099 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
5100 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
5101 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
5103 #Registering the new proxy for MaxElementArea
5104 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
5107 #Wrapper class for StdMeshers_MaxElementVolume hypothesis
5108 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
5110 ## Set Max Element Volume parameter value
5111 # @param area numerical value or name of variable from notebook
5112 def SetMaxElementVolume(self, volume):
5113 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
5114 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
5115 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
5117 #Registering the new proxy for MaxElementVolume
5118 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
5121 #Wrapper class for StdMeshers_NumberOfLayers hypothesis
5122 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
5124 ## Set Number Of Layers parameter value
5125 # @param nbLayers numerical value or name of variable from notebook
5126 def SetNumberOfLayers(self, nbLayers):
5127 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
5128 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
5129 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
5131 #Registering the new proxy for NumberOfLayers
5132 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
5134 #Wrapper class for StdMeshers_NumberOfSegments hypothesis
5135 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
5137 ## Set Number Of Segments parameter value
5138 # @param nbSeg numerical value or name of variable from notebook
5139 def SetNumberOfSegments(self, nbSeg):
5140 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
5141 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
5142 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5143 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
5145 ## Set Scale Factor parameter value
5146 # @param factor numerical value or name of variable from notebook
5147 def SetScaleFactor(self, factor):
5148 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
5149 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
5150 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
5152 #Registering the new proxy for NumberOfSegments
5153 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
5156 #Wrapper class for NETGENPlugin_Hypothesis hypothesis
5157 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
5159 ## Set Max Size parameter value
5160 # @param maxsize numerical value or name of variable from notebook
5161 def SetMaxSize(self, maxsize):
5162 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5163 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
5164 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5165 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
5167 ## Set Growth Rate parameter value
5168 # @param value numerical value or name of variable from notebook
5169 def SetGrowthRate(self, value):
5170 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5171 value, parameters = ParseParameters(lastParameters,4,2,value)
5172 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5173 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
5175 ## Set Number of Segments per Edge parameter value
5176 # @param value numerical value or name of variable from notebook
5177 def SetNbSegPerEdge(self, value):
5178 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5179 value, parameters = ParseParameters(lastParameters,4,3,value)
5180 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5181 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
5183 ## Set Number of Segments per Radius parameter value
5184 # @param value numerical value or name of variable from notebook
5185 def SetNbSegPerRadius(self, value):
5186 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
5187 value, parameters = ParseParameters(lastParameters,4,4,value)
5188 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
5189 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
5191 #Registering the new proxy for NETGENPlugin_Hypothesis
5192 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
5195 #Wrapper class for NETGENPlugin_Hypothesis_2D hypothesis
5196 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
5199 #Registering the new proxy for NETGENPlugin_Hypothesis_2D
5200 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
5202 #Wrapper class for NETGENPlugin_SimpleHypothesis_2D hypothesis
5203 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
5205 ## Set Number of Segments parameter value
5206 # @param nbSeg numerical value or name of variable from notebook
5207 def SetNumberOfSegments(self, nbSeg):
5208 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5209 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
5210 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5211 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
5213 ## Set Local Length parameter value
5214 # @param length numerical value or name of variable from notebook
5215 def SetLocalLength(self, length):
5216 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5217 length, parameters = ParseParameters(lastParameters,2,1,length)
5218 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5219 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
5221 ## Set Max Element Area parameter value
5222 # @param area numerical value or name of variable from notebook
5223 def SetMaxElementArea(self, area):
5224 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5225 area, parameters = ParseParameters(lastParameters,2,2,area)
5226 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5227 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
5229 def LengthFromEdges(self):
5230 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
5232 value, parameters = ParseParameters(lastParameters,2,2,value)
5233 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
5234 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
5236 #Registering the new proxy for NETGEN_SimpleParameters_2D
5237 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
5240 #Wrapper class for NETGENPlugin_SimpleHypothesis_3D hypothesis
5241 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
5242 ## Set Max Element Volume parameter value
5243 # @param volume numerical value or name of variable from notebook
5244 def SetMaxElementVolume(self, volume):
5245 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5246 volume, parameters = ParseParameters(lastParameters,3,3,volume)
5247 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5248 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
5250 def LengthFromFaces(self):
5251 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
5253 value, parameters = ParseParameters(lastParameters,3,3,value)
5254 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
5255 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
5257 #Registering the new proxy for NETGEN_SimpleParameters_3D
5258 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
5260 class Pattern(SMESH._objref_SMESH_Pattern):
5262 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
5264 if isinstance(theNodeIndexOnKeyPoint1,str):
5266 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
5268 theNodeIndexOnKeyPoint1 -= 1
5269 theMesh.SetParameters(Parameters)
5270 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
5272 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
5275 if isinstance(theNode000Index,str):
5277 if isinstance(theNode001Index,str):
5279 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
5281 theNode000Index -= 1
5283 theNode001Index -= 1
5284 theMesh.SetParameters(Parameters)
5285 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
5287 #Registering the new proxy for Pattern
5288 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)