new functions added

This commit is contained in:
Christoph Wintersteiger 2014-09-16 16:38:30 +00:00
parent 43b0054c54
commit 82ff904582

View File

@ -11,25 +11,49 @@ def execfile(fname):
exec(open(fname).read()) exec(open(fname).read())
import matplotlib.pyplot as plt
def plotgeom(self): def plotgeom(self):
if plotgeom.plot:
plt.close()
coords = self.PlotData() coords = self.PlotData()
import matplotlib.pyplot as plt for i in range(0,len(coords[2])):
plt.plot(coords[2],coords[3]) plt.plot(coords[2][i],coords[3][i],color='b')
plt.axis('equal') plt.axis('equal')
plt.xlim(coords[0]) plt.xlim(coords[0])
plt.ylim(coords[1]) plt.ylim(coords[1])
plotgeom.plot = True
plt.show(block=False) plt.show(block=False)
def plotpointindex(self): plotgeom.plot = False
def plotpointindex(self,show = True):
if show:
if len(plotpointindex.txt) == 0:
pi = self.PointData() pi = self.PointData()
import matplotlib.pyplot as plt
for i in range(0,len(pi[0])): for i in range(0,len(pi[0])):
plt.text(pi[0][i],pi[1][i],str(pi[2][i])) plotpointindex.txt.append(plt.text(pi[0][i],pi[1][i],str(pi[2][i])))
plotpointindex.txt.append(plt.plot(pi[0][i],pi[1][i],'ro'))
else:
pass
else:
for i in range(0,len(plotpointindex.txt)):
try:
plotpointindex.txt[i].remove()
except:
plotpointindex.txt[i][0].remove()
plotpointindex.txt.clear()
#plt.draw()
plt.show(block=False) plt.show(block=False)
def plotdomainindex(self): plotpointindex.txt = list()
def plotdomainindex(self, show = True):
if show:
if len(plotdomainindex.txt) == 0:
segdata = self.SegmentData() segdata = self.SegmentData()
import matplotlib.pyplot as plt
for i in range(0,len(segdata[0])): for i in range(0,len(segdata[0])):
if segdata[0][i][2]: if segdata[0][i][2]:
horr = 'right' horr = 'right'
@ -43,11 +67,32 @@ def plotdomainindex(self):
else: else:
vertr = 'bottom' vertr = 'bottom'
vertl = 'top' vertl = 'top'
plotdomainindex.txt.append(plt.text(segdata[0][i][0],segdata[0][i][1],str(segdata[2][i]),horizontalalignment=horl,verticalalignment=vertl))
plt.text(segdata[0][i][0],segdata[0][i][1],str(segdata[2][i]),horizontalalignment=horl,verticalalignment=vertl) plotdomainindex.txt.append(plt.text(segdata[1][i][0],segdata[1][i][1],str(segdata[3][i]),horizontalalignment=horr,verticalalignment=vertr))
plt.text(segdata[1][i][0],segdata[1][i][1],str(segdata[3][i]),horizontalalignment=horr,verticalalignment=vertr) else:
pass
else:
for i in range(0,len(plotdomainindex.txt)):
plotdomainindex.txt[i].remove()
plotdomainindex.txt.clear()
#plt.draw()
plt.show(block=False) plt.show(block=False)
plotdomainindex.txt = list()
from nglib.meshing import *
from nglib.geom2d import *
SplineGeometry.Plot = plotgeom
SplineGeometry.ShowPoints = plotpointindex
SplineGeometry.ShowDomains = plotdomainindex
def Line(point_index1,point_index2):
return ["line",point_index1,point_index2]
def Spline3(point_index1,point_index2,point_index3):
return ["spline3",point_index1,point_index2,point_index3]
def startConsole(): def startConsole():
import code import code