Back to index

salome-smesh  6.5.0
Functions | Variables
batchmode_mefisto Namespace Reference

Functions

def CreateMesh

Variables

 smesh = batchmode_smesh.smesh

Function Documentation

def batchmode_mefisto.CreateMesh (   theFileName,
  area,
  len = None,
  nbseg = None 
)

Definition at line 35 of file batchmode_mefisto.py.

00035 
00036 def CreateMesh (theFileName, area, len = None, nbseg = None):
00037     
00038     if not(os.path.isfile(theFileName)) or re.search("\.brep$", theFileName) is None :
00039         print "Incorrect file name !"
00040         return
00041 
00042     if (len is None) and (nbseg is None):
00043         print "Define length or number of segments !"
00044         return
00045 
00046     if (len is not None) and (nbseg is not None):
00047         print "Only one Hypothesis (from length and number of segments) can be defined !"
00048         return
00049 
00050     
00051     # ----  Import shape from BREP file and add it to the study  
00052     shape_mesh = batchmode_geompy.Import(theFileName, "BREP")
00053     Id_shape = batchmode_geompy.addToStudy(shape_mesh, "shape_mesh")
00054 
00055 
00056     # ---- SMESH
00057     print "-------------------------- create mesh"
00058     mesh = smesh.Mesh(shape_mesh)
00059       
00060     print "-------------------------- create Hypothesis"
00061     if (len is not None):
00062         print "-------------------------- LocalLength"
00063         algoReg = mesh.Segment()
00064         hypLength1 = algoReg.LocalLength(len)
00065         print "Hypothesis type : ", hypLength1.GetName()
00066         print "Hypothesis ID   : ", hypLength1.GetId()
00067         print "Hypothesis Value: ", hypLength1.GetLength()
00068     
00069     if (nbseg is not None):   
00070         print "-------------------------- NumberOfSegments"
00071         algoReg = mesh.Segment()
00072         hypNbSeg1 = algoReg.NumberOfSegments(nbseg)
00073         print "Hypothesis type : ", hypNbSeg1.GetName()
00074         print "Hypothesis ID   : ", hypNbSeg1.GetId()
00075         print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments()
00076 
00077     if (area == "LengthFromEdges"):
00078         print "-------------------------- LengthFromEdges"
00079         algoMef = mesh.Triangle()
00080         hypLengthFromEdges = algoMef.LengthFromEdges(1)
00081         print "Hypothesis type     : ", hypLengthFromEdges.GetName()
00082         print "Hypothesis ID       : ", hypLengthFromEdges.GetId()
00083         print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode()
00084        
00085     else:
00086         print "-------------------------- MaxElementArea"
00087         algoMef = mesh.Triangle()
00088         hypArea1 = algoMef.MaxElementArea(area)
00089         print "Hypothesis type : ", hypArea1.GetName()
00090         print "Hypothesis ID   : ", hypArea1.GetId()
00091         print "Hypothesis Value: ", hypArea1.GetMaxElementArea()
00092               
00093     
00094     print "-------------------------- Regular_1D"
00095     listHyp = algoReg.GetCompatibleHypothesis()
00096     for hyp in listHyp:
00097         print hyp
00098     
00099     print "Algo name: ", algoReg.GetName()
00100     print "Algo ID  : ", algoReg.GetId()
00101    
00102     print "-------------------------- MEFISTO_2D"
00103     listHyp = algoMef.GetCompatibleHypothesis()
00104     for hyp in listHyp:
00105         print hyp
00106         
00107     print "Algo name: ", algoMef.GetName()
00108     print "Algo ID  : ", algoMef.GetId()
00109 
00110 
00111     # ---- add hypothesis to shape
00112 
00113     print "-------------------------- compute mesh"
00114     ret = mesh.Compute()
00115     print  "Compute Mesh .... ", 
00116     print ret
00117     log = mesh.GetLog(0); # no erase trace
00118     #for linelog in log:
00119     #    print linelog
00120 
00121     print "------------ INFORMATION ABOUT MESH ------------"
00122     
00123     print "Number of nodes    : ", mesh.NbNodes()
00124     print "Number of edges    : ", mesh.NbEdges()
00125     print "Number of faces    : ", mesh.NbFaces()
00126     print "Number of triangles: ", mesh.NbTriangles()
00127 
00128     return mesh

Variable Documentation

Definition at line 32 of file batchmode_mefisto.py.