1 # Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Francis KLOSS, OCC
29 ## @defgroup l1_auxiliary Auxiliary methods and structures
30 ## @defgroup l1_creating Creating meshes
32 ## @defgroup l2_impexp Importing and exporting meshes
33 ## @defgroup l2_construct Constructing meshes
34 ## @defgroup l2_algorithms Defining Algorithms
36 ## @defgroup l3_algos_basic Basic meshing algorithms
37 ## @defgroup l3_algos_proj Projection Algorithms
38 ## @defgroup l3_algos_radialp Radial Prism
39 ## @defgroup l3_algos_segmarv Segments around Vertex
40 ## @defgroup l3_algos_3dextr 3D extrusion meshing algorithm
43 ## @defgroup l2_hypotheses Defining hypotheses
45 ## @defgroup l3_hypos_1dhyps 1D Meshing Hypotheses
46 ## @defgroup l3_hypos_2dhyps 2D Meshing Hypotheses
47 ## @defgroup l3_hypos_maxvol Max Element Volume hypothesis
48 ## @defgroup l3_hypos_netgen Netgen 2D and 3D hypotheses
49 ## @defgroup l3_hypos_ghs3dh GHS3D Parameters hypothesis
50 ## @defgroup l3_hypos_blsurf BLSURF Parameters hypothesis
51 ## @defgroup l3_hypos_hexotic Hexotic Parameters hypothesis
52 ## @defgroup l3_hypos_additi Additional Hypotheses
55 ## @defgroup l2_submeshes Constructing submeshes
56 ## @defgroup l2_compounds Building Compounds
57 ## @defgroup l2_editing Editing Meshes
60 ## @defgroup l1_meshinfo Mesh Information
61 ## @defgroup l1_controls Quality controls and Filtering
62 ## @defgroup l1_grouping Grouping elements
64 ## @defgroup l2_grps_create Creating groups
65 ## @defgroup l2_grps_edit Editing groups
66 ## @defgroup l2_grps_operon Using operations on groups
67 ## @defgroup l2_grps_delete Deleting Groups
70 ## @defgroup l1_modifying Modifying meshes
72 ## @defgroup l2_modif_add Adding nodes and elements
73 ## @defgroup l2_modif_del Removing nodes and elements
74 ## @defgroup l2_modif_edit Modifying nodes and elements
75 ## @defgroup l2_modif_renumber Renumbering nodes and elements
76 ## @defgroup l2_modif_trsf Transforming meshes (Translation, Rotation, Symmetry, Sewing, Merging)
77 ## @defgroup l2_modif_movenode Moving nodes
78 ## @defgroup l2_modif_throughp Mesh through point
79 ## @defgroup l2_modif_invdiag Diagonal inversion of elements
80 ## @defgroup l2_modif_unitetri Uniting triangles
81 ## @defgroup l2_modif_changori Changing orientation of elements
82 ## @defgroup l2_modif_cutquadr Cutting quadrangles
83 ## @defgroup l2_modif_smooth Smoothing
84 ## @defgroup l2_modif_extrurev Extrusion and Revolution
85 ## @defgroup l2_modif_patterns Pattern mapping
86 ## @defgroup l2_modif_tofromqu Convert to/from Quadratic Mesh
93 import SMESH # This is necessary for back compatibility
100 # import NETGENPlugin module if possible
108 ## @addtogroup l1_auxiliary
111 # Types of algorithms
122 NETGEN_1D2D3D = FULL_NETGEN
123 NETGEN_FULL = FULL_NETGEN
128 # MirrorType enumeration
129 POINT = SMESH_MeshEditor.POINT
130 AXIS = SMESH_MeshEditor.AXIS
131 PLANE = SMESH_MeshEditor.PLANE
133 # Smooth_Method enumeration
134 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
135 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
137 # Fineness enumeration (for NETGEN)
145 # Optimization level of GHS3D
146 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
148 # Topology treatment way of BLSURF
149 FromCAD, PreProcess, PreProcessPlus = 0,1,2
151 # Element size flag of BLSURF
152 DefaultSize, DefaultGeom, Custom = 0,0,1
154 PrecisionConfusion = 1e-07
156 def IsEqual(val1, val2, tol=PrecisionConfusion):
157 if abs(val1 - val2) < tol:
165 ior = salome.orb.object_to_string(obj)
166 sobj = salome.myStudy.FindObjectIOR(ior)
170 attr = sobj.FindAttribute("AttributeName")[1]
173 ## Sets a name to the object
174 def SetName(obj, name):
175 ior = salome.orb.object_to_string(obj)
176 sobj = salome.myStudy.FindObjectIOR(ior)
178 attr = sobj.FindAttribute("AttributeName")[1]
181 ## Prints error message if a hypothesis was not assigned.
182 def TreatHypoStatus(status, hypName, geomName, isAlgo):
184 hypType = "algorithm"
186 hypType = "hypothesis"
188 if status == HYP_UNKNOWN_FATAL :
189 reason = "for unknown reason"
190 elif status == HYP_INCOMPATIBLE :
191 reason = "this hypothesis mismatches the algorithm"
192 elif status == HYP_NOTCONFORM :
193 reason = "a non-conform mesh would be built"
194 elif status == HYP_ALREADY_EXIST :
195 reason = hypType + " of the same dimension is already assigned to this shape"
196 elif status == HYP_BAD_DIM :
197 reason = hypType + " mismatches the shape"
198 elif status == HYP_CONCURENT :
199 reason = "there are concurrent hypotheses on sub-shapes"
200 elif status == HYP_BAD_SUBSHAPE :
201 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
202 elif status == HYP_BAD_GEOMETRY:
203 reason = "geometry mismatches the expectation of the algorithm"
204 elif status == HYP_HIDDEN_ALGO:
205 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
206 elif status == HYP_HIDING_ALGO:
207 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
210 hypName = '"' + hypName + '"'
211 geomName= '"' + geomName+ '"'
212 if status < HYP_UNKNOWN_FATAL:
213 print hypName, "was assigned to", geomName,"but", reason
215 print hypName, "was not assigned to",geomName,":", reason
218 ## Converts an angle from degrees to radians
219 def DegreesToRadians(AngleInDegrees):
221 return AngleInDegrees * pi / 180.0
223 # end of l1_auxiliary
226 # All methods of this class are accessible directly from the smesh.py package.
227 class smeshDC(SMESH._objref_SMESH_Gen):
229 ## Sets the current study and Geometry component
230 # @ingroup l1_auxiliary
231 def init_smesh(self,theStudy,geompyD):
233 self.SetGeomEngine(geompyD)
234 self.SetCurrentStudy(theStudy)
236 ## Creates an empty Mesh. This mesh can have an underlying geometry.
237 # @param obj the Geometrical object on which the mesh is built. If not defined,
238 # the mesh will have no underlying geometry.
239 # @param name the name for the new mesh.
240 # @return an instance of Mesh class.
241 # @ingroup l2_construct
242 def Mesh(self, obj=0, name=0):
243 return Mesh(self,self.geompyD,obj,name)
245 ## Returns a long value from enumeration
246 # Should be used for SMESH.FunctorType enumeration
247 # @ingroup l1_controls
248 def EnumToLong(self,theItem):
251 ## Gets PointStruct from vertex
252 # @param theVertex a GEOM object(vertex)
253 # @return SMESH.PointStruct
254 # @ingroup l1_auxiliary
255 def GetPointStruct(self,theVertex):
256 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
257 return PointStruct(x,y,z)
259 ## Gets DirStruct from vector
260 # @param theVector a GEOM object(vector)
261 # @return SMESH.DirStruct
262 # @ingroup l1_auxiliary
263 def GetDirStruct(self,theVector):
264 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
265 if(len(vertices) != 2):
266 print "Error: vector object is incorrect."
268 p1 = self.geompyD.PointCoordinates(vertices[0])
269 p2 = self.geompyD.PointCoordinates(vertices[1])
270 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
271 dirst = DirStruct(pnt)
274 ## Makes DirStruct from a triplet
275 # @param x,y,z vector components
276 # @return SMESH.DirStruct
277 # @ingroup l1_auxiliary
278 def MakeDirStruct(self,x,y,z):
279 pnt = PointStruct(x,y,z)
280 return DirStruct(pnt)
282 ## Get AxisStruct from object
283 # @param theObj a GEOM object (line or plane)
284 # @return SMESH.AxisStruct
285 # @ingroup l1_auxiliary
286 def GetAxisStruct(self,theObj):
287 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
289 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
290 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
291 vertex1 = self.geompyD.PointCoordinates(vertex1)
292 vertex2 = self.geompyD.PointCoordinates(vertex2)
293 vertex3 = self.geompyD.PointCoordinates(vertex3)
294 vertex4 = self.geompyD.PointCoordinates(vertex4)
295 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
296 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
297 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] ]
298 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
300 elif len(edges) == 1:
301 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
302 p1 = self.geompyD.PointCoordinates( vertex1 )
303 p2 = self.geompyD.PointCoordinates( vertex2 )
304 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
308 # From SMESH_Gen interface:
309 # ------------------------
311 ## Sets the current mode
312 # @ingroup l1_auxiliary
313 def SetEmbeddedMode( self,theMode ):
314 #self.SetEmbeddedMode(theMode)
315 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
317 ## Gets the current mode
318 # @ingroup l1_auxiliary
319 def IsEmbeddedMode(self):
320 #return self.IsEmbeddedMode()
321 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
323 ## Sets the current study
324 # @ingroup l1_auxiliary
325 def SetCurrentStudy( self, theStudy ):
326 #self.SetCurrentStudy(theStudy)
327 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
329 ## Gets the current study
330 # @ingroup l1_auxiliary
331 def GetCurrentStudy(self):
332 #return self.GetCurrentStudy()
333 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
335 ## Creates a Mesh object importing data from the given UNV file
336 # @return an instance of Mesh class
338 def CreateMeshesFromUNV( self,theFileName ):
339 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
340 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
343 ## Creates a Mesh object(s) importing data from the given MED file
344 # @return a list of Mesh class instances
346 def CreateMeshesFromMED( self,theFileName ):
347 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
349 for iMesh in range(len(aSmeshMeshes)) :
350 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
351 aMeshes.append(aMesh)
352 return aMeshes, aStatus
354 ## Creates a Mesh object importing data from the given STL file
355 # @return an instance of Mesh class
357 def CreateMeshesFromSTL( self, theFileName ):
358 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
359 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
362 ## From SMESH_Gen interface
363 # @return the list of integer values
364 # @ingroup l1_auxiliary
365 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
366 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
368 ## From SMESH_Gen interface. Creates a pattern
369 # @return an instance of SMESH_Pattern
371 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
372 # @ingroup l2_modif_patterns
373 def GetPattern(self):
374 return SMESH._objref_SMESH_Gen.GetPattern(self)
377 # Filtering. Auxiliary functions:
378 # ------------------------------
380 ## Creates an empty criterion
381 # @return SMESH.Filter.Criterion
382 # @ingroup l1_controls
383 def GetEmptyCriterion(self):
384 Type = self.EnumToLong(FT_Undefined)
385 Compare = self.EnumToLong(FT_Undefined)
389 UnaryOp = self.EnumToLong(FT_Undefined)
390 BinaryOp = self.EnumToLong(FT_Undefined)
393 Precision = -1 ##@1e-07
394 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
395 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
397 ## Creates a criterion by the given parameters
398 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
399 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
400 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
401 # @param Treshold the threshold value (range of ids as string, shape, numeric)
402 # @param UnaryOp FT_LogicalNOT or FT_Undefined
403 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
404 # FT_Undefined (must be for the last criterion of all criteria)
405 # @return SMESH.Filter.Criterion
406 # @ingroup l1_controls
407 def GetCriterion(self,elementType,
409 Compare = FT_EqualTo,
411 UnaryOp=FT_Undefined,
412 BinaryOp=FT_Undefined):
413 aCriterion = self.GetEmptyCriterion()
414 aCriterion.TypeOfElement = elementType
415 aCriterion.Type = self.EnumToLong(CritType)
419 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
420 aCriterion.Compare = self.EnumToLong(Compare)
421 elif Compare == "=" or Compare == "==":
422 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
424 aCriterion.Compare = self.EnumToLong(FT_LessThan)
426 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
428 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
431 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
432 FT_BelongToCylinder, FT_LyingOnGeom]:
433 # Checks the treshold
434 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
435 aCriterion.ThresholdStr = GetName(aTreshold)
436 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
438 print "Error: The treshold should be a shape."
440 elif CritType == FT_RangeOfIds:
441 # Checks the treshold
442 if isinstance(aTreshold, str):
443 aCriterion.ThresholdStr = aTreshold
445 print "Error: The treshold should be a string."
447 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
448 # At this point the treshold is unnecessary
449 if aTreshold == FT_LogicalNOT:
450 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
451 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
452 aCriterion.BinaryOp = aTreshold
456 aTreshold = float(aTreshold)
457 aCriterion.Threshold = aTreshold
459 print "Error: The treshold should be a number."
462 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
463 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
465 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
466 aCriterion.BinaryOp = self.EnumToLong(Treshold)
468 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
469 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
471 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
472 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
476 ## Creates a filter with the given parameters
477 # @param elementType the type of elements in the group
478 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
479 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
480 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
481 # @param UnaryOp FT_LogicalNOT or FT_Undefined
482 # @return SMESH_Filter
483 # @ingroup l1_controls
484 def GetFilter(self,elementType,
485 CritType=FT_Undefined,
488 UnaryOp=FT_Undefined):
489 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
490 aFilterMgr = self.CreateFilterManager()
491 aFilter = aFilterMgr.CreateFilter()
493 aCriteria.append(aCriterion)
494 aFilter.SetCriteria(aCriteria)
497 ## Creates a numerical functor by its type
498 # @param theCriterion FT_...; functor type
499 # @return SMESH_NumericalFunctor
500 # @ingroup l1_controls
501 def GetFunctor(self,theCriterion):
502 aFilterMgr = self.CreateFilterManager()
503 if theCriterion == FT_AspectRatio:
504 return aFilterMgr.CreateAspectRatio()
505 elif theCriterion == FT_AspectRatio3D:
506 return aFilterMgr.CreateAspectRatio3D()
507 elif theCriterion == FT_Warping:
508 return aFilterMgr.CreateWarping()
509 elif theCriterion == FT_MinimumAngle:
510 return aFilterMgr.CreateMinimumAngle()
511 elif theCriterion == FT_Taper:
512 return aFilterMgr.CreateTaper()
513 elif theCriterion == FT_Skew:
514 return aFilterMgr.CreateSkew()
515 elif theCriterion == FT_Area:
516 return aFilterMgr.CreateArea()
517 elif theCriterion == FT_Volume3D:
518 return aFilterMgr.CreateVolume3D()
519 elif theCriterion == FT_MultiConnection:
520 return aFilterMgr.CreateMultiConnection()
521 elif theCriterion == FT_MultiConnection2D:
522 return aFilterMgr.CreateMultiConnection2D()
523 elif theCriterion == FT_Length:
524 return aFilterMgr.CreateLength()
525 elif theCriterion == FT_Length2D:
526 return aFilterMgr.CreateLength2D()
528 print "Error: given parameter is not numerucal functor type."
532 #Registering the new proxy for SMESH_Gen
533 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
539 ## This class allows defining and managing a mesh.
540 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
541 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
542 # new nodes and elements and by changing the existing entities), to get information
543 # about a mesh and to export a mesh into different formats.
552 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
553 # sets the GUI name of this mesh to \a name.
554 # @param smeshpyD an instance of smeshDC class
555 # @param geompyD an instance of geompyDC class
556 # @param obj Shape to be meshed or SMESH_Mesh object
557 # @param name Study name of the mesh
558 # @ingroup l2_construct
559 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
560 self.smeshpyD=smeshpyD
565 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
567 self.mesh = self.smeshpyD.CreateMesh(self.geom)
568 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
571 self.mesh = self.smeshpyD.CreateEmptyMesh()
573 SetName(self.mesh, name)
575 SetName(self.mesh, GetName(obj))
577 self.editor = self.mesh.GetMeshEditor()
579 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
580 # @param theMesh a SMESH_Mesh object
581 # @ingroup l2_construct
582 def SetMesh(self, theMesh):
584 self.geom = self.mesh.GetShapeToMesh()
586 ## Returns the mesh, that is an instance of SMESH_Mesh interface
587 # @return a SMESH_Mesh object
588 # @ingroup l2_construct
592 ## Gets the name of the mesh
593 # @return the name of the mesh as a string
594 # @ingroup l2_construct
596 name = GetName(self.GetMesh())
599 ## Sets a name to the mesh
600 # @param name a new name of the mesh
601 # @ingroup l2_construct
602 def SetName(self, name):
603 SetName(self.GetMesh(), name)
605 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
606 # The subMesh object gives access to the IDs of nodes and elements.
607 # @param theSubObject a geometrical object (shape)
608 # @param theName a name for the submesh
609 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
610 # @ingroup l2_submeshes
611 def GetSubMesh(self, theSubObject, theName):
612 submesh = self.mesh.GetSubMesh(theSubObject, theName)
615 ## Returns the shape associated to the mesh
616 # @return a GEOM_Object
617 # @ingroup l2_construct
621 ## Associates the given shape to the mesh (entails the recreation of the mesh)
622 # @param geom the shape to be meshed (GEOM_Object)
623 # @ingroup l2_construct
624 def SetShape(self, geom):
625 self.mesh = self.smeshpyD.CreateMesh(geom)
627 ## Returns true if the hypotheses are defined well
628 # @param theSubObject a subshape of a mesh shape
629 # @return True or False
630 # @ingroup l2_construct
631 def IsReadyToCompute(self, theSubObject):
632 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
634 ## Returns errors of hypotheses definition.
635 # The list of errors is empty if everything is OK.
636 # @param theSubObject a subshape of a mesh shape
637 # @return a list of errors
638 # @ingroup l2_construct
639 def GetAlgoState(self, theSubObject):
640 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
642 ## Returns a geometrical object on which the given element was built.
643 # The returned geometrical object, if not nil, is either found in the
644 # study or published by this method with the given name
645 # @param theElementID the id of the mesh element
646 # @param theGeomName the user-defined name of the geometrical object
647 # @return GEOM::GEOM_Object instance
648 # @ingroup l2_construct
649 def GetGeometryByMeshElement(self, theElementID, theGeomName):
650 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
652 ## Returns the mesh dimension depending on the dimension of the underlying shape
653 # @return mesh dimension as an integer value [0,3]
654 # @ingroup l1_auxiliary
655 def MeshDimension(self):
656 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
657 if len( shells ) > 0 :
659 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
661 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
667 ## Creates a segment discretization 1D algorithm.
668 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
669 # \n If the optional \a geom parameter is not set, this algorithm is global.
670 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
671 # @param algo the type of the required algorithm. Possible values are:
673 # - smesh.PYTHON for discretization via a python function,
674 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
675 # @param geom If defined is the subshape to be meshed
676 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
677 # @ingroup l3_algos_basic
678 def Segment(self, algo=REGULAR, geom=0):
679 ## if Segment(geom) is called by mistake
680 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
681 algo, geom = geom, algo
682 if not algo: algo = REGULAR
685 return Mesh_Segment(self, geom)
687 return Mesh_Segment_Python(self, geom)
688 elif algo == COMPOSITE:
689 return Mesh_CompositeSegment(self, geom)
691 return Mesh_Segment(self, geom)
693 ## Enables creation of nodes and segments usable by 2D algoritms.
694 # The added nodes and segments must be bound to edges and vertices by
695 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
696 # If the optional \a geom parameter is not set, this algorithm is global.
697 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
698 # @param geom the subshape to be manually meshed
699 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
700 # @ingroup l3_algos_basic
701 def UseExistingSegments(self, geom=0):
702 algo = Mesh_UseExisting(1,self,geom)
703 return algo.GetAlgorithm()
705 ## Enables creation of nodes and faces usable by 3D algoritms.
706 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
707 # and SetMeshElementOnShape()
708 # If the optional \a geom parameter is not set, this algorithm is global.
709 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
710 # @param geom the subshape to be manually meshed
711 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
712 # @ingroup l3_algos_basic
713 def UseExistingFaces(self, geom=0):
714 algo = Mesh_UseExisting(2,self,geom)
715 return algo.GetAlgorithm()
717 ## Creates a triangle 2D algorithm for faces.
718 # If the optional \a geom parameter is not set, this algorithm is global.
719 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
720 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
721 # @param geom If defined, the subshape to be meshed (GEOM_Object)
722 # @return an instance of Mesh_Triangle algorithm
723 # @ingroup l3_algos_basic
724 def Triangle(self, algo=MEFISTO, geom=0):
725 ## if Triangle(geom) is called by mistake
726 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
730 return Mesh_Triangle(self, algo, geom)
732 ## Creates a quadrangle 2D algorithm for faces.
733 # If the optional \a geom parameter is not set, this algorithm is global.
734 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
735 # @param geom If defined, the subshape to be meshed (GEOM_Object)
736 # @return an instance of Mesh_Quadrangle algorithm
737 # @ingroup l3_algos_basic
738 def Quadrangle(self, geom=0):
739 return Mesh_Quadrangle(self, geom)
741 ## Creates a tetrahedron 3D algorithm for solids.
742 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
743 # If the optional \a geom parameter is not set, this algorithm is global.
744 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
745 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
746 # @param geom If defined, the subshape to be meshed (GEOM_Object)
747 # @return an instance of Mesh_Tetrahedron algorithm
748 # @ingroup l3_algos_basic
749 def Tetrahedron(self, algo=NETGEN, geom=0):
750 ## if Tetrahedron(geom) is called by mistake
751 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
752 algo, geom = geom, algo
753 if not algo: algo = NETGEN
755 return Mesh_Tetrahedron(self, algo, geom)
757 ## Creates a hexahedron 3D algorithm for solids.
758 # If the optional \a geom parameter is not set, this algorithm is global.
759 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
760 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
761 # @param geom If defined, the subshape to be meshed (GEOM_Object)
762 # @return an instance of Mesh_Hexahedron algorithm
763 # @ingroup l3_algos_basic
764 def Hexahedron(self, algo=Hexa, geom=0):
765 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
766 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
767 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
768 elif geom == 0: algo, geom = Hexa, algo
769 return Mesh_Hexahedron(self, algo, geom)
771 ## Deprecated, used only for compatibility!
772 # @return an instance of Mesh_Netgen algorithm
773 # @ingroup l3_algos_basic
774 def Netgen(self, is3D, geom=0):
775 return Mesh_Netgen(self, is3D, geom)
777 ## Creates a projection 1D algorithm for edges.
778 # If the optional \a geom parameter is not set, this algorithm is global.
779 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
780 # @param geom If defined, the subshape to be meshed
781 # @return an instance of Mesh_Projection1D algorithm
782 # @ingroup l3_algos_proj
783 def Projection1D(self, geom=0):
784 return Mesh_Projection1D(self, geom)
786 ## Creates a projection 2D algorithm for faces.
787 # If the optional \a geom parameter is not set, this algorithm is global.
788 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
789 # @param geom If defined, the subshape to be meshed
790 # @return an instance of Mesh_Projection2D algorithm
791 # @ingroup l3_algos_proj
792 def Projection2D(self, geom=0):
793 return Mesh_Projection2D(self, geom)
795 ## Creates a projection 3D algorithm for solids.
796 # If the optional \a geom parameter is not set, this algorithm is global.
797 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
798 # @param geom If defined, the subshape to be meshed
799 # @return an instance of Mesh_Projection3D algorithm
800 # @ingroup l3_algos_proj
801 def Projection3D(self, geom=0):
802 return Mesh_Projection3D(self, geom)
804 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
805 # If the optional \a geom parameter is not set, this algorithm is global.
806 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
807 # @param geom If defined, the subshape to be meshed
808 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
809 # @ingroup l3_algos_radialp l3_algos_3dextr
810 def Prism(self, geom=0):
814 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
815 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
816 if nbSolids == 0 or nbSolids == nbShells:
817 return Mesh_Prism3D(self, geom)
818 return Mesh_RadialPrism3D(self, geom)
820 ## Computes the mesh and returns the status of the computation
821 # @return True or False
822 # @ingroup l2_construct
823 def Compute(self, geom=0):
824 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
826 geom = self.mesh.GetShapeToMesh()
831 ok = self.smeshpyD.Compute(self.mesh, geom)
832 except SALOME.SALOME_Exception, ex:
833 print "Mesh computation failed, exception caught:"
834 print " ", ex.details.text
837 print "Mesh computation failed, exception caught:"
838 traceback.print_exc()
840 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
851 reason = '%s %sD algorithm is missing' % (glob, dim)
852 elif err.state == HYP_MISSING:
853 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
854 % (glob, dim, name, dim))
855 elif err.state == HYP_NOTCONFORM:
856 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
857 elif err.state == HYP_BAD_PARAMETER:
858 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
859 % ( glob, dim, name ))
860 elif err.state == HYP_BAD_GEOMETRY:
861 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
862 'geometry' % ( glob, dim, name ))
864 reason = "For unknown reason."+\
865 " Revise Mesh.Compute() implementation in smeshDC.py!"
873 print '"' + GetName(self.mesh) + '"',"has not been computed:"
877 print '"' + GetName(self.mesh) + '"',"has not been computed."
880 if salome.sg.hasDesktop():
881 smeshgui = salome.ImportComponentGUI("SMESH")
882 smeshgui.Init(salome.myStudyId)
883 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
884 salome.sg.updateObjBrowser(1)
888 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
889 # The parameter \a fineness [0,-1] defines mesh fineness
890 # @return True or False
891 # @ingroup l3_algos_basic
892 def AutomaticTetrahedralization(self, fineness=0):
893 dim = self.MeshDimension()
895 self.RemoveGlobalHypotheses()
896 self.Segment().AutomaticLength(fineness)
898 self.Triangle().LengthFromEdges()
901 self.Tetrahedron(NETGEN)
903 return self.Compute()
905 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
906 # The parameter \a fineness [0,-1] defines mesh fineness
907 # @return True or False
908 # @ingroup l3_algos_basic
909 def AutomaticHexahedralization(self, fineness=0):
910 dim = self.MeshDimension()
911 # assign the hypotheses
912 self.RemoveGlobalHypotheses()
913 self.Segment().AutomaticLength(fineness)
920 return self.Compute()
922 ## Assigns a hypothesis
923 # @param hyp a hypothesis to assign
924 # @param geom a subhape of mesh geometry
925 # @return SMESH.Hypothesis_Status
926 # @ingroup l2_hypotheses
927 def AddHypothesis(self, hyp, geom=0):
928 if isinstance( hyp, Mesh_Algorithm ):
929 hyp = hyp.GetAlgorithm()
934 geom = self.mesh.GetShapeToMesh()
936 status = self.mesh.AddHypothesis(geom, hyp)
937 isAlgo = hyp._narrow( SMESH_Algo )
938 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
941 ## Unassigns a hypothesis
942 # @param hyp a hypothesis to unassign
943 # @param geom a subshape of mesh geometry
944 # @return SMESH.Hypothesis_Status
945 # @ingroup l2_hypotheses
946 def RemoveHypothesis(self, hyp, geom=0):
947 if isinstance( hyp, Mesh_Algorithm ):
948 hyp = hyp.GetAlgorithm()
953 status = self.mesh.RemoveHypothesis(geom, hyp)
956 ## Gets the list of hypotheses added on a geometry
957 # @param geom a subshape of mesh geometry
958 # @return the sequence of SMESH_Hypothesis
959 # @ingroup l2_hypotheses
960 def GetHypothesisList(self, geom):
961 return self.mesh.GetHypothesisList( geom )
963 ## Removes all global hypotheses
964 # @ingroup l2_hypotheses
965 def RemoveGlobalHypotheses(self):
966 current_hyps = self.mesh.GetHypothesisList( self.geom )
967 for hyp in current_hyps:
968 self.mesh.RemoveHypothesis( self.geom, hyp )
972 ## Creates a mesh group based on the geometric object \a grp
973 # and gives a \a name, \n if this parameter is not defined
974 # the name is the same as the geometric group name \n
975 # Note: Works like GroupOnGeom().
976 # @param grp a geometric group, a vertex, an edge, a face or a solid
977 # @param name the name of the mesh group
978 # @return SMESH_GroupOnGeom
979 # @ingroup l2_grps_create
980 def Group(self, grp, name=""):
981 return self.GroupOnGeom(grp, name)
983 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
984 # Exports the mesh in a file in MED format and chooses the \a version of MED format
985 # @param f the file name
986 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
988 def ExportToMED(self, f, version, opt=0):
989 self.mesh.ExportToMED(f, opt, version)
991 ## Exports the mesh in a file in MED format
992 # @param f is the file name
993 # @param auto_groups boolean parameter for creating/not creating
994 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
995 # the typical use is auto_groups=false.
996 # @param version MED format version(MED_V2_1 or MED_V2_2)
998 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
999 self.mesh.ExportToMED(f, auto_groups, version)
1001 ## Exports the mesh in a file in DAT format
1002 # @param f the file name
1003 # @ingroup l2_impexp
1004 def ExportDAT(self, f):
1005 self.mesh.ExportDAT(f)
1007 ## Exports the mesh in a file in UNV format
1008 # @param f the file name
1009 # @ingroup l2_impexp
1010 def ExportUNV(self, f):
1011 self.mesh.ExportUNV(f)
1013 ## Export the mesh in a file in STL format
1014 # @param f the file name
1015 # @param ascii defines the file encoding
1016 # @ingroup l2_impexp
1017 def ExportSTL(self, f, ascii=1):
1018 self.mesh.ExportSTL(f, ascii)
1021 # Operations with groups:
1022 # ----------------------
1024 ## Creates an empty mesh group
1025 # @param elementType the type of elements in the group
1026 # @param name the name of the mesh group
1027 # @return SMESH_Group
1028 # @ingroup l2_grps_create
1029 def CreateEmptyGroup(self, elementType, name):
1030 return self.mesh.CreateGroup(elementType, name)
1032 ## Creates a mesh group based on the geometrical object \a grp
1033 # and gives a \a name, \n if this parameter is not defined
1034 # the name is the same as the geometrical group name
1035 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1036 # @param name the name of the mesh group
1037 # @param typ the type of elements in the group. If not set, it is
1038 # automatically detected by the type of the geometry
1039 # @return SMESH_GroupOnGeom
1040 # @ingroup l2_grps_create
1041 def GroupOnGeom(self, grp, name="", typ=None):
1043 name = grp.GetName()
1046 tgeo = str(grp.GetShapeType())
1047 if tgeo == "VERTEX":
1049 elif tgeo == "EDGE":
1051 elif tgeo == "FACE":
1053 elif tgeo == "SOLID":
1055 elif tgeo == "SHELL":
1057 elif tgeo == "COMPOUND":
1058 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1059 print "Mesh.Group: empty geometric group", GetName( grp )
1061 tgeo = self.geompyD.GetType(grp)
1062 if tgeo == geompyDC.ShapeType["VERTEX"]:
1064 elif tgeo == geompyDC.ShapeType["EDGE"]:
1066 elif tgeo == geompyDC.ShapeType["FACE"]:
1068 elif tgeo == geompyDC.ShapeType["SOLID"]:
1072 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1075 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1077 ## Creates a mesh group by the given ids of elements
1078 # @param groupName the name of the mesh group
1079 # @param elementType the type of elements in the group
1080 # @param elemIDs the list of ids
1081 # @return SMESH_Group
1082 # @ingroup l2_grps_create
1083 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1084 group = self.mesh.CreateGroup(elementType, groupName)
1088 ## Creates a mesh group by the given conditions
1089 # @param groupName the name of the mesh group
1090 # @param elementType the type of elements in the group
1091 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1092 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1093 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1094 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1095 # @return SMESH_Group
1096 # @ingroup l2_grps_create
1100 CritType=FT_Undefined,
1103 UnaryOp=FT_Undefined):
1104 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1105 group = self.MakeGroupByCriterion(groupName, aCriterion)
1108 ## Creates a mesh group by the given criterion
1109 # @param groupName the name of the mesh group
1110 # @param Criterion the instance of Criterion class
1111 # @return SMESH_Group
1112 # @ingroup l2_grps_create
1113 def MakeGroupByCriterion(self, groupName, Criterion):
1114 aFilterMgr = self.smeshpyD.CreateFilterManager()
1115 aFilter = aFilterMgr.CreateFilter()
1117 aCriteria.append(Criterion)
1118 aFilter.SetCriteria(aCriteria)
1119 group = self.MakeGroupByFilter(groupName, aFilter)
1122 ## Creates a mesh group by the given criteria (list of criteria)
1123 # @param groupName the name of the mesh group
1124 # @param theCriteria the list of criteria
1125 # @return SMESH_Group
1126 # @ingroup l2_grps_create
1127 def MakeGroupByCriteria(self, groupName, theCriteria):
1128 aFilterMgr = self.smeshpyD.CreateFilterManager()
1129 aFilter = aFilterMgr.CreateFilter()
1130 aFilter.SetCriteria(theCriteria)
1131 group = self.MakeGroupByFilter(groupName, aFilter)
1134 ## Creates a mesh group by the given filter
1135 # @param groupName the name of the mesh group
1136 # @param theFilter the instance of Filter class
1137 # @return SMESH_Group
1138 # @ingroup l2_grps_create
1139 def MakeGroupByFilter(self, groupName, theFilter):
1140 anIds = theFilter.GetElementsId(self.mesh)
1141 anElemType = theFilter.GetElementType()
1142 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1145 ## Passes mesh elements through the given filter and return IDs of fitting elements
1146 # @param theFilter SMESH_Filter
1147 # @return a list of ids
1148 # @ingroup l1_controls
1149 def GetIdsFromFilter(self, theFilter):
1150 return theFilter.GetElementsId(self.mesh)
1152 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1153 # Returns a list of special structures (borders).
1154 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1155 # @ingroup l1_controls
1156 def GetFreeBorders(self):
1157 aFilterMgr = self.smeshpyD.CreateFilterManager()
1158 aPredicate = aFilterMgr.CreateFreeEdges()
1159 aPredicate.SetMesh(self.mesh)
1160 aBorders = aPredicate.GetBorders()
1164 # @ingroup l2_grps_delete
1165 def RemoveGroup(self, group):
1166 self.mesh.RemoveGroup(group)
1168 ## Removes a group with its contents
1169 # @ingroup l2_grps_delete
1170 def RemoveGroupWithContents(self, group):
1171 self.mesh.RemoveGroupWithContents(group)
1173 ## Gets the list of groups existing in the mesh
1174 # @return a sequence of SMESH_GroupBase
1175 # @ingroup l2_grps_create
1176 def GetGroups(self):
1177 return self.mesh.GetGroups()
1179 ## Gets the number of groups existing in the mesh
1180 # @return the quantity of groups as an integer value
1181 # @ingroup l2_grps_create
1183 return self.mesh.NbGroups()
1185 ## Gets the list of names of groups existing in the mesh
1186 # @return list of strings
1187 # @ingroup l2_grps_create
1188 def GetGroupNames(self):
1189 groups = self.GetGroups()
1191 for group in groups:
1192 names.append(group.GetName())
1195 ## Produces a union of two groups
1196 # A new group is created. All mesh elements that are
1197 # present in the initial groups are added to the new one
1198 # @return an instance of SMESH_Group
1199 # @ingroup l2_grps_operon
1200 def UnionGroups(self, group1, group2, name):
1201 return self.mesh.UnionGroups(group1, group2, name)
1203 ## Prodices an intersection of two groups
1204 # A new group is created. All mesh elements that are common
1205 # for the two initial groups are added to the new one.
1206 # @return an instance of SMESH_Group
1207 # @ingroup l2_grps_operon
1208 def IntersectGroups(self, group1, group2, name):
1209 return self.mesh.IntersectGroups(group1, group2, name)
1211 ## Produces a cut of two groups
1212 # A new group is created. All mesh elements that are present in
1213 # the main group but are not present in the tool group are added to the new one
1214 # @return an instance of SMESH_Group
1215 # @ingroup l2_grps_operon
1216 def CutGroups(self, mainGroup, toolGroup, name):
1217 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1220 # Get some info about mesh:
1221 # ------------------------
1223 ## Returns the log of nodes and elements added or removed
1224 # since the previous clear of the log.
1225 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1226 # @return list of log_block structures:
1231 # @ingroup l1_auxiliary
1232 def GetLog(self, clearAfterGet):
1233 return self.mesh.GetLog(clearAfterGet)
1235 ## Clears the log of nodes and elements added or removed since the previous
1236 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1237 # @ingroup l1_auxiliary
1239 self.mesh.ClearLog()
1241 ## Toggles auto color mode on the object.
1242 # @param theAutoColor the flag which toggles auto color mode.
1243 # @ingroup l1_auxiliary
1244 def SetAutoColor(self, theAutoColor):
1245 self.mesh.SetAutoColor(theAutoColor)
1247 ## Gets flag of object auto color mode.
1248 # @return True or False
1249 # @ingroup l1_auxiliary
1250 def GetAutoColor(self):
1251 return self.mesh.GetAutoColor()
1253 ## Gets the internal ID
1254 # @return integer value, which is the internal Id of the mesh
1255 # @ingroup l1_auxiliary
1257 return self.mesh.GetId()
1260 # @return integer value, which is the study Id of the mesh
1261 # @ingroup l1_auxiliary
1262 def GetStudyId(self):
1263 return self.mesh.GetStudyId()
1265 ## Checks the group names for duplications.
1266 # Consider the maximum group name length stored in MED file.
1267 # @return True or False
1268 # @ingroup l1_auxiliary
1269 def HasDuplicatedGroupNamesMED(self):
1270 return self.mesh.HasDuplicatedGroupNamesMED()
1272 ## Obtains the mesh editor tool
1273 # @return an instance of SMESH_MeshEditor
1274 # @ingroup l1_modifying
1275 def GetMeshEditor(self):
1276 return self.mesh.GetMeshEditor()
1279 # @return an instance of SALOME_MED::MESH
1280 # @ingroup l1_auxiliary
1281 def GetMEDMesh(self):
1282 return self.mesh.GetMEDMesh()
1285 # Get informations about mesh contents:
1286 # ------------------------------------
1288 ## Returns the number of nodes in the mesh
1289 # @return an integer value
1290 # @ingroup l1_meshinfo
1292 return self.mesh.NbNodes()
1294 ## Returns the number of elements in the mesh
1295 # @return an integer value
1296 # @ingroup l1_meshinfo
1297 def NbElements(self):
1298 return self.mesh.NbElements()
1300 ## Returns the number of edges in the mesh
1301 # @return an integer value
1302 # @ingroup l1_meshinfo
1304 return self.mesh.NbEdges()
1306 ## Returns the number of edges with the given order in the mesh
1307 # @param elementOrder the order of elements:
1308 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1309 # @return an integer value
1310 # @ingroup l1_meshinfo
1311 def NbEdgesOfOrder(self, elementOrder):
1312 return self.mesh.NbEdgesOfOrder(elementOrder)
1314 ## Returns the number of faces in the mesh
1315 # @return an integer value
1316 # @ingroup l1_meshinfo
1318 return self.mesh.NbFaces()
1320 ## Returns the number of faces with the given order in the mesh
1321 # @param elementOrder the order of elements:
1322 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1323 # @return an integer value
1324 # @ingroup l1_meshinfo
1325 def NbFacesOfOrder(self, elementOrder):
1326 return self.mesh.NbFacesOfOrder(elementOrder)
1328 ## Returns the number of triangles in the mesh
1329 # @return an integer value
1330 # @ingroup l1_meshinfo
1331 def NbTriangles(self):
1332 return self.mesh.NbTriangles()
1334 ## Returns the number of triangles with the given order in the mesh
1335 # @param elementOrder is the order of elements:
1336 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1337 # @return an integer value
1338 # @ingroup l1_meshinfo
1339 def NbTrianglesOfOrder(self, elementOrder):
1340 return self.mesh.NbTrianglesOfOrder(elementOrder)
1342 ## Returns the number of quadrangles in the mesh
1343 # @return an integer value
1344 # @ingroup l1_meshinfo
1345 def NbQuadrangles(self):
1346 return self.mesh.NbQuadrangles()
1348 ## Returns the number of quadrangles with the given order in the mesh
1349 # @param elementOrder the order of elements:
1350 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1351 # @return an integer value
1352 # @ingroup l1_meshinfo
1353 def NbQuadranglesOfOrder(self, elementOrder):
1354 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1356 ## Returns the number of polygons in the mesh
1357 # @return an integer value
1358 # @ingroup l1_meshinfo
1359 def NbPolygons(self):
1360 return self.mesh.NbPolygons()
1362 ## Returns the number of volumes in the mesh
1363 # @return an integer value
1364 # @ingroup l1_meshinfo
1365 def NbVolumes(self):
1366 return self.mesh.NbVolumes()
1368 ## Returns the number of volumes with the given order in the mesh
1369 # @param elementOrder the order of elements:
1370 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1371 # @return an integer value
1372 # @ingroup l1_meshinfo
1373 def NbVolumesOfOrder(self, elementOrder):
1374 return self.mesh.NbVolumesOfOrder(elementOrder)
1376 ## Returns the number of tetrahedrons in the mesh
1377 # @return an integer value
1378 # @ingroup l1_meshinfo
1380 return self.mesh.NbTetras()
1382 ## Returns the number of tetrahedrons with the given order in the mesh
1383 # @param elementOrder the order of elements:
1384 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1385 # @return an integer value
1386 # @ingroup l1_meshinfo
1387 def NbTetrasOfOrder(self, elementOrder):
1388 return self.mesh.NbTetrasOfOrder(elementOrder)
1390 ## Returns the number of hexahedrons in the mesh
1391 # @return an integer value
1392 # @ingroup l1_meshinfo
1394 return self.mesh.NbHexas()
1396 ## Returns the number of hexahedrons with the given order in the mesh
1397 # @param elementOrder the order of elements:
1398 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1399 # @return an integer value
1400 # @ingroup l1_meshinfo
1401 def NbHexasOfOrder(self, elementOrder):
1402 return self.mesh.NbHexasOfOrder(elementOrder)
1404 ## Returns the number of pyramids in the mesh
1405 # @return an integer value
1406 # @ingroup l1_meshinfo
1407 def NbPyramids(self):
1408 return self.mesh.NbPyramids()
1410 ## Returns the number of pyramids with the given order in the mesh
1411 # @param elementOrder the order of elements:
1412 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1413 # @return an integer value
1414 # @ingroup l1_meshinfo
1415 def NbPyramidsOfOrder(self, elementOrder):
1416 return self.mesh.NbPyramidsOfOrder(elementOrder)
1418 ## Returns the number of prisms in the mesh
1419 # @return an integer value
1420 # @ingroup l1_meshinfo
1422 return self.mesh.NbPrisms()
1424 ## Returns the number of prisms with the given order in the mesh
1425 # @param elementOrder the order of elements:
1426 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1427 # @return an integer value
1428 # @ingroup l1_meshinfo
1429 def NbPrismsOfOrder(self, elementOrder):
1430 return self.mesh.NbPrismsOfOrder(elementOrder)
1432 ## Returns the number of polyhedrons in the mesh
1433 # @return an integer value
1434 # @ingroup l1_meshinfo
1435 def NbPolyhedrons(self):
1436 return self.mesh.NbPolyhedrons()
1438 ## Returns the number of submeshes in the mesh
1439 # @return an integer value
1440 # @ingroup l1_meshinfo
1441 def NbSubMesh(self):
1442 return self.mesh.NbSubMesh()
1444 ## Returns the list of mesh elements IDs
1445 # @return the list of integer values
1446 # @ingroup l1_meshinfo
1447 def GetElementsId(self):
1448 return self.mesh.GetElementsId()
1450 ## Returns the list of IDs of mesh elements with the given type
1451 # @param elementType the required type of elements
1452 # @return list of integer values
1453 # @ingroup l1_meshinfo
1454 def GetElementsByType(self, elementType):
1455 return self.mesh.GetElementsByType(elementType)
1457 ## Returns the list of mesh nodes IDs
1458 # @return the list of integer values
1459 # @ingroup l1_meshinfo
1460 def GetNodesId(self):
1461 return self.mesh.GetNodesId()
1463 # Get the information about mesh elements:
1464 # ------------------------------------
1466 ## Returns the type of mesh element
1467 # @return the value from SMESH::ElementType enumeration
1468 # @ingroup l1_meshinfo
1469 def GetElementType(self, id, iselem):
1470 return self.mesh.GetElementType(id, iselem)
1472 ## Returns the list of submesh elements IDs
1473 # @param Shape a geom object(subshape) IOR
1474 # Shape must be the subshape of a ShapeToMesh()
1475 # @return the list of integer values
1476 # @ingroup l1_meshinfo
1477 def GetSubMeshElementsId(self, Shape):
1478 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1479 ShapeID = Shape.GetSubShapeIndices()[0]
1482 return self.mesh.GetSubMeshElementsId(ShapeID)
1484 ## Returns the list of submesh nodes IDs
1485 # @param Shape a geom object(subshape) IOR
1486 # Shape must be the subshape of a ShapeToMesh()
1487 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1488 # @return the list of integer values
1489 # @ingroup l1_meshinfo
1490 def GetSubMeshNodesId(self, Shape, all):
1491 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1492 ShapeID = Shape.GetSubShapeIndices()[0]
1495 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1497 ## Returns the list of IDs of submesh elements with the given type
1498 # @param Shape a geom object(subshape) IOR
1499 # Shape must be a subshape of a ShapeToMesh()
1500 # @return the list of integer values
1501 # @ingroup l1_meshinfo
1502 def GetSubMeshElementType(self, Shape):
1503 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1504 ShapeID = Shape.GetSubShapeIndices()[0]
1507 return self.mesh.GetSubMeshElementType(ShapeID)
1509 ## Gets the mesh description
1510 # @return string value
1511 # @ingroup l1_meshinfo
1513 return self.mesh.Dump()
1516 # Get the information about nodes and elements of a mesh by its IDs:
1517 # -----------------------------------------------------------
1519 ## Gets XYZ coordinates of a node
1520 # \n If there is no nodes for the given ID - returns an empty list
1521 # @return a list of double precision values
1522 # @ingroup l1_meshinfo
1523 def GetNodeXYZ(self, id):
1524 return self.mesh.GetNodeXYZ(id)
1526 ## Returns list of IDs of inverse elements for the given node
1527 # \n If there is no node for the given ID - returns an empty list
1528 # @return a list of integer values
1529 # @ingroup l1_meshinfo
1530 def GetNodeInverseElements(self, id):
1531 return self.mesh.GetNodeInverseElements(id)
1533 ## @brief Returns the position of a node on the shape
1534 # @return SMESH::NodePosition
1535 # @ingroup l1_meshinfo
1536 def GetNodePosition(self,NodeID):
1537 return self.mesh.GetNodePosition(NodeID)
1539 ## If the given element is a node, returns the ID of shape
1540 # \n If there is no node for the given ID - returns -1
1541 # @return an integer value
1542 # @ingroup l1_meshinfo
1543 def GetShapeID(self, id):
1544 return self.mesh.GetShapeID(id)
1546 ## Returns the ID of the result shape after
1547 # FindShape() from SMESH_MeshEditor for the given element
1548 # \n If there is no element for the given ID - returns -1
1549 # @return an integer value
1550 # @ingroup l1_meshinfo
1551 def GetShapeIDForElem(self,id):
1552 return self.mesh.GetShapeIDForElem(id)
1554 ## Returns the number of nodes for the given element
1555 # \n If there is no element for the given ID - returns -1
1556 # @return an integer value
1557 # @ingroup l1_meshinfo
1558 def GetElemNbNodes(self, id):
1559 return self.mesh.GetElemNbNodes(id)
1561 ## Returns the node ID the given index for the given element
1562 # \n If there is no element for the given ID - returns -1
1563 # \n If there is no node for the given index - returns -2
1564 # @return an integer value
1565 # @ingroup l1_meshinfo
1566 def GetElemNode(self, id, index):
1567 return self.mesh.GetElemNode(id, index)
1569 ## Returns the IDs of nodes of the given element
1570 # @return a list of integer values
1571 # @ingroup l1_meshinfo
1572 def GetElemNodes(self, id):
1573 return self.mesh.GetElemNodes(id)
1575 ## Returns true if the given node is the medium node in the given quadratic element
1576 # @ingroup l1_meshinfo
1577 def IsMediumNode(self, elementID, nodeID):
1578 return self.mesh.IsMediumNode(elementID, nodeID)
1580 ## Returns true if the given node is the medium node in one of quadratic elements
1581 # @ingroup l1_meshinfo
1582 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1583 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1585 ## Returns the number of edges for the given element
1586 # @ingroup l1_meshinfo
1587 def ElemNbEdges(self, id):
1588 return self.mesh.ElemNbEdges(id)
1590 ## Returns the number of faces for the given element
1591 # @ingroup l1_meshinfo
1592 def ElemNbFaces(self, id):
1593 return self.mesh.ElemNbFaces(id)
1595 ## Returns true if the given element is a polygon
1596 # @ingroup l1_meshinfo
1597 def IsPoly(self, id):
1598 return self.mesh.IsPoly(id)
1600 ## Returns true if the given element is quadratic
1601 # @ingroup l1_meshinfo
1602 def IsQuadratic(self, id):
1603 return self.mesh.IsQuadratic(id)
1605 ## Returns XYZ coordinates of the barycenter of the given element
1606 # \n If there is no element for the given ID - returns an empty list
1607 # @return a list of three double values
1608 # @ingroup l1_meshinfo
1609 def BaryCenter(self, id):
1610 return self.mesh.BaryCenter(id)
1613 # Mesh edition (SMESH_MeshEditor functionality):
1614 # ---------------------------------------------
1616 ## Removes the elements from the mesh by ids
1617 # @param IDsOfElements is a list of ids of elements to remove
1618 # @return True or False
1619 # @ingroup l2_modif_del
1620 def RemoveElements(self, IDsOfElements):
1621 return self.editor.RemoveElements(IDsOfElements)
1623 ## Removes nodes from mesh by ids
1624 # @param IDsOfNodes is a list of ids of nodes to remove
1625 # @return True or False
1626 # @ingroup l2_modif_del
1627 def RemoveNodes(self, IDsOfNodes):
1628 return self.editor.RemoveNodes(IDsOfNodes)
1630 ## Add a node to the mesh by coordinates
1631 # @return Id of the new node
1632 # @ingroup l2_modif_add
1633 def AddNode(self, x, y, z):
1634 return self.editor.AddNode( x, y, z)
1636 ## Creates a linear or quadratic edge (this is determined
1637 # by the number of given nodes).
1638 # @param IDsOfNodes the list of node IDs for creation of the element.
1639 # The order of nodes in this list should correspond to the description
1640 # of MED. \n This description is located by the following link:
1641 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1642 # @return the Id of the new edge
1643 # @ingroup l2_modif_add
1644 def AddEdge(self, IDsOfNodes):
1645 return self.editor.AddEdge(IDsOfNodes)
1647 ## Creates a linear or quadratic face (this is determined
1648 # by the number of given nodes).
1649 # @param IDsOfNodes the list of node IDs for creation of the element.
1650 # The order of nodes in this list should correspond to the description
1651 # of MED. \n This description is located by the following link:
1652 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1653 # @return the Id of the new face
1654 # @ingroup l2_modif_add
1655 def AddFace(self, IDsOfNodes):
1656 return self.editor.AddFace(IDsOfNodes)
1658 ## Adds a polygonal face to the mesh by the list of node IDs
1659 # @param IdsOfNodes the list of node IDs for creation of the element.
1660 # @return the Id of the new face
1661 # @ingroup l2_modif_add
1662 def AddPolygonalFace(self, IdsOfNodes):
1663 return self.editor.AddPolygonalFace(IdsOfNodes)
1665 ## Creates both simple and quadratic volume (this is determined
1666 # by the number of given nodes).
1667 # @param IDsOfNodes the list of node IDs for creation of the element.
1668 # The order of nodes in this list should correspond to the description
1669 # of MED. \n This description is located by the following link:
1670 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1671 # @return the Id of the new volumic element
1672 # @ingroup l2_modif_add
1673 def AddVolume(self, IDsOfNodes):
1674 return self.editor.AddVolume(IDsOfNodes)
1676 ## Creates a volume of many faces, giving nodes for each face.
1677 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1678 # @param Quantities the list of integer values, Quantities[i]
1679 # gives the quantity of nodes in face number i.
1680 # @return the Id of the new volumic element
1681 # @ingroup l2_modif_add
1682 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1683 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1685 ## Creates a volume of many faces, giving the IDs of the existing faces.
1686 # @param IdsOfFaces the list of face IDs for volume creation.
1688 # Note: The created volume will refer only to the nodes
1689 # of the given faces, not to the faces themselves.
1690 # @return the Id of the new volumic element
1691 # @ingroup l2_modif_add
1692 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1693 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1696 ## @brief Binds a node to a vertex
1697 # @param NodeID a node ID
1698 # @param Vertex a vertex or vertex ID
1699 # @return True if succeed else raises an exception
1700 # @ingroup l2_modif_add
1701 def SetNodeOnVertex(self, NodeID, Vertex):
1702 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1703 VertexID = Vertex.GetSubShapeIndices()[0]
1707 self.editor.SetNodeOnVertex(NodeID, VertexID)
1708 except SALOME.SALOME_Exception, inst:
1709 raise ValueError, inst.details.text
1713 ## @brief Stores the node position on an edge
1714 # @param NodeID a node ID
1715 # @param Edge an edge or edge ID
1716 # @param paramOnEdge a parameter on the edge where the node is located
1717 # @return True if succeed else raises an exception
1718 # @ingroup l2_modif_add
1719 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1720 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1721 EdgeID = Edge.GetSubShapeIndices()[0]
1725 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1726 except SALOME.SALOME_Exception, inst:
1727 raise ValueError, inst.details.text
1730 ## @brief Stores node position on a face
1731 # @param NodeID a node ID
1732 # @param Face a face or face ID
1733 # @param u U parameter on the face where the node is located
1734 # @param v V parameter on the face where the node is located
1735 # @return True if succeed else raises an exception
1736 # @ingroup l2_modif_add
1737 def SetNodeOnFace(self, NodeID, Face, u, v):
1738 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1739 FaceID = Face.GetSubShapeIndices()[0]
1743 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1744 except SALOME.SALOME_Exception, inst:
1745 raise ValueError, inst.details.text
1748 ## @brief Binds a node to a solid
1749 # @param NodeID a node ID
1750 # @param Solid a solid or solid ID
1751 # @return True if succeed else raises an exception
1752 # @ingroup l2_modif_add
1753 def SetNodeInVolume(self, NodeID, Solid):
1754 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1755 SolidID = Solid.GetSubShapeIndices()[0]
1759 self.editor.SetNodeInVolume(NodeID, SolidID)
1760 except SALOME.SALOME_Exception, inst:
1761 raise ValueError, inst.details.text
1764 ## @brief Bind an element to a shape
1765 # @param ElementID an element ID
1766 # @param Shape a shape or shape ID
1767 # @return True if succeed else raises an exception
1768 # @ingroup l2_modif_add
1769 def SetMeshElementOnShape(self, ElementID, Shape):
1770 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1771 ShapeID = Shape.GetSubShapeIndices()[0]
1775 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1776 except SALOME.SALOME_Exception, inst:
1777 raise ValueError, inst.details.text
1781 ## Moves the node with the given id
1782 # @param NodeID the id of the node
1783 # @param x a new X coordinate
1784 # @param y a new Y coordinate
1785 # @param z a new Z coordinate
1786 # @return True if succeed else False
1787 # @ingroup l2_modif_movenode
1788 def MoveNode(self, NodeID, x, y, z):
1789 return self.editor.MoveNode(NodeID, x, y, z)
1791 ## Finds the node closest to a point
1792 # @param x the X coordinate of a point
1793 # @param y the Y coordinate of a point
1794 # @param z the Z coordinate of a point
1795 # @return the ID of a node
1796 # @ingroup l2_modif_throughp
1797 def FindNodeClosestTo(self, x, y, z):
1798 preview = self.mesh.GetMeshEditPreviewer()
1799 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1801 ## Finds the node closest to a point and moves it to a point location
1802 # @param x the X coordinate of a point
1803 # @param y the Y coordinate of a point
1804 # @param z the Z coordinate of a point
1805 # @return the ID of a moved node
1806 # @ingroup l2_modif_throughp
1807 def MeshToPassThroughAPoint(self, x, y, z):
1808 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1810 ## Replaces two neighbour triangles sharing Node1-Node2 link
1811 # with the triangles built on the same 4 nodes but having other common link.
1812 # @param NodeID1 the ID of the first node
1813 # @param NodeID2 the ID of the second node
1814 # @return false if proper faces were not found
1815 # @ingroup l2_modif_invdiag
1816 def InverseDiag(self, NodeID1, NodeID2):
1817 return self.editor.InverseDiag(NodeID1, NodeID2)
1819 ## Replaces two neighbour triangles sharing Node1-Node2 link
1820 # with a quadrangle built on the same 4 nodes.
1821 # @param NodeID1 the ID of the first node
1822 # @param NodeID2 the ID of the second node
1823 # @return false if proper faces were not found
1824 # @ingroup l2_modif_unitetri
1825 def DeleteDiag(self, NodeID1, NodeID2):
1826 return self.editor.DeleteDiag(NodeID1, NodeID2)
1828 ## Reorients elements by ids
1829 # @param IDsOfElements if undefined reorients all mesh elements
1830 # @return True if succeed else False
1831 # @ingroup l2_modif_changori
1832 def Reorient(self, IDsOfElements=None):
1833 if IDsOfElements == None:
1834 IDsOfElements = self.GetElementsId()
1835 return self.editor.Reorient(IDsOfElements)
1837 ## Reorients all elements of the object
1838 # @param theObject mesh, submesh or group
1839 # @return True if succeed else False
1840 # @ingroup l2_modif_changori
1841 def ReorientObject(self, theObject):
1842 if ( isinstance( theObject, Mesh )):
1843 theObject = theObject.GetMesh()
1844 return self.editor.ReorientObject(theObject)
1846 ## Fuses the neighbouring triangles into quadrangles.
1847 # @param IDsOfElements The triangles to be fused,
1848 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1849 # @param MaxAngle is the maximum angle between element normals at which the fusion
1850 # is still performed; theMaxAngle is mesured in radians.
1851 # @return TRUE in case of success, FALSE otherwise.
1852 # @ingroup l2_modif_unitetri
1853 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1854 if IDsOfElements == []:
1855 IDsOfElements = self.GetElementsId()
1856 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1858 ## Fuses the neighbouring triangles of the object into quadrangles
1859 # @param theObject is mesh, submesh or group
1860 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1861 # @param MaxAngle a max angle between element normals at which the fusion
1862 # is still performed; theMaxAngle is mesured in radians.
1863 # @return TRUE in case of success, FALSE otherwise.
1864 # @ingroup l2_modif_unitetri
1865 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1866 if ( isinstance( theObject, Mesh )):
1867 theObject = theObject.GetMesh()
1868 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1870 ## Splits quadrangles into triangles.
1871 # @param IDsOfElements the faces to be splitted.
1872 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1873 # @return TRUE in case of success, FALSE otherwise.
1874 # @ingroup l2_modif_cutquadr
1875 def QuadToTri (self, IDsOfElements, theCriterion):
1876 if IDsOfElements == []:
1877 IDsOfElements = self.GetElementsId()
1878 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1880 ## Splits quadrangles into triangles.
1881 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1882 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1883 # @return TRUE in case of success, FALSE otherwise.
1884 # @ingroup l2_modif_cutquadr
1885 def QuadToTriObject (self, theObject, theCriterion):
1886 if ( isinstance( theObject, Mesh )):
1887 theObject = theObject.GetMesh()
1888 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1890 ## Splits quadrangles into triangles.
1891 # @param IDsOfElements the faces to be splitted
1892 # @param Diag13 is used to choose a diagonal for splitting.
1893 # @return TRUE in case of success, FALSE otherwise.
1894 # @ingroup l2_modif_cutquadr
1895 def SplitQuad (self, IDsOfElements, Diag13):
1896 if IDsOfElements == []:
1897 IDsOfElements = self.GetElementsId()
1898 return self.editor.SplitQuad(IDsOfElements, Diag13)
1900 ## Splits quadrangles into triangles.
1901 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1902 # @param Diag13 is used to choose a diagonal for splitting.
1903 # @return TRUE in case of success, FALSE otherwise.
1904 # @ingroup l2_modif_cutquadr
1905 def SplitQuadObject (self, theObject, Diag13):
1906 if ( isinstance( theObject, Mesh )):
1907 theObject = theObject.GetMesh()
1908 return self.editor.SplitQuadObject(theObject, Diag13)
1910 ## Finds a better splitting of the given quadrangle.
1911 # @param IDOfQuad the ID of the quadrangle to be splitted.
1912 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1913 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1914 # diagonal is better, 0 if error occurs.
1915 # @ingroup l2_modif_cutquadr
1916 def BestSplit (self, IDOfQuad, theCriterion):
1917 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1919 ## Splits quadrangle faces near triangular facets of volumes
1921 # @ingroup l1_auxiliary
1922 def SplitQuadsNearTriangularFacets(self):
1923 faces_array = self.GetElementsByType(SMESH.FACE)
1924 for face_id in faces_array:
1925 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1926 quad_nodes = self.mesh.GetElemNodes(face_id)
1927 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1928 isVolumeFound = False
1929 for node1_elem in node1_elems:
1930 if not isVolumeFound:
1931 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1932 nb_nodes = self.GetElemNbNodes(node1_elem)
1933 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1934 volume_elem = node1_elem
1935 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1936 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1937 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1938 isVolumeFound = True
1939 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1940 self.SplitQuad([face_id], False) # diagonal 2-4
1941 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1942 isVolumeFound = True
1943 self.SplitQuad([face_id], True) # diagonal 1-3
1944 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1945 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1946 isVolumeFound = True
1947 self.SplitQuad([face_id], True) # diagonal 1-3
1949 ## @brief Splits hexahedrons into tetrahedrons.
1951 # This operation uses pattern mapping functionality for splitting.
1952 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1953 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1954 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1955 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
1956 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
1957 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
1958 # @return TRUE in case of success, FALSE otherwise.
1959 # @ingroup l1_auxiliary
1960 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
1961 # Pattern: 5.---------.6
1966 # (0,0,1) 4.---------.7 * |
1973 # (0,0,0) 0.---------.3
1974 pattern_tetra = "!!! Nb of points: \n 8 \n\
1984 !!! Indices of points of 6 tetras: \n\
1992 pattern = self.smeshpyD.GetPattern()
1993 isDone = pattern.LoadFromFile(pattern_tetra)
1995 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
1998 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
1999 isDone = pattern.MakeMesh(self.mesh, False, False)
2000 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2002 # split quafrangle faces near triangular facets of volumes
2003 self.SplitQuadsNearTriangularFacets()
2007 ## @brief Split hexahedrons into prisms.
2009 # Uses the pattern mapping functionality for splitting.
2010 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2011 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2012 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2013 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2014 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2015 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2016 # @return TRUE in case of success, FALSE otherwise.
2017 # @ingroup l1_auxiliary
2018 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2019 # Pattern: 5.---------.6
2024 # (0,0,1) 4.---------.7 |
2031 # (0,0,0) 0.---------.3
2032 pattern_prism = "!!! Nb of points: \n 8 \n\
2042 !!! Indices of points of 2 prisms: \n\
2046 pattern = self.smeshpyD.GetPattern()
2047 isDone = pattern.LoadFromFile(pattern_prism)
2049 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2052 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2053 isDone = pattern.MakeMesh(self.mesh, False, False)
2054 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2056 # Splits quafrangle faces near triangular facets of volumes
2057 self.SplitQuadsNearTriangularFacets()
2061 ## Smoothes elements
2062 # @param IDsOfElements the list if ids of elements to smooth
2063 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2064 # Note that nodes built on edges and boundary nodes are always fixed.
2065 # @param MaxNbOfIterations the maximum number of iterations
2066 # @param MaxAspectRatio varies in range [1.0, inf]
2067 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2068 # @return TRUE in case of success, FALSE otherwise.
2069 # @ingroup l2_modif_smooth
2070 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2071 MaxNbOfIterations, MaxAspectRatio, Method):
2072 if IDsOfElements == []:
2073 IDsOfElements = self.GetElementsId()
2074 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2075 MaxNbOfIterations, MaxAspectRatio, Method)
2077 ## Smoothes elements which belong to the given object
2078 # @param theObject the object to smooth
2079 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2080 # Note that nodes built on edges and boundary nodes are always fixed.
2081 # @param MaxNbOfIterations the maximum number of iterations
2082 # @param MaxAspectRatio varies in range [1.0, inf]
2083 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2084 # @return TRUE in case of success, FALSE otherwise.
2085 # @ingroup l2_modif_smooth
2086 def SmoothObject(self, theObject, IDsOfFixedNodes,
2087 MaxNbOfIterations, MaxAspectRatio, Method):
2088 if ( isinstance( theObject, Mesh )):
2089 theObject = theObject.GetMesh()
2090 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2091 MaxNbOfIterations, MaxAspectRatio, Method)
2093 ## Parametrically smoothes the given elements
2094 # @param IDsOfElements the list if ids of elements to smooth
2095 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2096 # Note that nodes built on edges and boundary nodes are always fixed.
2097 # @param MaxNbOfIterations the maximum number of iterations
2098 # @param MaxAspectRatio varies in range [1.0, inf]
2099 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2100 # @return TRUE in case of success, FALSE otherwise.
2101 # @ingroup l2_modif_smooth
2102 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2103 MaxNbOfIterations, MaxAspectRatio, Method):
2104 if IDsOfElements == []:
2105 IDsOfElements = self.GetElementsId()
2106 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2107 MaxNbOfIterations, MaxAspectRatio, Method)
2109 ## Parametrically smoothes the elements which belong to the given object
2110 # @param theObject the object to smooth
2111 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2112 # Note that nodes built on edges and boundary nodes are always fixed.
2113 # @param MaxNbOfIterations the maximum number of iterations
2114 # @param MaxAspectRatio varies in range [1.0, inf]
2115 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2116 # @return TRUE in case of success, FALSE otherwise.
2117 # @ingroup l2_modif_smooth
2118 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2119 MaxNbOfIterations, MaxAspectRatio, Method):
2120 if ( isinstance( theObject, Mesh )):
2121 theObject = theObject.GetMesh()
2122 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2123 MaxNbOfIterations, MaxAspectRatio, Method)
2125 ## Converts the mesh to quadratic, deletes old elements, replacing
2126 # them with quadratic with the same id.
2127 # @ingroup l2_modif_tofromqu
2128 def ConvertToQuadratic(self, theForce3d):
2129 self.editor.ConvertToQuadratic(theForce3d)
2131 ## Converts the mesh from quadratic to ordinary,
2132 # deletes old quadratic elements, \n replacing
2133 # them with ordinary mesh elements with the same id.
2134 # @return TRUE in case of success, FALSE otherwise.
2135 # @ingroup l2_modif_tofromqu
2136 def ConvertFromQuadratic(self):
2137 return self.editor.ConvertFromQuadratic()
2139 ## Renumber mesh nodes
2140 # @ingroup l2_modif_renumber
2141 def RenumberNodes(self):
2142 self.editor.RenumberNodes()
2144 ## Renumber mesh elements
2145 # @ingroup l2_modif_renumber
2146 def RenumberElements(self):
2147 self.editor.RenumberElements()
2149 ## Generates new elements by rotation of the elements around the axis
2150 # @param IDsOfElements the list of ids of elements to sweep
2151 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2152 # @param AngleInRadians the angle of Rotation
2153 # @param NbOfSteps the number of steps
2154 # @param Tolerance tolerance
2155 # @param MakeGroups forces the generation of new groups from existing ones
2156 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2157 # of all steps, else - size of each step
2158 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2159 # @ingroup l2_modif_extrurev
2160 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2161 MakeGroups=False, TotalAngle=False):
2162 if IDsOfElements == []:
2163 IDsOfElements = self.GetElementsId()
2164 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2165 Axis = self.smeshpyD.GetAxisStruct(Axis)
2166 if TotalAngle and NbOfSteps:
2167 AngleInRadians /= NbOfSteps
2169 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2170 AngleInRadians, NbOfSteps, Tolerance)
2171 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2174 ## Generates new elements by rotation of the elements of object around the axis
2175 # @param theObject object which elements should be sweeped
2176 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2177 # @param AngleInRadians the angle of Rotation
2178 # @param NbOfSteps number of steps
2179 # @param Tolerance tolerance
2180 # @param MakeGroups forces the generation of new groups from existing ones
2181 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2182 # of all steps, else - size of each step
2183 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2184 # @ingroup l2_modif_extrurev
2185 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2186 MakeGroups=False, TotalAngle=False):
2187 if ( isinstance( theObject, Mesh )):
2188 theObject = theObject.GetMesh()
2189 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2190 Axis = self.smeshpyD.GetAxisStruct(Axis)
2191 if TotalAngle and NbOfSteps:
2192 AngleInRadians /= NbOfSteps
2194 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2195 NbOfSteps, Tolerance)
2196 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2199 ## Generates new elements by extrusion of the elements with given ids
2200 # @param IDsOfElements the list of elements ids for extrusion
2201 # @param StepVector vector, defining the direction and value of extrusion
2202 # @param NbOfSteps the number of steps
2203 # @param MakeGroups forces the generation of new groups from existing ones
2204 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2205 # @ingroup l2_modif_extrurev
2206 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2207 if IDsOfElements == []:
2208 IDsOfElements = self.GetElementsId()
2209 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2210 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2212 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2213 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2216 ## Generates new elements by extrusion of the elements with given ids
2217 # @param IDsOfElements is ids of elements
2218 # @param StepVector vector, defining the direction and value of extrusion
2219 # @param NbOfSteps the number of steps
2220 # @param ExtrFlags sets flags for extrusion
2221 # @param SewTolerance uses for comparing locations of nodes if flag
2222 # EXTRUSION_FLAG_SEW is set
2223 # @param MakeGroups forces the generation of new groups from existing ones
2224 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2225 # @ingroup l2_modif_extrurev
2226 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2227 ExtrFlags, SewTolerance, MakeGroups=False):
2228 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2229 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2231 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2232 ExtrFlags, SewTolerance)
2233 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2234 ExtrFlags, SewTolerance)
2237 ## Generates new elements by extrusion of the elements which belong to the object
2238 # @param theObject the object which elements should be processed
2239 # @param StepVector vector, defining the direction and value of extrusion
2240 # @param NbOfSteps the number of steps
2241 # @param MakeGroups forces the generation of new groups from existing ones
2242 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2243 # @ingroup l2_modif_extrurev
2244 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2245 if ( isinstance( theObject, Mesh )):
2246 theObject = theObject.GetMesh()
2247 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2248 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2250 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2251 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2254 ## Generates new elements by extrusion of the elements which belong to the object
2255 # @param theObject object which elements should be processed
2256 # @param StepVector vector, defining the direction and value of extrusion
2257 # @param NbOfSteps the number of steps
2258 # @param MakeGroups to generate new groups from existing ones
2259 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2260 # @ingroup l2_modif_extrurev
2261 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2262 if ( isinstance( theObject, Mesh )):
2263 theObject = theObject.GetMesh()
2264 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2265 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2267 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2268 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2271 ## Generates new elements by extrusion of the elements which belong to the object
2272 # @param theObject object which elements should be processed
2273 # @param StepVector vector, defining the direction and value of extrusion
2274 # @param NbOfSteps the number of steps
2275 # @param MakeGroups forces the generation of new groups from existing ones
2276 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2277 # @ingroup l2_modif_extrurev
2278 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2279 if ( isinstance( theObject, Mesh )):
2280 theObject = theObject.GetMesh()
2281 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2282 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2284 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2285 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2288 ## Generates new elements by extrusion of the given elements
2289 # The path of extrusion must be a meshed edge.
2290 # @param IDsOfElements ids of elements
2291 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2292 # @param PathShape shape(edge) defines the sub-mesh for the path
2293 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2294 # @param HasAngles allows the shape to be rotated around the path
2295 # to get the resulting mesh in a helical fashion
2296 # @param Angles list of angles
2297 # @param HasRefPoint allows using the reference point
2298 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2299 # The User can specify any point as the Reference Point.
2300 # @param MakeGroups forces the generation of new groups from existing ones
2301 # @param LinearVariation forces the computation of rotation angles as linear
2302 # variation of the given Angles along path steps
2303 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2304 # only SMESH::Extrusion_Error otherwise
2305 # @ingroup l2_modif_extrurev
2306 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2307 HasAngles, Angles, HasRefPoint, RefPoint,
2308 MakeGroups=False, LinearVariation=False):
2309 if IDsOfElements == []:
2310 IDsOfElements = self.GetElementsId()
2311 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2312 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2314 if ( isinstance( PathMesh, Mesh )):
2315 PathMesh = PathMesh.GetMesh()
2316 if HasAngles and Angles and LinearVariation:
2317 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2320 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2321 PathShape, NodeStart, HasAngles,
2322 Angles, HasRefPoint, RefPoint)
2323 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2324 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2326 ## Generates new elements by extrusion of the elements which belong to the object
2327 # The path of extrusion must be a meshed edge.
2328 # @param theObject the object which elements should be processed
2329 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2330 # @param PathShape shape(edge) defines the sub-mesh for the path
2331 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2332 # @param HasAngles allows the shape to be rotated around the path
2333 # to get the resulting mesh in a helical fashion
2334 # @param Angles list of angles
2335 # @param HasRefPoint allows using the reference point
2336 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2337 # The User can specify any point as the Reference Point.
2338 # @param MakeGroups forces the generation of new groups from existing ones
2339 # @param LinearVariation forces the computation of rotation angles as linear
2340 # variation of the given Angles along path steps
2341 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2342 # only SMESH::Extrusion_Error otherwise
2343 # @ingroup l2_modif_extrurev
2344 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2345 HasAngles, Angles, HasRefPoint, RefPoint,
2346 MakeGroups=False, LinearVariation=False):
2347 if ( isinstance( theObject, Mesh )):
2348 theObject = theObject.GetMesh()
2349 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2350 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2351 if ( isinstance( PathMesh, Mesh )):
2352 PathMesh = PathMesh.GetMesh()
2353 if HasAngles and Angles and LinearVariation:
2354 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2357 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2358 PathShape, NodeStart, HasAngles,
2359 Angles, HasRefPoint, RefPoint)
2360 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2361 NodeStart, HasAngles, Angles, HasRefPoint,
2364 ## Creates a symmetrical copy of mesh elements
2365 # @param IDsOfElements list of elements ids
2366 # @param Mirror is AxisStruct or geom object(point, line, plane)
2367 # @param theMirrorType is POINT, AXIS or PLANE
2368 # If the Mirror is a geom object this parameter is unnecessary
2369 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2370 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2371 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2372 # @ingroup l2_modif_trsf
2373 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2374 if IDsOfElements == []:
2375 IDsOfElements = self.GetElementsId()
2376 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2377 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2378 if Copy and MakeGroups:
2379 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2380 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2383 ## Creates a new mesh by a symmetrical copy of mesh elements
2384 # @param IDsOfElements the list of elements ids
2385 # @param Mirror is AxisStruct or geom object (point, line, plane)
2386 # @param theMirrorType is POINT, AXIS or PLANE
2387 # If the Mirror is a geom object this parameter is unnecessary
2388 # @param MakeGroups to generate new groups from existing ones
2389 # @param NewMeshName a name of the new mesh to create
2390 # @return instance of Mesh class
2391 # @ingroup l2_modif_trsf
2392 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2393 if IDsOfElements == []:
2394 IDsOfElements = self.GetElementsId()
2395 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2396 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2397 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2398 MakeGroups, NewMeshName)
2399 return Mesh(self.smeshpyD,self.geompyD,mesh)
2401 ## Creates a symmetrical copy of the object
2402 # @param theObject mesh, submesh or group
2403 # @param Mirror AxisStruct or geom object (point, line, plane)
2404 # @param theMirrorType is POINT, AXIS or PLANE
2405 # If the Mirror is a geom object this parameter is unnecessary
2406 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2407 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2408 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2409 # @ingroup l2_modif_trsf
2410 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2411 if ( isinstance( theObject, Mesh )):
2412 theObject = theObject.GetMesh()
2413 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2414 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2415 if Copy and MakeGroups:
2416 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2417 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2420 ## Creates a new mesh by a symmetrical copy of the object
2421 # @param theObject mesh, submesh or group
2422 # @param Mirror AxisStruct or geom object (point, line, plane)
2423 # @param theMirrorType POINT, AXIS or PLANE
2424 # If the Mirror is a geom object this parameter is unnecessary
2425 # @param MakeGroups forces the generation of new groups from existing ones
2426 # @param NewMeshName the name of the new mesh to create
2427 # @return instance of Mesh class
2428 # @ingroup l2_modif_trsf
2429 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2430 if ( isinstance( theObject, Mesh )):
2431 theObject = theObject.GetMesh()
2432 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2433 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2434 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2435 MakeGroups, NewMeshName)
2436 return Mesh( self.smeshpyD,self.geompyD,mesh )
2438 ## Translates the elements
2439 # @param IDsOfElements list of elements ids
2440 # @param Vector the direction of translation (DirStruct or vector)
2441 # @param Copy allows copying the translated elements
2442 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2443 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2444 # @ingroup l2_modif_trsf
2445 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2446 if IDsOfElements == []:
2447 IDsOfElements = self.GetElementsId()
2448 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2449 Vector = self.smeshpyD.GetDirStruct(Vector)
2450 if Copy and MakeGroups:
2451 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2452 self.editor.Translate(IDsOfElements, Vector, Copy)
2455 ## Creates a new mesh of translated elements
2456 # @param IDsOfElements list of elements ids
2457 # @param Vector the direction of translation (DirStruct or vector)
2458 # @param MakeGroups forces the generation of new groups from existing ones
2459 # @param NewMeshName the name of the newly created mesh
2460 # @return instance of Mesh class
2461 # @ingroup l2_modif_trsf
2462 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2463 if IDsOfElements == []:
2464 IDsOfElements = self.GetElementsId()
2465 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2466 Vector = self.smeshpyD.GetDirStruct(Vector)
2467 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2468 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2470 ## Translates the object
2471 # @param theObject the object to translate (mesh, submesh, or group)
2472 # @param Vector direction of translation (DirStruct or geom vector)
2473 # @param Copy allows copying the translated elements
2474 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2475 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2476 # @ingroup l2_modif_trsf
2477 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2478 if ( isinstance( theObject, Mesh )):
2479 theObject = theObject.GetMesh()
2480 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2481 Vector = self.smeshpyD.GetDirStruct(Vector)
2482 if Copy and MakeGroups:
2483 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2484 self.editor.TranslateObject(theObject, Vector, Copy)
2487 ## Creates a new mesh from the translated object
2488 # @param theObject the object to translate (mesh, submesh, or group)
2489 # @param Vector the direction of translation (DirStruct or geom vector)
2490 # @param MakeGroups forces the generation of new groups from existing ones
2491 # @param NewMeshName the name of the newly created mesh
2492 # @return instance of Mesh class
2493 # @ingroup l2_modif_trsf
2494 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2495 if (isinstance(theObject, Mesh)):
2496 theObject = theObject.GetMesh()
2497 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2498 Vector = self.smeshpyD.GetDirStruct(Vector)
2499 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2500 return Mesh( self.smeshpyD, self.geompyD, mesh )
2502 ## Rotates the elements
2503 # @param IDsOfElements list of elements ids
2504 # @param Axis the axis of rotation (AxisStruct or geom line)
2505 # @param AngleInRadians the angle of rotation (in radians)
2506 # @param Copy allows copying the rotated elements
2507 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2508 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2509 # @ingroup l2_modif_trsf
2510 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2511 if IDsOfElements == []:
2512 IDsOfElements = self.GetElementsId()
2513 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2514 Axis = self.smeshpyD.GetAxisStruct(Axis)
2515 if Copy and MakeGroups:
2516 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2517 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2520 ## Creates a new mesh of rotated elements
2521 # @param IDsOfElements list of element ids
2522 # @param Axis the axis of rotation (AxisStruct or geom line)
2523 # @param AngleInRadians the angle of rotation (in radians)
2524 # @param MakeGroups forces the generation of new groups from existing ones
2525 # @param NewMeshName the name of the newly created mesh
2526 # @return instance of Mesh class
2527 # @ingroup l2_modif_trsf
2528 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2529 if IDsOfElements == []:
2530 IDsOfElements = self.GetElementsId()
2531 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2532 Axis = self.smeshpyD.GetAxisStruct(Axis)
2533 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2534 MakeGroups, NewMeshName)
2535 return Mesh( self.smeshpyD, self.geompyD, mesh )
2537 ## Rotates the object
2538 # @param theObject the object to rotate( mesh, submesh, or group)
2539 # @param Axis the axis of rotation (AxisStruct or geom line)
2540 # @param AngleInRadians the angle of rotation (in radians)
2541 # @param Copy allows copying the rotated elements
2542 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2543 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2544 # @ingroup l2_modif_trsf
2545 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2546 if (isinstance(theObject, Mesh)):
2547 theObject = theObject.GetMesh()
2548 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2549 Axis = self.smeshpyD.GetAxisStruct(Axis)
2550 if Copy and MakeGroups:
2551 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2552 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2555 ## Creates a new mesh from the rotated object
2556 # @param theObject the object to rotate (mesh, submesh, or group)
2557 # @param Axis the axis of rotation (AxisStruct or geom line)
2558 # @param AngleInRadians the angle of rotation (in radians)
2559 # @param MakeGroups forces the generation of new groups from existing ones
2560 # @param NewMeshName the name of the newly created mesh
2561 # @return instance of Mesh class
2562 # @ingroup l2_modif_trsf
2563 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2564 if (isinstance( theObject, Mesh )):
2565 theObject = theObject.GetMesh()
2566 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2567 Axis = self.smeshpyD.GetAxisStruct(Axis)
2568 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2569 MakeGroups, NewMeshName)
2570 return Mesh( self.smeshpyD, self.geompyD, mesh )
2572 ## Finds groups of ajacent nodes within Tolerance.
2573 # @param Tolerance the value of tolerance
2574 # @return the list of groups of nodes
2575 # @ingroup l2_modif_trsf
2576 def FindCoincidentNodes (self, Tolerance):
2577 return self.editor.FindCoincidentNodes(Tolerance)
2579 ## Finds groups of ajacent nodes within Tolerance.
2580 # @param Tolerance the value of tolerance
2581 # @param SubMeshOrGroup SubMesh or Group
2582 # @return the list of groups of nodes
2583 # @ingroup l2_modif_trsf
2584 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2585 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2588 # @param GroupsOfNodes the list of groups of nodes
2589 # @ingroup l2_modif_trsf
2590 def MergeNodes (self, GroupsOfNodes):
2591 self.editor.MergeNodes(GroupsOfNodes)
2593 ## Finds the elements built on the same nodes.
2594 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2595 # @return a list of groups of equal elements
2596 # @ingroup l2_modif_trsf
2597 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2598 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2600 ## Merges elements in each given group.
2601 # @param GroupsOfElementsID groups of elements for merging
2602 # @ingroup l2_modif_trsf
2603 def MergeElements(self, GroupsOfElementsID):
2604 self.editor.MergeElements(GroupsOfElementsID)
2606 ## Leaves one element and removes all other elements built on the same nodes.
2607 # @ingroup l2_modif_trsf
2608 def MergeEqualElements(self):
2609 self.editor.MergeEqualElements()
2611 ## Sews free borders
2612 # @return SMESH::Sew_Error
2613 # @ingroup l2_modif_trsf
2614 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2615 FirstNodeID2, SecondNodeID2, LastNodeID2,
2616 CreatePolygons, CreatePolyedrs):
2617 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2618 FirstNodeID2, SecondNodeID2, LastNodeID2,
2619 CreatePolygons, CreatePolyedrs)
2621 ## Sews conform free borders
2622 # @return SMESH::Sew_Error
2623 # @ingroup l2_modif_trsf
2624 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2625 FirstNodeID2, SecondNodeID2):
2626 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2627 FirstNodeID2, SecondNodeID2)
2629 ## Sews border to side
2630 # @return SMESH::Sew_Error
2631 # @ingroup l2_modif_trsf
2632 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2633 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2634 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2635 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2637 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2638 # merged with the nodes of elements of Side2.
2639 # The number of elements in theSide1 and in theSide2 must be
2640 # equal and they should have similar nodal connectivity.
2641 # The nodes to merge should belong to side borders and
2642 # the first node should be linked to the second.
2643 # @return SMESH::Sew_Error
2644 # @ingroup l2_modif_trsf
2645 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2646 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2647 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2648 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2649 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2650 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2652 ## Sets new nodes for the given element.
2653 # @param ide the element id
2654 # @param newIDs nodes ids
2655 # @return If the number of nodes does not correspond to the type of element - returns false
2656 # @ingroup l2_modif_edit
2657 def ChangeElemNodes(self, ide, newIDs):
2658 return self.editor.ChangeElemNodes(ide, newIDs)
2660 ## If during the last operation of MeshEditor some nodes were
2661 # created, this method returns the list of their IDs, \n
2662 # if new nodes were not created - returns empty list
2663 # @return the list of integer values (can be empty)
2664 # @ingroup l1_auxiliary
2665 def GetLastCreatedNodes(self):
2666 return self.editor.GetLastCreatedNodes()
2668 ## If during the last operation of MeshEditor some elements were
2669 # created this method returns the list of their IDs, \n
2670 # if new elements were not created - returns empty list
2671 # @return the list of integer values (can be empty)
2672 # @ingroup l1_auxiliary
2673 def GetLastCreatedElems(self):
2674 return self.editor.GetLastCreatedElems()
2676 ## The mother class to define algorithm, it is not recommended to use it directly.
2679 # @ingroup l2_algorithms
2680 class Mesh_Algorithm:
2681 # @class Mesh_Algorithm
2682 # @brief Class Mesh_Algorithm
2684 #def __init__(self,smesh):
2692 ## Finds a hypothesis in the study by its type name and parameters.
2693 # Finds only the hypotheses created in smeshpyD engine.
2694 # @return SMESH.SMESH_Hypothesis
2695 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2696 study = smeshpyD.GetCurrentStudy()
2697 #to do: find component by smeshpyD object, not by its data type
2698 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2699 if scomp is not None:
2700 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2701 # Check if the root label of the hypotheses exists
2702 if res and hypRoot is not None:
2703 iter = study.NewChildIterator(hypRoot)
2704 # Check all published hypotheses
2706 hypo_so_i = iter.Value()
2707 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2708 if attr is not None:
2709 anIOR = attr.Value()
2710 hypo_o_i = salome.orb.string_to_object(anIOR)
2711 if hypo_o_i is not None:
2712 # Check if this is a hypothesis
2713 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2714 if hypo_i is not None:
2715 # Check if the hypothesis belongs to current engine
2716 if smeshpyD.GetObjectId(hypo_i) > 0:
2717 # Check if this is the required hypothesis
2718 if hypo_i.GetName() == hypname:
2720 if CompareMethod(hypo_i, args):
2734 ## Finds the algorithm in the study by its type name.
2735 # Finds only the algorithms, which have been created in smeshpyD engine.
2736 # @return SMESH.SMESH_Algo
2737 def FindAlgorithm (self, algoname, smeshpyD):
2738 study = smeshpyD.GetCurrentStudy()
2739 #to do: find component by smeshpyD object, not by its data type
2740 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2741 if scomp is not None:
2742 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2743 # Check if the root label of the algorithms exists
2744 if res and hypRoot is not None:
2745 iter = study.NewChildIterator(hypRoot)
2746 # Check all published algorithms
2748 algo_so_i = iter.Value()
2749 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2750 if attr is not None:
2751 anIOR = attr.Value()
2752 algo_o_i = salome.orb.string_to_object(anIOR)
2753 if algo_o_i is not None:
2754 # Check if this is an algorithm
2755 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2756 if algo_i is not None:
2757 # Checks if the algorithm belongs to the current engine
2758 if smeshpyD.GetObjectId(algo_i) > 0:
2759 # Check if this is the required algorithm
2760 if algo_i.GetName() == algoname:
2773 ## If the algorithm is global, returns 0; \n
2774 # else returns the submesh associated to this algorithm.
2775 def GetSubMesh(self):
2778 ## Returns the wrapped mesher.
2779 def GetAlgorithm(self):
2782 ## Gets the list of hypothesis that can be used with this algorithm
2783 def GetCompatibleHypothesis(self):
2786 mylist = self.algo.GetCompatibleHypothesis()
2789 ## Gets the name of the algorithm
2793 ## Sets the name to the algorithm
2794 def SetName(self, name):
2795 SetName(self.algo, name)
2797 ## Gets the id of the algorithm
2799 return self.algo.GetId()
2802 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2804 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2805 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2807 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2809 self.Assign(algo, mesh, geom)
2813 def Assign(self, algo, mesh, geom):
2815 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2822 name = GetName(geom)
2824 name = mesh.geompyD.SubShapeName(geom, piece)
2825 mesh.geompyD.addToStudyInFather(piece, geom, name)
2826 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2829 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2830 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2832 def CompareHyp (self, hyp, args):
2833 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2836 def CompareEqualHyp (self, hyp, args):
2840 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2841 UseExisting=0, CompareMethod=""):
2844 if CompareMethod == "": CompareMethod = self.CompareHyp
2845 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2848 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2854 a = a + s + str(args[i])
2858 SetName(hypo, hyp + a)
2860 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2861 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2865 # Public class: Mesh_Segment
2866 # --------------------------
2868 ## Class to define a segment 1D algorithm for discretization
2871 # @ingroup l3_algos_basic
2872 class Mesh_Segment(Mesh_Algorithm):
2874 ## Private constructor.
2875 def __init__(self, mesh, geom=0):
2876 Mesh_Algorithm.__init__(self)
2877 self.Create(mesh, geom, "Regular_1D")
2879 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2880 # @param l for the length of segments that cut an edge
2881 # @param UseExisting if ==true - searches for an existing hypothesis created with
2882 # the same parameters, else (default) - creates a new one
2883 # @param p precision, used for calculation of the number of segments.
2884 # The precision should be a positive, meaningful value within the range [0,1].
2885 # In general, the number of segments is calculated with the formula:
2886 # nb = ceil((edge_length / l) - p)
2887 # Function ceil rounds its argument to the higher integer.
2888 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2889 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2890 # p=1 means rounding of (edge_length / l) to the lower integer.
2891 # Default value is 1e-07.
2892 # @return an instance of StdMeshers_LocalLength hypothesis
2893 # @ingroup l3_hypos_1dhyps
2894 def LocalLength(self, l, UseExisting=0, p=1e-07):
2895 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2896 CompareMethod=self.CompareLocalLength)
2902 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2903 def CompareLocalLength(self, hyp, args):
2904 if IsEqual(hyp.GetLength(), args[0]):
2905 return IsEqual(hyp.GetPrecision(), args[1])
2908 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2909 # @param n for the number of segments that cut an edge
2910 # @param s for the scale factor (optional)
2911 # @param UseExisting if ==true - searches for an existing hypothesis created with
2912 # the same parameters, else (default) - create a new one
2913 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2914 # @ingroup l3_hypos_1dhyps
2915 def NumberOfSegments(self, n, s=[], UseExisting=0):
2917 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2918 CompareMethod=self.CompareNumberOfSegments)
2920 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2921 CompareMethod=self.CompareNumberOfSegments)
2922 hyp.SetDistrType( 1 )
2923 hyp.SetScaleFactor(s)
2924 hyp.SetNumberOfSegments(n)
2928 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2929 def CompareNumberOfSegments(self, hyp, args):
2930 if hyp.GetNumberOfSegments() == args[0]:
2934 if hyp.GetDistrType() == 1:
2935 if IsEqual(hyp.GetScaleFactor(), args[1]):
2939 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2940 # @param start defines the length of the first segment
2941 # @param end defines the length of the last segment
2942 # @param UseExisting if ==true - searches for an existing hypothesis created with
2943 # the same parameters, else (default) - creates a new one
2944 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2945 # @ingroup l3_hypos_1dhyps
2946 def Arithmetic1D(self, start, end, UseExisting=0):
2947 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2948 CompareMethod=self.CompareArithmetic1D)
2949 hyp.SetLength(start, 1)
2950 hyp.SetLength(end , 0)
2954 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
2955 def CompareArithmetic1D(self, hyp, args):
2956 if IsEqual(hyp.GetLength(1), args[0]):
2957 if IsEqual(hyp.GetLength(0), args[1]):
2961 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
2962 # @param start defines the length of the first segment
2963 # @param end defines the length of the last segment
2964 # @param UseExisting if ==true - searches for an existing hypothesis created with
2965 # the same parameters, else (default) - creates a new one
2966 # @return an instance of StdMeshers_StartEndLength hypothesis
2967 # @ingroup l3_hypos_1dhyps
2968 def StartEndLength(self, start, end, UseExisting=0):
2969 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
2970 CompareMethod=self.CompareStartEndLength)
2971 hyp.SetLength(start, 1)
2972 hyp.SetLength(end , 0)
2975 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
2976 def CompareStartEndLength(self, hyp, args):
2977 if IsEqual(hyp.GetLength(1), args[0]):
2978 if IsEqual(hyp.GetLength(0), args[1]):
2982 ## Defines "Deflection1D" hypothesis
2983 # @param d for the deflection
2984 # @param UseExisting if ==true - searches for an existing hypothesis created with
2985 # the same parameters, else (default) - create a new one
2986 # @ingroup l3_hypos_1dhyps
2987 def Deflection1D(self, d, UseExisting=0):
2988 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
2989 CompareMethod=self.CompareDeflection1D)
2990 hyp.SetDeflection(d)
2993 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
2994 def CompareDeflection1D(self, hyp, args):
2995 return IsEqual(hyp.GetDeflection(), args[0])
2997 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
2998 # the opposite side in case of quadrangular faces
2999 # @ingroup l3_hypos_additi
3000 def Propagation(self):
3001 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3003 ## Defines "AutomaticLength" hypothesis
3004 # @param fineness for the fineness [0-1]
3005 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3006 # same parameters, else (default) - create a new one
3007 # @ingroup l3_hypos_1dhyps
3008 def AutomaticLength(self, fineness=0, UseExisting=0):
3009 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3010 CompareMethod=self.CompareAutomaticLength)
3011 hyp.SetFineness( fineness )
3014 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3015 def CompareAutomaticLength(self, hyp, args):
3016 return IsEqual(hyp.GetFineness(), args[0])
3018 ## Defines "SegmentLengthAroundVertex" hypothesis
3019 # @param length for the segment length
3020 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3021 # Any other integer value means that the hypothesis will be set on the
3022 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3023 # @param UseExisting if ==true - searches for an existing hypothesis created with
3024 # the same parameters, else (default) - creates a new one
3025 # @ingroup l3_algos_segmarv
3026 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3028 store_geom = self.geom
3029 if type(vertex) is types.IntType:
3030 if vertex == 0 or vertex == 1:
3031 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3039 if self.geom is None:
3040 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3041 name = GetName(self.geom)
3043 piece = self.mesh.geom
3044 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3045 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3046 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3048 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3050 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3051 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3053 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3054 CompareMethod=self.CompareLengthNearVertex)
3055 self.geom = store_geom
3056 hyp.SetLength( length )
3059 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3060 # @ingroup l3_algos_segmarv
3061 def CompareLengthNearVertex(self, hyp, args):
3062 return IsEqual(hyp.GetLength(), args[0])
3064 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3065 # If the 2D mesher sees that all boundary edges are quadratic,
3066 # it generates quadratic faces, else it generates linear faces using
3067 # medium nodes as if they are vertices.
3068 # The 3D mesher generates quadratic volumes only if all boundary faces
3069 # are quadratic, else it fails.
3071 # @ingroup l3_hypos_additi
3072 def QuadraticMesh(self):
3073 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3076 # Public class: Mesh_CompositeSegment
3077 # --------------------------
3079 ## Defines a segment 1D algorithm for discretization
3081 # @ingroup l3_algos_basic
3082 class Mesh_CompositeSegment(Mesh_Segment):
3084 ## Private constructor.
3085 def __init__(self, mesh, geom=0):
3086 self.Create(mesh, geom, "CompositeSegment_1D")
3089 # Public class: Mesh_Segment_Python
3090 # ---------------------------------
3092 ## Defines a segment 1D algorithm for discretization with python function
3094 # @ingroup l3_algos_basic
3095 class Mesh_Segment_Python(Mesh_Segment):
3097 ## Private constructor.
3098 def __init__(self, mesh, geom=0):
3099 import Python1dPlugin
3100 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3102 ## Defines "PythonSplit1D" hypothesis
3103 # @param n for the number of segments that cut an edge
3104 # @param func for the python function that calculates the length of all segments
3105 # @param UseExisting if ==true - searches for the existing hypothesis created with
3106 # the same parameters, else (default) - creates a new one
3107 # @ingroup l3_hypos_1dhyps
3108 def PythonSplit1D(self, n, func, UseExisting=0):
3109 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3110 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3111 hyp.SetNumberOfSegments(n)
3112 hyp.SetPythonLog10RatioFunction(func)
3115 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3116 def ComparePythonSplit1D(self, hyp, args):
3117 #if hyp.GetNumberOfSegments() == args[0]:
3118 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3122 # Public class: Mesh_Triangle
3123 # ---------------------------
3125 ## Defines a triangle 2D algorithm
3127 # @ingroup l3_algos_basic
3128 class Mesh_Triangle(Mesh_Algorithm):
3137 ## Private constructor.
3138 def __init__(self, mesh, algoType, geom=0):
3139 Mesh_Algorithm.__init__(self)
3141 self.algoType = algoType
3142 if algoType == MEFISTO:
3143 self.Create(mesh, geom, "MEFISTO_2D")
3145 elif algoType == BLSURF:
3147 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3148 #self.SetPhysicalMesh() - PAL19680
3149 elif algoType == NETGEN:
3151 print "Warning: NETGENPlugin module unavailable"
3153 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3155 elif algoType == NETGEN_2D:
3157 print "Warning: NETGENPlugin module unavailable"
3159 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3162 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3163 # @param area for the maximum area of each triangle
3164 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3165 # same parameters, else (default) - creates a new one
3167 # Only for algoType == MEFISTO || NETGEN_2D
3168 # @ingroup l3_hypos_2dhyps
3169 def MaxElementArea(self, area, UseExisting=0):
3170 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3171 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3172 CompareMethod=self.CompareMaxElementArea)
3173 hyp.SetMaxElementArea(area)
3175 elif self.algoType == NETGEN:
3176 print "Netgen 1D-2D algo doesn't support this hypothesis"
3179 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3180 def CompareMaxElementArea(self, hyp, args):
3181 return IsEqual(hyp.GetMaxElementArea(), args[0])
3183 ## Defines "LengthFromEdges" hypothesis to build triangles
3184 # based on the length of the edges taken from the wire
3186 # Only for algoType == MEFISTO || NETGEN_2D
3187 # @ingroup l3_hypos_2dhyps
3188 def LengthFromEdges(self):
3189 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3190 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3192 elif self.algoType == NETGEN:
3193 print "Netgen 1D-2D algo doesn't support this hypothesis"
3196 ## Sets a way to define size of mesh elements to generate
3197 # @param thePhysicalMesh is: DefaultSize or Custom
3198 # Parameter of BLSURF algo
3199 # @ingroup l3_hypos_blsurf
3200 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3201 if self.params == 0:
3203 self.params.SetPhysicalMesh(thePhysicalMesh)
3205 ## Sets size of mesh elements to generate
3206 # Parameter of BLSURF algo
3207 # @ingroup l3_hypos_blsurf
3208 def SetPhySize(self, theVal):
3209 if self.params == 0:
3211 self.params.SetPhySize(theVal)
3213 ## Sets lower boundary of mesh element size (PhySize)
3214 # Parameter of BLSURF algo
3215 # @ingroup l3_hypos_blsurf
3216 def SetPhyMin(self, theVal=-1):
3217 if self.params == 0:
3219 self.params.SetPhyMin(theVal)
3221 ## Sets upper boundary of mesh element size (PhySize)
3222 # Parameter of BLSURF algo
3223 # @ingroup l3_hypos_blsurf
3224 def SetPhyMax(self, theVal=-1):
3225 if self.params == 0:
3227 self.params.SetPhyMax(theVal)
3229 ## Sets a way to define maximum angular deflection of mesh from CAD model
3230 # @param theGeometricMesh is: DefaultGeom or Custom
3231 # Parameter of BLSURF algo
3232 # @ingroup l3_hypos_blsurf
3233 def SetGeometricMesh(self, theGeometricMesh=0):
3234 if self.params == 0:
3236 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
3237 self.params.SetGeometricMesh(theGeometricMesh)
3239 ## Sets angular deflection (in degrees) of a mesh face from CAD surface
3240 # Parameter of BLSURF algo
3241 # @ingroup l3_hypos_blsurf
3242 def SetAngleMeshS(self, theVal=_angleMeshS):
3243 if self.params == 0:
3245 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
3246 self.params.SetAngleMeshS(theVal)
3248 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve
3249 # Parameter of BLSURF algo
3250 # @ingroup l3_hypos_blsurf
3251 def SetAngleMeshC(self, theVal=_angleMeshS):
3252 if self.params == 0:
3254 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
3255 self.params.SetAngleMeshC(theVal)
3257 ## Sets lower boundary of mesh element size computed to respect angular deflection
3258 # Parameter of BLSURF algo
3259 # @ingroup l3_hypos_blsurf
3260 def SetGeoMin(self, theVal=-1):
3261 if self.params == 0:
3263 self.params.SetGeoMin(theVal)
3265 ## Sets upper boundary of mesh element size computed to respect angular deflection
3266 # Parameter of BLSURF algo
3267 # @ingroup l3_hypos_blsurf
3268 def SetGeoMax(self, theVal=-1):
3269 if self.params == 0:
3271 self.params.SetGeoMax(theVal)
3273 ## Sets maximal allowed ratio between the lengths of two adjacent edges
3274 # Parameter of BLSURF algo
3275 # @ingroup l3_hypos_blsurf
3276 def SetGradation(self, theVal=_gradation):
3277 if self.params == 0:
3279 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
3280 self.params.SetGradation(theVal)
3282 ## Sets topology usage way defining how mesh conformity is assured:
3283 # FromCAD, PreProcess or PreProcessPlus
3284 # FromCAD - mesh conformity is assured by conformity of a shape
3285 # PreProcess or PreProcessPlus - by pre-processing a CAD model
3286 # Parameter of BLSURF algo
3287 # @ingroup l3_hypos_blsurf
3288 def SetTopology(self, way):
3289 if self.params == 0:
3291 self.params.SetTopology(way)
3293 ## To respect geometrical edges or not
3294 # Parameter of BLSURF algo
3295 # @ingroup l3_hypos_blsurf
3296 def SetDecimesh(self, toIgnoreEdges=False):
3297 if self.params == 0:
3299 self.params.SetDecimesh(toIgnoreEdges)
3301 ## Sets verbosity level in the range 0 to 100.
3302 # Parameter of BLSURF algo
3303 # @ingroup l3_hypos_blsurf
3304 def SetVerbosity(self, level):
3305 if self.params == 0:
3307 self.params.SetVerbosity(level)
3309 ## Sets advanced option value
3310 # Parameter of BLSURF algo
3311 # @ingroup l3_hypos_blsurf
3312 def SetOptionValue(self, optionName, value):
3313 if self.params == 0:
3315 self.params.SetOptionValue(optionName,level)
3317 ## Sets QuadAllowed flag
3319 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3320 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3321 def SetQuadAllowed(self, toAllow=True):
3322 if self.algoType == NETGEN_2D:
3323 if toAllow: # add QuadranglePreference
3324 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3325 else: # remove QuadranglePreference
3326 for hyp in self.mesh.GetHypothesisList( self.geom ):
3327 if hyp.GetName() == "QuadranglePreference":
3328 self.mesh.RemoveHypothesis( self.geom, hyp )
3333 if self.params == 0:
3336 self.params.SetQuadAllowed(toAllow)
3339 ## Defines "Netgen 2D Parameters" hypothesis
3341 # Only for algoType == NETGEN
3342 # @ingroup l3_hypos_netgen
3343 def Parameters(self):
3346 if self.algoType == NETGEN:
3347 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3348 "libNETGENEngine.so", UseExisting=0)
3350 elif self.algoType == MEFISTO:
3351 print "Mefisto algo doesn't support NETGEN_Parameters_2D hypothesis"
3353 elif self.algoType == NETGEN_2D:
3354 print "NETGEN_2D_ONLY algo doesn't support 'NETGEN_Parameters_2D' hypothesis"
3355 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3357 elif self.algoType == BLSURF:
3358 self.params = self.Hypothesis("BLSURF_Parameters", [],
3359 "libBLSURFEngine.so", UseExisting=0)
3365 # Only for algoType == NETGEN
3366 # @ingroup l3_hypos_netgen
3367 def SetMaxSize(self, theSize):
3368 if self.params == 0:
3370 if self.params is not None:
3371 self.params.SetMaxSize(theSize)
3373 ## Sets SecondOrder flag
3375 # Only for algoType == NETGEN
3376 # @ingroup l3_hypos_netgen
3377 def SetSecondOrder(self, theVal):
3378 if self.params == 0:
3380 if self.params is not None:
3381 self.params.SetSecondOrder(theVal)
3383 ## Sets Optimize flag
3385 # Only for algoType == NETGEN
3386 # @ingroup l3_hypos_netgen
3387 def SetOptimize(self, theVal):
3388 if self.params == 0:
3390 if self.params is not None:
3391 self.params.SetOptimize(theVal)
3394 # @param theFineness is:
3395 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3397 # Only for algoType == NETGEN
3398 # @ingroup l3_hypos_netgen
3399 def SetFineness(self, theFineness):
3400 if self.params == 0:
3402 if self.params is not None:
3403 self.params.SetFineness(theFineness)
3407 # Only for algoType == NETGEN
3408 # @ingroup l3_hypos_netgen
3409 def SetGrowthRate(self, theRate):
3410 if self.params == 0:
3412 if self.params is not None:
3413 self.params.SetGrowthRate(theRate)
3415 ## Sets NbSegPerEdge
3417 # Only for algoType == NETGEN
3418 # @ingroup l3_hypos_netgen
3419 def SetNbSegPerEdge(self, theVal):
3420 if self.params == 0:
3422 if self.params is not None:
3423 self.params.SetNbSegPerEdge(theVal)
3425 ## Sets NbSegPerRadius
3427 # Only for algoType == NETGEN
3428 # @ingroup l3_hypos_netgen
3429 def SetNbSegPerRadius(self, theVal):
3430 if self.params == 0:
3432 if self.params is not None:
3433 self.params.SetNbSegPerRadius(theVal)
3438 # Public class: Mesh_Quadrangle
3439 # -----------------------------
3441 ## Defines a quadrangle 2D algorithm
3443 # @ingroup l3_algos_basic
3444 class Mesh_Quadrangle(Mesh_Algorithm):
3446 ## Private constructor.
3447 def __init__(self, mesh, geom=0):
3448 Mesh_Algorithm.__init__(self)
3449 self.Create(mesh, geom, "Quadrangle_2D")
3451 ## Defines "QuadranglePreference" hypothesis, forcing construction
3452 # of quadrangles if the number of nodes on the opposite edges is not the same
3453 # while the total number of nodes on edges is even
3455 # @ingroup l3_hypos_additi
3456 def QuadranglePreference(self):
3457 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3458 CompareMethod=self.CompareEqualHyp)
3461 # Public class: Mesh_Tetrahedron
3462 # ------------------------------
3464 ## Defines a tetrahedron 3D algorithm
3466 # @ingroup l3_algos_basic
3467 class Mesh_Tetrahedron(Mesh_Algorithm):
3472 ## Private constructor.
3473 def __init__(self, mesh, algoType, geom=0):
3474 Mesh_Algorithm.__init__(self)
3476 if algoType == NETGEN:
3477 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3480 elif algoType == FULL_NETGEN:
3482 print "Warning: NETGENPlugin module has not been imported."
3483 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3486 elif algoType == GHS3D:
3488 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3491 self.algoType = algoType
3493 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3494 # @param vol for the maximum volume of each tetrahedron
3495 # @param UseExisting if ==true - searches for the existing hypothesis created with
3496 # the same parameters, else (default) - creates a new one
3497 # @ingroup l3_hypos_maxvol
3498 def MaxElementVolume(self, vol, UseExisting=0):
3499 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3500 CompareMethod=self.CompareMaxElementVolume)
3501 hyp.SetMaxElementVolume(vol)
3504 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3505 def CompareMaxElementVolume(self, hyp, args):
3506 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3508 ## Defines "Netgen 3D Parameters" hypothesis
3509 # @ingroup l3_hypos_netgen
3510 def Parameters(self):
3511 if (self.algoType == FULL_NETGEN):
3512 self.params = self.Hypothesis("NETGEN_Parameters", [],
3513 "libNETGENEngine.so", UseExisting=0)
3515 if (self.algoType == GHS3D):
3516 self.params = self.Hypothesis("GHS3D_Parameters", [],
3517 "libGHS3DEngine.so", UseExisting=0)
3520 print "Algo doesn't support this hypothesis"
3524 # Parameter of FULL_NETGEN
3525 # @ingroup l3_hypos_netgen
3526 def SetMaxSize(self, theSize):
3527 if self.params == 0:
3529 self.params.SetMaxSize(theSize)
3531 ## Sets SecondOrder flag
3532 # Parameter of FULL_NETGEN
3533 # @ingroup l3_hypos_netgen
3534 def SetSecondOrder(self, theVal):
3535 if self.params == 0:
3537 self.params.SetSecondOrder(theVal)
3539 ## Sets Optimize flag
3540 # Parameter of FULL_NETGEN
3541 # @ingroup l3_hypos_netgen
3542 def SetOptimize(self, theVal):
3543 if self.params == 0:
3545 self.params.SetOptimize(theVal)
3548 # @param theFineness is:
3549 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3550 # Parameter of FULL_NETGEN
3551 # @ingroup l3_hypos_netgen
3552 def SetFineness(self, theFineness):
3553 if self.params == 0:
3555 self.params.SetFineness(theFineness)
3558 # Parameter of FULL_NETGEN
3559 # @ingroup l3_hypos_netgen
3560 def SetGrowthRate(self, theRate):
3561 if self.params == 0:
3563 self.params.SetGrowthRate(theRate)
3565 ## Sets NbSegPerEdge
3566 # Parameter of FULL_NETGEN
3567 # @ingroup l3_hypos_netgen
3568 def SetNbSegPerEdge(self, theVal):
3569 if self.params == 0:
3571 self.params.SetNbSegPerEdge(theVal)
3573 ## Sets NbSegPerRadius
3574 # Parameter of FULL_NETGEN
3575 # @ingroup l3_hypos_netgen
3576 def SetNbSegPerRadius(self, theVal):
3577 if self.params == 0:
3579 self.params.SetNbSegPerRadius(theVal)
3581 ## To mesh "holes" in a solid or not. Default is to mesh.
3582 # Parameter of GHS3D
3583 # @ingroup l3_hypos_ghs3dh
3584 def SetToMeshHoles(self, toMesh):
3585 if self.params == 0: self.Parameters()
3586 self.params.SetToMeshHoles(toMesh)
3588 ## Set Optimization level:
3589 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3590 # Default is Medium_Optimization
3591 # Parameter of GHS3D
3592 # @ingroup l3_hypos_ghs3dh
3593 def SetOptimizationLevel(self, level):
3594 if self.params == 0: self.Parameters()
3595 self.params.SetOptimizationLevel(level)
3597 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3598 # Advanced parameter of GHS3D
3599 # @ingroup l3_hypos_ghs3dh
3600 def SetMaximumMemory(self, MB):
3601 if self.params == 0: self.Parameters()
3602 self.params.SetMaximumMemory(MB)
3604 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3605 # automatic memory adjustment mode
3606 # Advanced parameter of GHS3D
3607 # @ingroup l3_hypos_ghs3dh
3608 def SetInitialMemory(self, MB):
3609 if self.params == 0: self.Parameters()
3610 self.params.SetInitialMemory(MB)
3612 ## Path to working directory
3613 # Advanced parameter of GHS3D
3614 # @ingroup l3_hypos_ghs3dh
3615 def SetWorkingDirectory(self, path):
3616 if self.params == 0: self.Parameters()
3617 self.params.SetWorkingDirectory(path)
3619 ## To keep working files or remove them. Log file remains in case of errors anyway
3620 # Advanced parameter of GHS3D
3621 # @ingroup l3_hypos_ghs3dh
3622 def SetKeepFiles(self, toKeep):
3623 if self.params == 0: self.Parameters()
3624 self.params.SetKeepFiles(toKeep)
3626 ## To set verbose level [0-10]
3627 # 0 - no standard output,
3628 # 2 - prints the data, quality statistics of the skin and final meshes and
3629 # indicates when the final mesh is being saved. In addition the software
3630 # gives indication regarding the CPU time.
3631 # 10 - same as 2 plus the main steps in the computation, quality statistics
3632 # histogram of the skin mesh, quality statistics histogram together with
3633 # the characteristics of the final mesh.
3634 # Advanced parameter of GHS3D
3635 # @ingroup l3_hypos_ghs3dh
3636 def SetVerboseLevel(self, level):
3637 if self.params == 0: self.Parameters()
3638 self.params.SetVerboseLevel(level)
3640 ## To create new nodes
3641 # Advanced parameter of GHS3D
3642 # @ingroup l3_hypos_ghs3dh
3643 def SetToCreateNewNodes(self, toCreate):
3644 if self.params == 0: self.Parameters()
3645 self.params.SetToCreateNewNodes(toCreate)
3647 ## To use boundary recovery version which tries to create mesh on a very poor
3648 # quality surface mesh
3649 # Advanced parameter of GHS3D
3650 # @ingroup l3_hypos_ghs3dh
3651 def SetToUseBoundaryRecoveryVersion(self, toUse):
3652 if self.params == 0: self.Parameters()
3653 self.params.SetToUseBoundaryRecoveryVersion(toUse)
3655 ## To set hidden/undocumented/advanced options
3656 # Advanced parameter of GHS3D
3657 # @ingroup l3_hypos_ghs3dh
3658 def SetTextOption(self, option):
3659 if self.params == 0: self.Parameters()
3660 self.params.SetTextOption(option)
3662 # Public class: Mesh_Hexahedron
3663 # ------------------------------
3665 ## Defines a hexahedron 3D algorithm
3667 # @ingroup l3_algos_basic
3668 class Mesh_Hexahedron(Mesh_Algorithm):
3673 ## Private constructor.
3674 def __init__(self, mesh, algoType=Hexa, geom=0):
3675 Mesh_Algorithm.__init__(self)
3677 self.algoType = algoType
3679 if algoType == Hexa:
3680 self.Create(mesh, geom, "Hexa_3D")
3683 elif algoType == Hexotic:
3684 import HexoticPlugin
3685 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3688 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3689 # @ingroup l3_hypos_hexotic
3690 def MinMaxQuad(self, min=3, max=8, quad=True):
3691 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3693 self.params.SetHexesMinLevel(min)
3694 self.params.SetHexesMaxLevel(max)
3695 self.params.SetHexoticQuadrangles(quad)
3698 # Deprecated, only for compatibility!
3699 # Public class: Mesh_Netgen
3700 # ------------------------------
3702 ## Defines a NETGEN-based 2D or 3D algorithm
3703 # that needs no discrete boundary (i.e. independent)
3705 # This class is deprecated, only for compatibility!
3708 # @ingroup l3_algos_basic
3709 class Mesh_Netgen(Mesh_Algorithm):
3713 ## Private constructor.
3714 def __init__(self, mesh, is3D, geom=0):
3715 Mesh_Algorithm.__init__(self)
3718 print "Warning: NETGENPlugin module has not been imported."
3722 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3726 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3729 ## Defines the hypothesis containing parameters of the algorithm
3730 def Parameters(self):
3732 hyp = self.Hypothesis("NETGEN_Parameters", [],
3733 "libNETGENEngine.so", UseExisting=0)
3735 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3736 "libNETGENEngine.so", UseExisting=0)
3739 # Public class: Mesh_Projection1D
3740 # ------------------------------
3742 ## Defines a projection 1D algorithm
3743 # @ingroup l3_algos_proj
3745 class Mesh_Projection1D(Mesh_Algorithm):
3747 ## Private constructor.
3748 def __init__(self, mesh, geom=0):
3749 Mesh_Algorithm.__init__(self)
3750 self.Create(mesh, geom, "Projection_1D")
3752 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3753 # a mesh pattern is taken, and, optionally, the association of vertices
3754 # between the source edge and a target edge (to which a hypothesis is assigned)
3755 # @param edge from which nodes distribution is taken
3756 # @param mesh from which nodes distribution is taken (optional)
3757 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3758 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3759 # to associate with \a srcV (optional)
3760 # @param UseExisting if ==true - searches for the existing hypothesis created with
3761 # the same parameters, else (default) - creates a new one
3762 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3763 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3765 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3766 hyp.SetSourceEdge( edge )
3767 if not mesh is None and isinstance(mesh, Mesh):
3768 mesh = mesh.GetMesh()
3769 hyp.SetSourceMesh( mesh )
3770 hyp.SetVertexAssociation( srcV, tgtV )
3773 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3774 #def CompareSourceEdge(self, hyp, args):
3775 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3779 # Public class: Mesh_Projection2D
3780 # ------------------------------
3782 ## Defines a projection 2D algorithm
3783 # @ingroup l3_algos_proj
3785 class Mesh_Projection2D(Mesh_Algorithm):
3787 ## Private constructor.
3788 def __init__(self, mesh, geom=0):
3789 Mesh_Algorithm.__init__(self)
3790 self.Create(mesh, geom, "Projection_2D")
3792 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3793 # a mesh pattern is taken, and, optionally, the association of vertices
3794 # between the source face and the target face (to which a hypothesis is assigned)
3795 # @param face from which the mesh pattern is taken
3796 # @param mesh from which the mesh pattern is taken (optional)
3797 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3798 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3799 # to associate with \a srcV1 (optional)
3800 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3801 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3802 # to associate with \a srcV2 (optional)
3803 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3804 # the same parameters, else (default) - forces the creation a new one
3806 # Note: all association vertices must belong to one edge of a face
3807 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3808 srcV2=None, tgtV2=None, UseExisting=0):
3809 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3811 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3812 hyp.SetSourceFace( face )
3813 if not mesh is None and isinstance(mesh, Mesh):
3814 mesh = mesh.GetMesh()
3815 hyp.SetSourceMesh( mesh )
3816 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3819 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3820 #def CompareSourceFace(self, hyp, args):
3821 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3824 # Public class: Mesh_Projection3D
3825 # ------------------------------
3827 ## Defines a projection 3D algorithm
3828 # @ingroup l3_algos_proj
3830 class Mesh_Projection3D(Mesh_Algorithm):
3832 ## Private constructor.
3833 def __init__(self, mesh, geom=0):
3834 Mesh_Algorithm.__init__(self)
3835 self.Create(mesh, geom, "Projection_3D")
3837 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3838 # the mesh pattern is taken, and, optionally, the association of vertices
3839 # between the source and the target solid (to which a hipothesis is assigned)
3840 # @param solid from where the mesh pattern is taken
3841 # @param mesh from where the mesh pattern is taken (optional)
3842 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3843 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3844 # to associate with \a srcV1 (optional)
3845 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3846 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3847 # to associate with \a srcV2 (optional)
3848 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3849 # the same parameters, else (default) - creates a new one
3851 # Note: association vertices must belong to one edge of a solid
3852 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3853 srcV2=0, tgtV2=0, UseExisting=0):
3854 hyp = self.Hypothesis("ProjectionSource3D",
3855 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3857 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3858 hyp.SetSource3DShape( solid )
3859 if not mesh is None and isinstance(mesh, Mesh):
3860 mesh = mesh.GetMesh()
3861 hyp.SetSourceMesh( mesh )
3862 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3865 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3866 #def CompareSourceShape3D(self, hyp, args):
3867 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3871 # Public class: Mesh_Prism
3872 # ------------------------
3874 ## Defines a 3D extrusion algorithm
3875 # @ingroup l3_algos_3dextr
3877 class Mesh_Prism3D(Mesh_Algorithm):
3879 ## Private constructor.
3880 def __init__(self, mesh, geom=0):
3881 Mesh_Algorithm.__init__(self)
3882 self.Create(mesh, geom, "Prism_3D")
3884 # Public class: Mesh_RadialPrism
3885 # -------------------------------
3887 ## Defines a Radial Prism 3D algorithm
3888 # @ingroup l3_algos_radialp
3890 class Mesh_RadialPrism3D(Mesh_Algorithm):
3892 ## Private constructor.
3893 def __init__(self, mesh, geom=0):
3894 Mesh_Algorithm.__init__(self)
3895 self.Create(mesh, geom, "RadialPrism_3D")
3897 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3898 self.nbLayers = None
3900 ## Return 3D hypothesis holding the 1D one
3901 def Get3DHypothesis(self):
3902 return self.distribHyp
3904 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3905 # hypothesis. Returns the created hypothesis
3906 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3907 #print "OwnHypothesis",hypType
3908 if not self.nbLayers is None:
3909 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3910 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3911 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3912 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3913 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3914 self.distribHyp.SetLayerDistribution( hyp )
3917 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3918 # prisms to build between the inner and outer shells
3919 # @param n number of layers
3920 # @param UseExisting if ==true - searches for the existing hypothesis created with
3921 # the same parameters, else (default) - creates a new one
3922 def NumberOfLayers(self, n, UseExisting=0):
3923 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3924 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3925 CompareMethod=self.CompareNumberOfLayers)
3926 self.nbLayers.SetNumberOfLayers( n )
3927 return self.nbLayers
3929 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3930 def CompareNumberOfLayers(self, hyp, args):
3931 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3933 ## Defines "LocalLength" hypothesis, specifying the segment length
3934 # to build between the inner and the outer shells
3935 # @param l the length of segments
3936 # @param p the precision of rounding
3937 def LocalLength(self, l, p=1e-07):
3938 hyp = self.OwnHypothesis("LocalLength", [l,p])
3943 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3944 # prisms to build between the inner and the outer shells.
3945 # @param n the number of layers
3946 # @param s the scale factor (optional)
3947 def NumberOfSegments(self, n, s=[]):
3949 hyp = self.OwnHypothesis("NumberOfSegments", [n])
3951 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
3952 hyp.SetDistrType( 1 )
3953 hyp.SetScaleFactor(s)
3954 hyp.SetNumberOfSegments(n)
3957 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
3958 # to build between the inner and the outer shells with a length that changes in arithmetic progression
3959 # @param start the length of the first segment
3960 # @param end the length of the last segment
3961 def Arithmetic1D(self, start, end ):
3962 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
3963 hyp.SetLength(start, 1)
3964 hyp.SetLength(end , 0)
3967 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
3968 # to build between the inner and the outer shells as geometric length increasing
3969 # @param start for the length of the first segment
3970 # @param end for the length of the last segment
3971 def StartEndLength(self, start, end):
3972 hyp = self.OwnHypothesis("StartEndLength", [start, end])
3973 hyp.SetLength(start, 1)
3974 hyp.SetLength(end , 0)
3977 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
3978 # to build between the inner and outer shells
3979 # @param fineness defines the quality of the mesh within the range [0-1]
3980 def AutomaticLength(self, fineness=0):
3981 hyp = self.OwnHypothesis("AutomaticLength")
3982 hyp.SetFineness( fineness )
3985 # Private class: Mesh_UseExisting
3986 # -------------------------------
3987 class Mesh_UseExisting(Mesh_Algorithm):
3989 def __init__(self, dim, mesh, geom=0):
3991 self.Create(mesh, geom, "UseExisting_1D")
3993 self.Create(mesh, geom, "UseExisting_2D")