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
124 NETGEN_1D2D3D = FULL_NETGEN
125 NETGEN_FULL = FULL_NETGEN
130 # MirrorType enumeration
131 POINT = SMESH_MeshEditor.POINT
132 AXIS = SMESH_MeshEditor.AXIS
133 PLANE = SMESH_MeshEditor.PLANE
135 # Smooth_Method enumeration
136 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
137 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
139 # Fineness enumeration (for NETGEN)
147 # Optimization level of GHS3D
148 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
150 # Topology treatment way of BLSURF
151 FromCAD, PreProcess, PreProcessPlus = 0,1,2
153 # Element size flag of BLSURF
154 DefaultSize, DefaultGeom, Custom = 0,0,1
156 PrecisionConfusion = 1e-07
158 def IsEqual(val1, val2, tol=PrecisionConfusion):
159 if abs(val1 - val2) < tol:
167 ior = salome.orb.object_to_string(obj)
168 sobj = salome.myStudy.FindObjectIOR(ior)
172 attr = sobj.FindAttribute("AttributeName")[1]
175 ## Prints error message if a hypothesis was not assigned.
176 def TreatHypoStatus(status, hypName, geomName, isAlgo):
178 hypType = "algorithm"
180 hypType = "hypothesis"
182 if status == HYP_UNKNOWN_FATAL :
183 reason = "for unknown reason"
184 elif status == HYP_INCOMPATIBLE :
185 reason = "this hypothesis mismatches the algorithm"
186 elif status == HYP_NOTCONFORM :
187 reason = "a non-conform mesh would be built"
188 elif status == HYP_ALREADY_EXIST :
189 reason = hypType + " of the same dimension is already assigned to this shape"
190 elif status == HYP_BAD_DIM :
191 reason = hypType + " mismatches the shape"
192 elif status == HYP_CONCURENT :
193 reason = "there are concurrent hypotheses on sub-shapes"
194 elif status == HYP_BAD_SUBSHAPE :
195 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
196 elif status == HYP_BAD_GEOMETRY:
197 reason = "geometry mismatches the expectation of the algorithm"
198 elif status == HYP_HIDDEN_ALGO:
199 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
200 elif status == HYP_HIDING_ALGO:
201 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
202 elif status == HYP_NEED_SHAPE:
203 reason = "Algorithm can't work without shape"
206 hypName = '"' + hypName + '"'
207 geomName= '"' + geomName+ '"'
208 if status < HYP_UNKNOWN_FATAL:
209 print hypName, "was assigned to", geomName,"but", reason
211 print hypName, "was not assigned to",geomName,":", reason
214 ## Converts an angle from degrees to radians
215 def DegreesToRadians(AngleInDegrees):
217 return AngleInDegrees * pi / 180.0
219 # end of l1_auxiliary
222 # All methods of this class are accessible directly from the smesh.py package.
223 class smeshDC(SMESH._objref_SMESH_Gen):
225 ## Sets the current study and Geometry component
226 # @ingroup l1_auxiliary
227 def init_smesh(self,theStudy,geompyD):
228 self.SetCurrentStudy(theStudy,geompyD)
230 ## Creates an empty Mesh. This mesh can have an underlying geometry.
231 # @param obj the Geometrical object on which the mesh is built. If not defined,
232 # the mesh will have no underlying geometry.
233 # @param name the name for the new mesh.
234 # @return an instance of Mesh class.
235 # @ingroup l2_construct
236 def Mesh(self, obj=0, name=0):
237 return Mesh(self,self.geompyD,obj,name)
239 ## Returns a long value from enumeration
240 # Should be used for SMESH.FunctorType enumeration
241 # @ingroup l1_controls
242 def EnumToLong(self,theItem):
245 ## Gets PointStruct from vertex
246 # @param theVertex a GEOM object(vertex)
247 # @return SMESH.PointStruct
248 # @ingroup l1_auxiliary
249 def GetPointStruct(self,theVertex):
250 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
251 return PointStruct(x,y,z)
253 ## Gets DirStruct from vector
254 # @param theVector a GEOM object(vector)
255 # @return SMESH.DirStruct
256 # @ingroup l1_auxiliary
257 def GetDirStruct(self,theVector):
258 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
259 if(len(vertices) != 2):
260 print "Error: vector object is incorrect."
262 p1 = self.geompyD.PointCoordinates(vertices[0])
263 p2 = self.geompyD.PointCoordinates(vertices[1])
264 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
265 dirst = DirStruct(pnt)
268 ## Makes DirStruct from a triplet
269 # @param x,y,z vector components
270 # @return SMESH.DirStruct
271 # @ingroup l1_auxiliary
272 def MakeDirStruct(self,x,y,z):
273 pnt = PointStruct(x,y,z)
274 return DirStruct(pnt)
276 ## Get AxisStruct from object
277 # @param theObj a GEOM object (line or plane)
278 # @return SMESH.AxisStruct
279 # @ingroup l1_auxiliary
280 def GetAxisStruct(self,theObj):
281 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
283 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
284 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
285 vertex1 = self.geompyD.PointCoordinates(vertex1)
286 vertex2 = self.geompyD.PointCoordinates(vertex2)
287 vertex3 = self.geompyD.PointCoordinates(vertex3)
288 vertex4 = self.geompyD.PointCoordinates(vertex4)
289 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
290 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
291 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] ]
292 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
294 elif len(edges) == 1:
295 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
296 p1 = self.geompyD.PointCoordinates( vertex1 )
297 p2 = self.geompyD.PointCoordinates( vertex2 )
298 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
302 # From SMESH_Gen interface:
303 # ------------------------
305 ## Sets the given name to the object
306 # @param obj the object to rename
307 # @param name a new object name
308 # @ingroup l1_auxiliary
309 def SetName(self, obj, name):
310 print "obj_name = ", name
311 if isinstance( obj, Mesh ):
313 elif isinstance( obj, Mesh_Algorithm ):
314 obj = obj.GetAlgorithm()
315 ior = salome.orb.object_to_string(obj)
316 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
318 ## Sets the current mode
319 # @ingroup l1_auxiliary
320 def SetEmbeddedMode( self,theMode ):
321 #self.SetEmbeddedMode(theMode)
322 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
324 ## Gets the current mode
325 # @ingroup l1_auxiliary
326 def IsEmbeddedMode(self):
327 #return self.IsEmbeddedMode()
328 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
330 ## Sets the current study
331 # @ingroup l1_auxiliary
332 def SetCurrentStudy( self, theStudy, geompyD = None ):
333 #self.SetCurrentStudy(theStudy)
336 geompyD = geompy.geom
339 self.SetGeomEngine(geompyD)
340 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
342 ## Gets the current study
343 # @ingroup l1_auxiliary
344 def GetCurrentStudy(self):
345 #return self.GetCurrentStudy()
346 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
348 ## Creates a Mesh object importing data from the given UNV file
349 # @return an instance of Mesh class
351 def CreateMeshesFromUNV( self,theFileName ):
352 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
353 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
356 ## Creates a Mesh object(s) importing data from the given MED file
357 # @return a list of Mesh class instances
359 def CreateMeshesFromMED( self,theFileName ):
360 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
362 for iMesh in range(len(aSmeshMeshes)) :
363 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
364 aMeshes.append(aMesh)
365 return aMeshes, aStatus
367 ## Creates a Mesh object importing data from the given STL file
368 # @return an instance of Mesh class
370 def CreateMeshesFromSTL( self, theFileName ):
371 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
372 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
375 ## Concatenate the given meshes into one mesh.
376 # @return an instance of Mesh class
377 # @param meshes the meshes to combine into one mesh
378 # @param uniteIdenticalGroups if true, groups with same names are united, else they are renamed
379 # @param mergeNodesAndElements if true, equal nodes and elements aremerged
380 # @param mergeTolerance tolerance for merging nodes
381 # @param allGroups forces creation of groups of all elements
382 def Concatenate( self, meshes, uniteIdenticalGroups,
383 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
385 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
386 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
388 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
389 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
390 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
393 ## From SMESH_Gen interface
394 # @return the list of integer values
395 # @ingroup l1_auxiliary
396 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
397 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
399 ## From SMESH_Gen interface. Creates a pattern
400 # @return an instance of SMESH_Pattern
402 # <a href="../tui_modifying_meshes_page.html#tui_pattern_mapping">Example of Patterns usage</a>
403 # @ingroup l2_modif_patterns
404 def GetPattern(self):
405 return SMESH._objref_SMESH_Gen.GetPattern(self)
408 # Filtering. Auxiliary functions:
409 # ------------------------------
411 ## Creates an empty criterion
412 # @return SMESH.Filter.Criterion
413 # @ingroup l1_controls
414 def GetEmptyCriterion(self):
415 Type = self.EnumToLong(FT_Undefined)
416 Compare = self.EnumToLong(FT_Undefined)
420 UnaryOp = self.EnumToLong(FT_Undefined)
421 BinaryOp = self.EnumToLong(FT_Undefined)
424 Precision = -1 ##@1e-07
425 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
426 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
428 ## Creates a criterion by the given parameters
429 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
430 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
431 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
432 # @param Treshold the threshold value (range of ids as string, shape, numeric)
433 # @param UnaryOp FT_LogicalNOT or FT_Undefined
434 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
435 # FT_Undefined (must be for the last criterion of all criteria)
436 # @return SMESH.Filter.Criterion
437 # @ingroup l1_controls
438 def GetCriterion(self,elementType,
440 Compare = FT_EqualTo,
442 UnaryOp=FT_Undefined,
443 BinaryOp=FT_Undefined):
444 aCriterion = self.GetEmptyCriterion()
445 aCriterion.TypeOfElement = elementType
446 aCriterion.Type = self.EnumToLong(CritType)
450 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
451 aCriterion.Compare = self.EnumToLong(Compare)
452 elif Compare == "=" or Compare == "==":
453 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
455 aCriterion.Compare = self.EnumToLong(FT_LessThan)
457 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
459 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
462 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
463 FT_BelongToCylinder, FT_LyingOnGeom]:
464 # Checks the treshold
465 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
466 aCriterion.ThresholdStr = GetName(aTreshold)
467 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
469 print "Error: The treshold should be a shape."
471 elif CritType == FT_RangeOfIds:
472 # Checks the treshold
473 if isinstance(aTreshold, str):
474 aCriterion.ThresholdStr = aTreshold
476 print "Error: The treshold should be a string."
478 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
479 # At this point the treshold is unnecessary
480 if aTreshold == FT_LogicalNOT:
481 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
482 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
483 aCriterion.BinaryOp = aTreshold
487 aTreshold = float(aTreshold)
488 aCriterion.Threshold = aTreshold
490 print "Error: The treshold should be a number."
493 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
494 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
496 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
497 aCriterion.BinaryOp = self.EnumToLong(Treshold)
499 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
500 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
502 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
503 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
507 ## Creates a filter with the given parameters
508 # @param elementType the type of elements in the group
509 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
510 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
511 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
512 # @param UnaryOp FT_LogicalNOT or FT_Undefined
513 # @return SMESH_Filter
514 # @ingroup l1_controls
515 def GetFilter(self,elementType,
516 CritType=FT_Undefined,
519 UnaryOp=FT_Undefined):
520 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
521 aFilterMgr = self.CreateFilterManager()
522 aFilter = aFilterMgr.CreateFilter()
524 aCriteria.append(aCriterion)
525 aFilter.SetCriteria(aCriteria)
528 ## Creates a numerical functor by its type
529 # @param theCriterion FT_...; functor type
530 # @return SMESH_NumericalFunctor
531 # @ingroup l1_controls
532 def GetFunctor(self,theCriterion):
533 aFilterMgr = self.CreateFilterManager()
534 if theCriterion == FT_AspectRatio:
535 return aFilterMgr.CreateAspectRatio()
536 elif theCriterion == FT_AspectRatio3D:
537 return aFilterMgr.CreateAspectRatio3D()
538 elif theCriterion == FT_Warping:
539 return aFilterMgr.CreateWarping()
540 elif theCriterion == FT_MinimumAngle:
541 return aFilterMgr.CreateMinimumAngle()
542 elif theCriterion == FT_Taper:
543 return aFilterMgr.CreateTaper()
544 elif theCriterion == FT_Skew:
545 return aFilterMgr.CreateSkew()
546 elif theCriterion == FT_Area:
547 return aFilterMgr.CreateArea()
548 elif theCriterion == FT_Volume3D:
549 return aFilterMgr.CreateVolume3D()
550 elif theCriterion == FT_MultiConnection:
551 return aFilterMgr.CreateMultiConnection()
552 elif theCriterion == FT_MultiConnection2D:
553 return aFilterMgr.CreateMultiConnection2D()
554 elif theCriterion == FT_Length:
555 return aFilterMgr.CreateLength()
556 elif theCriterion == FT_Length2D:
557 return aFilterMgr.CreateLength2D()
559 print "Error: given parameter is not numerucal functor type."
561 ## Creates hypothesis
564 # @return created hypothesis instance
565 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
566 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
569 #Registering the new proxy for SMESH_Gen
570 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
576 ## This class allows defining and managing a mesh.
577 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
578 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
579 # new nodes and elements and by changing the existing entities), to get information
580 # about a mesh and to export a mesh into different formats.
589 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
590 # sets the GUI name of this mesh to \a name.
591 # @param smeshpyD an instance of smeshDC class
592 # @param geompyD an instance of geompyDC class
593 # @param obj Shape to be meshed or SMESH_Mesh object
594 # @param name Study name of the mesh
595 # @ingroup l2_construct
596 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
597 self.smeshpyD=smeshpyD
602 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
604 self.mesh = self.smeshpyD.CreateMesh(self.geom)
605 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
608 self.mesh = self.smeshpyD.CreateEmptyMesh()
610 self.smeshpyD.SetName(self.mesh, name)
612 self.smeshpyD.SetName(self.mesh, GetName(obj))
615 self.geom = self.mesh.GetShapeToMesh()
617 self.editor = self.mesh.GetMeshEditor()
619 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
620 # @param theMesh a SMESH_Mesh object
621 # @ingroup l2_construct
622 def SetMesh(self, theMesh):
624 self.geom = self.mesh.GetShapeToMesh()
626 ## Returns the mesh, that is an instance of SMESH_Mesh interface
627 # @return a SMESH_Mesh object
628 # @ingroup l2_construct
632 ## Gets the name of the mesh
633 # @return the name of the mesh as a string
634 # @ingroup l2_construct
636 name = GetName(self.GetMesh())
639 ## Sets a name to the mesh
640 # @param name a new name of the mesh
641 # @ingroup l2_construct
642 def SetName(self, name):
643 self.smeshpyD.SetName(self.GetMesh(), name)
645 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
646 # The subMesh object gives access to the IDs of nodes and elements.
647 # @param theSubObject a geometrical object (shape)
648 # @param theName a name for the submesh
649 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
650 # @ingroup l2_submeshes
651 def GetSubMesh(self, theSubObject, theName):
652 submesh = self.mesh.GetSubMesh(theSubObject, theName)
655 ## Returns the shape associated to the mesh
656 # @return a GEOM_Object
657 # @ingroup l2_construct
661 ## Associates the given shape to the mesh (entails the recreation of the mesh)
662 # @param geom the shape to be meshed (GEOM_Object)
663 # @ingroup l2_construct
664 def SetShape(self, geom):
665 self.mesh = self.smeshpyD.CreateMesh(geom)
667 ## Returns true if the hypotheses are defined well
668 # @param theSubObject a subshape of a mesh shape
669 # @return True or False
670 # @ingroup l2_construct
671 def IsReadyToCompute(self, theSubObject):
672 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
674 ## Returns errors of hypotheses definition.
675 # The list of errors is empty if everything is OK.
676 # @param theSubObject a subshape of a mesh shape
677 # @return a list of errors
678 # @ingroup l2_construct
679 def GetAlgoState(self, theSubObject):
680 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
682 ## Returns a geometrical object on which the given element was built.
683 # The returned geometrical object, if not nil, is either found in the
684 # study or published by this method with the given name
685 # @param theElementID the id of the mesh element
686 # @param theGeomName the user-defined name of the geometrical object
687 # @return GEOM::GEOM_Object instance
688 # @ingroup l2_construct
689 def GetGeometryByMeshElement(self, theElementID, theGeomName):
690 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
692 ## Returns the mesh dimension depending on the dimension of the underlying shape
693 # @return mesh dimension as an integer value [0,3]
694 # @ingroup l1_auxiliary
695 def MeshDimension(self):
696 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
697 if len( shells ) > 0 :
699 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
701 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
707 ## Creates a segment discretization 1D algorithm.
708 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
709 # \n If the optional \a geom parameter is not set, this algorithm is global.
710 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
711 # @param algo the type of the required algorithm. Possible values are:
713 # - smesh.PYTHON for discretization via a python function,
714 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
715 # @param geom If defined is the subshape to be meshed
716 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
717 # @ingroup l3_algos_basic
718 def Segment(self, algo=REGULAR, geom=0):
719 ## if Segment(geom) is called by mistake
720 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
721 algo, geom = geom, algo
722 if not algo: algo = REGULAR
725 return Mesh_Segment(self, geom)
727 return Mesh_Segment_Python(self, geom)
728 elif algo == COMPOSITE:
729 return Mesh_CompositeSegment(self, geom)
731 return Mesh_Segment(self, geom)
733 ## Enables creation of nodes and segments usable by 2D algoritms.
734 # The added nodes and segments must be bound to edges and vertices by
735 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
736 # If the optional \a geom parameter is not set, this algorithm is global.
737 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
738 # @param geom the subshape to be manually meshed
739 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
740 # @ingroup l3_algos_basic
741 def UseExistingSegments(self, geom=0):
742 algo = Mesh_UseExisting(1,self,geom)
743 return algo.GetAlgorithm()
745 ## Enables creation of nodes and faces usable by 3D algoritms.
746 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
747 # and SetMeshElementOnShape()
748 # If the optional \a geom parameter is not set, this algorithm is global.
749 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
750 # @param geom the subshape to be manually meshed
751 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
752 # @ingroup l3_algos_basic
753 def UseExistingFaces(self, geom=0):
754 algo = Mesh_UseExisting(2,self,geom)
755 return algo.GetAlgorithm()
757 ## Creates a triangle 2D algorithm for faces.
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 values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
761 # @param geom If defined, the subshape to be meshed (GEOM_Object)
762 # @return an instance of Mesh_Triangle algorithm
763 # @ingroup l3_algos_basic
764 def Triangle(self, algo=MEFISTO, geom=0):
765 ## if Triangle(geom) is called by mistake
766 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
770 return Mesh_Triangle(self, algo, geom)
772 ## Creates a quadrangle 2D algorithm for faces.
773 # If the optional \a geom parameter is not set, this algorithm is global.
774 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
775 # @param geom If defined, the subshape to be meshed (GEOM_Object)
776 # @return an instance of Mesh_Quadrangle algorithm
777 # @ingroup l3_algos_basic
778 def Quadrangle(self, geom=0):
779 return Mesh_Quadrangle(self, geom)
781 ## Creates a tetrahedron 3D algorithm for solids.
782 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
783 # If the optional \a geom parameter is not set, this algorithm is global.
784 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
785 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
786 # @param geom If defined, the subshape to be meshed (GEOM_Object)
787 # @return an instance of Mesh_Tetrahedron algorithm
788 # @ingroup l3_algos_basic
789 def Tetrahedron(self, algo=NETGEN, geom=0):
790 ## if Tetrahedron(geom) is called by mistake
791 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
792 algo, geom = geom, algo
793 if not algo: algo = NETGEN
795 return Mesh_Tetrahedron(self, algo, geom)
797 ## Creates a hexahedron 3D algorithm for solids.
798 # If the optional \a geom parameter is not set, this algorithm is global.
799 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
800 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
801 # @param geom If defined, the subshape to be meshed (GEOM_Object)
802 # @return an instance of Mesh_Hexahedron algorithm
803 # @ingroup l3_algos_basic
804 def Hexahedron(self, algo=Hexa, geom=0):
805 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
806 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
807 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
808 elif geom == 0: algo, geom = Hexa, algo
809 return Mesh_Hexahedron(self, algo, geom)
811 ## Deprecated, used only for compatibility!
812 # @return an instance of Mesh_Netgen algorithm
813 # @ingroup l3_algos_basic
814 def Netgen(self, is3D, geom=0):
815 return Mesh_Netgen(self, is3D, geom)
817 ## Creates a projection 1D algorithm for edges.
818 # If the optional \a geom parameter is not set, this algorithm is global.
819 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
820 # @param geom If defined, the subshape to be meshed
821 # @return an instance of Mesh_Projection1D algorithm
822 # @ingroup l3_algos_proj
823 def Projection1D(self, geom=0):
824 return Mesh_Projection1D(self, geom)
826 ## Creates a projection 2D algorithm for faces.
827 # If the optional \a geom parameter is not set, this algorithm is global.
828 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
829 # @param geom If defined, the subshape to be meshed
830 # @return an instance of Mesh_Projection2D algorithm
831 # @ingroup l3_algos_proj
832 def Projection2D(self, geom=0):
833 return Mesh_Projection2D(self, geom)
835 ## Creates a projection 3D algorithm for solids.
836 # If the optional \a geom parameter is not set, this algorithm is global.
837 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
838 # @param geom If defined, the subshape to be meshed
839 # @return an instance of Mesh_Projection3D algorithm
840 # @ingroup l3_algos_proj
841 def Projection3D(self, geom=0):
842 return Mesh_Projection3D(self, geom)
844 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
845 # If the optional \a geom parameter is not set, this algorithm is global.
846 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
847 # @param geom If defined, the subshape to be meshed
848 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
849 # @ingroup l3_algos_radialp l3_algos_3dextr
850 def Prism(self, geom=0):
854 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
855 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
856 if nbSolids == 0 or nbSolids == nbShells:
857 return Mesh_Prism3D(self, geom)
858 return Mesh_RadialPrism3D(self, geom)
860 ## Computes the mesh and returns the status of the computation
861 # @return True or False
862 # @ingroup l2_construct
863 def Compute(self, geom=0):
864 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
866 geom = self.mesh.GetShapeToMesh()
871 ok = self.smeshpyD.Compute(self.mesh, geom)
872 except SALOME.SALOME_Exception, ex:
873 print "Mesh computation failed, exception caught:"
874 print " ", ex.details.text
877 print "Mesh computation failed, exception caught:"
878 traceback.print_exc()
880 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
891 reason = '%s %sD algorithm is missing' % (glob, dim)
892 elif err.state == HYP_MISSING:
893 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
894 % (glob, dim, name, dim))
895 elif err.state == HYP_NOTCONFORM:
896 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
897 elif err.state == HYP_BAD_PARAMETER:
898 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
899 % ( glob, dim, name ))
900 elif err.state == HYP_BAD_GEOMETRY:
901 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
902 'geometry' % ( glob, dim, name ))
904 reason = "For unknown reason."+\
905 " Revise Mesh.Compute() implementation in smeshDC.py!"
913 print '"' + GetName(self.mesh) + '"',"has not been computed:"
917 print '"' + GetName(self.mesh) + '"',"has not been computed."
920 if salome.sg.hasDesktop():
921 smeshgui = salome.ImportComponentGUI("SMESH")
922 smeshgui.Init(salome.myStudyId)
923 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
924 salome.sg.updateObjBrowser(1)
928 ## Removes all nodes and elements
929 # @ingroup l2_construct
932 if salome.sg.hasDesktop():
933 smeshgui = salome.ImportComponentGUI("SMESH")
934 smeshgui.Init(salome.myStudyId)
935 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
936 salome.sg.updateObjBrowser(1)
938 ## Removes all nodes and elements of indicated shape
939 # @ingroup l2_construct
940 def ClearSubMesh(self, geomId):
941 self.mesh.ClearSubMesh(geomId)
942 if salome.sg.hasDesktop():
943 smeshgui = salome.ImportComponentGUI("SMESH")
944 smeshgui.Init(salome.myStudyId)
945 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
946 salome.sg.updateObjBrowser(1)
948 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
949 # @param fineness [0,-1] defines mesh fineness
950 # @return True or False
951 # @ingroup l3_algos_basic
952 def AutomaticTetrahedralization(self, fineness=0):
953 dim = self.MeshDimension()
955 self.RemoveGlobalHypotheses()
956 self.Segment().AutomaticLength(fineness)
958 self.Triangle().LengthFromEdges()
961 self.Tetrahedron(NETGEN)
963 return self.Compute()
965 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
966 # @param fineness [0,-1] defines mesh fineness
967 # @return True or False
968 # @ingroup l3_algos_basic
969 def AutomaticHexahedralization(self, fineness=0):
970 dim = self.MeshDimension()
971 # assign the hypotheses
972 self.RemoveGlobalHypotheses()
973 self.Segment().AutomaticLength(fineness)
980 return self.Compute()
982 ## Assigns a hypothesis
983 # @param hyp a hypothesis to assign
984 # @param geom a subhape of mesh geometry
985 # @return SMESH.Hypothesis_Status
986 # @ingroup l2_hypotheses
987 def AddHypothesis(self, hyp, geom=0):
988 if isinstance( hyp, Mesh_Algorithm ):
989 hyp = hyp.GetAlgorithm()
994 geom = self.mesh.GetShapeToMesh()
996 status = self.mesh.AddHypothesis(geom, hyp)
997 isAlgo = hyp._narrow( SMESH_Algo )
998 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
1001 ## Unassigns a hypothesis
1002 # @param hyp a hypothesis to unassign
1003 # @param geom a subshape of mesh geometry
1004 # @return SMESH.Hypothesis_Status
1005 # @ingroup l2_hypotheses
1006 def RemoveHypothesis(self, hyp, geom=0):
1007 if isinstance( hyp, Mesh_Algorithm ):
1008 hyp = hyp.GetAlgorithm()
1013 status = self.mesh.RemoveHypothesis(geom, hyp)
1016 ## Gets the list of hypotheses added on a geometry
1017 # @param geom a subshape of mesh geometry
1018 # @return the sequence of SMESH_Hypothesis
1019 # @ingroup l2_hypotheses
1020 def GetHypothesisList(self, geom):
1021 return self.mesh.GetHypothesisList( geom )
1023 ## Removes all global hypotheses
1024 # @ingroup l2_hypotheses
1025 def RemoveGlobalHypotheses(self):
1026 current_hyps = self.mesh.GetHypothesisList( self.geom )
1027 for hyp in current_hyps:
1028 self.mesh.RemoveHypothesis( self.geom, hyp )
1032 ## Creates a mesh group based on the geometric object \a grp
1033 # and gives a \a name, \n if this parameter is not defined
1034 # the name is the same as the geometric group name \n
1035 # Note: Works like GroupOnGeom().
1036 # @param grp a geometric group, a vertex, an edge, a face or a solid
1037 # @param name the name of the mesh group
1038 # @return SMESH_GroupOnGeom
1039 # @ingroup l2_grps_create
1040 def Group(self, grp, name=""):
1041 return self.GroupOnGeom(grp, name)
1043 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
1044 # Exports the mesh in a file in MED format and chooses the \a version of MED format
1045 # @param f the file name
1046 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
1047 # @ingroup l2_impexp
1048 def ExportToMED(self, f, version, opt=0):
1049 self.mesh.ExportToMED(f, opt, version)
1051 ## Exports the mesh in a file in MED format
1052 # @param f is the file name
1053 # @param auto_groups boolean parameter for creating/not creating
1054 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
1055 # the typical use is auto_groups=false.
1056 # @param version MED format version(MED_V2_1 or MED_V2_2)
1057 # @ingroup l2_impexp
1058 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
1059 self.mesh.ExportToMED(f, auto_groups, version)
1061 ## Exports the mesh in a file in DAT format
1062 # @param f the file name
1063 # @ingroup l2_impexp
1064 def ExportDAT(self, f):
1065 self.mesh.ExportDAT(f)
1067 ## Exports the mesh in a file in UNV format
1068 # @param f the file name
1069 # @ingroup l2_impexp
1070 def ExportUNV(self, f):
1071 self.mesh.ExportUNV(f)
1073 ## Export the mesh in a file in STL format
1074 # @param f the file name
1075 # @param ascii defines the file encoding
1076 # @ingroup l2_impexp
1077 def ExportSTL(self, f, ascii=1):
1078 self.mesh.ExportSTL(f, ascii)
1081 # Operations with groups:
1082 # ----------------------
1084 ## Creates an empty mesh group
1085 # @param elementType the type of elements in the group
1086 # @param name the name of the mesh group
1087 # @return SMESH_Group
1088 # @ingroup l2_grps_create
1089 def CreateEmptyGroup(self, elementType, name):
1090 return self.mesh.CreateGroup(elementType, name)
1092 ## Creates a mesh group based on the geometrical object \a grp
1093 # and gives a \a name, \n if this parameter is not defined
1094 # the name is the same as the geometrical group name
1095 # @param grp a geometrical group, a vertex, an edge, a face or a solid
1096 # @param name the name of the mesh group
1097 # @param typ the type of elements in the group. If not set, it is
1098 # automatically detected by the type of the geometry
1099 # @return SMESH_GroupOnGeom
1100 # @ingroup l2_grps_create
1101 def GroupOnGeom(self, grp, name="", typ=None):
1103 name = grp.GetName()
1106 tgeo = str(grp.GetShapeType())
1107 if tgeo == "VERTEX":
1109 elif tgeo == "EDGE":
1111 elif tgeo == "FACE":
1113 elif tgeo == "SOLID":
1115 elif tgeo == "SHELL":
1117 elif tgeo == "COMPOUND":
1118 if len( self.geompyD.GetObjectIDs( grp )) == 0:
1119 print "Mesh.Group: empty geometric group", GetName( grp )
1121 tgeo = self.geompyD.GetType(grp)
1122 if tgeo == geompyDC.ShapeType["VERTEX"]:
1124 elif tgeo == geompyDC.ShapeType["EDGE"]:
1126 elif tgeo == geompyDC.ShapeType["FACE"]:
1128 elif tgeo == geompyDC.ShapeType["SOLID"]:
1132 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1135 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
1137 ## Creates a mesh group by the given ids of elements
1138 # @param groupName the name of the mesh group
1139 # @param elementType the type of elements in the group
1140 # @param elemIDs the list of ids
1141 # @return SMESH_Group
1142 # @ingroup l2_grps_create
1143 def MakeGroupByIds(self, groupName, elementType, elemIDs):
1144 group = self.mesh.CreateGroup(elementType, groupName)
1148 ## Creates a mesh group by the given conditions
1149 # @param groupName the name of the mesh group
1150 # @param elementType the type of elements in the group
1151 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1152 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1153 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
1154 # @param UnaryOp FT_LogicalNOT or FT_Undefined
1155 # @return SMESH_Group
1156 # @ingroup l2_grps_create
1160 CritType=FT_Undefined,
1163 UnaryOp=FT_Undefined):
1164 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1165 group = self.MakeGroupByCriterion(groupName, aCriterion)
1168 ## Creates a mesh group by the given criterion
1169 # @param groupName the name of the mesh group
1170 # @param Criterion the instance of Criterion class
1171 # @return SMESH_Group
1172 # @ingroup l2_grps_create
1173 def MakeGroupByCriterion(self, groupName, Criterion):
1174 aFilterMgr = self.smeshpyD.CreateFilterManager()
1175 aFilter = aFilterMgr.CreateFilter()
1177 aCriteria.append(Criterion)
1178 aFilter.SetCriteria(aCriteria)
1179 group = self.MakeGroupByFilter(groupName, aFilter)
1182 ## Creates a mesh group by the given criteria (list of criteria)
1183 # @param groupName the name of the mesh group
1184 # @param theCriteria the list of criteria
1185 # @return SMESH_Group
1186 # @ingroup l2_grps_create
1187 def MakeGroupByCriteria(self, groupName, theCriteria):
1188 aFilterMgr = self.smeshpyD.CreateFilterManager()
1189 aFilter = aFilterMgr.CreateFilter()
1190 aFilter.SetCriteria(theCriteria)
1191 group = self.MakeGroupByFilter(groupName, aFilter)
1194 ## Creates a mesh group by the given filter
1195 # @param groupName the name of the mesh group
1196 # @param theFilter the instance of Filter class
1197 # @return SMESH_Group
1198 # @ingroup l2_grps_create
1199 def MakeGroupByFilter(self, groupName, theFilter):
1200 anIds = theFilter.GetElementsId(self.mesh)
1201 anElemType = theFilter.GetElementType()
1202 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1205 ## Passes mesh elements through the given filter and return IDs of fitting elements
1206 # @param theFilter SMESH_Filter
1207 # @return a list of ids
1208 # @ingroup l1_controls
1209 def GetIdsFromFilter(self, theFilter):
1210 return theFilter.GetElementsId(self.mesh)
1212 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1213 # Returns a list of special structures (borders).
1214 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1215 # @ingroup l1_controls
1216 def GetFreeBorders(self):
1217 aFilterMgr = self.smeshpyD.CreateFilterManager()
1218 aPredicate = aFilterMgr.CreateFreeEdges()
1219 aPredicate.SetMesh(self.mesh)
1220 aBorders = aPredicate.GetBorders()
1224 # @ingroup l2_grps_delete
1225 def RemoveGroup(self, group):
1226 self.mesh.RemoveGroup(group)
1228 ## Removes a group with its contents
1229 # @ingroup l2_grps_delete
1230 def RemoveGroupWithContents(self, group):
1231 self.mesh.RemoveGroupWithContents(group)
1233 ## Gets the list of groups existing in the mesh
1234 # @return a sequence of SMESH_GroupBase
1235 # @ingroup l2_grps_create
1236 def GetGroups(self):
1237 return self.mesh.GetGroups()
1239 ## Gets the number of groups existing in the mesh
1240 # @return the quantity of groups as an integer value
1241 # @ingroup l2_grps_create
1243 return self.mesh.NbGroups()
1245 ## Gets the list of names of groups existing in the mesh
1246 # @return list of strings
1247 # @ingroup l2_grps_create
1248 def GetGroupNames(self):
1249 groups = self.GetGroups()
1251 for group in groups:
1252 names.append(group.GetName())
1255 ## Produces a union of two groups
1256 # A new group is created. All mesh elements that are
1257 # present in the initial groups are added to the new one
1258 # @return an instance of SMESH_Group
1259 # @ingroup l2_grps_operon
1260 def UnionGroups(self, group1, group2, name):
1261 return self.mesh.UnionGroups(group1, group2, name)
1263 ## Produces a union list of groups
1264 # New group is created. All mesh elements that are present in
1265 # initial groups are added to the new one
1266 # @return an instance of SMESH_Group
1267 # @ingroup l2_grps_operon
1268 def UnionListOfGroups(self, groups, name):
1269 return self.mesh.UnionListOfGroups(groups, name)
1271 ## Prodices an intersection of two groups
1272 # A new group is created. All mesh elements that are common
1273 # for the two initial groups are added to the new one.
1274 # @return an instance of SMESH_Group
1275 # @ingroup l2_grps_operon
1276 def IntersectGroups(self, group1, group2, name):
1277 return self.mesh.IntersectGroups(group1, group2, name)
1279 ## Produces an intersection of groups
1280 # New group is created. All mesh elements that are present in all
1281 # initial groups simultaneously are added to the new one
1282 # @return an instance of SMESH_Group
1283 # @ingroup l2_grps_operon
1284 def IntersectListOfGroups(self, groups, name):
1285 return self.mesh.IntersectListOfGroups(groups, name)
1287 ## Produces a cut of two groups
1288 # A new group is created. All mesh elements that are present in
1289 # the main group but are not present in the tool group are added to the new one
1290 # @return an instance of SMESH_Group
1291 # @ingroup l2_grps_operon
1292 def CutGroups(self, main_group, tool_group, name):
1293 return self.mesh.CutGroups(main_group, tool_group, name)
1295 ## Produces a cut of groups
1296 # A new group is created. All mesh elements that are present in main groups
1297 # but do not present in tool groups are added to the new one
1298 # @return an instance of SMESH_Group
1299 # @ingroup l2_grps_operon
1300 def CutListOfGroups(self, main_groups, tool_groups, name):
1301 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
1303 ## Produces a group of elements with specified element type using list of existing groups
1304 # A new group is created. System
1305 # 1) extract all nodes on which groups elements are built
1306 # 2) combine all elements of specified dimension laying on these nodes
1307 # @return an instance of SMESH_Group
1308 # @ingroup l2_grps_operon
1309 def CreateDimGroup(self, groups, elem_type, name):
1310 return self.mesh.CreateDimGroup(groups, elem_type, name)
1313 # Get some info about mesh:
1314 # ------------------------
1316 ## Returns the log of nodes and elements added or removed
1317 # since the previous clear of the log.
1318 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1319 # @return list of log_block structures:
1324 # @ingroup l1_auxiliary
1325 def GetLog(self, clearAfterGet):
1326 return self.mesh.GetLog(clearAfterGet)
1328 ## Clears the log of nodes and elements added or removed since the previous
1329 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1330 # @ingroup l1_auxiliary
1332 self.mesh.ClearLog()
1334 ## Toggles auto color mode on the object.
1335 # @param theAutoColor the flag which toggles auto color mode.
1336 # @ingroup l1_auxiliary
1337 def SetAutoColor(self, theAutoColor):
1338 self.mesh.SetAutoColor(theAutoColor)
1340 ## Gets flag of object auto color mode.
1341 # @return True or False
1342 # @ingroup l1_auxiliary
1343 def GetAutoColor(self):
1344 return self.mesh.GetAutoColor()
1346 ## Gets the internal ID
1347 # @return integer value, which is the internal Id of the mesh
1348 # @ingroup l1_auxiliary
1350 return self.mesh.GetId()
1353 # @return integer value, which is the study Id of the mesh
1354 # @ingroup l1_auxiliary
1355 def GetStudyId(self):
1356 return self.mesh.GetStudyId()
1358 ## Checks the group names for duplications.
1359 # Consider the maximum group name length stored in MED file.
1360 # @return True or False
1361 # @ingroup l1_auxiliary
1362 def HasDuplicatedGroupNamesMED(self):
1363 return self.mesh.HasDuplicatedGroupNamesMED()
1365 ## Obtains the mesh editor tool
1366 # @return an instance of SMESH_MeshEditor
1367 # @ingroup l1_modifying
1368 def GetMeshEditor(self):
1369 return self.mesh.GetMeshEditor()
1372 # @return an instance of SALOME_MED::MESH
1373 # @ingroup l1_auxiliary
1374 def GetMEDMesh(self):
1375 return self.mesh.GetMEDMesh()
1378 # Get informations about mesh contents:
1379 # ------------------------------------
1381 ## Returns the number of nodes in the mesh
1382 # @return an integer value
1383 # @ingroup l1_meshinfo
1385 return self.mesh.NbNodes()
1387 ## Returns the number of elements in the mesh
1388 # @return an integer value
1389 # @ingroup l1_meshinfo
1390 def NbElements(self):
1391 return self.mesh.NbElements()
1393 ## Returns the number of edges in the mesh
1394 # @return an integer value
1395 # @ingroup l1_meshinfo
1397 return self.mesh.NbEdges()
1399 ## Returns the number of edges with the given order in the mesh
1400 # @param elementOrder the order of elements:
1401 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1402 # @return an integer value
1403 # @ingroup l1_meshinfo
1404 def NbEdgesOfOrder(self, elementOrder):
1405 return self.mesh.NbEdgesOfOrder(elementOrder)
1407 ## Returns the number of faces in the mesh
1408 # @return an integer value
1409 # @ingroup l1_meshinfo
1411 return self.mesh.NbFaces()
1413 ## Returns the number of faces with the given order in the mesh
1414 # @param elementOrder the order of elements:
1415 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1416 # @return an integer value
1417 # @ingroup l1_meshinfo
1418 def NbFacesOfOrder(self, elementOrder):
1419 return self.mesh.NbFacesOfOrder(elementOrder)
1421 ## Returns the number of triangles in the mesh
1422 # @return an integer value
1423 # @ingroup l1_meshinfo
1424 def NbTriangles(self):
1425 return self.mesh.NbTriangles()
1427 ## Returns the number of triangles with the given order in the mesh
1428 # @param elementOrder is the order of elements:
1429 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1430 # @return an integer value
1431 # @ingroup l1_meshinfo
1432 def NbTrianglesOfOrder(self, elementOrder):
1433 return self.mesh.NbTrianglesOfOrder(elementOrder)
1435 ## Returns the number of quadrangles in the mesh
1436 # @return an integer value
1437 # @ingroup l1_meshinfo
1438 def NbQuadrangles(self):
1439 return self.mesh.NbQuadrangles()
1441 ## Returns the number of quadrangles with the given order in the mesh
1442 # @param elementOrder the order of elements:
1443 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1444 # @return an integer value
1445 # @ingroup l1_meshinfo
1446 def NbQuadranglesOfOrder(self, elementOrder):
1447 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1449 ## Returns the number of polygons in the mesh
1450 # @return an integer value
1451 # @ingroup l1_meshinfo
1452 def NbPolygons(self):
1453 return self.mesh.NbPolygons()
1455 ## Returns the number of volumes in the mesh
1456 # @return an integer value
1457 # @ingroup l1_meshinfo
1458 def NbVolumes(self):
1459 return self.mesh.NbVolumes()
1461 ## Returns the number of volumes with the given order in the mesh
1462 # @param elementOrder the order of elements:
1463 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1464 # @return an integer value
1465 # @ingroup l1_meshinfo
1466 def NbVolumesOfOrder(self, elementOrder):
1467 return self.mesh.NbVolumesOfOrder(elementOrder)
1469 ## Returns the number of tetrahedrons in the mesh
1470 # @return an integer value
1471 # @ingroup l1_meshinfo
1473 return self.mesh.NbTetras()
1475 ## Returns the number of tetrahedrons with the given order in the mesh
1476 # @param elementOrder the order of elements:
1477 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1478 # @return an integer value
1479 # @ingroup l1_meshinfo
1480 def NbTetrasOfOrder(self, elementOrder):
1481 return self.mesh.NbTetrasOfOrder(elementOrder)
1483 ## Returns the number of hexahedrons in the mesh
1484 # @return an integer value
1485 # @ingroup l1_meshinfo
1487 return self.mesh.NbHexas()
1489 ## Returns the number of hexahedrons with the given order in the mesh
1490 # @param elementOrder the order of elements:
1491 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1492 # @return an integer value
1493 # @ingroup l1_meshinfo
1494 def NbHexasOfOrder(self, elementOrder):
1495 return self.mesh.NbHexasOfOrder(elementOrder)
1497 ## Returns the number of pyramids in the mesh
1498 # @return an integer value
1499 # @ingroup l1_meshinfo
1500 def NbPyramids(self):
1501 return self.mesh.NbPyramids()
1503 ## Returns the number of pyramids with the given order in the mesh
1504 # @param elementOrder the order of elements:
1505 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1506 # @return an integer value
1507 # @ingroup l1_meshinfo
1508 def NbPyramidsOfOrder(self, elementOrder):
1509 return self.mesh.NbPyramidsOfOrder(elementOrder)
1511 ## Returns the number of prisms in the mesh
1512 # @return an integer value
1513 # @ingroup l1_meshinfo
1515 return self.mesh.NbPrisms()
1517 ## Returns the number of prisms with the given order in the mesh
1518 # @param elementOrder the order of elements:
1519 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1520 # @return an integer value
1521 # @ingroup l1_meshinfo
1522 def NbPrismsOfOrder(self, elementOrder):
1523 return self.mesh.NbPrismsOfOrder(elementOrder)
1525 ## Returns the number of polyhedrons in the mesh
1526 # @return an integer value
1527 # @ingroup l1_meshinfo
1528 def NbPolyhedrons(self):
1529 return self.mesh.NbPolyhedrons()
1531 ## Returns the number of submeshes in the mesh
1532 # @return an integer value
1533 # @ingroup l1_meshinfo
1534 def NbSubMesh(self):
1535 return self.mesh.NbSubMesh()
1537 ## Returns the list of mesh elements IDs
1538 # @return the list of integer values
1539 # @ingroup l1_meshinfo
1540 def GetElementsId(self):
1541 return self.mesh.GetElementsId()
1543 ## Returns the list of IDs of mesh elements with the given type
1544 # @param elementType the required type of elements
1545 # @return list of integer values
1546 # @ingroup l1_meshinfo
1547 def GetElementsByType(self, elementType):
1548 return self.mesh.GetElementsByType(elementType)
1550 ## Returns the list of mesh nodes IDs
1551 # @return the list of integer values
1552 # @ingroup l1_meshinfo
1553 def GetNodesId(self):
1554 return self.mesh.GetNodesId()
1556 # Get the information about mesh elements:
1557 # ------------------------------------
1559 ## Returns the type of mesh element
1560 # @return the value from SMESH::ElementType enumeration
1561 # @ingroup l1_meshinfo
1562 def GetElementType(self, id, iselem):
1563 return self.mesh.GetElementType(id, iselem)
1565 ## Returns the list of submesh elements IDs
1566 # @param Shape a geom object(subshape) IOR
1567 # Shape must be the subshape of a ShapeToMesh()
1568 # @return the list of integer values
1569 # @ingroup l1_meshinfo
1570 def GetSubMeshElementsId(self, Shape):
1571 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1572 ShapeID = Shape.GetSubShapeIndices()[0]
1575 return self.mesh.GetSubMeshElementsId(ShapeID)
1577 ## Returns the list of submesh nodes IDs
1578 # @param Shape a geom object(subshape) IOR
1579 # Shape must be the subshape of a ShapeToMesh()
1580 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1581 # @return the list of integer values
1582 # @ingroup l1_meshinfo
1583 def GetSubMeshNodesId(self, Shape, all):
1584 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1585 ShapeID = Shape.GetSubShapeIndices()[0]
1588 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1590 ## Returns the list of IDs of submesh elements with the given type
1591 # @param Shape a geom object(subshape) IOR
1592 # Shape must be a subshape of a ShapeToMesh()
1593 # @return the list of integer values
1594 # @ingroup l1_meshinfo
1595 def GetSubMeshElementType(self, Shape):
1596 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1597 ShapeID = Shape.GetSubShapeIndices()[0]
1600 return self.mesh.GetSubMeshElementType(ShapeID)
1602 ## Gets the mesh description
1603 # @return string value
1604 # @ingroup l1_meshinfo
1606 return self.mesh.Dump()
1609 # Get the information about nodes and elements of a mesh by its IDs:
1610 # -----------------------------------------------------------
1612 ## Gets XYZ coordinates of a node
1613 # \n If there is no nodes for the given ID - returns an empty list
1614 # @return a list of double precision values
1615 # @ingroup l1_meshinfo
1616 def GetNodeXYZ(self, id):
1617 return self.mesh.GetNodeXYZ(id)
1619 ## Returns list of IDs of inverse elements for the given node
1620 # \n If there is no node for the given ID - returns an empty list
1621 # @return a list of integer values
1622 # @ingroup l1_meshinfo
1623 def GetNodeInverseElements(self, id):
1624 return self.mesh.GetNodeInverseElements(id)
1626 ## @brief Returns the position of a node on the shape
1627 # @return SMESH::NodePosition
1628 # @ingroup l1_meshinfo
1629 def GetNodePosition(self,NodeID):
1630 return self.mesh.GetNodePosition(NodeID)
1632 ## If the given element is a node, returns the ID of shape
1633 # \n If there is no node for the given ID - returns -1
1634 # @return an integer value
1635 # @ingroup l1_meshinfo
1636 def GetShapeID(self, id):
1637 return self.mesh.GetShapeID(id)
1639 ## Returns the ID of the result shape after
1640 # FindShape() from SMESH_MeshEditor for the given element
1641 # \n If there is no element for the given ID - returns -1
1642 # @return an integer value
1643 # @ingroup l1_meshinfo
1644 def GetShapeIDForElem(self,id):
1645 return self.mesh.GetShapeIDForElem(id)
1647 ## Returns the number of nodes for the given element
1648 # \n If there is no element for the given ID - returns -1
1649 # @return an integer value
1650 # @ingroup l1_meshinfo
1651 def GetElemNbNodes(self, id):
1652 return self.mesh.GetElemNbNodes(id)
1654 ## Returns the node ID the given index for the given element
1655 # \n If there is no element for the given ID - returns -1
1656 # \n If there is no node for the given index - returns -2
1657 # @return an integer value
1658 # @ingroup l1_meshinfo
1659 def GetElemNode(self, id, index):
1660 return self.mesh.GetElemNode(id, index)
1662 ## Returns the IDs of nodes of the given element
1663 # @return a list of integer values
1664 # @ingroup l1_meshinfo
1665 def GetElemNodes(self, id):
1666 return self.mesh.GetElemNodes(id)
1668 ## Returns true if the given node is the medium node in the given quadratic element
1669 # @ingroup l1_meshinfo
1670 def IsMediumNode(self, elementID, nodeID):
1671 return self.mesh.IsMediumNode(elementID, nodeID)
1673 ## Returns true if the given node is the medium node in one of quadratic elements
1674 # @ingroup l1_meshinfo
1675 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1676 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1678 ## Returns the number of edges for the given element
1679 # @ingroup l1_meshinfo
1680 def ElemNbEdges(self, id):
1681 return self.mesh.ElemNbEdges(id)
1683 ## Returns the number of faces for the given element
1684 # @ingroup l1_meshinfo
1685 def ElemNbFaces(self, id):
1686 return self.mesh.ElemNbFaces(id)
1688 ## Returns true if the given element is a polygon
1689 # @ingroup l1_meshinfo
1690 def IsPoly(self, id):
1691 return self.mesh.IsPoly(id)
1693 ## Returns true if the given element is quadratic
1694 # @ingroup l1_meshinfo
1695 def IsQuadratic(self, id):
1696 return self.mesh.IsQuadratic(id)
1698 ## Returns XYZ coordinates of the barycenter of the given element
1699 # \n If there is no element for the given ID - returns an empty list
1700 # @return a list of three double values
1701 # @ingroup l1_meshinfo
1702 def BaryCenter(self, id):
1703 return self.mesh.BaryCenter(id)
1706 # Mesh edition (SMESH_MeshEditor functionality):
1707 # ---------------------------------------------
1709 ## Removes the elements from the mesh by ids
1710 # @param IDsOfElements is a list of ids of elements to remove
1711 # @return True or False
1712 # @ingroup l2_modif_del
1713 def RemoveElements(self, IDsOfElements):
1714 return self.editor.RemoveElements(IDsOfElements)
1716 ## Removes nodes from mesh by ids
1717 # @param IDsOfNodes is a list of ids of nodes to remove
1718 # @return True or False
1719 # @ingroup l2_modif_del
1720 def RemoveNodes(self, IDsOfNodes):
1721 return self.editor.RemoveNodes(IDsOfNodes)
1723 ## Add a node to the mesh by coordinates
1724 # @return Id of the new node
1725 # @ingroup l2_modif_add
1726 def AddNode(self, x, y, z):
1727 return self.editor.AddNode( x, y, z)
1729 ## Creates a linear or quadratic edge (this is determined
1730 # by the number of given nodes).
1731 # @param IDsOfNodes the list of node IDs for creation of the element.
1732 # The order of nodes in this list should correspond to the description
1733 # of MED. \n This description is located by the following link:
1734 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1735 # @return the Id of the new edge
1736 # @ingroup l2_modif_add
1737 def AddEdge(self, IDsOfNodes):
1738 return self.editor.AddEdge(IDsOfNodes)
1740 ## Creates a linear or quadratic face (this is determined
1741 # by the number of given nodes).
1742 # @param IDsOfNodes the list of node IDs for creation of the element.
1743 # The order of nodes in this list should correspond to the description
1744 # of MED. \n This description is located by the following link:
1745 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1746 # @return the Id of the new face
1747 # @ingroup l2_modif_add
1748 def AddFace(self, IDsOfNodes):
1749 return self.editor.AddFace(IDsOfNodes)
1751 ## Adds a polygonal face to the mesh by the list of node IDs
1752 # @param IdsOfNodes the list of node IDs for creation of the element.
1753 # @return the Id of the new face
1754 # @ingroup l2_modif_add
1755 def AddPolygonalFace(self, IdsOfNodes):
1756 return self.editor.AddPolygonalFace(IdsOfNodes)
1758 ## Creates both simple and quadratic volume (this is determined
1759 # by the number of given nodes).
1760 # @param IDsOfNodes the list of node IDs for creation of the element.
1761 # The order of nodes in this list should correspond to the description
1762 # of MED. \n This description is located by the following link:
1763 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1764 # @return the Id of the new volumic element
1765 # @ingroup l2_modif_add
1766 def AddVolume(self, IDsOfNodes):
1767 return self.editor.AddVolume(IDsOfNodes)
1769 ## Creates a volume of many faces, giving nodes for each face.
1770 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1771 # @param Quantities the list of integer values, Quantities[i]
1772 # gives the quantity of nodes in face number i.
1773 # @return the Id of the new volumic element
1774 # @ingroup l2_modif_add
1775 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1776 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1778 ## Creates a volume of many faces, giving the IDs of the existing faces.
1779 # @param IdsOfFaces the list of face IDs for volume creation.
1781 # Note: The created volume will refer only to the nodes
1782 # of the given faces, not to the faces themselves.
1783 # @return the Id of the new volumic element
1784 # @ingroup l2_modif_add
1785 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1786 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1789 ## @brief Binds a node to a vertex
1790 # @param NodeID a node ID
1791 # @param Vertex a vertex or vertex ID
1792 # @return True if succeed else raises an exception
1793 # @ingroup l2_modif_add
1794 def SetNodeOnVertex(self, NodeID, Vertex):
1795 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1796 VertexID = Vertex.GetSubShapeIndices()[0]
1800 self.editor.SetNodeOnVertex(NodeID, VertexID)
1801 except SALOME.SALOME_Exception, inst:
1802 raise ValueError, inst.details.text
1806 ## @brief Stores the node position on an edge
1807 # @param NodeID a node ID
1808 # @param Edge an edge or edge ID
1809 # @param paramOnEdge a parameter on the edge where the node is located
1810 # @return True if succeed else raises an exception
1811 # @ingroup l2_modif_add
1812 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1813 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1814 EdgeID = Edge.GetSubShapeIndices()[0]
1818 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1819 except SALOME.SALOME_Exception, inst:
1820 raise ValueError, inst.details.text
1823 ## @brief Stores node position on a face
1824 # @param NodeID a node ID
1825 # @param Face a face or face ID
1826 # @param u U parameter on the face where the node is located
1827 # @param v V parameter on the face where the node is located
1828 # @return True if succeed else raises an exception
1829 # @ingroup l2_modif_add
1830 def SetNodeOnFace(self, NodeID, Face, u, v):
1831 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1832 FaceID = Face.GetSubShapeIndices()[0]
1836 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1837 except SALOME.SALOME_Exception, inst:
1838 raise ValueError, inst.details.text
1841 ## @brief Binds a node to a solid
1842 # @param NodeID a node ID
1843 # @param Solid a solid or solid ID
1844 # @return True if succeed else raises an exception
1845 # @ingroup l2_modif_add
1846 def SetNodeInVolume(self, NodeID, Solid):
1847 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1848 SolidID = Solid.GetSubShapeIndices()[0]
1852 self.editor.SetNodeInVolume(NodeID, SolidID)
1853 except SALOME.SALOME_Exception, inst:
1854 raise ValueError, inst.details.text
1857 ## @brief Bind an element to a shape
1858 # @param ElementID an element ID
1859 # @param Shape a shape or shape ID
1860 # @return True if succeed else raises an exception
1861 # @ingroup l2_modif_add
1862 def SetMeshElementOnShape(self, ElementID, Shape):
1863 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1864 ShapeID = Shape.GetSubShapeIndices()[0]
1868 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1869 except SALOME.SALOME_Exception, inst:
1870 raise ValueError, inst.details.text
1874 ## Moves the node with the given id
1875 # @param NodeID the id of the node
1876 # @param x a new X coordinate
1877 # @param y a new Y coordinate
1878 # @param z a new Z coordinate
1879 # @return True if succeed else False
1880 # @ingroup l2_modif_movenode
1881 def MoveNode(self, NodeID, x, y, z):
1882 return self.editor.MoveNode(NodeID, x, y, z)
1884 ## Finds the node closest to a point
1885 # @param x the X coordinate of a point
1886 # @param y the Y coordinate of a point
1887 # @param z the Z coordinate of a point
1888 # @return the ID of a node
1889 # @ingroup l2_modif_throughp
1890 def FindNodeClosestTo(self, x, y, z):
1891 preview = self.mesh.GetMeshEditPreviewer()
1892 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1894 ## Finds the node closest to a point and moves it to a point location
1895 # @param x the X coordinate of a point
1896 # @param y the Y coordinate of a point
1897 # @param z the Z coordinate of a point
1898 # @return the ID of a moved node
1899 # @ingroup l2_modif_throughp
1900 def MeshToPassThroughAPoint(self, x, y, z):
1901 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1903 ## Replaces two neighbour triangles sharing Node1-Node2 link
1904 # with the triangles built on the same 4 nodes but having other common link.
1905 # @param NodeID1 the ID of the first node
1906 # @param NodeID2 the ID of the second node
1907 # @return false if proper faces were not found
1908 # @ingroup l2_modif_invdiag
1909 def InverseDiag(self, NodeID1, NodeID2):
1910 return self.editor.InverseDiag(NodeID1, NodeID2)
1912 ## Replaces two neighbour triangles sharing Node1-Node2 link
1913 # with a quadrangle built on the same 4 nodes.
1914 # @param NodeID1 the ID of the first node
1915 # @param NodeID2 the ID of the second node
1916 # @return false if proper faces were not found
1917 # @ingroup l2_modif_unitetri
1918 def DeleteDiag(self, NodeID1, NodeID2):
1919 return self.editor.DeleteDiag(NodeID1, NodeID2)
1921 ## Reorients elements by ids
1922 # @param IDsOfElements if undefined reorients all mesh elements
1923 # @return True if succeed else False
1924 # @ingroup l2_modif_changori
1925 def Reorient(self, IDsOfElements=None):
1926 if IDsOfElements == None:
1927 IDsOfElements = self.GetElementsId()
1928 return self.editor.Reorient(IDsOfElements)
1930 ## Reorients all elements of the object
1931 # @param theObject mesh, submesh or group
1932 # @return True if succeed else False
1933 # @ingroup l2_modif_changori
1934 def ReorientObject(self, theObject):
1935 if ( isinstance( theObject, Mesh )):
1936 theObject = theObject.GetMesh()
1937 return self.editor.ReorientObject(theObject)
1939 ## Fuses the neighbouring triangles into quadrangles.
1940 # @param IDsOfElements The triangles to be fused,
1941 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1942 # @param MaxAngle is the maximum angle between element normals at which the fusion
1943 # is still performed; theMaxAngle is mesured in radians.
1944 # @return TRUE in case of success, FALSE otherwise.
1945 # @ingroup l2_modif_unitetri
1946 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1947 if IDsOfElements == []:
1948 IDsOfElements = self.GetElementsId()
1949 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1951 ## Fuses the neighbouring triangles of the object into quadrangles
1952 # @param theObject is mesh, submesh or group
1953 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1954 # @param MaxAngle a max angle between element normals at which the fusion
1955 # is still performed; theMaxAngle is mesured in radians.
1956 # @return TRUE in case of success, FALSE otherwise.
1957 # @ingroup l2_modif_unitetri
1958 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1959 if ( isinstance( theObject, Mesh )):
1960 theObject = theObject.GetMesh()
1961 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1963 ## Splits quadrangles into triangles.
1964 # @param IDsOfElements the faces to be splitted.
1965 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1966 # @return TRUE in case of success, FALSE otherwise.
1967 # @ingroup l2_modif_cutquadr
1968 def QuadToTri (self, IDsOfElements, theCriterion):
1969 if IDsOfElements == []:
1970 IDsOfElements = self.GetElementsId()
1971 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1973 ## Splits quadrangles into triangles.
1974 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1975 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1976 # @return TRUE in case of success, FALSE otherwise.
1977 # @ingroup l2_modif_cutquadr
1978 def QuadToTriObject (self, theObject, theCriterion):
1979 if ( isinstance( theObject, Mesh )):
1980 theObject = theObject.GetMesh()
1981 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1983 ## Splits quadrangles into triangles.
1984 # @param IDsOfElements the faces to be splitted
1985 # @param Diag13 is used to choose a diagonal for splitting.
1986 # @return TRUE in case of success, FALSE otherwise.
1987 # @ingroup l2_modif_cutquadr
1988 def SplitQuad (self, IDsOfElements, Diag13):
1989 if IDsOfElements == []:
1990 IDsOfElements = self.GetElementsId()
1991 return self.editor.SplitQuad(IDsOfElements, Diag13)
1993 ## Splits quadrangles into triangles.
1994 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1995 # @param Diag13 is used to choose a diagonal for splitting.
1996 # @return TRUE in case of success, FALSE otherwise.
1997 # @ingroup l2_modif_cutquadr
1998 def SplitQuadObject (self, theObject, Diag13):
1999 if ( isinstance( theObject, Mesh )):
2000 theObject = theObject.GetMesh()
2001 return self.editor.SplitQuadObject(theObject, Diag13)
2003 ## Finds a better splitting of the given quadrangle.
2004 # @param IDOfQuad the ID of the quadrangle to be splitted.
2005 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2006 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2007 # diagonal is better, 0 if error occurs.
2008 # @ingroup l2_modif_cutquadr
2009 def BestSplit (self, IDOfQuad, theCriterion):
2010 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2012 ## Splits quadrangle faces near triangular facets of volumes
2014 # @ingroup l1_auxiliary
2015 def SplitQuadsNearTriangularFacets(self):
2016 faces_array = self.GetElementsByType(SMESH.FACE)
2017 for face_id in faces_array:
2018 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2019 quad_nodes = self.mesh.GetElemNodes(face_id)
2020 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2021 isVolumeFound = False
2022 for node1_elem in node1_elems:
2023 if not isVolumeFound:
2024 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2025 nb_nodes = self.GetElemNbNodes(node1_elem)
2026 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2027 volume_elem = node1_elem
2028 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2029 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2030 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2031 isVolumeFound = True
2032 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2033 self.SplitQuad([face_id], False) # diagonal 2-4
2034 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2035 isVolumeFound = True
2036 self.SplitQuad([face_id], True) # diagonal 1-3
2037 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2038 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2039 isVolumeFound = True
2040 self.SplitQuad([face_id], True) # diagonal 1-3
2042 ## @brief Splits hexahedrons into tetrahedrons.
2044 # This operation uses pattern mapping functionality for splitting.
2045 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2046 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2047 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2048 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2049 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2050 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2051 # @return TRUE in case of success, FALSE otherwise.
2052 # @ingroup l1_auxiliary
2053 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2054 # Pattern: 5.---------.6
2059 # (0,0,1) 4.---------.7 * |
2066 # (0,0,0) 0.---------.3
2067 pattern_tetra = "!!! Nb of points: \n 8 \n\
2077 !!! Indices of points of 6 tetras: \n\
2085 pattern = self.smeshpyD.GetPattern()
2086 isDone = pattern.LoadFromFile(pattern_tetra)
2088 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2091 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2092 isDone = pattern.MakeMesh(self.mesh, False, False)
2093 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2095 # split quafrangle faces near triangular facets of volumes
2096 self.SplitQuadsNearTriangularFacets()
2100 ## @brief Split hexahedrons into prisms.
2102 # Uses the pattern mapping functionality for splitting.
2103 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2104 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2105 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2106 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2107 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2108 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2109 # @return TRUE in case of success, FALSE otherwise.
2110 # @ingroup l1_auxiliary
2111 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2112 # Pattern: 5.---------.6
2117 # (0,0,1) 4.---------.7 |
2124 # (0,0,0) 0.---------.3
2125 pattern_prism = "!!! Nb of points: \n 8 \n\
2135 !!! Indices of points of 2 prisms: \n\
2139 pattern = self.smeshpyD.GetPattern()
2140 isDone = pattern.LoadFromFile(pattern_prism)
2142 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2145 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2146 isDone = pattern.MakeMesh(self.mesh, False, False)
2147 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2149 # Splits quafrangle faces near triangular facets of volumes
2150 self.SplitQuadsNearTriangularFacets()
2154 ## Smoothes elements
2155 # @param IDsOfElements the list if ids of elements to smooth
2156 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2157 # Note that nodes built on edges and boundary nodes are always fixed.
2158 # @param MaxNbOfIterations the maximum number of iterations
2159 # @param MaxAspectRatio varies in range [1.0, inf]
2160 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2161 # @return TRUE in case of success, FALSE otherwise.
2162 # @ingroup l2_modif_smooth
2163 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2164 MaxNbOfIterations, MaxAspectRatio, Method):
2165 if IDsOfElements == []:
2166 IDsOfElements = self.GetElementsId()
2167 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2168 MaxNbOfIterations, MaxAspectRatio, Method)
2170 ## Smoothes elements which belong to the given object
2171 # @param theObject the object to smooth
2172 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2173 # Note that nodes built on edges and boundary nodes are always fixed.
2174 # @param MaxNbOfIterations the maximum number of iterations
2175 # @param MaxAspectRatio varies in range [1.0, inf]
2176 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2177 # @return TRUE in case of success, FALSE otherwise.
2178 # @ingroup l2_modif_smooth
2179 def SmoothObject(self, theObject, IDsOfFixedNodes,
2180 MaxNbOfIterations, MaxAspectRatio, Method):
2181 if ( isinstance( theObject, Mesh )):
2182 theObject = theObject.GetMesh()
2183 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2184 MaxNbOfIterations, MaxAspectRatio, Method)
2186 ## Parametrically smoothes the given elements
2187 # @param IDsOfElements the list if ids of elements to smooth
2188 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2189 # Note that nodes built on edges and boundary nodes are always fixed.
2190 # @param MaxNbOfIterations the maximum number of iterations
2191 # @param MaxAspectRatio varies in range [1.0, inf]
2192 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2193 # @return TRUE in case of success, FALSE otherwise.
2194 # @ingroup l2_modif_smooth
2195 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2196 MaxNbOfIterations, MaxAspectRatio, Method):
2197 if IDsOfElements == []:
2198 IDsOfElements = self.GetElementsId()
2199 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2200 MaxNbOfIterations, MaxAspectRatio, Method)
2202 ## Parametrically smoothes the elements which belong to the given object
2203 # @param theObject the object to smooth
2204 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2205 # Note that nodes built on edges and boundary nodes are always fixed.
2206 # @param MaxNbOfIterations the maximum number of iterations
2207 # @param MaxAspectRatio varies in range [1.0, inf]
2208 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2209 # @return TRUE in case of success, FALSE otherwise.
2210 # @ingroup l2_modif_smooth
2211 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2212 MaxNbOfIterations, MaxAspectRatio, Method):
2213 if ( isinstance( theObject, Mesh )):
2214 theObject = theObject.GetMesh()
2215 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2216 MaxNbOfIterations, MaxAspectRatio, Method)
2218 ## Converts the mesh to quadratic, deletes old elements, replacing
2219 # them with quadratic with the same id.
2220 # @ingroup l2_modif_tofromqu
2221 def ConvertToQuadratic(self, theForce3d):
2222 self.editor.ConvertToQuadratic(theForce3d)
2224 ## Converts the mesh from quadratic to ordinary,
2225 # deletes old quadratic elements, \n replacing
2226 # them with ordinary mesh elements with the same id.
2227 # @return TRUE in case of success, FALSE otherwise.
2228 # @ingroup l2_modif_tofromqu
2229 def ConvertFromQuadratic(self):
2230 return self.editor.ConvertFromQuadratic()
2232 ## Renumber mesh nodes
2233 # @ingroup l2_modif_renumber
2234 def RenumberNodes(self):
2235 self.editor.RenumberNodes()
2237 ## Renumber mesh elements
2238 # @ingroup l2_modif_renumber
2239 def RenumberElements(self):
2240 self.editor.RenumberElements()
2242 ## Generates new elements by rotation of the elements around the axis
2243 # @param IDsOfElements the list of ids of elements to sweep
2244 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2245 # @param AngleInRadians the angle of Rotation
2246 # @param NbOfSteps the number of steps
2247 # @param Tolerance tolerance
2248 # @param MakeGroups forces the generation of new groups from existing ones
2249 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2250 # of all steps, else - size of each step
2251 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2252 # @ingroup l2_modif_extrurev
2253 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2254 MakeGroups=False, TotalAngle=False):
2255 if IDsOfElements == []:
2256 IDsOfElements = self.GetElementsId()
2257 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2258 Axis = self.smeshpyD.GetAxisStruct(Axis)
2259 if TotalAngle and NbOfSteps:
2260 AngleInRadians /= NbOfSteps
2262 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2263 AngleInRadians, NbOfSteps, Tolerance)
2264 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2267 ## Generates new elements by rotation of the elements of object around the axis
2268 # @param theObject object which elements should be sweeped
2269 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2270 # @param AngleInRadians the angle of Rotation
2271 # @param NbOfSteps number of steps
2272 # @param Tolerance tolerance
2273 # @param MakeGroups forces the generation of new groups from existing ones
2274 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2275 # of all steps, else - size of each step
2276 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2277 # @ingroup l2_modif_extrurev
2278 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2279 MakeGroups=False, TotalAngle=False):
2280 if ( isinstance( theObject, Mesh )):
2281 theObject = theObject.GetMesh()
2282 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2283 Axis = self.smeshpyD.GetAxisStruct(Axis)
2284 if TotalAngle and NbOfSteps:
2285 AngleInRadians /= NbOfSteps
2287 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2288 NbOfSteps, Tolerance)
2289 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2292 ## Generates new elements by extrusion of the elements with given ids
2293 # @param IDsOfElements the list of elements ids for extrusion
2294 # @param StepVector vector, defining the direction and value of extrusion
2295 # @param NbOfSteps the number of steps
2296 # @param MakeGroups forces the generation of new groups from existing ones
2297 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2298 # @ingroup l2_modif_extrurev
2299 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2300 if IDsOfElements == []:
2301 IDsOfElements = self.GetElementsId()
2302 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2303 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2305 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2306 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2309 ## Generates new elements by extrusion of the elements with given ids
2310 # @param IDsOfElements is ids of elements
2311 # @param StepVector vector, defining the direction and value of extrusion
2312 # @param NbOfSteps the number of steps
2313 # @param ExtrFlags sets flags for extrusion
2314 # @param SewTolerance uses for comparing locations of nodes if flag
2315 # EXTRUSION_FLAG_SEW is set
2316 # @param MakeGroups forces the generation of new groups from existing ones
2317 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2318 # @ingroup l2_modif_extrurev
2319 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2320 ExtrFlags, SewTolerance, MakeGroups=False):
2321 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2322 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2324 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2325 ExtrFlags, SewTolerance)
2326 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2327 ExtrFlags, SewTolerance)
2330 ## Generates new elements by extrusion of the elements which belong to the object
2331 # @param theObject the object which elements should be processed
2332 # @param StepVector vector, defining the direction and value of extrusion
2333 # @param NbOfSteps the number of steps
2334 # @param MakeGroups forces the generation of new groups from existing ones
2335 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2336 # @ingroup l2_modif_extrurev
2337 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2338 if ( isinstance( theObject, Mesh )):
2339 theObject = theObject.GetMesh()
2340 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2341 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2343 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2344 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2347 ## Generates new elements by extrusion of the elements which belong to the object
2348 # @param theObject object which elements should be processed
2349 # @param StepVector vector, defining the direction and value of extrusion
2350 # @param NbOfSteps the number of steps
2351 # @param MakeGroups to generate new groups from existing ones
2352 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2353 # @ingroup l2_modif_extrurev
2354 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2355 if ( isinstance( theObject, Mesh )):
2356 theObject = theObject.GetMesh()
2357 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2358 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2360 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2361 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2364 ## Generates new elements by extrusion of the elements which belong to the object
2365 # @param theObject object which elements should be processed
2366 # @param StepVector vector, defining the direction and value of extrusion
2367 # @param NbOfSteps the number of steps
2368 # @param MakeGroups forces the generation of new groups from existing ones
2369 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2370 # @ingroup l2_modif_extrurev
2371 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2372 if ( isinstance( theObject, Mesh )):
2373 theObject = theObject.GetMesh()
2374 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2375 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2377 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2378 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2381 ## Generates new elements by extrusion of the given elements
2382 # The path of extrusion must be a meshed edge.
2383 # @param IDsOfElements ids of elements
2384 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2385 # @param PathShape shape(edge) defines the sub-mesh for the path
2386 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2387 # @param HasAngles allows the shape to be rotated around the path
2388 # to get the resulting mesh in a helical fashion
2389 # @param Angles list of angles
2390 # @param HasRefPoint allows using the reference point
2391 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2392 # The User can specify any point as the Reference Point.
2393 # @param MakeGroups forces the generation of new groups from existing ones
2394 # @param LinearVariation forces the computation of rotation angles as linear
2395 # variation of the given Angles along path steps
2396 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2397 # only SMESH::Extrusion_Error otherwise
2398 # @ingroup l2_modif_extrurev
2399 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2400 HasAngles, Angles, HasRefPoint, RefPoint,
2401 MakeGroups=False, LinearVariation=False):
2402 if IDsOfElements == []:
2403 IDsOfElements = self.GetElementsId()
2404 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2405 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2407 if ( isinstance( PathMesh, Mesh )):
2408 PathMesh = PathMesh.GetMesh()
2409 if HasAngles and Angles and LinearVariation:
2410 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2413 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2414 PathShape, NodeStart, HasAngles,
2415 Angles, HasRefPoint, RefPoint)
2416 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2417 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2419 ## Generates new elements by extrusion of the elements which belong to the object
2420 # The path of extrusion must be a meshed edge.
2421 # @param theObject the object which elements should be processed
2422 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2423 # @param PathShape shape(edge) defines the sub-mesh for the path
2424 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2425 # @param HasAngles allows the shape to be rotated around the path
2426 # to get the resulting mesh in a helical fashion
2427 # @param Angles list of angles
2428 # @param HasRefPoint allows using the reference point
2429 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2430 # The User can specify any point as the Reference Point.
2431 # @param MakeGroups forces the generation of new groups from existing ones
2432 # @param LinearVariation forces the computation of rotation angles as linear
2433 # variation of the given Angles along path steps
2434 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2435 # only SMESH::Extrusion_Error otherwise
2436 # @ingroup l2_modif_extrurev
2437 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2438 HasAngles, Angles, HasRefPoint, RefPoint,
2439 MakeGroups=False, LinearVariation=False):
2440 if ( isinstance( theObject, Mesh )):
2441 theObject = theObject.GetMesh()
2442 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2443 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2444 if ( isinstance( PathMesh, Mesh )):
2445 PathMesh = PathMesh.GetMesh()
2446 if HasAngles and Angles and LinearVariation:
2447 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2450 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2451 PathShape, NodeStart, HasAngles,
2452 Angles, HasRefPoint, RefPoint)
2453 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2454 NodeStart, HasAngles, Angles, HasRefPoint,
2457 ## Creates a symmetrical copy of mesh elements
2458 # @param IDsOfElements list of elements ids
2459 # @param Mirror is AxisStruct or geom object(point, line, plane)
2460 # @param theMirrorType is POINT, AXIS or PLANE
2461 # If the Mirror is a geom object this parameter is unnecessary
2462 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2463 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2464 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2465 # @ingroup l2_modif_trsf
2466 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2467 if IDsOfElements == []:
2468 IDsOfElements = self.GetElementsId()
2469 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2470 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2471 if Copy and MakeGroups:
2472 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2473 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2476 ## Creates a new mesh by a symmetrical copy of mesh elements
2477 # @param IDsOfElements the list of elements ids
2478 # @param Mirror is AxisStruct or geom object (point, line, plane)
2479 # @param theMirrorType is POINT, AXIS or PLANE
2480 # If the Mirror is a geom object this parameter is unnecessary
2481 # @param MakeGroups to generate new groups from existing ones
2482 # @param NewMeshName a name of the new mesh to create
2483 # @return instance of Mesh class
2484 # @ingroup l2_modif_trsf
2485 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2486 if IDsOfElements == []:
2487 IDsOfElements = self.GetElementsId()
2488 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2489 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2490 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2491 MakeGroups, NewMeshName)
2492 return Mesh(self.smeshpyD,self.geompyD,mesh)
2494 ## Creates a symmetrical copy of the object
2495 # @param theObject mesh, submesh or group
2496 # @param Mirror AxisStruct or geom object (point, line, plane)
2497 # @param theMirrorType is POINT, AXIS or PLANE
2498 # If the Mirror is a geom object this parameter is unnecessary
2499 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2500 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2501 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2502 # @ingroup l2_modif_trsf
2503 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2504 if ( isinstance( theObject, Mesh )):
2505 theObject = theObject.GetMesh()
2506 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2507 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2508 if Copy and MakeGroups:
2509 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2510 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2513 ## Creates a new mesh by a symmetrical copy of the object
2514 # @param theObject mesh, submesh or group
2515 # @param Mirror AxisStruct or geom object (point, line, plane)
2516 # @param theMirrorType POINT, AXIS or PLANE
2517 # If the Mirror is a geom object this parameter is unnecessary
2518 # @param MakeGroups forces the generation of new groups from existing ones
2519 # @param NewMeshName the name of the new mesh to create
2520 # @return instance of Mesh class
2521 # @ingroup l2_modif_trsf
2522 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2523 if ( isinstance( theObject, Mesh )):
2524 theObject = theObject.GetMesh()
2525 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2526 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2527 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2528 MakeGroups, NewMeshName)
2529 return Mesh( self.smeshpyD,self.geompyD,mesh )
2531 ## Translates the elements
2532 # @param IDsOfElements list of elements ids
2533 # @param Vector the direction of translation (DirStruct or vector)
2534 # @param Copy allows copying the translated elements
2535 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2536 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2537 # @ingroup l2_modif_trsf
2538 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2539 if IDsOfElements == []:
2540 IDsOfElements = self.GetElementsId()
2541 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2542 Vector = self.smeshpyD.GetDirStruct(Vector)
2543 if Copy and MakeGroups:
2544 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2545 self.editor.Translate(IDsOfElements, Vector, Copy)
2548 ## Creates a new mesh of translated elements
2549 # @param IDsOfElements list of elements ids
2550 # @param Vector the direction of translation (DirStruct or vector)
2551 # @param MakeGroups forces the generation of new groups from existing ones
2552 # @param NewMeshName the name of the newly created mesh
2553 # @return instance of Mesh class
2554 # @ingroup l2_modif_trsf
2555 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2556 if IDsOfElements == []:
2557 IDsOfElements = self.GetElementsId()
2558 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2559 Vector = self.smeshpyD.GetDirStruct(Vector)
2560 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2561 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2563 ## Translates the object
2564 # @param theObject the object to translate (mesh, submesh, or group)
2565 # @param Vector direction of translation (DirStruct or geom vector)
2566 # @param Copy allows copying the translated elements
2567 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2568 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2569 # @ingroup l2_modif_trsf
2570 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2571 if ( isinstance( theObject, Mesh )):
2572 theObject = theObject.GetMesh()
2573 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2574 Vector = self.smeshpyD.GetDirStruct(Vector)
2575 if Copy and MakeGroups:
2576 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2577 self.editor.TranslateObject(theObject, Vector, Copy)
2580 ## Creates a new mesh from the translated object
2581 # @param theObject the object to translate (mesh, submesh, or group)
2582 # @param Vector the direction of translation (DirStruct or geom vector)
2583 # @param MakeGroups forces the generation of new groups from existing ones
2584 # @param NewMeshName the name of the newly created mesh
2585 # @return instance of Mesh class
2586 # @ingroup l2_modif_trsf
2587 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2588 if (isinstance(theObject, Mesh)):
2589 theObject = theObject.GetMesh()
2590 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2591 Vector = self.smeshpyD.GetDirStruct(Vector)
2592 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2593 return Mesh( self.smeshpyD, self.geompyD, mesh )
2595 ## Rotates the elements
2596 # @param IDsOfElements list of elements ids
2597 # @param Axis the axis of rotation (AxisStruct or geom line)
2598 # @param AngleInRadians the angle of rotation (in radians)
2599 # @param Copy allows copying the rotated elements
2600 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2601 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2602 # @ingroup l2_modif_trsf
2603 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2604 if IDsOfElements == []:
2605 IDsOfElements = self.GetElementsId()
2606 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2607 Axis = self.smeshpyD.GetAxisStruct(Axis)
2608 if Copy and MakeGroups:
2609 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2610 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2613 ## Creates a new mesh of rotated elements
2614 # @param IDsOfElements list of element ids
2615 # @param Axis the axis of rotation (AxisStruct or geom line)
2616 # @param AngleInRadians the angle of rotation (in radians)
2617 # @param MakeGroups forces the generation of new groups from existing ones
2618 # @param NewMeshName the name of the newly created mesh
2619 # @return instance of Mesh class
2620 # @ingroup l2_modif_trsf
2621 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2622 if IDsOfElements == []:
2623 IDsOfElements = self.GetElementsId()
2624 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2625 Axis = self.smeshpyD.GetAxisStruct(Axis)
2626 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2627 MakeGroups, NewMeshName)
2628 return Mesh( self.smeshpyD, self.geompyD, mesh )
2630 ## Rotates the object
2631 # @param theObject the object to rotate( mesh, submesh, or group)
2632 # @param Axis the axis of rotation (AxisStruct or geom line)
2633 # @param AngleInRadians the angle of rotation (in radians)
2634 # @param Copy allows copying the rotated elements
2635 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2636 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2637 # @ingroup l2_modif_trsf
2638 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2639 if (isinstance(theObject, Mesh)):
2640 theObject = theObject.GetMesh()
2641 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2642 Axis = self.smeshpyD.GetAxisStruct(Axis)
2643 if Copy and MakeGroups:
2644 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2645 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2648 ## Creates a new mesh from the rotated object
2649 # @param theObject the object to rotate (mesh, submesh, or group)
2650 # @param Axis the axis of rotation (AxisStruct or geom line)
2651 # @param AngleInRadians the angle of rotation (in radians)
2652 # @param MakeGroups forces the generation of new groups from existing ones
2653 # @param NewMeshName the name of the newly created mesh
2654 # @return instance of Mesh class
2655 # @ingroup l2_modif_trsf
2656 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2657 if (isinstance( theObject, Mesh )):
2658 theObject = theObject.GetMesh()
2659 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2660 Axis = self.smeshpyD.GetAxisStruct(Axis)
2661 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2662 MakeGroups, NewMeshName)
2663 return Mesh( self.smeshpyD, self.geompyD, mesh )
2665 ## Finds groups of ajacent nodes within Tolerance.
2666 # @param Tolerance the value of tolerance
2667 # @return the list of groups of nodes
2668 # @ingroup l2_modif_trsf
2669 def FindCoincidentNodes (self, Tolerance):
2670 return self.editor.FindCoincidentNodes(Tolerance)
2672 ## Finds groups of ajacent nodes within Tolerance.
2673 # @param Tolerance the value of tolerance
2674 # @param SubMeshOrGroup SubMesh or Group
2675 # @return the list of groups of nodes
2676 # @ingroup l2_modif_trsf
2677 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2678 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2681 # @param GroupsOfNodes the list of groups of nodes
2682 # @ingroup l2_modif_trsf
2683 def MergeNodes (self, GroupsOfNodes):
2684 self.editor.MergeNodes(GroupsOfNodes)
2686 ## Finds the elements built on the same nodes.
2687 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2688 # @return a list of groups of equal elements
2689 # @ingroup l2_modif_trsf
2690 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2691 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2693 ## Merges elements in each given group.
2694 # @param GroupsOfElementsID groups of elements for merging
2695 # @ingroup l2_modif_trsf
2696 def MergeElements(self, GroupsOfElementsID):
2697 self.editor.MergeElements(GroupsOfElementsID)
2699 ## Leaves one element and removes all other elements built on the same nodes.
2700 # @ingroup l2_modif_trsf
2701 def MergeEqualElements(self):
2702 self.editor.MergeEqualElements()
2704 ## Sews free borders
2705 # @return SMESH::Sew_Error
2706 # @ingroup l2_modif_trsf
2707 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2708 FirstNodeID2, SecondNodeID2, LastNodeID2,
2709 CreatePolygons, CreatePolyedrs):
2710 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2711 FirstNodeID2, SecondNodeID2, LastNodeID2,
2712 CreatePolygons, CreatePolyedrs)
2714 ## Sews conform free borders
2715 # @return SMESH::Sew_Error
2716 # @ingroup l2_modif_trsf
2717 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2718 FirstNodeID2, SecondNodeID2):
2719 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2720 FirstNodeID2, SecondNodeID2)
2722 ## Sews border to side
2723 # @return SMESH::Sew_Error
2724 # @ingroup l2_modif_trsf
2725 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2726 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2727 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2728 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2730 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2731 # merged with the nodes of elements of Side2.
2732 # The number of elements in theSide1 and in theSide2 must be
2733 # equal and they should have similar nodal connectivity.
2734 # The nodes to merge should belong to side borders and
2735 # the first node should be linked to the second.
2736 # @return SMESH::Sew_Error
2737 # @ingroup l2_modif_trsf
2738 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2739 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2740 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2741 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2742 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2743 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2745 ## Sets new nodes for the given element.
2746 # @param ide the element id
2747 # @param newIDs nodes ids
2748 # @return If the number of nodes does not correspond to the type of element - returns false
2749 # @ingroup l2_modif_edit
2750 def ChangeElemNodes(self, ide, newIDs):
2751 return self.editor.ChangeElemNodes(ide, newIDs)
2753 ## If during the last operation of MeshEditor some nodes were
2754 # created, this method returns the list of their IDs, \n
2755 # if new nodes were not created - returns empty list
2756 # @return the list of integer values (can be empty)
2757 # @ingroup l1_auxiliary
2758 def GetLastCreatedNodes(self):
2759 return self.editor.GetLastCreatedNodes()
2761 ## If during the last operation of MeshEditor some elements were
2762 # created this method returns the list of their IDs, \n
2763 # if new elements were not created - returns empty list
2764 # @return the list of integer values (can be empty)
2765 # @ingroup l1_auxiliary
2766 def GetLastCreatedElems(self):
2767 return self.editor.GetLastCreatedElems()
2769 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2770 # @param theNodes identifiers of nodes to be doubled
2771 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
2772 # nodes. If list of element identifiers is empty then nodes are doubled but
2773 # they not assigned to elements
2774 # @return TRUE if operation has been completed successfully, FALSE otherwise
2775 # @ingroup l2_modif_edit
2776 def DoubleNodes(self, theNodes, theModifiedElems):
2777 return self.editor.DoubleNodes(theNodes, theModifiedElems)
2779 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2780 # This method provided for convenience works as DoubleNodes() described above.
2781 # @param theNodes identifiers of node to be doubled
2782 # @param theModifiedElems identifiers of elements to be updated
2783 # @return TRUE if operation has been completed successfully, FALSE otherwise
2784 # @ingroup l2_modif_edit
2785 def DoubleNode(self, theNodeId, theModifiedElems):
2786 return self.editor.DoubleNode(theNodeId, theModifiedElems)
2788 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2789 # This method provided for convenience works as DoubleNodes() described above.
2790 # @param theNodes group of nodes to be doubled
2791 # @param theModifiedElems group of elements to be updated.
2792 # @return TRUE if operation has been completed successfully, FALSE otherwise
2793 # @ingroup l2_modif_edit
2794 def DoubleNodeGroup(self, theNodes, theModifiedElems):
2795 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
2797 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2798 # This method provided for convenience works as DoubleNodes() described above.
2799 # @param theNodes list of groups of nodes to be doubled
2800 # @param theModifiedElems list of groups of elements to be updated.
2801 # @return TRUE if operation has been completed successfully, FALSE otherwise
2802 # @ingroup l2_modif_edit
2803 def DoubleNodeGroups(self, theNodes, theModifiedElems):
2804 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
2806 ## The mother class to define algorithm, it is not recommended to use it directly.
2809 # @ingroup l2_algorithms
2810 class Mesh_Algorithm:
2811 # @class Mesh_Algorithm
2812 # @brief Class Mesh_Algorithm
2814 #def __init__(self,smesh):
2822 ## Finds a hypothesis in the study by its type name and parameters.
2823 # Finds only the hypotheses created in smeshpyD engine.
2824 # @return SMESH.SMESH_Hypothesis
2825 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2826 study = smeshpyD.GetCurrentStudy()
2827 #to do: find component by smeshpyD object, not by its data type
2828 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2829 if scomp is not None:
2830 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2831 # Check if the root label of the hypotheses exists
2832 if res and hypRoot is not None:
2833 iter = study.NewChildIterator(hypRoot)
2834 # Check all published hypotheses
2836 hypo_so_i = iter.Value()
2837 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2838 if attr is not None:
2839 anIOR = attr.Value()
2840 hypo_o_i = salome.orb.string_to_object(anIOR)
2841 if hypo_o_i is not None:
2842 # Check if this is a hypothesis
2843 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2844 if hypo_i is not None:
2845 # Check if the hypothesis belongs to current engine
2846 if smeshpyD.GetObjectId(hypo_i) > 0:
2847 # Check if this is the required hypothesis
2848 if hypo_i.GetName() == hypname:
2850 if CompareMethod(hypo_i, args):
2864 ## Finds the algorithm in the study by its type name.
2865 # Finds only the algorithms, which have been created in smeshpyD engine.
2866 # @return SMESH.SMESH_Algo
2867 def FindAlgorithm (self, algoname, smeshpyD):
2868 study = smeshpyD.GetCurrentStudy()
2869 #to do: find component by smeshpyD object, not by its data type
2870 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2871 if scomp is not None:
2872 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2873 # Check if the root label of the algorithms exists
2874 if res and hypRoot is not None:
2875 iter = study.NewChildIterator(hypRoot)
2876 # Check all published algorithms
2878 algo_so_i = iter.Value()
2879 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2880 if attr is not None:
2881 anIOR = attr.Value()
2882 algo_o_i = salome.orb.string_to_object(anIOR)
2883 if algo_o_i is not None:
2884 # Check if this is an algorithm
2885 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2886 if algo_i is not None:
2887 # Checks if the algorithm belongs to the current engine
2888 if smeshpyD.GetObjectId(algo_i) > 0:
2889 # Check if this is the required algorithm
2890 if algo_i.GetName() == algoname:
2903 ## If the algorithm is global, returns 0; \n
2904 # else returns the submesh associated to this algorithm.
2905 def GetSubMesh(self):
2908 ## Returns the wrapped mesher.
2909 def GetAlgorithm(self):
2912 ## Gets the list of hypothesis that can be used with this algorithm
2913 def GetCompatibleHypothesis(self):
2916 mylist = self.algo.GetCompatibleHypothesis()
2919 ## Gets the name of the algorithm
2923 ## Sets the name to the algorithm
2924 def SetName(self, name):
2925 self.mesh.smeshpyD.SetName(self.algo, name)
2927 ## Gets the id of the algorithm
2929 return self.algo.GetId()
2932 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2934 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2935 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2937 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2939 self.Assign(algo, mesh, geom)
2943 def Assign(self, algo, mesh, geom):
2945 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2952 name = GetName(geom)
2954 name = mesh.geompyD.SubShapeName(geom, piece)
2955 mesh.geompyD.addToStudyInFather(piece, geom, name)
2956 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2959 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2960 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2962 def CompareHyp (self, hyp, args):
2963 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2966 def CompareEqualHyp (self, hyp, args):
2970 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2971 UseExisting=0, CompareMethod=""):
2974 if CompareMethod == "": CompareMethod = self.CompareHyp
2975 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2978 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2984 a = a + s + str(args[i])
2988 self.mesh.smeshpyD.SetName(hypo, hyp + a)
2990 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2991 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2995 # Public class: Mesh_Segment
2996 # --------------------------
2998 ## Class to define a segment 1D algorithm for discretization
3001 # @ingroup l3_algos_basic
3002 class Mesh_Segment(Mesh_Algorithm):
3004 ## Private constructor.
3005 def __init__(self, mesh, geom=0):
3006 Mesh_Algorithm.__init__(self)
3007 self.Create(mesh, geom, "Regular_1D")
3009 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3010 # @param l for the length of segments that cut an edge
3011 # @param UseExisting if ==true - searches for an existing hypothesis created with
3012 # the same parameters, else (default) - creates a new one
3013 # @param p precision, used for calculation of the number of segments.
3014 # The precision should be a positive, meaningful value within the range [0,1].
3015 # In general, the number of segments is calculated with the formula:
3016 # nb = ceil((edge_length / l) - p)
3017 # Function ceil rounds its argument to the higher integer.
3018 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3019 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3020 # p=1 means rounding of (edge_length / l) to the lower integer.
3021 # Default value is 1e-07.
3022 # @return an instance of StdMeshers_LocalLength hypothesis
3023 # @ingroup l3_hypos_1dhyps
3024 def LocalLength(self, l, UseExisting=0, p=1e-07):
3025 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3026 CompareMethod=self.CompareLocalLength)
3032 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3033 def CompareLocalLength(self, hyp, args):
3034 if IsEqual(hyp.GetLength(), args[0]):
3035 return IsEqual(hyp.GetPrecision(), args[1])
3038 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3039 # @param n for the number of segments that cut an edge
3040 # @param s for the scale factor (optional)
3041 # @param UseExisting if ==true - searches for an existing hypothesis created with
3042 # the same parameters, else (default) - create a new one
3043 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3044 # @ingroup l3_hypos_1dhyps
3045 def NumberOfSegments(self, n, s=[], UseExisting=0):
3047 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3048 CompareMethod=self.CompareNumberOfSegments)
3050 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3051 CompareMethod=self.CompareNumberOfSegments)
3052 hyp.SetDistrType( 1 )
3053 hyp.SetScaleFactor(s)
3054 hyp.SetNumberOfSegments(n)
3058 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3059 def CompareNumberOfSegments(self, hyp, args):
3060 if hyp.GetNumberOfSegments() == args[0]:
3064 if hyp.GetDistrType() == 1:
3065 if IsEqual(hyp.GetScaleFactor(), args[1]):
3069 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3070 # @param start defines the length of the first segment
3071 # @param end defines the length of the last segment
3072 # @param UseExisting if ==true - searches for an existing hypothesis created with
3073 # the same parameters, else (default) - creates a new one
3074 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3075 # @ingroup l3_hypos_1dhyps
3076 def Arithmetic1D(self, start, end, UseExisting=0):
3077 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3078 CompareMethod=self.CompareArithmetic1D)
3079 hyp.SetLength(start, 1)
3080 hyp.SetLength(end , 0)
3084 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3085 def CompareArithmetic1D(self, hyp, args):
3086 if IsEqual(hyp.GetLength(1), args[0]):
3087 if IsEqual(hyp.GetLength(0), args[1]):
3091 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3092 # @param start defines the length of the first segment
3093 # @param end defines the length of the last segment
3094 # @param UseExisting if ==true - searches for an existing hypothesis created with
3095 # the same parameters, else (default) - creates a new one
3096 # @return an instance of StdMeshers_StartEndLength hypothesis
3097 # @ingroup l3_hypos_1dhyps
3098 def StartEndLength(self, start, end, UseExisting=0):
3099 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3100 CompareMethod=self.CompareStartEndLength)
3101 hyp.SetLength(start, 1)
3102 hyp.SetLength(end , 0)
3105 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3106 def CompareStartEndLength(self, hyp, args):
3107 if IsEqual(hyp.GetLength(1), args[0]):
3108 if IsEqual(hyp.GetLength(0), args[1]):
3112 ## Defines "Deflection1D" hypothesis
3113 # @param d for the deflection
3114 # @param UseExisting if ==true - searches for an existing hypothesis created with
3115 # the same parameters, else (default) - create a new one
3116 # @ingroup l3_hypos_1dhyps
3117 def Deflection1D(self, d, UseExisting=0):
3118 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3119 CompareMethod=self.CompareDeflection1D)
3120 hyp.SetDeflection(d)
3123 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3124 def CompareDeflection1D(self, hyp, args):
3125 return IsEqual(hyp.GetDeflection(), args[0])
3127 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3128 # the opposite side in case of quadrangular faces
3129 # @ingroup l3_hypos_additi
3130 def Propagation(self):
3131 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3133 ## Defines "AutomaticLength" hypothesis
3134 # @param fineness for the fineness [0-1]
3135 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3136 # same parameters, else (default) - create a new one
3137 # @ingroup l3_hypos_1dhyps
3138 def AutomaticLength(self, fineness=0, UseExisting=0):
3139 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3140 CompareMethod=self.CompareAutomaticLength)
3141 hyp.SetFineness( fineness )
3144 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3145 def CompareAutomaticLength(self, hyp, args):
3146 return IsEqual(hyp.GetFineness(), args[0])
3148 ## Defines "SegmentLengthAroundVertex" hypothesis
3149 # @param length for the segment length
3150 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3151 # Any other integer value means that the hypothesis will be set on the
3152 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3153 # @param UseExisting if ==true - searches for an existing hypothesis created with
3154 # the same parameters, else (default) - creates a new one
3155 # @ingroup l3_algos_segmarv
3156 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3158 store_geom = self.geom
3159 if type(vertex) is types.IntType:
3160 if vertex == 0 or vertex == 1:
3161 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3169 if self.geom is None:
3170 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3171 name = GetName(self.geom)
3173 piece = self.mesh.geom
3174 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3175 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3176 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3178 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3180 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3181 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3183 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3184 CompareMethod=self.CompareLengthNearVertex)
3185 self.geom = store_geom
3186 hyp.SetLength( length )
3189 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3190 # @ingroup l3_algos_segmarv
3191 def CompareLengthNearVertex(self, hyp, args):
3192 return IsEqual(hyp.GetLength(), args[0])
3194 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3195 # If the 2D mesher sees that all boundary edges are quadratic,
3196 # it generates quadratic faces, else it generates linear faces using
3197 # medium nodes as if they are vertices.
3198 # The 3D mesher generates quadratic volumes only if all boundary faces
3199 # are quadratic, else it fails.
3201 # @ingroup l3_hypos_additi
3202 def QuadraticMesh(self):
3203 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3206 # Public class: Mesh_CompositeSegment
3207 # --------------------------
3209 ## Defines a segment 1D algorithm for discretization
3211 # @ingroup l3_algos_basic
3212 class Mesh_CompositeSegment(Mesh_Segment):
3214 ## Private constructor.
3215 def __init__(self, mesh, geom=0):
3216 self.Create(mesh, geom, "CompositeSegment_1D")
3219 # Public class: Mesh_Segment_Python
3220 # ---------------------------------
3222 ## Defines a segment 1D algorithm for discretization with python function
3224 # @ingroup l3_algos_basic
3225 class Mesh_Segment_Python(Mesh_Segment):
3227 ## Private constructor.
3228 def __init__(self, mesh, geom=0):
3229 import Python1dPlugin
3230 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3232 ## Defines "PythonSplit1D" hypothesis
3233 # @param n for the number of segments that cut an edge
3234 # @param func for the python function that calculates the length of all segments
3235 # @param UseExisting if ==true - searches for the existing hypothesis created with
3236 # the same parameters, else (default) - creates a new one
3237 # @ingroup l3_hypos_1dhyps
3238 def PythonSplit1D(self, n, func, UseExisting=0):
3239 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3240 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3241 hyp.SetNumberOfSegments(n)
3242 hyp.SetPythonLog10RatioFunction(func)
3245 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3246 def ComparePythonSplit1D(self, hyp, args):
3247 #if hyp.GetNumberOfSegments() == args[0]:
3248 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3252 # Public class: Mesh_Triangle
3253 # ---------------------------
3255 ## Defines a triangle 2D algorithm
3257 # @ingroup l3_algos_basic
3258 class Mesh_Triangle(Mesh_Algorithm):
3267 ## Private constructor.
3268 def __init__(self, mesh, algoType, geom=0):
3269 Mesh_Algorithm.__init__(self)
3271 self.algoType = algoType
3272 if algoType == MEFISTO:
3273 self.Create(mesh, geom, "MEFISTO_2D")
3275 elif algoType == BLSURF:
3277 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3278 #self.SetPhysicalMesh() - PAL19680
3279 elif algoType == NETGEN:
3281 print "Warning: NETGENPlugin module unavailable"
3283 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3285 elif algoType == NETGEN_2D:
3287 print "Warning: NETGENPlugin module unavailable"
3289 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3292 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3293 # @param area for the maximum area of each triangle
3294 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3295 # same parameters, else (default) - creates a new one
3297 # Only for algoType == MEFISTO || NETGEN_2D
3298 # @ingroup l3_hypos_2dhyps
3299 def MaxElementArea(self, area, UseExisting=0):
3300 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3301 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3302 CompareMethod=self.CompareMaxElementArea)
3303 elif self.algoType == NETGEN:
3304 hyp = self.Parameters(SIMPLE)
3305 hyp.SetMaxElementArea(area)
3308 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3309 def CompareMaxElementArea(self, hyp, args):
3310 return IsEqual(hyp.GetMaxElementArea(), args[0])
3312 ## Defines "LengthFromEdges" hypothesis to build triangles
3313 # based on the length of the edges taken from the wire
3315 # Only for algoType == MEFISTO || NETGEN_2D
3316 # @ingroup l3_hypos_2dhyps
3317 def LengthFromEdges(self):
3318 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3319 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3321 elif self.algoType == NETGEN:
3322 hyp = self.Parameters(SIMPLE)
3323 hyp.LengthFromEdges()
3326 ## Sets a way to define size of mesh elements to generate.
3327 # @param thePhysicalMesh is: DefaultSize or Custom.
3328 # @ingroup l3_hypos_blsurf
3329 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3330 # Parameter of BLSURF algo
3331 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3333 ## Sets size of mesh elements to generate.
3334 # @ingroup l3_hypos_blsurf
3335 def SetPhySize(self, theVal):
3336 # Parameter of BLSURF algo
3337 self.Parameters().SetPhySize(theVal)
3339 ## Sets lower boundary of mesh element size (PhySize).
3340 # @ingroup l3_hypos_blsurf
3341 def SetPhyMin(self, theVal=-1):
3342 # Parameter of BLSURF algo
3343 self.Parameters().SetPhyMin(theVal)
3345 ## Sets upper boundary of mesh element size (PhySize).
3346 # @ingroup l3_hypos_blsurf
3347 def SetPhyMax(self, theVal=-1):
3348 # Parameter of BLSURF algo
3349 self.Parameters().SetPhyMax(theVal)
3351 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3352 # @param theGeometricMesh is: DefaultGeom or Custom
3353 # @ingroup l3_hypos_blsurf
3354 def SetGeometricMesh(self, theGeometricMesh=0):
3355 # Parameter of BLSURF algo
3356 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3357 self.params.SetGeometricMesh(theGeometricMesh)
3359 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3360 # @ingroup l3_hypos_blsurf
3361 def SetAngleMeshS(self, theVal=_angleMeshS):
3362 # Parameter of BLSURF algo
3363 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3364 self.params.SetAngleMeshS(theVal)
3366 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3367 # @ingroup l3_hypos_blsurf
3368 def SetAngleMeshC(self, theVal=_angleMeshS):
3369 # Parameter of BLSURF algo
3370 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3371 self.params.SetAngleMeshC(theVal)
3373 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3374 # @ingroup l3_hypos_blsurf
3375 def SetGeoMin(self, theVal=-1):
3376 # Parameter of BLSURF algo
3377 self.Parameters().SetGeoMin(theVal)
3379 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3380 # @ingroup l3_hypos_blsurf
3381 def SetGeoMax(self, theVal=-1):
3382 # Parameter of BLSURF algo
3383 self.Parameters().SetGeoMax(theVal)
3385 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3386 # @ingroup l3_hypos_blsurf
3387 def SetGradation(self, theVal=_gradation):
3388 # Parameter of BLSURF algo
3389 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3390 self.params.SetGradation(theVal)
3392 ## Sets topology usage way.
3393 # @param way defines how mesh conformity is assured <ul>
3394 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3395 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3396 # @ingroup l3_hypos_blsurf
3397 def SetTopology(self, way):
3398 # Parameter of BLSURF algo
3399 self.Parameters().SetTopology(way)
3401 ## To respect geometrical edges or not.
3402 # @ingroup l3_hypos_blsurf
3403 def SetDecimesh(self, toIgnoreEdges=False):
3404 # Parameter of BLSURF algo
3405 self.Parameters().SetDecimesh(toIgnoreEdges)
3407 ## Sets verbosity level in the range 0 to 100.
3408 # @ingroup l3_hypos_blsurf
3409 def SetVerbosity(self, level):
3410 # Parameter of BLSURF algo
3411 self.Parameters().SetVerbosity(level)
3413 ## Sets advanced option value.
3414 # @ingroup l3_hypos_blsurf
3415 def SetOptionValue(self, optionName, level):
3416 # Parameter of BLSURF algo
3417 self.Parameters().SetOptionValue(optionName,level)
3419 ## Sets QuadAllowed flag.
3420 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3421 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3422 def SetQuadAllowed(self, toAllow=True):
3423 if self.algoType == NETGEN_2D:
3424 if toAllow: # add QuadranglePreference
3425 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3426 else: # remove QuadranglePreference
3427 for hyp in self.mesh.GetHypothesisList( self.geom ):
3428 if hyp.GetName() == "QuadranglePreference":
3429 self.mesh.RemoveHypothesis( self.geom, hyp )
3434 if self.Parameters():
3435 self.params.SetQuadAllowed(toAllow)
3438 ## Defines hypothesis having several parameters
3440 # @ingroup l3_hypos_netgen
3441 def Parameters(self, which=SOLE):
3444 if self.algoType == NETGEN:
3446 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3447 "libNETGENEngine.so", UseExisting=0)
3449 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3450 "libNETGENEngine.so", UseExisting=0)
3452 elif self.algoType == MEFISTO:
3453 print "Mefisto algo support no multi-parameter hypothesis"
3455 elif self.algoType == NETGEN_2D:
3456 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3457 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3459 elif self.algoType == BLSURF:
3460 self.params = self.Hypothesis("BLSURF_Parameters", [],
3461 "libBLSURFEngine.so", UseExisting=0)
3464 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3469 # Only for algoType == NETGEN
3470 # @ingroup l3_hypos_netgen
3471 def SetMaxSize(self, theSize):
3472 if self.Parameters():
3473 self.params.SetMaxSize(theSize)
3475 ## Sets SecondOrder flag
3477 # Only for algoType == NETGEN
3478 # @ingroup l3_hypos_netgen
3479 def SetSecondOrder(self, theVal):
3480 if self.Parameters():
3481 self.params.SetSecondOrder(theVal)
3483 ## Sets Optimize flag
3485 # Only for algoType == NETGEN
3486 # @ingroup l3_hypos_netgen
3487 def SetOptimize(self, theVal):
3488 if self.Parameters():
3489 self.params.SetOptimize(theVal)
3492 # @param theFineness is:
3493 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3495 # Only for algoType == NETGEN
3496 # @ingroup l3_hypos_netgen
3497 def SetFineness(self, theFineness):
3498 if self.Parameters():
3499 self.params.SetFineness(theFineness)
3503 # Only for algoType == NETGEN
3504 # @ingroup l3_hypos_netgen
3505 def SetGrowthRate(self, theRate):
3506 if self.Parameters():
3507 self.params.SetGrowthRate(theRate)
3509 ## Sets NbSegPerEdge
3511 # Only for algoType == NETGEN
3512 # @ingroup l3_hypos_netgen
3513 def SetNbSegPerEdge(self, theVal):
3514 if self.Parameters():
3515 self.params.SetNbSegPerEdge(theVal)
3517 ## Sets NbSegPerRadius
3519 # Only for algoType == NETGEN
3520 # @ingroup l3_hypos_netgen
3521 def SetNbSegPerRadius(self, theVal):
3522 if self.Parameters():
3523 self.params.SetNbSegPerRadius(theVal)
3525 ## Sets number of segments overriding value set by SetLocalLength()
3527 # Only for algoType == NETGEN
3528 # @ingroup l3_hypos_netgen
3529 def SetNumberOfSegments(self, theVal):
3530 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3532 ## Sets number of segments overriding value set by SetNumberOfSegments()
3534 # Only for algoType == NETGEN
3535 # @ingroup l3_hypos_netgen
3536 def SetLocalLength(self, theVal):
3537 self.Parameters(SIMPLE).SetLocalLength(theVal)
3542 # Public class: Mesh_Quadrangle
3543 # -----------------------------
3545 ## Defines a quadrangle 2D algorithm
3547 # @ingroup l3_algos_basic
3548 class Mesh_Quadrangle(Mesh_Algorithm):
3550 ## Private constructor.
3551 def __init__(self, mesh, geom=0):
3552 Mesh_Algorithm.__init__(self)
3553 self.Create(mesh, geom, "Quadrangle_2D")
3555 ## Defines "QuadranglePreference" hypothesis, forcing construction
3556 # of quadrangles if the number of nodes on the opposite edges is not the same
3557 # while the total number of nodes on edges is even
3559 # @ingroup l3_hypos_additi
3560 def QuadranglePreference(self):
3561 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3562 CompareMethod=self.CompareEqualHyp)
3565 ## Defines "TrianglePreference" hypothesis, forcing construction
3566 # of triangles in the refinement area if the number of nodes
3567 # on the opposite edges is not the same
3569 # @ingroup l3_hypos_additi
3570 def TrianglePreference(self):
3571 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3572 CompareMethod=self.CompareEqualHyp)
3575 # Public class: Mesh_Tetrahedron
3576 # ------------------------------
3578 ## Defines a tetrahedron 3D algorithm
3580 # @ingroup l3_algos_basic
3581 class Mesh_Tetrahedron(Mesh_Algorithm):
3586 ## Private constructor.
3587 def __init__(self, mesh, algoType, geom=0):
3588 Mesh_Algorithm.__init__(self)
3590 if algoType == NETGEN:
3591 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3594 elif algoType == FULL_NETGEN:
3596 print "Warning: NETGENPlugin module has not been imported."
3597 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3600 elif algoType == GHS3D:
3602 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3605 self.algoType = algoType
3607 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3608 # @param vol for the maximum volume of each tetrahedron
3609 # @param UseExisting if ==true - searches for the existing hypothesis created with
3610 # the same parameters, else (default) - creates a new one
3611 # @ingroup l3_hypos_maxvol
3612 def MaxElementVolume(self, vol, UseExisting=0):
3613 if self.algoType == NETGEN:
3614 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3615 CompareMethod=self.CompareMaxElementVolume)
3616 hyp.SetMaxElementVolume(vol)
3618 elif self.algoType == FULL_NETGEN:
3619 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3622 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3623 def CompareMaxElementVolume(self, hyp, args):
3624 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3626 ## Defines hypothesis having several parameters
3628 # @ingroup l3_hypos_netgen
3629 def Parameters(self, which=SOLE):
3632 if self.algoType == FULL_NETGEN:
3634 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3635 "libNETGENEngine.so", UseExisting=0)
3637 self.params = self.Hypothesis("NETGEN_Parameters", [],
3638 "libNETGENEngine.so", UseExisting=0)
3640 if self.algoType == GHS3D:
3641 self.params = self.Hypothesis("GHS3D_Parameters", [],
3642 "libGHS3DEngine.so", UseExisting=0)
3645 print "Algo supports no multi-parameter hypothesis"
3649 # Parameter of FULL_NETGEN
3650 # @ingroup l3_hypos_netgen
3651 def SetMaxSize(self, theSize):
3652 self.Parameters().SetMaxSize(theSize)
3654 ## Sets SecondOrder flag
3655 # Parameter of FULL_NETGEN
3656 # @ingroup l3_hypos_netgen
3657 def SetSecondOrder(self, theVal):
3658 self.Parameters().SetSecondOrder(theVal)
3660 ## Sets Optimize flag
3661 # Parameter of FULL_NETGEN
3662 # @ingroup l3_hypos_netgen
3663 def SetOptimize(self, theVal):
3664 self.Parameters().SetOptimize(theVal)
3667 # @param theFineness is:
3668 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3669 # Parameter of FULL_NETGEN
3670 # @ingroup l3_hypos_netgen
3671 def SetFineness(self, theFineness):
3672 self.Parameters().SetFineness(theFineness)
3675 # Parameter of FULL_NETGEN
3676 # @ingroup l3_hypos_netgen
3677 def SetGrowthRate(self, theRate):
3678 self.Parameters().SetGrowthRate(theRate)
3680 ## Sets NbSegPerEdge
3681 # Parameter of FULL_NETGEN
3682 # @ingroup l3_hypos_netgen
3683 def SetNbSegPerEdge(self, theVal):
3684 self.Parameters().SetNbSegPerEdge(theVal)
3686 ## Sets NbSegPerRadius
3687 # Parameter of FULL_NETGEN
3688 # @ingroup l3_hypos_netgen
3689 def SetNbSegPerRadius(self, theVal):
3690 self.Parameters().SetNbSegPerRadius(theVal)
3692 ## Sets number of segments overriding value set by SetLocalLength()
3693 # Only for algoType == NETGEN_FULL
3694 # @ingroup l3_hypos_netgen
3695 def SetNumberOfSegments(self, theVal):
3696 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3698 ## Sets number of segments overriding value set by SetNumberOfSegments()
3699 # Only for algoType == NETGEN_FULL
3700 # @ingroup l3_hypos_netgen
3701 def SetLocalLength(self, theVal):
3702 self.Parameters(SIMPLE).SetLocalLength(theVal)
3704 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3705 # Overrides value set by LengthFromEdges()
3706 # Only for algoType == NETGEN_FULL
3707 # @ingroup l3_hypos_netgen
3708 def MaxElementArea(self, area):
3709 self.Parameters(SIMPLE).SetMaxElementArea(area)
3711 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3712 # Overrides value set by MaxElementArea()
3713 # Only for algoType == NETGEN_FULL
3714 # @ingroup l3_hypos_netgen
3715 def LengthFromEdges(self):
3716 self.Parameters(SIMPLE).LengthFromEdges()
3718 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3719 # Overrides value set by MaxElementVolume()
3720 # Only for algoType == NETGEN_FULL
3721 # @ingroup l3_hypos_netgen
3722 def LengthFromFaces(self):
3723 self.Parameters(SIMPLE).LengthFromFaces()
3725 ## To mesh "holes" in a solid or not. Default is to mesh.
3726 # @ingroup l3_hypos_ghs3dh
3727 def SetToMeshHoles(self, toMesh):
3728 # Parameter of GHS3D
3729 self.Parameters().SetToMeshHoles(toMesh)
3731 ## Set Optimization level:
3732 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3733 # Default is Medium_Optimization
3734 # @ingroup l3_hypos_ghs3dh
3735 def SetOptimizationLevel(self, level):
3736 # Parameter of GHS3D
3737 self.Parameters().SetOptimizationLevel(level)
3739 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3740 # @ingroup l3_hypos_ghs3dh
3741 def SetMaximumMemory(self, MB):
3742 # Advanced parameter of GHS3D
3743 self.Parameters().SetMaximumMemory(MB)
3745 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3746 # automatic memory adjustment mode.
3747 # @ingroup l3_hypos_ghs3dh
3748 def SetInitialMemory(self, MB):
3749 # Advanced parameter of GHS3D
3750 self.Parameters().SetInitialMemory(MB)
3752 ## Path to working directory.
3753 # @ingroup l3_hypos_ghs3dh
3754 def SetWorkingDirectory(self, path):
3755 # Advanced parameter of GHS3D
3756 self.Parameters().SetWorkingDirectory(path)
3758 ## To keep working files or remove them. Log file remains in case of errors anyway.
3759 # @ingroup l3_hypos_ghs3dh
3760 def SetKeepFiles(self, toKeep):
3761 # Advanced parameter of GHS3D
3762 self.Parameters().SetKeepFiles(toKeep)
3764 ## To set verbose level [0-10]. <ul>
3765 #<li> 0 - no standard output,
3766 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3767 # indicates when the final mesh is being saved. In addition the software
3768 # gives indication regarding the CPU time.
3769 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3770 # histogram of the skin mesh, quality statistics histogram together with
3771 # the characteristics of the final mesh.</ul>
3772 # @ingroup l3_hypos_ghs3dh
3773 def SetVerboseLevel(self, level):
3774 # Advanced parameter of GHS3D
3775 self.Parameters().SetVerboseLevel(level)
3777 ## To create new nodes.
3778 # @ingroup l3_hypos_ghs3dh
3779 def SetToCreateNewNodes(self, toCreate):
3780 # Advanced parameter of GHS3D
3781 self.Parameters().SetToCreateNewNodes(toCreate)
3783 ## To use boundary recovery version which tries to create mesh on a very poor
3784 # quality surface mesh.
3785 # @ingroup l3_hypos_ghs3dh
3786 def SetToUseBoundaryRecoveryVersion(self, toUse):
3787 # Advanced parameter of GHS3D
3788 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3790 ## Sets command line option as text.
3791 # @ingroup l3_hypos_ghs3dh
3792 def SetTextOption(self, option):
3793 # Advanced parameter of GHS3D
3794 self.Parameters().SetTextOption(option)
3796 # Public class: Mesh_Hexahedron
3797 # ------------------------------
3799 ## Defines a hexahedron 3D algorithm
3801 # @ingroup l3_algos_basic
3802 class Mesh_Hexahedron(Mesh_Algorithm):
3807 ## Private constructor.
3808 def __init__(self, mesh, algoType=Hexa, geom=0):
3809 Mesh_Algorithm.__init__(self)
3811 self.algoType = algoType
3813 if algoType == Hexa:
3814 self.Create(mesh, geom, "Hexa_3D")
3817 elif algoType == Hexotic:
3818 import HexoticPlugin
3819 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3822 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3823 # @ingroup l3_hypos_hexotic
3824 def MinMaxQuad(self, min=3, max=8, quad=True):
3825 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3827 self.params.SetHexesMinLevel(min)
3828 self.params.SetHexesMaxLevel(max)
3829 self.params.SetHexoticQuadrangles(quad)
3832 # Deprecated, only for compatibility!
3833 # Public class: Mesh_Netgen
3834 # ------------------------------
3836 ## Defines a NETGEN-based 2D or 3D algorithm
3837 # that needs no discrete boundary (i.e. independent)
3839 # This class is deprecated, only for compatibility!
3842 # @ingroup l3_algos_basic
3843 class Mesh_Netgen(Mesh_Algorithm):
3847 ## Private constructor.
3848 def __init__(self, mesh, is3D, geom=0):
3849 Mesh_Algorithm.__init__(self)
3852 print "Warning: NETGENPlugin module has not been imported."
3856 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3860 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3863 ## Defines the hypothesis containing parameters of the algorithm
3864 def Parameters(self):
3866 hyp = self.Hypothesis("NETGEN_Parameters", [],
3867 "libNETGENEngine.so", UseExisting=0)
3869 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3870 "libNETGENEngine.so", UseExisting=0)
3873 # Public class: Mesh_Projection1D
3874 # ------------------------------
3876 ## Defines a projection 1D algorithm
3877 # @ingroup l3_algos_proj
3879 class Mesh_Projection1D(Mesh_Algorithm):
3881 ## Private constructor.
3882 def __init__(self, mesh, geom=0):
3883 Mesh_Algorithm.__init__(self)
3884 self.Create(mesh, geom, "Projection_1D")
3886 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3887 # a mesh pattern is taken, and, optionally, the association of vertices
3888 # between the source edge and a target edge (to which a hypothesis is assigned)
3889 # @param edge from which nodes distribution is taken
3890 # @param mesh from which nodes distribution is taken (optional)
3891 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3892 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3893 # to associate with \a srcV (optional)
3894 # @param UseExisting if ==true - searches for the existing hypothesis created with
3895 # the same parameters, else (default) - creates a new one
3896 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3897 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3899 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3900 hyp.SetSourceEdge( edge )
3901 if not mesh is None and isinstance(mesh, Mesh):
3902 mesh = mesh.GetMesh()
3903 hyp.SetSourceMesh( mesh )
3904 hyp.SetVertexAssociation( srcV, tgtV )
3907 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3908 #def CompareSourceEdge(self, hyp, args):
3909 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3913 # Public class: Mesh_Projection2D
3914 # ------------------------------
3916 ## Defines a projection 2D algorithm
3917 # @ingroup l3_algos_proj
3919 class Mesh_Projection2D(Mesh_Algorithm):
3921 ## Private constructor.
3922 def __init__(self, mesh, geom=0):
3923 Mesh_Algorithm.__init__(self)
3924 self.Create(mesh, geom, "Projection_2D")
3926 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3927 # a mesh pattern is taken, and, optionally, the association of vertices
3928 # between the source face and the target face (to which a hypothesis is assigned)
3929 # @param face from which the mesh pattern is taken
3930 # @param mesh from which the mesh pattern is taken (optional)
3931 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3932 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3933 # to associate with \a srcV1 (optional)
3934 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3935 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3936 # to associate with \a srcV2 (optional)
3937 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3938 # the same parameters, else (default) - forces the creation a new one
3940 # Note: all association vertices must belong to one edge of a face
3941 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3942 srcV2=None, tgtV2=None, UseExisting=0):
3943 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3945 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3946 hyp.SetSourceFace( face )
3947 if not mesh is None and isinstance(mesh, Mesh):
3948 mesh = mesh.GetMesh()
3949 hyp.SetSourceMesh( mesh )
3950 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3953 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3954 #def CompareSourceFace(self, hyp, args):
3955 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3958 # Public class: Mesh_Projection3D
3959 # ------------------------------
3961 ## Defines a projection 3D algorithm
3962 # @ingroup l3_algos_proj
3964 class Mesh_Projection3D(Mesh_Algorithm):
3966 ## Private constructor.
3967 def __init__(self, mesh, geom=0):
3968 Mesh_Algorithm.__init__(self)
3969 self.Create(mesh, geom, "Projection_3D")
3971 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3972 # the mesh pattern is taken, and, optionally, the association of vertices
3973 # between the source and the target solid (to which a hipothesis is assigned)
3974 # @param solid from where the mesh pattern is taken
3975 # @param mesh from where the mesh pattern is taken (optional)
3976 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3977 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3978 # to associate with \a srcV1 (optional)
3979 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3980 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3981 # to associate with \a srcV2 (optional)
3982 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3983 # the same parameters, else (default) - creates a new one
3985 # Note: association vertices must belong to one edge of a solid
3986 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3987 srcV2=0, tgtV2=0, UseExisting=0):
3988 hyp = self.Hypothesis("ProjectionSource3D",
3989 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3991 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3992 hyp.SetSource3DShape( solid )
3993 if not mesh is None and isinstance(mesh, Mesh):
3994 mesh = mesh.GetMesh()
3995 hyp.SetSourceMesh( mesh )
3996 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3999 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4000 #def CompareSourceShape3D(self, hyp, args):
4001 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4005 # Public class: Mesh_Prism
4006 # ------------------------
4008 ## Defines a 3D extrusion algorithm
4009 # @ingroup l3_algos_3dextr
4011 class Mesh_Prism3D(Mesh_Algorithm):
4013 ## Private constructor.
4014 def __init__(self, mesh, geom=0):
4015 Mesh_Algorithm.__init__(self)
4016 self.Create(mesh, geom, "Prism_3D")
4018 # Public class: Mesh_RadialPrism
4019 # -------------------------------
4021 ## Defines a Radial Prism 3D algorithm
4022 # @ingroup l3_algos_radialp
4024 class Mesh_RadialPrism3D(Mesh_Algorithm):
4026 ## Private constructor.
4027 def __init__(self, mesh, geom=0):
4028 Mesh_Algorithm.__init__(self)
4029 self.Create(mesh, geom, "RadialPrism_3D")
4031 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4032 self.nbLayers = None
4034 ## Return 3D hypothesis holding the 1D one
4035 def Get3DHypothesis(self):
4036 return self.distribHyp
4038 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4039 # hypothesis. Returns the created hypothesis
4040 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4041 #print "OwnHypothesis",hypType
4042 if not self.nbLayers is None:
4043 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4044 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4045 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4046 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4047 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4048 self.distribHyp.SetLayerDistribution( hyp )
4051 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4052 # prisms to build between the inner and outer shells
4053 # @param n number of layers
4054 # @param UseExisting if ==true - searches for the existing hypothesis created with
4055 # the same parameters, else (default) - creates a new one
4056 def NumberOfLayers(self, n, UseExisting=0):
4057 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4058 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4059 CompareMethod=self.CompareNumberOfLayers)
4060 self.nbLayers.SetNumberOfLayers( n )
4061 return self.nbLayers
4063 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4064 def CompareNumberOfLayers(self, hyp, args):
4065 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4067 ## Defines "LocalLength" hypothesis, specifying the segment length
4068 # to build between the inner and the outer shells
4069 # @param l the length of segments
4070 # @param p the precision of rounding
4071 def LocalLength(self, l, p=1e-07):
4072 hyp = self.OwnHypothesis("LocalLength", [l,p])
4077 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4078 # prisms to build between the inner and the outer shells.
4079 # @param n the number of layers
4080 # @param s the scale factor (optional)
4081 def NumberOfSegments(self, n, s=[]):
4083 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4085 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4086 hyp.SetDistrType( 1 )
4087 hyp.SetScaleFactor(s)
4088 hyp.SetNumberOfSegments(n)
4091 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4092 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4093 # @param start the length of the first segment
4094 # @param end the length of the last segment
4095 def Arithmetic1D(self, start, end ):
4096 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4097 hyp.SetLength(start, 1)
4098 hyp.SetLength(end , 0)
4101 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4102 # to build between the inner and the outer shells as geometric length increasing
4103 # @param start for the length of the first segment
4104 # @param end for the length of the last segment
4105 def StartEndLength(self, start, end):
4106 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4107 hyp.SetLength(start, 1)
4108 hyp.SetLength(end , 0)
4111 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4112 # to build between the inner and outer shells
4113 # @param fineness defines the quality of the mesh within the range [0-1]
4114 def AutomaticLength(self, fineness=0):
4115 hyp = self.OwnHypothesis("AutomaticLength")
4116 hyp.SetFineness( fineness )
4119 # Private class: Mesh_UseExisting
4120 # -------------------------------
4121 class Mesh_UseExisting(Mesh_Algorithm):
4123 def __init__(self, dim, mesh, geom=0):
4125 self.Create(mesh, geom, "UseExisting_1D")
4127 self.Create(mesh, geom, "UseExisting_2D")