1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
|
try:
# Linux
from libgeom2d.geom2d import *
except:
# Windows
from nglib.geom2d import *
import matplotlib.pyplot as plt
############################################################################
def plotgeom(self):
plt.close()
coords = self.PlotData()
for i in range(0,len(coords[2])):
plt.plot(coords[2][i],coords[3][i],color='b')
plt.axis('equal')
plt.xlim(coords[0])
plt.ylim(coords[1])
plt.show(block=False)
SplineGeometry.Plot = plotgeom
del plotgeom
############################################################################
def plotpointindex(self,show = True):
try:
self._txt
except:
self._txt = list()
if show:
if len(self._txt) == 0:
pi = self.PointData()
for i in range(0,len(pi[0])):
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'))
else:
pass
else:
for i in range(0,len(self._txt)):
try:
self._txt[i].remove()
except:
self._txt[i][0].remove()
self._txt.clear()
#plt.draw()
plt.show(block=False)
SplineGeometry.ShowPoints = plotpointindex
del plotpointindex
############################################################################
def plotdomainindex(self, show = True):
try:
self._dom
except:
self._dom = list()
if show:
if len(self._dom) == 0:
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'
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))
else:
pass
else:
for i in range(0,len(self._dom)):
self._dom[i].remove()
self._dom.clear()
#plt.draw()
plt.show(block=False)
SplineGeometry.ShowDomains = plotdomainindex
del 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]
|