mhk2.py :  » Business-Application » ThanCad » thancad-0.0.9 » p_gmhk » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » ThanCad 
ThanCad » thancad 0.0.9 » p_gmhk » mhk2.py
# -*- coding: iso-8859-7 -*-

from math import fabs,atan,sin,cos
from bisect import bisect
from p_gindplt import elips1,gfill
from p_gvec import Vector2
import com, mhk3, mhk5

LEP = ["", 
       " ",
       " ",
       "",                #  1,   ,   1 
       "",
       " ",
       "",
       "8",                       #   8
       "1",                       #   1
       " ",
       "1",                        #  1
       "2",                        #  2
       "3",                        #  3
       "4",                        #  4
       "",                       #  
       "",                       #   
       "",                       #   
      ] 

      
def leptomeries():
      "Plot drawing details."
#----------------------------------------------------------------------c
# reading  true                             c
# working  true          c
#                                                              c
# xtha     ..                                       c
# com.pl1, com.pl2 ,           c
# com.ianoig                                       c
# com.paxos                                                    c
# comment                                            c
#----------------------------------------------------------------------c
      begcom = False                     # Hardwired by the program
      endcom = False                     # Hardwired by the program
      com.lepcount = 0
      uLep = com.frw["lep"]
      while True:
          if not uLep.datLin(failoneof=False):
              coma = ['']
              x = com.kil[0]
              y = com.ery[1]
              if begcom: wcomment(coma, 1, x, y)
              coma = ['']
              x = com.kil[-1]
              y = com.ery[-1]
              if endcom: wcomment(coma, 1, x, y)
              return
          com.sitembig = uLep.datCurline().strip()
          com.sitem = com.sitembig[:4].strip()
          com.lepcount += 1
#c----------------------------------------------------------------------c
#c---     .       --c
#c---          --c
#c---                                     --c
#c----------------------------------------------------------------------c
          com.freeminheight = 0.0
          if com.sitem in ('', '', ''):
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
              com.mikos = uLep.datFloat()
              com.pl1 = uLep.datFloat()
              com.pl2 = uLep.datFloat()
              uLep.datLin()
              com.lepcount += 1
              if com.sitem == '':
                  com.ianoig = uLep.datInt()
                  com.paxos = uLep.datFloat()
                  com.paxosd = uLep.datFloat()
              else:
                  com.ianoig = uLep.datInt()
                  com.paxos = uLep.datFloat()
              if com.ianoig > com.ANOIGM: mhk5.stoperr(3, com.sitem)
              uLep.datLin()
              com.lepcount += 1
              com.pkol = uLep.datFloat()
              com.pthem  = uLep.datFloat()
              com.ythem = uLep.datFloat()
              if uLep.eol(): com.freeminheight = 0.0
        else:          com.freeminheight = uLep.datFloat()
              com.edafos[0] = [com.xthb, None]
              com.edafos[1] = [com.xthb + com.pl1, None]
              if com.ianoig - 2 > 0: step = (com.mikos-com.pl1-com.pl2) / (com.ianoig-2)
              for i in xrange(2, com.ianoig-1):       # do i = 3, com.ianoig-1
                  com.edafos[i] = [com.edafos[i-1][0] + step, None]
              if com.ianoig > 2:
                  com.edafos[com.ianoig-1] = [com.xthb + com.mikos - com.pl2, None]
                  com.edafos[com.ianoig]   = [com.xthb + com.mikos, None]
              else:
                  com.edafos[com.ianoig] = [com.xthb + com.mikos, None]
              bridge()
          elif com.sitem == '':                        #  
              com.infos1 =  "1" in com.sitembig                #   layer 'sxolia1'
              com.infosor = '' in com.sitembig             #  
              dl = uLep.datRawline()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
        if uLep.eol(): kato = 0.0
        else:          kato = uLep.datFloat()
              mhk3.infos(kato)
              com.infos1 = False
              com.infosor = False
          elif com.sitem == '':
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
              com.ythb = uLep.datFloat()
              com.kl1 = uLep.datFloat()
              com.kl2 = uLep.datFloat()
              uLep.datLin()
              com.lepcount += 1
              com.pl1 = uLep.datFloat()
              com.pl2 = uLep.datFloat()
              road()
          elif com.sitem == '':
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
              com.ythb = uLep.datFloat()
              com.pl1 = uLep.datFloat()
              pipe()
          elif com.sitem == '':
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
        if uLep.eol(): kato = 0.0
        else:          kato = uLep.datFloat()
              ydrolipsia(kato)
          elif com.sitem == '8':
