1 # Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 # Author : Francis KLOSS, OCC
31 ## @defgroup l1_auxiliary Auxiliary methods and structures
32 ## @defgroup l1_creating Creating meshes
34 ## @defgroup l2_impexp Importing and exporting meshes
35 ## @defgroup l2_construct Constructing meshes
36 ## @defgroup l2_algorithms Defining Algorithms
38 ## @defgroup l3_algos_basic Basic meshing algorithms
39 ## @defgroup l3_algos_proj Projection Algorithms
40 ## @defgroup l3_algos_radialp Radial Prism
41 ## @defgroup l3_algos_segmarv Segments around Vertex
42 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
45 ## @defgroup l2_hypotheses Defining hypotheses
47 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
48 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
49 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
50 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
51 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
52 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
53 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
54 ## @defgroup l3_hypos_additi Additional Hypotheses
57 ## @defgroup l2_submeshes Constructing submeshes
58 ## @defgroup l2_compounds Building Compounds
59 ## @defgroup l2_editing Editing Meshes
62 ## @defgroup l1_meshinfo Mesh Information
63 ## @defgroup l1_controls Quality controls and Filtering
64 ## @defgroup l1_grouping Grouping elements
66 ## @defgroup l2_grps_create Creating groups
67 ## @defgroup l2_grps_edit Editing groups
68 ## @defgroup l2_grps_operon Using operations on groups
69 ## @defgroup l2_grps_delete Deleting Groups
72 ## @defgroup l1_modifying Modifying meshes
74 ## @defgroup l2_modif_add Adding nodes and elements
75 ## @defgroup l2_modif_del Removing nodes and elements
76 ## @defgroup l2_modif_edit Modifying nodes and elements
77 ## @defgroup l2_modif_renumber Renumbering nodes and elements
78 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
79 ## @defgroup l2_modif_movenode Moving nodes
80 ## @defgroup l2_modif_throughp Mesh through point
81 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
82 ## @defgroup l2_modif_unitetri Uniting triangles
83 ## @defgroup l2_modif_changori Changing orientation of elements
84 ## @defgroup l2_modif_cutquadr Cutting quadrangles
85 ## @defgroup l2_modif_smooth Smoothing
86 ## @defgroup l2_modif_extrurev Extrusion and Revolution
87 ## @defgroup l2_modif_patterns Pattern mapping
88 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
95 import SMESH # This is necessary for back compatibility
102 # import NETGENPlugin module if possible
110 ## @addtogroup l1_auxiliary
113 # Types of algorithms
126 NETGEN_1D2D3D = FULL_NETGEN
127 NETGEN_FULL = FULL_NETGEN
133 # MirrorType enumeration
134 POINT = SMESH_MeshEditor.POINT
135 AXIS = SMESH_MeshEditor.AXIS
136 PLANE = SMESH_MeshEditor.PLANE
138 # Smooth_Method enumeration
139 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
140 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
142 # Fineness enumeration (for NETGEN)
150 # Optimization level of GHS3D
151 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
153 # Topology treatment way of BLSURF
154 FromCAD, PreProcess, PreProcessPlus = 0,1,2
156 # Element size flag of BLSURF
157 DefaultSize, DefaultGeom, Custom = 0,0,1
159 PrecisionConfusion = 1e-07
161 def IsEqual(val1, val2, tol=PrecisionConfusion):
162 if abs(val1 - val2) < tol:
170 ior = salome.orb.object_to_string(obj)
171 sobj = salome.myStudy.FindObjectIOR(ior)
175 attr = sobj.FindAttribute("AttributeName")[1]
178 ## Sets a name to the object
179 def SetName(obj, name):
180 if isinstance( obj, Mesh ):
182 elif isinstance( obj, Mesh_Algorithm ):
183 obj = obj.GetAlgorithm()
184 ior = salome.orb.object_to_string(obj)
185 sobj = salome.myStudy.FindObjectIOR(ior)
187 attr = sobj.FindAttribute("AttributeName")[1]
190 ## Prints error message if a hypothesis was not assigned.
191 def TreatHypoStatus(status, hypName, geomName, isAlgo):
193 hypType = "algorithm"
195 hypType = "hypothesis"
197 if status == HYP_UNKNOWN_FATAL :
198 reason = "for unknown reason"
199 elif status == HYP_INCOMPATIBLE :
200 reason = "this hypothesis mismatches the algorithm"
201 elif status == HYP_NOTCONFORM :
202 reason = "a non-conform mesh would be built"
203 elif status == HYP_ALREADY_EXIST :
204 reason = hypType + " of the same dimension is already assigned to this shape"
205 elif status == HYP_BAD_DIM :
206 reason = hypType + " mismatches the shape"
207 elif status == HYP_CONCURENT :
208 reason = "there are concurrent hypotheses on sub-shapes"
209 elif status == HYP_BAD_SUBSHAPE :
210 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
211 elif status == HYP_BAD_GEOMETRY:
212 reason = "geometry mismatches the expectation of the algorithm"
213 elif status == HYP_HIDDEN_ALGO:
214 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
215 elif status == HYP_HIDING_ALGO:
216 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
217 elif status == HYP_NEED_SHAPE:
218 reason = "Algorithm can't work without shape"
221 hypName = '"' + hypName + '"'
222 geomName= '"' + geomName+ '"'
223 if status < HYP_UNKNOWN_FATAL:
224 print hypName, "was assigned to", geomName,"but", reason
226 print hypName, "was not assigned to",geomName,":", reason
229 ## Converts an angle from degrees to radians
230 def DegreesToRadians(AngleInDegrees):
232 return AngleInDegrees * pi / 180.0
234 # end of l1_auxiliary
237 # All methods of this class are accessible directly from the smesh.py package.
238 class smeshDC(SMESH._objref_SMESH_Gen):
240 ## Sets the current study and Geometry component
241 # @ingroup l1_auxiliary
242 def init_smesh(self,theStudy,geompyD):
243 self.SetCurrentStudy(theStudy,geompyD)
245 ## Creates an empty Mesh. This mesh can have an underlying geometry.
246 # @param obj the Geometrical object on which the mesh is built. If not defined,
247 # the mesh will have no underlying geometry.
248 # @param name the name for the new mesh.
249 # @return an instance of Mesh class.
250 # @ingroup l2_construct
251 def Mesh(self, obj=0, name=0):
252 return Mesh(self,self.geompyD,obj,name)
254 ## Returns a long value from enumeration
255 # Should be used for SMESH.FunctorType enumeration
256 # @ingroup l1_controls
257 def EnumToLong(self,theItem):
260 ## Gets PointStruct from vertex
261 # @param theVertex a GEOM object(vertex)
262 # @return SMESH.PointStruct
263 # @ingroup l1_auxiliary
264 def GetPointStruct(self,theVertex):
265 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
266 return PointStruct(x,y,z)
268 ## Gets DirStruct from vector
269 # @param theVector a GEOM object(vector)
270 # @return SMESH.DirStruct
271 # @ingroup l1_auxiliary
272 def GetDirStruct(self,theVector):
273 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
274 if(len(vertices) != 2):
275 print "Error: vector object is incorrect."
277 p1 = self.geompyD.PointCoordinates(vertices[0])
278 p2 = self.geompyD.PointCoordinates(vertices[1])
279 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
280 dirst = DirStruct(pnt)
283 ## Makes DirStruct from a triplet
284 # @param x,y,z vector components
285 # @return SMESH.DirStruct
286 # @ingroup l1_auxiliary
287 def MakeDirStruct(self,x,y,z):
288 pnt = PointStruct(x,y,z)
289 return DirStruct(pnt)
291 ## Get AxisStruct from object
292 # @param theObj a GEOM object (line or plane)
293 # @return SMESH.AxisStruct
294 # @ingroup l1_auxiliary
295 def GetAxisStruct(self,theObj):
296 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
298 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
299 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
300 vertex1 = self.geompyD.PointCoordinates(vertex1)
301 vertex2 = self.geompyD.PointCoordinates(vertex2)
302 vertex3 = self.geompyD.PointCoordinates(vertex3)
303 vertex4 = self.geompyD.PointCoordinates(vertex4)
304 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
305 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
306 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] ]
307 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
309 elif len(edges) == 1:
310 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
311 p1 = self.geompyD.PointCoordinates( vertex1 )
312 p2 = self.geompyD.PointCoordinates( vertex2 )
313 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
317 # From SMESH_Gen interface:
318 # ------------------------
320 ## Sets the current mode
321 # @ingroup l1_auxiliary
322 def SetEmbeddedMode( self,theMode ):
323 #self.SetEmbeddedMode(theMode)
324 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
326 ## Gets the current mode
327 # @ingroup l1_auxiliary
328 def IsEmbeddedMode(self):
329 #return self.IsEmbeddedMode()
330 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
332 ## Sets the current study
333 # @ingroup l1_auxiliary
334 def SetCurrentStudy( self, theStudy, geompyD = None ):
335 #self.SetCurrentStudy(theStudy)
338 geompyD = geompy.geom
341 self.SetGeomEngine(geompyD)
342 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
344 ## Gets the current study
345 # @ingroup l1_auxiliary
346 def GetCurrentStudy(self):
347 #return self.GetCurrentStudy()
348 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
350 ## Creates a Mesh object importing data from the given UNV file
351 # @return an instance of Mesh class
353 def CreateMeshesFromUNV( self,theFileName ):
354 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
355 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
358 ## Creates a Mesh object(s) importing data from the given MED file
359 # @return a list of Mesh class instances
361 def CreateMeshesFromMED( self,theFileName ):
362 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
364 for iMesh in range(len(aSmeshMeshes)) :
365 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
366 aMeshes.append(aMesh)
367 return aMeshes, aStatus
369 ## Creates a Mesh object importing data from the given STL file
370 # @return an instance of Mesh class
372 def CreateMeshesFromSTL( self, theFileName ):
373 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
374 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
377 ## Concatenate the given meshes into one mesh.
378 # @return an instance of Mesh class
379 # @param meshes the meshes to combine into one mesh
380 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
381 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
382 # @param mergeTolerance tolerance for merging nodes
383 # @param allGroups forces creation of groups of all elements
384 def Concatenate( self, meshes, uniteIdenticalGroups,
385 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
387 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
388 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
390 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
391 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
392 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
395 ## From SMESH_Gen interface
396 # @return the list of integer values
397 # @ingroup l1_auxiliary
398 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
399 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
401 ## From SMESH_Gen interface. Creates a pattern
402 # @return an instance of SMESH_Pattern
404 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
405 # @ingroup l2_modif_patterns
406 def GetPattern(self):
407 return SMESH._objref_SMESH_Gen.GetPattern(self)
410 # Filtering. Auxiliary functions:
411 # ------------------------------
413 ## Creates an empty criterion
414 # @return SMESH.Filter.Criterion
415 # @ingroup l1_controls
416 def GetEmptyCriterion(self):
417 Type = self.EnumToLong(FT_Undefined)
418 Compare = self.EnumToLong(FT_Undefined)
422 UnaryOp = self.EnumToLong(FT_Undefined)
423 BinaryOp = self.EnumToLong(FT_Undefined)
426 Precision = -1 ##@1e-07
427 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
428 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
430 ## Creates a criterion by the given parameters
431 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
432 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
433 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
434 # @param Treshold the threshold value (range of ids as string, shape, numeric)
435 # @param UnaryOp FT_LogicalNOT or FT_Undefined
436 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
437 # FT_Undefined (must be for the last criterion of all criteria)
438 # @return SMESH.Filter.Criterion
439 # @ingroup l1_controls
440 def GetCriterion(self,elementType,
442 Compare = FT_EqualTo,
444 UnaryOp=FT_Undefined,
445 BinaryOp=FT_Undefined):
446 aCriterion = self.GetEmptyCriterion()
447 aCriterion.TypeOfElement = elementType
448 aCriterion.Type = self.EnumToLong(CritType)
452 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
453 aCriterion.Compare = self.EnumToLong(Compare)
454 elif Compare == "=" or Compare == "==":
455 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
457 aCriterion.Compare = self.EnumToLong(FT_LessThan)
459 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
461 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
464 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
465 FT_BelongToCylinder, FT_LyingOnGeom]:
466 # Checks the treshold
467 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
468 aCriterion.ThresholdStr = GetName(aTreshold)
469 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
471 print "Error: The treshold should be a shape."
473 elif CritType == FT_RangeOfIds:
474 # Checks the treshold
475 if isinstance(aTreshold, str):
476 aCriterion.ThresholdStr = aTreshold
478 print "Error: The treshold should be a string."
480 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
481 # At this point the treshold is unnecessary
482 if aTreshold == FT_LogicalNOT:
483 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
484 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
485 aCriterion.BinaryOp = aTreshold
489 aTreshold = float(aTreshold)
490 aCriterion.Threshold = aTreshold
492 print "Error: The treshold should be a number."
495 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
496 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
498 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
499 aCriterion.BinaryOp = self.EnumToLong(Treshold)
501 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
502 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
504 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
505 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
509 ## Creates a filter with the given parameters
510 # @param elementType the type of elements in the group
511 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
512 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
513 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
514 # @param UnaryOp FT_LogicalNOT or FT_Undefined
515 # @return SMESH_Filter
516 # @ingroup l1_controls
517 def GetFilter(self,elementType,
518 CritType=FT_Undefined,
521 UnaryOp=FT_Undefined):
522 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
523 aFilterMgr = self.CreateFilterManager()
524 aFilter = aFilterMgr.CreateFilter()
526 aCriteria.append(aCriterion)
527 aFilter.SetCriteria(aCriteria)
530 ## Creates a numerical functor by its type
531 # @param theCriterion FT_...; functor type
532 # @return SMESH_NumericalFunctor
533 # @ingroup l1_controls
534 def GetFunctor(self,theCriterion):
535 aFilterMgr = self.CreateFilterManager()
536 if theCriterion == FT_AspectRatio:
537 return aFilterMgr.CreateAspectRatio()
538 elif theCriterion == FT_AspectRatio3D:
539 return aFilterMgr.CreateAspectRatio3D()
540 elif theCriterion == FT_Warping:
541 return aFilterMgr.CreateWarping()
542 elif theCriterion == FT_MinimumAngle:
543 return aFilterMgr.CreateMinimumAngle()
544 elif theCriterion == FT_Taper:
545 return aFilterMgr.CreateTaper()
546 elif theCriterion == FT_Skew:
547 return aFilterMgr.CreateSkew()
548 elif theCriterion == FT_Area:
549 return aFilterMgr.CreateArea()
550 elif theCriterion == FT_Volume3D:
551 return aFilterMgr.CreateVolume3D()
552 elif theCriterion == FT_MultiConnection:
553 return aFilterMgr.CreateMultiConnection()
554 elif theCriterion == FT_MultiConnection2D:
555 return aFilterMgr.CreateMultiConnection2D()
556 elif theCriterion == FT_Length:
557 return aFilterMgr.CreateLength()
558 elif theCriterion == FT_Length2D:
559 return aFilterMgr.CreateLength2D()
561 print "Error: given parameter is not numerucal functor type."
565 #Registering the new proxy for SMESH_Gen
566 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
572 ## This class allows defining and managing a mesh.
573 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
574 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
575 # new nodes and elements and by changing the existing entities), to get information
576 # about a mesh and to export a mesh into different formats.
585 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
586 # sets the GUI name of this mesh to \a name.
587 # @param smeshpyD an instance of smeshDC class
588 # @param geompyD an instance of geompyDC class
589 # @param obj Shape to be meshed or SMESH_Mesh object
590 # @param name Study name of the mesh
591 # @ingroup l2_construct
592 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
593 self.smeshpyD=smeshpyD
598 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
600 self.mesh = self.smeshpyD.CreateMesh(self.geom)
601 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
604 self.mesh = self.smeshpyD.CreateEmptyMesh()
606 SetName(self.mesh, name)
608 SetName(self.mesh, GetName(obj))
611 self.geom = self.mesh.GetShapeToMesh()
613 self.editor = self.mesh.GetMeshEditor()
615 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
616 # @param theMesh a SMESH_Mesh object
617 # @ingroup l2_construct
618 def SetMesh(self, theMesh):
620 self.geom = self.mesh.GetShapeToMesh()
622 ## Returns the mesh, that is an instance of SMESH_Mesh interface
623 # @return a SMESH_Mesh object
624 # @ingroup l2_construct
628 ## Gets the name of the mesh
629 # @return the name of the mesh as a string
630 # @ingroup l2_construct
632 name = GetName(self.GetMesh())
635 ## Sets a name to the mesh
636 # @param name a new name of the mesh
637 # @ingroup l2_construct
638 def SetName(self, name):
639 SetName(self.GetMesh(), name)
641 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
642 # The subMesh object gives access to the IDs of nodes and elements.
643 # @param theSubObject a geometrical object (shape)
644 # @param theName a name for the submesh
645 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
646 # @ingroup l2_submeshes
647 def GetSubMesh(self, theSubObject, theName):
648 submesh = self.mesh.GetSubMesh(theSubObject, theName)
651 ## Returns the shape associated to the mesh
652 # @return a GEOM_Object
653 # @ingroup l2_construct
657 ## Associates the given shape to the mesh (entails the recreation of the mesh)
658 # @param geom the shape to be meshed (GEOM_Object)
659 # @ingroup l2_construct
660 def SetShape(self, geom):
661 self.mesh = self.smeshpyD.CreateMesh(geom)
663 ## Returns true if the hypotheses are defined well
664 # @param theSubObject a subshape of a mesh shape
665 # @return True or False
666 # @ingroup l2_construct
667 def IsReadyToCompute(self, theSubObject):
668 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
670 ## Returns errors of hypotheses definition.
671 # The list of errors is empty if everything is OK.
672 # @param theSubObject a subshape of a mesh shape
673 # @return a list of errors
674 # @ingroup l2_construct
675 def GetAlgoState(self, theSubObject):
676 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
678 ## Returns a geometrical object on which the given element was built.
679 # The returned geometrical object, if not nil, is either found in the
680 # study or published by this method with the given name
681 # @param theElementID the id of the mesh element
682 # @param theGeomName the user-defined name of the geometrical object
683 # @return GEOM::GEOM_Object instance
684 # @ingroup l2_construct
685 def GetGeometryByMeshElement(self, theElementID, theGeomName):
686 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
688 ## Returns the mesh dimension depending on the dimension of the underlying shape
689 # @return mesh dimension as an integer value [0,3]
690 # @ingroup l1_auxiliary
691 def MeshDimension(self):
692 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
693 if len( shells ) > 0 :
695 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
697 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
703 ## Creates a segment discretization 1D algorithm.
704 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
705 # \n If the optional \a geom parameter is not set, this algorithm is global.
706 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
707 # @param algo the type of the required algorithm. Possible values are:
709 # - smesh.PYTHON for discretization via a python function,
710 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
711 # @param geom If defined is the subshape to be meshed
712 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
713 # @ingroup l3_algos_basic
714 def Segment(self, algo=REGULAR, geom=0):
715 ## if Segment(geom) is called by mistake
716 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
717 algo, geom = geom, algo
718 if not algo: algo = REGULAR
721 return Mesh_Segment(self, geom)
723 return Mesh_Segment_Python(self, geom)
724 elif algo == COMPOSITE:
725 return Mesh_CompositeSegment(self, geom)
727 return Mesh_Segment(self, geom)
729 ## Enables creation of nodes and segments usable by 2D algoritms.
730 # The added nodes and segments must be bound to edges and vertices by
731 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
732 # If the optional \a geom parameter is not set, this algorithm is global.
733 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
734 # @param geom the subshape to be manually meshed
735 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
736 # @ingroup l3_algos_basic
737 def UseExistingSegments(self, geom=0):
738 algo = Mesh_UseExisting(1,self,geom)
739 return algo.GetAlgorithm()
741 ## Enables creation of nodes and faces usable by 3D algoritms.
742 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
743 # and SetMeshElementOnShape()
744 # If the optional \a geom parameter is not set, this algorithm is global.
745 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
746 # @param geom the subshape to be manually meshed
747 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
748 # @ingroup l3_algos_basic
749 def UseExistingFaces(self, geom=0):
750 algo = Mesh_UseExisting(2,self,geom)
751 return algo.GetAlgorithm()
753 ## Creates a triangle 2D algorithm for faces.
754 # If the optional \a geom parameter is not set, this algorithm is global.
755 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
756 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
757 # @param geom If defined, the subshape to be meshed (GEOM_Object)
758 # @return an instance of Mesh_Triangle algorithm
759 # @ingroup l3_algos_basic
760 def Triangle(self, algo=MEFISTO, geom=0):
761 ## if Triangle(geom) is called by mistake
762 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
766 return Mesh_Triangle(self, algo, geom)
768 ## Creates a quadrangle 2D algorithm for faces.
769 # If the optional \a geom parameter is not set, this algorithm is global.
770 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
771 # @param geom If defined, the subshape to be meshed (GEOM_Object)
772 # @return an instance of Mesh_Quadrangle algorithm
773 # @ingroup l3_algos_basic
774 def Quadrangle(self, geom=0):
775 return Mesh_Quadrangle(self, geom)
777 ## Creates a tetrahedron 3D algorithm for solids.
778 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
779 # If the optional \a geom parameter is not set, this algorithm is global.
780 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
781 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.GHS3DPRL, smesh.FULL_NETGEN
782 # @param geom If defined, the subshape to be meshed (GEOM_Object)
783 # @return an instance of Mesh_Tetrahedron algorithm
784 # @ingroup l3_algos_basic
785 def Tetrahedron(self, algo=NETGEN, geom=0):
786 ## if Tetrahedron(geom) is called by mistake
787 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
788 algo, geom = geom, algo
789 if not algo: algo = NETGEN
791 return Mesh_Tetrahedron(self, algo, geom)
793 ## Creates a hexahedron 3D algorithm for solids.
794 # If the optional \a geom parameter is not set, this algorithm is global.
795 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
796 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
797 # @param geom If defined, the subshape to be meshed (GEOM_Object)
798 # @return an instance of Mesh_Hexahedron algorithm
799 # @ingroup l3_algos_basic
800 def Hexahedron(self, algo=Hexa, geom=0):
801 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
802 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
803 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
804 elif geom == 0: algo, geom = Hexa, algo
805 return Mesh_Hexahedron(self, algo, geom)
807 ## Deprecated, used only for compatibility!
808 # @return an instance of Mesh_Netgen algorithm
809 # @ingroup l3_algos_basic
810 def Netgen(self, is3D, geom=0):
811 return Mesh_Netgen(self, is3D, geom)
813 ## Creates a projection 1D algorithm for edges.
814 # If the optional \a geom parameter is not set, this algorithm is global.
815 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
816 # @param geom If defined, the subshape to be meshed
817 # @return an instance of Mesh_Projection1D algorithm
818 # @ingroup l3_algos_proj
819 def Projection1D(self, geom=0):
820 return Mesh_Projection1D(self, geom)
822 ## Creates a projection 2D algorithm for faces.
823 # If the optional \a geom parameter is not set, this algorithm is global.
824 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
825 # @param geom If defined, the subshape to be meshed
826 # @return an instance of Mesh_Projection2D algorithm
827 # @ingroup l3_algos_proj
828 def Projection2D(self, geom=0):
829 return Mesh_Projection2D(self, geom)
831 ## Creates a projection 3D algorithm for solids.
832 # If the optional \a geom parameter is not set, this algorithm is global.
833 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
834 # @param geom If defined, the subshape to be meshed
835 # @return an instance of Mesh_Projection3D algorithm
836 # @ingroup l3_algos_proj
837 def Projection3D(self, geom=0):
838 return Mesh_Projection3D(self, geom)
840 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
841 # If the optional \a geom parameter is not set, this algorithm is global.
842 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
843 # @param geom If defined, the subshape to be meshed
844 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
845 # @ingroup l3_algos_radialp l3_algos_3dextr
846 def Prism(self, geom=0):
850 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
851 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
852 if nbSolids == 0 or nbSolids == nbShells:
853 return Mesh_Prism3D(self, geom)
854 return Mesh_RadialPrism3D(self, geom)
856 ## Computes the mesh and returns the status of the computation
857 # @return True or False
858 # @ingroup l2_construct
859 def Compute(self, geom=0):
860 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
862 geom = self.mesh.GetShapeToMesh()
867 ok = self.smeshpyD.Compute(self.mesh, geom)
868 except SALOME.SALOME_Exception, ex:
869 print "Mesh computation failed, exception caught:"
870 print " ", ex.details.text
873 print "Mesh computation failed, exception caught:"
874 traceback.print_exc()
876 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
887 reason = '%s %sD algorithm is missing' % (glob, dim)
888 elif err.state == HYP_MISSING:
889 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
890 % (glob, dim, name, dim))
891 elif err.state == HYP_NOTCONFORM:
892 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
893 elif err.state == HYP_BAD_PARAMETER:
894 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
895 % ( glob, dim, name ))
896 elif err.state == HYP_BAD_GEOMETRY:
897 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
898 'geometry' % ( glob, dim, name ))
900 reason = "For unknown reason."+\
901 " Revise Mesh.Compute() implementation in smeshDC.py!"
909 print '"' + GetName(self.mesh) + '"',"has not been computed:"
913 print '"' + GetName(self.mesh) + '"',"has not been computed."
916 if salome.sg.hasDesktop():
917 smeshgui = salome.ImportComponentGUI("SMESH")
918 smeshgui.Init(salome.myStudyId)
919 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
920 salome.sg.updateObjBrowser(1)
924 ## Removes all nodes and elements
925 # @ingroup l2_construct
928 if salome.sg.hasDesktop():
929 smeshgui = salome.ImportComponentGUI("SMESH")
930 smeshgui.Init(salome.myStudyId)
931 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
932 salome.sg.updateObjBrowser(1)
934 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
935 # @param fineness [0,-1] defines mesh fineness
936 # @return True or False
937 # @ingroup l3_algos_basic
938 def AutomaticTetrahedralization(self, fineness=0):
939 dim = self.MeshDimension()
941 self.RemoveGlobalHypotheses()
942 self.Segment().AutomaticLength(fineness)
944 self.Triangle().LengthFromEdges()
947 self.Tetrahedron(NETGEN)
949 return self.Compute()
951 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
952 # @param fineness [0,-1] defines mesh fineness
953 # @return True or False
954 # @ingroup l3_algos_basic
955 def AutomaticHexahedralization(self, fineness=0):
956 dim = self.MeshDimension()
957 # assign the hypotheses
958 self.RemoveGlobalHypotheses()
959 self.Segment().AutomaticLength(fineness)
966 return self.Compute()
968 ## Assigns a hypothesis
969 # @param hyp a hypothesis to assign
970 # @param geom a subhape of mesh geometry
971 # @return SMESH.Hypothesis_Status
972 # @ingroup l2_hypotheses
973 def AddHypothesis(self, hyp, geom=0):
974 if isinstance( hyp, Mesh_Algorithm ):
975 hyp = hyp.GetAlgorithm()
980 geom = self.mesh.GetShapeToMesh()
982 status = self.mesh.AddHypothesis(geom, hyp)
983 isAlgo = hyp._narrow( SMESH_Algo )
984 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
987 ## Unassigns a hypothesis
988 # @param hyp a hypothesis to unassign
989 # @param geom a subshape of mesh geometry
990 # @return SMESH.Hypothesis_Status
991 # @ingroup l2_hypotheses
992 def RemoveHypothesis(self, hyp, geom=0):
993 if isinstance( hyp, Mesh_Algorithm ):
994 hyp = hyp.GetAlgorithm()
999 status = self.mesh.RemoveHypothesis(geom, hyp)
1002 ## Gets the list of hypotheses added on a geometry
1003 # @param geom a subshape of mesh geometry
1004 # @return the sequence of SMESH_Hypothesis
1005 # @ingroup l2_hypotheses
1006 def GetHypothesisList(self, geom):
1007 return self.mesh.GetHypothesisList( geom )
1009 ## Removes all global hypotheses
1010 # @ingroup l2_hypotheses
1011 def RemoveGlobalHypotheses(self):
1012 current_hyps = self.mesh.GetHypothesisList( self.geom )
1013 for hyp in current_hyps:
1014 self.mesh.RemoveHypothesis( self.geom, hyp )
1018 ## Creates a mesh group based on the geometric object \a grp
1019 # and gives a \a name, \n if this parameter is not defined
1020 # the name is the same as the geometric group name \n
1021 # Note: Works like GroupOnGeom().
1022 # @param grp a geometric group, a vertex, an edge, a face or a solid
1023 # @param name the name of the mesh group
1024 # @return SMESH_GroupOnGeom
1025 # @ingroup l2_grps_create
1026 def Group(self, grp, name=""):
1027 return self.GroupOnGeom(grp, name)
1029 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1030 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1031 # @param f the file name
1032 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1033 # @ingroup l2_impexp
1034 def ExportToMED(self, f, version, opt=0):
1035 self.mesh.ExportToMED(f, opt, version)
1037 ## Exports the mesh in a file in MED format
1038 # @param f is the file name
1039 # @param auto_groups boolean parameter for creating/not creating
1040 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1041 # the typical use is auto_groups=false.
1042 # @param version MED format version(MED_V2_1 or MED_V2_2)
1043 # @ingroup l2_impexp
1044 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1045 self.mesh.ExportToMED(f, auto_groups, version)
1047 ## Exports the mesh in a file in DAT format
1048 # @param f the file name
1049 # @ingroup l2_impexp
1050 def ExportDAT(self, f):
1051 self.mesh.ExportDAT(f)
1053 ## Exports the mesh in a file in UNV format
1054 # @param f the file name
1055 # @ingroup l2_impexp
1056 def ExportUNV(self, f):
1057 self.mesh.ExportUNV(f)
1059 ## Export the mesh in a file in STL format
1060 # @param f the file name
1061 # @param ascii defines the file encoding
1062 # @ingroup l2_impexp
1063 def ExportSTL(self, f, ascii=1):
1064 self.mesh.ExportSTL(f, ascii)
1067 # Operations with groups:
1068 # ----------------------
1070 ## Creates an empty mesh group
1071 # @param elementType the type of elements in the group
1072 # @param name the name of the mesh group
1073 # @return SMESH_Group
1074 # @ingroup l2_grps_create
1075 def CreateEmptyGroup(self, elementType, name):
1076 return self.mesh.CreateGroup(elementType, name)
1078 ## Creates a mesh group based on the geometrical object \a grp
1079 # and gives a \a name, \n if this parameter is not defined
1080 # the name is the same as the geometrical group name
1081 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1082 # @param name the name of the mesh group
1083 # @param typ the type of elements in the group. If not set, it is
1084 # automatically detected by the type of the geometry
1085 # @return SMESH_GroupOnGeom
1086 # @ingroup l2_grps_create
1087 def GroupOnGeom(self, grp, name="", typ=None):
1089 name = grp.GetName()
1092 tgeo = str(grp.GetShapeType())
1093 if tgeo == "VERTEX":
1095 elif tgeo == "EDGE":
1097 elif tgeo == "FACE":
1099 elif tgeo == "SOLID":
1101 elif tgeo == "SHELL":
1103 elif tgeo == "COMPOUND":
1104 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1105 print "Mesh.Group: empty geometric group", GetName( grp )
1107 tgeo = self.geompyD.GetType(grp)
1108 if tgeo == geompyDC.ShapeType["VERTEX"]:
1110 elif tgeo == geompyDC.ShapeType["EDGE"]:
1112 elif tgeo == geompyDC.ShapeType["FACE"]:
1114 elif tgeo == geompyDC.ShapeType["SOLID"]:
1118 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1121 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1123 ## Creates a mesh group by the given ids of elements
1124 # @param groupName the name of the mesh group
1125 # @param elementType the type of elements in the group
1126 # @param elemIDs the list of ids
1127 # @return SMESH_Group
1128 # @ingroup l2_grps_create
1129 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1130 group = self.mesh.CreateGroup(elementType, groupName)
1134 ## Creates a mesh group by the given conditions
1135 # @param groupName the name of the mesh group
1136 # @param elementType the type of elements in the group
1137 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1138 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1139 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1140 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1141 # @return SMESH_Group
1142 # @ingroup l2_grps_create
1146 CritType=FT_Undefined,
1149 UnaryOp=FT_Undefined):
1150 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1151 group = self.MakeGroupByCriterion(groupName, aCriterion)
1154 ## Creates a mesh group by the given criterion
1155 # @param groupName the name of the mesh group
1156 # @param Criterion the instance of Criterion class
1157 # @return SMESH_Group
1158 # @ingroup l2_grps_create
1159 def MakeGroupByCriterion(self, groupName, Criterion):
1160 aFilterMgr = self.smeshpyD.CreateFilterManager()
1161 aFilter = aFilterMgr.CreateFilter()
1163 aCriteria.append(Criterion)
1164 aFilter.SetCriteria(aCriteria)
1165 group = self.MakeGroupByFilter(groupName, aFilter)
1168 ## Creates a mesh group by the given criteria (list of criteria)
1169 # @param groupName the name of the mesh group
1170 # @param theCriteria the list of criteria
1171 # @return SMESH_Group
1172 # @ingroup l2_grps_create
1173 def MakeGroupByCriteria(self, groupName, theCriteria):
1174 aFilterMgr = self.smeshpyD.CreateFilterManager()
1175 aFilter = aFilterMgr.CreateFilter()
1176 aFilter.SetCriteria(theCriteria)
1177 group = self.MakeGroupByFilter(groupName, aFilter)
1180 ## Creates a mesh group by the given filter
1181 # @param groupName the name of the mesh group
1182 # @param theFilter the instance of Filter class
1183 # @return SMESH_Group
1184 # @ingroup l2_grps_create
1185 def MakeGroupByFilter(self, groupName, theFilter):
1186 anIds = theFilter.GetElementsId(self.mesh)
1187 anElemType = theFilter.GetElementType()
1188 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1191 ## Passes mesh elements through the given filter and return IDs of fitting elements
1192 # @param theFilter SMESH_Filter
1193 # @return a list of ids
1194 # @ingroup l1_controls
1195 def GetIdsFromFilter(self, theFilter):
1196 return theFilter.GetElementsId(self.mesh)
1198 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1199 # Returns a list of special structures (borders).
1200 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1201 # @ingroup l1_controls
1202 def GetFreeBorders(self):
1203 aFilterMgr = self.smeshpyD.CreateFilterManager()
1204 aPredicate = aFilterMgr.CreateFreeEdges()
1205 aPredicate.SetMesh(self.mesh)
1206 aBorders = aPredicate.GetBorders()
1210 # @ingroup l2_grps_delete
1211 def RemoveGroup(self, group):
1212 self.mesh.RemoveGroup(group)
1214 ## Removes a group with its contents
1215 # @ingroup l2_grps_delete
1216 def RemoveGroupWithContents(self, group):
1217 self.mesh.RemoveGroupWithContents(group)
1219 ## Gets the list of groups existing in the mesh
1220 # @return a sequence of SMESH_GroupBase
1221 # @ingroup l2_grps_create
1222 def GetGroups(self):
1223 return self.mesh.GetGroups()
1225 ## Gets the number of groups existing in the mesh
1226 # @return the quantity of groups as an integer value
1227 # @ingroup l2_grps_create
1229 return self.mesh.NbGroups()
1231 ## Gets the list of names of groups existing in the mesh
1232 # @return list of strings
1233 # @ingroup l2_grps_create
1234 def GetGroupNames(self):
1235 groups = self.GetGroups()
1237 for group in groups:
1238 names.append(group.GetName())
1241 ## Produces a union of two groups
1242 # A new group is created. All mesh elements that are
1243 # present in the initial groups are added to the new one
1244 # @return an instance of SMESH_Group
1245 # @ingroup l2_grps_operon
1246 def UnionGroups(self, group1, group2, name):
1247 return self.mesh.UnionGroups(group1, group2, name)
1249 ## Prodices an intersection of two groups
1250 # A new group is created. All mesh elements that are common
1251 # for the two initial groups are added to the new one.
1252 # @return an instance of SMESH_Group
1253 # @ingroup l2_grps_operon
1254 def IntersectGroups(self, group1, group2, name):
1255 return self.mesh.IntersectGroups(group1, group2, name)
1257 ## Produces a cut of two groups
1258 # A new group is created. All mesh elements that are present in
1259 # the main group but are not present in the tool group are added to the new one
1260 # @return an instance of SMESH_Group
1261 # @ingroup l2_grps_operon
1262 def CutGroups(self, mainGroup, toolGroup, name):
1263 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1266 # Get some info about mesh:
1267 # ------------------------
1269 ## Returns the log of nodes and elements added or removed
1270 # since the previous clear of the log.
1271 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1272 # @return list of log_block structures:
1277 # @ingroup l1_auxiliary
1278 def GetLog(self, clearAfterGet):
1279 return self.mesh.GetLog(clearAfterGet)
1281 ## Clears the log of nodes and elements added or removed since the previous
1282 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1283 # @ingroup l1_auxiliary
1285 self.mesh.ClearLog()
1287 ## Toggles auto color mode on the object.
1288 # @param theAutoColor the flag which toggles auto color mode.
1289 # @ingroup l1_auxiliary
1290 def SetAutoColor(self, theAutoColor):
1291 self.mesh.SetAutoColor(theAutoColor)
1293 ## Gets flag of object auto color mode.
1294 # @return True or False
1295 # @ingroup l1_auxiliary
1296 def GetAutoColor(self):
1297 return self.mesh.GetAutoColor()
1299 ## Gets the internal ID
1300 # @return integer value, which is the internal Id of the mesh
1301 # @ingroup l1_auxiliary
1303 return self.mesh.GetId()
1306 # @return integer value, which is the study Id of the mesh
1307 # @ingroup l1_auxiliary
1308 def GetStudyId(self):
1309 return self.mesh.GetStudyId()
1311 ## Checks the group names for duplications.
1312 # Consider the maximum group name length stored in MED file.
1313 # @return True or False
1314 # @ingroup l1_auxiliary
1315 def HasDuplicatedGroupNamesMED(self):
1316 return self.mesh.HasDuplicatedGroupNamesMED()
1318 ## Obtains the mesh editor tool
1319 # @return an instance of SMESH_MeshEditor
1320 # @ingroup l1_modifying
1321 def GetMeshEditor(self):
1322 return self.mesh.GetMeshEditor()
1325 # @return an instance of SALOME_MED::MESH
1326 # @ingroup l1_auxiliary
1327 def GetMEDMesh(self):
1328 return self.mesh.GetMEDMesh()
1331 # Get informations about mesh contents:
1332 # ------------------------------------
1334 ## Returns the number of nodes in the mesh
1335 # @return an integer value
1336 # @ingroup l1_meshinfo
1338 return self.mesh.NbNodes()
1340 ## Returns the number of elements in the mesh
1341 # @return an integer value
1342 # @ingroup l1_meshinfo
1343 def NbElements(self):
1344 return self.mesh.NbElements()
1346 ## Returns the number of edges in the mesh
1347 # @return an integer value
1348 # @ingroup l1_meshinfo
1350 return self.mesh.NbEdges()
1352 ## Returns the number of edges with the given order in the mesh
1353 # @param elementOrder the order of elements:
1354 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1355 # @return an integer value
1356 # @ingroup l1_meshinfo
1357 def NbEdgesOfOrder(self, elementOrder):
1358 return self.mesh.NbEdgesOfOrder(elementOrder)
1360 ## Returns the number of faces in the mesh
1361 # @return an integer value
1362 # @ingroup l1_meshinfo
1364 return self.mesh.NbFaces()
1366 ## Returns the number of faces with the given order in the mesh
1367 # @param elementOrder the order of elements:
1368 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1369 # @return an integer value
1370 # @ingroup l1_meshinfo
1371 def NbFacesOfOrder(self, elementOrder):
1372 return self.mesh.NbFacesOfOrder(elementOrder)
1374 ## Returns the number of triangles in the mesh
1375 # @return an integer value
1376 # @ingroup l1_meshinfo
1377 def NbTriangles(self):
1378 return self.mesh.NbTriangles()
1380 ## Returns the number of triangles with the given order in the mesh
1381 # @param elementOrder is the order of elements:
1382 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1383 # @return an integer value
1384 # @ingroup l1_meshinfo
1385 def NbTrianglesOfOrder(self, elementOrder):
1386 return self.mesh.NbTrianglesOfOrder(elementOrder)
1388 ## Returns the number of quadrangles in the mesh
1389 # @return an integer value
1390 # @ingroup l1_meshinfo
1391 def NbQuadrangles(self):
1392 return self.mesh.NbQuadrangles()
1394 ## Returns the number of quadrangles with the given order in the mesh
1395 # @param elementOrder the order of elements:
1396 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1397 # @return an integer value
1398 # @ingroup l1_meshinfo
1399 def NbQuadranglesOfOrder(self, elementOrder):
1400 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1402 ## Returns the number of polygons in the mesh
1403 # @return an integer value
1404 # @ingroup l1_meshinfo
1405 def NbPolygons(self):
1406 return self.mesh.NbPolygons()
1408 ## Returns the number of volumes in the mesh
1409 # @return an integer value
1410 # @ingroup l1_meshinfo
1411 def NbVolumes(self):
1412 return self.mesh.NbVolumes()
1414 ## Returns the number of volumes with the given order in the mesh
1415 # @param elementOrder the order of elements:
1416 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1417 # @return an integer value
1418 # @ingroup l1_meshinfo
1419 def NbVolumesOfOrder(self, elementOrder):
1420 return self.mesh.NbVolumesOfOrder(elementOrder)
1422 ## Returns the number of tetrahedrons in the mesh
1423 # @return an integer value
1424 # @ingroup l1_meshinfo
1426 return self.mesh.NbTetras()
1428 ## Returns the number of tetrahedrons with the given order in the mesh
1429 # @param elementOrder the order of elements:
1430 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1431 # @return an integer value
1432 # @ingroup l1_meshinfo
1433 def NbTetrasOfOrder(self, elementOrder):
1434 return self.mesh.NbTetrasOfOrder(elementOrder)
1436 ## Returns the number of hexahedrons in the mesh
1437 # @return an integer value
1438 # @ingroup l1_meshinfo
1440 return self.mesh.NbHexas()
1442 ## Returns the number of hexahedrons with the given order in the mesh
1443 # @param elementOrder the order of elements:
1444 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1445 # @return an integer value
1446 # @ingroup l1_meshinfo
1447 def NbHexasOfOrder(self, elementOrder):
1448 return self.mesh.NbHexasOfOrder(elementOrder)
1450 ## Returns the number of pyramids in the mesh
1451 # @return an integer value
1452 # @ingroup l1_meshinfo
1453 def NbPyramids(self):
1454 return self.mesh.NbPyramids()
1456 ## Returns the number of pyramids with the given order in the mesh
1457 # @param elementOrder the order of elements:
1458 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1459 # @return an integer value
1460 # @ingroup l1_meshinfo
1461 def NbPyramidsOfOrder(self, elementOrder):
1462 return self.mesh.NbPyramidsOfOrder(elementOrder)
1464 ## Returns the number of prisms in the mesh
1465 # @return an integer value
1466 # @ingroup l1_meshinfo
1468 return self.mesh.NbPrisms()
1470 ## Returns the number of prisms with the given order in the mesh
1471 # @param elementOrder the order of elements:
1472 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1473 # @return an integer value
1474 # @ingroup l1_meshinfo
1475 def NbPrismsOfOrder(self, elementOrder):
1476 return self.mesh.NbPrismsOfOrder(elementOrder)
1478 ## Returns the number of polyhedrons in the mesh
1479 # @return an integer value
1480 # @ingroup l1_meshinfo
1481 def NbPolyhedrons(self):
1482 return self.mesh.NbPolyhedrons()
1484 ## Returns the number of submeshes in the mesh
1485 # @return an integer value
1486 # @ingroup l1_meshinfo
1487 def NbSubMesh(self):
1488 return self.mesh.NbSubMesh()
1490 ## Returns the list of mesh elements IDs
1491 # @return the list of integer values
1492 # @ingroup l1_meshinfo
1493 def GetElementsId(self):
1494 return self.mesh.GetElementsId()
1496 ## Returns the list of IDs of mesh elements with the given type
1497 # @param elementType the required type of elements
1498 # @return list of integer values
1499 # @ingroup l1_meshinfo
1500 def GetElementsByType(self, elementType):
1501 return self.mesh.GetElementsByType(elementType)
1503 ## Returns the list of mesh nodes IDs
1504 # @return the list of integer values
1505 # @ingroup l1_meshinfo
1506 def GetNodesId(self):
1507 return self.mesh.GetNodesId()
1509 # Get the information about mesh elements:
1510 # ------------------------------------
1512 ## Returns the type of mesh element
1513 # @return the value from SMESH::ElementType enumeration
1514 # @ingroup l1_meshinfo
1515 def GetElementType(self, id, iselem):
1516 return self.mesh.GetElementType(id, iselem)
1518 ## Returns the list of submesh elements IDs
1519 # @param Shape a geom object(subshape) IOR
1520 # Shape must be the subshape of a ShapeToMesh()
1521 # @return the list of integer values
1522 # @ingroup l1_meshinfo
1523 def GetSubMeshElementsId(self, Shape):
1524 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1525 ShapeID = Shape.GetSubShapeIndices()[0]
1528 return self.mesh.GetSubMeshElementsId(ShapeID)
1530 ## Returns the list of submesh nodes IDs
1531 # @param Shape a geom object(subshape) IOR
1532 # Shape must be the subshape of a ShapeToMesh()
1533 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1534 # @return the list of integer values
1535 # @ingroup l1_meshinfo
1536 def GetSubMeshNodesId(self, Shape, all):
1537 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1538 ShapeID = Shape.GetSubShapeIndices()[0]
1541 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1543 ## Returns the list of IDs of submesh elements with the given type
1544 # @param Shape a geom object(subshape) IOR
1545 # Shape must be a subshape of a ShapeToMesh()
1546 # @return the list of integer values
1547 # @ingroup l1_meshinfo
1548 def GetSubMeshElementType(self, Shape):
1549 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1550 ShapeID = Shape.GetSubShapeIndices()[0]
1553 return self.mesh.GetSubMeshElementType(ShapeID)
1555 ## Gets the mesh description
1556 # @return string value
1557 # @ingroup l1_meshinfo
1559 return self.mesh.Dump()
1562 # Get the information about nodes and elements of a mesh by its IDs:
1563 # -----------------------------------------------------------
1565 ## Gets XYZ coordinates of a node
1566 # \n If there is no nodes for the given ID - returns an empty list
1567 # @return a list of double precision values
1568 # @ingroup l1_meshinfo
1569 def GetNodeXYZ(self, id):
1570 return self.mesh.GetNodeXYZ(id)
1572 ## Returns list of IDs of inverse elements for the given node
1573 # \n If there is no node for the given ID - returns an empty list
1574 # @return a list of integer values
1575 # @ingroup l1_meshinfo
1576 def GetNodeInverseElements(self, id):
1577 return self.mesh.GetNodeInverseElements(id)
1579 ## @brief Returns the position of a node on the shape
1580 # @return SMESH::NodePosition
1581 # @ingroup l1_meshinfo
1582 def GetNodePosition(self,NodeID):
1583 return self.mesh.GetNodePosition(NodeID)
1585 ## If the given element is a node, returns the ID of shape
1586 # \n If there is no node for the given ID - returns -1
1587 # @return an integer value
1588 # @ingroup l1_meshinfo
1589 def GetShapeID(self, id):
1590 return self.mesh.GetShapeID(id)
1592 ## Returns the ID of the result shape after
1593 # FindShape() from SMESH_MeshEditor for the given element
1594 # \n If there is no element for the given ID - returns -1
1595 # @return an integer value
1596 # @ingroup l1_meshinfo
1597 def GetShapeIDForElem(self,id):
1598 return self.mesh.GetShapeIDForElem(id)
1600 ## Returns the number of nodes for the given element
1601 # \n If there is no element for the given ID - returns -1
1602 # @return an integer value
1603 # @ingroup l1_meshinfo
1604 def GetElemNbNodes(self, id):
1605 return self.mesh.GetElemNbNodes(id)
1607 ## Returns the node ID the given index for the given element
1608 # \n If there is no element for the given ID - returns -1
1609 # \n If there is no node for the given index - returns -2
1610 # @return an integer value
1611 # @ingroup l1_meshinfo
1612 def GetElemNode(self, id, index):
1613 return self.mesh.GetElemNode(id, index)
1615 ## Returns the IDs of nodes of the given element
1616 # @return a list of integer values
1617 # @ingroup l1_meshinfo
1618 def GetElemNodes(self, id):
1619 return self.mesh.GetElemNodes(id)
1621 ## Returns true if the given node is the medium node in the given quadratic element
1622 # @ingroup l1_meshinfo
1623 def IsMediumNode(self, elementID, nodeID):
1624 return self.mesh.IsMediumNode(elementID, nodeID)
1626 ## Returns true if the given node is the medium node in one of quadratic elements
1627 # @ingroup l1_meshinfo
1628 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1629 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1631 ## Returns the number of edges for the given element
1632 # @ingroup l1_meshinfo
1633 def ElemNbEdges(self, id):
1634 return self.mesh.ElemNbEdges(id)
1636 ## Returns the number of faces for the given element
1637 # @ingroup l1_meshinfo
1638 def ElemNbFaces(self, id):
1639 return self.mesh.ElemNbFaces(id)
1641 ## Returns true if the given element is a polygon
1642 # @ingroup l1_meshinfo
1643 def IsPoly(self, id):
1644 return self.mesh.IsPoly(id)
1646 ## Returns true if the given element is quadratic
1647 # @ingroup l1_meshinfo
1648 def IsQuadratic(self, id):
1649 return self.mesh.IsQuadratic(id)
1651 ## Returns XYZ coordinates of the barycenter of the given element
1652 # \n If there is no element for the given ID - returns an empty list
1653 # @return a list of three double values
1654 # @ingroup l1_meshinfo
1655 def BaryCenter(self, id):
1656 return self.mesh.BaryCenter(id)
1659 # Mesh edition (SMESH_MeshEditor functionality):
1660 # ---------------------------------------------
1662 ## Removes the elements from the mesh by ids
1663 # @param IDsOfElements is a list of ids of elements to remove
1664 # @return True or False
1665 # @ingroup l2_modif_del
1666 def RemoveElements(self, IDsOfElements):
1667 return self.editor.RemoveElements(IDsOfElements)
1669 ## Removes nodes from mesh by ids
1670 # @param IDsOfNodes is a list of ids of nodes to remove
1671 # @return True or False
1672 # @ingroup l2_modif_del
1673 def RemoveNodes(self, IDsOfNodes):
1674 return self.editor.RemoveNodes(IDsOfNodes)
1676 ## Add a node to the mesh by coordinates
1677 # @return Id of the new node
1678 # @ingroup l2_modif_add
1679 def AddNode(self, x, y, z):
1680 return self.editor.AddNode( x, y, z)
1682 ## Creates a linear or quadratic edge (this is determined
1683 # by the number of given nodes).
1684 # @param IDsOfNodes the list of node IDs for creation of the element.
1685 # The order of nodes in this list should correspond to the description
1686 # of MED. \n This description is located by the following link:
1687 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1688 # @return the Id of the new edge
1689 # @ingroup l2_modif_add
1690 def AddEdge(self, IDsOfNodes):
1691 return self.editor.AddEdge(IDsOfNodes)
1693 ## Creates a linear or quadratic face (this is determined
1694 # by the number of given nodes).
1695 # @param IDsOfNodes the list of node IDs for creation of the element.
1696 # The order of nodes in this list should correspond to the description
1697 # of MED. \n This description is located by the following link:
1698 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1699 # @return the Id of the new face
1700 # @ingroup l2_modif_add
1701 def AddFace(self, IDsOfNodes):
1702 return self.editor.AddFace(IDsOfNodes)
1704 ## Adds a polygonal face to the mesh by the list of node IDs
1705 # @param IdsOfNodes the list of node IDs for creation of the element.
1706 # @return the Id of the new face
1707 # @ingroup l2_modif_add
1708 def AddPolygonalFace(self, IdsOfNodes):
1709 return self.editor.AddPolygonalFace(IdsOfNodes)
1711 ## Creates both simple and quadratic volume (this is determined
1712 # by the number of given nodes).
1713 # @param IDsOfNodes the list of node IDs for creation of the element.
1714 # The order of nodes in this list should correspond to the description
1715 # of MED. \n This description is located by the following link:
1716 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1717 # @return the Id of the new volumic element
1718 # @ingroup l2_modif_add
1719 def AddVolume(self, IDsOfNodes):
1720 return self.editor.AddVolume(IDsOfNodes)
1722 ## Creates a volume of many faces, giving nodes for each face.
1723 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1724 # @param Quantities the list of integer values, Quantities[i]
1725 # gives the quantity of nodes in face number i.
1726 # @return the Id of the new volumic element
1727 # @ingroup l2_modif_add
1728 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1729 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1731 ## Creates a volume of many faces, giving the IDs of the existing faces.
1732 # @param IdsOfFaces the list of face IDs for volume creation.
1734 # Note: The created volume will refer only to the nodes
1735 # of the given faces, not to the faces themselves.
1736 # @return the Id of the new volumic element
1737 # @ingroup l2_modif_add
1738 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1739 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1742 ## @brief Binds a node to a vertex
1743 # @param NodeID a node ID
1744 # @param Vertex a vertex or vertex ID
1745 # @return True if succeed else raises an exception
1746 # @ingroup l2_modif_add
1747 def SetNodeOnVertex(self, NodeID, Vertex):
1748 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1749 VertexID = Vertex.GetSubShapeIndices()[0]
1753 self.editor.SetNodeOnVertex(NodeID, VertexID)
1754 except SALOME.SALOME_Exception, inst:
1755 raise ValueError, inst.details.text
1759 ## @brief Stores the node position on an edge
1760 # @param NodeID a node ID
1761 # @param Edge an edge or edge ID
1762 # @param paramOnEdge a parameter on the edge where the node is located
1763 # @return True if succeed else raises an exception
1764 # @ingroup l2_modif_add
1765 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1766 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1767 EdgeID = Edge.GetSubShapeIndices()[0]
1771 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1772 except SALOME.SALOME_Exception, inst:
1773 raise ValueError, inst.details.text
1776 ## @brief Stores node position on a face
1777 # @param NodeID a node ID
1778 # @param Face a face or face ID
1779 # @param u U parameter on the face where the node is located
1780 # @param v V parameter on the face where the node is located
1781 # @return True if succeed else raises an exception
1782 # @ingroup l2_modif_add
1783 def SetNodeOnFace(self, NodeID, Face, u, v):
1784 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1785 FaceID = Face.GetSubShapeIndices()[0]
1789 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1790 except SALOME.SALOME_Exception, inst:
1791 raise ValueError, inst.details.text
1794 ## @brief Binds a node to a solid
1795 # @param NodeID a node ID
1796 # @param Solid a solid or solid ID
1797 # @return True if succeed else raises an exception
1798 # @ingroup l2_modif_add
1799 def SetNodeInVolume(self, NodeID, Solid):
1800 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1801 SolidID = Solid.GetSubShapeIndices()[0]
1805 self.editor.SetNodeInVolume(NodeID, SolidID)
1806 except SALOME.SALOME_Exception, inst:
1807 raise ValueError, inst.details.text
1810 ## @brief Bind an element to a shape
1811 # @param ElementID an element ID
1812 # @param Shape a shape or shape ID
1813 # @return True if succeed else raises an exception
1814 # @ingroup l2_modif_add
1815 def SetMeshElementOnShape(self, ElementID, Shape):
1816 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1817 ShapeID = Shape.GetSubShapeIndices()[0]
1821 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1822 except SALOME.SALOME_Exception, inst:
1823 raise ValueError, inst.details.text
1827 ## Moves the node with the given id
1828 # @param NodeID the id of the node
1829 # @param x a new X coordinate
1830 # @param y a new Y coordinate
1831 # @param z a new Z coordinate
1832 # @return True if succeed else False
1833 # @ingroup l2_modif_movenode
1834 def MoveNode(self, NodeID, x, y, z):
1835 return self.editor.MoveNode(NodeID, x, y, z)
1837 ## Finds the node closest to a point
1838 # @param x the X coordinate of a point
1839 # @param y the Y coordinate of a point
1840 # @param z the Z coordinate of a point
1841 # @return the ID of a node
1842 # @ingroup l2_modif_throughp
1843 def FindNodeClosestTo(self, x, y, z):
1844 preview = self.mesh.GetMeshEditPreviewer()
1845 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1847 ## Finds the node closest to a point and moves it to a point location
1848 # @param x the X coordinate of a point
1849 # @param y the Y coordinate of a point
1850 # @param z the Z coordinate of a point
1851 # @return the ID of a moved node
1852 # @ingroup l2_modif_throughp
1853 def MeshToPassThroughAPoint(self, x, y, z):
1854 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1856 ## Replaces two neighbour triangles sharing Node1-Node2 link
1857 # with the triangles built on the same 4 nodes but having other common link.
1858 # @param NodeID1 the ID of the first node
1859 # @param NodeID2 the ID of the second node
1860 # @return false if proper faces were not found
1861 # @ingroup l2_modif_invdiag
1862 def InverseDiag(self, NodeID1, NodeID2):
1863 return self.editor.InverseDiag(NodeID1, NodeID2)
1865 ## Replaces two neighbour triangles sharing Node1-Node2 link
1866 # with a quadrangle built on the same 4 nodes.
1867 # @param NodeID1 the ID of the first node
1868 # @param NodeID2 the ID of the second node
1869 # @return false if proper faces were not found
1870 # @ingroup l2_modif_unitetri
1871 def DeleteDiag(self, NodeID1, NodeID2):
1872 return self.editor.DeleteDiag(NodeID1, NodeID2)
1874 ## Reorients elements by ids
1875 # @param IDsOfElements if undefined reorients all mesh elements
1876 # @return True if succeed else False
1877 # @ingroup l2_modif_changori
1878 def Reorient(self, IDsOfElements=None):
1879 if IDsOfElements == None:
1880 IDsOfElements = self.GetElementsId()
1881 return self.editor.Reorient(IDsOfElements)
1883 ## Reorients all elements of the object
1884 # @param theObject mesh, submesh or group
1885 # @return True if succeed else False
1886 # @ingroup l2_modif_changori
1887 def ReorientObject(self, theObject):
1888 if ( isinstance( theObject, Mesh )):
1889 theObject = theObject.GetMesh()
1890 return self.editor.ReorientObject(theObject)
1892 ## Fuses the neighbouring triangles into quadrangles.
1893 # @param IDsOfElements The triangles to be fused,
1894 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1895 # @param MaxAngle is the maximum angle between element normals at which the fusion
1896 # is still performed; theMaxAngle is mesured in radians.
1897 # @return TRUE in case of success, FALSE otherwise.
1898 # @ingroup l2_modif_unitetri
1899 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1900 if IDsOfElements == []:
1901 IDsOfElements = self.GetElementsId()
1902 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1904 ## Fuses the neighbouring triangles of the object into quadrangles
1905 # @param theObject is mesh, submesh or group
1906 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1907 # @param MaxAngle a max angle between element normals at which the fusion
1908 # is still performed; theMaxAngle is mesured in radians.
1909 # @return TRUE in case of success, FALSE otherwise.
1910 # @ingroup l2_modif_unitetri
1911 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1912 if ( isinstance( theObject, Mesh )):
1913 theObject = theObject.GetMesh()
1914 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1916 ## Splits quadrangles into triangles.
1917 # @param IDsOfElements the faces to be splitted.
1918 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1919 # @return TRUE in case of success, FALSE otherwise.
1920 # @ingroup l2_modif_cutquadr
1921 def QuadToTri (self, IDsOfElements, theCriterion):
1922 if IDsOfElements == []:
1923 IDsOfElements = self.GetElementsId()
1924 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1926 ## Splits quadrangles into triangles.
1927 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1928 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1929 # @return TRUE in case of success, FALSE otherwise.
1930 # @ingroup l2_modif_cutquadr
1931 def QuadToTriObject (self, theObject, theCriterion):
1932 if ( isinstance( theObject, Mesh )):
1933 theObject = theObject.GetMesh()
1934 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1936 ## Splits quadrangles into triangles.
1937 # @param IDsOfElements the faces to be splitted
1938 # @param Diag13 is used to choose a diagonal for splitting.
1939 # @return TRUE in case of success, FALSE otherwise.
1940 # @ingroup l2_modif_cutquadr
1941 def SplitQuad (self, IDsOfElements, Diag13):
1942 if IDsOfElements == []:
1943 IDsOfElements = self.GetElementsId()
1944 return self.editor.SplitQuad(IDsOfElements, Diag13)
1946 ## Splits quadrangles into triangles.
1947 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1948 # @param Diag13 is used to choose a diagonal for splitting.
1949 # @return TRUE in case of success, FALSE otherwise.
1950 # @ingroup l2_modif_cutquadr
1951 def SplitQuadObject (self, theObject, Diag13):
1952 if ( isinstance( theObject, Mesh )):
1953 theObject = theObject.GetMesh()
1954 return self.editor.SplitQuadObject(theObject, Diag13)
1956 ## Finds a better splitting of the given quadrangle.
1957 # @param IDOfQuad the ID of the quadrangle to be splitted.
1958 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1959 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1960 # diagonal is better, 0 if error occurs.
1961 # @ingroup l2_modif_cutquadr
1962 def BestSplit (self, IDOfQuad, theCriterion):
1963 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1965 ## Splits quadrangle faces near triangular facets of volumes
1967 # @ingroup l1_auxiliary
1968 def SplitQuadsNearTriangularFacets(self):
1969 faces_array = self.GetElementsByType(SMESH.FACE)
1970 for face_id in faces_array:
1971 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1972 quad_nodes = self.mesh.GetElemNodes(face_id)
1973 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1974 isVolumeFound = False
1975 for node1_elem in node1_elems:
1976 if not isVolumeFound:
1977 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1978 nb_nodes = self.GetElemNbNodes(node1_elem)
1979 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1980 volume_elem = node1_elem
1981 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1982 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1983 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1984 isVolumeFound = True
1985 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1986 self.SplitQuad([face_id], False) # diagonal 2-4
1987 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1988 isVolumeFound = True
1989 self.SplitQuad([face_id], True) # diagonal 1-3
1990 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1991 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1992 isVolumeFound = True
1993 self.SplitQuad([face_id], True) # diagonal 1-3
1995 ## @brief Splits hexahedrons into tetrahedrons.
1997 # This operation uses pattern mapping functionality for splitting.
1998 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1999 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2000 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2001 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2002 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2003 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2004 # @return TRUE in case of success, FALSE otherwise.
2005 # @ingroup l1_auxiliary
2006 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2007 # Pattern: 5.---------.6
2012 # (0,0,1) 4.---------.7 * |
2019 # (0,0,0) 0.---------.3
2020 pattern_tetra = "!!! Nb of points: \n 8 \n\
2030 !!! Indices of points of 6 tetras: \n\
2038 pattern = self.smeshpyD.GetPattern()
2039 isDone = pattern.LoadFromFile(pattern_tetra)
2041 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2044 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2045 isDone = pattern.MakeMesh(self.mesh, False, False)
2046 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2048 # split quafrangle faces near triangular facets of volumes
2049 self.SplitQuadsNearTriangularFacets()
2053 ## @brief Split hexahedrons into prisms.
2055 # Uses the pattern mapping functionality for splitting.
2056 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2057 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2058 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2059 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2060 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2061 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2062 # @return TRUE in case of success, FALSE otherwise.
2063 # @ingroup l1_auxiliary
2064 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2065 # Pattern: 5.---------.6
2070 # (0,0,1) 4.---------.7 |
2077 # (0,0,0) 0.---------.3
2078 pattern_prism = "!!! Nb of points: \n 8 \n\
2088 !!! Indices of points of 2 prisms: \n\
2092 pattern = self.smeshpyD.GetPattern()
2093 isDone = pattern.LoadFromFile(pattern_prism)
2095 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2098 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2099 isDone = pattern.MakeMesh(self.mesh, False, False)
2100 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2102 # Splits quafrangle faces near triangular facets of volumes
2103 self.SplitQuadsNearTriangularFacets()
2107 ## Smoothes elements
2108 # @param IDsOfElements the list if ids of elements to smooth
2109 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2110 # Note that nodes built on edges and boundary nodes are always fixed.
2111 # @param MaxNbOfIterations the maximum number of iterations
2112 # @param MaxAspectRatio varies in range [1.0, inf]
2113 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2114 # @return TRUE in case of success, FALSE otherwise.
2115 # @ingroup l2_modif_smooth
2116 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2117 MaxNbOfIterations, MaxAspectRatio, Method):
2118 if IDsOfElements == []:
2119 IDsOfElements = self.GetElementsId()
2120 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2121 MaxNbOfIterations, MaxAspectRatio, Method)
2123 ## Smoothes elements which belong to the given object
2124 # @param theObject the object to smooth
2125 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2126 # Note that nodes built on edges and boundary nodes are always fixed.
2127 # @param MaxNbOfIterations the maximum number of iterations
2128 # @param MaxAspectRatio varies in range [1.0, inf]
2129 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2130 # @return TRUE in case of success, FALSE otherwise.
2131 # @ingroup l2_modif_smooth
2132 def SmoothObject(self, theObject, IDsOfFixedNodes,
2133 MaxNbOfIterations, MaxAspectRatio, Method):
2134 if ( isinstance( theObject, Mesh )):
2135 theObject = theObject.GetMesh()
2136 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2137 MaxNbOfIterations, MaxAspectRatio, Method)
2139 ## Parametrically smoothes the given elements
2140 # @param IDsOfElements the list if ids of elements to smooth
2141 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2142 # Note that nodes built on edges and boundary nodes are always fixed.
2143 # @param MaxNbOfIterations the maximum number of iterations
2144 # @param MaxAspectRatio varies in range [1.0, inf]
2145 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2146 # @return TRUE in case of success, FALSE otherwise.
2147 # @ingroup l2_modif_smooth
2148 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2149 MaxNbOfIterations, MaxAspectRatio, Method):
2150 if IDsOfElements == []:
2151 IDsOfElements = self.GetElementsId()
2152 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2153 MaxNbOfIterations, MaxAspectRatio, Method)
2155 ## Parametrically smoothes the elements which belong to the given object
2156 # @param theObject the object to smooth
2157 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2158 # Note that nodes built on edges and boundary nodes are always fixed.
2159 # @param MaxNbOfIterations the maximum number of iterations
2160 # @param MaxAspectRatio varies in range [1.0, inf]
2161 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2162 # @return TRUE in case of success, FALSE otherwise.
2163 # @ingroup l2_modif_smooth
2164 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2165 MaxNbOfIterations, MaxAspectRatio, Method):
2166 if ( isinstance( theObject, Mesh )):
2167 theObject = theObject.GetMesh()
2168 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2169 MaxNbOfIterations, MaxAspectRatio, Method)
2171 ## Converts the mesh to quadratic, deletes old elements, replacing
2172 # them with quadratic with the same id.
2173 # @ingroup l2_modif_tofromqu
2174 def ConvertToQuadratic(self, theForce3d):
2175 self.editor.ConvertToQuadratic(theForce3d)
2177 ## Converts the mesh from quadratic to ordinary,
2178 # deletes old quadratic elements, \n replacing
2179 # them with ordinary mesh elements with the same id.
2180 # @return TRUE in case of success, FALSE otherwise.
2181 # @ingroup l2_modif_tofromqu
2182 def ConvertFromQuadratic(self):
2183 return self.editor.ConvertFromQuadratic()
2185 ## Renumber mesh nodes
2186 # @ingroup l2_modif_renumber
2187 def RenumberNodes(self):
2188 self.editor.RenumberNodes()
2190 ## Renumber mesh elements
2191 # @ingroup l2_modif_renumber
2192 def RenumberElements(self):
2193 self.editor.RenumberElements()
2195 ## Generates new elements by rotation of the elements around the axis
2196 # @param IDsOfElements the list of ids of elements to sweep
2197 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2198 # @param AngleInRadians the angle of Rotation
2199 # @param NbOfSteps the number of steps
2200 # @param Tolerance tolerance
2201 # @param MakeGroups forces the generation of new groups from existing ones
2202 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2203 # of all steps, else - size of each step
2204 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2205 # @ingroup l2_modif_extrurev
2206 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2207 MakeGroups=False, TotalAngle=False):
2208 if IDsOfElements == []:
2209 IDsOfElements = self.GetElementsId()
2210 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2211 Axis = self.smeshpyD.GetAxisStruct(Axis)
2212 if TotalAngle and NbOfSteps:
2213 AngleInRadians /= NbOfSteps
2215 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2216 AngleInRadians, NbOfSteps, Tolerance)
2217 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2220 ## Generates new elements by rotation of the elements of object around the axis
2221 # @param theObject object which elements should be sweeped
2222 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2223 # @param AngleInRadians the angle of Rotation
2224 # @param NbOfSteps number of steps
2225 # @param Tolerance tolerance
2226 # @param MakeGroups forces the generation of new groups from existing ones
2227 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2228 # of all steps, else - size of each step
2229 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2230 # @ingroup l2_modif_extrurev
2231 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2232 MakeGroups=False, TotalAngle=False):
2233 if ( isinstance( theObject, Mesh )):
2234 theObject = theObject.GetMesh()
2235 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2236 Axis = self.smeshpyD.GetAxisStruct(Axis)
2237 if TotalAngle and NbOfSteps:
2238 AngleInRadians /= NbOfSteps
2240 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2241 NbOfSteps, Tolerance)
2242 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2245 ## Generates new elements by extrusion of the elements with given ids
2246 # @param IDsOfElements the list of elements ids for extrusion
2247 # @param StepVector vector, defining the direction and value of extrusion
2248 # @param NbOfSteps the number of steps
2249 # @param MakeGroups forces the generation of new groups from existing ones
2250 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2251 # @ingroup l2_modif_extrurev
2252 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2253 if IDsOfElements == []:
2254 IDsOfElements = self.GetElementsId()
2255 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2256 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2258 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2259 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2262 ## Generates new elements by extrusion of the elements with given ids
2263 # @param IDsOfElements is ids of elements
2264 # @param StepVector vector, defining the direction and value of extrusion
2265 # @param NbOfSteps the number of steps
2266 # @param ExtrFlags sets flags for extrusion
2267 # @param SewTolerance uses for comparing locations of nodes if flag
2268 # EXTRUSION_FLAG_SEW is set
2269 # @param MakeGroups forces the generation of new groups from existing ones
2270 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2271 # @ingroup l2_modif_extrurev
2272 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2273 ExtrFlags, SewTolerance, MakeGroups=False):
2274 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2275 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2277 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2278 ExtrFlags, SewTolerance)
2279 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2280 ExtrFlags, SewTolerance)
2283 ## Generates new elements by extrusion of the elements which belong to the object
2284 # @param theObject the object which elements should be processed
2285 # @param StepVector vector, defining the direction and value of extrusion
2286 # @param NbOfSteps the number of steps
2287 # @param MakeGroups forces the generation of new groups from existing ones
2288 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2289 # @ingroup l2_modif_extrurev
2290 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2291 if ( isinstance( theObject, Mesh )):
2292 theObject = theObject.GetMesh()
2293 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2294 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2296 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2297 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2300 ## Generates new elements by extrusion of the elements which belong to the object
2301 # @param theObject object which elements should be processed
2302 # @param StepVector vector, defining the direction and value of extrusion
2303 # @param NbOfSteps the number of steps
2304 # @param MakeGroups to generate new groups from existing ones
2305 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2306 # @ingroup l2_modif_extrurev
2307 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2308 if ( isinstance( theObject, Mesh )):
2309 theObject = theObject.GetMesh()
2310 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2311 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2313 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2314 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2317 ## Generates new elements by extrusion of the elements which belong to the object
2318 # @param theObject object which elements should be processed
2319 # @param StepVector vector, defining the direction and value of extrusion
2320 # @param NbOfSteps the number of steps
2321 # @param MakeGroups forces the generation of new groups from existing ones
2322 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2323 # @ingroup l2_modif_extrurev
2324 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2325 if ( isinstance( theObject, Mesh )):
2326 theObject = theObject.GetMesh()
2327 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2328 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2330 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2331 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2334 ## Generates new elements by extrusion of the given elements
2335 # The path of extrusion must be a meshed edge.
2336 # @param IDsOfElements ids of elements
2337 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2338 # @param PathShape shape(edge) defines the sub-mesh for the path
2339 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2340 # @param HasAngles allows the shape to be rotated around the path
2341 # to get the resulting mesh in a helical fashion
2342 # @param Angles list of angles
2343 # @param HasRefPoint allows using the reference point
2344 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2345 # The User can specify any point as the Reference Point.
2346 # @param MakeGroups forces the generation of new groups from existing ones
2347 # @param LinearVariation forces the computation of rotation angles as linear
2348 # variation of the given Angles along path steps
2349 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2350 # only SMESH::Extrusion_Error otherwise
2351 # @ingroup l2_modif_extrurev
2352 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2353 HasAngles, Angles, HasRefPoint, RefPoint,
2354 MakeGroups=False, LinearVariation=False):
2355 if IDsOfElements == []:
2356 IDsOfElements = self.GetElementsId()
2357 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2358 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2360 if ( isinstance( PathMesh, Mesh )):
2361 PathMesh = PathMesh.GetMesh()
2362 if HasAngles and Angles and LinearVariation:
2363 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2366 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2367 PathShape, NodeStart, HasAngles,
2368 Angles, HasRefPoint, RefPoint)
2369 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2370 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2372 ## Generates new elements by extrusion of the elements which belong to the object
2373 # The path of extrusion must be a meshed edge.
2374 # @param theObject the object which elements should be processed
2375 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2376 # @param PathShape shape(edge) defines the sub-mesh for the path
2377 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2378 # @param HasAngles allows the shape to be rotated around the path
2379 # to get the resulting mesh in a helical fashion
2380 # @param Angles list of angles
2381 # @param HasRefPoint allows using the reference point
2382 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2383 # The User can specify any point as the Reference Point.
2384 # @param MakeGroups forces the generation of new groups from existing ones
2385 # @param LinearVariation forces the computation of rotation angles as linear
2386 # variation of the given Angles along path steps
2387 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2388 # only SMESH::Extrusion_Error otherwise
2389 # @ingroup l2_modif_extrurev
2390 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2391 HasAngles, Angles, HasRefPoint, RefPoint,
2392 MakeGroups=False, LinearVariation=False):
2393 if ( isinstance( theObject, Mesh )):
2394 theObject = theObject.GetMesh()
2395 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2396 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2397 if ( isinstance( PathMesh, Mesh )):
2398 PathMesh = PathMesh.GetMesh()
2399 if HasAngles and Angles and LinearVariation:
2400 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2403 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2404 PathShape, NodeStart, HasAngles,
2405 Angles, HasRefPoint, RefPoint)
2406 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2407 NodeStart, HasAngles, Angles, HasRefPoint,
2410 ## Creates a symmetrical copy of mesh elements
2411 # @param IDsOfElements list of elements ids
2412 # @param Mirror is AxisStruct or geom object(point, line, plane)
2413 # @param theMirrorType is POINT, AXIS or PLANE
2414 # If the Mirror is a geom object this parameter is unnecessary
2415 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2416 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2417 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2418 # @ingroup l2_modif_trsf
2419 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2420 if IDsOfElements == []:
2421 IDsOfElements = self.GetElementsId()
2422 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2423 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2424 if Copy and MakeGroups:
2425 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2426 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2429 ## Creates a new mesh by a symmetrical copy of mesh elements
2430 # @param IDsOfElements the list of elements ids
2431 # @param Mirror is AxisStruct or geom object (point, line, plane)
2432 # @param theMirrorType is POINT, AXIS or PLANE
2433 # If the Mirror is a geom object this parameter is unnecessary
2434 # @param MakeGroups to generate new groups from existing ones
2435 # @param NewMeshName a name of the new mesh to create
2436 # @return instance of Mesh class
2437 # @ingroup l2_modif_trsf
2438 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2439 if IDsOfElements == []:
2440 IDsOfElements = self.GetElementsId()
2441 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2442 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2443 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2444 MakeGroups, NewMeshName)
2445 return Mesh(self.smeshpyD,self.geompyD,mesh)
2447 ## Creates a symmetrical copy of the object
2448 # @param theObject mesh, submesh or group
2449 # @param Mirror AxisStruct or geom object (point, line, plane)
2450 # @param theMirrorType is POINT, AXIS or PLANE
2451 # If the Mirror is a geom object this parameter is unnecessary
2452 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2453 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2454 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2455 # @ingroup l2_modif_trsf
2456 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2457 if ( isinstance( theObject, Mesh )):
2458 theObject = theObject.GetMesh()
2459 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2460 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2461 if Copy and MakeGroups:
2462 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2463 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2466 ## Creates a new mesh by a symmetrical copy of the object
2467 # @param theObject mesh, submesh or group
2468 # @param Mirror AxisStruct or geom object (point, line, plane)
2469 # @param theMirrorType POINT, AXIS or PLANE
2470 # If the Mirror is a geom object this parameter is unnecessary
2471 # @param MakeGroups forces the generation of new groups from existing ones
2472 # @param NewMeshName the name of the new mesh to create
2473 # @return instance of Mesh class
2474 # @ingroup l2_modif_trsf
2475 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2476 if ( isinstance( theObject, Mesh )):
2477 theObject = theObject.GetMesh()
2478 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2479 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2480 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2481 MakeGroups, NewMeshName)
2482 return Mesh( self.smeshpyD,self.geompyD,mesh )
2484 ## Translates the elements
2485 # @param IDsOfElements list of elements ids
2486 # @param Vector the direction of translation (DirStruct or vector)
2487 # @param Copy allows copying the translated elements
2488 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2489 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2490 # @ingroup l2_modif_trsf
2491 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2492 if IDsOfElements == []:
2493 IDsOfElements = self.GetElementsId()
2494 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2495 Vector = self.smeshpyD.GetDirStruct(Vector)
2496 if Copy and MakeGroups:
2497 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2498 self.editor.Translate(IDsOfElements, Vector, Copy)
2501 ## Creates a new mesh of translated elements
2502 # @param IDsOfElements list of elements ids
2503 # @param Vector the direction of translation (DirStruct or vector)
2504 # @param MakeGroups forces the generation of new groups from existing ones
2505 # @param NewMeshName the name of the newly created mesh
2506 # @return instance of Mesh class
2507 # @ingroup l2_modif_trsf
2508 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2509 if IDsOfElements == []:
2510 IDsOfElements = self.GetElementsId()
2511 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2512 Vector = self.smeshpyD.GetDirStruct(Vector)
2513 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2514 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2516 ## Translates the object
2517 # @param theObject the object to translate (mesh, submesh, or group)
2518 # @param Vector direction of translation (DirStruct or geom vector)
2519 # @param Copy allows copying the translated elements
2520 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2521 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2522 # @ingroup l2_modif_trsf
2523 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2524 if ( isinstance( theObject, Mesh )):
2525 theObject = theObject.GetMesh()
2526 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2527 Vector = self.smeshpyD.GetDirStruct(Vector)
2528 if Copy and MakeGroups:
2529 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2530 self.editor.TranslateObject(theObject, Vector, Copy)
2533 ## Creates a new mesh from the translated object
2534 # @param theObject the object to translate (mesh, submesh, or group)
2535 # @param Vector the direction of translation (DirStruct or geom vector)
2536 # @param MakeGroups forces the generation of new groups from existing ones
2537 # @param NewMeshName the name of the newly created mesh
2538 # @return instance of Mesh class
2539 # @ingroup l2_modif_trsf
2540 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2541 if (isinstance(theObject, Mesh)):
2542 theObject = theObject.GetMesh()
2543 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2544 Vector = self.smeshpyD.GetDirStruct(Vector)
2545 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2546 return Mesh( self.smeshpyD, self.geompyD, mesh )
2548 ## Rotates the elements
2549 # @param IDsOfElements list of elements ids
2550 # @param Axis the axis of rotation (AxisStruct or geom line)
2551 # @param AngleInRadians the angle of rotation (in radians)
2552 # @param Copy allows copying the rotated elements
2553 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2554 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2555 # @ingroup l2_modif_trsf
2556 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2557 if IDsOfElements == []:
2558 IDsOfElements = self.GetElementsId()
2559 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2560 Axis = self.smeshpyD.GetAxisStruct(Axis)
2561 if Copy and MakeGroups:
2562 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2563 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2566 ## Creates a new mesh of rotated elements
2567 # @param IDsOfElements list of element ids
2568 # @param Axis the axis of rotation (AxisStruct or geom line)
2569 # @param AngleInRadians the angle of rotation (in radians)
2570 # @param MakeGroups forces the generation of new groups from existing ones
2571 # @param NewMeshName the name of the newly created mesh
2572 # @return instance of Mesh class
2573 # @ingroup l2_modif_trsf
2574 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2575 if IDsOfElements == []:
2576 IDsOfElements = self.GetElementsId()
2577 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2578 Axis = self.smeshpyD.GetAxisStruct(Axis)
2579 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2580 MakeGroups, NewMeshName)
2581 return Mesh( self.smeshpyD, self.geompyD, mesh )
2583 ## Rotates the object
2584 # @param theObject the object to rotate( mesh, submesh, or group)
2585 # @param Axis the axis of rotation (AxisStruct or geom line)
2586 # @param AngleInRadians the angle of rotation (in radians)
2587 # @param Copy allows copying the rotated elements
2588 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2589 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2590 # @ingroup l2_modif_trsf
2591 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2592 if (isinstance(theObject, Mesh)):
2593 theObject = theObject.GetMesh()
2594 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2595 Axis = self.smeshpyD.GetAxisStruct(Axis)
2596 if Copy and MakeGroups:
2597 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2598 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2601 ## Creates a new mesh from the rotated object
2602 # @param theObject the object to rotate (mesh, submesh, or group)
2603 # @param Axis the axis of rotation (AxisStruct or geom line)
2604 # @param AngleInRadians the angle of rotation (in radians)
2605 # @param MakeGroups forces the generation of new groups from existing ones
2606 # @param NewMeshName the name of the newly created mesh
2607 # @return instance of Mesh class
2608 # @ingroup l2_modif_trsf
2609 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2610 if (isinstance( theObject, Mesh )):
2611 theObject = theObject.GetMesh()
2612 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2613 Axis = self.smeshpyD.GetAxisStruct(Axis)
2614 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2615 MakeGroups, NewMeshName)
2616 return Mesh( self.smeshpyD, self.geompyD, mesh )
2618 ## Finds groups of ajacent nodes within Tolerance.
2619 # @param Tolerance the value of tolerance
2620 # @return the list of groups of nodes
2621 # @ingroup l2_modif_trsf
2622 def FindCoincidentNodes (self, Tolerance):
2623 return self.editor.FindCoincidentNodes(Tolerance)
2625 ## Finds groups of ajacent nodes within Tolerance.
2626 # @param Tolerance the value of tolerance
2627 # @param SubMeshOrGroup SubMesh or Group
2628 # @return the list of groups of nodes
2629 # @ingroup l2_modif_trsf
2630 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2631 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2634 # @param GroupsOfNodes the list of groups of nodes
2635 # @ingroup l2_modif_trsf
2636 def MergeNodes (self, GroupsOfNodes):
2637 self.editor.MergeNodes(GroupsOfNodes)
2639 ## Finds the elements built on the same nodes.
2640 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2641 # @return a list of groups of equal elements
2642 # @ingroup l2_modif_trsf
2643 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2644 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2646 ## Merges elements in each given group.
2647 # @param GroupsOfElementsID groups of elements for merging
2648 # @ingroup l2_modif_trsf
2649 def MergeElements(self, GroupsOfElementsID):
2650 self.editor.MergeElements(GroupsOfElementsID)
2652 ## Leaves one element and removes all other elements built on the same nodes.
2653 # @ingroup l2_modif_trsf
2654 def MergeEqualElements(self):
2655 self.editor.MergeEqualElements()
2657 ## Sews free borders
2658 # @return SMESH::Sew_Error
2659 # @ingroup l2_modif_trsf
2660 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2661 FirstNodeID2, SecondNodeID2, LastNodeID2,
2662 CreatePolygons, CreatePolyedrs):
2663 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2664 FirstNodeID2, SecondNodeID2, LastNodeID2,
2665 CreatePolygons, CreatePolyedrs)
2667 ## Sews conform free borders
2668 # @return SMESH::Sew_Error
2669 # @ingroup l2_modif_trsf
2670 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2671 FirstNodeID2, SecondNodeID2):
2672 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2673 FirstNodeID2, SecondNodeID2)
2675 ## Sews border to side
2676 # @return SMESH::Sew_Error
2677 # @ingroup l2_modif_trsf
2678 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2679 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2680 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2681 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2683 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2684 # merged with the nodes of elements of Side2.
2685 # The number of elements in theSide1 and in theSide2 must be
2686 # equal and they should have similar nodal connectivity.
2687 # The nodes to merge should belong to side borders and
2688 # the first node should be linked to the second.
2689 # @return SMESH::Sew_Error
2690 # @ingroup l2_modif_trsf
2691 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2692 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2693 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2694 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2695 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2696 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2698 ## Sets new nodes for the given element.
2699 # @param ide the element id
2700 # @param newIDs nodes ids
2701 # @return If the number of nodes does not correspond to the type of element - returns false
2702 # @ingroup l2_modif_edit
2703 def ChangeElemNodes(self, ide, newIDs):
2704 return self.editor.ChangeElemNodes(ide, newIDs)
2706 ## If during the last operation of MeshEditor some nodes were
2707 # created, this method returns the list of their IDs, \n
2708 # if new nodes were not created - returns empty list
2709 # @return the list of integer values (can be empty)
2710 # @ingroup l1_auxiliary
2711 def GetLastCreatedNodes(self):
2712 return self.editor.GetLastCreatedNodes()
2714 ## If during the last operation of MeshEditor some elements were
2715 # created this method returns the list of their IDs, \n
2716 # if new elements were not created - returns empty list
2717 # @return the list of integer values (can be empty)
2718 # @ingroup l1_auxiliary
2719 def GetLastCreatedElems(self):
2720 return self.editor.GetLastCreatedElems()
2722 ## The mother class to define algorithm, it is not recommended to use it directly.
2725 # @ingroup l2_algorithms
2726 class Mesh_Algorithm:
2727 # @class Mesh_Algorithm
2728 # @brief Class Mesh_Algorithm
2730 #def __init__(self,smesh):
2738 ## Finds a hypothesis in the study by its type name and parameters.
2739 # Finds only the hypotheses created in smeshpyD engine.
2740 # @return SMESH.SMESH_Hypothesis
2741 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2742 study = smeshpyD.GetCurrentStudy()
2743 #to do: find component by smeshpyD object, not by its data type
2744 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2745 if scomp is not None:
2746 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2747 # Check if the root label of the hypotheses exists
2748 if res and hypRoot is not None:
2749 iter = study.NewChildIterator(hypRoot)
2750 # Check all published hypotheses
2752 hypo_so_i = iter.Value()
2753 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2754 if attr is not None:
2755 anIOR = attr.Value()
2756 hypo_o_i = salome.orb.string_to_object(anIOR)
2757 if hypo_o_i is not None:
2758 # Check if this is a hypothesis
2759 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2760 if hypo_i is not None:
2761 # Check if the hypothesis belongs to current engine
2762 if smeshpyD.GetObjectId(hypo_i) > 0:
2763 # Check if this is the required hypothesis
2764 if hypo_i.GetName() == hypname:
2766 if CompareMethod(hypo_i, args):
2780 ## Finds the algorithm in the study by its type name.
2781 # Finds only the algorithms, which have been created in smeshpyD engine.
2782 # @return SMESH.SMESH_Algo
2783 def FindAlgorithm (self, algoname, smeshpyD):
2784 study = smeshpyD.GetCurrentStudy()
2785 #to do: find component by smeshpyD object, not by its data type
2786 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2787 if scomp is not None:
2788 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2789 # Check if the root label of the algorithms exists
2790 if res and hypRoot is not None:
2791 iter = study.NewChildIterator(hypRoot)
2792 # Check all published algorithms
2794 algo_so_i = iter.Value()
2795 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2796 if attr is not None:
2797 anIOR = attr.Value()
2798 algo_o_i = salome.orb.string_to_object(anIOR)
2799 if algo_o_i is not None:
2800 # Check if this is an algorithm
2801 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2802 if algo_i is not None:
2803 # Checks if the algorithm belongs to the current engine
2804 if smeshpyD.GetObjectId(algo_i) > 0:
2805 # Check if this is the required algorithm
2806 if algo_i.GetName() == algoname:
2819 ## If the algorithm is global, returns 0; \n
2820 # else returns the submesh associated to this algorithm.
2821 def GetSubMesh(self):
2824 ## Returns the wrapped mesher.
2825 def GetAlgorithm(self):
2828 ## Gets the list of hypothesis that can be used with this algorithm
2829 def GetCompatibleHypothesis(self):
2832 mylist = self.algo.GetCompatibleHypothesis()
2835 ## Gets the name of the algorithm
2839 ## Sets the name to the algorithm
2840 def SetName(self, name):
2841 SetName(self.algo, name)
2843 ## Gets the id of the algorithm
2845 return self.algo.GetId()
2848 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2850 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2851 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2853 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2855 self.Assign(algo, mesh, geom)
2859 def Assign(self, algo, mesh, geom):
2861 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2868 name = GetName(geom)
2870 name = mesh.geompyD.SubShapeName(geom, piece)
2871 mesh.geompyD.addToStudyInFather(piece, geom, name)
2872 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2875 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2876 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2878 def CompareHyp (self, hyp, args):
2879 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2882 def CompareEqualHyp (self, hyp, args):
2886 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2887 UseExisting=0, CompareMethod=""):
2890 if CompareMethod == "": CompareMethod = self.CompareHyp
2891 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2894 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2900 a = a + s + str(args[i])
2904 SetName(hypo, hyp + a)
2906 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2907 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2911 # Public class: Mesh_Segment
2912 # --------------------------
2914 ## Class to define a segment 1D algorithm for discretization
2917 # @ingroup l3_algos_basic
2918 class Mesh_Segment(Mesh_Algorithm):
2920 ## Private constructor.
2921 def __init__(self, mesh, geom=0):
2922 Mesh_Algorithm.__init__(self)
2923 self.Create(mesh, geom, "Regular_1D")
2925 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2926 # @param l for the length of segments that cut an edge
2927 # @param UseExisting if ==true - searches for an existing hypothesis created with
2928 # the same parameters, else (default) - creates a new one
2929 # @param p precision, used for calculation of the number of segments.
2930 # The precision should be a positive, meaningful value within the range [0,1].
2931 # In general, the number of segments is calculated with the formula:
2932 # nb = ceil((edge_length / l) - p)
2933 # Function ceil rounds its argument to the higher integer.
2934 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2935 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2936 # p=1 means rounding of (edge_length / l) to the lower integer.
2937 # Default value is 1e-07.
2938 # @return an instance of StdMeshers_LocalLength hypothesis
2939 # @ingroup l3_hypos_1dhyps
2940 def LocalLength(self, l, UseExisting=0, p=1e-07):
2941 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2942 CompareMethod=self.CompareLocalLength)
2948 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2949 def CompareLocalLength(self, hyp, args):
2950 if IsEqual(hyp.GetLength(), args[0]):
2951 return IsEqual(hyp.GetPrecision(), args[1])
2954 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2955 # @param n for the number of segments that cut an edge
2956 # @param s for the scale factor (optional)
2957 # @param UseExisting if ==true - searches for an existing hypothesis created with
2958 # the same parameters, else (default) - create a new one
2959 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2960 # @ingroup l3_hypos_1dhyps
2961 def NumberOfSegments(self, n, s=[], UseExisting=0):
2963 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2964 CompareMethod=self.CompareNumberOfSegments)
2966 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2967 CompareMethod=self.CompareNumberOfSegments)
2968 hyp.SetDistrType( 1 )
2969 hyp.SetScaleFactor(s)
2970 hyp.SetNumberOfSegments(n)
2974 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2975 def CompareNumberOfSegments(self, hyp, args):
2976 if hyp.GetNumberOfSegments() == args[0]:
2980 if hyp.GetDistrType() == 1:
2981 if IsEqual(hyp.GetScaleFactor(), args[1]):
2985 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2986 # @param start defines the length of the first segment
2987 # @param end defines the length of the last segment
2988 # @param UseExisting if ==true - searches for an existing hypothesis created with
2989 # the same parameters, else (default) - creates a new one
2990 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2991 # @ingroup l3_hypos_1dhyps
2992 def Arithmetic1D(self, start, end, UseExisting=0):
2993 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2994 CompareMethod=self.CompareArithmetic1D)
2995 hyp.SetLength(start, 1)
2996 hyp.SetLength(end , 0)
3000 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3001 def CompareArithmetic1D(self, hyp, args):
3002 if IsEqual(hyp.GetLength(1), args[0]):
3003 if IsEqual(hyp.GetLength(0), args[1]):
3007 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3008 # @param start defines the length of the first segment
3009 # @param end defines the length of the last segment
3010 # @param UseExisting if ==true - searches for an existing hypothesis created with
3011 # the same parameters, else (default) - creates a new one
3012 # @return an instance of StdMeshers_StartEndLength hypothesis
3013 # @ingroup l3_hypos_1dhyps
3014 def StartEndLength(self, start, end, UseExisting=0):
3015 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3016 CompareMethod=self.CompareStartEndLength)
3017 hyp.SetLength(start, 1)
3018 hyp.SetLength(end , 0)
3021 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3022 def CompareStartEndLength(self, hyp, args):
3023 if IsEqual(hyp.GetLength(1), args[0]):
3024 if IsEqual(hyp.GetLength(0), args[1]):
3028 ## Defines "Deflection1D" hypothesis
3029 # @param d for the deflection
3030 # @param UseExisting if ==true - searches for an existing hypothesis created with
3031 # the same parameters, else (default) - create a new one
3032 # @ingroup l3_hypos_1dhyps
3033 def Deflection1D(self, d, UseExisting=0):
3034 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3035 CompareMethod=self.CompareDeflection1D)
3036 hyp.SetDeflection(d)
3039 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3040 def CompareDeflection1D(self, hyp, args):
3041 return IsEqual(hyp.GetDeflection(), args[0])
3043 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3044 # the opposite side in case of quadrangular faces
3045 # @ingroup l3_hypos_additi
3046 def Propagation(self):
3047 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3049 ## Defines "AutomaticLength" hypothesis
3050 # @param fineness for the fineness [0-1]
3051 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3052 # same parameters, else (default) - create a new one
3053 # @ingroup l3_hypos_1dhyps
3054 def AutomaticLength(self, fineness=0, UseExisting=0):
3055 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3056 CompareMethod=self.CompareAutomaticLength)
3057 hyp.SetFineness( fineness )
3060 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3061 def CompareAutomaticLength(self, hyp, args):
3062 return IsEqual(hyp.GetFineness(), args[0])
3064 ## Defines "SegmentLengthAroundVertex" hypothesis
3065 # @param length for the segment length
3066 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3067 # Any other integer value means that the hypothesis will be set on the
3068 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3069 # @param UseExisting if ==true - searches for an existing hypothesis created with
3070 # the same parameters, else (default) - creates a new one
3071 # @ingroup l3_algos_segmarv
3072 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3074 store_geom = self.geom
3075 if type(vertex) is types.IntType:
3076 if vertex == 0 or vertex == 1:
3077 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3085 if self.geom is None:
3086 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3087 name = GetName(self.geom)
3089 piece = self.mesh.geom
3090 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3091 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3092 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3094 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3096 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3097 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3099 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3100 CompareMethod=self.CompareLengthNearVertex)
3101 self.geom = store_geom
3102 hyp.SetLength( length )
3105 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3106 # @ingroup l3_algos_segmarv
3107 def CompareLengthNearVertex(self, hyp, args):
3108 return IsEqual(hyp.GetLength(), args[0])
3110 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3111 # If the 2D mesher sees that all boundary edges are quadratic,
3112 # it generates quadratic faces, else it generates linear faces using
3113 # medium nodes as if they are vertices.
3114 # The 3D mesher generates quadratic volumes only if all boundary faces
3115 # are quadratic, else it fails.
3117 # @ingroup l3_hypos_additi
3118 def QuadraticMesh(self):
3119 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3122 # Public class: Mesh_CompositeSegment
3123 # --------------------------
3125 ## Defines a segment 1D algorithm for discretization
3127 # @ingroup l3_algos_basic
3128 class Mesh_CompositeSegment(Mesh_Segment):
3130 ## Private constructor.
3131 def __init__(self, mesh, geom=0):
3132 self.Create(mesh, geom, "CompositeSegment_1D")
3135 # Public class: Mesh_Segment_Python
3136 # ---------------------------------
3138 ## Defines a segment 1D algorithm for discretization with python function
3140 # @ingroup l3_algos_basic
3141 class Mesh_Segment_Python(Mesh_Segment):
3143 ## Private constructor.
3144 def __init__(self, mesh, geom=0):
3145 import Python1dPlugin
3146 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3148 ## Defines "PythonSplit1D" hypothesis
3149 # @param n for the number of segments that cut an edge
3150 # @param func for the python function that calculates the length of all segments
3151 # @param UseExisting if ==true - searches for the existing hypothesis created with
3152 # the same parameters, else (default) - creates a new one
3153 # @ingroup l3_hypos_1dhyps
3154 def PythonSplit1D(self, n, func, UseExisting=0):
3155 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3156 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3157 hyp.SetNumberOfSegments(n)
3158 hyp.SetPythonLog10RatioFunction(func)
3161 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3162 def ComparePythonSplit1D(self, hyp, args):
3163 #if hyp.GetNumberOfSegments() == args[0]:
3164 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3168 # Public class: Mesh_Triangle
3169 # ---------------------------
3171 ## Defines a triangle 2D algorithm
3173 # @ingroup l3_algos_basic
3174 class Mesh_Triangle(Mesh_Algorithm):
3183 ## Private constructor.
3184 def __init__(self, mesh, algoType, geom=0):
3185 Mesh_Algorithm.__init__(self)
3187 self.algoType = algoType
3188 if algoType == MEFISTO:
3189 self.Create(mesh, geom, "MEFISTO_2D")
3191 elif algoType == BLSURF:
3193 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3194 #self.SetPhysicalMesh() - PAL19680
3195 elif algoType == NETGEN:
3197 print "Warning: NETGENPlugin module unavailable"
3199 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3201 elif algoType == NETGEN_2D:
3203 print "Warning: NETGENPlugin module unavailable"
3205 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3208 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3209 # @param area for the maximum area of each triangle
3210 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3211 # same parameters, else (default) - creates a new one
3213 # Only for algoType == MEFISTO || NETGEN_2D
3214 # @ingroup l3_hypos_2dhyps
3215 def MaxElementArea(self, area, UseExisting=0):
3216 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3217 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3218 CompareMethod=self.CompareMaxElementArea)
3219 elif self.algoType == NETGEN:
3220 hyp = self.Parameters(SIMPLE)
3221 hyp.SetMaxElementArea(area)
3224 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3225 def CompareMaxElementArea(self, hyp, args):
3226 return IsEqual(hyp.GetMaxElementArea(), args[0])
3228 ## Defines "LengthFromEdges" hypothesis to build triangles
3229 # based on the length of the edges taken from the wire
3231 # Only for algoType == MEFISTO || NETGEN_2D
3232 # @ingroup l3_hypos_2dhyps
3233 def LengthFromEdges(self):
3234 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3235 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3237 elif self.algoType == NETGEN:
3238 hyp = self.Parameters(SIMPLE)
3239 hyp.LengthFromEdges()
3242 ## Sets a way to define size of mesh elements to generate.
3243 # @param thePhysicalMesh is: DefaultSize or Custom.
3244 # @ingroup l3_hypos_blsurf
3245 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3246 # Parameter of BLSURF algo
3247 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3249 ## Sets size of mesh elements to generate.
3250 # @ingroup l3_hypos_blsurf
3251 def SetPhySize(self, theVal):
3252 # Parameter of BLSURF algo
3253 self.Parameters().SetPhySize(theVal)
3255 ## Sets lower boundary of mesh element size (PhySize).
3256 # @ingroup l3_hypos_blsurf
3257 def SetPhyMin(self, theVal=-1):
3258 # Parameter of BLSURF algo
3259 self.Parameters().SetPhyMin(theVal)
3261 ## Sets upper boundary of mesh element size (PhySize).
3262 # @ingroup l3_hypos_blsurf
3263 def SetPhyMax(self, theVal=-1):
3264 # Parameter of BLSURF algo
3265 self.Parameters().SetPhyMax(theVal)
3267 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3268 # @param theGeometricMesh is: DefaultGeom or Custom
3269 # @ingroup l3_hypos_blsurf
3270 def SetGeometricMesh(self, theGeometricMesh=0):
3271 # Parameter of BLSURF algo
3272 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3273 self.params.SetGeometricMesh(theGeometricMesh)
3275 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3276 # @ingroup l3_hypos_blsurf
3277 def SetAngleMeshS(self, theVal=_angleMeshS):
3278 # Parameter of BLSURF algo
3279 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3280 self.params.SetAngleMeshS(theVal)
3282 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3283 # @ingroup l3_hypos_blsurf
3284 def SetAngleMeshC(self, theVal=_angleMeshS):
3285 # Parameter of BLSURF algo
3286 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3287 self.params.SetAngleMeshC(theVal)
3289 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3290 # @ingroup l3_hypos_blsurf
3291 def SetGeoMin(self, theVal=-1):
3292 # Parameter of BLSURF algo
3293 self.Parameters().SetGeoMin(theVal)
3295 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3296 # @ingroup l3_hypos_blsurf
3297 def SetGeoMax(self, theVal=-1):
3298 # Parameter of BLSURF algo
3299 self.Parameters().SetGeoMax(theVal)
3301 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3302 # @ingroup l3_hypos_blsurf
3303 def SetGradation(self, theVal=_gradation):
3304 # Parameter of BLSURF algo
3305 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3306 self.params.SetGradation(theVal)
3308 ## Sets topology usage way.
3309 # @param way defines how mesh conformity is assured <ul>
3310 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3311 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3312 # @ingroup l3_hypos_blsurf
3313 def SetTopology(self, way):
3314 # Parameter of BLSURF algo
3315 self.Parameters().SetTopology(way)
3317 ## To respect geometrical edges or not.
3318 # @ingroup l3_hypos_blsurf
3319 def SetDecimesh(self, toIgnoreEdges=False):
3320 # Parameter of BLSURF algo
3321 self.Parameters().SetDecimesh(toIgnoreEdges)
3323 ## Sets verbosity level in the range 0 to 100.
3324 # @ingroup l3_hypos_blsurf
3325 def SetVerbosity(self, level):
3326 # Parameter of BLSURF algo
3327 self.Parameters().SetVerbosity(level)
3329 ## Sets advanced option value.
3330 # @ingroup l3_hypos_blsurf
3331 def SetOptionValue(self, optionName, level):
3332 # Parameter of BLSURF algo
3333 self.Parameters().SetOptionValue(optionName,level)
3335 ## Sets QuadAllowed flag.
3336 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3337 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3338 def SetQuadAllowed(self, toAllow=True):
3339 if self.algoType == NETGEN_2D:
3340 if toAllow: # add QuadranglePreference
3341 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3342 else: # remove QuadranglePreference
3343 for hyp in self.mesh.GetHypothesisList( self.geom ):
3344 if hyp.GetName() == "QuadranglePreference":
3345 self.mesh.RemoveHypothesis( self.geom, hyp )
3350 if self.Parameters():
3351 self.params.SetQuadAllowed(toAllow)
3354 ## Defines hypothesis having several parameters
3356 # @ingroup l3_hypos_netgen
3357 def Parameters(self, which=SOLE):
3360 if self.algoType == NETGEN:
3362 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3363 "libNETGENEngine.so", UseExisting=0)
3365 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3366 "libNETGENEngine.so", UseExisting=0)
3368 elif self.algoType == MEFISTO:
3369 print "Mefisto algo support no multi-parameter hypothesis"
3371 elif self.algoType == NETGEN_2D:
3372 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3373 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3375 elif self.algoType == BLSURF:
3376 self.params = self.Hypothesis("BLSURF_Parameters", [],
3377 "libBLSURFEngine.so", UseExisting=0)
3380 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3385 # Only for algoType == NETGEN
3386 # @ingroup l3_hypos_netgen
3387 def SetMaxSize(self, theSize):
3388 if self.Parameters():
3389 self.params.SetMaxSize(theSize)
3391 ## Sets SecondOrder flag
3393 # Only for algoType == NETGEN
3394 # @ingroup l3_hypos_netgen
3395 def SetSecondOrder(self, theVal):
3396 if self.Parameters():
3397 self.params.SetSecondOrder(theVal)
3399 ## Sets Optimize flag
3401 # Only for algoType == NETGEN
3402 # @ingroup l3_hypos_netgen
3403 def SetOptimize(self, theVal):
3404 if self.Parameters():
3405 self.params.SetOptimize(theVal)
3408 # @param theFineness is:
3409 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3411 # Only for algoType == NETGEN
3412 # @ingroup l3_hypos_netgen
3413 def SetFineness(self, theFineness):
3414 if self.Parameters():
3415 self.params.SetFineness(theFineness)
3419 # Only for algoType == NETGEN
3420 # @ingroup l3_hypos_netgen
3421 def SetGrowthRate(self, theRate):
3422 if self.Parameters():
3423 self.params.SetGrowthRate(theRate)
3425 ## Sets NbSegPerEdge
3427 # Only for algoType == NETGEN
3428 # @ingroup l3_hypos_netgen
3429 def SetNbSegPerEdge(self, theVal):
3430 if self.Parameters():
3431 self.params.SetNbSegPerEdge(theVal)
3433 ## Sets NbSegPerRadius
3435 # Only for algoType == NETGEN
3436 # @ingroup l3_hypos_netgen
3437 def SetNbSegPerRadius(self, theVal):
3438 if self.Parameters():
3439 self.params.SetNbSegPerRadius(theVal)
3441 ## Sets number of segments overriding value set by SetLocalLength()
3443 # Only for algoType == NETGEN
3444 # @ingroup l3_hypos_netgen
3445 def SetNumberOfSegments(self, theVal):
3446 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3448 ## Sets number of segments overriding value set by SetNumberOfSegments()
3450 # Only for algoType == NETGEN
3451 # @ingroup l3_hypos_netgen
3452 def SetLocalLength(self, theVal):
3453 self.Parameters(SIMPLE).SetLocalLength(theVal)
3458 # Public class: Mesh_Quadrangle
3459 # -----------------------------
3461 ## Defines a quadrangle 2D algorithm
3463 # @ingroup l3_algos_basic
3464 class Mesh_Quadrangle(Mesh_Algorithm):
3466 ## Private constructor.
3467 def __init__(self, mesh, geom=0):
3468 Mesh_Algorithm.__init__(self)
3469 self.Create(mesh, geom, "Quadrangle_2D")
3471 ## Defines "QuadranglePreference" hypothesis, forcing construction
3472 # of quadrangles if the number of nodes on the opposite edges is not the same
3473 # while the total number of nodes on edges is even
3475 # @ingroup l3_hypos_additi
3476 def QuadranglePreference(self):
3477 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3478 CompareMethod=self.CompareEqualHyp)
3481 ## Defines "TrianglePreference" hypothesis, forcing construction
3482 # of triangles in the refinement area if the number of nodes
3483 # on the opposite edges is not the same
3485 # @ingroup l3_hypos_additi
3486 def TrianglePreference(self):
3487 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3488 CompareMethod=self.CompareEqualHyp)
3491 # Public class: Mesh_Tetrahedron
3492 # ------------------------------
3494 ## Defines a tetrahedron 3D algorithm
3496 # @ingroup l3_algos_basic
3497 class Mesh_Tetrahedron(Mesh_Algorithm):
3502 ## Private constructor.
3503 def __init__(self, mesh, algoType, geom=0):
3504 Mesh_Algorithm.__init__(self)
3506 if algoType == NETGEN:
3507 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3510 elif algoType == FULL_NETGEN:
3512 print "Warning: NETGENPlugin module has not been imported."
3513 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3516 elif algoType == GHS3D:
3518 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3521 elif algoType == GHS3DPRL:
3522 import GHS3DPRLPlugin
3523 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
3526 self.algoType = algoType
3528 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3529 # @param vol for the maximum volume of each tetrahedron
3530 # @param UseExisting if ==true - searches for the existing hypothesis created with
3531 # the same parameters, else (default) - creates a new one
3532 # @ingroup l3_hypos_maxvol
3533 def MaxElementVolume(self, vol, UseExisting=0):
3534 if self.algoType == NETGEN:
3535 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3536 CompareMethod=self.CompareMaxElementVolume)
3537 hyp.SetMaxElementVolume(vol)
3539 elif self.algoType == FULL_NETGEN:
3540 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3543 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3544 def CompareMaxElementVolume(self, hyp, args):
3545 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3547 ## Defines hypothesis having several parameters
3549 # @ingroup l3_hypos_netgen
3550 def Parameters(self, which=SOLE):
3554 if self.algoType == FULL_NETGEN:
3556 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3557 "libNETGENEngine.so", UseExisting=0)
3559 self.params = self.Hypothesis("NETGEN_Parameters", [],
3560 "libNETGENEngine.so", UseExisting=0)
3563 if self.algoType == GHS3D:
3564 self.params = self.Hypothesis("GHS3D_Parameters", [],
3565 "libGHS3DEngine.so", UseExisting=0)
3568 if self.algoType == GHS3DPRL:
3569 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
3570 "libGHS3DPRLEngine.so", UseExisting=0)
3573 print "Algo supports no multi-parameter hypothesis"
3577 # Parameter of FULL_NETGEN
3578 # @ingroup l3_hypos_netgen
3579 def SetMaxSize(self, theSize):
3580 self.Parameters().SetMaxSize(theSize)
3582 ## Sets SecondOrder flag
3583 # Parameter of FULL_NETGEN
3584 # @ingroup l3_hypos_netgen
3585 def SetSecondOrder(self, theVal):
3586 self.Parameters().SetSecondOrder(theVal)
3588 ## Sets Optimize flag
3589 # Parameter of FULL_NETGEN
3590 # @ingroup l3_hypos_netgen
3591 def SetOptimize(self, theVal):
3592 self.Parameters().SetOptimize(theVal)
3595 # @param theFineness is:
3596 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3597 # Parameter of FULL_NETGEN
3598 # @ingroup l3_hypos_netgen
3599 def SetFineness(self, theFineness):
3600 self.Parameters().SetFineness(theFineness)
3603 # Parameter of FULL_NETGEN
3604 # @ingroup l3_hypos_netgen
3605 def SetGrowthRate(self, theRate):
3606 self.Parameters().SetGrowthRate(theRate)
3608 ## Sets NbSegPerEdge
3609 # Parameter of FULL_NETGEN
3610 # @ingroup l3_hypos_netgen
3611 def SetNbSegPerEdge(self, theVal):
3612 self.Parameters().SetNbSegPerEdge(theVal)
3614 ## Sets NbSegPerRadius
3615 # Parameter of FULL_NETGEN
3616 # @ingroup l3_hypos_netgen
3617 def SetNbSegPerRadius(self, theVal):
3618 self.Parameters().SetNbSegPerRadius(theVal)
3620 ## Sets number of segments overriding value set by SetLocalLength()
3621 # Only for algoType == NETGEN_FULL
3622 # @ingroup l3_hypos_netgen
3623 def SetNumberOfSegments(self, theVal):
3624 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3626 ## Sets number of segments overriding value set by SetNumberOfSegments()
3627 # Only for algoType == NETGEN_FULL
3628 # @ingroup l3_hypos_netgen
3629 def SetLocalLength(self, theVal):
3630 self.Parameters(SIMPLE).SetLocalLength(theVal)
3632 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3633 # Overrides value set by LengthFromEdges()
3634 # Only for algoType == NETGEN_FULL
3635 # @ingroup l3_hypos_netgen
3636 def MaxElementArea(self, area):
3637 self.Parameters(SIMPLE).SetMaxElementArea(area)
3639 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3640 # Overrides value set by MaxElementArea()
3641 # Only for algoType == NETGEN_FULL
3642 # @ingroup l3_hypos_netgen
3643 def LengthFromEdges(self):
3644 self.Parameters(SIMPLE).LengthFromEdges()
3646 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3647 # Overrides value set by MaxElementVolume()
3648 # Only for algoType == NETGEN_FULL
3649 # @ingroup l3_hypos_netgen
3650 def LengthFromFaces(self):
3651 self.Parameters(SIMPLE).LengthFromFaces()
3653 ## To mesh "holes" in a solid or not. Default is to mesh.
3654 # @ingroup l3_hypos_ghs3dh
3655 def SetToMeshHoles(self, toMesh):
3656 # Parameter of GHS3D
3657 self.Parameters().SetToMeshHoles(toMesh)
3659 ## Set Optimization level:
3660 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3661 # Default is Medium_Optimization
3662 # @ingroup l3_hypos_ghs3dh
3663 def SetOptimizationLevel(self, level):
3664 # Parameter of GHS3D
3665 self.Parameters().SetOptimizationLevel(level)
3667 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3668 # @ingroup l3_hypos_ghs3dh
3669 def SetMaximumMemory(self, MB):
3670 # Advanced parameter of GHS3D
3671 self.Parameters().SetMaximumMemory(MB)
3673 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3674 # automatic memory adjustment mode.
3675 # @ingroup l3_hypos_ghs3dh
3676 def SetInitialMemory(self, MB):
3677 # Advanced parameter of GHS3D
3678 self.Parameters().SetInitialMemory(MB)
3680 ## Path to working directory.
3681 # @ingroup l3_hypos_ghs3dh
3682 def SetWorkingDirectory(self, path):
3683 # Advanced parameter of GHS3D
3684 self.Parameters().SetWorkingDirectory(path)
3686 ## To keep working files or remove them. Log file remains in case of errors anyway.
3687 # @ingroup l3_hypos_ghs3dh
3688 def SetKeepFiles(self, toKeep):
3689 # Advanced parameter of GHS3D and GHS3DPRL
3690 self.Parameters().SetKeepFiles(toKeep)
3692 ## To set verbose level [0-10]. <ul>
3693 #<li> 0 - no standard output,
3694 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3695 # indicates when the final mesh is being saved. In addition the software
3696 # gives indication regarding the CPU time.
3697 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3698 # histogram of the skin mesh, quality statistics histogram together with
3699 # the characteristics of the final mesh.</ul>
3700 # @ingroup l3_hypos_ghs3dh
3701 def SetVerboseLevel(self, level):
3702 # Advanced parameter of GHS3D
3703 self.Parameters().SetVerboseLevel(level)
3705 ## To create new nodes.
3706 # @ingroup l3_hypos_ghs3dh
3707 def SetToCreateNewNodes(self, toCreate):
3708 # Advanced parameter of GHS3D
3709 self.Parameters().SetToCreateNewNodes(toCreate)
3711 ## To use boundary recovery version which tries to create mesh on a very poor
3712 # quality surface mesh.
3713 # @ingroup l3_hypos_ghs3dh
3714 def SetToUseBoundaryRecoveryVersion(self, toUse):
3715 # Advanced parameter of GHS3D
3716 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3718 ## Sets command line option as text.
3719 # @ingroup l3_hypos_ghs3dh
3720 def SetTextOption(self, option):
3721 # Advanced parameter of GHS3D
3722 self.Parameters().SetTextOption(option)
3724 ## Sets MED files name and path.
3725 def SetMEDName(self, value):
3726 self.Parameters().SetMEDName(value)
3728 ## Sets the number of partition of the initial mesh
3729 def SetNbPart(self, value):
3730 self.Parameters().SetNbPart(value)
3732 ## When big mesh, start tepal in background
3733 def SetBackground(self, value):
3734 self.Parameters().SetBackground(value)
3736 # Public class: Mesh_Hexahedron
3737 # ------------------------------
3739 ## Defines a hexahedron 3D algorithm
3741 # @ingroup l3_algos_basic
3742 class Mesh_Hexahedron(Mesh_Algorithm):
3747 ## Private constructor.
3748 def __init__(self, mesh, algoType=Hexa, geom=0):
3749 Mesh_Algorithm.__init__(self)
3751 self.algoType = algoType
3753 if algoType == Hexa:
3754 self.Create(mesh, geom, "Hexa_3D")
3757 elif algoType == Hexotic:
3758 import HexoticPlugin
3759 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3762 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3763 # @ingroup l3_hypos_hexotic
3764 def MinMaxQuad(self, min=3, max=8, quad=True):
3765 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3767 self.params.SetHexesMinLevel(min)
3768 self.params.SetHexesMaxLevel(max)
3769 self.params.SetHexoticQuadrangles(quad)
3772 # Deprecated, only for compatibility!
3773 # Public class: Mesh_Netgen
3774 # ------------------------------
3776 ## Defines a NETGEN-based 2D or 3D algorithm
3777 # that needs no discrete boundary (i.e. independent)
3779 # This class is deprecated, only for compatibility!
3782 # @ingroup l3_algos_basic
3783 class Mesh_Netgen(Mesh_Algorithm):
3787 ## Private constructor.
3788 def __init__(self, mesh, is3D, geom=0):
3789 Mesh_Algorithm.__init__(self)
3792 print "Warning: NETGENPlugin module has not been imported."
3796 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3800 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3803 ## Defines the hypothesis containing parameters of the algorithm
3804 def Parameters(self):
3806 hyp = self.Hypothesis("NETGEN_Parameters", [],
3807 "libNETGENEngine.so", UseExisting=0)
3809 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3810 "libNETGENEngine.so", UseExisting=0)
3813 # Public class: Mesh_Projection1D
3814 # ------------------------------
3816 ## Defines a projection 1D algorithm
3817 # @ingroup l3_algos_proj
3819 class Mesh_Projection1D(Mesh_Algorithm):
3821 ## Private constructor.
3822 def __init__(self, mesh, geom=0):
3823 Mesh_Algorithm.__init__(self)
3824 self.Create(mesh, geom, "Projection_1D")
3826 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3827 # a mesh pattern is taken, and, optionally, the association of vertices
3828 # between the source edge and a target edge (to which a hypothesis is assigned)
3829 # @param edge from which nodes distribution is taken
3830 # @param mesh from which nodes distribution is taken (optional)
3831 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3832 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3833 # to associate with \a srcV (optional)
3834 # @param UseExisting if ==true - searches for the existing hypothesis created with
3835 # the same parameters, else (default) - creates a new one
3836 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3837 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3839 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3840 hyp.SetSourceEdge( edge )
3841 if not mesh is None and isinstance(mesh, Mesh):
3842 mesh = mesh.GetMesh()
3843 hyp.SetSourceMesh( mesh )
3844 hyp.SetVertexAssociation( srcV, tgtV )
3847 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3848 #def CompareSourceEdge(self, hyp, args):
3849 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3853 # Public class: Mesh_Projection2D
3854 # ------------------------------
3856 ## Defines a projection 2D algorithm
3857 # @ingroup l3_algos_proj
3859 class Mesh_Projection2D(Mesh_Algorithm):
3861 ## Private constructor.
3862 def __init__(self, mesh, geom=0):
3863 Mesh_Algorithm.__init__(self)
3864 self.Create(mesh, geom, "Projection_2D")
3866 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3867 # a mesh pattern is taken, and, optionally, the association of vertices
3868 # between the source face and the target face (to which a hypothesis is assigned)
3869 # @param face from which the mesh pattern is taken
3870 # @param mesh from which the mesh pattern is taken (optional)
3871 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3872 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3873 # to associate with \a srcV1 (optional)
3874 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3875 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3876 # to associate with \a srcV2 (optional)
3877 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3878 # the same parameters, else (default) - forces the creation a new one
3880 # Note: all association vertices must belong to one edge of a face
3881 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3882 srcV2=None, tgtV2=None, UseExisting=0):
3883 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3885 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3886 hyp.SetSourceFace( face )
3887 if not mesh is None and isinstance(mesh, Mesh):
3888 mesh = mesh.GetMesh()
3889 hyp.SetSourceMesh( mesh )
3890 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3893 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3894 #def CompareSourceFace(self, hyp, args):
3895 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3898 # Public class: Mesh_Projection3D
3899 # ------------------------------
3901 ## Defines a projection 3D algorithm
3902 # @ingroup l3_algos_proj
3904 class Mesh_Projection3D(Mesh_Algorithm):
3906 ## Private constructor.
3907 def __init__(self, mesh, geom=0):
3908 Mesh_Algorithm.__init__(self)
3909 self.Create(mesh, geom, "Projection_3D")
3911 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3912 # the mesh pattern is taken, and, optionally, the association of vertices
3913 # between the source and the target solid (to which a hipothesis is assigned)
3914 # @param solid from where the mesh pattern is taken
3915 # @param mesh from where the mesh pattern is taken (optional)
3916 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3917 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3918 # to associate with \a srcV1 (optional)
3919 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3920 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3921 # to associate with \a srcV2 (optional)
3922 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3923 # the same parameters, else (default) - creates a new one
3925 # Note: association vertices must belong to one edge of a solid
3926 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3927 srcV2=0, tgtV2=0, UseExisting=0):
3928 hyp = self.Hypothesis("ProjectionSource3D",
3929 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3931 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3932 hyp.SetSource3DShape( solid )
3933 if not mesh is None and isinstance(mesh, Mesh):
3934 mesh = mesh.GetMesh()
3935 hyp.SetSourceMesh( mesh )
3936 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3939 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3940 #def CompareSourceShape3D(self, hyp, args):
3941 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3945 # Public class: Mesh_Prism
3946 # ------------------------
3948 ## Defines a 3D extrusion algorithm
3949 # @ingroup l3_algos_3dextr
3951 class Mesh_Prism3D(Mesh_Algorithm):
3953 ## Private constructor.
3954 def __init__(self, mesh, geom=0):
3955 Mesh_Algorithm.__init__(self)
3956 self.Create(mesh, geom, "Prism_3D")
3958 # Public class: Mesh_RadialPrism
3959 # -------------------------------
3961 ## Defines a Radial Prism 3D algorithm
3962 # @ingroup l3_algos_radialp
3964 class Mesh_RadialPrism3D(Mesh_Algorithm):
3966 ## Private constructor.
3967 def __init__(self, mesh, geom=0):
3968 Mesh_Algorithm.__init__(self)
3969 self.Create(mesh, geom, "RadialPrism_3D")
3971 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3972 self.nbLayers = None
3974 ## Return 3D hypothesis holding the 1D one
3975 def Get3DHypothesis(self):
3976 return self.distribHyp
3978 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3979 # hypothesis. Returns the created hypothesis
3980 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3981 #print "OwnHypothesis",hypType
3982 if not self.nbLayers is None:
3983 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3984 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3985 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3986 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3987 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3988 self.distribHyp.SetLayerDistribution( hyp )
3991 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3992 # prisms to build between the inner and outer shells
3993 # @param n number of layers
3994 # @param UseExisting if ==true - searches for the existing hypothesis created with
3995 # the same parameters, else (default) - creates a new one
3996 def NumberOfLayers(self, n, UseExisting=0):
3997 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3998 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3999 CompareMethod=self.CompareNumberOfLayers)
4000 self.nbLayers.SetNumberOfLayers( n )
4001 return self.nbLayers
4003 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4004 def CompareNumberOfLayers(self, hyp, args):
4005 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4007 ## Defines "LocalLength" hypothesis, specifying the segment length
4008 # to build between the inner and the outer shells
4009 # @param l the length of segments
4010 # @param p the precision of rounding
4011 def LocalLength(self, l, p=1e-07):
4012 hyp = self.OwnHypothesis("LocalLength", [l,p])
4017 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4018 # prisms to build between the inner and the outer shells.
4019 # @param n the number of layers
4020 # @param s the scale factor (optional)
4021 def NumberOfSegments(self, n, s=[]):
4023 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4025 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4026 hyp.SetDistrType( 1 )
4027 hyp.SetScaleFactor(s)
4028 hyp.SetNumberOfSegments(n)
4031 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4032 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4033 # @param start the length of the first segment
4034 # @param end the length of the last segment
4035 def Arithmetic1D(self, start, end ):
4036 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4037 hyp.SetLength(start, 1)
4038 hyp.SetLength(end , 0)
4041 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4042 # to build between the inner and the outer shells as geometric length increasing
4043 # @param start for the length of the first segment
4044 # @param end for the length of the last segment
4045 def StartEndLength(self, start, end):
4046 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4047 hyp.SetLength(start, 1)
4048 hyp.SetLength(end , 0)
4051 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4052 # to build between the inner and outer shells
4053 # @param fineness defines the quality of the mesh within the range [0-1]
4054 def AutomaticLength(self, fineness=0):
4055 hyp = self.OwnHypothesis("AutomaticLength")
4056 hyp.SetFineness( fineness )
4059 # Private class: Mesh_UseExisting
4060 # -------------------------------
4061 class Mesh_UseExisting(Mesh_Algorithm):
4063 def __init__(self, dim, mesh, geom=0):
4065 self.Create(mesh, geom, "UseExisting_1D")
4067 self.Create(mesh, geom, "UseExisting_2D")