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 ## Convert group on geom into standalone group
1314 # @ingroup l2_grps_delete
1315 def ConvertToStandalone(self, group):
1316 return self.mesh.ConvertToStandalone(group)
1318 # Get some info about mesh:
1319 # ------------------------
1321 ## Returns the log of nodes and elements added or removed
1322 # since the previous clear of the log.
1323 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1324 # @return list of log_block structures:
1329 # @ingroup l1_auxiliary
1330 def GetLog(self, clearAfterGet):
1331 return self.mesh.GetLog(clearAfterGet)
1333 ## Clears the log of nodes and elements added or removed since the previous
1334 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1335 # @ingroup l1_auxiliary
1337 self.mesh.ClearLog()
1339 ## Toggles auto color mode on the object.
1340 # @param theAutoColor the flag which toggles auto color mode.
1341 # @ingroup l1_auxiliary
1342 def SetAutoColor(self, theAutoColor):
1343 self.mesh.SetAutoColor(theAutoColor)
1345 ## Gets flag of object auto color mode.
1346 # @return True or False
1347 # @ingroup l1_auxiliary
1348 def GetAutoColor(self):
1349 return self.mesh.GetAutoColor()
1351 ## Gets the internal ID
1352 # @return integer value, which is the internal Id of the mesh
1353 # @ingroup l1_auxiliary
1355 return self.mesh.GetId()
1358 # @return integer value, which is the study Id of the mesh
1359 # @ingroup l1_auxiliary
1360 def GetStudyId(self):
1361 return self.mesh.GetStudyId()
1363 ## Checks the group names for duplications.
1364 # Consider the maximum group name length stored in MED file.
1365 # @return True or False
1366 # @ingroup l1_auxiliary
1367 def HasDuplicatedGroupNamesMED(self):
1368 return self.mesh.HasDuplicatedGroupNamesMED()
1370 ## Obtains the mesh editor tool
1371 # @return an instance of SMESH_MeshEditor
1372 # @ingroup l1_modifying
1373 def GetMeshEditor(self):
1374 return self.mesh.GetMeshEditor()
1377 # @return an instance of SALOME_MED::MESH
1378 # @ingroup l1_auxiliary
1379 def GetMEDMesh(self):
1380 return self.mesh.GetMEDMesh()
1383 # Get informations about mesh contents:
1384 # ------------------------------------
1386 ## Returns the number of nodes in the mesh
1387 # @return an integer value
1388 # @ingroup l1_meshinfo
1390 return self.mesh.NbNodes()
1392 ## Returns the number of elements in the mesh
1393 # @return an integer value
1394 # @ingroup l1_meshinfo
1395 def NbElements(self):
1396 return self.mesh.NbElements()
1398 ## Returns the number of edges in the mesh
1399 # @return an integer value
1400 # @ingroup l1_meshinfo
1402 return self.mesh.NbEdges()
1404 ## Returns the number of edges with the given order in the mesh
1405 # @param elementOrder the order of elements:
1406 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1407 # @return an integer value
1408 # @ingroup l1_meshinfo
1409 def NbEdgesOfOrder(self, elementOrder):
1410 return self.mesh.NbEdgesOfOrder(elementOrder)
1412 ## Returns the number of faces in the mesh
1413 # @return an integer value
1414 # @ingroup l1_meshinfo
1416 return self.mesh.NbFaces()
1418 ## Returns the number of faces with the given order in the mesh
1419 # @param elementOrder the order of elements:
1420 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1421 # @return an integer value
1422 # @ingroup l1_meshinfo
1423 def NbFacesOfOrder(self, elementOrder):
1424 return self.mesh.NbFacesOfOrder(elementOrder)
1426 ## Returns the number of triangles in the mesh
1427 # @return an integer value
1428 # @ingroup l1_meshinfo
1429 def NbTriangles(self):
1430 return self.mesh.NbTriangles()
1432 ## Returns the number of triangles with the given order in the mesh
1433 # @param elementOrder is the order of elements:
1434 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1435 # @return an integer value
1436 # @ingroup l1_meshinfo
1437 def NbTrianglesOfOrder(self, elementOrder):
1438 return self.mesh.NbTrianglesOfOrder(elementOrder)
1440 ## Returns the number of quadrangles in the mesh
1441 # @return an integer value
1442 # @ingroup l1_meshinfo
1443 def NbQuadrangles(self):
1444 return self.mesh.NbQuadrangles()
1446 ## Returns the number of quadrangles with the given order in the mesh
1447 # @param elementOrder the order of elements:
1448 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1449 # @return an integer value
1450 # @ingroup l1_meshinfo
1451 def NbQuadranglesOfOrder(self, elementOrder):
1452 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1454 ## Returns the number of polygons in the mesh
1455 # @return an integer value
1456 # @ingroup l1_meshinfo
1457 def NbPolygons(self):
1458 return self.mesh.NbPolygons()
1460 ## Returns the number of volumes in the mesh
1461 # @return an integer value
1462 # @ingroup l1_meshinfo
1463 def NbVolumes(self):
1464 return self.mesh.NbVolumes()
1466 ## Returns the number of volumes with the given order in the mesh
1467 # @param elementOrder the order of elements:
1468 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1469 # @return an integer value
1470 # @ingroup l1_meshinfo
1471 def NbVolumesOfOrder(self, elementOrder):
1472 return self.mesh.NbVolumesOfOrder(elementOrder)
1474 ## Returns the number of tetrahedrons in the mesh
1475 # @return an integer value
1476 # @ingroup l1_meshinfo
1478 return self.mesh.NbTetras()
1480 ## Returns the number of tetrahedrons with the given order in the mesh
1481 # @param elementOrder the order of elements:
1482 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1483 # @return an integer value
1484 # @ingroup l1_meshinfo
1485 def NbTetrasOfOrder(self, elementOrder):
1486 return self.mesh.NbTetrasOfOrder(elementOrder)
1488 ## Returns the number of hexahedrons in the mesh
1489 # @return an integer value
1490 # @ingroup l1_meshinfo
1492 return self.mesh.NbHexas()
1494 ## Returns the number of hexahedrons with the given order in the mesh
1495 # @param elementOrder the order of elements:
1496 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1497 # @return an integer value
1498 # @ingroup l1_meshinfo
1499 def NbHexasOfOrder(self, elementOrder):
1500 return self.mesh.NbHexasOfOrder(elementOrder)
1502 ## Returns the number of pyramids in the mesh
1503 # @return an integer value
1504 # @ingroup l1_meshinfo
1505 def NbPyramids(self):
1506 return self.mesh.NbPyramids()
1508 ## Returns the number of pyramids with the given order in the mesh
1509 # @param elementOrder the order of elements:
1510 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1511 # @return an integer value
1512 # @ingroup l1_meshinfo
1513 def NbPyramidsOfOrder(self, elementOrder):
1514 return self.mesh.NbPyramidsOfOrder(elementOrder)
1516 ## Returns the number of prisms in the mesh
1517 # @return an integer value
1518 # @ingroup l1_meshinfo
1520 return self.mesh.NbPrisms()
1522 ## Returns the number of prisms with the given order in the mesh
1523 # @param elementOrder the order of elements:
1524 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1525 # @return an integer value
1526 # @ingroup l1_meshinfo
1527 def NbPrismsOfOrder(self, elementOrder):
1528 return self.mesh.NbPrismsOfOrder(elementOrder)
1530 ## Returns the number of polyhedrons in the mesh
1531 # @return an integer value
1532 # @ingroup l1_meshinfo
1533 def NbPolyhedrons(self):
1534 return self.mesh.NbPolyhedrons()
1536 ## Returns the number of submeshes in the mesh
1537 # @return an integer value
1538 # @ingroup l1_meshinfo
1539 def NbSubMesh(self):
1540 return self.mesh.NbSubMesh()
1542 ## Returns the list of mesh elements IDs
1543 # @return the list of integer values
1544 # @ingroup l1_meshinfo
1545 def GetElementsId(self):
1546 return self.mesh.GetElementsId()
1548 ## Returns the list of IDs of mesh elements with the given type
1549 # @param elementType the required type of elements
1550 # @return list of integer values
1551 # @ingroup l1_meshinfo
1552 def GetElementsByType(self, elementType):
1553 return self.mesh.GetElementsByType(elementType)
1555 ## Returns the list of mesh nodes IDs
1556 # @return the list of integer values
1557 # @ingroup l1_meshinfo
1558 def GetNodesId(self):
1559 return self.mesh.GetNodesId()
1561 # Get the information about mesh elements:
1562 # ------------------------------------
1564 ## Returns the type of mesh element
1565 # @return the value from SMESH::ElementType enumeration
1566 # @ingroup l1_meshinfo
1567 def GetElementType(self, id, iselem):
1568 return self.mesh.GetElementType(id, iselem)
1570 ## Returns the list of submesh elements IDs
1571 # @param Shape a geom object(subshape) IOR
1572 # Shape must be the subshape of a ShapeToMesh()
1573 # @return the list of integer values
1574 # @ingroup l1_meshinfo
1575 def GetSubMeshElementsId(self, Shape):
1576 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1577 ShapeID = Shape.GetSubShapeIndices()[0]
1580 return self.mesh.GetSubMeshElementsId(ShapeID)
1582 ## Returns the list of submesh nodes IDs
1583 # @param Shape a geom object(subshape) IOR
1584 # Shape must be the subshape of a ShapeToMesh()
1585 # @param all If true, gives all nodes of submesh elements, otherwise gives only submesh nodes
1586 # @return the list of integer values
1587 # @ingroup l1_meshinfo
1588 def GetSubMeshNodesId(self, Shape, all):
1589 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1590 ShapeID = Shape.GetSubShapeIndices()[0]
1593 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1595 ## Returns the list of IDs of submesh elements with the given type
1596 # @param Shape a geom object(subshape) IOR
1597 # Shape must be a subshape of a ShapeToMesh()
1598 # @return the list of integer values
1599 # @ingroup l1_meshinfo
1600 def GetSubMeshElementType(self, Shape):
1601 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1602 ShapeID = Shape.GetSubShapeIndices()[0]
1605 return self.mesh.GetSubMeshElementType(ShapeID)
1607 ## Gets the mesh description
1608 # @return string value
1609 # @ingroup l1_meshinfo
1611 return self.mesh.Dump()
1614 # Get the information about nodes and elements of a mesh by its IDs:
1615 # -----------------------------------------------------------
1617 ## Gets XYZ coordinates of a node
1618 # \n If there is no nodes for the given ID - returns an empty list
1619 # @return a list of double precision values
1620 # @ingroup l1_meshinfo
1621 def GetNodeXYZ(self, id):
1622 return self.mesh.GetNodeXYZ(id)
1624 ## Returns list of IDs of inverse elements for the given node
1625 # \n If there is no node for the given ID - returns an empty list
1626 # @return a list of integer values
1627 # @ingroup l1_meshinfo
1628 def GetNodeInverseElements(self, id):
1629 return self.mesh.GetNodeInverseElements(id)
1631 ## @brief Returns the position of a node on the shape
1632 # @return SMESH::NodePosition
1633 # @ingroup l1_meshinfo
1634 def GetNodePosition(self,NodeID):
1635 return self.mesh.GetNodePosition(NodeID)
1637 ## If the given element is a node, returns the ID of shape
1638 # \n If there is no node for the given ID - returns -1
1639 # @return an integer value
1640 # @ingroup l1_meshinfo
1641 def GetShapeID(self, id):
1642 return self.mesh.GetShapeID(id)
1644 ## Returns the ID of the result shape after
1645 # FindShape() from SMESH_MeshEditor for the given element
1646 # \n If there is no element for the given ID - returns -1
1647 # @return an integer value
1648 # @ingroup l1_meshinfo
1649 def GetShapeIDForElem(self,id):
1650 return self.mesh.GetShapeIDForElem(id)
1652 ## Returns the number of nodes for the given element
1653 # \n If there is no element for the given ID - returns -1
1654 # @return an integer value
1655 # @ingroup l1_meshinfo
1656 def GetElemNbNodes(self, id):
1657 return self.mesh.GetElemNbNodes(id)
1659 ## Returns the node ID the given index for the given element
1660 # \n If there is no element for the given ID - returns -1
1661 # \n If there is no node for the given index - returns -2
1662 # @return an integer value
1663 # @ingroup l1_meshinfo
1664 def GetElemNode(self, id, index):
1665 return self.mesh.GetElemNode(id, index)
1667 ## Returns the IDs of nodes of the given element
1668 # @return a list of integer values
1669 # @ingroup l1_meshinfo
1670 def GetElemNodes(self, id):
1671 return self.mesh.GetElemNodes(id)
1673 ## Returns true if the given node is the medium node in the given quadratic element
1674 # @ingroup l1_meshinfo
1675 def IsMediumNode(self, elementID, nodeID):
1676 return self.mesh.IsMediumNode(elementID, nodeID)
1678 ## Returns true if the given node is the medium node in one of quadratic elements
1679 # @ingroup l1_meshinfo
1680 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1681 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1683 ## Returns the number of edges for the given element
1684 # @ingroup l1_meshinfo
1685 def ElemNbEdges(self, id):
1686 return self.mesh.ElemNbEdges(id)
1688 ## Returns the number of faces for the given element
1689 # @ingroup l1_meshinfo
1690 def ElemNbFaces(self, id):
1691 return self.mesh.ElemNbFaces(id)
1693 ## Returns true if the given element is a polygon
1694 # @ingroup l1_meshinfo
1695 def IsPoly(self, id):
1696 return self.mesh.IsPoly(id)
1698 ## Returns true if the given element is quadratic
1699 # @ingroup l1_meshinfo
1700 def IsQuadratic(self, id):
1701 return self.mesh.IsQuadratic(id)
1703 ## Returns XYZ coordinates of the barycenter of the given element
1704 # \n If there is no element for the given ID - returns an empty list
1705 # @return a list of three double values
1706 # @ingroup l1_meshinfo
1707 def BaryCenter(self, id):
1708 return self.mesh.BaryCenter(id)
1711 # Mesh edition (SMESH_MeshEditor functionality):
1712 # ---------------------------------------------
1714 ## Removes the elements from the mesh by ids
1715 # @param IDsOfElements is a list of ids of elements to remove
1716 # @return True or False
1717 # @ingroup l2_modif_del
1718 def RemoveElements(self, IDsOfElements):
1719 return self.editor.RemoveElements(IDsOfElements)
1721 ## Removes nodes from mesh by ids
1722 # @param IDsOfNodes is a list of ids of nodes to remove
1723 # @return True or False
1724 # @ingroup l2_modif_del
1725 def RemoveNodes(self, IDsOfNodes):
1726 return self.editor.RemoveNodes(IDsOfNodes)
1728 ## Add a node to the mesh by coordinates
1729 # @return Id of the new node
1730 # @ingroup l2_modif_add
1731 def AddNode(self, x, y, z):
1732 return self.editor.AddNode( x, y, z)
1734 ## Creates a linear or quadratic edge (this is determined
1735 # by the number of given nodes).
1736 # @param IDsOfNodes the list of node IDs for creation of the element.
1737 # The order of nodes in this list should correspond to the description
1738 # of MED. \n This description is located by the following link:
1739 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1740 # @return the Id of the new edge
1741 # @ingroup l2_modif_add
1742 def AddEdge(self, IDsOfNodes):
1743 return self.editor.AddEdge(IDsOfNodes)
1745 ## Creates a linear or quadratic face (this is determined
1746 # by the number of given nodes).
1747 # @param IDsOfNodes the list of node IDs for creation of the element.
1748 # The order of nodes in this list should correspond to the description
1749 # of MED. \n This description is located by the following link:
1750 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1751 # @return the Id of the new face
1752 # @ingroup l2_modif_add
1753 def AddFace(self, IDsOfNodes):
1754 return self.editor.AddFace(IDsOfNodes)
1756 ## Adds a polygonal face to the mesh by the list of node IDs
1757 # @param IdsOfNodes the list of node IDs for creation of the element.
1758 # @return the Id of the new face
1759 # @ingroup l2_modif_add
1760 def AddPolygonalFace(self, IdsOfNodes):
1761 return self.editor.AddPolygonalFace(IdsOfNodes)
1763 ## Creates both simple and quadratic volume (this is determined
1764 # by the number of given nodes).
1765 # @param IDsOfNodes the list of node IDs for creation of the element.
1766 # The order of nodes in this list should correspond to the description
1767 # of MED. \n This description is located by the following link:
1768 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1769 # @return the Id of the new volumic element
1770 # @ingroup l2_modif_add
1771 def AddVolume(self, IDsOfNodes):
1772 return self.editor.AddVolume(IDsOfNodes)
1774 ## Creates a volume of many faces, giving nodes for each face.
1775 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1776 # @param Quantities the list of integer values, Quantities[i]
1777 # gives the quantity of nodes in face number i.
1778 # @return the Id of the new volumic element
1779 # @ingroup l2_modif_add
1780 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1781 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1783 ## Creates a volume of many faces, giving the IDs of the existing faces.
1784 # @param IdsOfFaces the list of face IDs for volume creation.
1786 # Note: The created volume will refer only to the nodes
1787 # of the given faces, not to the faces themselves.
1788 # @return the Id of the new volumic element
1789 # @ingroup l2_modif_add
1790 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1791 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1794 ## @brief Binds a node to a vertex
1795 # @param NodeID a node ID
1796 # @param Vertex a vertex or vertex ID
1797 # @return True if succeed else raises an exception
1798 # @ingroup l2_modif_add
1799 def SetNodeOnVertex(self, NodeID, Vertex):
1800 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1801 VertexID = Vertex.GetSubShapeIndices()[0]
1805 self.editor.SetNodeOnVertex(NodeID, VertexID)
1806 except SALOME.SALOME_Exception, inst:
1807 raise ValueError, inst.details.text
1811 ## @brief Stores the node position on an edge
1812 # @param NodeID a node ID
1813 # @param Edge an edge or edge ID
1814 # @param paramOnEdge a parameter on the edge where the node is located
1815 # @return True if succeed else raises an exception
1816 # @ingroup l2_modif_add
1817 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1818 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1819 EdgeID = Edge.GetSubShapeIndices()[0]
1823 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1824 except SALOME.SALOME_Exception, inst:
1825 raise ValueError, inst.details.text
1828 ## @brief Stores node position on a face
1829 # @param NodeID a node ID
1830 # @param Face a face or face ID
1831 # @param u U parameter on the face where the node is located
1832 # @param v V parameter on the face where the node is located
1833 # @return True if succeed else raises an exception
1834 # @ingroup l2_modif_add
1835 def SetNodeOnFace(self, NodeID, Face, u, v):
1836 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1837 FaceID = Face.GetSubShapeIndices()[0]
1841 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1842 except SALOME.SALOME_Exception, inst:
1843 raise ValueError, inst.details.text
1846 ## @brief Binds a node to a solid
1847 # @param NodeID a node ID
1848 # @param Solid a solid or solid ID
1849 # @return True if succeed else raises an exception
1850 # @ingroup l2_modif_add
1851 def SetNodeInVolume(self, NodeID, Solid):
1852 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1853 SolidID = Solid.GetSubShapeIndices()[0]
1857 self.editor.SetNodeInVolume(NodeID, SolidID)
1858 except SALOME.SALOME_Exception, inst:
1859 raise ValueError, inst.details.text
1862 ## @brief Bind an element to a shape
1863 # @param ElementID an element ID
1864 # @param Shape a shape or shape ID
1865 # @return True if succeed else raises an exception
1866 # @ingroup l2_modif_add
1867 def SetMeshElementOnShape(self, ElementID, Shape):
1868 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1869 ShapeID = Shape.GetSubShapeIndices()[0]
1873 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1874 except SALOME.SALOME_Exception, inst:
1875 raise ValueError, inst.details.text
1879 ## Moves the node with the given id
1880 # @param NodeID the id of the node
1881 # @param x a new X coordinate
1882 # @param y a new Y coordinate
1883 # @param z a new Z coordinate
1884 # @return True if succeed else False
1885 # @ingroup l2_modif_movenode
1886 def MoveNode(self, NodeID, x, y, z):
1887 return self.editor.MoveNode(NodeID, x, y, z)
1889 ## Finds the node closest to a point
1890 # @param x the X coordinate of a point
1891 # @param y the Y coordinate of a point
1892 # @param z the Z coordinate of a point
1893 # @return the ID of a node
1894 # @ingroup l2_modif_throughp
1895 def FindNodeClosestTo(self, x, y, z):
1896 preview = self.mesh.GetMeshEditPreviewer()
1897 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1899 ## Finds the node closest to a point and moves it to a point location
1900 # @param x the X coordinate of a point
1901 # @param y the Y coordinate of a point
1902 # @param z the Z coordinate of a point
1903 # @return the ID of a moved node
1904 # @ingroup l2_modif_throughp
1905 def MeshToPassThroughAPoint(self, x, y, z):
1906 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1908 ## Replaces two neighbour triangles sharing Node1-Node2 link
1909 # with the triangles built on the same 4 nodes but having other common link.
1910 # @param NodeID1 the ID of the first node
1911 # @param NodeID2 the ID of the second node
1912 # @return false if proper faces were not found
1913 # @ingroup l2_modif_invdiag
1914 def InverseDiag(self, NodeID1, NodeID2):
1915 return self.editor.InverseDiag(NodeID1, NodeID2)
1917 ## Replaces two neighbour triangles sharing Node1-Node2 link
1918 # with a quadrangle built on the same 4 nodes.
1919 # @param NodeID1 the ID of the first node
1920 # @param NodeID2 the ID of the second node
1921 # @return false if proper faces were not found
1922 # @ingroup l2_modif_unitetri
1923 def DeleteDiag(self, NodeID1, NodeID2):
1924 return self.editor.DeleteDiag(NodeID1, NodeID2)
1926 ## Reorients elements by ids
1927 # @param IDsOfElements if undefined reorients all mesh elements
1928 # @return True if succeed else False
1929 # @ingroup l2_modif_changori
1930 def Reorient(self, IDsOfElements=None):
1931 if IDsOfElements == None:
1932 IDsOfElements = self.GetElementsId()
1933 return self.editor.Reorient(IDsOfElements)
1935 ## Reorients all elements of the object
1936 # @param theObject mesh, submesh or group
1937 # @return True if succeed else False
1938 # @ingroup l2_modif_changori
1939 def ReorientObject(self, theObject):
1940 if ( isinstance( theObject, Mesh )):
1941 theObject = theObject.GetMesh()
1942 return self.editor.ReorientObject(theObject)
1944 ## Fuses the neighbouring triangles into quadrangles.
1945 # @param IDsOfElements The triangles to be fused,
1946 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1947 # @param MaxAngle is the maximum angle between element normals at which the fusion
1948 # is still performed; theMaxAngle is mesured in radians.
1949 # @return TRUE in case of success, FALSE otherwise.
1950 # @ingroup l2_modif_unitetri
1951 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1952 if IDsOfElements == []:
1953 IDsOfElements = self.GetElementsId()
1954 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1956 ## Fuses the neighbouring triangles of the object into quadrangles
1957 # @param theObject is mesh, submesh or group
1958 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1959 # @param MaxAngle a max angle between element normals at which the fusion
1960 # is still performed; theMaxAngle is mesured in radians.
1961 # @return TRUE in case of success, FALSE otherwise.
1962 # @ingroup l2_modif_unitetri
1963 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1964 if ( isinstance( theObject, Mesh )):
1965 theObject = theObject.GetMesh()
1966 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1968 ## Splits quadrangles into triangles.
1969 # @param IDsOfElements the faces to be splitted.
1970 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1971 # @return TRUE in case of success, FALSE otherwise.
1972 # @ingroup l2_modif_cutquadr
1973 def QuadToTri (self, IDsOfElements, theCriterion):
1974 if IDsOfElements == []:
1975 IDsOfElements = self.GetElementsId()
1976 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1978 ## Splits quadrangles into triangles.
1979 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1980 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1981 # @return TRUE in case of success, FALSE otherwise.
1982 # @ingroup l2_modif_cutquadr
1983 def QuadToTriObject (self, theObject, theCriterion):
1984 if ( isinstance( theObject, Mesh )):
1985 theObject = theObject.GetMesh()
1986 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1988 ## Splits quadrangles into triangles.
1989 # @param IDsOfElements the faces to be splitted
1990 # @param Diag13 is used to choose a diagonal for splitting.
1991 # @return TRUE in case of success, FALSE otherwise.
1992 # @ingroup l2_modif_cutquadr
1993 def SplitQuad (self, IDsOfElements, Diag13):
1994 if IDsOfElements == []:
1995 IDsOfElements = self.GetElementsId()
1996 return self.editor.SplitQuad(IDsOfElements, Diag13)
1998 ## Splits quadrangles into triangles.
1999 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
2000 # @param Diag13 is used to choose a diagonal for splitting.
2001 # @return TRUE in case of success, FALSE otherwise.
2002 # @ingroup l2_modif_cutquadr
2003 def SplitQuadObject (self, theObject, Diag13):
2004 if ( isinstance( theObject, Mesh )):
2005 theObject = theObject.GetMesh()
2006 return self.editor.SplitQuadObject(theObject, Diag13)
2008 ## Finds a better splitting of the given quadrangle.
2009 # @param IDOfQuad the ID of the quadrangle to be splitted.
2010 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
2011 # @return 1 if 1-3 diagonal is better, 2 if 2-4
2012 # diagonal is better, 0 if error occurs.
2013 # @ingroup l2_modif_cutquadr
2014 def BestSplit (self, IDOfQuad, theCriterion):
2015 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
2017 ## Splits quadrangle faces near triangular facets of volumes
2019 # @ingroup l1_auxiliary
2020 def SplitQuadsNearTriangularFacets(self):
2021 faces_array = self.GetElementsByType(SMESH.FACE)
2022 for face_id in faces_array:
2023 if self.GetElemNbNodes(face_id) == 4: # quadrangle
2024 quad_nodes = self.mesh.GetElemNodes(face_id)
2025 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
2026 isVolumeFound = False
2027 for node1_elem in node1_elems:
2028 if not isVolumeFound:
2029 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
2030 nb_nodes = self.GetElemNbNodes(node1_elem)
2031 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
2032 volume_elem = node1_elem
2033 volume_nodes = self.mesh.GetElemNodes(volume_elem)
2034 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
2035 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
2036 isVolumeFound = True
2037 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
2038 self.SplitQuad([face_id], False) # diagonal 2-4
2039 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
2040 isVolumeFound = True
2041 self.SplitQuad([face_id], True) # diagonal 1-3
2042 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
2043 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
2044 isVolumeFound = True
2045 self.SplitQuad([face_id], True) # diagonal 1-3
2047 ## @brief Splits hexahedrons into tetrahedrons.
2049 # This operation uses pattern mapping functionality for splitting.
2050 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
2051 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
2052 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
2053 # will be mapped into <VAR>theNode000</VAR>-th node of each volume, the (0,0,1)
2054 # key-point will be mapped into <VAR>theNode001</VAR>-th node of each volume.
2055 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
2056 # @return TRUE in case of success, FALSE otherwise.
2057 # @ingroup l1_auxiliary
2058 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
2059 # Pattern: 5.---------.6
2064 # (0,0,1) 4.---------.7 * |
2071 # (0,0,0) 0.---------.3
2072 pattern_tetra = "!!! Nb of points: \n 8 \n\
2082 !!! Indices of points of 6 tetras: \n\
2090 pattern = self.smeshpyD.GetPattern()
2091 isDone = pattern.LoadFromFile(pattern_tetra)
2093 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2096 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2097 isDone = pattern.MakeMesh(self.mesh, False, False)
2098 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2100 # split quafrangle faces near triangular facets of volumes
2101 self.SplitQuadsNearTriangularFacets()
2105 ## @brief Split hexahedrons into prisms.
2107 # Uses the pattern mapping functionality for splitting.
2108 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
2109 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
2110 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
2111 # will be mapped into the <VAR>theNode000</VAR>-th node of each volume, keypoint (0,0,1)
2112 # will be mapped into the <VAR>theNode001</VAR>-th node of each volume.
2113 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
2114 # @return TRUE in case of success, FALSE otherwise.
2115 # @ingroup l1_auxiliary
2116 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
2117 # Pattern: 5.---------.6
2122 # (0,0,1) 4.---------.7 |
2129 # (0,0,0) 0.---------.3
2130 pattern_prism = "!!! Nb of points: \n 8 \n\
2140 !!! Indices of points of 2 prisms: \n\
2144 pattern = self.smeshpyD.GetPattern()
2145 isDone = pattern.LoadFromFile(pattern_prism)
2147 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
2150 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
2151 isDone = pattern.MakeMesh(self.mesh, False, False)
2152 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
2154 # Splits quafrangle faces near triangular facets of volumes
2155 self.SplitQuadsNearTriangularFacets()
2159 ## Smoothes elements
2160 # @param IDsOfElements the list if ids of elements to smooth
2161 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2162 # Note that nodes built on edges and boundary nodes are always fixed.
2163 # @param MaxNbOfIterations the maximum number of iterations
2164 # @param MaxAspectRatio varies in range [1.0, inf]
2165 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2166 # @return TRUE in case of success, FALSE otherwise.
2167 # @ingroup l2_modif_smooth
2168 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
2169 MaxNbOfIterations, MaxAspectRatio, Method):
2170 if IDsOfElements == []:
2171 IDsOfElements = self.GetElementsId()
2172 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
2173 MaxNbOfIterations, MaxAspectRatio, Method)
2175 ## Smoothes elements which belong to the given object
2176 # @param theObject the object to smooth
2177 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2178 # Note that nodes built on edges and boundary nodes are always fixed.
2179 # @param MaxNbOfIterations the maximum number of iterations
2180 # @param MaxAspectRatio varies in range [1.0, inf]
2181 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2182 # @return TRUE in case of success, FALSE otherwise.
2183 # @ingroup l2_modif_smooth
2184 def SmoothObject(self, theObject, IDsOfFixedNodes,
2185 MaxNbOfIterations, MaxAspectRatio, Method):
2186 if ( isinstance( theObject, Mesh )):
2187 theObject = theObject.GetMesh()
2188 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
2189 MaxNbOfIterations, MaxAspectRatio, Method)
2191 ## Parametrically smoothes the given elements
2192 # @param IDsOfElements the list if ids of elements to smooth
2193 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2194 # Note that nodes built on edges and boundary nodes are always fixed.
2195 # @param MaxNbOfIterations the maximum number of iterations
2196 # @param MaxAspectRatio varies in range [1.0, inf]
2197 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2198 # @return TRUE in case of success, FALSE otherwise.
2199 # @ingroup l2_modif_smooth
2200 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
2201 MaxNbOfIterations, MaxAspectRatio, Method):
2202 if IDsOfElements == []:
2203 IDsOfElements = self.GetElementsId()
2204 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
2205 MaxNbOfIterations, MaxAspectRatio, Method)
2207 ## Parametrically smoothes the elements which belong to the given object
2208 # @param theObject the object to smooth
2209 # @param IDsOfFixedNodes the list of ids of fixed nodes.
2210 # Note that nodes built on edges and boundary nodes are always fixed.
2211 # @param MaxNbOfIterations the maximum number of iterations
2212 # @param MaxAspectRatio varies in range [1.0, inf]
2213 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
2214 # @return TRUE in case of success, FALSE otherwise.
2215 # @ingroup l2_modif_smooth
2216 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
2217 MaxNbOfIterations, MaxAspectRatio, Method):
2218 if ( isinstance( theObject, Mesh )):
2219 theObject = theObject.GetMesh()
2220 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
2221 MaxNbOfIterations, MaxAspectRatio, Method)
2223 ## Converts the mesh to quadratic, deletes old elements, replacing
2224 # them with quadratic with the same id.
2225 # @ingroup l2_modif_tofromqu
2226 def ConvertToQuadratic(self, theForce3d):
2227 self.editor.ConvertToQuadratic(theForce3d)
2229 ## Converts the mesh from quadratic to ordinary,
2230 # deletes old quadratic elements, \n replacing
2231 # them with ordinary mesh elements with the same id.
2232 # @return TRUE in case of success, FALSE otherwise.
2233 # @ingroup l2_modif_tofromqu
2234 def ConvertFromQuadratic(self):
2235 return self.editor.ConvertFromQuadratic()
2237 ## Renumber mesh nodes
2238 # @ingroup l2_modif_renumber
2239 def RenumberNodes(self):
2240 self.editor.RenumberNodes()
2242 ## Renumber mesh elements
2243 # @ingroup l2_modif_renumber
2244 def RenumberElements(self):
2245 self.editor.RenumberElements()
2247 ## Generates new elements by rotation of the elements around the axis
2248 # @param IDsOfElements the list of ids of elements to sweep
2249 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2250 # @param AngleInRadians the angle of Rotation
2251 # @param NbOfSteps the number of steps
2252 # @param Tolerance tolerance
2253 # @param MakeGroups forces the generation of new groups from existing ones
2254 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2255 # of all steps, else - size of each step
2256 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2257 # @ingroup l2_modif_extrurev
2258 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
2259 MakeGroups=False, TotalAngle=False):
2260 if IDsOfElements == []:
2261 IDsOfElements = self.GetElementsId()
2262 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2263 Axis = self.smeshpyD.GetAxisStruct(Axis)
2264 if TotalAngle and NbOfSteps:
2265 AngleInRadians /= NbOfSteps
2267 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
2268 AngleInRadians, NbOfSteps, Tolerance)
2269 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
2272 ## Generates new elements by rotation of the elements of object around the axis
2273 # @param theObject object which elements should be sweeped
2274 # @param Axis the axis of rotation, AxisStruct or line(geom object)
2275 # @param AngleInRadians the angle of Rotation
2276 # @param NbOfSteps number of steps
2277 # @param Tolerance tolerance
2278 # @param MakeGroups forces the generation of new groups from existing ones
2279 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
2280 # of all steps, else - size of each step
2281 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2282 # @ingroup l2_modif_extrurev
2283 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
2284 MakeGroups=False, TotalAngle=False):
2285 if ( isinstance( theObject, Mesh )):
2286 theObject = theObject.GetMesh()
2287 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2288 Axis = self.smeshpyD.GetAxisStruct(Axis)
2289 if TotalAngle and NbOfSteps:
2290 AngleInRadians /= NbOfSteps
2292 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
2293 NbOfSteps, Tolerance)
2294 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
2297 ## Generates new elements by extrusion of the elements with given ids
2298 # @param IDsOfElements the list of elements ids for extrusion
2299 # @param StepVector vector, defining the direction and value of extrusion
2300 # @param NbOfSteps the number of steps
2301 # @param MakeGroups forces the generation of new groups from existing ones
2302 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2303 # @ingroup l2_modif_extrurev
2304 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
2305 if IDsOfElements == []:
2306 IDsOfElements = self.GetElementsId()
2307 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2308 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2310 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
2311 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
2314 ## Generates new elements by extrusion of the elements with given ids
2315 # @param IDsOfElements is ids of elements
2316 # @param StepVector vector, defining the direction and value of extrusion
2317 # @param NbOfSteps the number of steps
2318 # @param ExtrFlags sets flags for extrusion
2319 # @param SewTolerance uses for comparing locations of nodes if flag
2320 # EXTRUSION_FLAG_SEW is set
2321 # @param MakeGroups forces the generation of new groups from existing ones
2322 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2323 # @ingroup l2_modif_extrurev
2324 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
2325 ExtrFlags, SewTolerance, MakeGroups=False):
2326 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2327 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2329 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
2330 ExtrFlags, SewTolerance)
2331 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
2332 ExtrFlags, SewTolerance)
2335 ## Generates new elements by extrusion of the elements which belong to the object
2336 # @param theObject the object which elements should be processed
2337 # @param StepVector vector, defining the direction and value of extrusion
2338 # @param NbOfSteps the number of steps
2339 # @param MakeGroups forces the generation of new groups from existing ones
2340 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2341 # @ingroup l2_modif_extrurev
2342 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2343 if ( isinstance( theObject, Mesh )):
2344 theObject = theObject.GetMesh()
2345 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2346 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2348 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2349 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2352 ## Generates new elements by extrusion of the elements which belong to the object
2353 # @param theObject object which elements should be processed
2354 # @param StepVector vector, defining the direction and value of extrusion
2355 # @param NbOfSteps the number of steps
2356 # @param MakeGroups to generate new groups from existing ones
2357 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2358 # @ingroup l2_modif_extrurev
2359 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2360 if ( isinstance( theObject, Mesh )):
2361 theObject = theObject.GetMesh()
2362 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2363 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2365 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2366 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2369 ## Generates new elements by extrusion of the elements which belong to the object
2370 # @param theObject object which elements should be processed
2371 # @param StepVector vector, defining the direction and value of extrusion
2372 # @param NbOfSteps the number of steps
2373 # @param MakeGroups forces the generation of new groups from existing ones
2374 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2375 # @ingroup l2_modif_extrurev
2376 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2377 if ( isinstance( theObject, Mesh )):
2378 theObject = theObject.GetMesh()
2379 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2380 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2382 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2383 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2386 ## Generates new elements by extrusion of the given elements
2387 # The path of extrusion must be a meshed edge.
2388 # @param IDsOfElements ids of elements
2389 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2390 # @param PathShape shape(edge) defines the sub-mesh for the path
2391 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2392 # @param HasAngles allows the shape to be rotated around the path
2393 # to get the resulting mesh in a helical fashion
2394 # @param Angles list of angles
2395 # @param HasRefPoint allows using the reference point
2396 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2397 # The User can specify any point as the Reference Point.
2398 # @param MakeGroups forces the generation of new groups from existing ones
2399 # @param LinearVariation forces the computation of rotation angles as linear
2400 # variation of the given Angles along path steps
2401 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2402 # only SMESH::Extrusion_Error otherwise
2403 # @ingroup l2_modif_extrurev
2404 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2405 HasAngles, Angles, HasRefPoint, RefPoint,
2406 MakeGroups=False, LinearVariation=False):
2407 if IDsOfElements == []:
2408 IDsOfElements = self.GetElementsId()
2409 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2410 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2412 if ( isinstance( PathMesh, Mesh )):
2413 PathMesh = PathMesh.GetMesh()
2414 if HasAngles and Angles and LinearVariation:
2415 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2418 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2419 PathShape, NodeStart, HasAngles,
2420 Angles, HasRefPoint, RefPoint)
2421 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2422 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2424 ## Generates new elements by extrusion of the elements which belong to the object
2425 # The path of extrusion must be a meshed edge.
2426 # @param theObject the object which elements should be processed
2427 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2428 # @param PathShape shape(edge) defines the sub-mesh for the path
2429 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2430 # @param HasAngles allows the shape to be rotated around the path
2431 # to get the resulting mesh in a helical fashion
2432 # @param Angles list of angles
2433 # @param HasRefPoint allows using the reference point
2434 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2435 # The User can specify any point as the Reference Point.
2436 # @param MakeGroups forces the generation of new groups from existing ones
2437 # @param LinearVariation forces the computation of rotation angles as linear
2438 # variation of the given Angles along path steps
2439 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2440 # only SMESH::Extrusion_Error otherwise
2441 # @ingroup l2_modif_extrurev
2442 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2443 HasAngles, Angles, HasRefPoint, RefPoint,
2444 MakeGroups=False, LinearVariation=False):
2445 if ( isinstance( theObject, Mesh )):
2446 theObject = theObject.GetMesh()
2447 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2448 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2449 if ( isinstance( PathMesh, Mesh )):
2450 PathMesh = PathMesh.GetMesh()
2451 if HasAngles and Angles and LinearVariation:
2452 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2455 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2456 PathShape, NodeStart, HasAngles,
2457 Angles, HasRefPoint, RefPoint)
2458 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2459 NodeStart, HasAngles, Angles, HasRefPoint,
2462 ## Creates a symmetrical copy of mesh elements
2463 # @param IDsOfElements list of elements ids
2464 # @param Mirror is AxisStruct or geom object(point, line, plane)
2465 # @param theMirrorType is POINT, AXIS or PLANE
2466 # If the Mirror is a geom object this parameter is unnecessary
2467 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2468 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2469 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2470 # @ingroup l2_modif_trsf
2471 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2472 if IDsOfElements == []:
2473 IDsOfElements = self.GetElementsId()
2474 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2475 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2476 if Copy and MakeGroups:
2477 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2478 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2481 ## Creates a new mesh by a symmetrical copy of mesh elements
2482 # @param IDsOfElements the list of elements ids
2483 # @param Mirror is AxisStruct or geom object (point, line, plane)
2484 # @param theMirrorType is POINT, AXIS or PLANE
2485 # If the Mirror is a geom object this parameter is unnecessary
2486 # @param MakeGroups to generate new groups from existing ones
2487 # @param NewMeshName a name of the new mesh to create
2488 # @return instance of Mesh class
2489 # @ingroup l2_modif_trsf
2490 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2491 if IDsOfElements == []:
2492 IDsOfElements = self.GetElementsId()
2493 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2494 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2495 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2496 MakeGroups, NewMeshName)
2497 return Mesh(self.smeshpyD,self.geompyD,mesh)
2499 ## Creates a symmetrical copy of the object
2500 # @param theObject mesh, submesh or group
2501 # @param Mirror AxisStruct or geom object (point, line, plane)
2502 # @param theMirrorType is POINT, AXIS or PLANE
2503 # If the Mirror is a geom object this parameter is unnecessary
2504 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2505 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2506 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2507 # @ingroup l2_modif_trsf
2508 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2509 if ( isinstance( theObject, Mesh )):
2510 theObject = theObject.GetMesh()
2511 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2512 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2513 if Copy and MakeGroups:
2514 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2515 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2518 ## Creates a new mesh by a symmetrical copy of the object
2519 # @param theObject mesh, submesh or group
2520 # @param Mirror AxisStruct or geom object (point, line, plane)
2521 # @param theMirrorType POINT, AXIS or PLANE
2522 # If the Mirror is a geom object this parameter is unnecessary
2523 # @param MakeGroups forces the generation of new groups from existing ones
2524 # @param NewMeshName the name of the new mesh to create
2525 # @return instance of Mesh class
2526 # @ingroup l2_modif_trsf
2527 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2528 if ( isinstance( theObject, Mesh )):
2529 theObject = theObject.GetMesh()
2530 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2531 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2532 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2533 MakeGroups, NewMeshName)
2534 return Mesh( self.smeshpyD,self.geompyD,mesh )
2536 ## Translates the elements
2537 # @param IDsOfElements list of elements ids
2538 # @param Vector the direction of translation (DirStruct or vector)
2539 # @param Copy allows copying the translated elements
2540 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2541 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2542 # @ingroup l2_modif_trsf
2543 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2544 if IDsOfElements == []:
2545 IDsOfElements = self.GetElementsId()
2546 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2547 Vector = self.smeshpyD.GetDirStruct(Vector)
2548 if Copy and MakeGroups:
2549 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2550 self.editor.Translate(IDsOfElements, Vector, Copy)
2553 ## Creates a new mesh of translated elements
2554 # @param IDsOfElements list of elements ids
2555 # @param Vector the direction of translation (DirStruct or vector)
2556 # @param MakeGroups forces the generation of new groups from existing ones
2557 # @param NewMeshName the name of the newly created mesh
2558 # @return instance of Mesh class
2559 # @ingroup l2_modif_trsf
2560 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2561 if IDsOfElements == []:
2562 IDsOfElements = self.GetElementsId()
2563 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2564 Vector = self.smeshpyD.GetDirStruct(Vector)
2565 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2566 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2568 ## Translates the object
2569 # @param theObject the object to translate (mesh, submesh, or group)
2570 # @param Vector direction of translation (DirStruct or geom vector)
2571 # @param Copy allows copying the translated elements
2572 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2573 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2574 # @ingroup l2_modif_trsf
2575 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2576 if ( isinstance( theObject, Mesh )):
2577 theObject = theObject.GetMesh()
2578 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2579 Vector = self.smeshpyD.GetDirStruct(Vector)
2580 if Copy and MakeGroups:
2581 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2582 self.editor.TranslateObject(theObject, Vector, Copy)
2585 ## Creates a new mesh from the translated object
2586 # @param theObject the object to translate (mesh, submesh, or group)
2587 # @param Vector the direction of translation (DirStruct or geom vector)
2588 # @param MakeGroups forces the generation of new groups from existing ones
2589 # @param NewMeshName the name of the newly created mesh
2590 # @return instance of Mesh class
2591 # @ingroup l2_modif_trsf
2592 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2593 if (isinstance(theObject, Mesh)):
2594 theObject = theObject.GetMesh()
2595 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2596 Vector = self.smeshpyD.GetDirStruct(Vector)
2597 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2598 return Mesh( self.smeshpyD, self.geompyD, mesh )
2600 ## Rotates the elements
2601 # @param IDsOfElements list of elements ids
2602 # @param Axis the axis of rotation (AxisStruct or geom line)
2603 # @param AngleInRadians the angle of rotation (in radians)
2604 # @param Copy allows copying the rotated elements
2605 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2606 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2607 # @ingroup l2_modif_trsf
2608 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2609 if IDsOfElements == []:
2610 IDsOfElements = self.GetElementsId()
2611 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2612 Axis = self.smeshpyD.GetAxisStruct(Axis)
2613 if Copy and MakeGroups:
2614 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2615 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2618 ## Creates a new mesh of rotated elements
2619 # @param IDsOfElements list of element ids
2620 # @param Axis the axis of rotation (AxisStruct or geom line)
2621 # @param AngleInRadians the angle of rotation (in radians)
2622 # @param MakeGroups forces the generation of new groups from existing ones
2623 # @param NewMeshName the name of the newly created mesh
2624 # @return instance of Mesh class
2625 # @ingroup l2_modif_trsf
2626 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2627 if IDsOfElements == []:
2628 IDsOfElements = self.GetElementsId()
2629 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2630 Axis = self.smeshpyD.GetAxisStruct(Axis)
2631 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2632 MakeGroups, NewMeshName)
2633 return Mesh( self.smeshpyD, self.geompyD, mesh )
2635 ## Rotates the object
2636 # @param theObject the object to rotate( mesh, submesh, or group)
2637 # @param Axis the axis of rotation (AxisStruct or geom line)
2638 # @param AngleInRadians the angle of rotation (in radians)
2639 # @param Copy allows copying the rotated elements
2640 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2641 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2642 # @ingroup l2_modif_trsf
2643 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2644 if (isinstance(theObject, Mesh)):
2645 theObject = theObject.GetMesh()
2646 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2647 Axis = self.smeshpyD.GetAxisStruct(Axis)
2648 if Copy and MakeGroups:
2649 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2650 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2653 ## Creates a new mesh from the rotated object
2654 # @param theObject the object to rotate (mesh, submesh, or group)
2655 # @param Axis the axis of rotation (AxisStruct or geom line)
2656 # @param AngleInRadians the angle of rotation (in radians)
2657 # @param MakeGroups forces the generation of new groups from existing ones
2658 # @param NewMeshName the name of the newly created mesh
2659 # @return instance of Mesh class
2660 # @ingroup l2_modif_trsf
2661 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2662 if (isinstance( theObject, Mesh )):
2663 theObject = theObject.GetMesh()
2664 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2665 Axis = self.smeshpyD.GetAxisStruct(Axis)
2666 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2667 MakeGroups, NewMeshName)
2668 return Mesh( self.smeshpyD, self.geompyD, mesh )
2670 ## Finds groups of ajacent nodes within Tolerance.
2671 # @param Tolerance the value of tolerance
2672 # @return the list of groups of nodes
2673 # @ingroup l2_modif_trsf
2674 def FindCoincidentNodes (self, Tolerance):
2675 return self.editor.FindCoincidentNodes(Tolerance)
2677 ## Finds groups of ajacent nodes within Tolerance.
2678 # @param Tolerance the value of tolerance
2679 # @param SubMeshOrGroup SubMesh or Group
2680 # @return the list of groups of nodes
2681 # @ingroup l2_modif_trsf
2682 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2683 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2686 # @param GroupsOfNodes the list of groups of nodes
2687 # @ingroup l2_modif_trsf
2688 def MergeNodes (self, GroupsOfNodes):
2689 self.editor.MergeNodes(GroupsOfNodes)
2691 ## Finds the elements built on the same nodes.
2692 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2693 # @return a list of groups of equal elements
2694 # @ingroup l2_modif_trsf
2695 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2696 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2698 ## Merges elements in each given group.
2699 # @param GroupsOfElementsID groups of elements for merging
2700 # @ingroup l2_modif_trsf
2701 def MergeElements(self, GroupsOfElementsID):
2702 self.editor.MergeElements(GroupsOfElementsID)
2704 ## Leaves one element and removes all other elements built on the same nodes.
2705 # @ingroup l2_modif_trsf
2706 def MergeEqualElements(self):
2707 self.editor.MergeEqualElements()
2709 ## Sews free borders
2710 # @return SMESH::Sew_Error
2711 # @ingroup l2_modif_trsf
2712 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2713 FirstNodeID2, SecondNodeID2, LastNodeID2,
2714 CreatePolygons, CreatePolyedrs):
2715 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2716 FirstNodeID2, SecondNodeID2, LastNodeID2,
2717 CreatePolygons, CreatePolyedrs)
2719 ## Sews conform free borders
2720 # @return SMESH::Sew_Error
2721 # @ingroup l2_modif_trsf
2722 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2723 FirstNodeID2, SecondNodeID2):
2724 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2725 FirstNodeID2, SecondNodeID2)
2727 ## Sews border to side
2728 # @return SMESH::Sew_Error
2729 # @ingroup l2_modif_trsf
2730 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2731 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2732 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2733 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2735 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2736 # merged with the nodes of elements of Side2.
2737 # The number of elements in theSide1 and in theSide2 must be
2738 # equal and they should have similar nodal connectivity.
2739 # The nodes to merge should belong to side borders and
2740 # the first node should be linked to the second.
2741 # @return SMESH::Sew_Error
2742 # @ingroup l2_modif_trsf
2743 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2744 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2745 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2746 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2747 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2748 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2750 ## Sets new nodes for the given element.
2751 # @param ide the element id
2752 # @param newIDs nodes ids
2753 # @return If the number of nodes does not correspond to the type of element - returns false
2754 # @ingroup l2_modif_edit
2755 def ChangeElemNodes(self, ide, newIDs):
2756 return self.editor.ChangeElemNodes(ide, newIDs)
2758 ## If during the last operation of MeshEditor some nodes were
2759 # created, this method returns the list of their IDs, \n
2760 # if new nodes were not created - returns empty list
2761 # @return the list of integer values (can be empty)
2762 # @ingroup l1_auxiliary
2763 def GetLastCreatedNodes(self):
2764 return self.editor.GetLastCreatedNodes()
2766 ## If during the last operation of MeshEditor some elements were
2767 # created this method returns the list of their IDs, \n
2768 # if new elements were not created - returns empty list
2769 # @return the list of integer values (can be empty)
2770 # @ingroup l1_auxiliary
2771 def GetLastCreatedElems(self):
2772 return self.editor.GetLastCreatedElems()
2774 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2775 # @param theNodes identifiers of nodes to be doubled
2776 # @param theModifiedElems identifiers of elements to be updated by the new (doubled)
2777 # nodes. If list of element identifiers is empty then nodes are doubled but
2778 # they not assigned to elements
2779 # @return TRUE if operation has been completed successfully, FALSE otherwise
2780 # @ingroup l2_modif_edit
2781 def DoubleNodes(self, theNodes, theModifiedElems):
2782 return self.editor.DoubleNodes(theNodes, theModifiedElems)
2784 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2785 # This method provided for convenience works as DoubleNodes() described above.
2786 # @param theNodes identifiers of node to be doubled
2787 # @param theModifiedElems identifiers of elements to be updated
2788 # @return TRUE if operation has been completed successfully, FALSE otherwise
2789 # @ingroup l2_modif_edit
2790 def DoubleNode(self, theNodeId, theModifiedElems):
2791 return self.editor.DoubleNode(theNodeId, theModifiedElems)
2793 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2794 # This method provided for convenience works as DoubleNodes() described above.
2795 # @param theNodes group of nodes to be doubled
2796 # @param theModifiedElems group of elements to be updated.
2797 # @return TRUE if operation has been completed successfully, FALSE otherwise
2798 # @ingroup l2_modif_edit
2799 def DoubleNodeGroup(self, theNodes, theModifiedElems):
2800 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
2802 ## Creates a hole in a mesh by doubling the nodes of some particular elements
2803 # This method provided for convenience works as DoubleNodes() described above.
2804 # @param theNodes list of groups of nodes to be doubled
2805 # @param theModifiedElems list of groups of elements to be updated.
2806 # @return TRUE if operation has been completed successfully, FALSE otherwise
2807 # @ingroup l2_modif_edit
2808 def DoubleNodeGroups(self, theNodes, theModifiedElems):
2809 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
2811 ## The mother class to define algorithm, it is not recommended to use it directly.
2814 # @ingroup l2_algorithms
2815 class Mesh_Algorithm:
2816 # @class Mesh_Algorithm
2817 # @brief Class Mesh_Algorithm
2819 #def __init__(self,smesh):
2827 ## Finds a hypothesis in the study by its type name and parameters.
2828 # Finds only the hypotheses created in smeshpyD engine.
2829 # @return SMESH.SMESH_Hypothesis
2830 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2831 study = smeshpyD.GetCurrentStudy()
2832 #to do: find component by smeshpyD object, not by its data type
2833 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2834 if scomp is not None:
2835 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2836 # Check if the root label of the hypotheses exists
2837 if res and hypRoot is not None:
2838 iter = study.NewChildIterator(hypRoot)
2839 # Check all published hypotheses
2841 hypo_so_i = iter.Value()
2842 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2843 if attr is not None:
2844 anIOR = attr.Value()
2845 hypo_o_i = salome.orb.string_to_object(anIOR)
2846 if hypo_o_i is not None:
2847 # Check if this is a hypothesis
2848 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2849 if hypo_i is not None:
2850 # Check if the hypothesis belongs to current engine
2851 if smeshpyD.GetObjectId(hypo_i) > 0:
2852 # Check if this is the required hypothesis
2853 if hypo_i.GetName() == hypname:
2855 if CompareMethod(hypo_i, args):
2869 ## Finds the algorithm in the study by its type name.
2870 # Finds only the algorithms, which have been created in smeshpyD engine.
2871 # @return SMESH.SMESH_Algo
2872 def FindAlgorithm (self, algoname, smeshpyD):
2873 study = smeshpyD.GetCurrentStudy()
2874 #to do: find component by smeshpyD object, not by its data type
2875 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2876 if scomp is not None:
2877 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2878 # Check if the root label of the algorithms exists
2879 if res and hypRoot is not None:
2880 iter = study.NewChildIterator(hypRoot)
2881 # Check all published algorithms
2883 algo_so_i = iter.Value()
2884 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2885 if attr is not None:
2886 anIOR = attr.Value()
2887 algo_o_i = salome.orb.string_to_object(anIOR)
2888 if algo_o_i is not None:
2889 # Check if this is an algorithm
2890 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2891 if algo_i is not None:
2892 # Checks if the algorithm belongs to the current engine
2893 if smeshpyD.GetObjectId(algo_i) > 0:
2894 # Check if this is the required algorithm
2895 if algo_i.GetName() == algoname:
2908 ## If the algorithm is global, returns 0; \n
2909 # else returns the submesh associated to this algorithm.
2910 def GetSubMesh(self):
2913 ## Returns the wrapped mesher.
2914 def GetAlgorithm(self):
2917 ## Gets the list of hypothesis that can be used with this algorithm
2918 def GetCompatibleHypothesis(self):
2921 mylist = self.algo.GetCompatibleHypothesis()
2924 ## Gets the name of the algorithm
2928 ## Sets the name to the algorithm
2929 def SetName(self, name):
2930 self.mesh.smeshpyD.SetName(self.algo, name)
2932 ## Gets the id of the algorithm
2934 return self.algo.GetId()
2937 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2939 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2940 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2942 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2944 self.Assign(algo, mesh, geom)
2948 def Assign(self, algo, mesh, geom):
2950 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2957 name = GetName(geom)
2959 name = mesh.geompyD.SubShapeName(geom, piece)
2960 mesh.geompyD.addToStudyInFather(piece, geom, name)
2961 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2964 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2965 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2967 def CompareHyp (self, hyp, args):
2968 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2971 def CompareEqualHyp (self, hyp, args):
2975 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2976 UseExisting=0, CompareMethod=""):
2979 if CompareMethod == "": CompareMethod = self.CompareHyp
2980 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2983 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2989 a = a + s + str(args[i])
2993 self.mesh.smeshpyD.SetName(hypo, hyp + a)
2995 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2996 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
3000 # Public class: Mesh_Segment
3001 # --------------------------
3003 ## Class to define a segment 1D algorithm for discretization
3006 # @ingroup l3_algos_basic
3007 class Mesh_Segment(Mesh_Algorithm):
3009 ## Private constructor.
3010 def __init__(self, mesh, geom=0):
3011 Mesh_Algorithm.__init__(self)
3012 self.Create(mesh, geom, "Regular_1D")
3014 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
3015 # @param l for the length of segments that cut an edge
3016 # @param UseExisting if ==true - searches for an existing hypothesis created with
3017 # the same parameters, else (default) - creates a new one
3018 # @param p precision, used for calculation of the number of segments.
3019 # The precision should be a positive, meaningful value within the range [0,1].
3020 # In general, the number of segments is calculated with the formula:
3021 # nb = ceil((edge_length / l) - p)
3022 # Function ceil rounds its argument to the higher integer.
3023 # So, p=0 means rounding of (edge_length / l) to the higher integer,
3024 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
3025 # p=1 means rounding of (edge_length / l) to the lower integer.
3026 # Default value is 1e-07.
3027 # @return an instance of StdMeshers_LocalLength hypothesis
3028 # @ingroup l3_hypos_1dhyps
3029 def LocalLength(self, l, UseExisting=0, p=1e-07):
3030 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
3031 CompareMethod=self.CompareLocalLength)
3037 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
3038 def CompareLocalLength(self, hyp, args):
3039 if IsEqual(hyp.GetLength(), args[0]):
3040 return IsEqual(hyp.GetPrecision(), args[1])
3043 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
3044 # @param n for the number of segments that cut an edge
3045 # @param s for the scale factor (optional)
3046 # @param UseExisting if ==true - searches for an existing hypothesis created with
3047 # the same parameters, else (default) - create a new one
3048 # @return an instance of StdMeshers_NumberOfSegments hypothesis
3049 # @ingroup l3_hypos_1dhyps
3050 def NumberOfSegments(self, n, s=[], UseExisting=0):
3052 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
3053 CompareMethod=self.CompareNumberOfSegments)
3055 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
3056 CompareMethod=self.CompareNumberOfSegments)
3057 hyp.SetDistrType( 1 )
3058 hyp.SetScaleFactor(s)
3059 hyp.SetNumberOfSegments(n)
3063 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
3064 def CompareNumberOfSegments(self, hyp, args):
3065 if hyp.GetNumberOfSegments() == args[0]:
3069 if hyp.GetDistrType() == 1:
3070 if IsEqual(hyp.GetScaleFactor(), args[1]):
3074 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
3075 # @param start defines the length of the first segment
3076 # @param end defines the length of the last segment
3077 # @param UseExisting if ==true - searches for an existing hypothesis created with
3078 # the same parameters, else (default) - creates a new one
3079 # @return an instance of StdMeshers_Arithmetic1D hypothesis
3080 # @ingroup l3_hypos_1dhyps
3081 def Arithmetic1D(self, start, end, UseExisting=0):
3082 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
3083 CompareMethod=self.CompareArithmetic1D)
3084 hyp.SetLength(start, 1)
3085 hyp.SetLength(end , 0)
3089 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
3090 def CompareArithmetic1D(self, hyp, args):
3091 if IsEqual(hyp.GetLength(1), args[0]):
3092 if IsEqual(hyp.GetLength(0), args[1]):
3096 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
3097 # @param start defines the length of the first segment
3098 # @param end defines the length of the last segment
3099 # @param UseExisting if ==true - searches for an existing hypothesis created with
3100 # the same parameters, else (default) - creates a new one
3101 # @return an instance of StdMeshers_StartEndLength hypothesis
3102 # @ingroup l3_hypos_1dhyps
3103 def StartEndLength(self, start, end, UseExisting=0):
3104 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
3105 CompareMethod=self.CompareStartEndLength)
3106 hyp.SetLength(start, 1)
3107 hyp.SetLength(end , 0)
3110 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
3111 def CompareStartEndLength(self, hyp, args):
3112 if IsEqual(hyp.GetLength(1), args[0]):
3113 if IsEqual(hyp.GetLength(0), args[1]):
3117 ## Defines "Deflection1D" hypothesis
3118 # @param d for the deflection
3119 # @param UseExisting if ==true - searches for an existing hypothesis created with
3120 # the same parameters, else (default) - create a new one
3121 # @ingroup l3_hypos_1dhyps
3122 def Deflection1D(self, d, UseExisting=0):
3123 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
3124 CompareMethod=self.CompareDeflection1D)
3125 hyp.SetDeflection(d)
3128 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
3129 def CompareDeflection1D(self, hyp, args):
3130 return IsEqual(hyp.GetDeflection(), args[0])
3132 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
3133 # the opposite side in case of quadrangular faces
3134 # @ingroup l3_hypos_additi
3135 def Propagation(self):
3136 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3138 ## Defines "AutomaticLength" hypothesis
3139 # @param fineness for the fineness [0-1]
3140 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3141 # same parameters, else (default) - create a new one
3142 # @ingroup l3_hypos_1dhyps
3143 def AutomaticLength(self, fineness=0, UseExisting=0):
3144 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
3145 CompareMethod=self.CompareAutomaticLength)
3146 hyp.SetFineness( fineness )
3149 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
3150 def CompareAutomaticLength(self, hyp, args):
3151 return IsEqual(hyp.GetFineness(), args[0])
3153 ## Defines "SegmentLengthAroundVertex" hypothesis
3154 # @param length for the segment length
3155 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
3156 # Any other integer value means that the hypothesis will be set on the
3157 # whole 1D shape, where Mesh_Segment algorithm is assigned.
3158 # @param UseExisting if ==true - searches for an existing hypothesis created with
3159 # the same parameters, else (default) - creates a new one
3160 # @ingroup l3_algos_segmarv
3161 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
3163 store_geom = self.geom
3164 if type(vertex) is types.IntType:
3165 if vertex == 0 or vertex == 1:
3166 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
3174 if self.geom is None:
3175 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
3176 name = GetName(self.geom)
3178 piece = self.mesh.geom
3179 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
3180 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
3181 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
3183 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
3185 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
3186 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
3188 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
3189 CompareMethod=self.CompareLengthNearVertex)
3190 self.geom = store_geom
3191 hyp.SetLength( length )
3194 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
3195 # @ingroup l3_algos_segmarv
3196 def CompareLengthNearVertex(self, hyp, args):
3197 return IsEqual(hyp.GetLength(), args[0])
3199 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
3200 # If the 2D mesher sees that all boundary edges are quadratic,
3201 # it generates quadratic faces, else it generates linear faces using
3202 # medium nodes as if they are vertices.
3203 # The 3D mesher generates quadratic volumes only if all boundary faces
3204 # are quadratic, else it fails.
3206 # @ingroup l3_hypos_additi
3207 def QuadraticMesh(self):
3208 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3211 # Public class: Mesh_CompositeSegment
3212 # --------------------------
3214 ## Defines a segment 1D algorithm for discretization
3216 # @ingroup l3_algos_basic
3217 class Mesh_CompositeSegment(Mesh_Segment):
3219 ## Private constructor.
3220 def __init__(self, mesh, geom=0):
3221 self.Create(mesh, geom, "CompositeSegment_1D")
3224 # Public class: Mesh_Segment_Python
3225 # ---------------------------------
3227 ## Defines a segment 1D algorithm for discretization with python function
3229 # @ingroup l3_algos_basic
3230 class Mesh_Segment_Python(Mesh_Segment):
3232 ## Private constructor.
3233 def __init__(self, mesh, geom=0):
3234 import Python1dPlugin
3235 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
3237 ## Defines "PythonSplit1D" hypothesis
3238 # @param n for the number of segments that cut an edge
3239 # @param func for the python function that calculates the length of all segments
3240 # @param UseExisting if ==true - searches for the existing hypothesis created with
3241 # the same parameters, else (default) - creates a new one
3242 # @ingroup l3_hypos_1dhyps
3243 def PythonSplit1D(self, n, func, UseExisting=0):
3244 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
3245 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
3246 hyp.SetNumberOfSegments(n)
3247 hyp.SetPythonLog10RatioFunction(func)
3250 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
3251 def ComparePythonSplit1D(self, hyp, args):
3252 #if hyp.GetNumberOfSegments() == args[0]:
3253 # if hyp.GetPythonLog10RatioFunction() == args[1]:
3257 # Public class: Mesh_Triangle
3258 # ---------------------------
3260 ## Defines a triangle 2D algorithm
3262 # @ingroup l3_algos_basic
3263 class Mesh_Triangle(Mesh_Algorithm):
3272 ## Private constructor.
3273 def __init__(self, mesh, algoType, geom=0):
3274 Mesh_Algorithm.__init__(self)
3276 self.algoType = algoType
3277 if algoType == MEFISTO:
3278 self.Create(mesh, geom, "MEFISTO_2D")
3280 elif algoType == BLSURF:
3282 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
3283 #self.SetPhysicalMesh() - PAL19680
3284 elif algoType == NETGEN:
3286 print "Warning: NETGENPlugin module unavailable"
3288 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3290 elif algoType == NETGEN_2D:
3292 print "Warning: NETGENPlugin module unavailable"
3294 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
3297 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
3298 # @param area for the maximum area of each triangle
3299 # @param UseExisting if ==true - searches for an existing hypothesis created with the
3300 # same parameters, else (default) - creates a new one
3302 # Only for algoType == MEFISTO || NETGEN_2D
3303 # @ingroup l3_hypos_2dhyps
3304 def MaxElementArea(self, area, UseExisting=0):
3305 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3306 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
3307 CompareMethod=self.CompareMaxElementArea)
3308 elif self.algoType == NETGEN:
3309 hyp = self.Parameters(SIMPLE)
3310 hyp.SetMaxElementArea(area)
3313 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
3314 def CompareMaxElementArea(self, hyp, args):
3315 return IsEqual(hyp.GetMaxElementArea(), args[0])
3317 ## Defines "LengthFromEdges" hypothesis to build triangles
3318 # based on the length of the edges taken from the wire
3320 # Only for algoType == MEFISTO || NETGEN_2D
3321 # @ingroup l3_hypos_2dhyps
3322 def LengthFromEdges(self):
3323 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
3324 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3326 elif self.algoType == NETGEN:
3327 hyp = self.Parameters(SIMPLE)
3328 hyp.LengthFromEdges()
3331 ## Sets a way to define size of mesh elements to generate.
3332 # @param thePhysicalMesh is: DefaultSize or Custom.
3333 # @ingroup l3_hypos_blsurf
3334 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
3335 # Parameter of BLSURF algo
3336 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
3338 ## Sets size of mesh elements to generate.
3339 # @ingroup l3_hypos_blsurf
3340 def SetPhySize(self, theVal):
3341 # Parameter of BLSURF algo
3342 self.Parameters().SetPhySize(theVal)
3344 ## Sets lower boundary of mesh element size (PhySize).
3345 # @ingroup l3_hypos_blsurf
3346 def SetPhyMin(self, theVal=-1):
3347 # Parameter of BLSURF algo
3348 self.Parameters().SetPhyMin(theVal)
3350 ## Sets upper boundary of mesh element size (PhySize).
3351 # @ingroup l3_hypos_blsurf
3352 def SetPhyMax(self, theVal=-1):
3353 # Parameter of BLSURF algo
3354 self.Parameters().SetPhyMax(theVal)
3356 ## Sets a way to define maximum angular deflection of mesh from CAD model.
3357 # @param theGeometricMesh is: DefaultGeom or Custom
3358 # @ingroup l3_hypos_blsurf
3359 def SetGeometricMesh(self, theGeometricMesh=0):
3360 # Parameter of BLSURF algo
3361 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
3362 self.params.SetGeometricMesh(theGeometricMesh)
3364 ## Sets angular deflection (in degrees) of a mesh face from CAD surface.
3365 # @ingroup l3_hypos_blsurf
3366 def SetAngleMeshS(self, theVal=_angleMeshS):
3367 # Parameter of BLSURF algo
3368 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3369 self.params.SetAngleMeshS(theVal)
3371 ## Sets angular deflection (in degrees) of a mesh edge from CAD curve.
3372 # @ingroup l3_hypos_blsurf
3373 def SetAngleMeshC(self, theVal=_angleMeshS):
3374 # Parameter of BLSURF algo
3375 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
3376 self.params.SetAngleMeshC(theVal)
3378 ## Sets lower boundary of mesh element size computed to respect angular deflection.
3379 # @ingroup l3_hypos_blsurf
3380 def SetGeoMin(self, theVal=-1):
3381 # Parameter of BLSURF algo
3382 self.Parameters().SetGeoMin(theVal)
3384 ## Sets upper boundary of mesh element size computed to respect angular deflection.
3385 # @ingroup l3_hypos_blsurf
3386 def SetGeoMax(self, theVal=-1):
3387 # Parameter of BLSURF algo
3388 self.Parameters().SetGeoMax(theVal)
3390 ## Sets maximal allowed ratio between the lengths of two adjacent edges.
3391 # @ingroup l3_hypos_blsurf
3392 def SetGradation(self, theVal=_gradation):
3393 # Parameter of BLSURF algo
3394 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
3395 self.params.SetGradation(theVal)
3397 ## Sets topology usage way.
3398 # @param way defines how mesh conformity is assured <ul>
3399 # <li>FromCAD - mesh conformity is assured by conformity of a shape</li>
3400 # <li>PreProcess or PreProcessPlus - by pre-processing a CAD model</li></ul>
3401 # @ingroup l3_hypos_blsurf
3402 def SetTopology(self, way):
3403 # Parameter of BLSURF algo
3404 self.Parameters().SetTopology(way)
3406 ## To respect geometrical edges or not.
3407 # @ingroup l3_hypos_blsurf
3408 def SetDecimesh(self, toIgnoreEdges=False):
3409 # Parameter of BLSURF algo
3410 self.Parameters().SetDecimesh(toIgnoreEdges)
3412 ## Sets verbosity level in the range 0 to 100.
3413 # @ingroup l3_hypos_blsurf
3414 def SetVerbosity(self, level):
3415 # Parameter of BLSURF algo
3416 self.Parameters().SetVerbosity(level)
3418 ## Sets advanced option value.
3419 # @ingroup l3_hypos_blsurf
3420 def SetOptionValue(self, optionName, level):
3421 # Parameter of BLSURF algo
3422 self.Parameters().SetOptionValue(optionName,level)
3424 ## Sets QuadAllowed flag.
3425 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
3426 # @ingroup l3_hypos_netgen l3_hypos_blsurf
3427 def SetQuadAllowed(self, toAllow=True):
3428 if self.algoType == NETGEN_2D:
3429 if toAllow: # add QuadranglePreference
3430 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
3431 else: # remove QuadranglePreference
3432 for hyp in self.mesh.GetHypothesisList( self.geom ):
3433 if hyp.GetName() == "QuadranglePreference":
3434 self.mesh.RemoveHypothesis( self.geom, hyp )
3439 if self.Parameters():
3440 self.params.SetQuadAllowed(toAllow)
3443 ## Defines hypothesis having several parameters
3445 # @ingroup l3_hypos_netgen
3446 def Parameters(self, which=SOLE):
3449 if self.algoType == NETGEN:
3451 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
3452 "libNETGENEngine.so", UseExisting=0)
3454 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
3455 "libNETGENEngine.so", UseExisting=0)
3457 elif self.algoType == MEFISTO:
3458 print "Mefisto algo support no multi-parameter hypothesis"
3460 elif self.algoType == NETGEN_2D:
3461 print "NETGEN_2D_ONLY algo support no multi-parameter hypothesis"
3462 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3464 elif self.algoType == BLSURF:
3465 self.params = self.Hypothesis("BLSURF_Parameters", [],
3466 "libBLSURFEngine.so", UseExisting=0)
3469 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
3474 # Only for algoType == NETGEN
3475 # @ingroup l3_hypos_netgen
3476 def SetMaxSize(self, theSize):
3477 if self.Parameters():
3478 self.params.SetMaxSize(theSize)
3480 ## Sets SecondOrder flag
3482 # Only for algoType == NETGEN
3483 # @ingroup l3_hypos_netgen
3484 def SetSecondOrder(self, theVal):
3485 if self.Parameters():
3486 self.params.SetSecondOrder(theVal)
3488 ## Sets Optimize flag
3490 # Only for algoType == NETGEN
3491 # @ingroup l3_hypos_netgen
3492 def SetOptimize(self, theVal):
3493 if self.Parameters():
3494 self.params.SetOptimize(theVal)
3497 # @param theFineness is:
3498 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3500 # Only for algoType == NETGEN
3501 # @ingroup l3_hypos_netgen
3502 def SetFineness(self, theFineness):
3503 if self.Parameters():
3504 self.params.SetFineness(theFineness)
3508 # Only for algoType == NETGEN
3509 # @ingroup l3_hypos_netgen
3510 def SetGrowthRate(self, theRate):
3511 if self.Parameters():
3512 self.params.SetGrowthRate(theRate)
3514 ## Sets NbSegPerEdge
3516 # Only for algoType == NETGEN
3517 # @ingroup l3_hypos_netgen
3518 def SetNbSegPerEdge(self, theVal):
3519 if self.Parameters():
3520 self.params.SetNbSegPerEdge(theVal)
3522 ## Sets NbSegPerRadius
3524 # Only for algoType == NETGEN
3525 # @ingroup l3_hypos_netgen
3526 def SetNbSegPerRadius(self, theVal):
3527 if self.Parameters():
3528 self.params.SetNbSegPerRadius(theVal)
3530 ## Sets number of segments overriding value set by SetLocalLength()
3532 # Only for algoType == NETGEN
3533 # @ingroup l3_hypos_netgen
3534 def SetNumberOfSegments(self, theVal):
3535 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3537 ## Sets number of segments overriding value set by SetNumberOfSegments()
3539 # Only for algoType == NETGEN
3540 # @ingroup l3_hypos_netgen
3541 def SetLocalLength(self, theVal):
3542 self.Parameters(SIMPLE).SetLocalLength(theVal)
3547 # Public class: Mesh_Quadrangle
3548 # -----------------------------
3550 ## Defines a quadrangle 2D algorithm
3552 # @ingroup l3_algos_basic
3553 class Mesh_Quadrangle(Mesh_Algorithm):
3555 ## Private constructor.
3556 def __init__(self, mesh, geom=0):
3557 Mesh_Algorithm.__init__(self)
3558 self.Create(mesh, geom, "Quadrangle_2D")
3560 ## Defines "QuadranglePreference" hypothesis, forcing construction
3561 # of quadrangles if the number of nodes on the opposite edges is not the same
3562 # while the total number of nodes on edges is even
3564 # @ingroup l3_hypos_additi
3565 def QuadranglePreference(self):
3566 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3567 CompareMethod=self.CompareEqualHyp)
3570 ## Defines "TrianglePreference" hypothesis, forcing construction
3571 # of triangles in the refinement area if the number of nodes
3572 # on the opposite edges is not the same
3574 # @ingroup l3_hypos_additi
3575 def TrianglePreference(self):
3576 hyp = self.Hypothesis("TrianglePreference", UseExisting=1,
3577 CompareMethod=self.CompareEqualHyp)
3580 # Public class: Mesh_Tetrahedron
3581 # ------------------------------
3583 ## Defines a tetrahedron 3D algorithm
3585 # @ingroup l3_algos_basic
3586 class Mesh_Tetrahedron(Mesh_Algorithm):
3591 ## Private constructor.
3592 def __init__(self, mesh, algoType, geom=0):
3593 Mesh_Algorithm.__init__(self)
3595 if algoType == NETGEN:
3596 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3599 elif algoType == FULL_NETGEN:
3601 print "Warning: NETGENPlugin module has not been imported."
3602 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3605 elif algoType == GHS3D:
3607 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3610 self.algoType = algoType
3612 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3613 # @param vol for the maximum volume of each tetrahedron
3614 # @param UseExisting if ==true - searches for the existing hypothesis created with
3615 # the same parameters, else (default) - creates a new one
3616 # @ingroup l3_hypos_maxvol
3617 def MaxElementVolume(self, vol, UseExisting=0):
3618 if self.algoType == NETGEN:
3619 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3620 CompareMethod=self.CompareMaxElementVolume)
3621 hyp.SetMaxElementVolume(vol)
3623 elif self.algoType == FULL_NETGEN:
3624 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
3627 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3628 def CompareMaxElementVolume(self, hyp, args):
3629 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3631 ## Defines hypothesis having several parameters
3633 # @ingroup l3_hypos_netgen
3634 def Parameters(self, which=SOLE):
3637 if self.algoType == FULL_NETGEN:
3639 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
3640 "libNETGENEngine.so", UseExisting=0)
3642 self.params = self.Hypothesis("NETGEN_Parameters", [],
3643 "libNETGENEngine.so", UseExisting=0)
3645 if self.algoType == GHS3D:
3646 self.params = self.Hypothesis("GHS3D_Parameters", [],
3647 "libGHS3DEngine.so", UseExisting=0)
3650 print "Algo supports no multi-parameter hypothesis"
3654 # Parameter of FULL_NETGEN
3655 # @ingroup l3_hypos_netgen
3656 def SetMaxSize(self, theSize):
3657 self.Parameters().SetMaxSize(theSize)
3659 ## Sets SecondOrder flag
3660 # Parameter of FULL_NETGEN
3661 # @ingroup l3_hypos_netgen
3662 def SetSecondOrder(self, theVal):
3663 self.Parameters().SetSecondOrder(theVal)
3665 ## Sets Optimize flag
3666 # Parameter of FULL_NETGEN
3667 # @ingroup l3_hypos_netgen
3668 def SetOptimize(self, theVal):
3669 self.Parameters().SetOptimize(theVal)
3672 # @param theFineness is:
3673 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3674 # Parameter of FULL_NETGEN
3675 # @ingroup l3_hypos_netgen
3676 def SetFineness(self, theFineness):
3677 self.Parameters().SetFineness(theFineness)
3680 # Parameter of FULL_NETGEN
3681 # @ingroup l3_hypos_netgen
3682 def SetGrowthRate(self, theRate):
3683 self.Parameters().SetGrowthRate(theRate)
3685 ## Sets NbSegPerEdge
3686 # Parameter of FULL_NETGEN
3687 # @ingroup l3_hypos_netgen
3688 def SetNbSegPerEdge(self, theVal):
3689 self.Parameters().SetNbSegPerEdge(theVal)
3691 ## Sets NbSegPerRadius
3692 # Parameter of FULL_NETGEN
3693 # @ingroup l3_hypos_netgen
3694 def SetNbSegPerRadius(self, theVal):
3695 self.Parameters().SetNbSegPerRadius(theVal)
3697 ## Sets number of segments overriding value set by SetLocalLength()
3698 # Only for algoType == NETGEN_FULL
3699 # @ingroup l3_hypos_netgen
3700 def SetNumberOfSegments(self, theVal):
3701 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
3703 ## Sets number of segments overriding value set by SetNumberOfSegments()
3704 # Only for algoType == NETGEN_FULL
3705 # @ingroup l3_hypos_netgen
3706 def SetLocalLength(self, theVal):
3707 self.Parameters(SIMPLE).SetLocalLength(theVal)
3709 ## Defines "MaxElementArea" parameter of NETGEN_SimpleParameters_3D hypothesis.
3710 # Overrides value set by LengthFromEdges()
3711 # Only for algoType == NETGEN_FULL
3712 # @ingroup l3_hypos_netgen
3713 def MaxElementArea(self, area):
3714 self.Parameters(SIMPLE).SetMaxElementArea(area)
3716 ## Defines "LengthFromEdges" parameter of NETGEN_SimpleParameters_3D hypothesis
3717 # Overrides value set by MaxElementArea()
3718 # Only for algoType == NETGEN_FULL
3719 # @ingroup l3_hypos_netgen
3720 def LengthFromEdges(self):
3721 self.Parameters(SIMPLE).LengthFromEdges()
3723 ## Defines "LengthFromFaces" parameter of NETGEN_SimpleParameters_3D hypothesis
3724 # Overrides value set by MaxElementVolume()
3725 # Only for algoType == NETGEN_FULL
3726 # @ingroup l3_hypos_netgen
3727 def LengthFromFaces(self):
3728 self.Parameters(SIMPLE).LengthFromFaces()
3730 ## To mesh "holes" in a solid or not. Default is to mesh.
3731 # @ingroup l3_hypos_ghs3dh
3732 def SetToMeshHoles(self, toMesh):
3733 # Parameter of GHS3D
3734 self.Parameters().SetToMeshHoles(toMesh)
3736 ## Set Optimization level:
3737 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3738 # Default is Medium_Optimization
3739 # @ingroup l3_hypos_ghs3dh
3740 def SetOptimizationLevel(self, level):
3741 # Parameter of GHS3D
3742 self.Parameters().SetOptimizationLevel(level)
3744 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3745 # @ingroup l3_hypos_ghs3dh
3746 def SetMaximumMemory(self, MB):
3747 # Advanced parameter of GHS3D
3748 self.Parameters().SetMaximumMemory(MB)
3750 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3751 # automatic memory adjustment mode.
3752 # @ingroup l3_hypos_ghs3dh
3753 def SetInitialMemory(self, MB):
3754 # Advanced parameter of GHS3D
3755 self.Parameters().SetInitialMemory(MB)
3757 ## Path to working directory.
3758 # @ingroup l3_hypos_ghs3dh
3759 def SetWorkingDirectory(self, path):
3760 # Advanced parameter of GHS3D
3761 self.Parameters().SetWorkingDirectory(path)
3763 ## To keep working files or remove them. Log file remains in case of errors anyway.
3764 # @ingroup l3_hypos_ghs3dh
3765 def SetKeepFiles(self, toKeep):
3766 # Advanced parameter of GHS3D
3767 self.Parameters().SetKeepFiles(toKeep)
3769 ## To set verbose level [0-10]. <ul>
3770 #<li> 0 - no standard output,
3771 #<li> 2 - prints the data, quality statistics of the skin and final meshes and
3772 # indicates when the final mesh is being saved. In addition the software
3773 # gives indication regarding the CPU time.
3774 #<li>10 - same as 2 plus the main steps in the computation, quality statistics
3775 # histogram of the skin mesh, quality statistics histogram together with
3776 # the characteristics of the final mesh.</ul>
3777 # @ingroup l3_hypos_ghs3dh
3778 def SetVerboseLevel(self, level):
3779 # Advanced parameter of GHS3D
3780 self.Parameters().SetVerboseLevel(level)
3782 ## To create new nodes.
3783 # @ingroup l3_hypos_ghs3dh
3784 def SetToCreateNewNodes(self, toCreate):
3785 # Advanced parameter of GHS3D
3786 self.Parameters().SetToCreateNewNodes(toCreate)
3788 ## To use boundary recovery version which tries to create mesh on a very poor
3789 # quality surface mesh.
3790 # @ingroup l3_hypos_ghs3dh
3791 def SetToUseBoundaryRecoveryVersion(self, toUse):
3792 # Advanced parameter of GHS3D
3793 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
3795 ## Sets command line option as text.
3796 # @ingroup l3_hypos_ghs3dh
3797 def SetTextOption(self, option):
3798 # Advanced parameter of GHS3D
3799 self.Parameters().SetTextOption(option)
3801 # Public class: Mesh_Hexahedron
3802 # ------------------------------
3804 ## Defines a hexahedron 3D algorithm
3806 # @ingroup l3_algos_basic
3807 class Mesh_Hexahedron(Mesh_Algorithm):
3812 ## Private constructor.
3813 def __init__(self, mesh, algoType=Hexa, geom=0):
3814 Mesh_Algorithm.__init__(self)
3816 self.algoType = algoType
3818 if algoType == Hexa:
3819 self.Create(mesh, geom, "Hexa_3D")
3822 elif algoType == Hexotic:
3823 import HexoticPlugin
3824 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3827 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3828 # @ingroup l3_hypos_hexotic
3829 def MinMaxQuad(self, min=3, max=8, quad=True):
3830 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3832 self.params.SetHexesMinLevel(min)
3833 self.params.SetHexesMaxLevel(max)
3834 self.params.SetHexoticQuadrangles(quad)
3837 # Deprecated, only for compatibility!
3838 # Public class: Mesh_Netgen
3839 # ------------------------------
3841 ## Defines a NETGEN-based 2D or 3D algorithm
3842 # that needs no discrete boundary (i.e. independent)
3844 # This class is deprecated, only for compatibility!
3847 # @ingroup l3_algos_basic
3848 class Mesh_Netgen(Mesh_Algorithm):
3852 ## Private constructor.
3853 def __init__(self, mesh, is3D, geom=0):
3854 Mesh_Algorithm.__init__(self)
3857 print "Warning: NETGENPlugin module has not been imported."
3861 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3865 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3868 ## Defines the hypothesis containing parameters of the algorithm
3869 def Parameters(self):
3871 hyp = self.Hypothesis("NETGEN_Parameters", [],
3872 "libNETGENEngine.so", UseExisting=0)
3874 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3875 "libNETGENEngine.so", UseExisting=0)
3878 # Public class: Mesh_Projection1D
3879 # ------------------------------
3881 ## Defines a projection 1D algorithm
3882 # @ingroup l3_algos_proj
3884 class Mesh_Projection1D(Mesh_Algorithm):
3886 ## Private constructor.
3887 def __init__(self, mesh, geom=0):
3888 Mesh_Algorithm.__init__(self)
3889 self.Create(mesh, geom, "Projection_1D")
3891 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3892 # a mesh pattern is taken, and, optionally, the association of vertices
3893 # between the source edge and a target edge (to which a hypothesis is assigned)
3894 # @param edge from which nodes distribution is taken
3895 # @param mesh from which nodes distribution is taken (optional)
3896 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3897 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3898 # to associate with \a srcV (optional)
3899 # @param UseExisting if ==true - searches for the existing hypothesis created with
3900 # the same parameters, else (default) - creates a new one
3901 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3902 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3904 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3905 hyp.SetSourceEdge( edge )
3906 if not mesh is None and isinstance(mesh, Mesh):
3907 mesh = mesh.GetMesh()
3908 hyp.SetSourceMesh( mesh )
3909 hyp.SetVertexAssociation( srcV, tgtV )
3912 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3913 #def CompareSourceEdge(self, hyp, args):
3914 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3918 # Public class: Mesh_Projection2D
3919 # ------------------------------
3921 ## Defines a projection 2D algorithm
3922 # @ingroup l3_algos_proj
3924 class Mesh_Projection2D(Mesh_Algorithm):
3926 ## Private constructor.
3927 def __init__(self, mesh, geom=0):
3928 Mesh_Algorithm.__init__(self)
3929 self.Create(mesh, geom, "Projection_2D")
3931 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3932 # a mesh pattern is taken, and, optionally, the association of vertices
3933 # between the source face and the target face (to which a hypothesis is assigned)
3934 # @param face from which the mesh pattern is taken
3935 # @param mesh from which the mesh pattern is taken (optional)
3936 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3937 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3938 # to associate with \a srcV1 (optional)
3939 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3940 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3941 # to associate with \a srcV2 (optional)
3942 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3943 # the same parameters, else (default) - forces the creation a new one
3945 # Note: all association vertices must belong to one edge of a face
3946 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3947 srcV2=None, tgtV2=None, UseExisting=0):
3948 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3950 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3951 hyp.SetSourceFace( face )
3952 if not mesh is None and isinstance(mesh, Mesh):
3953 mesh = mesh.GetMesh()
3954 hyp.SetSourceMesh( mesh )
3955 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3958 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3959 #def CompareSourceFace(self, hyp, args):
3960 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3963 # Public class: Mesh_Projection3D
3964 # ------------------------------
3966 ## Defines a projection 3D algorithm
3967 # @ingroup l3_algos_proj
3969 class Mesh_Projection3D(Mesh_Algorithm):
3971 ## Private constructor.
3972 def __init__(self, mesh, geom=0):
3973 Mesh_Algorithm.__init__(self)
3974 self.Create(mesh, geom, "Projection_3D")
3976 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3977 # the mesh pattern is taken, and, optionally, the association of vertices
3978 # between the source and the target solid (to which a hipothesis is assigned)
3979 # @param solid from where the mesh pattern is taken
3980 # @param mesh from where the mesh pattern is taken (optional)
3981 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3982 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3983 # to associate with \a srcV1 (optional)
3984 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3985 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3986 # to associate with \a srcV2 (optional)
3987 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3988 # the same parameters, else (default) - creates a new one
3990 # Note: association vertices must belong to one edge of a solid
3991 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3992 srcV2=0, tgtV2=0, UseExisting=0):
3993 hyp = self.Hypothesis("ProjectionSource3D",
3994 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3996 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3997 hyp.SetSource3DShape( solid )
3998 if not mesh is None and isinstance(mesh, Mesh):
3999 mesh = mesh.GetMesh()
4000 hyp.SetSourceMesh( mesh )
4001 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
4004 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
4005 #def CompareSourceShape3D(self, hyp, args):
4006 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
4010 # Public class: Mesh_Prism
4011 # ------------------------
4013 ## Defines a 3D extrusion algorithm
4014 # @ingroup l3_algos_3dextr
4016 class Mesh_Prism3D(Mesh_Algorithm):
4018 ## Private constructor.
4019 def __init__(self, mesh, geom=0):
4020 Mesh_Algorithm.__init__(self)
4021 self.Create(mesh, geom, "Prism_3D")
4023 # Public class: Mesh_RadialPrism
4024 # -------------------------------
4026 ## Defines a Radial Prism 3D algorithm
4027 # @ingroup l3_algos_radialp
4029 class Mesh_RadialPrism3D(Mesh_Algorithm):
4031 ## Private constructor.
4032 def __init__(self, mesh, geom=0):
4033 Mesh_Algorithm.__init__(self)
4034 self.Create(mesh, geom, "RadialPrism_3D")
4036 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
4037 self.nbLayers = None
4039 ## Return 3D hypothesis holding the 1D one
4040 def Get3DHypothesis(self):
4041 return self.distribHyp
4043 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
4044 # hypothesis. Returns the created hypothesis
4045 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
4046 #print "OwnHypothesis",hypType
4047 if not self.nbLayers is None:
4048 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
4049 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
4050 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
4051 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
4052 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
4053 self.distribHyp.SetLayerDistribution( hyp )
4056 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
4057 # prisms to build between the inner and outer shells
4058 # @param n number of layers
4059 # @param UseExisting if ==true - searches for the existing hypothesis created with
4060 # the same parameters, else (default) - creates a new one
4061 def NumberOfLayers(self, n, UseExisting=0):
4062 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
4063 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
4064 CompareMethod=self.CompareNumberOfLayers)
4065 self.nbLayers.SetNumberOfLayers( n )
4066 return self.nbLayers
4068 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
4069 def CompareNumberOfLayers(self, hyp, args):
4070 return IsEqual(hyp.GetNumberOfLayers(), args[0])
4072 ## Defines "LocalLength" hypothesis, specifying the segment length
4073 # to build between the inner and the outer shells
4074 # @param l the length of segments
4075 # @param p the precision of rounding
4076 def LocalLength(self, l, p=1e-07):
4077 hyp = self.OwnHypothesis("LocalLength", [l,p])
4082 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
4083 # prisms to build between the inner and the outer shells.
4084 # @param n the number of layers
4085 # @param s the scale factor (optional)
4086 def NumberOfSegments(self, n, s=[]):
4088 hyp = self.OwnHypothesis("NumberOfSegments", [n])
4090 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
4091 hyp.SetDistrType( 1 )
4092 hyp.SetScaleFactor(s)
4093 hyp.SetNumberOfSegments(n)
4096 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
4097 # to build between the inner and the outer shells with a length that changes in arithmetic progression
4098 # @param start the length of the first segment
4099 # @param end the length of the last segment
4100 def Arithmetic1D(self, start, end ):
4101 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
4102 hyp.SetLength(start, 1)
4103 hyp.SetLength(end , 0)
4106 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
4107 # to build between the inner and the outer shells as geometric length increasing
4108 # @param start for the length of the first segment
4109 # @param end for the length of the last segment
4110 def StartEndLength(self, start, end):
4111 hyp = self.OwnHypothesis("StartEndLength", [start, end])
4112 hyp.SetLength(start, 1)
4113 hyp.SetLength(end , 0)
4116 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
4117 # to build between the inner and outer shells
4118 # @param fineness defines the quality of the mesh within the range [0-1]
4119 def AutomaticLength(self, fineness=0):
4120 hyp = self.OwnHypothesis("AutomaticLength")
4121 hyp.SetFineness( fineness )
4124 # Private class: Mesh_UseExisting
4125 # -------------------------------
4126 class Mesh_UseExisting(Mesh_Algorithm):
4128 def __init__(self, dim, mesh, geom=0):
4130 self.Create(mesh, geom, "UseExisting_1D")
4132 self.Create(mesh, geom, "UseExisting_2D")