#              read (dl, '(2f15.0,a15)', iostat=ierr) com.xthb, kato, s
              uLep.datLin()
              com.lepcount += 1
              dl = uLep.DatRawline()
              dl = dl[:30] + "'" + dl[30:] + "'"
              uLep.datLinSet(dl)
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              s = uLep.datStr().rstrip()
              diklida8(kato,s)
          elif com.sitem == '1':
#              read (dl, '(2f15.0,a15)', iostat=ierr) com.xthb, kato, s
              uLep.datLin()
              com.lepcount += 1
              dl = uLep.DatRawline()
              dl = dl[:30] + "'" + dl[30:] + "'"
              uLep.datLinSet(dl)
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              s = uLep.datStr().rstrip()
              diklida1(kato,s)
          elif com.sitem == '2':
#              read (dl, '(2f15.0,a15)', iostat=ierr) com.xthb, kato, s
              uLep.datLin()
              com.lepcount += 1
              dl = uLep.DatRawline()
              dl = dl[:30] + "'" + dl[30:] + "'"
              uLep.datLinSet(dl)
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              s = uLep.datStr().rstrip()
              antiplhgmatikh(kato,s)
          elif com.sitem in ('1', '2', '3', '4'):
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              aereksagogos(kato)
          elif com.sitem == '':
#              read (dl, '(2f15.0,2a15)', iostat=ierr) com.xthb, kato, s, s1
              uLep.datLin()
              com.lepcount += 1
              dl = uLep.DatRawline()
              dl = dl[:30] + "'" + dl[30:45] + "' '" + dl[45:] + "'"
              uLep.datLinSet(dl)
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              s = uLep.datStr().rstrip()
              s1 = uLep.datStr().rstrip()
              symbolh(kato,s,s1)
          elif com.sitem == '':
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              agrotikosdromosb(kato)
          elif com.sitem == '':
              uLep.datLin()
              com.lepcount += 1
              com.xthb = uLep.datFloat()
              kato = uLep.datFloat()
              agrotikosdromosa(kato)
          else:
              mhk5.stoperr(4, com.sitem)
      
#=======================================================================

