2014-09-26 21:11:52 +06:00
|
|
|
try:
|
|
|
|
# Linux
|
|
|
|
from libgeom2d.geom2d import *
|
|
|
|
except:
|
|
|
|
# Windows
|
|
|
|
from nglib.geom2d import *
|
2014-09-10 17:17:37 +06:00
|
|
|
|
2014-09-16 22:38:30 +06:00
|
|
|
import matplotlib.pyplot as plt
|
2014-09-10 17:17:37 +06:00
|
|
|
|
2014-09-26 21:11:52 +06:00
|
|
|
############################################################################
|
2014-09-16 22:38:30 +06:00
|
|
|
|
2014-09-26 21:11:52 +06:00
|
|
|
def plotgeom(self):
|
|
|
|
plt.close()
|
2014-09-10 17:17:37 +06:00
|
|
|
coords = self.PlotData()
|
2014-09-16 22:38:30 +06:00
|
|
|
for i in range(0,len(coords[2])):
|
|
|
|
plt.plot(coords[2][i],coords[3][i],color='b')
|
|
|
|
|
2014-09-10 17:17:37 +06:00
|
|
|
plt.axis('equal')
|
|
|
|
plt.xlim(coords[0])
|
|
|
|
plt.ylim(coords[1])
|
|
|
|
plt.show(block=False)
|
|
|
|
|
2014-09-26 21:11:52 +06:00
|
|
|
SplineGeometry.Plot = plotgeom
|
|
|
|
del plotgeom
|
|
|
|
|
|
|
|
############################################################################
|
2014-09-16 22:38:30 +06:00
|
|
|
|
|
|
|
def plotpointindex(self,show = True):
|
2014-09-26 21:11:52 +06:00
|
|
|
try:
|
|
|
|
self._txt
|
|
|
|
except:
|
|
|
|
self._txt = list()
|
2014-09-16 22:38:30 +06:00
|
|
|
if show:
|
2014-09-26 21:11:52 +06:00
|
|
|
if len(self._txt) == 0:
|
2014-09-16 22:38:30 +06:00
|
|
|
pi = self.PointData()
|
|
|
|
for i in range(0,len(pi[0])):
|
2014-09-26 21:11:52 +06:00
|
|
|
self._txt.append(plt.text(pi[0][i],pi[1][i],str(pi[2][i])))
|
|
|
|
self._txt.append(plt.plot(pi[0][i],pi[1][i],'ro'))
|
2014-09-16 22:38:30 +06:00
|
|
|
else:
|
|
|
|
pass
|
|
|
|
else:
|
2014-09-26 21:11:52 +06:00
|
|
|
for i in range(0,len(self._txt)):
|
2014-09-16 22:38:30 +06:00
|
|
|
try:
|
2014-09-26 21:11:52 +06:00
|
|
|
self._txt[i].remove()
|
2014-09-16 22:38:30 +06:00
|
|
|
except:
|
2014-09-26 21:11:52 +06:00
|
|
|
self._txt[i][0].remove()
|
|
|
|
self._txt.clear()
|
2014-09-16 22:38:30 +06:00
|
|
|
#plt.draw()
|
2014-09-10 17:17:37 +06:00
|
|
|
plt.show(block=False)
|
|
|
|
|
2014-09-26 21:11:52 +06:00
|
|
|
SplineGeometry.ShowPoints = plotpointindex
|
|
|
|
del plotpointindex
|
|
|
|
|
|
|
|
############################################################################
|
|
|
|
|
2014-09-16 22:38:30 +06:00
|
|
|
def plotdomainindex(self, show = True):
|
2014-09-26 21:11:52 +06:00
|
|
|
try:
|
|
|
|
self._dom
|
|
|
|
except:
|
|
|
|
self._dom = list()
|
2014-09-16 22:38:30 +06:00
|
|
|
if show:
|
2014-09-26 21:11:52 +06:00
|
|
|
if len(self._dom) == 0:
|
2014-09-16 22:38:30 +06:00
|
|
|
segdata = self.SegmentData()
|
|
|
|
for i in range(0,len(segdata[0])):
|
|
|
|
if segdata[0][i][2]:
|
|
|
|
horr = 'right'
|
|
|
|
horl = 'left'
|
|
|
|
else:
|
|
|
|
horr = 'left'
|
|
|
|
horl = 'right'
|
|
|
|
if segdata[0][i][3]:
|
|
|
|
vertr = 'top'
|
|
|
|
vertl = 'bottom'
|
|
|
|
else:
|
|
|
|
vertr = 'bottom'
|
|
|
|
vertl = 'top'
|
2014-09-26 21:11:52 +06:00
|
|
|
self._dom.append(plt.text(segdata[0][i][0],segdata[0][i][1],str(segdata[2][i]),horizontalalignment=horl,verticalalignment=vertl))
|
|
|
|
self._dom.append(plt.text(segdata[1][i][0],segdata[1][i][1],str(segdata[3][i]),horizontalalignment=horr,verticalalignment=vertr))
|
2014-09-10 17:17:37 +06:00
|
|
|
else:
|
2014-09-16 22:38:30 +06:00
|
|
|
pass
|
|
|
|
else:
|
2014-09-26 21:11:52 +06:00
|
|
|
for i in range(0,len(self._dom)):
|
|
|
|
self._dom[i].remove()
|
|
|
|
self._dom.clear()
|
2014-09-16 22:38:30 +06:00
|
|
|
#plt.draw()
|
2014-09-10 17:17:37 +06:00
|
|
|
plt.show(block=False)
|
|
|
|
|
2014-09-16 22:38:30 +06:00
|
|
|
SplineGeometry.ShowDomains = plotdomainindex
|
2014-09-26 21:11:52 +06:00
|
|
|
del plotdomainindex
|
|
|
|
|
|
|
|
############################################################################
|
2014-09-16 22:38:30 +06:00
|
|
|
|
|
|
|
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]
|
|
|
|
|