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
30 # To get started, please, have a look at smeshDC::smeshDC documentation
31 # for general services of smesh package
32 # You can also find the smeshDC::smeshDC documentation by the first
33 # item in the Data Structures list on this page.
34 # See also the list of Data Structures and the list of Functions
35 # for other classes and methods of smesh python interface.
41 import SMESH # This is necessary for back compatibility
48 # import NETGENPlugin module if possible
67 NETGEN_1D2D3D = FULL_NETGEN
68 NETGEN_FULL = FULL_NETGEN
73 # MirrorType enumeration
74 POINT = SMESH_MeshEditor.POINT
75 AXIS = SMESH_MeshEditor.AXIS
76 PLANE = SMESH_MeshEditor.PLANE
78 # Smooth_Method enumeration
79 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
80 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
82 # Fineness enumeration (for NETGEN)
90 # Optimization level of GHS3D
91 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
93 # Topology treatment way of BLSURF
94 FromCAD, PreProcess, PreProcessPlus = 0,1,2
96 # Element size flag of BLSURF
97 DefaultSize, DefaultGeom, Custom = 0,0,1
99 PrecisionConfusion = 1e-07
101 def IsEqual(val1, val2, tol=PrecisionConfusion):
102 if abs(val1 - val2) < tol:
110 ior = salome.orb.object_to_string(obj)
111 sobj = salome.myStudy.FindObjectIOR(ior)
115 attr = sobj.FindAttribute("AttributeName")[1]
118 ## Sets a name to the object
119 def SetName(obj, name):
120 ior = salome.orb.object_to_string(obj)
121 sobj = salome.myStudy.FindObjectIOR(ior)
123 attr = sobj.FindAttribute("AttributeName")[1]
126 ## Prints error message if a hypothesis was not assigned.
127 def TreatHypoStatus(status, hypName, geomName, isAlgo):
129 hypType = "algorithm"
131 hypType = "hypothesis"
133 if status == HYP_UNKNOWN_FATAL :
134 reason = "for unknown reason"
135 elif status == HYP_INCOMPATIBLE :
136 reason = "this hypothesis mismatches the algorithm"
137 elif status == HYP_NOTCONFORM :
138 reason = "a non-conform mesh would be built"
139 elif status == HYP_ALREADY_EXIST :
140 reason = hypType + " of the same dimension is already assigned to this shape"
141 elif status == HYP_BAD_DIM :
142 reason = hypType + " mismatches the shape"
143 elif status == HYP_CONCURENT :
144 reason = "there are concurrent hypotheses on sub-shapes"
145 elif status == HYP_BAD_SUBSHAPE :
146 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
147 elif status == HYP_BAD_GEOMETRY:
148 reason = "geometry mismatches the expectation of the algorithm"
149 elif status == HYP_HIDDEN_ALGO:
150 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
151 elif status == HYP_HIDING_ALGO:
152 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
155 hypName = '"' + hypName + '"'
156 geomName= '"' + geomName+ '"'
157 if status < HYP_UNKNOWN_FATAL:
158 print hypName, "was assigned to", geomName,"but", reason
160 print hypName, "was not assigned to",geomName,":", reason
163 ## Converts an angle from degrees to radians
164 def DegreesToRadians(AngleInDegrees):
166 return AngleInDegrees * pi / 180.0
168 ## Methods of the package smesh.py provide general services of MESH component.
170 # All methods of this class are accessible directly from the smesh.py package.
171 # Use these methods to create an empty mesh, to import the mesh from file,
172 # and to create patterns and filtering criteria.
173 class smeshDC(SMESH._objref_SMESH_Gen):
175 ## Sets the current study and Geometry component
176 def init_smesh(self,theStudy,geompyD):
178 self.SetGeomEngine(geompyD)
179 self.SetCurrentStudy(theStudy)
181 ## Creates an empty Mesh. This mesh can have an underlying geometry.
182 # @param obj the Geometrical object on which the mesh is built. If not defined,
183 # the mesh will have no underlying geometry.
184 # @param name the name for the new mesh.
185 # @return an instance of Mesh class.
186 def Mesh(self, obj=0, name=0):
187 return Mesh(self,self.geompyD,obj,name)
189 ## Returns a long value from enumeration
190 # Should be used for SMESH.FunctorType enumeration
191 def EnumToLong(self,theItem):
194 ## Gets PointStruct from vertex
195 # @param theVertex a GEOM object(vertex)
196 # @return SMESH.PointStruct
197 def GetPointStruct(self,theVertex):
198 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
199 return PointStruct(x,y,z)
201 ## Gets DirStruct from vector
202 # @param theVector a GEOM object(vector)
203 # @return SMESH.DirStruct
204 def GetDirStruct(self,theVector):
205 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
206 if(len(vertices) != 2):
207 print "Error: vector object is incorrect."
209 p1 = self.geompyD.PointCoordinates(vertices[0])
210 p2 = self.geompyD.PointCoordinates(vertices[1])
211 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
212 dirst = DirStruct(pnt)
215 ## Makes DirStruct from a triplet
216 # @param x,y,z vector components
217 # @return SMESH.DirStruct
218 def MakeDirStruct(self,x,y,z):
219 pnt = PointStruct(x,y,z)
220 return DirStruct(pnt)
222 ## Get AxisStruct from object
223 # @param theObj a GEOM object (line or plane)
224 # @return SMESH.AxisStruct
225 def GetAxisStruct(self,theObj):
226 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
228 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
229 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
230 vertex1 = self.geompyD.PointCoordinates(vertex1)
231 vertex2 = self.geompyD.PointCoordinates(vertex2)
232 vertex3 = self.geompyD.PointCoordinates(vertex3)
233 vertex4 = self.geompyD.PointCoordinates(vertex4)
234 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
235 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
236 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] ]
237 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
239 elif len(edges) == 1:
240 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
241 p1 = self.geompyD.PointCoordinates( vertex1 )
242 p2 = self.geompyD.PointCoordinates( vertex2 )
243 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
247 # From SMESH_Gen interface:
248 # ------------------------
250 ## Sets the current mode
251 def SetEmbeddedMode( self,theMode ):
252 #self.SetEmbeddedMode(theMode)
253 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
255 ## Gets the current mode
256 def IsEmbeddedMode(self):
257 #return self.IsEmbeddedMode()
258 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
260 ## Sets the current study
261 def SetCurrentStudy( self, theStudy ):
262 #self.SetCurrentStudy(theStudy)
263 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
265 ## Gets the current study
266 def GetCurrentStudy(self):
267 #return self.GetCurrentStudy()
268 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
270 ## Creates a Mesh object importing data from the given UNV file
271 # @return an instance of Mesh class
272 def CreateMeshesFromUNV( self,theFileName ):
273 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
274 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
277 ## Creates a Mesh object(s) importing data from the given MED file
278 # @return a list of Mesh class instances
279 def CreateMeshesFromMED( self,theFileName ):
280 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
282 for iMesh in range(len(aSmeshMeshes)) :
283 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
284 aMeshes.append(aMesh)
285 return aMeshes, aStatus
287 ## Creates a Mesh object importing data from the given STL file
288 # @return an instance of Mesh class
289 def CreateMeshesFromSTL( self, theFileName ):
290 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
291 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
294 ## From SMESH_Gen interface
295 # @return the list of integer values
296 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
297 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
299 ## From SMESH_Gen interface. Creates a pattern
300 # @return an instance of SMESH_Pattern
301 def GetPattern(self):
302 return SMESH._objref_SMESH_Gen.GetPattern(self)
305 # Filtering. Auxiliary functions:
306 # ------------------------------
308 ## Creates an empty criterion
309 # @return SMESH.Filter.Criterion
310 def GetEmptyCriterion(self):
311 Type = self.EnumToLong(FT_Undefined)
312 Compare = self.EnumToLong(FT_Undefined)
316 UnaryOp = self.EnumToLong(FT_Undefined)
317 BinaryOp = self.EnumToLong(FT_Undefined)
320 Precision = -1 ##@1e-07
321 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
322 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
324 ## Creates a criterion by the given parameters
325 # @param elementType the type of elements(NODE, EDGE, FACE, VOLUME)
326 # @param CritType the type of criterion (FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc.)
327 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
328 # @param Treshold the threshold value (range of ids as string, shape, numeric)
329 # @param UnaryOp FT_LogicalNOT or FT_Undefined
330 # @param BinaryOp a binary logical operation FT_LogicalAND, FT_LogicalOR or
331 # FT_Undefined (must be for the last criterion of all criteria)
332 # @return SMESH.Filter.Criterion
333 def GetCriterion(self,elementType,
335 Compare = FT_EqualTo,
337 UnaryOp=FT_Undefined,
338 BinaryOp=FT_Undefined):
339 aCriterion = self.GetEmptyCriterion()
340 aCriterion.TypeOfElement = elementType
341 aCriterion.Type = self.EnumToLong(CritType)
345 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
346 aCriterion.Compare = self.EnumToLong(Compare)
347 elif Compare == "=" or Compare == "==":
348 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
350 aCriterion.Compare = self.EnumToLong(FT_LessThan)
352 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
354 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
357 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
358 FT_BelongToCylinder, FT_LyingOnGeom]:
359 # Checks the treshold
360 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
361 aCriterion.ThresholdStr = GetName(aTreshold)
362 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
364 print "Error: The treshold should be a shape."
366 elif CritType == FT_RangeOfIds:
367 # Checks the treshold
368 if isinstance(aTreshold, str):
369 aCriterion.ThresholdStr = aTreshold
371 print "Error: The treshold should be a string."
373 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
374 # At this point the treshold is unnecessary
375 if aTreshold == FT_LogicalNOT:
376 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
377 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
378 aCriterion.BinaryOp = aTreshold
382 aTreshold = float(aTreshold)
383 aCriterion.Threshold = aTreshold
385 print "Error: The treshold should be a number."
388 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
389 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
391 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
392 aCriterion.BinaryOp = self.EnumToLong(Treshold)
394 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
395 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
397 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
398 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
402 ## Creates a filter with the given parameters
403 # @param elementType the type of elements in the group
404 # @param CritType the type of criterion ( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
405 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
406 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
407 # @param UnaryOp FT_LogicalNOT or FT_Undefined
408 # @return SMESH_Filter
409 def GetFilter(self,elementType,
410 CritType=FT_Undefined,
413 UnaryOp=FT_Undefined):
414 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
415 aFilterMgr = self.CreateFilterManager()
416 aFilter = aFilterMgr.CreateFilter()
418 aCriteria.append(aCriterion)
419 aFilter.SetCriteria(aCriteria)
422 ## Creates a numerical functor by its type
423 # @param theCriterion FT_...; functor type
424 # @return SMESH_NumericalFunctor
425 def GetFunctor(self,theCriterion):
426 aFilterMgr = self.CreateFilterManager()
427 if theCriterion == FT_AspectRatio:
428 return aFilterMgr.CreateAspectRatio()
429 elif theCriterion == FT_AspectRatio3D:
430 return aFilterMgr.CreateAspectRatio3D()
431 elif theCriterion == FT_Warping:
432 return aFilterMgr.CreateWarping()
433 elif theCriterion == FT_MinimumAngle:
434 return aFilterMgr.CreateMinimumAngle()
435 elif theCriterion == FT_Taper:
436 return aFilterMgr.CreateTaper()
437 elif theCriterion == FT_Skew:
438 return aFilterMgr.CreateSkew()
439 elif theCriterion == FT_Area:
440 return aFilterMgr.CreateArea()
441 elif theCriterion == FT_Volume3D:
442 return aFilterMgr.CreateVolume3D()
443 elif theCriterion == FT_MultiConnection:
444 return aFilterMgr.CreateMultiConnection()
445 elif theCriterion == FT_MultiConnection2D:
446 return aFilterMgr.CreateMultiConnection2D()
447 elif theCriterion == FT_Length:
448 return aFilterMgr.CreateLength()
449 elif theCriterion == FT_Length2D:
450 return aFilterMgr.CreateLength2D()
452 print "Error: given parameter is not numerucal functor type."
455 #Registering the new proxy for SMESH_Gen
456 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
462 ## This class allows defining and managing a mesh.
463 # It has a set of methods to build a mesh on the given geometry, including the definition of sub-meshes.
464 # It also has methods to define groups of mesh elements, to modify a mesh (by addition of
465 # new nodes and elements and by changing the existing entities), to get information
466 # about a mesh and to export a mesh into different formats.
475 # Creates a mesh on the shape \a obj (or an empty mesh if \a obj is equal to 0) and
476 # sets the GUI name of this mesh to \a name.
477 # @param obj Shape to be meshed or SMESH_Mesh object
478 # @param name Study name of the mesh
479 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
480 self.smeshpyD=smeshpyD
485 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
487 self.mesh = self.smeshpyD.CreateMesh(self.geom)
488 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
491 self.mesh = self.smeshpyD.CreateEmptyMesh()
493 SetName(self.mesh, name)
495 SetName(self.mesh, GetName(obj))
497 self.editor = self.mesh.GetMeshEditor()
499 ## Initializes the Mesh object from an instance of SMESH_Mesh interface
500 # @param theMesh a SMESH_Mesh object
501 def SetMesh(self, theMesh):
503 self.geom = self.mesh.GetShapeToMesh()
505 ## Returns the mesh, that is an instance of SMESH_Mesh interface
506 # @return a SMESH_Mesh object
510 ## Gets the name of the mesh
511 # @return the name of the mesh as a string
513 name = GetName(self.GetMesh())
516 ## Sets a name to the mesh
517 # @param name a new name of the mesh
518 def SetName(self, name):
519 SetName(self.GetMesh(), name)
521 ## Gets the subMesh object associated to a \a theSubObject geometrical object.
522 # The subMesh object gives access to the IDs of nodes and elements.
523 # @param theSubObject a geometrical object (shape)
524 # @return an object of type SMESH_SubMesh, representing a part of mesh, which lies on the given shape
525 def GetSubMesh(self, theSubObject, name):
526 submesh = self.mesh.GetSubMesh(theSubObject, name)
529 ## Returns the shape associated to the mesh
530 # @return a GEOM_Object
534 ## Associates the given shape to the mesh (entails the recreation of the mesh)
535 # @param geom the shape to be meshed (GEOM_Object)
536 def SetShape(self, geom):
537 self.mesh = self.smeshpyD.CreateMesh(geom)
539 ## Returns true if the hypotheses are defined well
540 # @param theSubObject a subshape of a mesh shape
541 # @return True or False
542 def IsReadyToCompute(self, theSubObject):
543 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
545 ## Returns errors of hypotheses definition.
546 # The list of errors is empty if everything is OK.
547 # @param theSubObject a subshape of a mesh shape
548 # @return a list of errors
549 def GetAlgoState(self, theSubObject):
550 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
552 ## Returns a geometrical object on which the given element was built.
553 # The returned geometrical object, if not nil, is either found in the
554 # study or published by this method with the given name
555 # @param theElementID the id of the mesh element
556 # @param theGeomName the user-defined name of the geometrical object
557 # @return GEOM::GEOM_Object instance
558 def GetGeometryByMeshElement(self, theElementID, theGeomName):
559 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
561 ## Returns the mesh dimension depending on the dimension of the underlying shape
562 # @return mesh dimension as an integer value [0,3]
563 def MeshDimension(self):
564 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
565 if len( shells ) > 0 :
567 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
569 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
575 ## Creates a segment discretization 1D algorithm.
576 # If the optional \a algo parameter is not set, this algorithm is REGULAR.
577 # \n If the optional \a geom parameter is not set, this algorithm is global.
578 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
579 # @param algo the type of the required algorithm. Possible values are:
581 # - smesh.PYTHON for discretization via a python function,
582 # - smesh.COMPOSITE for meshing a set of edges on one face side as a whole.
583 # @param geom If defined is the subshape to be meshed
584 # @return an instance of Mesh_Segment or Mesh_Segment_Python, or Mesh_CompositeSegment class
585 def Segment(self, algo=REGULAR, geom=0):
586 ## if Segment(geom) is called by mistake
587 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
588 algo, geom = geom, algo
589 if not algo: algo = REGULAR
592 return Mesh_Segment(self, geom)
594 return Mesh_Segment_Python(self, geom)
595 elif algo == COMPOSITE:
596 return Mesh_CompositeSegment(self, geom)
598 return Mesh_Segment(self, geom)
600 ## Enables creation of nodes and segments usable by 2D algoritms.
601 # The added nodes and segments must be bound to edges and vertices by
602 # SetNodeOnVertex(), SetNodeOnEdge() and SetMeshElementOnShape()
603 # If the optional \a geom parameter is not set, this algorithm is global.
604 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
605 # @param geom the subshape to be manually meshed
606 # @return StdMeshers_UseExisting_1D algorithm that generates nothing
607 def UseExistingSegments(self, geom=0):
608 algo = Mesh_UseExisting(1,self,geom)
609 return algo.GetAlgorithm()
611 ## Enables creation of nodes and faces usable by 3D algoritms.
612 # The added nodes and faces must be bound to geom faces by SetNodeOnFace()
613 # and SetMeshElementOnShape()
614 # If the optional \a geom parameter is not set, this algorithm is global.
615 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
616 # @param geom the subshape to be manually meshed
617 # @return StdMeshers_UseExisting_2D algorithm that generates nothing
618 def UseExistingFaces(self, geom=0):
619 algo = Mesh_UseExisting(2,self,geom)
620 return algo.GetAlgorithm()
622 ## Creates a triangle 2D algorithm for faces.
623 # If the optional \a geom parameter is not set, this algorithm is global.
624 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
625 # @param algo values are: smesh.MEFISTO || smesh.NETGEN_1D2D || smesh.NETGEN_2D || smesh.BLSURF
626 # @param geom If defined, the subshape to be meshed (GEOM_Object)
627 # @return an instance of Mesh_Triangle algorithm
628 def Triangle(self, algo=MEFISTO, geom=0):
629 ## if Triangle(geom) is called by mistake
630 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
634 return Mesh_Triangle(self, algo, geom)
636 ## Creates a quadrangle 2D algorithm for faces.
637 # If the optional \a geom parameter is not set, this algorithm is global.
638 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
639 # @param geom If defined, the subshape to be meshed (GEOM_Object)
640 # @return an instance of Mesh_Quadrangle algorithm
641 def Quadrangle(self, geom=0):
642 return Mesh_Quadrangle(self, geom)
644 ## Creates a tetrahedron 3D algorithm for solids.
645 # The parameter \a algo permits to choose the algorithm: NETGEN or GHS3D
646 # If the optional \a geom parameter is not set, this algorithm is global.
647 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
648 # @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
649 # @param geom If defined, the subshape to be meshed (GEOM_Object)
650 # @return an instance of Mesh_Tetrahedron algorithm
651 def Tetrahedron(self, algo=NETGEN, geom=0):
652 ## if Tetrahedron(geom) is called by mistake
653 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
654 algo, geom = geom, algo
655 if not algo: algo = NETGEN
657 return Mesh_Tetrahedron(self, algo, geom)
659 ## Creates a hexahedron 3D algorithm for solids.
660 # If the optional \a geom parameter is not set, this algorithm is global.
661 # \n Otherwise, this algorithm defines a submesh based on \a geom subshape.
662 # @param algo possible values are: smesh.Hexa, smesh.Hexotic
663 # @param geom If defined, the subshape to be meshed (GEOM_Object)
664 # @return an instance of Mesh_Hexahedron algorithm
665 def Hexahedron(self, algo=Hexa, geom=0):
666 ## if Hexahedron(geom, algo) or Hexahedron(geom) is called by mistake
667 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
668 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
669 elif geom == 0: algo, geom = Hexa, algo
670 return Mesh_Hexahedron(self, algo, geom)
672 ## Deprecated, used only for compatibility!
673 # @return an instance of Mesh_Netgen algorithm
674 def Netgen(self, is3D, geom=0):
675 return Mesh_Netgen(self, is3D, geom)
677 ## Creates a projection 1D algorithm for edges.
678 # If the optional \a geom parameter is not set, this algorithm is global.
679 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
680 # @param geom If defined, the subshape to be meshed
681 # @return an instance of Mesh_Projection1D algorithm
682 def Projection1D(self, geom=0):
683 return Mesh_Projection1D(self, geom)
685 ## Creates a projection 2D algorithm for faces.
686 # If the optional \a geom parameter is not set, this algorithm is global.
687 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
688 # @param geom If defined, the subshape to be meshed
689 # @return an instance of Mesh_Projection2D algorithm
690 def Projection2D(self, geom=0):
691 return Mesh_Projection2D(self, geom)
693 ## Creates a projection 3D algorithm for solids.
694 # If the optional \a geom parameter is not set, this algorithm is global.
695 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
696 # @param geom If defined, the subshape to be meshed
697 # @return an instance of Mesh_Projection3D algorithm
698 def Projection3D(self, geom=0):
699 return Mesh_Projection3D(self, geom)
701 ## Creates a 3D extrusion (Prism 3D) or RadialPrism 3D algorithm for solids.
702 # If the optional \a geom parameter is not set, this algorithm is global.
703 # Otherwise, this algorithm defines a submesh based on \a geom subshape.
704 # @param geom If defined, the subshape to be meshed
705 # @return an instance of Mesh_Prism3D or Mesh_RadialPrism3D algorithm
706 def Prism(self, geom=0):
710 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
711 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
712 if nbSolids == 0 or nbSolids == nbShells:
713 return Mesh_Prism3D(self, geom)
714 return Mesh_RadialPrism3D(self, geom)
716 ## Computes the mesh and returns the status of the computation
717 # @return True or False
718 def Compute(self, geom=0):
719 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
721 print "Compute impossible: mesh is not constructed on geom shape."
727 ok = self.smeshpyD.Compute(self.mesh, geom)
728 except SALOME.SALOME_Exception, ex:
729 print "Mesh computation failed, exception caught:"
730 print " ", ex.details.text
733 print "Mesh computation failed, exception caught:"
734 traceback.print_exc()
736 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
747 reason = '%s %sD algorithm is missing' % (glob, dim)
748 elif err.state == HYP_MISSING:
749 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
750 % (glob, dim, name, dim))
751 elif err.state == HYP_NOTCONFORM:
752 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
753 elif err.state == HYP_BAD_PARAMETER:
754 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
755 % ( glob, dim, name ))
756 elif err.state == HYP_BAD_GEOMETRY:
757 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
758 'geometry' % ( glob, dim, name ))
760 reason = "For unknown reason."+\
761 " Revise Mesh.Compute() implementation in smeshDC.py!"
769 print '"' + GetName(self.mesh) + '"',"has not been computed:"
772 print '"' + GetName(self.mesh) + '"',"has not been computed."
775 if salome.sg.hasDesktop():
776 smeshgui = salome.ImportComponentGUI("SMESH")
777 smeshgui.Init(salome.myStudyId)
778 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
779 salome.sg.updateObjBrowser(1)
783 ## Computes a tetrahedral mesh using AutomaticLength + MEFISTO + NETGEN
784 # The parameter \a fineness [0,-1] defines mesh fineness
785 # @return True or False
786 def AutomaticTetrahedralization(self, fineness=0):
787 dim = self.MeshDimension()
789 self.RemoveGlobalHypotheses()
790 self.Segment().AutomaticLength(fineness)
792 self.Triangle().LengthFromEdges()
795 self.Tetrahedron(NETGEN)
797 return self.Compute()
799 ## Computes an hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
800 # The parameter \a fineness [0,-1] defines mesh fineness
801 # @return True or False
802 def AutomaticHexahedralization(self, fineness=0):
803 dim = self.MeshDimension()
804 # assign the hypotheses
805 self.RemoveGlobalHypotheses()
806 self.Segment().AutomaticLength(fineness)
813 return self.Compute()
815 ## Assigns a hypothesis
816 # @param hyp a hypothesis to assign
817 # @param geom a subhape of mesh geometry
818 # @return SMESH.Hypothesis_Status
819 def AddHypothesis(self, hyp, geom=0):
820 if isinstance( hyp, Mesh_Algorithm ):
821 hyp = hyp.GetAlgorithm()
826 status = self.mesh.AddHypothesis(geom, hyp)
827 isAlgo = hyp._narrow( SMESH_Algo )
828 TreatHypoStatus( status, GetName( hyp ), GetName( geom ), isAlgo )
831 ## Unassigns a hypothesis
832 # @param hyp a hypothesis to unassign
833 # @param geom a subshape of mesh geometry
834 # @return SMESH.Hypothesis_Status
835 def RemoveHypothesis(self, hyp, geom=0):
836 if isinstance( hyp, Mesh_Algorithm ):
837 hyp = hyp.GetAlgorithm()
842 status = self.mesh.RemoveHypothesis(geom, hyp)
845 ## Gets the list of hypotheses added on a geometry
846 # @param geom a subshape of mesh geometry
847 # @return the sequence of SMESH_Hypothesis
848 def GetHypothesisList(self, geom):
849 return self.mesh.GetHypothesisList( geom )
851 ## Removes all global hypotheses
852 def RemoveGlobalHypotheses(self):
853 current_hyps = self.mesh.GetHypothesisList( self.geom )
854 for hyp in current_hyps:
855 self.mesh.RemoveHypothesis( self.geom, hyp )
859 ## Creates a mesh group based on the geometric object \a grp
860 # and gives a \a name, \n if this parameter is not defined
861 # the name is the same as the geometric group name \n
862 # Note: Works like GroupOnGeom().
863 # @param grp a geometric group, a vertex, an edge, a face or a solid
864 # @param name the name of the mesh group
865 # @return SMESH_GroupOnGeom
866 def Group(self, grp, name=""):
867 return self.GroupOnGeom(grp, name)
869 ## Deprecated, used only for compatibility! Please, use ExportMED() method instead.
870 # Exports the mesh in a file in MED format and chooses the \a version of MED format
871 # @param f the file name
872 # @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
873 def ExportToMED(self, f, version, opt=0):
874 self.mesh.ExportToMED(f, opt, version)
876 ## Exports the mesh in a file in MED format
877 # @param f is the file name
878 # @param auto_groups boolean parameter for creating/not creating
879 # the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
880 # the typical use is auto_groups=false.
881 # @param version MED format version(MED_V2_1 or MED_V2_2)
882 def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
883 self.mesh.ExportToMED(f, auto_groups, version)
885 ## Exports the mesh in a file in DAT format
886 # @param f the file name
887 def ExportDAT(self, f):
888 self.mesh.ExportDAT(f)
890 ## Exports the mesh in a file in UNV format
891 # @param f the file name
892 def ExportUNV(self, f):
893 self.mesh.ExportUNV(f)
895 ## Export the mesh in a file in STL format
896 # @param f the file name
897 # @param ascii defines the file encoding
898 def ExportSTL(self, f, ascii=1):
899 self.mesh.ExportSTL(f, ascii)
902 # Operations with groups:
903 # ----------------------
905 ## Creates an empty mesh group
906 # @param elementType the type of elements in the group
907 # @param name the name of the mesh group
908 # @return SMESH_Group
909 def CreateEmptyGroup(self, elementType, name):
910 return self.mesh.CreateGroup(elementType, name)
912 ## Creates a mesh group based on the geometrical object \a grp
913 # and gives a \a name, \n if this parameter is not defined
914 # the name is the same as the geometrical group name
915 # @param grp a geometrical group, a vertex, an edge, a face or a solid
916 # @param name the name of the mesh group
917 # @return SMESH_GroupOnGeom
918 def GroupOnGeom(self, grp, name="", typ=None):
923 tgeo = str(grp.GetShapeType())
930 elif tgeo == "SOLID":
932 elif tgeo == "SHELL":
934 elif tgeo == "COMPOUND":
935 if len( self.geompyD.GetObjectIDs( grp )) == 0:
936 print "Mesh.Group: empty geometric group", GetName( grp )
938 tgeo = self.geompyD.GetType(grp)
939 if tgeo == geompyDC.ShapeType["VERTEX"]:
941 elif tgeo == geompyDC.ShapeType["EDGE"]:
943 elif tgeo == geompyDC.ShapeType["FACE"]:
945 elif tgeo == geompyDC.ShapeType["SOLID"]:
949 print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
952 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
954 ## Creates a mesh group by the given ids of elements
955 # @param groupName the name of the mesh group
956 # @param elementType the type of elements in the group
957 # @param elemIDs the list of ids
958 # @return SMESH_Group
959 def MakeGroupByIds(self, groupName, elementType, elemIDs):
960 group = self.mesh.CreateGroup(elementType, groupName)
964 ## Creates a mesh group by the given conditions
965 # @param groupName the name of the mesh group
966 # @param elementType the type of elements in the group
967 # @param CritType the type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
968 # @param Compare belongs to {FT_LessThan, FT_MoreThan, FT_EqualTo}
969 # @param Treshold the threshold value (range of id ids as string, shape, numeric)
970 # @param UnaryOp FT_LogicalNOT or FT_Undefined
971 # @return SMESH_Group
975 CritType=FT_Undefined,
978 UnaryOp=FT_Undefined):
979 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
980 group = self.MakeGroupByCriterion(groupName, aCriterion)
983 ## Creates a mesh group by the given criterion
984 # @param groupName the name of the mesh group
985 # @param Criterion the instance of Criterion class
986 # @return SMESH_Group
987 def MakeGroupByCriterion(self, groupName, Criterion):
988 aFilterMgr = self.smeshpyD.CreateFilterManager()
989 aFilter = aFilterMgr.CreateFilter()
991 aCriteria.append(Criterion)
992 aFilter.SetCriteria(aCriteria)
993 group = self.MakeGroupByFilter(groupName, aFilter)
996 ## Creates a mesh group by the given criteria (list of criteria)
997 # @param groupName the name of the mesh group
998 # @param Criteria the list of criteria
999 # @return SMESH_Group
1000 def MakeGroupByCriteria(self, groupName, theCriteria):
1001 aFilterMgr = self.smeshpyD.CreateFilterManager()
1002 aFilter = aFilterMgr.CreateFilter()
1003 aFilter.SetCriteria(theCriteria)
1004 group = self.MakeGroupByFilter(groupName, aFilter)
1007 ## Creates a mesh group by the given filter
1008 # @param groupName the name of the mesh group
1009 # @param Criterion the instance of Filter class
1010 # @return SMESH_Group
1011 def MakeGroupByFilter(self, groupName, theFilter):
1012 anIds = theFilter.GetElementsId(self.mesh)
1013 anElemType = theFilter.GetElementType()
1014 group = self.MakeGroupByIds(groupName, anElemType, anIds)
1017 ## Passes mesh elements through the given filter and return IDs of fitting elements
1018 # @param theFilter SMESH_Filter
1019 # @return a list of ids
1020 def GetIdsFromFilter(self, theFilter):
1021 return theFilter.GetElementsId(self.mesh)
1023 ## Verifies whether a 2D mesh element has free edges (edges connected to one face only)\n
1024 # Returns a list of special structures (borders).
1025 # @return a list of SMESH.FreeEdges.Border structure: edge id and ids of two its nodes.
1026 def GetFreeBorders(self):
1027 aFilterMgr = self.smeshpyD.CreateFilterManager()
1028 aPredicate = aFilterMgr.CreateFreeEdges()
1029 aPredicate.SetMesh(self.mesh)
1030 aBorders = aPredicate.GetBorders()
1034 def RemoveGroup(self, group):
1035 self.mesh.RemoveGroup(group)
1037 ## Removes a group with its contents
1038 def RemoveGroupWithContents(self, group):
1039 self.mesh.RemoveGroupWithContents(group)
1041 ## Gets the list of groups existing in the mesh
1042 # @return a sequence of SMESH_GroupBase
1043 def GetGroups(self):
1044 return self.mesh.GetGroups()
1046 ## Gets the number of groups existing in the mesh
1047 # @return the quantity of groups as an integer value
1049 return self.mesh.NbGroups()
1051 ## Gets the list of names of groups existing in the mesh
1052 # @return list of strings
1053 def GetGroupNames(self):
1054 groups = self.GetGroups()
1056 for group in groups:
1057 names.append(group.GetName())
1060 ## Produces a union of two groups
1061 # A new group is created. All mesh elements that are
1062 # present in the initial groups are added to the new one
1063 # @return an instance of SMESH_Group
1064 def UnionGroups(self, group1, group2, name):
1065 return self.mesh.UnionGroups(group1, group2, name)
1067 ## Prodices an intersection of two groups
1068 # A new group is created. All mesh elements that are common
1069 # for the two initial groups are added to the new one.
1070 # @return an instance of SMESH_Group
1071 def IntersectGroups(self, group1, group2, name):
1072 return self.mesh.IntersectGroups(group1, group2, name)
1074 ## Produces a cut of two groups
1075 # A new group is created. All mesh elements that are present in
1076 # the main group but are not present in the tool group are added to the new one
1077 # @return an instance of SMESH_Group
1078 def CutGroups(self, mainGroup, toolGroup, name):
1079 return self.mesh.CutGroups(mainGroup, toolGroup, name)
1082 # Get some info about mesh:
1083 # ------------------------
1085 ## Returns the log of nodes and elements added or removed
1086 # since the previous clear of the log.
1087 # @param clearAfterGet log is emptied after Get (safe if concurrents access)
1088 # @return list of log_block structures:
1093 def GetLog(self, clearAfterGet):
1094 return self.mesh.GetLog(clearAfterGet)
1096 ## Clears the log of nodes and elements added or removed since the previous
1097 # clear. Must be used immediately after GetLog if clearAfterGet is false.
1099 self.mesh.ClearLog()
1101 ## Toggles auto color mode on the object.
1102 # @param theAutoColor the flag which toggles auto color mode.
1103 def SetAutoColor(self, theAutoColor):
1104 self.mesh.SetAutoColor(theAutoColor)
1106 ## Gets flag of object auto color mode.
1107 # @return True or False
1108 def GetAutoColor(self):
1109 return self.mesh.GetAutoColor()
1111 ## Gets the internal ID
1112 # @return integer value, which is the internal Id of the mesh
1114 return self.mesh.GetId()
1117 # @return integer value, which is the study Id of the mesh
1118 def GetStudyId(self):
1119 return self.mesh.GetStudyId()
1121 ## Checks the group names for duplications.
1122 # Consider the maximum group name length stored in MED file.
1123 # @return True or False
1124 def HasDuplicatedGroupNamesMED(self):
1125 return self.mesh.HasDuplicatedGroupNamesMED()
1127 ## Obtains the mesh editor tool
1128 # @return an instance of SMESH_MeshEditor
1129 def GetMeshEditor(self):
1130 return self.mesh.GetMeshEditor()
1133 # @return an instance of SALOME_MED::MESH
1134 def GetMEDMesh(self):
1135 return self.mesh.GetMEDMesh()
1138 # Get informations about mesh contents:
1139 # ------------------------------------
1141 ## Returns the number of nodes in the mesh
1142 # @return an integer value
1144 return self.mesh.NbNodes()
1146 ## Returns the number of elements in the mesh
1147 # @return an integer value
1148 def NbElements(self):
1149 return self.mesh.NbElements()
1151 ## Returns the number of edges in the mesh
1152 # @return an integer value
1154 return self.mesh.NbEdges()
1156 ## Returns the number of edges with the given order in the mesh
1157 # @param elementOrder the order of elements:
1158 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1159 # @return an integer value
1160 def NbEdgesOfOrder(self, elementOrder):
1161 return self.mesh.NbEdgesOfOrder(elementOrder)
1163 ## Returns the number of faces in the mesh
1164 # @return an integer value
1166 return self.mesh.NbFaces()
1168 ## Returns the number of faces with the given order in the mesh
1169 # @param elementOrder the order of elements:
1170 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1171 # @return an integer value
1172 def NbFacesOfOrder(self, elementOrder):
1173 return self.mesh.NbFacesOfOrder(elementOrder)
1175 ## Returns the number of triangles in the mesh
1176 # @return an integer value
1177 def NbTriangles(self):
1178 return self.mesh.NbTriangles()
1180 ## Returns the number of triangles with the given order in the mesh
1181 # @param elementOrder is the order of elements:
1182 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1183 # @return an integer value
1184 def NbTrianglesOfOrder(self, elementOrder):
1185 return self.mesh.NbTrianglesOfOrder(elementOrder)
1187 ## Returns the number of quadrangles in the mesh
1188 # @return an integer value
1189 def NbQuadrangles(self):
1190 return self.mesh.NbQuadrangles()
1192 ## Returns the number of quadrangles with the given order in the mesh
1193 # @param elementOrder the order of elements:
1194 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1195 # @return an integer value
1196 def NbQuadranglesOfOrder(self, elementOrder):
1197 return self.mesh.NbQuadranglesOfOrder(elementOrder)
1199 ## Returns the number of polygons in the mesh
1200 # @return an integer value
1201 def NbPolygons(self):
1202 return self.mesh.NbPolygons()
1204 ## Returns the number of volumes in the mesh
1205 # @return an integer value
1206 def NbVolumes(self):
1207 return self.mesh.NbVolumes()
1209 ## Returns the number of volumes with the given order in the mesh
1210 # @param elementOrder the order of elements:
1211 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1212 # @return an integer value
1213 def NbVolumesOfOrder(self, elementOrder):
1214 return self.mesh.NbVolumesOfOrder(elementOrder)
1216 ## Returns the number of tetrahedrons in the mesh
1217 # @return an integer value
1219 return self.mesh.NbTetras()
1221 ## Returns the number of tetrahedrons with the given order in the mesh
1222 # @param elementOrder the order of elements:
1223 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1224 # @return an integer value
1225 def NbTetrasOfOrder(self, elementOrder):
1226 return self.mesh.NbTetrasOfOrder(elementOrder)
1228 ## Returns the number of hexahedrons in the mesh
1229 # @return an integer value
1231 return self.mesh.NbHexas()
1233 ## Returns the number of hexahedrons with the given order in the mesh
1234 # @param elementOrder the order of elements:
1235 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1236 # @return an integer value
1237 def NbHexasOfOrder(self, elementOrder):
1238 return self.mesh.NbHexasOfOrder(elementOrder)
1240 ## Returns the number of pyramids in the mesh
1241 # @return an integer value
1242 def NbPyramids(self):
1243 return self.mesh.NbPyramids()
1245 ## Returns the number of pyramids with the given order in the mesh
1246 # @param elementOrder the order of elements:
1247 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1248 # @return an integer value
1249 def NbPyramidsOfOrder(self, elementOrder):
1250 return self.mesh.NbPyramidsOfOrder(elementOrder)
1252 ## Returns the number of prisms in the mesh
1253 # @return an integer value
1255 return self.mesh.NbPrisms()
1257 ## Returns the number of prisms with the given order in the mesh
1258 # @param elementOrder the order of elements:
1259 # ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1260 # @return an integer value
1261 def NbPrismsOfOrder(self, elementOrder):
1262 return self.mesh.NbPrismsOfOrder(elementOrder)
1264 ## Returns the number of polyhedrons in the mesh
1265 # @return an integer value
1266 def NbPolyhedrons(self):
1267 return self.mesh.NbPolyhedrons()
1269 ## Returns the number of submeshes in the mesh
1270 # @return an integer value
1271 def NbSubMesh(self):
1272 return self.mesh.NbSubMesh()
1274 ## Returns the list of mesh elements IDs
1275 # @return the list of integer values
1276 def GetElementsId(self):
1277 return self.mesh.GetElementsId()
1279 ## Returns the list of IDs of mesh elements with the given type
1280 # @param elementType the required type of elements
1281 # @return list of integer values
1282 def GetElementsByType(self, elementType):
1283 return self.mesh.GetElementsByType(elementType)
1285 ## Returns the list of mesh nodes IDs
1286 # @return the list of integer values
1287 def GetNodesId(self):
1288 return self.mesh.GetNodesId()
1290 # Get the information about mesh elements:
1291 # ------------------------------------
1293 ## Returns the type of mesh element
1294 # @return the value from SMESH::ElementType enumeration
1295 def GetElementType(self, id, iselem):
1296 return self.mesh.GetElementType(id, iselem)
1298 ## Returns the list of submesh elements IDs
1299 # @param Shape a geom object(subshape) IOR
1300 # Shape must be the subshape of a ShapeToMesh()
1301 # @return the list of integer values
1302 def GetSubMeshElementsId(self, Shape):
1303 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1304 ShapeID = Shape.GetSubShapeIndices()[0]
1307 return self.mesh.GetSubMeshElementsId(ShapeID)
1309 ## Returns the list of submesh nodes IDs
1310 # @param Shape a geom object(subshape) IOR
1311 # Shape must be the subshape of a ShapeToMesh()
1312 # @return the list of integer values
1313 def GetSubMeshNodesId(self, Shape, all):
1314 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1315 ShapeID = Shape.GetSubShapeIndices()[0]
1318 return self.mesh.GetSubMeshNodesId(ShapeID, all)
1320 ## Returns the list of IDs of submesh elements with the given type
1321 # @param Shape a geom object(subshape) IOR
1322 # Shape must be a subshape of a ShapeToMesh()
1323 # @return the list of integer values
1324 def GetSubMeshElementType(self, Shape):
1325 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1326 ShapeID = Shape.GetSubShapeIndices()[0]
1329 return self.mesh.GetSubMeshElementType(ShapeID)
1331 ## Gets the mesh description
1332 # @return string value
1334 return self.mesh.Dump()
1337 # Get the information about nodes and elements of a mesh by its IDs:
1338 # -----------------------------------------------------------
1340 ## Gets XYZ coordinates of a node
1341 # \n If there is no nodes for the given ID - returns an empty list
1342 # @return a list of double precision values
1343 def GetNodeXYZ(self, id):
1344 return self.mesh.GetNodeXYZ(id)
1346 ## Returns list of IDs of inverse elements for the given node
1347 # \n If there is no node for the given ID - returns an empty list
1348 # @return a list of integer values
1349 def GetNodeInverseElements(self, id):
1350 return self.mesh.GetNodeInverseElements(id)
1352 ## @brief Returns the position of a node on the shape
1353 # @return SMESH::NodePosition
1354 def GetNodePosition(self,NodeID):
1355 return self.mesh.GetNodePosition(NodeID)
1357 ## If the given element is a node, returns the ID of shape
1358 # \n If there is no node for the given ID - returns -1
1359 # @return an integer value
1360 def GetShapeID(self, id):
1361 return self.mesh.GetShapeID(id)
1363 ## Returns the ID of the result shape after
1364 # FindShape() from SMESH_MeshEditor for the given element
1365 # \n If there is no element for the given ID - returns -1
1366 # @return an integer value
1367 def GetShapeIDForElem(self,id):
1368 return self.mesh.GetShapeIDForElem(id)
1370 ## Returns the number of nodes for the given element
1371 # \n If there is no element for the given ID - returns -1
1372 # @return an integer value
1373 def GetElemNbNodes(self, id):
1374 return self.mesh.GetElemNbNodes(id)
1376 ## Returns the node ID the given index for the given element
1377 # \n If there is no element for the given ID - returns -1
1378 # \n If there is no node for the given index - returns -2
1379 # @return an integer value
1380 def GetElemNode(self, id, index):
1381 return self.mesh.GetElemNode(id, index)
1383 ## Returns the IDs of nodes of the given element
1384 # @return a list of integer values
1385 def GetElemNodes(self, id):
1386 return self.mesh.GetElemNodes(id)
1388 ## Returns true if the given node is the medium node in the given quadratic element
1389 def IsMediumNode(self, elementID, nodeID):
1390 return self.mesh.IsMediumNode(elementID, nodeID)
1392 ## Returns true if the given node is the medium node in one of quadratic elements
1393 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1394 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1396 ## Returns the number of edges for the given element
1397 def ElemNbEdges(self, id):
1398 return self.mesh.ElemNbEdges(id)
1400 ## Returns the number of faces for the given element
1401 def ElemNbFaces(self, id):
1402 return self.mesh.ElemNbFaces(id)
1404 ## Returns true if the given element is a polygon
1405 def IsPoly(self, id):
1406 return self.mesh.IsPoly(id)
1408 ## Returns true if the given element is quadratic
1409 def IsQuadratic(self, id):
1410 return self.mesh.IsQuadratic(id)
1412 ## Returns XYZ coordinates of the barycenter of the given element
1413 # \n If there is no element for the given ID - returns an empty list
1414 # @return a list of three double values
1415 def BaryCenter(self, id):
1416 return self.mesh.BaryCenter(id)
1419 # Mesh edition (SMESH_MeshEditor functionality):
1420 # ---------------------------------------------
1422 ## Removes the elements from the mesh by ids
1423 # @param IDsOfElements is a list of ids of elements to remove
1424 # @return True or False
1425 def RemoveElements(self, IDsOfElements):
1426 return self.editor.RemoveElements(IDsOfElements)
1428 ## Removes nodes from mesh by ids
1429 # @param IDsOfNodes is a list of ids of nodes to remove
1430 # @return True or False
1431 def RemoveNodes(self, IDsOfNodes):
1432 return self.editor.RemoveNodes(IDsOfNodes)
1434 ## Add a node to the mesh by coordinates
1435 # @return Id of the new node
1436 def AddNode(self, x, y, z):
1437 return self.editor.AddNode( x, y, z)
1440 ## Creates a linear or quadratic edge (this is determined
1441 # by the number of given nodes).
1442 # @param IdsOfNodes the list of node IDs for creation of the element.
1443 # The order of nodes in this list should correspond to the description
1444 # of MED. \n This description is located by the following link:
1445 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1446 # @return the Id of the new edge
1447 def AddEdge(self, IDsOfNodes):
1448 return self.editor.AddEdge(IDsOfNodes)
1450 ## Creates a linear or quadratic face (this is determined
1451 # by the number of given nodes).
1452 # @param IdsOfNodes the list of node IDs for creation of the element.
1453 # The order of nodes in this list should correspond to the description
1454 # of MED. \n This description is located by the following link:
1455 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1456 # @return the Id of the new face
1457 def AddFace(self, IDsOfNodes):
1458 return self.editor.AddFace(IDsOfNodes)
1460 ## Adds a polygonal face to the mesh by the list of node IDs
1461 # @return the Id of the new face
1462 def AddPolygonalFace(self, IdsOfNodes):
1463 return self.editor.AddPolygonalFace(IdsOfNodes)
1465 ## Creates both simple and quadratic volume (this is determined
1466 # by the number of given nodes).
1467 # @param IdsOfNodes the list of node IDs for creation of the element.
1468 # The order of nodes in this list should correspond to the description
1469 # of MED. \n This description is located by the following link:
1470 # http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1471 # @return the Id of the new volumic element
1472 def AddVolume(self, IDsOfNodes):
1473 return self.editor.AddVolume(IDsOfNodes)
1475 ## Creates a volume of many faces, giving nodes for each face.
1476 # @param IdsOfNodes the list of node IDs for volume creation face by face.
1477 # @param Quantities the list of integer values, Quantities[i]
1478 # gives the quantity of nodes in face number i.
1479 # @return the Id of the new volumic element
1480 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1481 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1483 ## Creates a volume of many faces, giving the IDs of the existing faces.
1484 # @param IdsOfFaces the list of face IDs for volume creation.
1486 # Note: The created volume will refer only to the nodes
1487 # of the given faces, not to the faces themselves.
1488 # @return the Id of the new volumic element
1489 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1490 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1493 ## @brief Binds a node to a vertex
1494 # @param NodeID a node ID
1495 # @param Vertex a vertex or vertex ID
1496 # @return True if succeed else raises an exception
1497 def SetNodeOnVertex(self, NodeID, Vertex):
1498 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
1499 VertexID = Vertex.GetSubShapeIndices()[0]
1503 self.editor.SetNodeOnVertex(NodeID, VertexID)
1504 except SALOME.SALOME_Exception, inst:
1505 raise ValueError, inst.details.text
1509 ## @brief Stores the node position on an edge
1510 # @param NodeID a node ID
1511 # @param Edge an edge or edge ID
1512 # @param paramOnEdge a parameter on the edge where the node is located
1513 # @return True if succeed else raises an exception
1514 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
1515 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
1516 EdgeID = Edge.GetSubShapeIndices()[0]
1520 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
1521 except SALOME.SALOME_Exception, inst:
1522 raise ValueError, inst.details.text
1525 ## @brief Stores node position on a face
1526 # @param NodeID a node ID
1527 # @param Face a face or face ID
1528 # @param u U parameter on the face where the node is located
1529 # @param v V parameter on the face where the node is located
1530 # @return True if succeed else raises an exception
1531 def SetNodeOnFace(self, NodeID, Face, u, v):
1532 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
1533 FaceID = Face.GetSubShapeIndices()[0]
1537 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
1538 except SALOME.SALOME_Exception, inst:
1539 raise ValueError, inst.details.text
1542 ## @brief Binds a node to a solid
1543 # @param NodeID a node ID
1544 # @param Solid a solid or solid ID
1545 # @return True if succeed else raises an exception
1546 def SetNodeInVolume(self, NodeID, Solid):
1547 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
1548 SolidID = Solid.GetSubShapeIndices()[0]
1552 self.editor.SetNodeInVolume(NodeID, SolidID)
1553 except SALOME.SALOME_Exception, inst:
1554 raise ValueError, inst.details.text
1557 ## @brief Bind an element to a shape
1558 # @param ElementID an element ID
1559 # @param Shape a shape or shape ID
1560 # @return True if succeed else raises an exception
1561 def SetMeshElementOnShape(self, ElementID, Shape):
1562 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
1563 ShapeID = Shape.GetSubShapeIndices()[0]
1567 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
1568 except SALOME.SALOME_Exception, inst:
1569 raise ValueError, inst.details.text
1573 ## Moves the node with the given id
1574 # @param NodeID the id of the node
1575 # @param x a new X coordinate
1576 # @param y a new Y coordinate
1577 # @param z a new Z coordinate
1578 # @return True if succeed else False
1579 def MoveNode(self, NodeID, x, y, z):
1580 return self.editor.MoveNode(NodeID, x, y, z)
1582 ## Finds the node closest to a point
1583 # @param x the X coordinate of a point
1584 # @param y the Y coordinate of a point
1585 # @param z the Z coordinate of a point
1586 # @return the ID of a node
1587 def FindNodeClosestTo(self, x, y, z):
1588 preview = self.mesh.GetMeshEditPreviewer()
1589 return preview.MoveClosestNodeToPoint(x, y, z, -1)
1591 ## Finds the node closest to a point and moves it to a point location
1592 # @param x the X coordinate of a point
1593 # @param y the Y coordinate of a point
1594 # @param z the Z coordinate of a point
1595 # @return the ID of a moved node
1596 def MeshToPassThroughAPoint(self, x, y, z):
1597 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
1599 ## Replaces two neighbour triangles sharing Node1-Node2 link
1600 # with the triangles built on the same 4 nodes but having other common link.
1601 # @param NodeID1 the ID of the first node
1602 # @param NodeID2 the ID of the second node
1603 # @return false if proper faces were not found
1604 def InverseDiag(self, NodeID1, NodeID2):
1605 return self.editor.InverseDiag(NodeID1, NodeID2)
1607 ## Replaces two neighbour triangles sharing Node1-Node2 link
1608 # with a quadrangle built on the same 4 nodes.
1609 # @param NodeID1 the ID of the first node
1610 # @param NodeID2 the ID of the second node
1611 # @return false if proper faces were not found
1612 def DeleteDiag(self, NodeID1, NodeID2):
1613 return self.editor.DeleteDiag(NodeID1, NodeID2)
1615 ## Reorients elements by ids
1616 # @param IDsOfElements if undefined reorients all mesh elements
1617 # @return True if succeed else False
1618 def Reorient(self, IDsOfElements=None):
1619 if IDsOfElements == None:
1620 IDsOfElements = self.GetElementsId()
1621 return self.editor.Reorient(IDsOfElements)
1623 ## Reorients all elements of the object
1624 # @param theObject mesh, submesh or group
1625 # @return True if succeed else False
1626 def ReorientObject(self, theObject):
1627 if ( isinstance( theObject, Mesh )):
1628 theObject = theObject.GetMesh()
1629 return self.editor.ReorientObject(theObject)
1631 ## Fuses the neighbouring triangles into quadrangles.
1632 # @param IDsOfElements The triangles to be fused,
1633 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1634 # @param MaxAngle is the maximum angle between element normals at which the fusion
1635 # is still performed; theMaxAngle is mesured in radians.
1636 # @return TRUE in case of success, FALSE otherwise.
1637 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
1638 if IDsOfElements == []:
1639 IDsOfElements = self.GetElementsId()
1640 return self.editor.TriToQuad(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1642 ## Fuses the neighbouring triangles of the object into quadrangles
1643 # @param theObject is mesh, submesh or group
1644 # @param theCriterion is FT_...; used to choose a neighbour to fuse with.
1645 # @param MaxAngle a max angle between element normals at which the fusion
1646 # is still performed; theMaxAngle is mesured in radians.
1647 # @return TRUE in case of success, FALSE otherwise.
1648 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
1649 if ( isinstance( theObject, Mesh )):
1650 theObject = theObject.GetMesh()
1651 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
1653 ## Splits quadrangles into triangles.
1654 # @param IDsOfElements the faces to be splitted.
1655 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1656 # @return TRUE in case of success, FALSE otherwise.
1657 def QuadToTri (self, IDsOfElements, theCriterion):
1658 if IDsOfElements == []:
1659 IDsOfElements = self.GetElementsId()
1660 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
1662 ## Splits quadrangles into triangles.
1663 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1664 # @param theCriterion FT_...; used to choose a diagonal for splitting.
1665 # @return TRUE in case of success, FALSE otherwise.
1666 def QuadToTriObject (self, theObject, theCriterion):
1667 if ( isinstance( theObject, Mesh )):
1668 theObject = theObject.GetMesh()
1669 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
1671 ## Splits quadrangles into triangles.
1672 # @param theElems the faces to be splitted
1673 # @param the13Diag is used to choose a diagonal for splitting.
1674 # @return TRUE in case of success, FALSE otherwise.
1675 def SplitQuad (self, IDsOfElements, Diag13):
1676 if IDsOfElements == []:
1677 IDsOfElements = self.GetElementsId()
1678 return self.editor.SplitQuad(IDsOfElements, Diag13)
1680 ## Splits quadrangles into triangles.
1681 # @param theObject the object from which the list of elements is taken, this is mesh, submesh or group
1682 # @return TRUE in case of success, FALSE otherwise.
1683 def SplitQuadObject (self, theObject, Diag13):
1684 if ( isinstance( theObject, Mesh )):
1685 theObject = theObject.GetMesh()
1686 return self.editor.SplitQuadObject(theObject, Diag13)
1688 ## Finds a better splitting of the given quadrangle.
1689 # @param IDOfQuad the ID of the quadrangle to be splitted.
1690 # @param theCriterion FT_...; a criterion to choose a diagonal for splitting.
1691 # @return 1 if 1-3 diagonal is better, 2 if 2-4
1692 # diagonal is better, 0 if error occurs.
1693 def BestSplit (self, IDOfQuad, theCriterion):
1694 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
1696 ## Splits quadrangle faces near triangular facets of volumes
1698 def SplitQuadsNearTriangularFacets(self):
1699 faces_array = self.GetElementsByType(SMESH.FACE)
1700 for face_id in faces_array:
1701 if self.GetElemNbNodes(face_id) == 4: # quadrangle
1702 quad_nodes = self.mesh.GetElemNodes(face_id)
1703 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
1704 isVolumeFound = False
1705 for node1_elem in node1_elems:
1706 if not isVolumeFound:
1707 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
1708 nb_nodes = self.GetElemNbNodes(node1_elem)
1709 if 3 < nb_nodes and nb_nodes < 7: # tetra or penta, or prism
1710 volume_elem = node1_elem
1711 volume_nodes = self.mesh.GetElemNodes(volume_elem)
1712 if volume_nodes.count(quad_nodes[2 -1]) > 0: # 1,2
1713 if volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,2,4
1714 isVolumeFound = True
1715 if volume_nodes.count(quad_nodes[3 -1]) == 0: # 1,2,4 & !3
1716 self.SplitQuad([face_id], False) # diagonal 2-4
1717 elif volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,2,3 & !4
1718 isVolumeFound = True
1719 self.SplitQuad([face_id], True) # diagonal 1-3
1720 elif volume_nodes.count(quad_nodes[4 -1]) > 0: # 1,4 & !2
1721 if volume_nodes.count(quad_nodes[3 -1]) > 0: # 1,4,3 & !2
1722 isVolumeFound = True
1723 self.SplitQuad([face_id], True) # diagonal 1-3
1725 ## @brief Splits hexahedrons into tetrahedrons.
1727 # This operation uses pattern mapping functionality for splitting.
1728 # @param theObject the object from which the list of hexahedrons is taken; this is mesh, submesh or group.
1729 # @param theNode000,theNode001 within the range [0,7]; gives the orientation of the
1730 # pattern relatively each hexahedron: the (0,0,0) key-point of the pattern
1731 # will be mapped into <theNode000>-th node of each volume, the (0,0,1)
1732 # key-point will be mapped into <theNode001>-th node of each volume.
1733 # The (0,0,0) key-point of the used pattern corresponds to a non-split corner.
1734 # @return TRUE in case of success, FALSE otherwise.
1735 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
1736 # Pattern: 5.---------.6
1741 # (0,0,1) 4.---------.7 * |
1748 # (0,0,0) 0.---------.3
1749 pattern_tetra = "!!! Nb of points: \n 8 \n\
1759 !!! Indices of points of 6 tetras: \n\
1767 pattern = self.smeshpyD.GetPattern()
1768 isDone = pattern.LoadFromFile(pattern_tetra)
1770 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
1773 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
1774 isDone = pattern.MakeMesh(self.mesh, False, False)
1775 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
1777 # split quafrangle faces near triangular facets of volumes
1778 self.SplitQuadsNearTriangularFacets()
1782 ## @brief Split hexahedrons into prisms.
1784 # Uses the pattern mapping functionality for splitting.
1785 # @param theObject the object (mesh, submesh or group) from where the list of hexahedrons is taken;
1786 # @param theNode000,theNode001 (within the range [0,7]) gives the orientation of the
1787 # pattern relatively each hexahedron: keypoint (0,0,0) of the pattern
1788 # will be mapped into the <theNode000>-th node of each volume, keypoint (0,0,1)
1789 # will be mapped into the <theNode001>-th node of each volume.
1790 # Edge (0,0,0)-(0,0,1) of used pattern connects two not split corners.
1791 # @return TRUE in case of success, FALSE otherwise.
1792 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
1793 # Pattern: 5.---------.6
1798 # (0,0,1) 4.---------.7 |
1805 # (0,0,0) 0.---------.3
1806 pattern_prism = "!!! Nb of points: \n 8 \n\
1816 !!! Indices of points of 2 prisms: \n\
1820 pattern = self.smeshpyD.GetPattern()
1821 isDone = pattern.LoadFromFile(pattern_prism)
1823 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
1826 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
1827 isDone = pattern.MakeMesh(self.mesh, False, False)
1828 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
1830 # Splits quafrangle faces near triangular facets of volumes
1831 self.SplitQuadsNearTriangularFacets()
1835 ## Smoothes elements
1836 # @param IDsOfElements the list if ids of elements to smooth
1837 # @param IDsOfFixedNodes the list of ids of fixed nodes.
1838 # Note that nodes built on edges and boundary nodes are always fixed.
1839 # @param MaxNbOfIterations the maximum number of iterations
1840 # @param MaxAspectRatio varies in range [1.0, inf]
1841 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1842 # @return TRUE in case of success, FALSE otherwise.
1843 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
1844 MaxNbOfIterations, MaxAspectRatio, Method):
1845 if IDsOfElements == []:
1846 IDsOfElements = self.GetElementsId()
1847 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
1848 MaxNbOfIterations, MaxAspectRatio, Method)
1850 ## Smoothes elements which belong to the given object
1851 # @param theObject the object to smooth
1852 # @param IDsOfFixedNodes the list of ids of fixed nodes.
1853 # Note that nodes built on edges and boundary nodes are always fixed.
1854 # @param MaxNbOfIterations the maximum number of iterations
1855 # @param MaxAspectRatio varies in range [1.0, inf]
1856 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1857 # @return TRUE in case of success, FALSE otherwise.
1858 def SmoothObject(self, theObject, IDsOfFixedNodes,
1859 MaxNbOfIterations, MaxxAspectRatio, Method):
1860 if ( isinstance( theObject, Mesh )):
1861 theObject = theObject.GetMesh()
1862 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
1863 MaxNbOfIterations, MaxxAspectRatio, Method)
1865 ## Parametrically smoothes the given elements
1866 # @param IDsOfElements the list if ids of elements to smooth
1867 # @param IDsOfFixedNodes the list of ids of fixed nodes.
1868 # Note that nodes built on edges and boundary nodes are always fixed.
1869 # @param MaxNbOfIterations the maximum number of iterations
1870 # @param MaxAspectRatio varies in range [1.0, inf]
1871 # @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1872 # @return TRUE in case of success, FALSE otherwise.
1873 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
1874 MaxNbOfIterations, MaxAspectRatio, Method):
1875 if IDsOfElements == []:
1876 IDsOfElements = self.GetElementsId()
1877 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1878 MaxNbOfIterations, MaxAspectRatio, Method)
1880 ## Parametrically smoothes the elements which belong to the given object
1881 # @param theObject the object to smooth
1882 # @param IDsOfFixedNodes the list of ids of fixed nodes.
1883 # Note that nodes built on edges and boundary nodes are always fixed.
1884 # @param MaxNbOfIterations the maximum number of iterations
1885 # @param MaxAspectRatio varies in range [1.0, inf]
1886 # @param Method Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1887 # @return TRUE in case of success, FALSE otherwise.
1888 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
1889 MaxNbOfIterations, MaxAspectRatio, Method):
1890 if ( isinstance( theObject, Mesh )):
1891 theObject = theObject.GetMesh()
1892 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
1893 MaxNbOfIterations, MaxAspectRatio, Method)
1895 ## Converts the mesh to quadratic, deletes old elements, replacing
1896 # them with quadratic with the same id.
1897 def ConvertToQuadratic(self, theForce3d):
1898 self.editor.ConvertToQuadratic(theForce3d)
1900 ## Converts the mesh from quadratic to ordinary,
1901 # deletes old quadratic elements, \n replacing
1902 # them with ordinary mesh elements with the same id.
1903 # @return TRUE in case of success, FALSE otherwise.
1904 def ConvertFromQuadratic(self):
1905 return self.editor.ConvertFromQuadratic()
1907 ## Renumber mesh nodes
1908 def RenumberNodes(self):
1909 self.editor.RenumberNodes()
1911 ## Renumber mesh elements
1912 def RenumberElements(self):
1913 self.editor.RenumberElements()
1915 ## Generates new elements by rotation of the elements around the axis
1916 # @param IDsOfElements the list of ids of elements to sweep
1917 # @param Axix the axis of rotation, AxisStruct or line(geom object)
1918 # @param AngleInRadians the angle of Rotation
1919 # @param NbOfStep the number of steps
1920 # @param Tolerance tolerance
1921 # @param MakeGroups forces the generation of new groups from existing ones
1922 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
1923 # of all steps, else - size of each step
1924 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
1925 def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance,
1926 MakeGroups=False, TotalAngle=False):
1927 if IDsOfElements == []:
1928 IDsOfElements = self.GetElementsId()
1929 if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
1930 Axix = self.smeshpyD.GetAxisStruct(Axix)
1931 if TotalAngle and NbOfSteps:
1932 AngleInRadians /= NbOfSteps
1934 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axix,
1935 AngleInRadians, NbOfSteps, Tolerance)
1936 self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
1939 ## Generates new elements by rotation of the elements of object around the axis
1940 # @param theObject object which elements should be sweeped
1941 # @param Axix the axis of rotation, AxisStruct or line(geom object)
1942 # @param AngleInRadians the angle of Rotation
1943 # @param NbOfSteps number of steps
1944 # @param Tolerance tolerance
1945 # @param MakeGroups forces the generation of new groups from existing ones
1946 # @param TotalAngle gives meaning of AngleInRadians: if True then it is an angular size
1947 # of all steps, else - size of each step
1948 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
1949 def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance,
1950 MakeGroups=False, TotalAngle=False):
1951 if ( isinstance( theObject, Mesh )):
1952 theObject = theObject.GetMesh()
1953 if ( isinstance( Axix, geompyDC.GEOM._objref_GEOM_Object)):
1954 Axix = self.smeshpyD.GetAxisStruct(Axix)
1955 if TotalAngle and NbOfSteps:
1956 AngleInRadians /= NbOfSteps
1958 return self.editor.RotationSweepObjectMakeGroups(theObject, Axix, AngleInRadians,
1959 NbOfSteps, Tolerance)
1960 self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
1963 ## Generates new elements by extrusion of the elements with given ids
1964 # @param IDsOfElements the list of elements ids for extrusion
1965 # @param StepVector vector, defining the direction and value of extrusion
1966 # @param NbOfSteps the number of steps
1967 # @param MakeGroups forces the generation of new groups from existing ones
1968 # @return the list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
1969 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
1970 if IDsOfElements == []:
1971 IDsOfElements = self.GetElementsId()
1972 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
1973 StepVector = self.smeshpyD.GetDirStruct(StepVector)
1975 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
1976 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
1979 ## Generates new elements by extrusion of the elements with given ids
1980 # @param IDsOfElements is ids of elements
1981 # @param StepVector vector, defining the direction and value of extrusion
1982 # @param NbOfSteps the number of steps
1983 # @param ExtrFlags sets flags for extrusion
1984 # @param SewTolerance uses for comparing locations of nodes if flag
1985 # EXTRUSION_FLAG_SEW is set
1986 # @param MakeGroups forces the generation of new groups from existing ones
1987 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
1988 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance, MakeGroups=False):
1989 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
1990 StepVector = self.smeshpyD.GetDirStruct(StepVector)
1992 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
1993 ExtrFlags, SewTolerance)
1994 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
1995 ExtrFlags, SewTolerance)
1998 ## Generates new elements by extrusion of the elements which belong to the object
1999 # @param theObject the object which elements should be processed
2000 # @param StepVector vector, defining the direction and value of extrusion
2001 # @param NbOfSteps the number of steps
2002 # @param MakeGroups forces the generation of new groups from existing ones
2003 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2004 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2005 if ( isinstance( theObject, Mesh )):
2006 theObject = theObject.GetMesh()
2007 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2008 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2010 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
2011 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
2014 ## Generates new elements by extrusion of the elements which belong to the object
2015 # @param theObject object which elements should be processed
2016 # @param StepVector vector, defining the direction and value of extrusion
2017 # @param NbOfSteps the number of steps
2018 # @param MakeGroups to generate new groups from existing ones
2019 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2020 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2021 if ( isinstance( theObject, Mesh )):
2022 theObject = theObject.GetMesh()
2023 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2024 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2026 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
2027 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
2030 ## Generates new elements by extrusion of the elements which belong to the object
2031 # @param theObject object which elements should be processed
2032 # @param StepVector vector, defining the direction and value of extrusion
2033 # @param NbOfSteps the number of steps
2034 # @param MakeGroups forces the generation of new groups from existing ones
2035 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2036 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
2037 if ( isinstance( theObject, Mesh )):
2038 theObject = theObject.GetMesh()
2039 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
2040 StepVector = self.smeshpyD.GetDirStruct(StepVector)
2042 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
2043 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
2046 ## Generates new elements by extrusion of the given elements
2047 # The path of extrusion must be a meshed edge.
2048 # @param IDsOfElements ids of elements
2049 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
2050 # @param PathShape shape(edge) defines the sub-mesh for the path
2051 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2052 # @param HasAngles allows the shape to be rotated around the path
2053 # to get the resulting mesh in a helical fashion
2054 # @param Angles list of angles
2055 # @param HasRefPoint allows using the reference point
2056 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2057 # The User can specify any point as the Reference Point.
2058 # @param MakeGroups forces the generation of new groups from existing ones
2059 # @param LinearVariation forces the computation of rotation angles as linear
2060 # variation of the given Angles along path steps
2061 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2062 # only SMESH::Extrusion_Error otherwise
2063 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
2064 HasAngles, Angles, HasRefPoint, RefPoint,
2065 MakeGroups=False, LinearVariation=False):
2066 if IDsOfElements == []:
2067 IDsOfElements = self.GetElementsId()
2068 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2069 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2071 if ( isinstance( PathMesh, Mesh )):
2072 PathMesh = PathMesh.GetMesh()
2073 if HasAngles and Angles and LinearVariation:
2074 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2077 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
2078 PathShape, NodeStart, HasAngles,
2079 Angles, HasRefPoint, RefPoint)
2080 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
2081 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
2083 ## Generates new elements by extrusion of the elements which belong to the object
2084 # The path of extrusion must be a meshed edge.
2085 # @param IDsOfElements is ids of elements
2086 # @param PathMesh mesh containing a 1D sub-mesh on the edge, along which the extrusion proceeds
2087 # @param PathShape shape(edge) defines the sub-mesh for the path
2088 # @param NodeStart the first or the last node on the edge. Defines the direction of extrusion
2089 # @param HasAngles allows the shape to be rotated around the path
2090 # to get the resulting mesh in a helical fashion
2091 # @param Angles list of angles
2092 # @param HasRefPoint allows using the reference point
2093 # @param RefPoint the point around which the shape is rotated (the mass center of the shape by default).
2094 # The User can specify any point as the Reference Point.
2095 # @param MakeGroups forces the generation of new groups from existing ones
2096 # @param LinearVariation forces the computation of rotation angles as linear
2097 # variation of the given Angles along path steps
2098 # @return list of created groups (SMESH_GroupBase) and SMESH::Extrusion_Error if MakeGroups=True,
2099 # only SMESH::Extrusion_Error otherwise
2100 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
2101 HasAngles, Angles, HasRefPoint, RefPoint,
2102 MakeGroups=False, LinearVariation=False):
2103 if ( isinstance( theObject, Mesh )):
2104 theObject = theObject.GetMesh()
2105 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
2106 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
2107 if ( isinstance( PathMesh, Mesh )):
2108 PathMesh = PathMesh.GetMesh()
2109 if HasAngles and Angles and LinearVariation:
2110 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
2113 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
2114 PathShape, NodeStart, HasAngles,
2115 Angles, HasRefPoint, RefPoint)
2116 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
2117 NodeStart, HasAngles, Angles, HasRefPoint,
2120 ## Creates a symmetrical copy of mesh elements
2121 # @param IDsOfElements list of elements ids
2122 # @param Mirror is AxisStruct or geom object(point, line, plane)
2123 # @param theMirrorType is POINT, AXIS or PLANE
2124 # If the Mirror is a geom object this parameter is unnecessary
2125 # @param Copy allows to copy element (Copy is 1) or to replace with its mirroring (Copy is 0)
2126 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2127 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2128 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2129 if IDsOfElements == []:
2130 IDsOfElements = self.GetElementsId()
2131 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2132 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2133 if Copy and MakeGroups:
2134 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
2135 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
2138 ## Creates a new mesh by a symmetrical copy of mesh elements
2139 # @param IDsOfElements the list of elements ids
2140 # @param Mirror is AxisStruct or geom object (point, line, plane)
2141 # @param theMirrorType is POINT, AXIS or PLANE
2142 # If the Mirror is a geom object this parameter is unnecessary
2143 # @param MakeGroups to generate new groups from existing ones
2144 # @param NewMeshName a name of the new mesh to create
2145 # @return instance of Mesh class
2146 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
2147 if IDsOfElements == []:
2148 IDsOfElements = self.GetElementsId()
2149 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2150 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2151 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
2152 MakeGroups, NewMeshName)
2153 return Mesh(self.smeshpyD,self.geompyD,mesh)
2155 ## Creates a symmetrical copy of the object
2156 # @param theObject mesh, submesh or group
2157 # @param Mirror AxisStruct or geom object (point, line, plane)
2158 # @param theMirrorType is POINT, AXIS or PLANE
2159 # If the Mirror is a geom object this parameter is unnecessary
2160 # @param Copy allows copying the element (Copy is 1) or replacing it with its mirror (Copy is 0)
2161 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2162 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2163 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
2164 if ( isinstance( theObject, Mesh )):
2165 theObject = theObject.GetMesh()
2166 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2167 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2168 if Copy and MakeGroups:
2169 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
2170 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
2173 ## Creates a new mesh by a symmetrical copy of the object
2174 # @param theObject mesh, submesh or group
2175 # @param Mirror AxisStruct or geom object (point, line, plane)
2176 # @param theMirrorType POINT, AXIS or PLANE
2177 # If the Mirror is a geom object this parameter is unnecessary
2178 # @param MakeGroups forces the generation of new groups from existing ones
2179 # @param NewMeshName the name of the new mesh to create
2180 # @return instance of Mesh class
2181 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
2182 if ( isinstance( theObject, Mesh )):
2183 theObject = theObject.GetMesh()
2184 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
2185 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
2186 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
2187 MakeGroups, NewMeshName)
2188 return Mesh( self.smeshpyD,self.geompyD,mesh )
2190 ## Translates the elements
2191 # @param IDsOfElements list of elements ids
2192 # @param Vector the direction of translation (DirStruct or vector)
2193 # @param Copy allows copying the translated elements
2194 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2195 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2196 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
2197 if IDsOfElements == []:
2198 IDsOfElements = self.GetElementsId()
2199 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2200 Vector = self.smeshpyD.GetDirStruct(Vector)
2201 if Copy and MakeGroups:
2202 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
2203 self.editor.Translate(IDsOfElements, Vector, Copy)
2206 ## Creates a new mesh of translated elements
2207 # @param IDsOfElements list of elements ids
2208 # @param Vector the direction of translation (DirStruct or vector)
2209 # @param MakeGroups forces the generation of new groups from existing ones
2210 # @param NewMeshName the name of the newly created mesh
2211 # @return instance of Mesh class
2212 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
2213 if IDsOfElements == []:
2214 IDsOfElements = self.GetElementsId()
2215 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2216 Vector = self.smeshpyD.GetDirStruct(Vector)
2217 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
2218 return Mesh ( self.smeshpyD, self.geompyD, mesh )
2220 ## Translates the object
2221 # @param theObject the object to translate (mesh, submesh, or group)
2222 # @param Vector direction of translation (DirStruct or geom vector)
2223 # @param Copy allows copying the translated elements
2224 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2225 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2226 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
2227 if ( isinstance( theObject, Mesh )):
2228 theObject = theObject.GetMesh()
2229 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
2230 Vector = self.smeshpyD.GetDirStruct(Vector)
2231 if Copy and MakeGroups:
2232 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
2233 self.editor.TranslateObject(theObject, Vector, Copy)
2236 ## Creates a new mesh from the translated object
2237 # @param theObject the object to translate (mesh, submesh, or group)
2238 # @param Vector the direction of translation (DirStruct or geom vector)
2239 # @param MakeGroups forces the generation of new groups from existing ones
2240 # @param NewMeshName the name of the newly created mesh
2241 # @return instance of Mesh class
2242 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
2243 if (isinstance(theObject, Mesh)):
2244 theObject = theObject.GetMesh()
2245 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
2246 Vector = self.smeshpyD.GetDirStruct(Vector)
2247 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
2248 return Mesh( self.smeshpyD, self.geompyD, mesh )
2250 ## Rotates the elements
2251 # @param IDsOfElements list of elements ids
2252 # @param Axis the axis of rotation (AxisStruct or geom line)
2253 # @param AngleInRadians the angle of rotation (in radians)
2254 # @param Copy allows copying the rotated elements
2255 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2256 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2257 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
2258 if IDsOfElements == []:
2259 IDsOfElements = self.GetElementsId()
2260 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2261 Axis = self.smeshpyD.GetAxisStruct(Axis)
2262 if Copy and MakeGroups:
2263 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
2264 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
2267 ## Creates a new mesh of rotated elements
2268 # @param IDsOfElements list of element ids
2269 # @param Axis the axis of rotation (AxisStruct or geom line)
2270 # @param AngleInRadians the angle of rotation (in radians)
2271 # @param MakeGroups forces the generation of new groups from existing ones
2272 # @param NewMeshName the name of the newly created mesh
2273 # @return instance of Mesh class
2274 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
2275 if IDsOfElements == []:
2276 IDsOfElements = self.GetElementsId()
2277 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
2278 Axis = self.smeshpyD.GetAxisStruct(Axis)
2279 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
2280 MakeGroups, NewMeshName)
2281 return Mesh( self.smeshpyD, self.geompyD, mesh )
2283 ## Rotates the object
2284 # @param theObject the object to rotate( mesh, submesh, or group)
2285 # @param Axis the axis of rotation (AxisStruct or geom line)
2286 # @param AngleInRadians the angle of rotation (in radians)
2287 # @param Copy allows copying the rotated elements
2288 # @param MakeGroups forces the generation of new groups from existing ones (if Copy)
2289 # @return list of created groups (SMESH_GroupBase) if MakeGroups=True, empty list otherwise
2290 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
2291 if (isinstance(theObject, Mesh)):
2292 theObject = theObject.GetMesh()
2293 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2294 Axis = self.smeshpyD.GetAxisStruct(Axis)
2295 if Copy and MakeGroups:
2296 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
2297 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
2300 ## Creates a new mesh from the rotated object
2301 # @param theObject the object to rotate (mesh, submesh, or group)
2302 # @param Axis the axis of rotation (AxisStruct or geom line)
2303 # @param AngleInRadians the angle of rotation (in radians)
2304 # @param MakeGroups forces the generation of new groups from existing ones
2305 # @param NewMeshName the name of the newly created mesh
2306 # @return instance of Mesh class
2307 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
2308 if (isinstance( theObject, Mesh )):
2309 theObject = theObject.GetMesh()
2310 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
2311 Axis = self.smeshpyD.GetAxisStruct(Axis)
2312 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
2313 MakeGroups, NewMeshName)
2314 return Mesh( self.smeshpyD, self.geompyD, mesh )
2316 ## Finds groups of ajacent nodes within Tolerance.
2317 # @param Tolerance the value of tolerance
2318 # @return the list of groups of nodes
2319 def FindCoincidentNodes (self, Tolerance):
2320 return self.editor.FindCoincidentNodes(Tolerance)
2322 ## Finds groups of ajacent nodes within Tolerance.
2323 # @param Tolerance the value of tolerance
2324 # @param SubMeshOrGroup SubMesh or Group
2325 # @return the list of groups of nodes
2326 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance):
2327 return self.editor.FindCoincidentNodesOnPart(SubMeshOrGroup, Tolerance)
2330 # @param GroupsOfNodes the list of groups of nodes
2331 def MergeNodes (self, GroupsOfNodes):
2332 self.editor.MergeNodes(GroupsOfNodes)
2334 ## Finds the elements built on the same nodes.
2335 # @param MeshOrSubMeshOrGroup Mesh or SubMesh, or Group of elements for searching
2336 # @return a list of groups of equal elements
2337 def FindEqualElements (self, MeshOrSubMeshOrGroup):
2338 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
2340 ## Merges elements in each given group.
2341 # @param GroupsOfElementsID groups of elements for merging
2342 def MergeElements(self, GroupsOfElementsID):
2343 self.editor.MergeElements(GroupsOfElementsID)
2345 ## Leaves one element and removes all other elements built on the same nodes.
2346 def MergeEqualElements(self):
2347 self.editor.MergeEqualElements()
2349 ## Sews free borders
2350 # @return SMESH::Sew_Error
2351 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2352 FirstNodeID2, SecondNodeID2, LastNodeID2,
2353 CreatePolygons, CreatePolyedrs):
2354 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2355 FirstNodeID2, SecondNodeID2, LastNodeID2,
2356 CreatePolygons, CreatePolyedrs)
2358 ## Sews conform free borders
2359 # @return SMESH::Sew_Error
2360 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
2361 FirstNodeID2, SecondNodeID2):
2362 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
2363 FirstNodeID2, SecondNodeID2)
2365 ## Sews border to side
2366 # @return SMESH::Sew_Error
2367 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2368 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
2369 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
2370 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
2372 ## Sews two sides of a mesh. The nodes belonging to Side1 are
2373 # merged with the nodes of elements of Side2.
2374 # The number of elements in theSide1 and in theSide2 must be
2375 # equal and they should have similar nodal connectivity.
2376 # The nodes to merge should belong to side borders and
2377 # the first node should be linked to the second.
2378 # @return SMESH::Sew_Error
2379 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
2380 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2381 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
2382 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
2383 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
2384 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
2386 ## Sets new nodes for the given element.
2387 # @param ide the element id
2388 # @param newIDs nodes ids
2389 # @return If the number of nodes does not correspond to the type of element - returns false
2390 def ChangeElemNodes(self, ide, newIDs):
2391 return self.editor.ChangeElemNodes(ide, newIDs)
2393 ## If during the last operation of MeshEditor some nodes were
2394 # created, this method returns the list of their IDs, \n
2395 # if new nodes were not created - returns empty list
2396 # @return the list of integer values (can be empty)
2397 def GetLastCreatedNodes(self):
2398 return self.editor.GetLastCreatedNodes()
2400 ## If during the last operation of MeshEditor some elements were
2401 # created this method returns the list of their IDs, \n
2402 # if new elements were not created - returns empty list
2403 # @return the list of integer values (can be empty)
2404 def GetLastCreatedElems(self):
2405 return self.editor.GetLastCreatedElems()
2407 ## The mother class to define algorithm, it is not recommended to use it directly.
2410 class Mesh_Algorithm:
2411 # @class Mesh_Algorithm
2412 # @brief Class Mesh_Algorithm
2414 #def __init__(self,smesh):
2422 ## Finds a hypothesis in the study by its type name and parameters.
2423 # Finds only the hypotheses created in smeshpyD engine.
2424 # @return SMESH.SMESH_Hypothesis
2425 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
2426 study = smeshpyD.GetCurrentStudy()
2427 #to do: find component by smeshpyD object, not by its data type
2428 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2429 if scomp is not None:
2430 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
2431 # Check if the root label of the hypotheses exists
2432 if res and hypRoot is not None:
2433 iter = study.NewChildIterator(hypRoot)
2434 # Check all published hypotheses
2436 hypo_so_i = iter.Value()
2437 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
2438 if attr is not None:
2439 anIOR = attr.Value()
2440 hypo_o_i = salome.orb.string_to_object(anIOR)
2441 if hypo_o_i is not None:
2442 # Check if this is a hypothesis
2443 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
2444 if hypo_i is not None:
2445 # Check if the hypothesis belongs to current engine
2446 if smeshpyD.GetObjectId(hypo_i) > 0:
2447 # Check if this is the required hypothesis
2448 if hypo_i.GetName() == hypname:
2450 if CompareMethod(hypo_i, args):
2464 ## Finds the algorithm in the study by its type name.
2465 # Finds only the algorithms, which have been created in smeshpyD engine.
2466 # @return SMESH.SMESH_Algo
2467 def FindAlgorithm (self, algoname, smeshpyD):
2468 study = smeshpyD.GetCurrentStudy()
2469 #to do: find component by smeshpyD object, not by its data type
2470 scomp = study.FindComponent(smeshpyD.ComponentDataType())
2471 if scomp is not None:
2472 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
2473 # Check if the root label of the algorithms exists
2474 if res and hypRoot is not None:
2475 iter = study.NewChildIterator(hypRoot)
2476 # Check all published algorithms
2478 algo_so_i = iter.Value()
2479 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
2480 if attr is not None:
2481 anIOR = attr.Value()
2482 algo_o_i = salome.orb.string_to_object(anIOR)
2483 if algo_o_i is not None:
2484 # Check if this is an algorithm
2485 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
2486 if algo_i is not None:
2487 # Checks if the algorithm belongs to the current engine
2488 if smeshpyD.GetObjectId(algo_i) > 0:
2489 # Check if this is the required algorithm
2490 if algo_i.GetName() == algoname:
2503 ## If the algorithm is global, returns 0; \n
2504 # else returns the submesh associated to this algorithm.
2505 def GetSubMesh(self):
2508 ## Returns the wrapped mesher.
2509 def GetAlgorithm(self):
2512 ## Gets the list of hypothesis that can be used with this algorithm
2513 def GetCompatibleHypothesis(self):
2516 mylist = self.algo.GetCompatibleHypothesis()
2519 ## Gets the name of the algorithm
2523 ## Sets the name to the algorithm
2524 def SetName(self, name):
2525 SetName(self.algo, name)
2527 ## Gets the id of the algorithm
2529 return self.algo.GetId()
2532 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
2534 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
2535 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
2537 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
2539 self.Assign(algo, mesh, geom)
2543 def Assign(self, algo, mesh, geom):
2545 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
2552 name = GetName(geom)
2554 name = mesh.geompyD.SubShapeName(geom, piece)
2555 mesh.geompyD.addToStudyInFather(piece, geom, name)
2556 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
2559 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
2560 TreatHypoStatus( status, algo.GetName(), GetName(self.geom), True )
2562 def CompareHyp (self, hyp, args):
2563 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
2566 def CompareEqualHyp (self, hyp, args):
2570 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
2571 UseExisting=0, CompareMethod=""):
2574 if CompareMethod == "": CompareMethod = self.CompareHyp
2575 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
2578 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
2584 a = a + s + str(args[i])
2588 SetName(hypo, hyp + a)
2590 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
2591 TreatHypoStatus( status, GetName(hypo), GetName(self.geom), 0 )
2595 # Public class: Mesh_Segment
2596 # --------------------------
2598 ## Class to define a segment 1D algorithm for discretization
2601 class Mesh_Segment(Mesh_Algorithm):
2603 ## Private constructor.
2604 def __init__(self, mesh, geom=0):
2605 Mesh_Algorithm.__init__(self)
2606 self.Create(mesh, geom, "Regular_1D")
2608 ## Defines "LocalLength" hypothesis to cut an edge in several segments with the same length
2609 # @param l for the length of segments that cut an edge
2610 # @param UseExisting if ==true - searches for an existing hypothesis created with
2611 # the same parameters, else (default) - creates a new one
2612 # @param p precision, used for calculation of the number of segments.
2613 # The precision should be a positive, meaningful value within the range [0,1].
2614 # In general, the number of segments is calculated with the formula:
2615 # nb = ceil((edge_length / l) - p)
2616 # Function ceil rounds its argument to the higher integer.
2617 # So, p=0 means rounding of (edge_length / l) to the higher integer,
2618 # p=0.5 means rounding of (edge_length / l) to the nearest integer,
2619 # p=1 means rounding of (edge_length / l) to the lower integer.
2620 # Default value is 1e-07.
2621 # @return an instance of StdMeshers_LocalLength hypothesis
2622 def LocalLength(self, l, UseExisting=0, p=1e-07):
2623 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
2624 CompareMethod=self.CompareLocalLength)
2630 ## Checks if the given "LocalLength" hypothesis has the same parameters as the given arguments
2631 def CompareLocalLength(self, hyp, args):
2632 if IsEqual(hyp.GetLength(), args[0]):
2633 return IsEqual(hyp.GetPrecision(), args[1])
2636 ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments
2637 # @param n for the number of segments that cut an edge
2638 # @param s for the scale factor (optional)
2639 # @param UseExisting if ==true - searches for an existing hypothesis created with
2640 # the same parameters, else (default) - create a new one
2641 # @return an instance of StdMeshers_NumberOfSegments hypothesis
2642 def NumberOfSegments(self, n, s=[], UseExisting=0):
2644 hyp = self.Hypothesis("NumberOfSegments", [n], UseExisting=UseExisting,
2645 CompareMethod=self.CompareNumberOfSegments)
2647 hyp = self.Hypothesis("NumberOfSegments", [n,s], UseExisting=UseExisting,
2648 CompareMethod=self.CompareNumberOfSegments)
2649 hyp.SetDistrType( 1 )
2650 hyp.SetScaleFactor(s)
2651 hyp.SetNumberOfSegments(n)
2655 ## Checks if the given "NumberOfSegments" hypothesis has the same parameters as the given arguments
2656 def CompareNumberOfSegments(self, hyp, args):
2657 if hyp.GetNumberOfSegments() == args[0]:
2661 if hyp.GetDistrType() == 1:
2662 if IsEqual(hyp.GetScaleFactor(), args[1]):
2666 ## Defines "Arithmetic1D" hypothesis to cut an edge in several segments with increasing arithmetic length
2667 # @param start defines the length of the first segment
2668 # @param end defines the length of the last segment
2669 # @param UseExisting if ==true - searches for an existing hypothesis created with
2670 # the same parameters, else (default) - creates a new one
2671 # @return an instance of StdMeshers_Arithmetic1D hypothesis
2672 def Arithmetic1D(self, start, end, UseExisting=0):
2673 hyp = self.Hypothesis("Arithmetic1D", [start, end], UseExisting=UseExisting,
2674 CompareMethod=self.CompareArithmetic1D)
2675 hyp.SetLength(start, 1)
2676 hyp.SetLength(end , 0)
2680 ## Check if the given "Arithmetic1D" hypothesis has the same parameters as the given arguments
2681 def CompareArithmetic1D(self, hyp, args):
2682 if IsEqual(hyp.GetLength(1), args[0]):
2683 if IsEqual(hyp.GetLength(0), args[1]):
2687 ## Defines "StartEndLength" hypothesis to cut an edge in several segments with increasing geometric length
2688 # @param start defines the length of the first segment
2689 # @param end defines the length of the last segment
2690 # @param UseExisting if ==true - searches for an existing hypothesis created with
2691 # the same parameters, else (default) - creates a new one
2692 # @return an instance of StdMeshers_StartEndLength hypothesis
2693 def StartEndLength(self, start, end, UseExisting=0):
2694 hyp = self.Hypothesis("StartEndLength", [start, end], UseExisting=UseExisting,
2695 CompareMethod=self.CompareStartEndLength)
2696 hyp.SetLength(start, 1)
2697 hyp.SetLength(end , 0)
2700 ## Check if the given "StartEndLength" hypothesis has the same parameters as the given arguments
2701 def CompareStartEndLength(self, hyp, args):
2702 if IsEqual(hyp.GetLength(1), args[0]):
2703 if IsEqual(hyp.GetLength(0), args[1]):
2707 ## Defines "Deflection1D" hypothesis
2708 # @param d for the deflection
2709 # @param UseExisting if ==true - searches for an existing hypothesis created with
2710 # the same parameters, else (default) - create a new one
2711 def Deflection1D(self, d, UseExisting=0):
2712 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
2713 CompareMethod=self.CompareDeflection1D)
2714 hyp.SetDeflection(d)
2717 ## Check if the given "Deflection1D" hypothesis has the same parameters as the given arguments
2718 def CompareDeflection1D(self, hyp, args):
2719 return IsEqual(hyp.GetDeflection(), args[0])
2721 ## Defines "Propagation" hypothesis that propagates all other hypotheses on all other edges that are at
2722 # the opposite side in case of quadrangular faces
2723 def Propagation(self):
2724 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
2726 ## Defines "AutomaticLength" hypothesis
2727 # @param fineness for the fineness [0-1]
2728 # @param UseExisting if ==true - searches for an existing hypothesis created with the
2729 # same parameters, else (default) - create a new one
2730 def AutomaticLength(self, fineness=0, UseExisting=0):
2731 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
2732 CompareMethod=self.CompareAutomaticLength)
2733 hyp.SetFineness( fineness )
2736 ## Checks if the given "AutomaticLength" hypothesis has the same parameters as the given arguments
2737 def CompareAutomaticLength(self, hyp, args):
2738 return IsEqual(hyp.GetFineness(), args[0])
2740 ## Defines "SegmentLengthAroundVertex" hypothesis
2741 # @param length for the segment length
2742 # @param vertex for the length localization: the vertex index [0,1] | vertex object.
2743 # Any other integer value means that the hypothesis will be set on the
2744 # whole 1D shape, where Mesh_Segment algorithm is assigned.
2745 # @param UseExisting if ==true - searches for an existing hypothesis created with
2746 # the same parameters, else (default) - creates a new one
2747 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
2749 store_geom = self.geom
2750 if type(vertex) is types.IntType:
2751 if vertex == 0 or vertex == 1:
2752 vertex = self.mesh.geompyD.SubShapeAllSorted(self.geom, geompyDC.ShapeType["VERTEX"])[vertex]
2760 if self.geom is None:
2761 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
2762 name = GetName(self.geom)
2764 piece = self.mesh.geom
2765 name = self.mesh.geompyD.SubShapeName(self.geom, piece)
2766 self.mesh.geompyD.addToStudyInFather(piece, self.geom, name)
2767 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
2769 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
2771 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
2772 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
2774 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
2775 CompareMethod=self.CompareLengthNearVertex)
2776 self.geom = store_geom
2777 hyp.SetLength( length )
2780 ## Checks if the given "LengthNearVertex" hypothesis has the same parameters as the given arguments
2781 def CompareLengthNearVertex(self, hyp, args):
2782 return IsEqual(hyp.GetLength(), args[0])
2784 ## Defines "QuadraticMesh" hypothesis, forcing construction of quadratic edges.
2785 # If the 2D mesher sees that all boundary edges are quadratic,
2786 # it generates quadratic faces, else it generates linear faces using
2787 # medium nodes as if they are vertices.
2788 # The 3D mesher generates quadratic volumes only if all boundary faces
2789 # are quadratic, else it fails.
2790 def QuadraticMesh(self):
2791 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
2794 # Public class: Mesh_CompositeSegment
2795 # --------------------------
2797 ## Defines a segment 1D algorithm for discretization
2799 class Mesh_CompositeSegment(Mesh_Segment):
2801 ## Private constructor.
2802 def __init__(self, mesh, geom=0):
2803 self.Create(mesh, geom, "CompositeSegment_1D")
2806 # Public class: Mesh_Segment_Python
2807 # ---------------------------------
2809 ## Defines a segment 1D algorithm for discretization with python function
2811 class Mesh_Segment_Python(Mesh_Segment):
2813 ## Private constructor.
2814 def __init__(self, mesh, geom=0):
2815 import Python1dPlugin
2816 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
2818 ## Defines "PythonSplit1D" hypothesis
2819 # @param n for the number of segments that cut an edge
2820 # @param func for the python function that calculates the length of all segments
2821 # @param UseExisting if ==true - searches for the existing hypothesis created with
2822 # the same parameters, else (default) - creates a new one
2823 def PythonSplit1D(self, n, func, UseExisting=0):
2824 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
2825 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
2826 hyp.SetNumberOfSegments(n)
2827 hyp.SetPythonLog10RatioFunction(func)
2830 ## Checks if the given "PythonSplit1D" hypothesis has the same parameters as the given arguments
2831 def ComparePythonSplit1D(self, hyp, args):
2832 #if hyp.GetNumberOfSegments() == args[0]:
2833 # if hyp.GetPythonLog10RatioFunction() == args[1]:
2837 # Public class: Mesh_Triangle
2838 # ---------------------------
2840 ## Defines a triangle 2D algorithm
2842 class Mesh_Triangle(Mesh_Algorithm):
2851 ## Private constructor.
2852 def __init__(self, mesh, algoType, geom=0):
2853 Mesh_Algorithm.__init__(self)
2855 self.algoType = algoType
2856 if algoType == MEFISTO:
2857 self.Create(mesh, geom, "MEFISTO_2D")
2859 elif algoType == BLSURF:
2861 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
2862 self.SetPhysicalMesh()
2863 elif algoType == NETGEN:
2865 print "Warning: NETGENPlugin module unavailable"
2867 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
2869 elif algoType == NETGEN_2D:
2871 print "Warning: NETGENPlugin module unavailable"
2873 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
2876 ## Defines "MaxElementArea" hypothesis basing on the definition of the maximum area of each triangle
2877 # @param area for the maximum area of each triangle
2878 # @param UseExisting if ==true - searches for an existing hypothesis created with the
2879 # same parameters, else (default) - creates a new one
2881 # Only for algoType == MEFISTO || NETGEN_2D
2882 def MaxElementArea(self, area, UseExisting=0):
2883 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
2884 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
2885 CompareMethod=self.CompareMaxElementArea)
2886 hyp.SetMaxElementArea(area)
2888 elif self.algoType == NETGEN:
2889 print "Netgen 1D-2D algo doesn't support this hypothesis"
2892 ## Checks if the given "MaxElementArea" hypothesis has the same parameters as the given arguments
2893 def CompareMaxElementArea(self, hyp, args):
2894 return IsEqual(hyp.GetMaxElementArea(), args[0])
2896 ## Defines "LengthFromEdges" hypothesis to build triangles
2897 # based on the length of the edges taken from the wire
2899 # Only for algoType == MEFISTO || NETGEN_2D
2900 def LengthFromEdges(self):
2901 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
2902 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
2904 elif self.algoType == NETGEN:
2905 print "Netgen 1D-2D algo doesn't support this hypothesis"
2908 ## Sets a way to define size of mesh elements to generate
2909 # @param thePhysicalMesh is: DefaultSize or Custom
2910 # Parameter of BLSURF algo
2911 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
2912 if self.params == 0:
2914 self.params.SetPhysicalMesh(thePhysicalMesh)
2916 ## Sets size of mesh elements to generate
2917 # Parameter of BLSURF algo
2918 def SetPhySize(self, theVal):
2919 if self.params == 0:
2921 self.params.SetPhySize(theVal)
2923 ## Sets a way to define maximum angular deflection of mesh from CAD model
2924 # @param theGeometricMesh is: DefaultGeom or Custom
2925 # Parameter of BLSURF algo
2926 def SetGeometricMesh(self, theGeometricMesh=0):
2927 if self.params == 0:
2929 if self.params.GetPhysicalMesh() == 0: theGeometricMesh = 1
2930 self.params.SetGeometricMesh(theGeometricMesh)
2932 ## Sets angular deflection (in degrees) of mesh from CAD model
2933 # Parameter of BLSURF algo
2934 def SetAngleMeshS(self, theVal=_angleMeshS):
2935 if self.params == 0:
2937 if self.params.GetGeometricMesh() == 0: theVal = self._angleMeshS
2938 self.params.SetAngleMeshS(theVal)
2940 ## Sets maximal allowed ratio between the lengths of two adjacent edges
2941 # Parameter of BLSURF algo
2942 def SetGradation(self, theVal=_gradation):
2943 if self.params == 0:
2945 if self.params.GetGeometricMesh() == 0: theVal = self._gradation
2946 self.params.SetGradation(theVal)
2948 ## Sets topology usage way defining how mesh conformity is assured:
2949 # FromCAD, PreProcess or PreProcessPlus
2950 # FromCAD - mesh conformity is assured by conformity of a shape
2951 # PreProcess or PreProcessPlus - by pre-processing a CAD model
2952 # Parameter of BLSURF algo
2953 def SetTopology(self, way):
2954 if self.params == 0:
2956 self.params.SetTopology(way)
2958 ## To respect geometrical edges or not
2959 # Parameter of BLSURF algo
2960 def SetDecimesh(self, toIgnoreEdges=False):
2961 if self.params == 0:
2963 self.params.SetDecimesh(toIgnoreEdges)
2965 ## Sets QuadAllowed flag
2967 # Only for algoType == NETGEN || NETGEN_2D || BLSURF
2968 def SetQuadAllowed(self, toAllow=True):
2969 if self.algoType == NETGEN_2D:
2970 if toAllow: # add QuadranglePreference
2971 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
2972 else: # remove QuadranglePreference
2973 for hyp in self.mesh.GetHypothesisList( self.geom ):
2974 if hyp.GetName() == "QuadranglePreference":
2975 self.mesh.RemoveHypothesis( self.geom, hyp )
2980 if self.params == 0:
2983 self.params.SetQuadAllowed(toAllow)
2986 ## Defines "Netgen 2D Parameters" hypothesis
2988 # Only for algoType == NETGEN
2989 def Parameters(self):
2992 if self.algoType == NETGEN:
2993 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
2994 "libNETGENEngine.so", UseExisting=0)
2996 elif self.algoType == MEFISTO:
2997 print "Mefisto algo doesn't support NETGEN_Parameters_2D hypothesis"
2999 elif self.algoType == NETGEN_2D:
3000 print "NETGEN_2D_ONLY algo doesn't support 'NETGEN_Parameters_2D' hypothesis"
3001 print "NETGEN_2D_ONLY uses 'MaxElementArea' and 'LengthFromEdges' ones"
3003 elif self.algoType == BLSURF:
3004 self.params = self.Hypothesis("BLSURF_Parameters", [],
3005 "libBLSURFEngine.so", UseExisting=0)
3011 # Only for algoType == NETGEN
3012 def SetMaxSize(self, theSize):
3013 if self.params == 0:
3015 if self.params is not None:
3016 self.params.SetMaxSize(theSize)
3018 ## Sets SecondOrder flag
3020 # Only for algoType == NETGEN
3021 def SetSecondOrder(self, theVal):
3022 if self.params == 0:
3024 if self.params is not None:
3025 self.params.SetSecondOrder(theVal)
3027 ## Sets Optimize flag
3029 # Only for algoType == NETGEN
3030 def SetOptimize(self, theVal):
3031 if self.params == 0:
3033 if self.params is not None:
3034 self.params.SetOptimize(theVal)
3037 # @param theFineness is:
3038 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3040 # Only for algoType == NETGEN
3041 def SetFineness(self, theFineness):
3042 if self.params == 0:
3044 if self.params is not None:
3045 self.params.SetFineness(theFineness)
3049 # Only for algoType == NETGEN
3050 def SetGrowthRate(self, theRate):
3051 if self.params == 0:
3053 if self.params is not None:
3054 self.params.SetGrowthRate(theRate)
3056 ## Sets NbSegPerEdge
3058 # Only for algoType == NETGEN
3059 def SetNbSegPerEdge(self, theVal):
3060 if self.params == 0:
3062 if self.params is not None:
3063 self.params.SetNbSegPerEdge(theVal)
3065 ## Sets NbSegPerRadius
3067 # Only for algoType == NETGEN
3068 def SetNbSegPerRadius(self, theVal):
3069 if self.params == 0:
3071 if self.params is not None:
3072 self.params.SetNbSegPerRadius(theVal)
3077 # Public class: Mesh_Quadrangle
3078 # -----------------------------
3080 ## Defines a quadrangle 2D algorithm
3082 class Mesh_Quadrangle(Mesh_Algorithm):
3084 ## Private constructor.
3085 def __init__(self, mesh, geom=0):
3086 Mesh_Algorithm.__init__(self)
3087 self.Create(mesh, geom, "Quadrangle_2D")
3089 ## Defines "QuadranglePreference" hypothesis, forcing construction
3090 # of quadrangles if the number of nodes on the opposite edges is not the same
3091 # while the total number of nodes on edges is even
3092 def QuadranglePreference(self):
3093 hyp = self.Hypothesis("QuadranglePreference", UseExisting=1,
3094 CompareMethod=self.CompareEqualHyp)
3097 # Public class: Mesh_Tetrahedron
3098 # ------------------------------
3100 ## Defines a tetrahedron 3D algorithm
3102 class Mesh_Tetrahedron(Mesh_Algorithm):
3107 ## Private constructor.
3108 def __init__(self, mesh, algoType, geom=0):
3109 Mesh_Algorithm.__init__(self)
3111 if algoType == NETGEN:
3112 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
3115 elif algoType == FULL_NETGEN:
3117 print "Warning: NETGENPlugin module has not been imported."
3118 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3121 elif algoType == GHS3D:
3123 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
3126 self.algoType = algoType
3128 ## Defines "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedron
3129 # @param vol for the maximum volume of each tetrahedron
3130 # @param UseExisting if ==true - searches for the existing hypothesis created with
3131 # the same parameters, else (default) - creates a new one
3132 def MaxElementVolume(self, vol, UseExisting=0):
3133 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
3134 CompareMethod=self.CompareMaxElementVolume)
3135 hyp.SetMaxElementVolume(vol)
3138 ## Checks if the given "MaxElementVolume" hypothesis has the same parameters as the given arguments
3139 def CompareMaxElementVolume(self, hyp, args):
3140 return IsEqual(hyp.GetMaxElementVolume(), args[0])
3142 ## Defines "Netgen 3D Parameters" hypothesis
3143 def Parameters(self):
3144 if (self.algoType == FULL_NETGEN):
3145 self.params = self.Hypothesis("NETGEN_Parameters", [],
3146 "libNETGENEngine.so", UseExisting=0)
3148 if (self.algoType == GHS3D):
3149 self.params = self.Hypothesis("GHS3D_Parameters", [],
3150 "libGHS3DEngine.so", UseExisting=0)
3153 print "Algo doesn't support this hypothesis"
3157 # Parameter of FULL_NETGEN
3158 def SetMaxSize(self, theSize):
3159 if self.params == 0:
3161 self.params.SetMaxSize(theSize)
3163 ## Sets SecondOrder flag
3164 # Parameter of FULL_NETGEN
3165 def SetSecondOrder(self, theVal):
3166 if self.params == 0:
3168 self.params.SetSecondOrder(theVal)
3170 ## Sets Optimize flag
3171 # Parameter of FULL_NETGEN
3172 def SetOptimize(self, theVal):
3173 if self.params == 0:
3175 self.params.SetOptimize(theVal)
3178 # @param theFineness is:
3179 # VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
3180 # Parameter of FULL_NETGEN
3181 def SetFineness(self, theFineness):
3182 if self.params == 0:
3184 self.params.SetFineness(theFineness)
3187 # Parameter of FULL_NETGEN
3188 def SetGrowthRate(self, theRate):
3189 if self.params == 0:
3191 self.params.SetGrowthRate(theRate)
3193 ## Sets NbSegPerEdge
3194 # Parameter of FULL_NETGEN
3195 def SetNbSegPerEdge(self, theVal):
3196 if self.params == 0:
3198 self.params.SetNbSegPerEdge(theVal)
3200 ## Sets NbSegPerRadius
3201 # Parameter of FULL_NETGEN
3202 def SetNbSegPerRadius(self, theVal):
3203 if self.params == 0:
3205 self.params.SetNbSegPerRadius(theVal)
3207 ## To mesh "holes" in a solid or not. Default is to mesh.
3208 # Parameter of GHS3D
3209 def SetToMeshHoles(self, toMesh):
3210 if self.params == 0: self.Parameters()
3211 self.params.SetToMeshHoles(toMesh)
3213 ## Set Optimization level:
3214 # None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization.
3215 # Default is Medium_Optimization
3216 # Parameter of GHS3D
3217 def SetOptimizationLevel(self, level):
3218 if self.params == 0: self.Parameters()
3219 self.params.SetOptimizationLevel(level)
3221 ## Maximal size of memory to be used by the algorithm (in Megabytes).
3222 # Advanced parameter of GHS3D
3223 def SetMaximumMemory(self, MB):
3224 if self.params == 0: self.Parameters()
3225 self.params.SetMaximumMemory(MB)
3227 ## Initial size of memory to be used by the algorithm (in Megabytes) in
3228 # automatic memory adjustment mode
3229 # Advanced parameter of GHS3D
3230 def SetInitialMemory(self, MB):
3231 if self.params == 0: self.Parameters()
3232 self.params.SetInitialMemory(MB)
3234 ## Path to working directory
3235 # Advanced parameter of GHS3D
3236 def SetWorkingDirectory(self, path):
3237 if self.params == 0: self.Parameters()
3238 self.params.SetWorkingDirectory(path)
3240 ## To keep working files or remove them. Log file remains in case of errors anyway
3241 # Advanced parameter of GHS3D
3242 def SetKeepFiles(self, toKeep):
3243 if self.params == 0: self.Parameters()
3244 self.params.SetKeepFiles(toKeep)
3246 # Public class: Mesh_Hexahedron
3247 # ------------------------------
3249 ## Defines a hexahedron 3D algorithm
3251 class Mesh_Hexahedron(Mesh_Algorithm):
3256 ## Private constructor.
3257 def __init__(self, mesh, algoType=Hexa, geom=0):
3258 Mesh_Algorithm.__init__(self)
3260 self.algoType = algoType
3262 if algoType == Hexa:
3263 self.Create(mesh, geom, "Hexa_3D")
3266 elif algoType == Hexotic:
3267 import HexoticPlugin
3268 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
3271 ## Defines "MinMaxQuad" hypothesis to give three hexotic parameters
3272 def MinMaxQuad(self, min=3, max=8, quad=True):
3273 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
3275 self.params.SetHexesMinLevel(min)
3276 self.params.SetHexesMaxLevel(max)
3277 self.params.SetHexoticQuadrangles(quad)
3280 # Deprecated, only for compatibility!
3281 # Public class: Mesh_Netgen
3282 # ------------------------------
3284 ## Defines a NETGEN-based 2D or 3D algorithm
3285 # that needs no discrete boundary (i.e. independent)
3287 # This class is deprecated, only for compatibility!
3290 class Mesh_Netgen(Mesh_Algorithm):
3294 ## Private constructor.
3295 def __init__(self, mesh, is3D, geom=0):
3296 Mesh_Algorithm.__init__(self)
3299 print "Warning: NETGENPlugin module has not been imported."
3303 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
3307 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
3310 ## Defines the hypothesis containing parameters of the algorithm
3311 def Parameters(self):
3313 hyp = self.Hypothesis("NETGEN_Parameters", [],
3314 "libNETGENEngine.so", UseExisting=0)
3316 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
3317 "libNETGENEngine.so", UseExisting=0)
3320 # Public class: Mesh_Projection1D
3321 # ------------------------------
3323 ## Defines a projection 1D algorithm
3325 class Mesh_Projection1D(Mesh_Algorithm):
3327 ## Private constructor.
3328 def __init__(self, mesh, geom=0):
3329 Mesh_Algorithm.__init__(self)
3330 self.Create(mesh, geom, "Projection_1D")
3332 ## Defines "Source Edge" hypothesis, specifying a meshed edge, from where
3333 # a mesh pattern is taken, and, optionally, the association of vertices
3334 # between the source edge and a target edge (to which a hypothesis is assigned)
3335 # @param edge from which nodes distribution is taken
3336 # @param mesh from which nodes distribution is taken (optional)
3337 # @param srcV a vertex of \a edge to associate with \a tgtV (optional)
3338 # @param tgtV a vertex of \a the edge to which the algorithm is assigned,
3339 # to associate with \a srcV (optional)
3340 # @param UseExisting if ==true - searches for the existing hypothesis created with
3341 # the same parameters, else (default) - creates a new one
3342 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
3343 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
3345 #UseExisting=UseExisting, CompareMethod=self.CompareSourceEdge)
3346 hyp.SetSourceEdge( edge )
3347 if not mesh is None and isinstance(mesh, Mesh):
3348 mesh = mesh.GetMesh()
3349 hyp.SetSourceMesh( mesh )
3350 hyp.SetVertexAssociation( srcV, tgtV )
3353 ## Checks if the given "SourceEdge" hypothesis has the same parameters as the given arguments
3354 #def CompareSourceEdge(self, hyp, args):
3355 # # it does not seem to be useful to reuse the existing "SourceEdge" hypothesis
3359 # Public class: Mesh_Projection2D
3360 # ------------------------------
3362 ## Defines a projection 2D algorithm
3364 class Mesh_Projection2D(Mesh_Algorithm):
3366 ## Private constructor.
3367 def __init__(self, mesh, geom=0):
3368 Mesh_Algorithm.__init__(self)
3369 self.Create(mesh, geom, "Projection_2D")
3371 ## Defines "Source Face" hypothesis, specifying a meshed face, from where
3372 # a mesh pattern is taken, and, optionally, the association of vertices
3373 # between the source face and the target face (to which a hypothesis is assigned)
3374 # @param face from which the mesh pattern is taken
3375 # @param mesh from which the mesh pattern is taken (optional)
3376 # @param srcV1 a vertex of \a face to associate with \a tgtV1 (optional)
3377 # @param tgtV1 a vertex of \a the face to which the algorithm is assigned,
3378 # to associate with \a srcV1 (optional)
3379 # @param srcV2 a vertex of \a face to associate with \a tgtV1 (optional)
3380 # @param tgtV2 a vertex of \a the face to which the algorithm is assigned,
3381 # to associate with \a srcV2 (optional)
3382 # @param UseExisting if ==true - forces the search for the existing hypothesis created with
3383 # the same parameters, else (default) - forces the creation a new one
3385 # Note: all association vertices must belong to one edge of a face
3386 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
3387 srcV2=None, tgtV2=None, UseExisting=0):
3388 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
3390 #UseExisting=UseExisting, CompareMethod=self.CompareSourceFace)
3391 hyp.SetSourceFace( face )
3392 if not mesh is None and isinstance(mesh, Mesh):
3393 mesh = mesh.GetMesh()
3394 hyp.SetSourceMesh( mesh )
3395 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3398 ## Checks if the given "SourceFace" hypothesis has the same parameters as the given arguments
3399 #def CompareSourceFace(self, hyp, args):
3400 # # it does not seem to be useful to reuse the existing "SourceFace" hypothesis
3403 # Public class: Mesh_Projection3D
3404 # ------------------------------
3406 ## Defines a projection 3D algorithm
3408 class Mesh_Projection3D(Mesh_Algorithm):
3410 ## Private constructor.
3411 def __init__(self, mesh, geom=0):
3412 Mesh_Algorithm.__init__(self)
3413 self.Create(mesh, geom, "Projection_3D")
3415 ## Defines the "Source Shape 3D" hypothesis, specifying a meshed solid, from where
3416 # the mesh pattern is taken, and, optionally, the association of vertices
3417 # between the source and the target solid (to which a hipothesis is assigned)
3418 # @param solid from where the mesh pattern is taken
3419 # @param mesh from where the mesh pattern is taken (optional)
3420 # @param srcV1 a vertex of \a solid to associate with \a tgtV1 (optional)
3421 # @param tgtV1 a vertex of \a the solid where the algorithm is assigned,
3422 # to associate with \a srcV1 (optional)
3423 # @param srcV2 a vertex of \a solid to associate with \a tgtV1 (optional)
3424 # @param tgtV2 a vertex of \a the solid to which the algorithm is assigned,
3425 # to associate with \a srcV2 (optional)
3426 # @param UseExisting - if ==true - searches for the existing hypothesis created with
3427 # the same parameters, else (default) - creates a new one
3429 # Note: association vertices must belong to one edge of a solid
3430 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
3431 srcV2=0, tgtV2=0, UseExisting=0):
3432 hyp = self.Hypothesis("ProjectionSource3D",
3433 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
3435 #UseExisting=UseExisting, CompareMethod=self.CompareSourceShape3D)
3436 hyp.SetSource3DShape( solid )
3437 if not mesh is None and isinstance(mesh, Mesh):
3438 mesh = mesh.GetMesh()
3439 hyp.SetSourceMesh( mesh )
3440 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
3443 ## Checks if the given "SourceShape3D" hypothesis has the same parameters as given arguments
3444 #def CompareSourceShape3D(self, hyp, args):
3445 # # seems to be not really useful to reuse existing "SourceShape3D" hypothesis
3449 # Public class: Mesh_Prism
3450 # ------------------------
3452 ## Defines a 3D extrusion algorithm
3454 class Mesh_Prism3D(Mesh_Algorithm):
3456 ## Private constructor.
3457 def __init__(self, mesh, geom=0):
3458 Mesh_Algorithm.__init__(self)
3459 self.Create(mesh, geom, "Prism_3D")
3461 # Public class: Mesh_RadialPrism
3462 # -------------------------------
3464 ## Defines a Radial Prism 3D algorithm
3466 class Mesh_RadialPrism3D(Mesh_Algorithm):
3468 ## Private constructor.
3469 def __init__(self, mesh, geom=0):
3470 Mesh_Algorithm.__init__(self)
3471 self.Create(mesh, geom, "RadialPrism_3D")
3473 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
3474 self.nbLayers = None
3476 ## Return 3D hypothesis holding the 1D one
3477 def Get3DHypothesis(self):
3478 return self.distribHyp
3480 ## Private method creating a 1D hypothesis and storing it in the LayerDistribution
3481 # hypothesis. Returns the created hypothesis
3482 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
3483 #print "OwnHypothesis",hypType
3484 if not self.nbLayers is None:
3485 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
3486 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
3487 study = self.mesh.smeshpyD.GetCurrentStudy() # prevents publishing own 1D hypothesis
3488 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
3489 self.mesh.smeshpyD.SetCurrentStudy( study ) # enables publishing
3490 self.distribHyp.SetLayerDistribution( hyp )
3493 ## Defines "NumberOfLayers" hypothesis, specifying the number of layers of
3494 # prisms to build between the inner and outer shells
3495 # @param UseExisting if ==true - searches for the existing hypothesis created with
3496 # the same parameters, else (default) - creates a new one
3497 def NumberOfLayers(self, n, UseExisting=0):
3498 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
3499 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
3500 CompareMethod=self.CompareNumberOfLayers)
3501 self.nbLayers.SetNumberOfLayers( n )
3502 return self.nbLayers
3504 ## Checks if the given "NumberOfLayers" hypothesis has the same parameters as the given arguments
3505 def CompareNumberOfLayers(self, hyp, args):
3506 return IsEqual(hyp.GetNumberOfLayers(), args[0])
3508 ## Defines "LocalLength" hypothesis, specifying the segment length
3509 # to build between the inner and the outer shells
3510 # @param l the length of segments
3511 # @param p the precision of rounding
3512 def LocalLength(self, l, p=1e-07):
3513 hyp = self.OwnHypothesis("LocalLength", [l,p])
3518 ## Defines "NumberOfSegments" hypothesis, specifying the number of layers of
3519 # prisms to build between the inner and the outer shells.
3520 # @param n the number of layers
3521 # @param s the scale factor (optional)
3522 def NumberOfSegments(self, n, s=[]):
3524 hyp = self.OwnHypothesis("NumberOfSegments", [n])
3526 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
3527 hyp.SetDistrType( 1 )
3528 hyp.SetScaleFactor(s)
3529 hyp.SetNumberOfSegments(n)
3532 ## Defines "Arithmetic1D" hypothesis, specifying the distribution of segments
3533 # to build between the inner and the outer shells with a length that changes in arithmetic progression
3534 # @param start the length of the first segment
3535 # @param end the length of the last segment
3536 def Arithmetic1D(self, start, end ):
3537 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
3538 hyp.SetLength(start, 1)
3539 hyp.SetLength(end , 0)
3542 ## Defines "StartEndLength" hypothesis, specifying distribution of segments
3543 # to build between the inner and the outer shells as geometric length increasing
3544 # @param start for the length of the first segment
3545 # @param end for the length of the last segment
3546 def StartEndLength(self, start, end):
3547 hyp = self.OwnHypothesis("StartEndLength", [start, end])
3548 hyp.SetLength(start, 1)
3549 hyp.SetLength(end , 0)
3552 ## Defines "AutomaticLength" hypothesis, specifying the number of segments
3553 # to build between the inner and outer shells
3554 # @param fineness defines the quality of the mesh within the range [0-1]
3555 def AutomaticLength(self, fineness=0):
3556 hyp = self.OwnHypothesis("AutomaticLength")
3557 hyp.SetFineness( fineness )
3560 # Private class: Mesh_UseExisting
3561 # -------------------------------
3562 class Mesh_UseExisting(Mesh_Algorithm):
3564 def __init__(self, dim, mesh, geom=0):
3566 self.Create(mesh, geom, "UseExisting_1D")
3568 self.Create(mesh, geom, "UseExisting_2D")