def symbolh(kato, s, s1):
      "Plot Symbolh of roads."
      s = s.strip()
      s1 = s1.strip()
      uDxf = com.frw["dxf"]
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato

      uDxf.thanDxfPlot(xp,yp-0.5*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp-3.0*com.pkly,2)
      uDxf.thanDxfPlotCircle(xp,yp,0.5*com.pkly)
      uDxf.thanDxfPlot(xp,yp-0.5*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp+0.5*com.pkly,2)
      uDxf.thanDxfPlot(xp+0.6*com.pkly,yp,3)
      uDxf.thanDxfPlot(xp+3.1*com.pkly,yp,2)
      uDxf.thanDxfPlotSymbol(xp+0.6*com.pkly,yp+com.HG*com.pkly*0.8,com.HG*0.8,s,0.0)
      uDxf.thanDxfPlotSymbol(xp+0.6*com.pkly,yp-com.HG*com.pkly*2.0,com.HG*0.8,s1,0.0)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def agrotikosdromosb(kato):
      "Plot rural road intersection - type b."
      uDxf = com.frw["dxf"]
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato
      uDxf.thanDxfPlotSolid3(xp,yp,xp+1.7*com.pkly,yp-0.375*com.pkly,xp,yp-0.75*com.pkly)
      uDxf.thanDxfPlot(xp,yp-0.75*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp-3.15*com.pkly,2)
      uDxf.thanDxfPlotSolid4(xp-0.175*com.pkly, yp-3.15*com.pkly,
                             xp+0.175*com.pkly, yp-3.15*com.pkly,
                             xp+0.175*com.pkly, yp-3.5 *com.pkly,
                             xp-0.175*com.pkly, yp-3.5 *com.pkly)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def agrotikosdromosa(kato):
      "Plot rural road intersection - type a."
      uDxf = com.frw["dxf"]
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato
      uDxf.thanDxfPlotSolid4(xp,                yp,
                             xp+0.6*com.pkly,   yp,
                             xp+0.6*com.pkly,   yp-0.55*com.pkly,
                             xp,                yp-0.55*com.pkly)
      uDxf.thanDxfPlotSolid3(xp+0.6*com.pkly,   yp,
                             xp+1.15*com.pkly,  yp,
                             xp+0.6*com.pkly,   yp-0.275*com.pkly)
      uDxf.thanDxfPlotSolid3(xp+0.6*com.pkly,   yp-0.275*com.pkly,
                             xp+1.15*com.pkly,  yp-0.55*com.pkly,
                             xp+0.6*com.pkly,   yp-0.55*com.pkly)
      uDxf.thanDxfPlot(xp,yp-0.55*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp-2.65*com.pkly,2)
      uDxf.thanDxfPlotSolid4(xp-0.175*com.pkly, yp-2.65*com.pkly,
                             xp+0.175*com.pkly, yp-2.65*com.pkly,
                             xp+0.175*com.pkly, yp-3.0*com.pkly,
                             xp-0.175*com.pkly, yp-3.0*com.pkly)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def ydrolipsia(kato):
      "Plot irrigation water hose."
      uDxf = com.frw["dxf"]
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato

      uDxf.thanDxfPlotSolid3(xp,               yp,
                             xp-0.05*com.pkly, yp-0.4*com.pkly,
                             xp+0.05*com.pkly, yp-0.4*com.pkly)
      uDxf.thanDxfPlot(xp,yp-0.4*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp-1.0*com.pkly,2)
      uDxf.thanDxfPlot(xp,yp-1.4*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp-2.5*com.pkly,2)
      uDxf.thanDxfPlotCircle(xp,yp-1.2*com.pkly,0.2*com.pkly)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def diklida8(kato, sname):
      "Plot irrigation security door - type 8."
      uDxf = com.frw["dxf"]
      sname = sname.strip()
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato

      uDxf.thanDxfPlotPolyVertex(xp-0.4*com.pkly,yp-0.25*com.pkly,3)
      uDxf.thanDxfPlotPolyVertex(xp+0.4*com.pkly,yp+0.25*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.4*com.pkly,yp-0.25*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp-0.4*com.pkly,yp+0.25*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp-0.4*com.pkly,yp-0.25*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(0.0,0.0,999)
      uDxf.thanDxfPlot(xp, yp, 3)
      uDxf.thanDxfPlot(xp, yp-2.75*com.pkly, 2)
      uDxf.thanDxfPlotSymbol(xp-com.HG*com.pkly*0.7,yp-2.7*com.pkly,com.HG*0.8,sname,90.0)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def diklida1(kato,sname):
      "Plot irrigation security door - type 8."
      uDxf = com.frw["dxf"]
      sname = sname.strip()
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato
      uDxf.thanDxfPlotPolyVertex(xp,yp,3)
      uDxf.thanDxfPlotPolyVertex(xp,yp-1.0*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.35*com.pkly,yp-1.0*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.35*com.pkly,yp-2.2*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(0.0,0.0,999)
#------  ----------------------------------------------------c
      uDxf.thanDxfPlotPolyVertex(xp+0.15*com.pkly,yp-2.2*com.pkly,3)
      uDxf.thanDxfPlotPolyVertex(xp+0.55*com.pkly,yp-2.2*com.pkly,3)
      uDxf.thanDxfPlotPolyVertex(xp+0.15*com.pkly,yp-3.0*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.55*com.pkly,yp-3.0*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.15*com.pkly,yp-2.2*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(0.0,0.0,999)
      uDxf.thanDxfPlot(xp+0.35*com.pkly,yp-3.0*com.pkly,3)
      uDxf.thanDxfPlot(xp+0.35*com.pkly,yp-3.55*com.pkly,2)
      uDxf.thanDxfPlotSolid3(xp+0.3*com.pkly,  yp-3.55*com.pkly,
                             xp+0.4*com.pkly,  yp-3.55*com.pkly,
                             xp+0.35*com.pkly, yp-3.95*com.pkly)
      uDxf.thanDxfPlotSymbol(xp+(0.55+com.HG)*com.pkly,yp-2.2*com.pkly,com.HG*0.8,sname,90.0)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def antiplhgmatikh(kato,sname):
      "Plot irrigation atiplcom.HGmatikh valve."
      uDxf = com.frw["dxf"]
      sname = sname.strip()
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato
      uDxf.thanDxfPlot(xp,yp-3.8*com.pkly,3)
      uDxf.thanDxfPlot(xp,yp,2)
      uDxf.thanDxfPlotPolyVertex(xp-0.6*com.pkly,yp-0.2*com.pkly,3)
      uDxf.thanDxfPlotPolyVertex(xp-0.6*com.pkly,yp,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.6*com.pkly,yp,2)
      uDxf.thanDxfPlotPolyVertex(xp+0.6*com.pkly,yp-0.2*com.pkly,2)
      uDxf.thanDxfPlotPolyVertex(0.0,0.0,999)
      c = (3.8*com.pkly-lens(sname)*com.HG*0.8)/3.0
      uDxf.thanDxfPlotSymbol(xp-com.HG*com.pkly*0.8,yp-3.8*com.pkly+c,com.HG*0.8,sname,90.0)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def aereksagogos(kato):
      "Plot irrigation air out."
      uDxf = com.frw["dxf"]
      uDxf.thanDxfSetLayer('TEXNIKA')
      xp = (com.xthb-com.kil[0])*com.pklx
      yp = com.paper + com.plxm - com.um + com.dm - kato
      uDxf.thanDxfPlot(xp, yp, 3)
      uDxf.thanDxfPlot(xp, yp-2.8*com.pkly, 2)
      uDxf.thanDxfPlot(xp-0.6*com.pkly, yp-0.6*com.pkly, 3)
      uDxf.thanDxfPlot(xp+0.6*com.pkly, yp-0.6*com.pkly, 2)
      uDxf.thanDxfPlotArc(xp,yp-0.6*com.pkly,0.6*com.pkly,0.0,180.0)
      c = (2.2-3.0*com.HG*0.8)*com.pkly/2.0
      uDxf.thanDxfPlotSymbol(xp-1.0*com.pklx,yp-2.8*com.pkly+c,com.HG*0.8,com.sitem,90.0)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def pipe():
      "Plot sewage pipe intersection."
      uDxf = com.frw["dxf"]
      if fabs(com.xthb) < 1.0e-6: com.xthb = 1.0e-3
      uDxf.thanDxfSetLayer('TEXNIKA')
      r = com.pl1
      xc = (com.xthb - com.kil[0]) * com.pklx
      yc = (com.ythb - mhk3.getkatv(com.xthb)) * com.pkly
      elips1(uDxf, xc + r*com.pklx, yc, xc - r*com.pklx, yc, xc, yc, r*com.pklx, r*com.pkly, 0.0, 0, 3)
      elips1(uDxf, xc - r*com.pklx, yc, xc + r*com.pklx, yc, xc, yc, r*com.pklx, r*com.pkly, 0.0, 0, 3)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#=======================================================================

def road():
      "Plot intersection with road."
      uDxf = com.frw["dxf"]
      if fabs(com.xthb) < 1.0e-6: com.xthb = 1.0e-3
      uDxf.thanDxfSetLayer('TEXNIKA')
#----       --------------------c
      p1 = bisect(com.kil, com.xthb)
      p2 = bisect(com.kil, com.xthb-com.pl1)
      p = p1 - 1
      xs = com.xthb
      ys = com.ythb
      xe = com.xthb - com.pl1
      ykat = mhk3.getkatv(xs)
      while p >= p2:
          print p1, p2, p
          if mhk3.getkatv(com.kil[p]) != ykat:
              plotpartofroad (xs, ys, com.kil[p], com.kl1, -1)
              ys = ys - com.kl1 * (xs - xe)
              xs = com.kil[p]
              ykat = mhk3.getkatv(com.kil[p])
          p -= 1
      plotpartofroad (xs, ys, xe, com.kl1, -1)

#----       -----------------------c
      p2 = bisect(com.kil, com.xthb+com.pl2) - 1
      p = p1
      xs = com.xthb
      ys = com.ythb
      xe = com.xthb + com.pl2
      ykat = mhk3.getkatv(xs)
      while p <= p2:
          if mhk3.getkatv(com.kil[p]) != ykat:
              plotpartofroad (xs, ys, com.kil[p], -com.kl2, 1)
              ys = ys + com.kl2 * (xs - xe)
              xs = com.kil[p]
              ykat = mhk3.getkatv (com.kil[p])
          p += 1
      plotpartofroad (xs, ys, xe, -com.kl2, 1)
      mhk3.gcomment(com.xthb, mhk3.getery(com.xthb))
      uDxf.thanDxfSetLayer ('TEXTL')

#======================================================================

def plotpartofroad (xs, ys, xe, rkl, id):
      "Plots part of intersection with road."
      uDxf = com.frw["dxf"]
      ang = atan(rkl)
      mik = fabs(xe - xs) / cos(ang)
      kat = mhk3.getkatv(xs)

      a = Vector2(xs, ys)
      b = Vector2(xs - id * cos(ang), ys + sin(ang))
      n = b - a
      n1 = n.normal() * (-id)          # Positive is on the right side
      a = n1 * (com.ROADWIDTH / 2.0)
      rk = [None]*4
      rk[0] = Vector2(xs, ys)
      n = n1.normal() * (-id)
      a = n * mik
      rk[1] = rk[0] + a
      n1 = n.normal() * (-id)
      a = n1 * com.ROADWIDTH
      rk[2] = rk[1] + a
      n = n1.normal() * (-id)
      a = n * mik
      rk[3] = rk[2] + a
      for i in xrange(4):
          rk[i].x = (rk[i].x - com.kil[0]) * com.pklx
          rk[i].y = (rk[i].y - kat) * com.pkly + com.platit
      uDxf.thanDxfPlotSolid4 (rk[0].x, rk[0].y,
                              rk[1].x, rk[1].y,
                              rk[2].x, rk[2].y,
                              rk[3].x, rk[3].y)

#======================================================================

def bridge():
      "Plot a bridge."
      uDxf = com.frw["dxf"]
      if fabs(com.xthb) < 1.0e-6: com.xthb = 1.0e-3
      uDxf.thanDxfSetLayer('TEXNIKA')

#----         ----------c
      for i in xrange(com.ianoig + 1):
          com.edafos[i][1] = mhk3.getedafos(com.edafos[i][0])

#----          c
      er1 = mhk3.getery(com.edafos[0][0])
      er2 = mhk3.getery(com.edafos[com.ianoig][0])
      checkklish(com.edafos[0][0], er1, com.edafos[com.ianoig][0], er2)
      a = (er2 - er1) / (com.edafos[com.ianoig][0] - com.edafos[0][0])

#----    ---------------------------------------------c
      p1 = bisect(com.kil, com.edafos[0][0])
      p2 = bisect(com.kil, com.edafos[com.ianoig][0]) - 1
      p = p1
      xs = com.edafos[0][0]
      ys = er1
      xe = com.edafos[com.ianoig][0]
      ykat = mhk3.getkatv(xs)
      mhk3.calcplatoi()
      while p <= p2:
          if mhk3.getkatv(com.kil[p]) != ykat:
              plotpartofbridge (xs, ys, com.kil[p], a)
              ys = a * (com.kil[p] - xs) + er1
              xs = com.kil[p]
              ykat = mhk3.getkatv(com.kil[p])
          p += 1
      plotpartofbridge (xs, ys, xe, a)

#----         ----c
      for i in xrange(com.ianoig+1):     #do i=1, com.ianoig+1
          if com.sitem == '' or com.sitem == '':
              x1 = (com.edafos[i][0] - com.kil[0]) * com.pklx
              y = a * (com.edafos[i][0] - com.edafos[0][0]) + er1
              y1 = (y - com.paxos - mhk3.getkatv(com.edafos[i][0])) * com.pkly + com.platit
              y2 = (com.edafos[i][1] - mhk3.getkatv(com.edafos[i][0])) * com.pkly + com.platit
              uDxf.thanDxfPlotSolid4(x1-com.pkol/2.0,  y1,
                                     x1+com.pkol/2.0,  y1,
                                     x1+com.pkol/2.0,  y2,
                                     x1-com.pkol/2.0,  y2)
              uDxf.thanDxfPlotSolid4(x1-com.pthem/2.0, y2,
                                     x1+com.pthem/2.0, y2,
                                     x1+com.pthem/2.0, y2-com.ythem,
                                     x1-com.pthem/2.0, y2-com.ythem)
          elif i < com.ianoig:
              mhk3.kibot(com.edafos[i][0], com.edafos[i+1][0], er1, er2, a)
      mhk3.gcomment(com.edafos[0][0] + (com.edafos[com.ianoig][0] - com.edafos[0][0])/2.0, (er1+er2)/2.0)
      uDxf.thanDxfSetLayer('TEXTL')

#=======================================================================

def plotpartofbridge(xs, ys, xe, a):
      "Plots part of bridge."
      uDxf = com.frw["dxf"]
      ye = a * (xe - xs) + ys
      katv = mhk3.getkatv (xs)
      x1 = (xs - com.kil[0]) * com.pklx
      y1 = (ys - katv) * com.pkly + com.platit
      uDxf.thanDxfPlotPolyVertex (x1, y1, 3)
      xk = [None] * 5
      yk = [None] * 5
      xk[0] = x1
      yk[0] = y1
      if xe < com.edafos[com.ianoig][0]:
          x1 = (xe - com.kil[0]) * com.pklx
      else:
          x1 = (xe - com.kil[0]) * com.pklx
      y1 = (ye - katv) * com.pkly + com.platit
      uDxf.thanDxfPlotPolyVertex (x1, y1, 2)
      xk[1] = x1
      yk[1] = y1
      uDxf.thanDxfPlotPolyVertex (x1, y1 - com.paxos, 2)
      xk[2] = x1
      yk[2] = y1 - com.paxos
      x1 = (xs - com.kil[0]) * com.pklx
      y1 = (ys - katv) * com.pkly + com.platit
      uDxf.thanDxfPlotPolyVertex (x1, y1 - com.paxos, 2)
      xk[3] = x1
      yk[3] = y1 - com.paxos
      xk[4] = xk[0]
      yk[4] = yk[0]
      uDxf.thanDxfPlotPolyVertex (x1, y1, 2)
      uDxf.thanDxfPlotPolyVertex (0.0, 0.0, 999)
      gfill(uDxf, xk, yk, 45.0, com.GAP, 0)

#=======================================================================

def checkklish(xs, ys, xe, ye):
      """Tests slope.
      
#----------------------------------------------------------------------c
#                      c
#                 c
#                                                            c
#----------------------------------------------------------------------c
      """
      a = (ye - ys) / (xe - xs)
      x1 = xs
      y1 = ys
      p1 = bisect(com.kil, xs)
      p2 = bisect(com.kil, xe)
      dif = 0.0
      for i in xrange(p1, p2+1):
          y = a * (com.kil[i] - xs) + ys
          if com.ery[i] - y < dif: dif = com.ery[i] - y
      if dif < 0.0:
          dif = fabs(dif)
          ys = ys - dif
          ye = ye - dif
          y1 = ys

      for i in xrange(com.ianoig):      #do i = 1 , com.ianoig + 1
          if com.edafos[i][0] > xe: return
          y = a * (com.edafos[i][0] - x1) + y1 - com.paxos / com.pkly
          if com.edafos[i][1] > y: com.edafos[i][1] = y
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.