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
132 # MirrorType enumeration
133 POINT = SMESH_MeshEditor.POINT
134 AXIS = SMESH_MeshEditor.AXIS
135 PLANE = SMESH_MeshEditor.PLANE
137 # Smooth_Method enumeration
138 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
139 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
141 # Fineness enumeration (for NETGEN)
149 # Optimization level of GHS3D
150 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
152 # Topology treatment way of BLSURF
153 FromCAD, PreProcess, PreProcessPlus = 0,1,2
155 # Element size flag of BLSURF
156 DefaultSize, DefaultGeom, Custom = 0,0,1
158 PrecisionConfusion = 1e-07
160 def IsEqual(val1, val2, tol=PrecisionConfusion):
161 if abs(val1 - val2) < tol:
169 ior = salome.orb.object_to_string(obj)
170 sobj = salome.myStudy.FindObjectIOR(ior)
174 attr = sobj.FindAttribute("AttributeName")[1]
177 ## Sets a name to the object
178 def SetName(obj, name):
179 if isinstance( obj, Mesh ):
181 elif isinstance( obj, Mesh_Algorithm ):
182 obj = obj.GetAlgorithm()
183 ior = salome.orb.object_to_string(obj)
184 sobj = salome.myStudy.FindObjectIOR(ior)
186 attr = sobj.FindAttribute("AttributeName")[1]
189 ## Prints error message if a hypothesis was not assigned.
190 def TreatHypoStatus(status, hypName, geomName, isAlgo):
192 hypType = "algorithm"
194 hypType = "hypothesis"
196 if status == HYP_UNKNOWN_FATAL :
197 reason = "for unknown reason"
198 elif status == HYP_INCOMPATIBLE :
199 reason = "this hypothesis mismatches the algorithm"
200 elif status == HYP_NOTCONFORM :
201 reason = "a non-conform mesh would be built"
202 elif status == HYP_ALREADY_EXIST :
203 reason = hypType + " of the same dimension is already assigned to this shape"
204 elif status == HYP_BAD_DIM :
205 reason = hypType + " mismatches the shape"
206 elif status == HYP_CONCURENT :
207 reason = "there are concurrent hypotheses on sub-shapes"
208 elif status == HYP_BAD_SUBSHAPE :
209 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
210 elif status == HYP_BAD_GEOMETRY:
211 reason = "geometry mismatches the expectation of the algorithm"
212 elif status == HYP_HIDDEN_ALGO:
213 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
214 elif status == HYP_HIDING_ALGO:
215 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
216 elif status == HYP_NEED_SHAPE:
217 reason = "Algorithm can't work without shape"
220 hypName = '"' + hypName + '"'
221 geomName= '"' + geomName+ '"'
222 if status < HYP_UNKNOWN_FATAL:
223 print hypName, "was assigned to", geomName,"but", reason
225 print hypName, "was not assigned to",geomName,":", reason
228 ## Converts an angle from degrees to radians
229 def DegreesToRadians(AngleInDegrees):
231 return AngleInDegrees * pi / 180.0
233 # end of l1_auxiliary
236 # All methods of this class are accessible directly from the smesh.py package.
237 class smeshDC(SMESH._objref_SMESH_Gen):
239 ## Sets the current study and Geometry component
240 # @ingroup l1_auxiliary
241 def init_smesh(self,theStudy,geompyD):
242 self.SetCurrentStudy(theStudy,geompyD)
244 ## Creates an empty Mesh. This mesh can have an underlying geometry.
245 # @param obj the Geometrical object on which the mesh is built. If not defined,
246 # the mesh will have no underlying geometry.
247 # @param name the name for the new mesh.
248 # @return an instance of Mesh class.
249 # @ingroup l2_construct
250 def Mesh(self, obj=0, name=0):
251 return Mesh(self,self.geompyD,obj,name)
253 ## Returns a long value from enumeration
254 # Should be used for SMESH.FunctorType enumeration
255 # @ingroup l1_controls
256 def EnumToLong(self,theItem):
259 ## Gets PointStruct from vertex
260 # @param theVertex a GEOM object(vertex)
261 # @return SMESH.PointStruct
262 # @ingroup l1_auxiliary
263 def GetPointStruct(self,theVertex):
264 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
265 return PointStruct(x,y,z)
267 ## Gets DirStruct from vector
268 # @param theVector a GEOM object(vector)
269 # @return SMESH.DirStruct
270 # @ingroup l1_auxiliary
271 def GetDirStruct(self,theVector):
272 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
273 if(len(vertices) != 2):
274 print "Error: vector object is incorrect."
276 p1 = self.geompyD.PointCoordinates(vertices[0])
277 p2 = self.geompyD.PointCoordinates(vertices[1])
278 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
279 dirst = DirStruct(pnt)
282 ## Makes DirStruct from a triplet
283 # @param x,y,z vector components
284 # @return SMESH.DirStruct
285 # @ingroup l1_auxiliary
286 def MakeDirStruct(self,x,y,z):
287 pnt = PointStruct(x,y,z)
288 return DirStruct(pnt)
290 ## Get AxisStruct from object
291 # @param theObj a GEOM object (line or plane)
292 # @return SMESH.AxisStruct
293 # @ingroup l1_auxiliary
294 def GetAxisStruct(self,theObj):
295 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
297 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
298 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
299 vertex1 = self.geompyD.PointCoordinates(vertex1)
300 vertex2 = self.geompyD.PointCoordinates(vertex2)
301 vertex3 = self.geompyD.PointCoordinates(vertex3)
302 vertex4 = self.geompyD.PointCoordinates(vertex4)
303 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
304 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
305 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] ]
306 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
308 elif len(edges) == 1:
309 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
310 p1 = self.geompyD.PointCoordinates( vertex1 )
311 p2 = self.geompyD.PointCoordinates( vertex2 )
312 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
316 # From SMESH_Gen interface:
317 # ------------------------
319 ## Sets the current mode
320 # @ingroup l1_auxiliary
321 def SetEmbeddedMode( self,theMode ):
322 #self.SetEmbeddedMode(theMode)
323 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
325 ## Gets the current mode
326 # @ingroup l1_auxiliary
327 def IsEmbeddedMode(self):
328 #return self.IsEmbeddedMode()
329 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
331 ## Sets the current study
332 # @ingroup l1_auxiliary
333 def SetCurrentStudy( self, theStudy, geompyD = None ):
334 #self.SetCurrentStudy(theStudy)
337 geompyD = geompy.geom
340 self.SetGeomEngine(geompyD)
341 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
343 ## Gets the current study
344 # @ingroup l1_auxiliary
345 def GetCurrentStudy(self):
346 #return self.GetCurrentStudy()
347 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
349 ## Creates a Mesh object importing data from the given UNV file
350 # @return an instance of Mesh class
352 def CreateMeshesFromUNV( self,theFileName ):
353 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
354 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
357 ## Creates a Mesh object(s) importing data from the given MED file
358 # @return a list of Mesh class instances
360 def CreateMeshesFromMED( self,theFileName ):
361 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
363 for iMesh in range(len(aSmeshMeshes)) :
364 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
365 aMeshes.append(aMesh)
366 return aMeshes, aStatus
368 ## Creates a Mesh object importing data from the given STL file
369 # @return an instance of Mesh class
371 def CreateMeshesFromSTL( self, theFileName ):
372 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
373 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
376 ## Concatenate the given meshes into one mesh.
377 # @return an instance of Mesh class
378 # @param meshes the meshes to combine into one mesh
379 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
380 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
381 # @param mergeTolerance tolerance for merging nodes
382 # @param allGroups forces creation of groups of all elements
383 def Concatenate( self, meshes, uniteIdenticalGroups,
384 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
386 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
387 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
389 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
390 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
391 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
394 ## From SMESH_Gen interface
395 # @return the list of integer values
396 # @ingroup l1_auxiliary
397 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
398 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
400 ## From SMESH_Gen interface. Creates a pattern
401 # @return an instance of SMESH_Pattern
403 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
404 # @ingroup l2_modif_patterns
405 def GetPattern(self):
406 return SMESH._objref_SMESH_Gen.GetPattern(self)
409 # Filtering. Auxiliary functions:
410 # ------------------------------
412 ## Creates an empty criterion
413 # @return SMESH.Filter.Criterion
414 # @ingroup l1_controls
415 def GetEmptyCriterion(self):
416 Type = self.EnumToLong(FT_Undefined)
417 Compare = self.EnumToLong(FT_Undefined)
421 UnaryOp = self.EnumToLong(FT_Undefined)
422 BinaryOp = self.EnumToLong(FT_Undefined)
425 Precision = -1 ##@1e-07
426 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
427 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
429 ## Creates a criterion by the given parameters
430 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
431 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
432 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
433 # @param Treshold the threshold value (range of ids as string, shape, numeric)
434 # @param UnaryOp FT_LogicalNOT or FT_Undefined
435 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
436 # FT_Undefined (must be for the last criterion of all criteria)
437 # @return SMESH.Filter.Criterion
438 # @ingroup l1_controls
439 def GetCriterion(self,elementType,
441 Compare = FT_EqualTo,
443 UnaryOp=FT_Undefined,
444 BinaryOp=FT_Undefined):
445 aCriterion = self.GetEmptyCriterion()
446 aCriterion.TypeOfElement = elementType
447 aCriterion.Type = self.EnumToLong(CritType)
451 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
452 aCriterion.Compare = self.EnumToLong(Compare)
453 elif Compare == "=" or Compare == "==":
454 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
456 aCriterion.Compare = self.EnumToLong(FT_LessThan)
458 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
460 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
463 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
464 FT_BelongToCylinder, FT_LyingOnGeom]:
465 # Checks the treshold
466 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
467 aCriterion.ThresholdStr = GetName(aTreshold)
468 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
470 print "Error: The treshold should be a shape."
472 elif CritType == FT_RangeOfIds:
473 # Checks the treshold
474 if isinstance(aTreshold, str):
475 aCriterion.ThresholdStr = aTreshold
477 print "Error: The treshold should be a string."
479 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
480 # At this point the treshold is unnecessary
481 if aTreshold == FT_LogicalNOT:
482 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
483 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
484 aCriterion.BinaryOp = aTreshold
488 aTreshold = float(aTreshold)
489 aCriterion.Threshold = aTreshold
491 print "Error: The treshold should be a number."
494 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
495 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
497 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
498 aCriterion.BinaryOp = self.EnumToLong(Treshold)
500 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
501 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
503 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
504 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
508 ## Creates a filter with the given parameters
509 # @param elementType the type of elements in the group
510 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
511 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
512 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
513 # @param UnaryOp FT_LogicalNOT or FT_Undefined
514 # @return SMESH_Filter
515 # @ingroup l1_controls
516 def GetFilter(self,elementType,
517 CritType=FT_Undefined,
520 UnaryOp=FT_Undefined):
521 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
522 aFilterMgr = self.CreateFilterManager()
523 aFilter = aFilterMgr.CreateFilter()
525 aCriteria.append(aCriterion)
526 aFilter.SetCriteria(aCriteria)
529 ## Creates a numerical functor by its type
530 # @param theCriterion FT_...; functor type
531 # @return SMESH_NumericalFunctor
532 # @ingroup l1_controls
533 def GetFunctor(self,theCriterion):
534 aFilterMgr = self.CreateFilterManager()
535 if theCriterion == FT_AspectRatio:
536 return aFilterMgr.CreateAspectRatio()
537 elif theCriterion == FT_AspectRatio3D:
538 return aFilterMgr.CreateAspectRatio3D()
539 elif theCriterion == FT_Warping:
540 return aFilterMgr.CreateWarping()
541 elif theCriterion == FT_MinimumAngle:
542 return aFilterMgr.CreateMinimumAngle()
543 elif theCriterion == FT_Taper:
544 return aFilterMgr.CreateTaper()
545 elif theCriterion == FT_Skew:
546 return aFilterMgr.CreateSkew()
547 elif theCriterion == FT_Area:
548 return aFilterMgr.CreateArea()
549 elif theCriterion == FT_Volume3D:
550 return aFilterMgr.CreateVolume3D()
551 elif theCriterion == FT_MultiConnection:
552 return aFilterMgr.CreateMultiConnection()
553 elif theCriterion == FT_MultiConnection2D:
554 return aFilterMgr.CreateMultiConnection2D()
555 elif theCriterion == FT_Length:
556 return aFilterMgr.CreateLength()
557 elif theCriterion == FT_Length2D:
558 return aFilterMgr.CreateLength2D()
560 print "Error: given parameter is not numerucal functor type."
564 #Registering the new proxy for SMESH_Gen
565 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
571 ## This class allows defining and managing a mesh.
572 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
573 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
574 # new nodes and elements and by changing the existing entities), to get information
575 # about a mesh and to export a mesh into different formats.
584 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
585 # sets the GUI name of this mesh to \a name.
586 # @param smeshpyD an instance of smeshDC class
587 # @param geompyD an instance of geompyDC class
588 # @param obj Shape to be meshed or SMESH_Mesh object
589 # @param name Study name of the mesh
590 # @ingroup l2_construct
591 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
592 self.smeshpyD=smeshpyD
597 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
599 self.mesh = self.smeshpyD.CreateMesh(self.geom)
600 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
603 self.mesh = self.smeshpyD.CreateEmptyMesh()
605 SetName(self.mesh, name)
607 SetName(self.mesh, GetName(obj))
610 self.geom = self.mesh.GetShapeToMesh()
612 self.editor = self.mesh.GetMeshEditor()
614 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
615 # @param theMesh a SMESH_Mesh object
616 # @ingroup l2_construct
617 def SetMesh(self, theMesh):
619 self.geom = self.mesh.GetShapeToMesh()
621 ## Returns the mesh, that is an instance of SMESH_Mesh interface
622 # @return a SMESH_Mesh object
623 # @ingroup l2_construct
627 ## Gets the name of the mesh
628 # @return the name of the mesh as a string
629 # @ingroup l2_construct
631 name = GetName(self.GetMesh())
634 ## Sets a name to the mesh
635 # @param name a new name of the mesh
636 # @ingroup l2_construct
637 def SetName(self, name):
638 SetName(self.GetMesh(), name)
640 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
641 # The subMesh object gives access to the IDs of nodes and elements.
642 # @param theSubObject a geometrical object (shape)
643 # @param theName a name for the submesh
644 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
645 # @ingroup l2_submeshes
646 def GetSubMesh(self, theSubObject, theName):
647 submesh = self.mesh.GetSubMesh(theSubObject, theName)
650 ## Returns the shape associated to the mesh
651 # @return a GEOM_Object
652 # @ingroup l2_construct
656 ## Associates the given shape to the mesh (entails the recreation of the mesh)
657 # @param geom the shape to be meshed (GEOM_Object)
658 # @ingroup l2_construct
659 def SetShape(self, geom):
660 self.mesh = self.smeshpyD.CreateMesh(geom)
662 ## Returns true if the hypotheses are defined well
663 # @param theSubObject a subshape of a mesh shape
664 # @return True or False
665 # @ingroup l2_construct
666 def IsReadyToCompute(self, theSubObject):
667 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
669 ## Returns errors of hypotheses definition.
670 # The list of errors is empty if everything is OK.
671 # @param theSubObject a subshape of a mesh shape
672 # @return a list of errors
673 # @ingroup l2_construct
674 def GetAlgoState(self, theSubObject):
675 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
677 ## Returns a geometrical object on which the given element was built.
678 # The returned geometrical object, if not nil, is either found in the
679 # study or published by this method with the given name
680 # @param theElementID the id of the mesh element
681 # @param theGeomName the user-defined name of the geometrical object
682 # @return GEOM::GEOM_Object instance
683 # @ingroup l2_construct
684 def GetGeometryByMeshElement(self, theElementID, theGeomName):
685 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
687 ## Returns the mesh dimension depending on the dimension of the underlying shape
688 # @return mesh dimension as an integer value [0,3]
689 # @ingroup l1_auxiliary
690 def MeshDimension(self):
691 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
692 if len( shells ) > 0 :
694 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
696 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
702 ## Creates a segment discretization 1D algorithm.
703 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
704 # \n If the optional \a geom parameter is not set, this algorithm is global.
705 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
706 # @param algo the type of the required algorithm. Possible values are:
708 # - smesh.PYTHON for discretization via a python function,
709 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
710 # @param geom If defined is the subshape to be meshed
711 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
712 # @ingroup l3_algos_basic
713 def Segment(self, algo=REGULAR, geom=0):
714 ## if Segment(geom) is called by mistake
715 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
716 algo, geom = geom, algo
717 if not algo: algo = REGULAR
720 return Mesh_Segment(self, geom)
722 return Mesh_Segment_Python(self, geom)
723 elif algo == COMPOSITE:
724 return Mesh_CompositeSegment(self, geom)
726 return Mesh_Segment(self, geom)
728 ## Enables creation of nodes and segments usable by 2D algoritms.
729 # The added nodes and segments must be bound to edges and vertices by
730 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
731 # If the optional \a geom parameter is not set, this algorithm is global.
732 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
733 # @param geom the subshape to be manually meshed
734 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
735 # @ingroup l3_algos_basic
736 def UseExistingSegments(self, geom=0):
737 algo = Mesh_UseExisting(1,self,geom)
738 return algo.GetAlgorithm()
740 ## Enables creation of nodes and faces usable by 3D algoritms.
741 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
742 # and SetMeshElementOnShape()
743 # If the optional \a geom parameter is not set, this algorithm is global.
744 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
745 # @param geom the subshape to be manually meshed
746 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
747 # @ingroup l3_algos_basic
748 def UseExistingFaces(self, geom=0):
749 algo = Mesh_UseExisting(2,self,geom)
750 return algo.GetAlgorithm()
752 ## Creates a triangle 2D algorithm for faces.
753 # If the optional \a geom parameter is not set, this algorithm is global.
754 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
755 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
756 # @param geom If defined, the subshape to be meshed (GEOM_Object)
757 # @return an instance of Mesh_Triangle algorithm
758 # @ingroup l3_algos_basic
759 def Triangle(self, algo=MEFISTO, geom=0):
760 ## if Triangle(geom) is called by mistake
761 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
765 return Mesh_Triangle(self, algo, geom)
767 ## Creates a quadrangle 2D algorithm for faces.
768 # If the optional \a geom parameter is not set, this algorithm is global.
769 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
770 # @param geom If defined, the subshape to be meshed (GEOM_Object)
771 # @return an instance of Mesh_Quadrangle algorithm
772 # @ingroup l3_algos_basic
773 def Quadrangle(self, geom=0):
774 return Mesh_Quadrangle(self, geom)
776 ## Creates a tetrahedron 3D algorithm for solids.
777 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
778 # If the optional \a geom parameter is not set, this algorithm is global.
779 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
780 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
781 # @param geom If defined, the subshape to be meshed (GEOM_Object)
782 # @return an instance of Mesh_Tetrahedron algorithm
783 # @ingroup l3_algos_basic
784 def Tetrahedron(self, algo=NETGEN, geom=0):
785 ## if Tetrahedron(geom) is called by mistake
786 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
787 algo, geom = geom, algo
788 if not algo: algo = NETGEN
790 return Mesh_Tetrahedron(self, algo, geom)
792 ## Creates a hexahedron 3D algorithm for solids.
793 # If the optional \a geom parameter is not set, this algorithm is global.
794 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
795 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
796 # @param geom If defined, the subshape to be meshed (GEOM_Object)
797 # @return an instance of Mesh_Hexahedron algorithm
798 # @ingroup l3_algos_basic
799 def Hexahedron(self, algo=Hexa, geom=0):
800 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
801 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
802 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
803 elif geom == 0: algo, geom = Hexa, algo
804 return Mesh_Hexahedron(self, algo, geom)
806 ## Deprecated, used only for compatibility!
807 # @return an instance of Mesh_Netgen algorithm
808 # @ingroup l3_algos_basic
809 def Netgen(self, is3D, geom=0):
810 return Mesh_Netgen(self, is3D, geom)
812 ## Creates a projection 1D algorithm for edges.
813 # If the optional \a geom parameter is not set, this algorithm is global.
814 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
815 # @param geom If defined, the subshape to be meshed
816 # @return an instance of Mesh_Projection1D algorithm
817 # @ingroup l3_algos_proj
818 def Projection1D(self, geom=0):
819 return Mesh_Projection1D(self, geom)
821 ## Creates a projection 2D algorithm for faces.
822 # If the optional \a geom parameter is not set, this algorithm is global.
823 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
824 # @param geom If defined, the subshape to be meshed
825 # @return an instance of Mesh_Projection2D algorithm
826 # @ingroup l3_algos_proj
827 def Projection2D(self, geom=0):
828 return Mesh_Projection2D(self, geom)
830 ## Creates a projection 3D algorithm for solids.
831 # If the optional \a geom parameter is not set, this algorithm is global.
832 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
833 # @param geom If defined, the subshape to be meshed
834 # @return an instance of Mesh_Projection3D algorithm
835 # @ingroup l3_algos_proj
836 def Projection3D(self, geom=0):
837 return Mesh_Projection3D(self, geom)
839 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
840 # If the optional \a geom parameter is not set, this algorithm is global.
841 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
842 # @param geom If defined, the subshape to be meshed
843 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
844 # @ingroup l3_algos_radialp l3_algos_3dextr
845 def Prism(self, geom=0):
849 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
850 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
851 if nbSolids == 0 or nbSolids == nbShells:
852 return Mesh_Prism3D(self, geom)
853 return Mesh_RadialPrism3D(self, geom)
855 ## Computes the mesh and returns the status of the computation
856 # @return True or False
857 # @ingroup l2_construct
858 def Compute(self, geom=0):
859 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
861 geom = self.mesh.GetShapeToMesh()
866 ok = self.smeshpyD.Compute(self.mesh, geom)
867 except SALOME.SALOME_Exception, ex:
868 print "Mesh computation failed, exception caught:"
869 print " ", ex.details.text
872 print "Mesh computation failed, exception caught:"
873 traceback.print_exc()
875 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
886 reason = '%s %sD algorithm is missing' % (glob, dim)
887 elif err.state == HYP_MISSING:
888 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
889 % (glob, dim, name, dim))
890 elif err.state == HYP_NOTCONFORM:
891 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
892 elif err.state == HYP_BAD_PARAMETER:
893 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
894 % ( glob, dim, name ))
895 elif err.state == HYP_BAD_GEOMETRY:
896 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
897 'geometry' % ( glob, dim, name ))
899 reason = "For unknown reason."+\
900 " Revise Mesh.Compute() implementation in smeshDC.py!"
908 print '"' + GetName(self.mesh) + '"',"has not been computed:"
912 print '"' + GetName(self.mesh) + '"',"has not been computed."
915 if salome.sg.hasDesktop():
916 smeshgui = salome.ImportComponentGUI("SMESH")
917 smeshgui.Init(salome.myStudyId)
918 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
919 salome.sg.updateObjBrowser(1)
923 ## Removes all nodes and elements
924 # @ingroup l2_construct
927 if salome.sg.hasDesktop():
928 smeshgui = salome.ImportComponentGUI("SMESH")
929 smeshgui.Init(salome.myStudyId)
930 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
931 salome.sg.updateObjBrowser(1)
933 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
934 # @param fineness [0,-1] defines mesh fineness
935 # @return True or False
936 # @ingroup l3_algos_basic
937 def AutomaticTetrahedralization(self, fineness=0):
938 dim = self.MeshDimension()
940 self.RemoveGlobalHypotheses()
941 self.Segment().AutomaticLength(fineness)
943 self.Triangle().LengthFromEdges()
946 self.Tetrahedron(NETGEN)
948 return self.Compute()
950 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
951 # @param fineness [0,-1] defines mesh fineness
952 # @return True or False
953 # @ingroup l3_algos_basic
954 def AutomaticHexahedralization(self, fineness=0):
955 dim = self.MeshDimension()
956 # assign the hypotheses
957 self.RemoveGlobalHypotheses()
958 self.Segment().AutomaticLength(fineness)
965 return self.Compute()
967 ## Assigns a hypothesis
968 # @param hyp a hypothesis to assign
969 # @param geom a subhape of mesh geometry
970 # @return SMESH.Hypothesis_Status
971 # @ingroup l2_hypotheses
972 def AddHypothesis(self, hyp, geom=0):
973 if isinstance( hyp, Mesh_Algorithm ):
974 hyp = hyp.GetAlgorithm()
979 geom = self.mesh.GetShapeToMesh()
981 status = self.mesh.AddHypothesis(geom, hyp)
982 isAlgo = hyp._narrow( SMESH_Algo )
983 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
986 ## Unassigns a hypothesis
987 # @param hyp a hypothesis to unassign
988 # @param geom a subshape of mesh geometry
989 # @return SMESH.Hypothesis_Status
990 # @ingroup l2_hypotheses
991 def RemoveHypothesis(self, hyp, geom=0):
992 if isinstance( hyp, Mesh_Algorithm ):
993 hyp = hyp.GetAlgorithm()
998 status = self.mesh.RemoveHypothesis(geom, hyp)
1001 ## Gets the list of hypotheses added on a geometry
1002 # @param geom a subshape of mesh geometry
1003 # @return the sequence of SMESH_Hypothesis
1004 # @ingroup l2_hypotheses
1005 def GetHypothesisList(self, geom):
1006 return self.mesh.GetHypothesisList( geom )
1008 ## Removes all global hypotheses
1009 # @ingroup l2_hypotheses
1010 def RemoveGlobalHypotheses(self):
1011 current_hyps = self.mesh.GetHypothesisList( self.geom )
1012 for hyp in current_hyps:
1013 self.mesh.RemoveHypothesis( self.geom, hyp )
1017 ## Creates a mesh group based on the geometric object \a grp
1018 # and gives a \a name, \n if this parameter is not defined
1019 # the name is the same as the geometric group name \n
1020 # Note: Works like GroupOnGeom().
1021 # @param grp a geometric group, a vertex, an edge, a face or a solid
1022 # @param name the name of the mesh group
1023 # @return SMESH_GroupOnGeom
1024 # @ingroup l2_grps_create
1025 def Group(self, grp, name=""):
1026 return self.GroupOnGeom(grp, name)
1028 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1029 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1030 # @param f the file name
1031 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1032 # @ingroup l2_impexp
1033 def ExportToMED(self, f, version, opt=0):
1034 self.mesh.ExportToMED(f, opt, version)
1036 ## Exports the mesh in a file in MED format
1037 # @param f is the file name
1038 # @param auto_groups boolean parameter for creating/not creating
1039 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1040 # the typical use is auto_groups=false.
1041 # @param version MED format version(MED_V2_1 or MED_V2_2)
1042 # @ingroup l2_impexp
1043 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1044 self.mesh.ExportToMED(f, auto_groups, version)
1046 ## Exports the mesh in a file in DAT format
1047 # @param f the file name
1048 # @ingroup l2_impexp
1049 def ExportDAT(self, f):
1050 self.mesh.ExportDAT(f)
1052 ## Exports the mesh in a file in UNV format
1053 # @param f the file name
1054 # @ingroup l2_impexp
1055 def ExportUNV(self, f):
1056 self.mesh.ExportUNV(f)
1058 ## Export the mesh in a file in STL format
1059 # @param f the file name
1060 # @param ascii defines the file encoding
1061 # @ingroup l2_impexp
1062 def ExportSTL(self, f, ascii=1):
1063 self.mesh.ExportSTL(f, ascii)
1066 # Operations with groups:
1067 # ----------------------
1069 ## Creates an empty mesh group
1070 # @param elementType the type of elements in the group
1071 # @param name the name of the mesh group
1072 # @return SMESH_Group
1073 # @ingroup l2_grps_create
1074 def CreateEmptyGroup(self, elementType, name):
1075 return self.mesh.CreateGroup(elementType, name)
1077 ## Creates a mesh group based on the geometrical object \a grp
1078 # and gives a \a name, \n if this parameter is not defined
1079 # the name is the same as the geometrical group name
1080 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1081 # @param name the name of the mesh group
1082 # @param typ the type of elements in the group. If not set, it is
1083 # automatically detected by the type of the geometry
1084 # @return SMESH_GroupOnGeom
1085 # @ingroup l2_grps_create
1086 def GroupOnGeom(self, grp, name="", typ=None):
1088 name = grp.GetName()
1091 tgeo = str(grp.GetShapeType())
1092 if tgeo == "VERTEX":
1094 elif tgeo == "EDGE":
1096 elif tgeo == "FACE":
1098 elif tgeo == "SOLID":
1100 elif tgeo == "SHELL":
1102 elif tgeo == "COMPOUND":
1103 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1104 print "Mesh.Group: empty geometric group", GetName( grp )
1106 tgeo = self.geompyD.GetType(grp)
1107 if tgeo == geompyDC.ShapeType["VERTEX"]:
1109 elif tgeo == geompyDC.ShapeType["EDGE"]:
1111 elif tgeo == geompyDC.ShapeType["FACE"]:
1113 elif tgeo == geompyDC.ShapeType["SOLID"]:
1117 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1120 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1122 ## Creates a mesh group by the given ids of elements
1123 # @param groupName the name of the mesh group
1124 # @param elementType the type of elements in the group
1125 # @param elemIDs the list of ids
1126 # @return SMESH_Group
1127 # @ingroup l2_grps_create
1128 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1129 group = self.mesh.CreateGroup(elementType, groupName)
1133 ## Creates a mesh group by the given conditions
1134 # @param groupName the name of the mesh group
1135 # @param elementType the type of elements in the group
1136 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1137 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1138 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1139 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1140 # @return SMESH_Group
1141 # @ingroup l2_grps_create
1145 CritType=FT_Undefined,
1148 UnaryOp=FT_Undefined):
1149 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1150 group = self.MakeGroupByCriterion(groupName, aCriterion)
1153 ## Creates a mesh group by the given criterion
1154 # @param groupName the name of the mesh group
1155 # @param Criterion the instance of Criterion class
1156 # @return SMESH_Group
1157 # @ingroup l2_grps_create
1158 def MakeGroupByCriterion(self, groupName, Criterion):
1159 aFilterMgr = self.smeshpyD.CreateFilterManager()
1160 aFilter = aFilterMgr.CreateFilter()
1162 aCriteria.append(Criterion)
1163 aFilter.SetCriteria(aCriteria)
1164 group = self.MakeGroupByFilter(groupName, aFilter)
1167 ## Creates a mesh group by the given criteria (list of criteria)
1168 # @param groupName the name of the mesh group
1169 # @param theCriteria the list of criteria
1170 # @return SMESH_Group
1171 # @ingroup l2_grps_create
1172 def MakeGroupByCriteria(self, groupName, theCriteria):
1173 aFilterMgr = self.smeshpyD.CreateFilterManager()
1174 aFilter = aFilterMgr.CreateFilter()
1175 aFilter.SetCriteria(theCriteria)
1176 group = self.MakeGroupByFilter(groupName, aFilter)
1179 ## Creates a mesh group by the given filter
1180 # @param groupName the name of the mesh group
1181 # @param theFilter the instance of Filter class
1182 # @return SMESH_Group
1183 # @ingroup l2_grps_create
1184 def MakeGroupByFilter(self, groupName, theFilter):
1185 anIds = theFilter.GetElementsId(self.mesh)
1186 anElemType = theFilter.GetElementType()
1187 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1190 ## Passes mesh elements through the given filter and return IDs of fitting elements
1191 # @param theFilter SMESH_Filter
1192 # @return a list of ids
1193 # @ingroup l1_controls
1194 def GetIdsFromFilter(self, theFilter):
1195 return theFilter.GetElementsId(self.mesh)
1197 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1198 # Returns a list of special structures (borders).
1199 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1200 # @ingroup l1_controls
1201 def GetFreeBorders(self):
1202 aFilterMgr = self.smeshpyD.CreateFilterManager()
1203 aPredicate = aFilterMgr.CreateFreeEdges()
1204 aPredicate.SetMesh(self.mesh)
1205 aBorders = aPredicate.GetBorders()
1209 # @ingroup l2_grps_delete
1210 def RemoveGroup(self, group):
1211 self.mesh.RemoveGroup(group)
1213 ## Removes a group with its contents
1214 # @ingroup l2_grps_delete
1215 def RemoveGroupWithContents(self, group):
1216 self.mesh.RemoveGroupWithContents(group)
1218 ## Gets the list of groups existing in the mesh
1219 # @return a sequence of SMESH_GroupBase
1220 # @ingroup l2_grps_create
1221 def GetGroups(self):
1222 return self.mesh.GetGroups()
1224 ## Gets the number of groups existing in the mesh
1225 # @return the quantity of groups as an integer value
1226 # @ingroup l2_grps_create
1228 return self.mesh.NbGroups()
1230 ## Gets the list of names of groups existing in the mesh
1231 # @return list of strings
1232 # @ingroup l2_grps_create
1233 def GetGroupNames(self):
1234 groups = self.GetGroups()
1236 for group in groups:
1237 names.append(group.GetName())
1240 ## Produces a union of two groups
1241 # A new group is created. All mesh elements that are
1242 # present in the initial groups are added to the new one
1243 # @return an instance of SMESH_Group
1244 # @ingroup l2_grps_operon
1245 def UnionGroups(self, group1, group2, name):
1246 return self.mesh.UnionGroups(group1, group2, name)
1248 ## Prodices an intersection of two groups
1249 # A new group is created. All mesh elements that are common
1250 # for the two initial groups are added to the new one.
1251 # @return an instance of SMESH_Group
1252 # @ingroup l2_grps_operon
1253 def IntersectGroups(self, group1, group2, name):
1254 return self.mesh.IntersectGroups(group1, group2, name)
1256 ## Produces a cut of two groups
1257 # A new group is created. All mesh elements that are present in
1258 # the main group but are not present in the tool group are added to the new one
1259 # @return an instance of SMESH_Group
1260 # @ingroup l2_grps_operon
1261 def CutGroups(self, mainGroup, toolGroup, name):
1262 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1265 # Get some info about mesh:
1266 # ------------------------
1268 ## Returns the log of nodes and elements added or removed
1269 # since the previous clear of the log.
1270 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1271 # @return list of log_block structures:
1276 # @ingroup l1_auxiliary
1277 def GetLog(self, clearAfterGet):
1278 return self.mesh.GetLog(clearAfterGet)
1280 ## Clears the log of nodes and elements added or removed since the previous
1281 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1282 # @ingroup l1_auxiliary
1284 self.mesh.ClearLog()
1286 ## Toggles auto color mode on the object.
1287 # @param theAutoColor the flag which toggles auto color mode.
1288 # @ingroup l1_auxiliary
1289 def SetAutoColor(self, theAutoColor):
1290 self.mesh.SetAutoColor(theAutoColor)
1292 ## Gets flag of object auto color mode.
1293 # @return True or False
1294 # @ingroup l1_auxiliary
1295 def GetAutoColor(self):
1296 return self.mesh.GetAutoColor()
1298 ## Gets the internal ID
1299 # @return integer value, which is the internal Id of the mesh
1300 # @ingroup l1_auxiliary
1302 return self.mesh.GetId()
1305 # @return integer value, which is the study Id of the mesh
1306 # @ingroup l1_auxiliary
1307 def GetStudyId(self):
1308 return self.mesh.GetStudyId()
1310 ## Checks the group names for duplications.
1311 # Consider the maximum group name length stored in MED file.
1312 # @return True or False
1313 # @ingroup l1_auxiliary
1314 def HasDuplicatedGroupNamesMED(self):
1315 return self.mesh.HasDuplicatedGroupNamesMED()
1317 ## Obtains the mesh editor tool
1318 # @return an instance of SMESH_MeshEditor
1319 # @ingroup l1_modifying
1320 def GetMeshEditor(self):
1321 return self.mesh.GetMeshEditor()
1324 # @return an instance of SALOME_MED::MESH
1325 # @ingroup l1_auxiliary
1326 def GetMEDMesh(self):
1327 return self.mesh.GetMEDMesh()
1330 # Get informations about mesh contents:
1331 # ------------------------------------
1333 ## Returns the number of nodes in the mesh
1334 # @return an integer value
1335 # @ingroup l1_meshinfo
1337 return self.mesh.NbNodes()
1339 ## Returns the number of elements in the mesh
1340 # @return an integer value
1341 # @ingroup l1_meshinfo
1342 def NbElements(self):
1343 return self.mesh.NbElements()
1345 ## Returns the number of edges in the mesh
1346 # @return an integer value
1347 # @ingroup l1_meshinfo
1349 return self.mesh.NbEdges()
1351 ## Returns the number of edges with the given order in the mesh
1352 # @param elementOrder the order of elements:
1353 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1354 # @return an integer value
1355 # @ingroup l1_meshinfo
1356 def NbEdgesOfOrder(self, elementOrder):
1357 return self.mesh.NbEdgesOfOrder(elementOrder)
1359 ## Returns the number of faces in the mesh
1360 # @return an integer value
1361 # @ingroup l1_meshinfo
1363 return self.mesh.NbFaces()
1365 ## Returns the number of faces with the given order in the mesh
1366 # @param elementOrder the order of elements:
1367 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1368 # @return an integer value
1369 # @ingroup l1_meshinfo
1370 def NbFacesOfOrder(self, elementOrder):
1371 return self.mesh.NbFacesOfOrder(elementOrder)
1373 ## Returns the number of triangles in the mesh
1374 # @return an integer value
1375 # @ingroup l1_meshinfo
1376 def NbTriangles(self):
1377 return self.mesh.NbTriangles()
1379 ## Returns the number of triangles with the given order in the mesh
1380 # @param elementOrder is the order of elements:
1381 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1382 # @return an integer value
1383 # @ingroup l1_meshinfo
1384 def NbTrianglesOfOrder(self, elementOrder):
1385 return self.mesh.NbTrianglesOfOrder(elementOrder)
1387 ## Returns the number of quadrangles in the mesh
1388 # @return an integer value
1389 # @ingroup l1_meshinfo
1390 def NbQuadrangles(self):
1391 return self.mesh.NbQuadrangles()
1393 ## Returns the number of quadrangles with the given order in the mesh
1394 # @param elementOrder the order of elements:
1395 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1396 # @return an integer value
1397 # @ingroup l1_meshinfo
1398 def NbQuadranglesOfOrder(self, elementOrder):
1399 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1401 ## Returns the number of polygons in the mesh
1402 # @return an integer value
1403 # @ingroup l1_meshinfo
1404 def NbPolygons(self):
1405 return self.mesh.NbPolygons()
1407 ## Returns the number of volumes in the mesh
1408 # @return an integer value
1409 # @ingroup l1_meshinfo
1410 def NbVolumes(self):
1411 return self.mesh.NbVolumes()
1413 ## Returns the number of volumes with the given order in the mesh
1414 # @param elementOrder the order of elements:
1415 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1416 # @return an integer value
1417 # @ingroup l1_meshinfo
1418 def NbVolumesOfOrder(self, elementOrder):
1419 return self.mesh.NbVolumesOfOrder(elementOrder)
1421 ## Returns the number of tetrahedrons in the mesh
1422 # @return an integer value
1423 # @ingroup l1_meshinfo
1425 return self.mesh.NbTetras()
1427 ## Returns the number of tetrahedrons with the given order in the mesh
1428 # @param elementOrder the order of elements:
1429 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1430 # @return an integer value
1431 # @ingroup l1_meshinfo
1432 def NbTetrasOfOrder(self, elementOrder):
1433 return self.mesh.NbTetrasOfOrder(elementOrder)
1435 ## Returns the number of hexahedrons in the mesh
1436 # @return an integer value
1437 # @ingroup l1_meshinfo
1439 return self.mesh.NbHexas()
1441 ## Returns the number of hexahedrons with the given order in the mesh
1442 # @param elementOrder the order of elements:
1443 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1444 # @return an integer value
1445 # @ingroup l1_meshinfo
1446 def NbHexasOfOrder(self, elementOrder):
1447 return self.mesh.NbHexasOfOrder(elementOrder)
1449 ## Returns the number of pyramids in the mesh
1450 # @return an integer value
1451 # @ingroup l1_meshinfo
1452 def NbPyramids(self):
1453 return self.mesh.NbPyramids()
1455 ## Returns the number of pyramids with the given order in the mesh
1456 # @param elementOrder the order of elements:
1457 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1458 # @return an integer value
1459 # @ingroup l1_meshinfo
1460 def NbPyramidsOfOrder(self, elementOrder):
1461 return self.mesh.NbPyramidsOfOrder(elementOrder)
1463 ## Returns the number of prisms in the mesh
1464 # @return an integer value
1465 # @ingroup l1_meshinfo
1467 return self.mesh.NbPrisms()
1469 ## Returns the number of prisms with the given order in the mesh
1470 # @param elementOrder the order of elements:
1471 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1472 # @return an integer value
1473 # @ingroup l1_meshinfo
1474 def NbPrismsOfOrder(self, elementOrder):
1475 return self.mesh.NbPrismsOfOrder(elementOrder)
1477 ## Returns the number of polyhedrons in the mesh
1478 # @return an integer value
1479 # @ingroup l1_meshinfo
1480 def NbPolyhedrons(self):
1481 return self.mesh.NbPolyhedrons()
1483 ## Returns the number of submeshes in the mesh
1484 # @return an integer value
1485 # @ingroup l1_meshinfo
1486 def NbSubMesh(self):
1487 return self.mesh.NbSubMesh()
1489 ## Returns the list of mesh elements IDs
1490 # @return the list of integer values
1491 # @ingroup l1_meshinfo
1492 def GetElementsId(self):
1493 return self.mesh.GetElementsId()
1495 ## Returns the list of IDs of mesh elements with the given type
1496 # @param elementType the required type of elements
1497 # @return list of integer values
1498 # @ingroup l1_meshinfo
1499 def GetElementsByType(self, elementType):
1500 return self.mesh.GetElementsByType(elementType)
1502 ## Returns the list of mesh nodes IDs
1503 # @return the list of integer values
1504 # @ingroup l1_meshinfo
1505 def GetNodesId(self):
1506 return self.mesh.GetNodesId()
1508 # Get the information about mesh elements:
1509 # ------------------------------------
1511 ## Returns the type of mesh element
1512 # @return the value from SMESH::ElementType enumeration
1513 # @ingroup l1_meshinfo
1514 def GetElementType(self, id, iselem):
1515 return self.mesh.GetElementType(id, iselem)
1517 ## Returns the list of submesh elements IDs
1518 # @param Shape a geom object(subshape) IOR
1519 # Shape must be the subshape of a ShapeToMesh()
1520 # @return the list of integer values
1521 # @ingroup l1_meshinfo
1522 def GetSubMeshElementsId(self, Shape):
1523 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1524 ShapeID = Shape.GetSubShapeIndices()[0]
1527 return self.mesh.GetSubMeshElementsId(ShapeID)
1529 ## Returns the list of submesh nodes IDs
1530 # @param Shape a geom object(subshape) IOR
1531 # Shape must be the subshape of a ShapeToMesh()
1532 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1533 # @return the list of integer values
1534 # @ingroup l1_meshinfo
1535 def GetSubMeshNodesId(self, Shape, all):
1536 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1537 ShapeID = Shape.GetSubShapeIndices()[0]
1540 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1542 ## Returns the list of IDs of submesh elements with the given type
1543 # @param Shape a geom object(subshape) IOR
1544 # Shape must be a subshape of a ShapeToMesh()
1545 # @return the list of integer values
1546 # @ingroup l1_meshinfo
1547 def GetSubMeshElementType(self, Shape):
1548 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1549 ShapeID = Shape.GetSubShapeIndices()[0]
1552 return self.mesh.GetSubMeshElementType(ShapeID)
1554 ## Gets the mesh description
1555 # @return string value
1556 # @ingroup l1_meshinfo
1558 return self.mesh.Dump()
1561 # Get the information about nodes and elements of a mesh by its IDs:
1562 # -----------------------------------------------------------
1564 ## Gets XYZ coordinates of a node
1565 # \n If there is no nodes for the given ID - returns an empty list
1566 # @return a list of double precision values
1567 # @ingroup l1_meshinfo
1568 def GetNodeXYZ(self, id):
1569 return self.mesh.GetNodeXYZ(id)
1571 ## Returns list of IDs of inverse elements for the given node
1572 # \n If there is no node for the given ID - returns an empty list
1573 # @return a list of integer values
1574 # @ingroup l1_meshinfo
1575 def GetNodeInverseElements(self, id):
1576 return self.mesh.GetNodeInverseElements(id)
1578 ## @brief Returns the position of a node on the shape
1579 # @return SMESH::NodePosition
1580 # @ingroup l1_meshinfo
1581 def GetNodePosition(self,NodeID):
1582 return self.mesh.GetNodePosition(NodeID)
1584 ## If the given element is a node, returns the ID of shape
1585 # \n If there is no node for the given ID - returns -1
1586 # @return an integer value
1587 # @ingroup l1_meshinfo
1588 def GetShapeID(self, id):
1589 return self.mesh.GetShapeID(id)
1591 ## Returns the ID of the result shape after
1592 # FindShape() from SMESH_MeshEditor for the given element
1593 # \n If there is no element for the given ID - returns -1
1594 # @return an integer value
1595 # @ingroup l1_meshinfo
1596 def GetShapeIDForElem(self,id):
1597 return self.mesh.GetShapeIDForElem(id)
1599 ## Returns the number of nodes for the given element
1600 # \n If there is no element for the given ID - returns -1
1601 # @return an integer value
1602 # @ingroup l1_meshinfo
1603 def GetElemNbNodes(self, id):
1604 return self.mesh.GetElemNbNodes(id)
1606 ## Returns the node ID the given index for the given element
1607 # \n If there is no element for the given ID - returns -1
1608 # \n If there is no node for the given index - returns -2
1609 # @return an integer value
1610 # @ingroup l1_meshinfo
1611 def GetElemNode(self, id, index):
1612 return self.mesh.GetElemNode(id, index)
1614 ## Returns the IDs of nodes of the given element
1615 # @return a list of integer values
1616 # @ingroup l1_meshinfo
1617 def GetElemNodes(self, id):
1618 return self.mesh.GetElemNodes(id)
1620 ## Returns true if the given node is the medium node in the given quadratic element
1621 # @ingroup l1_meshinfo
1622 def IsMediumNode(self, elementID, nodeID):
1623 return self.mesh.IsMediumNode(elementID, nodeID)
1625 ## Returns true if the given node is the medium node in one of quadratic elements
1626 # @ingroup l1_meshinfo
1627 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1628 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1630 ## Returns the number of edges for the given element
1631 # @ingroup l1_meshinfo
1632 def ElemNbEdges(self, id):
1633 return self.mesh.ElemNbEdges(id)
1635 ## Returns the number of faces for the given element
1636 # @ingroup l1_meshinfo
1637 def ElemNbFaces(self, id):
1638 return self.mesh.ElemNbFaces(id)
1640 ## Returns true if the given element is a polygon
1641 # @ingroup l1_meshinfo
1642 def IsPoly(self, id):
1643 return self.mesh.IsPoly(id)
1645 ## Returns true if the given element is quadratic
1646 # @ingroup l1_meshinfo
1647 def IsQuadratic(self, id):
1648 return self.mesh.IsQuadratic(id)
1650 ## Returns XYZ coordinates of the barycenter of the given element
1651 # \n If there is no element for the given ID - returns an empty list
1652 # @return a list of three double values
1653 # @ingroup l1_meshinfo
1654 def BaryCenter(self, id):
1655 return self.mesh.BaryCenter(id)
1658 # Mesh edition (SMESH_MeshEditor functionality):
1659 # ---------------------------------------------
1661 ## Removes the elements from the mesh by ids
1662 # @param IDsOfElements is a list of ids of elements to remove
1663 # @return True or False
1664 # @ingroup l2_modif_del
1665 def RemoveElements(self, IDsOfElements):
1666 return self.editor.RemoveElements(IDsOfElements)
1668 ## Removes nodes from mesh by ids
1669 # @param IDsOfNodes is a list of ids of nodes to remove
1670 # @return True or False
1671 # @ingroup l2_modif_del
1672 def RemoveNodes(self, IDsOfNodes):
1673 return self.editor.RemoveNodes(IDsOfNodes)
1675 ## Add a node to the mesh by coordinates
1676 # @return Id of the new node
1677 # @ingroup l2_modif_add
1678 def AddNode(self, x, y, z):
1679 return self.editor.AddNode( x, y, z)
1681 ## Creates a linear or quadratic edge (this is determined
1682 # by the number of given nodes).
1683 # @param IDsOfNodes the list of node IDs for creation of the element.
1684 # The order of nodes in this list should correspond to the description
1685 # of MED. \n This description is located by the following link:
1686 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1687 # @return the Id of the new edge
1688 # @ingroup l2_modif_add
1689 def AddEdge(self, IDsOfNodes):
1690 return self.editor.AddEdge(IDsOfNodes)
1692 ## Creates a linear or quadratic face (this is determined
1693 # by the number of given nodes).
1694 # @param IDsOfNodes the list of node IDs for creation of the element.
1695 # The order of nodes in this list should correspond to the description
1696 # of MED. \n This description is located by the following link:
1697 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1698 # @return the Id of the new face
1699 # @ingroup l2_modif_add
1700 def AddFace(self, IDsOfNodes):
1701 return self.editor.AddFace(IDsOfNodes)
1703 ## Adds a polygonal face to the mesh by the list of node IDs
1704 # @param IdsOfNodes the list of node IDs for creation of the element.
1705 # @return the Id of the new face
1706 # @ingroup l2_modif_add
1707 def AddPolygonalFace(self, IdsOfNodes):
1708 return self.editor.AddPolygonalFace(IdsOfNodes)
1710 ## Creates both simple and quadratic volume (this is determined
1711 # by the number of given nodes).
1712 # @param IDsOfNodes the list of node IDs for creation of the element.
1713 # The order of nodes in this list should correspond to the description
1714 # of MED. \n This description is located by the following link:
1715 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1716 # @return the Id of the new volumic element
1717 # @ingroup l2_modif_add
1718 def AddVolume(self, IDsOfNodes):
1719 return self.editor.AddVolume(IDsOfNodes)
1721 ## Creates a volume of many faces, giving nodes for each face.
1722 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1723 # @param Quantities the list of integer values, Quantities[i]
1724 # gives the quantity of nodes in face number i.
1725 # @return the Id of the new volumic element
1726 # @ingroup l2_modif_add
1727 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1728 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1730 ## Creates a volume of many faces, giving the IDs of the existing faces.
1731 # @param IdsOfFaces the list of face IDs for volume creation.
1733 # Note: The created volume will refer only to the nodes
1734 # of the given faces, not to the faces themselves.
1735 # @return the Id of the new volumic element
1736 # @ingroup l2_modif_add
1737 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1738 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1741 ## @brief Binds a node to a vertex
1742 # @param NodeID a node ID
1743 # @param Vertex a vertex or vertex ID
1744 # @return True if succeed else raises an exception
1745 # @ingroup l2_modif_add
1746 def SetNodeOnVertex(self, NodeID, Vertex):
1747 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1748 VertexID = Vertex.GetSubShapeIndices()[0]
1752 self.editor.SetNodeOnVertex(NodeID, VertexID)
1753 except SALOME.SALOME_Exception, inst:
1754 raise ValueError, inst.details.text
1758 ## @brief Stores the node position on an edge
1759 # @param NodeID a node ID
1760 # @param Edge an edge or edge ID
1761 # @param paramOnEdge a parameter on the edge where the node is located
1762 # @return True if succeed else raises an exception
1763 # @ingroup l2_modif_add
1764 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1765 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1766 EdgeID = Edge.GetSubShapeIndices()[0]
1770 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1771 except SALOME.SALOME_Exception, inst:
1772 raise ValueError, inst.details.text
1775 ## @brief Stores node position on a face
1776 # @param NodeID a node ID
1777 # @param Face a face or face ID
1778 # @param u U parameter on the face where the node is located
1779 # @param v V parameter on the face where the node is located
1780 # @return True if succeed else raises an exception
1781 # @ingroup l2_modif_add
1782 def SetNodeOnFace(self, NodeID, Face, u, v):
1783 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1784 FaceID = Face.GetSubShapeIndices()[0]
1788 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1789 except SALOME.SALOME_Exception, inst:
1790 raise ValueError, inst.details.text
1793 ## @brief Binds a node to a solid
1794 # @param NodeID a node ID
1795 # @param Solid a solid or solid ID
1796 # @return True if succeed else raises an exception
1797 # @ingroup l2_modif_add
1798 def SetNodeInVolume(self, NodeID, Solid):
1799 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1800 SolidID = Solid.GetSubShapeIndices()[0]
1804 self.editor.SetNodeInVolume(NodeID, SolidID)
1805 except SALOME.SALOME_Exception, inst:
1806 raise ValueError, inst.details.text
1809 ## @brief Bind an element to a shape
1810 # @param ElementID an element ID
1811 # @param Shape a shape or shape ID
1812 # @return True if succeed else raises an exception
1813 # @ingroup l2_modif_add
1814 def SetMeshElementOnShape(self, ElementID, Shape):
1815 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1816 ShapeID = Shape.GetSubShapeIndices()[0]
1820 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1821 except SALOME.SALOME_Exception, inst:
1822 raise ValueError, inst.details.text
1826 ## Moves the node with the given id
1827 # @param NodeID the id of the node
1828 # @param x a new X coordinate
1829 # @param y a new Y coordinate
1830 # @param z a new Z coordinate
1831 # @return True if succeed else False
1832 # @ingroup l2_modif_movenode
1833 def MoveNode(self, NodeID, x, y, z):
1834 return self.editor.MoveNode(NodeID, x, y, z)
1836 ## Finds the node closest to a point
1837 # @param x the X coordinate of a point
1838 # @param y the Y coordinate of a point
1839 # @param z the Z coordinate of a point
1840 # @return the ID of a node
1841 # @ingroup l2_modif_throughp
1842 def FindNodeClosestTo(self, x, y, z):
1843 preview = self.mesh.GetMeshEditPreviewer()
1844 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1846 ## Finds the node closest to a point and moves it to a point location
1847 # @param x the X coordinate of a point
1848 # @param y the Y coordinate of a point
1849 # @param z the Z coordinate of a point
1850 # @return the ID of a moved node
1851 # @ingroup l2_modif_throughp
1852 def MeshToPassThroughAPoint(self, x, y, z):
1853 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1855 ## Replaces two neighbour triangles sharing Node1-Node2 link
1856 # with the triangles built on the same 4 nodes but having other common link.
1857 # @param NodeID1 the ID of the first node
1858 # @param NodeID2 the ID of the second node
1859 # @return false if proper faces were not found
1860 # @ingroup l2_modif_invdiag
1861 def InverseDiag(self, NodeID1, NodeID2):
1862 return self.editor.InverseDiag(NodeID1, NodeID2)
1864 ## Replaces two neighbour triangles sharing Node1-Node2 link
1865 # with a quadrangle built on the same 4 nodes.
1866 # @param NodeID1 the ID of the first node
1867 # @param NodeID2 the ID of the second node
1868 # @return false if proper faces were not found
1869 # @ingroup l2_modif_unitetri
1870 def DeleteDiag(self, NodeID1, NodeID2):
1871 return self.editor.DeleteDiag(NodeID1, NodeID2)
1873 ## Reorients elements by ids
1874 # @param IDsOfElements if undefined reorients all mesh elements
1875 # @return True if succeed else False
1876 # @ingroup l2_modif_changori
1877 def Reorient(self, IDsOfElements=None):
1878 if IDsOfElements == None:
1879 IDsOfElements = self.GetElementsId()
1880 return self.editor.Reorient(IDsOfElements)
1882 ## Reorients all elements of the object
1883 # @param theObject mesh, submesh or group
1884 # @return True if succeed else False
1885 # @ingroup l2_modif_changori
1886 def ReorientObject(self, theObject):
1887 if ( isinstance( theObject, Mesh )):
1888 theObject = theObject.GetMesh()
1889 return self.editor.ReorientObject(theObject)
1891 ## Fuses the neighbouring triangles into quadrangles.
1892 # @param IDsOfElements The triangles to be fused,
1893 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1894 # @param MaxAngle is the maximum angle between element normals at which the fusion
1895 # is still performed; theMaxAngle is mesured in radians.
1896 # @return TRUE in case of success, FALSE otherwise.
1897 # @ingroup l2_modif_unitetri
1898 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1899 if IDsOfElements == []:
1900 IDsOfElements = self.GetElementsId()
1901 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1903 ## Fuses the neighbouring triangles of the object into quadrangles
1904 # @param theObject is mesh, submesh or group
1905 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1906 # @param MaxAngle a max angle between element normals at which the fusion
1907 # is still performed; theMaxAngle is mesured in radians.
1908 # @return TRUE in case of success, FALSE otherwise.
1909 # @ingroup l2_modif_unitetri
1910 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1911 if ( isinstance( theObject, Mesh )):
1912 theObject = theObject.GetMesh()
1913 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1915 ## Splits quadrangles into triangles.
1916 # @param IDsOfElements the faces to be splitted.
1917 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1918 # @return TRUE in case of success, FALSE otherwise.
1919 # @ingroup l2_modif_cutquadr
1920 def QuadToTri (self, IDsOfElements, theCriterion):
1921 if IDsOfElements == []:
1922 IDsOfElements = self.GetElementsId()
1923 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1925 ## Splits quadrangles into triangles.
1926 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1927 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1928 # @return TRUE in case of success, FALSE otherwise.
1929 # @ingroup l2_modif_cutquadr
1930 def QuadToTriObject (self, theObject, theCriterion):
1931 if ( isinstance( theObject, Mesh )):
1932 theObject = theObject.GetMesh()
1933 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1935 ## Splits quadrangles into triangles.
1936 # @param IDsOfElements the faces to be splitted
1937 # @param Diag13 is used to choose a diagonal for splitting.
1938 # @return TRUE in case of success, FALSE otherwise.
1939 # @ingroup l2_modif_cutquadr
1940 def SplitQuad (self, IDsOfElements, Diag13):
1941 if IDsOfElements == []:
1942 IDsOfElements = self.GetElementsId()
1943 return self.editor.SplitQuad(IDsOfElements, Diag13)
1945 ## Splits quadrangles into triangles.
1946 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1947 # @param Diag13 is used to choose a diagonal for splitting.
1948 # @return TRUE in case of success, FALSE otherwise.
1949 # @ingroup l2_modif_cutquadr
1950 def SplitQuadObject (self, theObject, Diag13):
1951 if ( isinstance( theObject, Mesh )):
1952 theObject = theObject.GetMesh()
1953 return self.editor.SplitQuadObject(theObject, Diag13)
1955 ## Finds a better splitting of the given quadrangle.
1956 # @param IDOfQuad the ID of the quadrangle to be splitted.
1957 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1958 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1959 # diagonal is better, 0 if error occurs.
1960 # @ingroup l2_modif_cutquadr
1961 def BestSplit (self, IDOfQuad, theCriterion):
1962 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1964 ## Splits quadrangle faces near triangular facets of volumes
1966 # @ingroup l1_auxiliary
1967 def SplitQuadsNearTriangularFacets(self):
1968 faces_array = self.GetElementsByType(SMESH.FACE)
1969 for face_id in faces_array:
1970 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1971 quad_nodes = self.mesh.GetElemNodes(face_id)
1972 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1973 isVolumeFound = False
1974 for node1_elem in node1_elems:
1975 if not isVolumeFound:
1976 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1977 nb_nodes = self.GetElemNbNodes(node1_elem)
1978 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1979 volume_elem = node1_elem
1980 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1981 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1982 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1983 isVolumeFound = True
1984 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1985 self.SplitQuad([face_id], False) # diagonal 2-4
1986 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1987 isVolumeFound = True
1988 self.SplitQuad([face_id], True) # diagonal 1-3
1989 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1990 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1991 isVolumeFound = True
1992 self.SplitQuad([face_id], True) # diagonal 1-3
1994 ## @brief Splits hexahedrons into tetrahedrons.
1996 # This operation uses pattern mapping functionality for splitting.
1997 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1998 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1999 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2000 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2001 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2002 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2003 # @return TRUE in case of success, FALSE otherwise.
2004 # @ingroup l1_auxiliary
2005 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2006 # Pattern: 5.---------.6
2011 # (0,0,1) 4.---------.7 * |
2018 # (0,0,0) 0.---------.3
2019 pattern_tetra = "!!! Nb of points: \n 8 \n\
2029 !!! Indices of points of 6 tetras: \n\
2037 pattern = self.smeshpyD.GetPattern()
2038 isDone = pattern.LoadFromFile(pattern_tetra)
2040 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2043 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2044 isDone = pattern.MakeMesh(self.mesh, False, False)
2045 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2047 # split quafrangle faces near triangular facets of volumes
2048 self.SplitQuadsNearTriangularFacets()
2052 ## @brief Split hexahedrons into prisms.
2054 # Uses the pattern mapping functionality for splitting.
2055 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2056 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2057 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2058 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2059 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2060 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2061 # @return TRUE in case of success, FALSE otherwise.
2062 # @ingroup l1_auxiliary
2063 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2064 # Pattern: 5.---------.6
2069 # (0,0,1) 4.---------.7 |
2076 # (0,0,0) 0.---------.3
2077 pattern_prism = "!!! Nb of points: \n 8 \n\
2087 !!! Indices of points of 2 prisms: \n\
2091 pattern = self.smeshpyD.GetPattern()
2092 isDone = pattern.LoadFromFile(pattern_prism)
2094 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2097 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2098 isDone = pattern.MakeMesh(self.mesh, False, False)
2099 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2101 # Splits quafrangle faces near triangular facets of volumes
2102 self.SplitQuadsNearTriangularFacets()
2106 ## Smoothes elements
2107 # @param IDsOfElements the list if ids of elements to smooth
2108 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2109 # Note that nodes built on edges and boundary nodes are always fixed.
2110 # @param MaxNbOfIterations the maximum number of iterations
2111 # @param MaxAspectRatio varies in range [1.0, inf]
2112 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2113 # @return TRUE in case of success, FALSE otherwise.
2114 # @ingroup l2_modif_smooth
2115 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2116 MaxNbOfIterations, MaxAspectRatio, Method):
2117 if IDsOfElements == []:
2118 IDsOfElements = self.GetElementsId()
2119 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2120 MaxNbOfIterations, MaxAspectRatio, Method)
2122 ## Smoothes elements which belong to the given object
2123 # @param theObject the object to smooth
2124 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2125 # Note that nodes built on edges and boundary nodes are always fixed.
2126 # @param MaxNbOfIterations the maximum number of iterations
2127 # @param MaxAspectRatio varies in range [1.0, inf]
2128 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2129 # @return TRUE in case of success, FALSE otherwise.
2130 # @ingroup l2_modif_smooth
2131 def SmoothObject(self, theObject, IDsOfFixedNodes,
2132 MaxNbOfIterations, MaxAspectRatio, Method):
2133 if ( isinstance( theObject, Mesh )):
2134 theObject = theObject.GetMesh()
2135 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2136 MaxNbOfIterations, MaxAspectRatio, Method)
2138 ## Parametrically smoothes the given elements
2139 # @param IDsOfElements the list if ids of elements to smooth
2140 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2141 # Note that nodes built on edges and boundary nodes are always fixed.
2142 # @param MaxNbOfIterations the maximum number of iterations
2143 # @param MaxAspectRatio varies in range [1.0, inf]
2144 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2145 # @return TRUE in case of success, FALSE otherwise.
2146 # @ingroup l2_modif_smooth
2147 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2148 MaxNbOfIterations, MaxAspectRatio, Method):
2149 if IDsOfElements == []:
2150 IDsOfElements = self.GetElementsId()
2151 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2152 MaxNbOfIterations, MaxAspectRatio, Method)
2154 ## Parametrically smoothes the elements which belong to the given object
2155 # @param theObject the object to smooth
2156 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2157 # Note that nodes built on edges and boundary nodes are always fixed.
2158 # @param MaxNbOfIterations the maximum number of iterations
2159 # @param MaxAspectRatio varies in range [1.0, inf]
2160 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2161 # @return TRUE in case of success, FALSE otherwise.
2162 # @ingroup l2_modif_smooth
2163 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2164 MaxNbOfIterations, MaxAspectRatio, Method):
2165 if ( isinstance( theObject, Mesh )):
2166 theObject = theObject.GetMesh()
2167 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2168 MaxNbOfIterations, MaxAspectRatio, Method)
2170 ## Converts the mesh to quadratic, deletes old elements, replacing
2171 # them with quadratic with the same id.
2172 # @ingroup l2_modif_tofromqu
2173 def ConvertToQuadratic(self, theForce3d):
2174 self.editor.ConvertToQuadratic(theForce3d)
2176 ## Converts the mesh from quadratic to ordinary,
2177 # deletes old quadratic elements, \n replacing
2178 # them with ordinary mesh elements with the same id.
2179 # @return TRUE in case of success, FALSE otherwise.
2180 # @ingroup l2_modif_tofromqu
2181 def ConvertFromQuadratic(self):
2182 return self.editor.ConvertFromQuadratic()
2184 ## Renumber mesh nodes
2185 # @ingroup l2_modif_renumber
2186 def RenumberNodes(self):
2187 self.editor.RenumberNodes()
2189 ## Renumber mesh elements
2190 # @ingroup l2_modif_renumber
2191 def RenumberElements(self):
2192 self.editor.RenumberElements()
2194 ## Generates new elements by rotation of the elements around the axis
2195 # @param IDsOfElements the list of ids of elements to sweep
2196 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2197 # @param AngleInRadians the angle of Rotation
2198 # @param NbOfSteps the number of steps
2199 # @param Tolerance tolerance
2200 # @param MakeGroups forces the generation of new groups from existing ones
2201 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2202 # of all steps, else - size of each step
2203 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2204 # @ingroup l2_modif_extrurev
2205 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2206 MakeGroups=False, TotalAngle=False):
2207 if IDsOfElements == []:
2208 IDsOfElements = self.GetElementsId()
2209 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2210 Axis = self.smeshpyD.GetAxisStruct(Axis)
2211 if TotalAngle and NbOfSteps:
2212 AngleInRadians /= NbOfSteps
2214 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2215 AngleInRadians, NbOfSteps, Tolerance)
2216 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2219 ## Generates new elements by rotation of the elements of object around the axis
2220 # @param theObject object which elements should be sweeped
2221 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2222 # @param AngleInRadians the angle of Rotation
2223 # @param NbOfSteps number of steps
2224 # @param Tolerance tolerance
2225 # @param MakeGroups forces the generation of new groups from existing ones
2226 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2227 # of all steps, else - size of each step
2228 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2229 # @ingroup l2_modif_extrurev
2230 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2231 MakeGroups=False, TotalAngle=False):
2232 if ( isinstance( theObject, Mesh )):
2233 theObject = theObject.GetMesh()
2234 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2235 Axis = self.smeshpyD.GetAxisStruct(Axis)
2236 if TotalAngle and NbOfSteps:
2237 AngleInRadians /= NbOfSteps
2239 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2240 NbOfSteps, Tolerance)
2241 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2244 ## Generates new elements by extrusion of the elements with given ids
2245 # @param IDsOfElements the list of elements ids for extrusion
2246 # @param StepVector vector, defining the direction and value of extrusion
2247 # @param NbOfSteps the number of steps
2248 # @param MakeGroups forces the generation of new groups from existing ones
2249 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2250 # @ingroup l2_modif_extrurev
2251 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2252 if IDsOfElements == []:
2253 IDsOfElements = self.GetElementsId()
2254 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2255 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2257 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2258 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2261 ## Generates new elements by extrusion of the elements with given ids
2262 # @param IDsOfElements is ids of elements
2263 # @param StepVector vector, defining the direction and value of extrusion
2264 # @param NbOfSteps the number of steps
2265 # @param ExtrFlags sets flags for extrusion
2266 # @param SewTolerance uses for comparing locations of nodes if flag
2267 # EXTRUSION_FLAG_SEW is set
2268 # @param MakeGroups forces the generation of new groups from existing ones
2269 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2270 # @ingroup l2_modif_extrurev
2271 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2272 ExtrFlags, SewTolerance, MakeGroups=False):
2273 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2274 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2276 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2277 ExtrFlags, SewTolerance)
2278 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2279 ExtrFlags, SewTolerance)
2282 ## Generates new elements by extrusion of the elements which belong to the object
2283 # @param theObject the object which elements should be processed
2284 # @param StepVector vector, defining the direction and value of extrusion
2285 # @param NbOfSteps the number of steps
2286 # @param MakeGroups forces the generation of new groups from existing ones
2287 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2288 # @ingroup l2_modif_extrurev
2289 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2290 if ( isinstance( theObject, Mesh )):
2291 theObject = theObject.GetMesh()
2292 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2293 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2295 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2296 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2299 ## Generates new elements by extrusion of the elements which belong to the object
2300 # @param theObject object which elements should be processed
2301 # @param StepVector vector, defining the direction and value of extrusion
2302 # @param NbOfSteps the number of steps
2303 # @param MakeGroups to generate new groups from existing ones
2304 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2305 # @ingroup l2_modif_extrurev
2306 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2307 if ( isinstance( theObject, Mesh )):
2308 theObject = theObject.GetMesh()
2309 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2310 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2312 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2313 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2316 ## Generates new elements by extrusion of the elements which belong to the object
2317 # @param theObject object which elements should be processed
2318 # @param StepVector vector, defining the direction and value of extrusion
2319 # @param NbOfSteps the number of steps
2320 # @param MakeGroups forces the generation of new groups from existing ones
2321 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2322 # @ingroup l2_modif_extrurev
2323 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2324 if ( isinstance( theObject, Mesh )):
2325 theObject = theObject.GetMesh()
2326 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2327 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2329 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2330 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2333 ## Generates new elements by extrusion of the given elements
2334 # The path of extrusion must be a meshed edge.
2335 # @param IDsOfElements ids of elements
2336 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2337 # @param PathShape shape(edge) defines the sub-mesh for the path
2338 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2339 # @param HasAngles allows the shape to be rotated around the path
2340 # to get the resulting mesh in a helical fashion
2341 # @param Angles list of angles
2342 # @param HasRefPoint allows using the reference point
2343 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2344 # The User can specify any point as the Reference Point.
2345 # @param MakeGroups forces the generation of new groups from existing ones
2346 # @param LinearVariation forces the computation of rotation angles as linear
2347 # variation of the given Angles along path steps
2348 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2349 # only SMESH::Extrusion_Error otherwise
2350 # @ingroup l2_modif_extrurev
2351 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2352 HasAngles, Angles, HasRefPoint, RefPoint,
2353 MakeGroups=False, LinearVariation=False):
2354 if IDsOfElements == []:
2355 IDsOfElements = self.GetElementsId()
2356 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2357 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2359 if ( isinstance( PathMesh, Mesh )):
2360 PathMesh = PathMesh.GetMesh()
2361 if HasAngles and Angles and LinearVariation:
2362 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2365 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2366 PathShape, NodeStart, HasAngles,
2367 Angles, HasRefPoint, RefPoint)
2368 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2369 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2371 ## Generates new elements by extrusion of the elements which belong to the object
2372 # The path of extrusion must be a meshed edge.
2373 # @param theObject the object which elements should be processed
2374 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2375 # @param PathShape shape(edge) defines the sub-mesh for the path
2376 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2377 # @param HasAngles allows the shape to be rotated around the path
2378 # to get the resulting mesh in a helical fashion
2379 # @param Angles list of angles
2380 # @param HasRefPoint allows using the reference point
2381 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2382 # The User can specify any point as the Reference Point.
2383 # @param MakeGroups forces the generation of new groups from existing ones
2384 # @param LinearVariation forces the computation of rotation angles as linear
2385 # variation of the given Angles along path steps
2386 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2387 # only SMESH::Extrusion_Error otherwise
2388 # @ingroup l2_modif_extrurev
2389 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2390 HasAngles, Angles, HasRefPoint, RefPoint,
2391 MakeGroups=False, LinearVariation=False):
2392 if ( isinstance( theObject, Mesh )):
2393 theObject = theObject.GetMesh()
2394 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2395 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2396 if ( isinstance( PathMesh, Mesh )):
2397 PathMesh = PathMesh.GetMesh()
2398 if HasAngles and Angles and LinearVariation:
2399 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2402 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2403 PathShape, NodeStart, HasAngles,
2404 Angles, HasRefPoint, RefPoint)
2405 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2406 NodeStart, HasAngles, Angles, HasRefPoint,
2409 ## Creates a symmetrical copy of mesh elements
2410 # @param IDsOfElements list of elements ids
2411 # @param Mirror is AxisStruct or geom object(point, line, plane)
2412 # @param theMirrorType is POINT, AXIS or PLANE
2413 # If the Mirror is a geom object this parameter is unnecessary
2414 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2415 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2416 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2417 # @ingroup l2_modif_trsf
2418 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2419 if IDsOfElements == []:
2420 IDsOfElements = self.GetElementsId()
2421 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2422 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2423 if Copy and MakeGroups:
2424 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2425 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2428 ## Creates a new mesh by a symmetrical copy of mesh elements
2429 # @param IDsOfElements the list of elements ids
2430 # @param Mirror is AxisStruct or geom object (point, line, plane)
2431 # @param theMirrorType is POINT, AXIS or PLANE
2432 # If the Mirror is a geom object this parameter is unnecessary
2433 # @param MakeGroups to generate new groups from existing ones
2434 # @param NewMeshName a name of the new mesh to create
2435 # @return instance of Mesh class
2436 # @ingroup l2_modif_trsf
2437 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2438 if IDsOfElements == []:
2439 IDsOfElements = self.GetElementsId()
2440 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2441 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2442 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2443 MakeGroups, NewMeshName)
2444 return Mesh(self.smeshpyD,self.geompyD,mesh)
2446 ## Creates a symmetrical copy of the object
2447 # @param theObject mesh, submesh or group
2448 # @param Mirror AxisStruct or geom object (point, line, plane)
2449 # @param theMirrorType is POINT, AXIS or PLANE
2450 # If the Mirror is a geom object this parameter is unnecessary
2451 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2452 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2453 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2454 # @ingroup l2_modif_trsf
2455 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2456 if ( isinstance( theObject, Mesh )):
2457 theObject = theObject.GetMesh()
2458 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2459 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2460 if Copy and MakeGroups:
2461 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2462 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2465 ## Creates a new mesh by a symmetrical copy of the object
2466 # @param theObject mesh, submesh or group
2467 # @param Mirror AxisStruct or geom object (point, line, plane)
2468 # @param theMirrorType POINT, AXIS or PLANE
2469 # If the Mirror is a geom object this parameter is unnecessary
2470 # @param MakeGroups forces the generation of new groups from existing ones
2471 # @param NewMeshName the name of the new mesh to create
2472 # @return instance of Mesh class
2473 # @ingroup l2_modif_trsf
2474 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2475 if ( isinstance( theObject, Mesh )):
2476 theObject = theObject.GetMesh()
2477 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2478 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2479 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2480 MakeGroups, NewMeshName)
2481 return Mesh( self.smeshpyD,self.geompyD,mesh )
2483 ## Translates the elements
2484 # @param IDsOfElements list of elements ids
2485 # @param Vector the direction of translation (DirStruct or vector)
2486 # @param Copy allows copying the translated elements
2487 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2488 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2489 # @ingroup l2_modif_trsf
2490 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2491 if IDsOfElements == []:
2492 IDsOfElements = self.GetElementsId()
2493 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2494 Vector = self.smeshpyD.GetDirStruct(Vector)
2495 if Copy and MakeGroups:
2496 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2497 self.editor.Translate(IDsOfElements, Vector, Copy)
2500 ## Creates a new mesh of translated elements
2501 # @param IDsOfElements list of elements ids
2502 # @param Vector the direction of translation (DirStruct or vector)
2503 # @param MakeGroups forces the generation of new groups from existing ones
2504 # @param NewMeshName the name of the newly created mesh
2505 # @return instance of Mesh class
2506 # @ingroup l2_modif_trsf
2507 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2508 if IDsOfElements == []:
2509 IDsOfElements = self.GetElementsId()
2510 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2511 Vector = self.smeshpyD.GetDirStruct(Vector)
2512 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2513 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2515 ## Translates the object
2516 # @param theObject the object to translate (mesh, submesh, or group)
2517 # @param Vector direction of translation (DirStruct or geom vector)
2518 # @param Copy allows copying the translated elements
2519 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2520 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2521 # @ingroup l2_modif_trsf
2522 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2523 if ( isinstance( theObject, Mesh )):
2524 theObject = theObject.GetMesh()
2525 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2526 Vector = self.smeshpyD.GetDirStruct(Vector)
2527 if Copy and MakeGroups:
2528 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2529 self.editor.TranslateObject(theObject, Vector, Copy)
2532 ## Creates a new mesh from the translated object
2533 # @param theObject the object to translate (mesh, submesh, or group)
2534 # @param Vector the direction of translation (DirStruct or geom vector)
2535 # @param MakeGroups forces the generation of new groups from existing ones
2536 # @param NewMeshName the name of the newly created mesh
2537 # @return instance of Mesh class
2538 # @ingroup l2_modif_trsf
2539 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2540 if (isinstance(theObject, Mesh)):
2541 theObject = theObject.GetMesh()
2542 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2543 Vector = self.smeshpyD.GetDirStruct(Vector)
2544 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2545 return Mesh( self.smeshpyD, self.geompyD, mesh )
2547 ## Rotates the elements
2548 # @param IDsOfElements list of elements ids
2549 # @param Axis the axis of rotation (AxisStruct or geom line)
2550 # @param AngleInRadians the angle of rotation (in radians)
2551 # @param Copy allows copying the rotated elements
2552 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2553 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2554 # @ingroup l2_modif_trsf
2555 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2556 if IDsOfElements == []:
2557 IDsOfElements = self.GetElementsId()
2558 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2559 Axis = self.smeshpyD.GetAxisStruct(Axis)
2560 if Copy and MakeGroups:
2561 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2562 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2565 ## Creates a new mesh of rotated elements
2566 # @param IDsOfElements list of element ids
2567 # @param Axis the axis of rotation (AxisStruct or geom line)
2568 # @param AngleInRadians the angle of rotation (in radians)
2569 # @param MakeGroups forces the generation of new groups from existing ones
2570 # @param NewMeshName the name of the newly created mesh
2571 # @return instance of Mesh class
2572 # @ingroup l2_modif_trsf
2573 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2574 if IDsOfElements == []:
2575 IDsOfElements = self.GetElementsId()
2576 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2577 Axis = self.smeshpyD.GetAxisStruct(Axis)
2578 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2579 MakeGroups, NewMeshName)
2580 return Mesh( self.smeshpyD, self.geompyD, mesh )
2582 ## Rotates the object
2583 # @param theObject the object to rotate( mesh, submesh, or group)
2584 # @param Axis the axis of rotation (AxisStruct or geom line)
2585 # @param AngleInRadians the angle of rotation (in radians)
2586 # @param Copy allows copying the rotated elements
2587 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2588 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2589 # @ingroup l2_modif_trsf
2590 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2591 if (isinstance(theObject, Mesh)):
2592 theObject = theObject.GetMesh()
2593 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2594 Axis = self.smeshpyD.GetAxisStruct(Axis)
2595 if Copy and MakeGroups:
2596 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2597 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2600 ## Creates a new mesh from the rotated object
2601 # @param theObject the object to rotate (mesh, submesh, or group)
2602 # @param Axis the axis of rotation (AxisStruct or geom line)
2603 # @param AngleInRadians the angle of rotation (in radians)
2604 # @param MakeGroups forces the generation of new groups from existing ones
2605 # @param NewMeshName the name of the newly created mesh
2606 # @return instance of Mesh class
2607 # @ingroup l2_modif_trsf
2608 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2609 if (isinstance( theObject, Mesh )):
2610 theObject = theObject.GetMesh()
2611 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2612 Axis = self.smeshpyD.GetAxisStruct(Axis)
2613 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2614 MakeGroups, NewMeshName)
2615 return Mesh( self.smeshpyD, self.geompyD, mesh )
2617 ## Finds groups of ajacent nodes within Tolerance.
2618 # @param Tolerance the value of tolerance
2619 # @return the list of groups of nodes
2620 # @ingroup l2_modif_trsf
2621 def FindCoincidentNodes (self, Tolerance):
2622 return self.editor.FindCoincidentNodes(Tolerance)
2624 ## Finds groups of ajacent nodes within Tolerance.
2625 # @param Tolerance the value of tolerance
2626 # @param SubMeshOrGroup SubMesh or Group
2627 # @return the list of groups of nodes
2628 # @ingroup l2_modif_trsf
2629 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2630 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2633 # @param GroupsOfNodes the list of groups of nodes
2634 # @ingroup l2_modif_trsf
2635 def MergeNodes (self, GroupsOfNodes):
2636 self.editor.MergeNodes(GroupsOfNodes)
2638 ## Finds the elements built on the same nodes.
2639 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2640 # @return a list of groups of equal elements
2641 # @ingroup l2_modif_trsf
2642 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2643 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2645 ## Merges elements in each given group.
2646 # @param GroupsOfElementsID groups of elements for merging
2647 # @ingroup l2_modif_trsf
2648 def MergeElements(self, GroupsOfElementsID):
2649 self.editor.MergeElements(GroupsOfElementsID)
2651 ## Leaves one element and removes all other elements built on the same nodes.
2652 # @ingroup l2_modif_trsf
2653 def MergeEqualElements(self):
2654 self.editor.MergeEqualElements()
2656 ## Sews free borders
2657 # @return SMESH::Sew_Error
2658 # @ingroup l2_modif_trsf
2659 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2660 FirstNodeID2, SecondNodeID2, LastNodeID2,
2661 CreatePolygons, CreatePolyedrs):
2662 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2663 FirstNodeID2, SecondNodeID2, LastNodeID2,
2664 CreatePolygons, CreatePolyedrs)
2666 ## Sews conform free borders
2667 # @return SMESH::Sew_Error
2668 # @ingroup l2_modif_trsf
2669 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2670 FirstNodeID2, SecondNodeID2):
2671 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2672 FirstNodeID2, SecondNodeID2)
2674 ## Sews border to side
2675 # @return SMESH::Sew_Error
2676 # @ingroup l2_modif_trsf
2677 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2678 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2679 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2680 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2682 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2683 # merged with the nodes of elements of Side2.
2684 # The number of elements in theSide1 and in theSide2 must be
2685 # equal and they should have similar nodal connectivity.
2686 # The nodes to merge should belong to side borders and
2687 # the first node should be linked to the second.
2688 # @return SMESH::Sew_Error
2689 # @ingroup l2_modif_trsf
2690 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2691 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2692 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2693 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2694 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2695 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2697 ## Sets new nodes for the given element.
2698 # @param ide the element id
2699 # @param newIDs nodes ids
2700 # @return If the number of nodes does not correspond to the type of element - returns false
2701 # @ingroup l2_modif_edit
2702 def ChangeElemNodes(self, ide, newIDs):
2703 return self.editor.ChangeElemNodes(ide, newIDs)
2705 ## If during the last operation of MeshEditor some nodes were
2706 # created, this method returns the list of their IDs, \n
2707 # if new nodes were not created - returns empty list
2708 # @return the list of integer values (can be empty)
2709 # @ingroup l1_auxiliary
2710 def GetLastCreatedNodes(self):
2711 return self.editor.GetLastCreatedNodes()
2713 ## If during the last operation of MeshEditor some elements were
2714 # created this method returns the list of their IDs, \n
2715 # if new elements were not created - returns empty list
2716 # @return the list of integer values (can be empty)
2717 # @ingroup l1_auxiliary
2718 def GetLastCreatedElems(self):
2719 return self.editor.GetLastCreatedElems()
2721 ## The mother class to define algorithm, it is not recommended to use it directly.
2724 # @ingroup l2_algorithms
2725 class Mesh_Algorithm:
2726 # @class Mesh_Algorithm
2727 # @brief Class Mesh_Algorithm
2729 #def __init__(self,smesh):
2737 ## Finds a hypothesis in the study by its type name and parameters.
2738 # Finds only the hypotheses created in smeshpyD engine.
2739 # @return SMESH.SMESH_Hypothesis
2740 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2741 study = smeshpyD.GetCurrentStudy()
2742 #to do: find component by smeshpyD object, not by its data type
2743 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2744 if scomp is not None:
2745 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2746 # Check if the root label of the hypotheses exists
2747 if res and hypRoot is not None:
2748 iter = study.NewChildIterator(hypRoot)
2749 # Check all published hypotheses
2751 hypo_so_i = iter.Value()
2752 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2753 if attr is not None:
2754 anIOR = attr.Value()
2755 hypo_o_i = salome.orb.string_to_object(anIOR)
2756 if hypo_o_i is not None:
2757 # Check if this is a hypothesis
2758 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2759 if hypo_i is not None:
2760 # Check if the hypothesis belongs to current engine
2761 if smeshpyD.GetObjectId(hypo_i) > 0:
2762 # Check if this is the required hypothesis
2763 if hypo_i.GetName() == hypname:
2765 if CompareMethod(hypo_i, args):
2779 ## Finds the algorithm in the study by its type name.
2780 # Finds only the algorithms, which have been created in smeshpyD engine.
2781 # @return SMESH.SMESH_Algo
2782 def FindAlgorithm (self, algoname, smeshpyD):
2783 study = smeshpyD.GetCurrentStudy()
2784 #to do: find component by smeshpyD object, not by its data type
2785 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2786 if scomp is not None:
2787 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2788 # Check if the root label of the algorithms exists
2789 if res and hypRoot is not None:
2790 iter = study.NewChildIterator(hypRoot)
2791 # Check all published algorithms
2793 algo_so_i = iter.Value()
2794 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2795 if attr is not None:
2796 anIOR = attr.Value()
2797 algo_o_i = salome.orb.string_to_object(anIOR)
2798 if algo_o_i is not None:
2799 # Check if this is an algorithm
2800 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2801 if algo_i is not None:
2802 # Checks if the algorithm belongs to the current engine
2803 if smeshpyD.GetObjectId(algo_i) > 0:
2804 # Check if this is the required algorithm
2805 if algo_i.GetName() == algoname:
2818 ## If the algorithm is global, returns 0; \n
2819 # else returns the submesh associated to this algorithm.
2820 def GetSubMesh(self):
2823 ## Returns the wrapped mesher.
2824 def GetAlgorithm(self):
2827 ## Gets the list of hypothesis that can be used with this algorithm
2828 def GetCompatibleHypothesis(self):
2831 mylist = self.algo.GetCompatibleHypothesis()
2834 ## Gets the name of the algorithm
2838 ## Sets the name to the algorithm
2839 def SetName(self, name):
2840 SetName(self.algo, name)
2842 ## Gets the id of the algorithm
2844 return self.algo.GetId()
2847 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2849 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2850 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2852 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2854 self.Assign(algo, mesh, geom)
2858 def Assign(self, algo, mesh, geom):
2860 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2867 name = GetName(geom)
2869 name = mesh.geompyD.SubShapeName(geom, piece)
2870 mesh.geompyD.addToStudyInFather(piece, geom, name)
2871 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2874 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2875 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2877 def CompareHyp (self, hyp, args):
2878 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2881 def CompareEqualHyp (self, hyp, args):
2885 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2886 UseExisting=0, CompareMethod=""):
2889 if CompareMethod == "": CompareMethod = self.CompareHyp
2890 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2893 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2899 a = a + s + str(args[i])
2903 SetName(hypo, hyp + a)
2905 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2906 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2910 # Public class: Mesh_Segment
2911 # --------------------------
2913 ## Class to define a segment 1D algorithm for discretization
2916 # @ingroup l3_algos_basic
2917 class Mesh_Segment(Mesh_Algorithm):
2919 ## Private constructor.
2920 def __init__(self, mesh, geom=0):
2921 Mesh_Algorithm.__init__(self)
2922 self.Create(mesh, geom, "Regular_1D")
2924 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2925 # @param l for the length of segments that cut an edge
2926 # @param UseExisting if ==true - searches for an existing hypothesis created with
2927 # the same parameters, else (default) - creates a new one
2928 # @param p precision, used for calculation of the number of segments.
2929 # The precision should be a positive, meaningful value within the range [0,1].
2930 # In general, the number of segments is calculated with the formula:
2931 # nb = ceil((edge_length / l) - p)
2932 # Function ceil rounds its argument to the higher integer.
2933 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2934 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2935 # p=1 means rounding of (edge_length / l) to the lower integer.
2936 # Default value is 1e-07.
2937 # @return an instance of StdMeshers_LocalLength hypothesis
2938 # @ingroup l3_hypos_1dhyps
2939 def LocalLength(self, l, UseExisting=0, p=1e-07):
2940 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2941 CompareMethod=self.CompareLocalLength)
2947 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2948 def CompareLocalLength(self, hyp, args):
2949 if IsEqual(hyp.GetLength(), args[0]):
2950 return IsEqual(hyp.GetPrecision(), args[1])
2953 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2954 # @param n for the number of segments that cut an edge
2955 # @param s for the scale factor (optional)
2956 # @param UseExisting if ==true - searches for an existing hypothesis created with
2957 # the same parameters, else (default) - create a new one
2958 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2959 # @ingroup l3_hypos_1dhyps
2960 def NumberOfSegments(self, n, s=[], UseExisting=0):
2962 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2963 CompareMethod=self.CompareNumberOfSegments)
2965 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2966 CompareMethod=self.CompareNumberOfSegments)
2967 hyp.SetDistrType( 1 )
2968 hyp.SetScaleFactor(s)
2969 hyp.SetNumberOfSegments(n)
2973 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2974 def CompareNumberOfSegments(self, hyp, args):
2975 if hyp.GetNumberOfSegments() == args[0]:
2979 if hyp.GetDistrType() == 1:
2980 if IsEqual(hyp.GetScaleFactor(), args[1]):
2984 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2985 # @param start defines the length of the first segment
2986 # @param end defines the length of the last segment
2987 # @param UseExisting if ==true - searches for an existing hypothesis created with
2988 # the same parameters, else (default) - creates a new one
2989 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2990 # @ingroup l3_hypos_1dhyps
2991 def Arithmetic1D(self, start, end, UseExisting=0):
2992 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2993 CompareMethod=self.CompareArithmetic1D)
2994 hyp.SetLength(start, 1)
2995 hyp.SetLength(end , 0)
2999 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3000 def CompareArithmetic1D(self, hyp, args):
3001 if IsEqual(hyp.GetLength(1), args[0]):
3002 if IsEqual(hyp.GetLength(0), args[1]):
3006 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3007 # @param start defines the length of the first segment
3008 # @param end defines the length of the last segment
3009 # @param UseExisting if ==true - searches for an existing hypothesis created with
3010 # the same parameters, else (default) - creates a new one
3011 # @return an instance of StdMeshers_StartEndLength hypothesis
3012 # @ingroup l3_hypos_1dhyps
3013 def StartEndLength(self, start, end, UseExisting=0):
3014 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3015 CompareMethod=self.CompareStartEndLength)
3016 hyp.SetLength(start, 1)
3017 hyp.SetLength(end , 0)
3020 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3021 def CompareStartEndLength(self, hyp, args):
3022 if IsEqual(hyp.GetLength(1), args[0]):
3023 if IsEqual(hyp.GetLength(0), args[1]):
3027 ## Defines "Deflection1D" hypothesis
3028 # @param d for the deflection
3029 # @param UseExisting if ==true - searches for an existing hypothesis created with
3030 # the same parameters, else (default) - create a new one
3031 # @ingroup l3_hypos_1dhyps
3032 def Deflection1D(self, d, UseExisting=0):
3033 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3034 CompareMethod=self.CompareDeflection1D)
3035 hyp.SetDeflection(d)
3038 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3039 def CompareDeflection1D(self, hyp, args):
3040 return IsEqual(hyp.GetDeflection(), args[0])
3042 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3043 # the opposite side in case of quadrangular faces
3044 # @ingroup l3_hypos_additi
3045 def Propagation(self):
3046 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3048 ## Defines "AutomaticLength" hypothesis
3049 # @param fineness for the fineness [0-1]
3050 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3051 # same parameters, else (default) - create a new one
3052 # @ingroup l3_hypos_1dhyps
3053 def AutomaticLength(self, fineness=0, UseExisting=0):
3054 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3055 CompareMethod=self.CompareAutomaticLength)
3056 hyp.SetFineness( fineness )
3059 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3060 def CompareAutomaticLength(self, hyp, args):
3061 return IsEqual(hyp.GetFineness(), args[0])
3063 ## Defines "SegmentLengthAroundVertex" hypothesis
3064 # @param length for the segment length
3065 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3066 # Any other integer value means that the hypothesis will be set on the
3067 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3068 # @param UseExisting if ==true - searches for an existing hypothesis created with
3069 # the same parameters, else (default) - creates a new one
3070 # @ingroup l3_algos_segmarv
3071 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3073 store_geom = self.geom
3074 if type(vertex) is types.IntType:
3075 if vertex == 0 or vertex == 1:
3076 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3084 if self.geom is None:
3085 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3086 name = GetName(self.geom)
3088 piece = self.mesh.geom
3089 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3090 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3091 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3093 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3095 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3096 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3098 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3099 CompareMethod=self.CompareLengthNearVertex)
3100 self.geom = store_geom
3101 hyp.SetLength( length )
3104 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3105 # @ingroup l3_algos_segmarv
3106 def CompareLengthNearVertex(self, hyp, args):
3107 return IsEqual(hyp.GetLength(), args[0])
3109 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3110 # If the 2D mesher sees that all boundary edges are quadratic,
3111 # it generates quadratic faces, else it generates linear faces using
3112 # medium nodes as if they are vertices.
3113 # The 3D mesher generates quadratic volumes only if all boundary faces
3114 # are quadratic, else it fails.
3116 # @ingroup l3_hypos_additi
3117 def QuadraticMesh(self):
3118 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3121 # Public class: Mesh_CompositeSegment
3122 # --------------------------
3124 ## Defines a segment 1D algorithm for discretization
3126 # @ingroup l3_algos_basic
3127 class Mesh_CompositeSegment(Mesh_Segment):
3129 ## Private constructor.
3130 def __init__(self, mesh, geom=0):
3131 self.Create(mesh, geom, "CompositeSegment_1D")
3134 # Public class: Mesh_Segment_Python
3135 # ---------------------------------
3137 ## Defines a segment 1D algorithm for discretization with python function
3139 # @ingroup l3_algos_basic
3140 class Mesh_Segment_Python(Mesh_Segment):
3142 ## Private constructor.
3143 def __init__(self, mesh, geom=0):
3144 import Python1dPlugin
3145 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3147 ## Defines "PythonSplit1D" hypothesis
3148 # @param n for the number of segments that cut an edge
3149 # @param func for the python function that calculates the length of all segments
3150 # @param UseExisting if ==true - searches for the existing hypothesis created with
3151 # the same parameters, else (default) - creates a new one
3152 # @ingroup l3_hypos_1dhyps
3153 def PythonSplit1D(self, n, func, UseExisting=0):
3154 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3155 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3156 hyp.SetNumberOfSegments(n)
3157 hyp.SetPythonLog10RatioFunction(func)
3160 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3161 def ComparePythonSplit1D(self, hyp, args):
3162 #if hyp.GetNumberOfSegments() == args[0]:
3163 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3167 # Public class: Mesh_Triangle
3168 # ---------------------------
3170 ## Defines a triangle 2D algorithm
3172 # @ingroup l3_algos_basic
3173 class Mesh_Triangle(Mesh_Algorithm):
3182 ## Private constructor.
3183 def __init__(self, mesh, algoType, geom=0):
3184 Mesh_Algorithm.__init__(self)
3186 self.algoType = algoType
3187 if algoType == MEFISTO:
3188 self.Create(mesh, geom, "MEFISTO_2D")
3190 elif algoType == BLSURF:
3192 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3193 #self.SetPhysicalMesh() - PAL19680
3194 elif algoType == NETGEN:
3196 print "Warning: NETGENPlugin module unavailable"
3198 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3200 elif algoType == NETGEN_2D:
3202 print "Warning: NETGENPlugin module unavailable"
3204 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3207 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3208 # @param area for the maximum area of each triangle
3209 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3210 # same parameters, else (default) - creates a new one
3212 # Only for algoType == MEFISTO || NETGEN_2D
3213 # @ingroup l3_hypos_2dhyps
3214 def MaxElementArea(self, area, UseExisting=0):
3215 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3216 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3217 CompareMethod=self.CompareMaxElementArea)
3218 elif self.algoType == NETGEN:
3219 hyp = self.Parameters(SIMPLE)
3220 hyp.SetMaxElementArea(area)
3223 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3224 def CompareMaxElementArea(self, hyp, args):
3225 return IsEqual(hyp.GetMaxElementArea(), args[0])
3227 ## Defines "LengthFromEdges" hypothesis to build triangles
3228 # based on the length of the edges taken from the wire
3230 # Only for algoType == MEFISTO || NETGEN_2D
3231 # @ingroup l3_hypos_2dhyps
3232 def LengthFromEdges(self):
3233 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3234 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3236 elif self.algoType == NETGEN:
3237 hyp = self.Parameters(SIMPLE)
3238 hyp.LengthFromEdges()
3241 ## Sets a way to define size of mesh elements to generate.
3242 # @param thePhysicalMesh is: DefaultSize or Custom.
3243 # @ingroup l3_hypos_blsurf
3244 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3245 # Parameter of BLSURF algo
3246 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3248 ## Sets size of mesh elements to generate.
3249 # @ingroup l3_hypos_blsurf
3250 def SetPhySize(self, theVal):
3251 # Parameter of BLSURF algo
3252 self.Parameters().SetPhySize(theVal)
3254 ## Sets lower boundary of mesh element size (PhySize).
3255 # @ingroup l3_hypos_blsurf
3256 def SetPhyMin(self, theVal=-1):
3257 # Parameter of BLSURF algo
3258 self.Parameters().SetPhyMin(theVal)
3260 ## Sets upper boundary of mesh element size (PhySize).
3261 # @ingroup l3_hypos_blsurf
3262 def SetPhyMax(self, theVal=-1):
3263 # Parameter of BLSURF algo
3264 self.Parameters().SetPhyMax(theVal)
3266 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3267 # @param theGeometricMesh is: DefaultGeom or Custom
3268 # @ingroup l3_hypos_blsurf
3269 def SetGeometricMesh(self, theGeometricMesh=0):
3270 # Parameter of BLSURF algo
3271 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3272 self.params.SetGeometricMesh(theGeometricMesh)
3274 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3275 # @ingroup l3_hypos_blsurf
3276 def SetAngleMeshS(self, theVal=_angleMeshS):
3277 # Parameter of BLSURF algo
3278 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3279 self.params.SetAngleMeshS(theVal)
3281 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3282 # @ingroup l3_hypos_blsurf
3283 def SetAngleMeshC(self, theVal=_angleMeshS):
3284 # Parameter of BLSURF algo
3285 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3286 self.params.SetAngleMeshC(theVal)
3288 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3289 # @ingroup l3_hypos_blsurf
3290 def SetGeoMin(self, theVal=-1):
3291 # Parameter of BLSURF algo
3292 self.Parameters().SetGeoMin(theVal)
3294 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3295 # @ingroup l3_hypos_blsurf
3296 def SetGeoMax(self, theVal=-1):
3297 # Parameter of BLSURF algo
3298 self.Parameters().SetGeoMax(theVal)
3300 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3301 # @ingroup l3_hypos_blsurf
3302 def SetGradation(self, theVal=_gradation):
3303 # Parameter of BLSURF algo
3304 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3305 self.params.SetGradation(theVal)
3307 ## Sets topology usage way.
3308 # @param way defines how mesh conformity is assured <ul>
3309 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3310 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3311 # @ingroup l3_hypos_blsurf
3312 def SetTopology(self, way):
3313 # Parameter of BLSURF algo
3314 self.Parameters().SetTopology(way)
3316 ## To respect geometrical edges or not.
3317 # @ingroup l3_hypos_blsurf
3318 def SetDecimesh(self, toIgnoreEdges=False):
3319 # Parameter of BLSURF algo
3320 self.Parameters().SetDecimesh(toIgnoreEdges)
3322 ## Sets verbosity level in the range 0 to 100.
3323 # @ingroup l3_hypos_blsurf
3324 def SetVerbosity(self, level):
3325 # Parameter of BLSURF algo
3326 self.Parameters().SetVerbosity(level)
3328 ## Sets advanced option value.
3329 # @ingroup l3_hypos_blsurf
3330 def SetOptionValue(self, optionName, level):
3331 # Parameter of BLSURF algo
3332 self.Parameters().SetOptionValue(optionName,level)
3334 ## Sets QuadAllowed flag.
3335 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3336 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3337 def SetQuadAllowed(self, toAllow=True):
3338 if self.algoType == NETGEN_2D:
3339 if toAllow: # add QuadranglePreference
3340 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3341 else: # remove QuadranglePreference
3342 for hyp in self.mesh.GetHypothesisList( self.geom ):
3343 if hyp.GetName() == "QuadranglePreference":
3344 self.mesh.RemoveHypothesis( self.geom, hyp )
3349 if self.Parameters():
3350 self.params.SetQuadAllowed(toAllow)
3353 ## Defines hypothesis having several parameters
3355 # @ingroup l3_hypos_netgen
3356 def Parameters(self, which=SOLE):
3359 if self.algoType == NETGEN:
3361 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3362 "libNETGENEngine.so", UseExisting=0)
3364 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3365 "libNETGENEngine.so", UseExisting=0)
3367 elif self.algoType == MEFISTO:
3368 print "Mefisto algo support no multi-parameter hypothesis"
3370 elif self.algoType == NETGEN_2D:
3371 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3372 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3374 elif self.algoType == BLSURF:
3375 self.params = self.Hypothesis("BLSURF_Parameters", [],
3376 "libBLSURFEngine.so", UseExisting=0)
3379 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3384 # Only for algoType == NETGEN
3385 # @ingroup l3_hypos_netgen
3386 def SetMaxSize(self, theSize):
3387 if self.Parameters():
3388 self.params.SetMaxSize(theSize)
3390 ## Sets SecondOrder flag
3392 # Only for algoType == NETGEN
3393 # @ingroup l3_hypos_netgen
3394 def SetSecondOrder(self, theVal):
3395 if self.Parameters():
3396 self.params.SetSecondOrder(theVal)
3398 ## Sets Optimize flag
3400 # Only for algoType == NETGEN
3401 # @ingroup l3_hypos_netgen
3402 def SetOptimize(self, theVal):
3403 if self.Parameters():
3404 self.params.SetOptimize(theVal)
3407 # @param theFineness is:
3408 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3410 # Only for algoType == NETGEN
3411 # @ingroup l3_hypos_netgen
3412 def SetFineness(self, theFineness):
3413 if self.Parameters():
3414 self.params.SetFineness(theFineness)
3418 # Only for algoType == NETGEN
3419 # @ingroup l3_hypos_netgen
3420 def SetGrowthRate(self, theRate):
3421 if self.Parameters():
3422 self.params.SetGrowthRate(theRate)
3424 ## Sets NbSegPerEdge
3426 # Only for algoType == NETGEN
3427 # @ingroup l3_hypos_netgen
3428 def SetNbSegPerEdge(self, theVal):
3429 if self.Parameters():
3430 self.params.SetNbSegPerEdge(theVal)
3432 ## Sets NbSegPerRadius
3434 # Only for algoType == NETGEN
3435 # @ingroup l3_hypos_netgen
3436 def SetNbSegPerRadius(self, theVal):
3437 if self.Parameters():
3438 self.params.SetNbSegPerRadius(theVal)
3440 ## Sets number of segments overriding value set by SetLocalLength()
3442 # Only for algoType == NETGEN
3443 # @ingroup l3_hypos_netgen
3444 def SetNumberOfSegments(self, theVal):
3445 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3447 ## Sets number of segments overriding value set by SetNumberOfSegments()
3449 # Only for algoType == NETGEN
3450 # @ingroup l3_hypos_netgen
3451 def SetLocalLength(self, theVal):
3452 self.Parameters(SIMPLE).SetLocalLength(theVal)
3457 # Public class: Mesh_Quadrangle
3458 # -----------------------------
3460 ## Defines a quadrangle 2D algorithm
3462 # @ingroup l3_algos_basic
3463 class Mesh_Quadrangle(Mesh_Algorithm):
3465 ## Private constructor.
3466 def __init__(self, mesh, geom=0):
3467 Mesh_Algorithm.__init__(self)
3468 self.Create(mesh, geom, "Quadrangle_2D")
3470 ## Defines "QuadranglePreference" hypothesis, forcing construction
3471 # of quadrangles if the number of nodes on the opposite edges is not the same
3472 # while the total number of nodes on edges is even
3474 # @ingroup l3_hypos_additi
3475 def QuadranglePreference(self):
3476 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3477 CompareMethod=self.CompareEqualHyp)
3480 ## Defines "TrianglePreference" hypothesis, forcing construction
3481 # of triangles in the refinement area if the number of nodes
3482 # on the opposite edges is not the same
3484 # @ingroup l3_hypos_additi
3485 def TrianglePreference(self):
3486 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3487 CompareMethod=self.CompareEqualHyp)
3490 # Public class: Mesh_Tetrahedron
3491 # ------------------------------
3493 ## Defines a tetrahedron 3D algorithm
3495 # @ingroup l3_algos_basic
3496 class Mesh_Tetrahedron(Mesh_Algorithm):
3501 ## Private constructor.
3502 def __init__(self, mesh, algoType, geom=0):
3503 Mesh_Algorithm.__init__(self)
3505 if algoType == NETGEN:
3506 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3509 elif algoType == FULL_NETGEN:
3511 print "Warning: NETGENPlugin module has not been imported."
3512 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3515 elif algoType == GHS3D:
3517 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3520 self.algoType = algoType
3522 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3523 # @param vol for the maximum volume of each tetrahedron
3524 # @param UseExisting if ==true - searches for the existing hypothesis created with
3525 # the same parameters, else (default) - creates a new one
3526 # @ingroup l3_hypos_maxvol
3527 def MaxElementVolume(self, vol, UseExisting=0):
3528 if self.algoType == NETGEN:
3529 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3530 CompareMethod=self.CompareMaxElementVolume)
3531 hyp.SetMaxElementVolume(vol)
3533 elif self.algoType == FULL_NETGEN:
3534 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3537 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3538 def CompareMaxElementVolume(self, hyp, args):
3539 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3541 ## Defines hypothesis having several parameters
3543 # @ingroup l3_hypos_netgen
3544 def Parameters(self, which=SOLE):
3547 if self.algoType == FULL_NETGEN:
3549 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3550 "libNETGENEngine.so", UseExisting=0)
3552 self.params = self.Hypothesis("NETGEN_Parameters", [],
3553 "libNETGENEngine.so", UseExisting=0)
3555 if self.algoType == GHS3D:
3556 self.params = self.Hypothesis("GHS3D_Parameters", [],
3557 "libGHS3DEngine.so", UseExisting=0)
3560 print "Algo supports no multi-parameter hypothesis"
3564 # Parameter of FULL_NETGEN
3565 # @ingroup l3_hypos_netgen
3566 def SetMaxSize(self, theSize):
3567 self.Parameters().SetMaxSize(theSize)
3569 ## Sets SecondOrder flag
3570 # Parameter of FULL_NETGEN
3571 # @ingroup l3_hypos_netgen
3572 def SetSecondOrder(self, theVal):
3573 self.Parameters().SetSecondOrder(theVal)
3575 ## Sets Optimize flag
3576 # Parameter of FULL_NETGEN
3577 # @ingroup l3_hypos_netgen
3578 def SetOptimize(self, theVal):
3579 self.Parameters().SetOptimize(theVal)
3582 # @param theFineness is:
3583 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3584 # Parameter of FULL_NETGEN
3585 # @ingroup l3_hypos_netgen
3586 def SetFineness(self, theFineness):
3587 self.Parameters().SetFineness(theFineness)
3590 # Parameter of FULL_NETGEN
3591 # @ingroup l3_hypos_netgen
3592 def SetGrowthRate(self, theRate):
3593 self.Parameters().SetGrowthRate(theRate)
3595 ## Sets NbSegPerEdge
3596 # Parameter of FULL_NETGEN
3597 # @ingroup l3_hypos_netgen
3598 def SetNbSegPerEdge(self, theVal):
3599 self.Parameters().SetNbSegPerEdge(theVal)
3601 ## Sets NbSegPerRadius
3602 # Parameter of FULL_NETGEN
3603 # @ingroup l3_hypos_netgen
3604 def SetNbSegPerRadius(self, theVal):
3605 self.Parameters().SetNbSegPerRadius(theVal)
3607 ## Sets number of segments overriding value set by SetLocalLength()
3608 # Only for algoType == NETGEN_FULL
3609 # @ingroup l3_hypos_netgen
3610 def SetNumberOfSegments(self, theVal):
3611 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3613 ## Sets number of segments overriding value set by SetNumberOfSegments()
3614 # Only for algoType == NETGEN_FULL
3615 # @ingroup l3_hypos_netgen
3616 def SetLocalLength(self, theVal):
3617 self.Parameters(SIMPLE).SetLocalLength(theVal)
3619 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3620 # Overrides value set by LengthFromEdges()
3621 # Only for algoType == NETGEN_FULL
3622 # @ingroup l3_hypos_netgen
3623 def MaxElementArea(self, area):
3624 self.Parameters(SIMPLE).SetMaxElementArea(area)
3626 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3627 # Overrides value set by MaxElementArea()
3628 # Only for algoType == NETGEN_FULL
3629 # @ingroup l3_hypos_netgen
3630 def LengthFromEdges(self):
3631 self.Parameters(SIMPLE).LengthFromEdges()
3633 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3634 # Overrides value set by MaxElementVolume()
3635 # Only for algoType == NETGEN_FULL
3636 # @ingroup l3_hypos_netgen
3637 def LengthFromFaces(self):
3638 self.Parameters(SIMPLE).LengthFromFaces()
3640 ## To mesh "holes" in a solid or not. Default is to mesh.
3641 # @ingroup l3_hypos_ghs3dh
3642 def SetToMeshHoles(self, toMesh):
3643 # Parameter of GHS3D
3644 self.Parameters().SetToMeshHoles(toMesh)
3646 ## Set Optimization level:
3647 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3648 # Default is Medium_Optimization
3649 # @ingroup l3_hypos_ghs3dh
3650 def SetOptimizationLevel(self, level):
3651 # Parameter of GHS3D
3652 self.Parameters().SetOptimizationLevel(level)
3654 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3655 # @ingroup l3_hypos_ghs3dh
3656 def SetMaximumMemory(self, MB):
3657 # Advanced parameter of GHS3D
3658 self.Parameters().SetMaximumMemory(MB)
3660 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3661 # automatic memory adjustment mode.
3662 # @ingroup l3_hypos_ghs3dh
3663 def SetInitialMemory(self, MB):
3664 # Advanced parameter of GHS3D
3665 self.Parameters().SetInitialMemory(MB)
3667 ## Path to working directory.
3668 # @ingroup l3_hypos_ghs3dh
3669 def SetWorkingDirectory(self, path):
3670 # Advanced parameter of GHS3D
3671 self.Parameters().SetWorkingDirectory(path)
3673 ## To keep working files or remove them. Log file remains in case of errors anyway.
3674 # @ingroup l3_hypos_ghs3dh
3675 def SetKeepFiles(self, toKeep):
3676 # Advanced parameter of GHS3D
3677 self.Parameters().SetKeepFiles(toKeep)
3679 ## To set verbose level [0-10]. <ul>
3680 #<li> 0 - no standard output,
3681 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3682 # indicates when the final mesh is being saved. In addition the software
3683 # gives indication regarding the CPU time.
3684 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3685 # histogram of the skin mesh, quality statistics histogram together with
3686 # the characteristics of the final mesh.</ul>
3687 # @ingroup l3_hypos_ghs3dh
3688 def SetVerboseLevel(self, level):
3689 # Advanced parameter of GHS3D
3690 self.Parameters().SetVerboseLevel(level)
3692 ## To create new nodes.
3693 # @ingroup l3_hypos_ghs3dh
3694 def SetToCreateNewNodes(self, toCreate):
3695 # Advanced parameter of GHS3D
3696 self.Parameters().SetToCreateNewNodes(toCreate)
3698 ## To use boundary recovery version which tries to create mesh on a very poor
3699 # quality surface mesh.
3700 # @ingroup l3_hypos_ghs3dh
3701 def SetToUseBoundaryRecoveryVersion(self, toUse):
3702 # Advanced parameter of GHS3D
3703 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3705 ## Sets command line option as text.
3706 # @ingroup l3_hypos_ghs3dh
3707 def SetTextOption(self, option):
3708 # Advanced parameter of GHS3D
3709 self.Parameters().SetTextOption(option)
3711 # Public class: Mesh_Hexahedron
3712 # ------------------------------
3714 ## Defines a hexahedron 3D algorithm
3716 # @ingroup l3_algos_basic
3717 class Mesh_Hexahedron(Mesh_Algorithm):
3722 ## Private constructor.
3723 def __init__(self, mesh, algoType=Hexa, geom=0):
3724 Mesh_Algorithm.__init__(self)
3726 self.algoType = algoType
3728 if algoType == Hexa:
3729 self.Create(mesh, geom, "Hexa_3D")
3732 elif algoType == Hexotic:
3733 import HexoticPlugin
3734 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3737 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3738 # @ingroup l3_hypos_hexotic
3739 def MinMaxQuad(self, min=3, max=8, quad=True):
3740 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3742 self.params.SetHexesMinLevel(min)
3743 self.params.SetHexesMaxLevel(max)
3744 self.params.SetHexoticQuadrangles(quad)
3747 # Deprecated, only for compatibility!
3748 # Public class: Mesh_Netgen
3749 # ------------------------------
3751 ## Defines a NETGEN-based 2D or 3D algorithm
3752 # that needs no discrete boundary (i.e. independent)
3754 # This class is deprecated, only for compatibility!
3757 # @ingroup l3_algos_basic
3758 class Mesh_Netgen(Mesh_Algorithm):
3762 ## Private constructor.
3763 def __init__(self, mesh, is3D, geom=0):
3764 Mesh_Algorithm.__init__(self)
3767 print "Warning: NETGENPlugin module has not been imported."
3771 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3775 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3778 ## Defines the hypothesis containing parameters of the algorithm
3779 def Parameters(self):
3781 hyp = self.Hypothesis("NETGEN_Parameters", [],
3782 "libNETGENEngine.so", UseExisting=0)
3784 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3785 "libNETGENEngine.so", UseExisting=0)
3788 # Public class: Mesh_Projection1D
3789 # ------------------------------
3791 ## Defines a projection 1D algorithm
3792 # @ingroup l3_algos_proj
3794 class Mesh_Projection1D(Mesh_Algorithm):
3796 ## Private constructor.
3797 def __init__(self, mesh, geom=0):
3798 Mesh_Algorithm.__init__(self)
3799 self.Create(mesh, geom, "Projection_1D")
3801 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3802 # a mesh pattern is taken, and, optionally, the association of vertices
3803 # between the source edge and a target edge (to which a hypothesis is assigned)
3804 # @param edge from which nodes distribution is taken
3805 # @param mesh from which nodes distribution is taken (optional)
3806 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3807 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3808 # to associate with \a srcV (optional)
3809 # @param UseExisting if ==true - searches for the existing hypothesis created with
3810 # the same parameters, else (default) - creates a new one
3811 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3812 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3814 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3815 hyp.SetSourceEdge( edge )
3816 if not mesh is None and isinstance(mesh, Mesh):
3817 mesh = mesh.GetMesh()
3818 hyp.SetSourceMesh( mesh )
3819 hyp.SetVertexAssociation( srcV, tgtV )
3822 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3823 #def CompareSourceEdge(self, hyp, args):
3824 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3828 # Public class: Mesh_Projection2D
3829 # ------------------------------
3831 ## Defines a projection 2D algorithm
3832 # @ingroup l3_algos_proj
3834 class Mesh_Projection2D(Mesh_Algorithm):
3836 ## Private constructor.
3837 def __init__(self, mesh, geom=0):
3838 Mesh_Algorithm.__init__(self)
3839 self.Create(mesh, geom, "Projection_2D")
3841 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3842 # a mesh pattern is taken, and, optionally, the association of vertices
3843 # between the source face and the target face (to which a hypothesis is assigned)
3844 # @param face from which the mesh pattern is taken
3845 # @param mesh from which the mesh pattern is taken (optional)
3846 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3847 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3848 # to associate with \a srcV1 (optional)
3849 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3850 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3851 # to associate with \a srcV2 (optional)
3852 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3853 # the same parameters, else (default) - forces the creation a new one
3855 # Note: all association vertices must belong to one edge of a face
3856 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3857 srcV2=None, tgtV2=None, UseExisting=0):
3858 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3860 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3861 hyp.SetSourceFace( face )
3862 if not mesh is None and isinstance(mesh, Mesh):
3863 mesh = mesh.GetMesh()
3864 hyp.SetSourceMesh( mesh )
3865 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3868 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3869 #def CompareSourceFace(self, hyp, args):
3870 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3873 # Public class: Mesh_Projection3D
3874 # ------------------------------
3876 ## Defines a projection 3D algorithm
3877 # @ingroup l3_algos_proj
3879 class Mesh_Projection3D(Mesh_Algorithm):
3881 ## Private constructor.
3882 def __init__(self, mesh, geom=0):
3883 Mesh_Algorithm.__init__(self)
3884 self.Create(mesh, geom, "Projection_3D")
3886 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3887 # the mesh pattern is taken, and, optionally, the association of vertices
3888 # between the source and the target solid (to which a hipothesis is assigned)
3889 # @param solid from where the mesh pattern is taken
3890 # @param mesh from where the mesh pattern is taken (optional)
3891 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3892 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3893 # to associate with \a srcV1 (optional)
3894 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3895 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3896 # to associate with \a srcV2 (optional)
3897 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3898 # the same parameters, else (default) - creates a new one
3900 # Note: association vertices must belong to one edge of a solid
3901 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3902 srcV2=0, tgtV2=0, UseExisting=0):
3903 hyp = self.Hypothesis("ProjectionSource3D",
3904 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3906 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3907 hyp.SetSource3DShape( solid )
3908 if not mesh is None and isinstance(mesh, Mesh):
3909 mesh = mesh.GetMesh()
3910 hyp.SetSourceMesh( mesh )
3911 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3914 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3915 #def CompareSourceShape3D(self, hyp, args):
3916 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3920 # Public class: Mesh_Prism
3921 # ------------------------
3923 ## Defines a 3D extrusion algorithm
3924 # @ingroup l3_algos_3dextr
3926 class Mesh_Prism3D(Mesh_Algorithm):
3928 ## Private constructor.
3929 def __init__(self, mesh, geom=0):
3930 Mesh_Algorithm.__init__(self)
3931 self.Create(mesh, geom, "Prism_3D")
3933 # Public class: Mesh_RadialPrism
3934 # -------------------------------
3936 ## Defines a Radial Prism 3D algorithm
3937 # @ingroup l3_algos_radialp
3939 class Mesh_RadialPrism3D(Mesh_Algorithm):
3941 ## Private constructor.
3942 def __init__(self, mesh, geom=0):
3943 Mesh_Algorithm.__init__(self)
3944 self.Create(mesh, geom, "RadialPrism_3D")
3946 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3947 self.nbLayers = None
3949 ## Return 3D hypothesis holding the 1D one
3950 def Get3DHypothesis(self):
3951 return self.distribHyp
3953 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3954 # hypothesis. Returns the created hypothesis
3955 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3956 #print "OwnHypothesis",hypType
3957 if not self.nbLayers is None:
3958 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3959 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3960 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3961 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3962 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3963 self.distribHyp.SetLayerDistribution( hyp )
3966 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3967 # prisms to build between the inner and outer shells
3968 # @param n number of layers
3969 # @param UseExisting if ==true - searches for the existing hypothesis created with
3970 # the same parameters, else (default) - creates a new one
3971 def NumberOfLayers(self, n, UseExisting=0):
3972 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3973 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3974 CompareMethod=self.CompareNumberOfLayers)
3975 self.nbLayers.SetNumberOfLayers( n )
3976 return self.nbLayers
3978 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3979 def CompareNumberOfLayers(self, hyp, args):
3980 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3982 ## Defines "LocalLength" hypothesis, specifying the segment length
3983 # to build between the inner and the outer shells
3984 # @param l the length of segments
3985 # @param p the precision of rounding
3986 def LocalLength(self, l, p=1e-07):
3987 hyp = self.OwnHypothesis("LocalLength", [l,p])
3992 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3993 # prisms to build between the inner and the outer shells.
3994 # @param n the number of layers
3995 # @param s the scale factor (optional)
3996 def NumberOfSegments(self, n, s=[]):
3998 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4000 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4001 hyp.SetDistrType( 1 )
4002 hyp.SetScaleFactor(s)
4003 hyp.SetNumberOfSegments(n)
4006 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4007 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4008 # @param start the length of the first segment
4009 # @param end the length of the last segment
4010 def Arithmetic1D(self, start, end ):
4011 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4012 hyp.SetLength(start, 1)
4013 hyp.SetLength(end , 0)
4016 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4017 # to build between the inner and the outer shells as geometric length increasing
4018 # @param start for the length of the first segment
4019 # @param end for the length of the last segment
4020 def StartEndLength(self, start, end):
4021 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4022 hyp.SetLength(start, 1)
4023 hyp.SetLength(end , 0)
4026 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4027 # to build between the inner and outer shells
4028 # @param fineness defines the quality of the mesh within the range [0-1]
4029 def AutomaticLength(self, fineness=0):
4030 hyp = self.OwnHypothesis("AutomaticLength")
4031 hyp.SetFineness( fineness )
4034 # Private class: Mesh_UseExisting
4035 # -------------------------------
4036 class Mesh_UseExisting(Mesh_Algorithm):
4038 def __init__(self, dim, mesh, geom=0):
4040 self.Create(mesh, geom, "UseExisting_1D")
4042 self.Create(mesh, geom, "UseExisting_2D")