# -*- coding: iso-8859-7 -*-
from math import fabs
from bisect import bisect
from p_gindplt import gfill
import com, mhk5
def kibot(x1, x2, er1, er2, c):
"Plot boxed type pipe."
#----
y = findminedafos (x1, x2)
#---- ----------------------c
p1 = bisect(com.kil, x1)
p2 = bisect(com.kil, x2) - 1
p = p1
xs = x1
xe = x2
ykat = getkatv(xs)
uDxf = com.frw["dxf"]
while p <= p2:
if getkatv(com.kil[p]) != ykat:
plotpartofkibot(xs, com.kil[p], y)
xs = com.kil[p]
ykat = getkatv (com.kil[p])
p += 1
plotpartofkibot (xs, xe, y)
#---- -------------------------c
x = (x1 - com.kil[0]) * com.pklx
y1 = c * (x1 - com.edafos[0][0]) + er1
y1 = (y1 - getkatv(x1) - com.paxos) * com.pkly + com.platit
y2 = (y - getkatv(x1)) * com.pkly + com.platit
uDxf.thanDxfPlotSolid4(x - com.pkol/2.0, y2,
x + com.pkol/2.0, y2,
x + com.pkol/2.0, y1, x - com.pkol/2.0, y1)
if x2 == com.edafos[com.ianoig][0]:
x = (x2 - com.kil[0]) * com.pklx
y1 = (er2 - getkatv(x2) - com.paxos) * com.pkly + com.platit
y2 = (y - getkatv(x2)) * com.pkly + com.platit
uDxf.thanDxfPlotSolid4(x - com.pkol/2.0, y2,
x + com.pkol/2.0, y2,
x + com.pkol/2.0, y1,
x - com.pkol/2.0, y1)
#=======================================================================
def findminedafos (x1, x2):
"Finds the minimum ground height between x1 and x2."
y1 = getedafos(x1)
y2 = getedafos(x2)
p1 = bisect(com.kil, x1)
p2 = bisect(com.kil, x2)
y = min(y1, y2)
for i in xrange(p1, p2): # p2 is bigger than x2, so don't check it
y = min(y, com.edaf[i])
return y
#=======================================================================
def plotpartofkibot(x1, x2, y):
"Plot part of boded type pipe."
px1 = (x1 - com.kil[0]) * com.pklx
py1 = (y - getkatv(x1)) * com.pkly + com.platit
px2 = (x2 - com.kil[0]) * com.pklx
py2 = py1 - com.paxosd * com.pkly
uDxf = com.frw["dxf"]
a = px1, px2, px2, px1, px1
b = py1, py1, py2, py2, py1
uDxf.thanDxfPlotPolyline(a, b)
gfill(uDxf, a, b, 45.0, com.GAP, 0)
#=======================================================================
def infos(kato):
if com.infosor:
orcomment(kato)
else:
er = getery(com.xthb)
gcomment(com.xthb, er)
#c=======================================================================
def orcomment (kato):
"Plots horizontal comments."
coms = readcomments()
#-----
n = 0
for com1 in coms: n = max(n, len(com1))
#-----
xp = (com.xthb - com.kil[0]) * com.pklx
yp = com.paper + com.plxm - com.um + com.dm - kato
xp = xp - n * com.HG * 0.5
#-----
uDxf = com.frw["dxf"]
uDxf.thanDxfSetLayer('SXOLIA_OR')
if com.infos1: uDxf.thanDxfSetLayer('SXOLIA1_OR')
for com1 in coms:
uDxf.thanDxfPlotSymbol(xp, yp, com.HG, com1, 0.0)
yp = yp - com.HG * 1.5
#=======================================================================
def calcplatoi():
"""
c----------------------------------------------------------------------c
c , , c
c c
c c
c c
c 1 - 0.3, 4 - 0.5, 10 - 0.8, 15 - 0.8, 30 - 1.5, c
c com.paxos = 0.217 * x^0.533 c
c c
c 1 - 0.2, 4 - 0.6, 10 - 1.0, 15 - 1.5, 30 - 1.5, c
c com.pkol = 0.346 * x^0.461 c
c c
c 1 - 0.5, 4 - 1.0, 10 - 1.0, 15 - 1.5, 30 - 1.5, c
c com.ythem = 0.595 * x^0.288 c
c 2 * c
c----------------------------------------------------------------------c
"""
#---- --------------------------------------c
dis = 0.0
for i in xrange(com.ianoig): #do i = 1, com.ianoig
if fabs(com.edafos[i+1][0] - com.edafos[i][0]) > dis:
dis = fabs(com.edafos[i+1][0] - com.edafos[i][0])
if com.ianoig == 0: dis = com.pl1
#---- ---------------------------------------------c
if com.paxos == 0.0:
com.paxos = 0.217 * dis**0.553
if com.paxosd == 0.0:
com.paxosd = com.paxos
if com.pkol == 0.0:
com.pkol = 0.346 * dis**0.461
com.pthem = 2.0 * com.pkol
if com.ythem == 0.0:
com.ythem = 0.595 * dis**0.288
#---- -------------------------------------------c
com.paxos = com.paxos * com.pkly
com.paxosd = com.paxosd * com.pkly
com.pkol = com.pkol * com.pklx
com.pthem = com.pthem * com.pklx
com.ythem = com.ythem * com.pkly
#======================================================================
def gcomment (x, y):
"""
c----------------------------------------------------------------------c
c ulep . c
c c
c----------------------------------------------------------------------c
"""
coms = readcomments()
wcomment(coms, x, y)
#===========================================================================
_oxi = frozenset(('', '', 'OXI', 'oxi'))
def readcomments():
"Reads comments lines which will be plotted."
#----- '',
#
coms = []
uLep = com.frw["lep"]
while True:
uLep.datLin()
dl = uLep.datCurline().rstrip()
if dl.strip() == '$': break
coms.append(dl)
if len(coms) > 0 and coms[0].strip() in _oxi:
coms = []
return coms
#=======================================================================
def wcomment(coms, x, y):
#---- . --------------c
if com.freeminheight != 0.0:
#---- com.paxos com.pkly cm ---------c
com.freeminheight = com.freeminheight - com.paxos / com.pkly
s = '. %.2f ' % com.freeminheight
coms.append(s)
lay = 'SXOLIA'
if com.infos1: lay= 'SXOLIA1'
uDxf = com.frw["dxf"]
uDxf.thanDxfSetLayer(lay)
rx = x
ry = y
x = (x - com.kil[0]) * com.pklx # cm
xb = x - len(coms) * com.HG * 1.5 # cm
maxy = com.TEXTFBEG + (y - getkatv(rx)) * com.pkly + com.platit # cm
#---- -------------------------------------------c
ys = com.paper
uDxf.thanDxfPlot (x, com.platit, 3)
uDxf.thanDxfPlot (x, ys, 2)
#---- ---------------------------------------c
mlen = 0
for com1 in coms: mlen = max(len(com1), mlen)
ys = maxy
#---- ---------------------------------------------c
for com1 in coms:
yb = ys
uDxf.thanDxfPlotSymbol(xb, yb, com.HG, com1, 90.0)
xb += com.HG * 1.5
rys = getery(rx)
ye = getedafos (rx)
#---- .. ------------------------------------------------c
uDxf.thanDxfSetLayer(lay+'_XTH')
xb = x + 2.0 * com.HG
s = '.. ' + mhk5.xfrm(rx, '%.2f')
yb = ys
uDxf.thanDxfPlotSymbol(xb, yb, com.HG, s, 90.0)
#---- -----------------------------------c
s = '=%.2f' % rys
yb = ys
xb = xb + 1.5 * com.HG
uDxf.thanDxfPlotSymbol(xb, yb, com.HG, s, 90.0)
#---- ------------------------------------c
s = '=%.2f' % ye
yb = ys
xb = xb + 1.5 * com.HG
uDxf.thanDxfPlotSymbol(xb, yb, com.HG, s, 90.0)
uDxf.thanDxfSetLayer ('TEXTL')
#=======================================================================
def getedafos(x):
"Gets the ground height at a defined station."
p2 = bisect(com.kil, x)
if p2 == 0:
if fabs(x-com.kil[0]) <= 0.01: return com.ery[0]
com.frw["lep"].er(" .. %.2f ." % com.xthb)
if p2 == len(com.kil):
if fabs(x-com.kil[-1]) <= 0.01: return com.ery[-1]
com.frw["lep"].er(" .. %.2f ." % com.xthb)
assert 0 < p2 < len(com.kil)
p1 = p2 - 1
return com.edaf[p1] + (x - com.kil[p1]) * (com.edaf[p2] - com.edaf[p1]) / (com.kil[p2] - com.kil[p1])
#=======================================================================
def getery(x):
"Gets the grade line height at a defined station."
p2 = bisect(com.kil, x)
if p2 == 0:
if fabs(x-com.kil[0]) <= 0.01: return com.ery[0]
com.frw["lep"].er(" .. %.2f ." % com.xthb)
if p2 == len(com.kil):
if fabs(x-com.kil[-1]) <= 0.01: return com.ery[-1]
com.frw["lep"].er(" .. %.2f ." % com.xthb)
assert 0 < p2 < len(com.kil)
p1 = p2 - 1
return com.ery[p1] + (x - com.kil[p1]) * (com.ery[p2] - com.ery[p1]) / (com.kil[p2] - com.kil[p1])
#=======================================================================
def getkatv (xth):
"Get the height of the (water)fall valid at the defined station."
if xth > com.katar[-1][0]: stoperr(30, sitem)
for x,y in com.katar:
if xth <= x: return y
assert 0, "THIS IS A BUG!!!!!!!!"
|