Пример #1
0
def plotfunc2d(minx, maxx, n):
    pl = plotfunc2d2poly(minx, maxx, n)
    irit.color(pl, irit.YELLOW)
    irit.attrib(pl, "width", irit.GenRealObject(0.05))
    miny = 1e+006
    maxy = -1e+006
    i = 0
    while (i <= 2):
        miny = miny + i
        i = i + 1
    retval = pl
    i = 0
    while (i <= irit.SizeOf(pl) - 1):
        v = irit.coord(pl, i)
        real_val = irit.FetchRealObject(irit.coord(v, 1))
        if (real_val > maxy):
            maxy = irit.FetchRealObject(irit.coord(v, 1))
        if (real_val < miny):
            miny = irit.FetchRealObject(irit.coord(v, 1))
        i = i + 1
    ax = (irit.poly(
        irit.list((irit.min(minx, 0), 0, 0),
                  (irit.max(maxx, 0), 0, 0)), 1) + irit.poly(
                      irit.list((0, irit.min(miny, 0), 0),
                                (0, irit.max(maxy, 0), 0)), 1))

    irit.color(ax, irit.RED)
    irit.attrib(ax, "width", irit.GenRealObject(0.02))
    tr = irit.trans(
        ((-minx + maxx) / 2.0, (-miny + maxy) / 2.0, 0)) * irit.scale(
            (2.0 / (maxx - minx), 2.0 / (maxy - miny), 0))
    sv = irit.GetViewMatrix()
    irit.SetViewMatrix(irit.rotx(0))
    retval = irit.list(pl, ax) * tr
    irit.viewobj(irit.list(irit.GetViewMatrix(), retval))
    irit.printf("xdomain = [%lf %lf], ydomain = [%lf %lf]\n",
                irit.list(minx, maxx, miny, maxy))
    irit.SetViewMatrix(sv)
    return retval
Пример #2
0
# ############################################################################
#
#  Back part of the fuselage:
#
c1 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.P3, 1, 2.5, 0, (-0.1 ) ), \
                                  irit.ctlpt( irit.P3, 0.707, 1.77, 0.283, (-0.071 ) ), \
                                  irit.ctlpt( irit.P3, 1, 2.5, 0.4, 0 ), \
                                  irit.ctlpt( irit.P3, 0.707, 1.77, 0.283, 0.566 ), \
                                  irit.ctlpt( irit.P3, 1, 2.5, 0, 0.8 ), \
                                  irit.ctlpt( irit.P3, 0.707, 1.77, (-0.283 ), 0.566 ), \
                                  irit.ctlpt( irit.P3, 1, 2.5, (-0.4 ), 0 ), \
                                  irit.ctlpt( irit.P3, 0.707, 1.77, (-0.283 ), (-0.071 ) ), \
                                  irit.ctlpt( irit.P3, 1, 2.5, 0, (-0.1 ) ) ), irit.list( 0, 0, 0, 1, 1, 2,\
2, 3, 3, 4, 4, 4 ) ) * irit.trans( ( 0, 0, 0 ) )
irit.color(c1, irit.RED)
c2 = c1 * irit.scale((1.05, 1.05, 1.05)) * irit.trans((0.3, 0, 0))
irit.color(c2, irit.RED)
c3 = c1 * irit.scale((0.95, 0.95, 0.95)) * irit.trans((1.7, 0, (-0.02)))
irit.color(c3, irit.RED)
c4 = irit.circle((0, 0, 0), 0.35) * irit.roty(90) * irit.trans((5, 0, 0.2))
irit.color(c4, irit.RED)
c5 = c4 * irit.trans((0.2, 0, 0))
irit.color(c5, irit.RED)
c6 = irit.circle((0, 0, 0), 0.3) * irit.roty(90) * irit.trans((10.5, 0, 0.2))
irit.color(c6, irit.RED)
c7 = irit.circle((0, 0, 0), 0.01) * irit.roty(90) * irit.trans((11, 0, 0.25))
irit.color(c7, irit.RED)

fuseback = irit.sfromcrvs( irit.list( c1, c2, c3, c4, c5, c6,\
c7 ), 3, irit.KV_OPEN )
irit.color(fuseback, irit.RED)
Пример #3
0
#
import math
import irit
#

#
#  This solid was taken from: Geometric Modeling,
#  by Michael E. Mortenson page 441, figure 10.9
#
#                                Created by Gershon Elber,       Apr 90
#

t = irit.time(1)

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.5, 0.5, 0.5)))
save_res = irit.GetResolution()

#
#  Try it with coplanar false for fun.
#
#  irit.iritstate( "coplanar", false );
#

psort = irit.iritstate("polysort", irit.GenRealObject(0))

t1 = irit.box(((-2), (-0.35), 0), 4, 0.7, 0.4)
irit.SetResolution(80)
t2 = irit.cylin((0, 0, 0), (0, 0, 0.4), 1.4, 3)
s1 = t1 * t2
irit.free(t1)
Пример #4
0
import math
import irit
#

#
#  Yet another simple 3D mechanical object.
#
#                                Created by Gershon Elber,       Sep 89
#

save_mat = irit.GetViewMatrix()
save_res = irit.GetResolution()

irit.SetResolution(16)
irit.SetViewMatrix(irit.GetViewMatrix() * irit.trans(
    (0, (-0.3), 0)) * irit.scale((0.8, 0.8, 0.8)))
b1 = irit.box(((-0.6), (-0.3), 0), 1.2, 0.6, 0.6)
c1 = irit.cylin((0, (-0.25), 0.59), (0, 0.5, 0), 0.55, 3)
s1 = (b1 + c1)
irit.color(s1, irit.YELLOW)
irit.free(b1)
irit.free(c1)
irit.view(irit.list(irit.GetViewMatrix(), s1), irit.ON)

b2 = irit.box(((-0.4), (-0.4), (-0.1)), 0.8, 0.8, 0.35)
irit.view(b2, irit.OFF)
s2 = (s1 - b2)
irit.free(s1)
irit.free(b2)
irit.color(s2, irit.YELLOW)
irit.view(s2, irit.ON)
Пример #5
0
# 

# 
#  Sets the viewing direction on the display device.
# 
save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.rotx( 0 ))
irit.viewobj( irit.GetViewMatrix() )
irit.SetViewMatrix(  save_mat)

# ############################################################################
crv1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, 0.3, 0 ), \
                                irit.ctlpt( irit.E2, 0, 0.5 ), \
                                irit.ctlpt( irit.E2, (-0.2 ), 0 ) ) )
crv1a = crv1 * irit.trans( ( (-0.4 ), 0, 0 ) )
crv1b = crv1a * irit.scale( ( (-1 ), 1, 1 ) )
irit.color( crv1a, irit.GREEN )
irit.color( crv1b, irit.GREEN )
irit.view( irit.list( crv1a, crv1b ), irit.ON )

i = 0
while ( i <= 300 ):
    c = irit.cmorph( crv1a, crv1b, 0, i/300.0 )
    irit.color( c, irit.YELLOW )
    irit.view( irit.list( crv1a, crv1b, c ), irit.ON )
    i = i + 1

crvs = irit.cmorph( crv1a, crv1b, 2, 0.005 )
irit.snoc( crv1b, crvs )
i = 1
while ( i <= irit.SizeOf( crvs ) ):
Пример #6
0
                                                 irit.ctlpt( irit.E3, 0.4, 2.4, 0 ), \
                                                 irit.ctlpt( irit.E3, 1.3, 2.4, 0 ), \
                                                 irit.ctlpt( irit.E3, 1.3, 2.25, 0 ) ) ), irit.list( irit.list( 0, 0, 0, 0, 1, 1,\
1, 2, 2, 2, 2 ), irit.list( 0, 0, 0, 0, 1, 1,\
1, 2, 2, 2, 3, 3,\
3, 4, 4, 4, 4 ) ) )

echosrc = irit.iritstate("echosource", echosrc)
irit.free(echosrc)

irit.color(body, irit.RED)
irit.color(cap, irit.GREEN)
irit.color(spout, irit.BLUE)
irit.color(handle, irit.MAGENTA)

irit.SetViewMatrix(irit.scale((0.3, 0.3, 0.3)))

save_approx_opt = irit.GetPolyApproxOpt()
irit.SetPolyApproxOpt(1)
irit.SetPolyApproxTol(0.025)
pbody = (-irit.gpolygon(irit.sregion(body, irit.COL, 0.8, 3), 1))
pspout = (-irit.gpolygon(irit.sregion(spout, irit.COL, 0, 1), 1))
phandle = (-irit.gpolygon(handle, 1)) * irit.tx(0.15)

teapotaux = (pbody + pspout + phandle)

basey = 0.025
bodybase = irit.poly(
    irit.list(((-2), basey, (-2)), ((-2), basey, 2), (2, basey, 2),
              (2, basey, (-2))), irit.FALSE)
Пример #7
0
scylin = irit.ruledsrf(c1, c1 * irit.tz(1))
irit.color(scylin, irit.YELLOW)
scylinev = irit.evolute(scylin)
irit.color(scylinev, irit.GREEN)
irit.interact(irit.list(irit.GetAxes(), scylin, scylinev))

irit.save("sevolute",
          irit.list(irit.GetAxes(), scylin, scylinev, scone, sconeev))

irit.free(scone)
irit.free(sconeev)
irit.free(scylin)
irit.free(scylinev)

scone2 = irit.ruledsrf(c1,
                       c1 * irit.sc(0.1) * irit.tz(1)) * irit.scale((2, 1, 1))
irit.free(c1)
irit.color(scone2, irit.YELLOW)
scone2ev = irit.evolute(scone2)
irit.color(scone2ev, irit.GREEN)
irit.interact(irit.list(irit.GetAxes(), scone2, scone2ev))
irit.free(scone2)
irit.free(scone2ev)

# ############################################################################
#  Gaussian curvature of a parametric surface.
# ############################################################################
srf1 = irit.hermite( irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ), \
                                              irit.ctlpt( irit.E3, 0.5, 0.2, 0 ), \
                                              irit.ctlpt( irit.E3, 1, 0, 0 ) ) ), irit.cbezier( irit.list( \
                                              irit.ctlpt( irit.E3, 0, 1, 0 ), \
Пример #8
0
                             irit.ctlpt( irit.E3, 0.3, 1, 0 ), \
                             irit.ctlpt( irit.E3, 0, 2, 1 ) ), irit.list( \
                             irit.ctlpt( irit.E3, 1.1, 0, 0 ), \
                             irit.ctlpt( irit.E3, 1.3, 1.5, 2 ), \
                             irit.ctlpt( irit.E3, 1, 2.1, 0 ) ), irit.list( \
                             irit.ctlpt( irit.E3, 2.1, 0, 2 ), \
                             irit.ctlpt( irit.E3, 2.3, 1, 0 ), \
                             irit.ctlpt( irit.E3, 2, 2, 2 ) ), irit.list( \
                             irit.ctlpt( irit.E3, 3.1, 0, 0 ), \
                             irit.ctlpt( irit.E3, 3.3, 1.5, 2 ), \
                             irit.ctlpt( irit.E3, 3, 2.1, 0 ) ), irit.list( \
                             irit.ctlpt( irit.E3, 4.1, 0, 1 ), \
                             irit.ctlpt( irit.E3, 4.3, 1, 0 ), \
                             irit.ctlpt( irit.E3, 4, 2, 1 ) ) )

cb = irit.cbezier(cbzr) * irit.scale((0.7, 1.4, 1))

irit.color(cb, irit.RED)
sb = irit.sbezier(sbzr)

irit.color(sb, irit.RED)

irit.save(
    "bezier1",
    irit.list(irit.fforder(cb), irit.ffmsize(cb), irit.ffctlpts(cb),
              irit.fforder(sb), irit.ffmsize(sb), irit.ffctlpts(sb)))

if (display == 1):
    irit.interact(irit.list(irit.GetAxes(), cb, sb))
    irit.viewstate("dsrfmesh", 1)
    irit.pause()
Пример #9
0
    irit.interact(c2)
    c3 = (a - b)
    irit.interact(c3)
    c4 = (b - a)
    irit.interact(c4)
    irit.save(
        fname, irit.list(c1, c2 * irit.tx(4), c3 * irit.tx(8),
                         c4 * irit.tx(12)))


a = irit.cylin((0, 0, 0), (0, 0, 1), 1, 3)
b = irit.cylin((0.5, 0, 0), (0, 0, 1), 1, 3)
do_coplanars(a, b, "coplanr1")

a = irit.cylin((0, 0, 0), (0, 0, 1), 1, 3)
b = a * irit.scale((2, 0.5, 1))
do_coplanars(a, b, "coplanr2")

a = irit.box(((-2), (-2), 0), 4, 4, 1)
b = irit.cylin((0, 0, 0), (0, 0, 2), 1, 3)
do_coplanars(a, b, "coplanr3")

a = irit.box((0, 0, 0), 1, 1, 2)
b = irit.box((0, 0, 0), 2, 1, 1)
do_coplanars(a, b, "coplanr4")

a = irit.box((0, 0, 0), 1, 1, 2)
b = irit.box((0, 0.5, 0), 2, 1, 1)
do_coplanars(a, b, "coplanr5")

a = irit.box((0, 0, 0), 1, 1, 2)
Пример #10
0

#
#  1. Simple close loop intersection. Both srfs are bi-quadratic polynomials.
#

s1 = irit.sbezier( irit.list( irit.list( irit.ctlpt( irit.E3, 0.1, 0, 1 ), \
                                         irit.ctlpt( irit.E3, 0.3, 1, 0.5 ), \
                                         irit.ctlpt( irit.E3, 0, 2, 1 ) ), irit.list( \
                                         irit.ctlpt( irit.E3, 1.1, 0, 0.5 ), \
                                         irit.ctlpt( irit.E3, 1.3, 1, 0 ), \
                                         irit.ctlpt( irit.E3, 1, 2, 0.5 ) ), irit.list( \
                                         irit.ctlpt( irit.E3, 2.1, 0, 1.1 ), \
                                         irit.ctlpt( irit.E3, 2.3, 1, 0.4 ), \
                                         irit.ctlpt( irit.E3, 2, 2, 1.2 ) ) ) )
s2 = s1 * irit.scale((1, 1, (-1))) * irit.tz(1.2)
irit.color(s1, irit.RED)
irit.color(s2, irit.GREEN)

i = testinter(s1, s2)

all = irit.list(s1, s2, i)
irit.interact(all)

irit.save("ssi1", all)

#
#  2 and 3. Same as 1 but both surfaces are degree raised. How much does it
#  slows down ssi computation!?
#
Пример #11
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  The most common example of wireframe ambiguity. See for example:
#  Geometric Modeling by Michael E. Mortenson, page 4...
#

save_res = irit.GetResolution()
save_mat = irit.GetViewMatrix()

irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale(
    (0.6, 0.6, 0.6)) * irit.rotx(30) * irit.roty(20))
a = irit.box(((-0.5), (-0.5), (-0.55)), 1, 1, 1.1)

irit.SetResolution(4)
#  To create 4 sided pyramids from cones...
c1 = irit.cone((0, 0, (-0.6)),
               (0, 0, 0.6001), 0.6 * math.sqrt(2), 1) * irit.rotz(45)
c2 = irit.cone((0, 0, 0.6),
               (0, 0, (-0.6)), 0.6 * math.sqrt(2), 1) * irit.rotz(45)

a = (a - c1 - c2)
irit.free(c1)
irit.free(c2)
irit.view(irit.list(irit.GetViewMatrix(), a), irit.ON)

b = irit.box(((-0.3), (-0.3), (-1)), 0.6, 0.6, 2)
Пример #12
0
chairbasecrv = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0.6, 0, 0 ), \
                                            irit.ctlpt( irit.E3, 0.3, 0, 0.05 ), \
                                            irit.ctlpt( irit.E3, 0, 0, 0 ) ), irit.list( irit.KV_OPEN ) )
chairbasecross = ( irit.arc( ( 0.25, 0.05, 0 ), ( 0.25, 0, 0 ), ( 0.3, 0, 0 ) ) + \
				   irit.arc( ( 0.3, 0, 0 ), ( 0.25, 0, 0 ), ( 0.25, (-0.05 ), 0 ) ) + \
				   irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0.25, (-0.05 ), 0 ), \
										  irit.ctlpt( irit.E3, 0.22, (-0.05 ), 0 ), \
										  irit.ctlpt( irit.E3, 0, 0, 0 ), \
										  irit.ctlpt( irit.E3, (-0.22 ), (-0.05 ), 0 ), \
										  irit.ctlpt( irit.E3, (-0.25 ), (-0.05 ), 0 ) ), irit.list( irit.KV_OPEN ) ) + irit.arc( ( (-0.25 ), (-0.05 ), 0 ), ( (-0.25 ), 0, 0 ), ( (-0.3 ), 0, 0 ) ) + irit.arc( ( (-0.3 ), 0, 0 ), ( (-0.25 ), 0, 0 ), ( (-0.25 ), 0.05, 0 ) ) + \
										  irit.ctlpt( irit.E3, 0.25, 0.05, 0 ) )
chairbasemain = (-irit.sweepsrf( chairbasecross * irit.rotz( 90 ), chairbasecrv, irit.GenRealObject(0) ) )

chaircrv1 = irit.cmesh( chairbasemain, irit.ROW, 0 )
chaircrv1a = chaircrv1 * irit.trans( ( 0.06, 0, (-0.02 ) ) )
chaircrv1b = chaircrv1 * irit.scale( ( 0, 0.83, 0 ) ) * irit.trans( ( 0.66, 0, (-0.02 ) ) )
chairbasecover1 = (-irit.sfromcrvs( irit.list( chaircrv1, chaircrv1a, chaircrv1b ), 3, irit.KV_OPEN ) )
irit.free( chaircrv1 )
irit.free( chaircrv1a )
irit.free( chaircrv1b )
irit.free( chairbasecrv )

chaircrv2 = irit.cmesh( chairbasemain, irit.ROW, 2 )
chaircrv2a = chaircrv2 * irit.trans( ( (-0.06 ), 0, (-0.02 ) ) )
chaircrv2b = chaircrv2 * irit.scale( ( 0, 0.83, 0 ) ) * irit.trans( ( (-0.06 ), 0, (-0.02 ) ) )
chairbasecover2 = irit.sfromcrvs( irit.list( chaircrv2, chaircrv2a, chaircrv2b ), 3, irit.KV_OPEN )
irit.free( chaircrv2 )
irit.free( chaircrv2a )
irit.free( chaircrv2b )

chairbase = irit.list( chairbasemain, chairbasecover1, chairbasecover2 ) * irit.scale( ( 0.75, 1, 1 ) )
Пример #13
0
irit.attrib(tsrf1, "resolution", irit.GenIntObject(2))

crv1 = irit.compose(srf1, tcrv1)
irit.free(srf1)
irit.free(tcrv1)
irit.color(crv1, irit.GREEN)

pc = irit.crefine(irit.pcircle(((-1.7), (-1), 1), 0.4), 0, irit.list(1, 2, 3))
srf2 = irit.ruledsrf( irit.ceditpt( irit.ceditpt( pc, irit.ctlpt( irit.E3, (-2.1 ), (-1 ), 1.2 ), 9 ), \
                                                      irit.ctlpt( irit.E3, (-1.3 ), (-1 ), 1.2 ), 3 ), pc * irit.tz( 1 ) ) * irit.rotz( (-90 ) ) * irit.trans( ( 2.7, (-0.7 ), 0 ) )
crv2 = irit.csurface(srf2, irit.ROW, 0)
irit.color(crv2, irit.GREEN)
irit.free(pc)

tan1 = irit.symbdiff(
    crv1 * irit.scale((0.6, 0.4, 1)) * irit.trans((0.7, 0.6, 0)), crv1)
tan2 = irit.pcircle((0, 0, 3), 0)

blend = irit.hermite(crv1, (-crv2), tan1 * irit.sc(1), (-tan2) * irit.sc(1))
irit.color(blend, irit.RED)
irit.attrib(blend, "width", irit.GenRealObject(0.02))

all = irit.list(blend, tsrf1, (-srf2))
irit.interact(all)
irit.save("blend1", all)

crv2a = irit.ffmatch( crv1, (-crv2 ), 5, 25, 2, 0,\
1 )

blend = irit.hermite(crv1, crv2a, tan1 * irit.sc(1), (-tan2) * irit.sc(1))
irit.free(crv1)
Пример #14
0
c4 = circ2 * irit.sc(0.5) * irit.rz(90) * irit.sx(1.8) * irit.ty(
    2.3) * irit.tx(3.1)
c5 = circ2 * irit.sc(0.42) * irit.rz(90) * irit.sx(1.8) * irit.ty(
    2.35) * irit.tx(3.1)
c6 = circ2 * irit.sc(0.25) * irit.rz(90) * irit.sx(1.8) * irit.ty(
    2.15) * irit.tx(2.82)
spout2 = irit.sfromcrvs( irit.list( c1, c2, c3, c3a, c4, c5,\
c6 ), 4, irit.KV_OPEN )

irit.color(body2, irit.RED)
irit.color(cap2, irit.GREEN)
irit.color(spout2, irit.CYAN)
irit.color(handle2, irit.MAGENTA)

irit.SetViewMatrix(
    irit.scale((0.3, 0.3, 0.3)) * irit.ty((-0.5)) * irit.ry(70) * irit.rx(20))
teapot2 = irit.list(body2, spout2, handle2, cap2)
irit.save("teapot2", teapot2)
irit.interact(irit.list(irit.GetViewMatrix(), teapot2))

irit.free(c0)
irit.free(c1)
irit.free(c2)
irit.free(c3)
irit.free(c3a)
irit.free(c4)
irit.free(c5)
irit.free(c6)
irit.free(c7)
irit.free(c8)
irit.free(circ)
Пример #15
0
aiso = irit.adapiso(srf1, irit.ROW, 0.05, irit.FALSE, irit.FALSE)
irit.color(aiso, irit.YELLOW)
irit.interact(irit.list(irit.GetAxes(), srf1, aiso))

srf2 = irit.sbspline( 3, 3, irit.list( irit.list( irit.ctlpt( irit.E3, 1, 0, 0 ), \
                                                  irit.ctlpt( irit.E3, 1, 1, 2 ), \
                                                  irit.ctlpt( irit.E3, 1, 2, 0 ) ), irit.list( \
                                                  irit.ctlpt( irit.E3, 2, 0.9, 2 ), \
                                                  irit.ctlpt( irit.E3, 2, 1, 0 ), \
                                                  irit.ctlpt( irit.E3, 2, 1.1, 2 ) ), irit.list( \
                                                  irit.ctlpt( irit.E3, 3, 0, 0 ), \
                                                  irit.ctlpt( irit.E3, 3, 1, 2 ), \
                                                  irit.ctlpt( irit.E3, 3, 2, 0 ) ), irit.list( \
                                                  irit.ctlpt( irit.E3, 4, 0.9, 1 ), \
                                                  irit.ctlpt( irit.E3, 4, 1, 0 ), \
                                                  irit.ctlpt( irit.E3, 4, 1.1, 1 ) ) ), irit.list( irit.list( irit.KV_OPEN ), irit.list( irit.KV_OPEN ) ) ) * irit.scale( ( 0.5, 0.5, 0.5 ) ) * irit.trans( ( (-0.5 ), 0, 0 ) )
irit.color(srf2, irit.MAGENTA)

aiso = irit.adapiso(srf2, irit.COL, 0.05, irit.TRUE, irit.FALSE)
irit.color(aiso, irit.YELLOW)
irit.interact(irit.list(irit.GetAxes(), srf2, aiso))
irit.save("adap1iso", irit.list(irit.GetAxes(), srf2, aiso))

aiso = irit.adapiso(srf2, irit.COL, 0.05, irit.FALSE, irit.FALSE)
irit.color(aiso, irit.YELLOW)
irit.interact(irit.list(irit.GetAxes(), srf2, aiso))
irit.save("adap2iso", irit.list(irit.splitlst(irit.GetAxes()), srf2, aiso))
#  Test SplitLst...

srf3 = irit.sbspline( 3, 3, irit.list( irit.list( irit.ctlpt( irit.E3, 1, 0, 0 ), \
                                                  irit.ctlpt( irit.E3, 1, 1, 0 ), \
Пример #16
0
1, 2, 2, 2, 3, 3,\
3, 4, 4, 4, 4 ) ) )

cap = irit.sreparam( irit.sregion( cap, irit.COL, 0.0005, 2 ), irit.COL, 0,\
2 )


echosrc = irit.iritstate( "echosource", echosrc )
irit.free( echosrc )

irit.color( body, irit.RED )
irit.color( cap, irit.GREEN )
irit.color( spout, irit.BLUE )
irit.color( handle, irit.MAGENTA )

irit.SetViewMatrix(  irit.scale( ( 0.3, 0.3, 0.3 ) ))
teapot = irit.list( body, spout, handle, cap )

# interact( list( view_mat, Teapot ) );
irit.save( "teapot", teapot )

tea1 = teapot * irit.tx( 7 ) 
tea2 = teapot * irit.tx( 7 ) * irit.tz( 5 ) 
tea3 = teapot * irit.tz( 5 ) 

irit.SetViewMatrix(  irit.scale( ( 0.15, 0.15, 0.15 ) ) * irit.rx( 50 ) * irit.ry( 40 ) * irit.tx( (-0.7 ) ) * irit.ty( 0.2 ))
irit.interact( irit.list( irit.GetViewMatrix(), teapot, tea1, tea2, tea3 ) )
irit.free( tea1 )
irit.free( tea2 )
irit.free( tea3 )
Пример #17
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#


# 
#  This file existance is justified to demonstrate loops on free form trans.:
# 

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.GetViewMatrix() * irit.scale( ( 0.7, 0.7, 0.7 ) ) )

cbzr = irit.cbezier( irit.list( irit.ctlpt( irit.P3, 1, 0, 0, 0 ), \
                                irit.ctlpt( irit.P3, 0.707, 0.707, 0, 0 ), \
                                irit.ctlpt( irit.P3, 1, 1, 1, 0 ) ) )
sbzr = irit.sbezier( irit.list( irit.list( irit.ctlpt( irit.E3, 0, 0, 0.5 ), \
                                           irit.ctlpt( irit.E3, 0, 0.5, (-1 ) ), \
                                           irit.ctlpt( irit.E3, 0, 1, 0.5 ) ), irit.list( \
                                           irit.ctlpt( irit.E3, 0.5, 0, (-0.5 ) ), \
                                           irit.ctlpt( irit.E3, 0.5, 0.5, 1 ), \
                                           irit.ctlpt( irit.E3, 0.5, 1, (-0.5 ) ) ), irit.list( \
                                           irit.ctlpt( irit.E3, 1, 0, 0.5 ), \
                                           irit.ctlpt( irit.E3, 1, 0.5, (-1 ) ), \
                                           irit.ctlpt( irit.E3, 1, 1, 0.5 ) ) ) )

rot10x = irit.rotx( 10 )
rot10y = irit.roty( 10 )
rot10z = irit.rotz( 10 )
Пример #18
0
def layouthandletrimmedsrfs(tsrfs, highlighttrim):
    retval = irit.nil()
    i = 1
    while (i <= irit.SizeOf(tsrfs)):
        irit.snoc(layouthandleonetrimmed(irit.nth(tsrfs, i), highlighttrim),
                  retval)
        i = i + 1
    return retval


# ############################################################################
#
#  Layout (prisa) of a sphere - several resolutions/directions.
#
view_mat3d = irit.rotx((-90)) * irit.roty(135) * irit.rotx((-30)) * irit.scale(
    (0.5, 0.5, 0.5))
view_mat2d = irit.scale((0.15, 0.15, 0.15)) * irit.trans((0, (-0.8), 0))

s45 = math.sin(math.pi / 4)

halfcirc = irit.cbspline( 3, irit.list( irit.ctlpt( irit.P3, 1, 0, 0, 1 ), \
                                        irit.ctlpt( irit.P3, s45, (-s45 ), 0, s45 ), \
                                        irit.ctlpt( irit.P3, 1, (-1 ), 0, 0 ), \
                                        irit.ctlpt( irit.P3, s45, (-s45 ), 0, (-s45 ) ), \
                                        irit.ctlpt( irit.P3, 1, 0, 0, (-1 ) ) ), irit.list( 0, 0, 0, 1, 1, 2,\
2, 2 ) )
sp = irit.surfrev(halfcirc)
irit.color(sp, irit.YELLOW)

irit.interact(irit.list(view_mat3d, sp))
Пример #19
0

# 
#  A model of the B58 Bomber.
# 
# 
#                        Gershon Elber, October 1991.
# 

if ( irit.GetMachine() == irit.MSDOS ):
    irit.SetResolution(8)
else:
    irit.SetResolution(10)

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.trans( ( 5, 2, 0 ) ) * irit.scale( ( 0.15, 0.15, 0.15 ) ) )

# 
#  Set up for colored or wood texture version. set do_texture to 1 for
#  wood version, otherwise color version. Note locally (in irit) it will
#  always be displayed in colors.
# 
do_texture = 0



if ( do_texture == 1 ):
    woodcolor = "244,164,96"
    texture = "wood,1"
    redcolor = woodcolor
    graycolor = woodcolor
Пример #20
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#


# 
#  This is the DtoP custom designed Gearbox 'EndPlate'
#                        Designed by Andy Bray <*****@*****.**> 1992
# 

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.GetViewMatrix() * 
					 irit.scale( ( 0.13, 0.13, 0.13 ) ))
save_res = irit.GetResolution()

cplnr = irit.iritstate( "coplanar", irit.GenIntObject(1) )
#  Try 'irit.iritstate("coplanar", false);'

box1 = irit.box( ( 0, 0, 1 ), 7.8, 10.4, 1.6 )
# If the line below is uncommented, then the file fails at the first operation
# most other resolutions work without problem. This could be because
# coincidentally something approximates colinear when it is not, but in that
# case a resultion of 50 or 20 might do it, and do not.
# resolution = 10;
hole1 = irit.cylin( ( 1, 1, 2.601 ), ( 0, 0, (-1.6015 ) ), 0.3, 3 )
solid1 = ( box1 - hole1 )
irit.free( hole1 )
irit.free( box1 )
irit.view( irit.list( irit.GetViewMatrix(), solid1 ), irit.ON )
Пример #21
0
        tr1 = virttree3(newpos,
                        rotatevector2(dir, rfactor) * lfactor, size * wfactor,
                        blevel, level - 1)
        tr2 = virttree3(
            newpos,
            rotatevector2(dir, rfactor * irit.random((-1), 1)) * lfactor,
            size * wfactor, blevel, level - 1)
        tr3 = virttree3(newpos,
                        rotatevector2(dir, (-rfactor)) * lfactor,
                        size * wfactor, blevel, level - 1)
        retval = retval + tr1 + tr2 + tr3
    return retval


irit.SetViewMatrix(
    irit.rotx((-90)) * irit.roty(135) * irit.rotx((-30)) * irit.scale(
        (0.2, 0.2, 0.2)) * irit.trans((0, (-0.5), 0)))

tree1 = virttree2(irit.point(0, 0, 0), irit.vector(0, 0, 1), 0.3, 4, 7)
irit.interact(irit.list(irit.GetViewMatrix(), tree1))
irit.free(tree1)

tree2 = virttree3(irit.point(0, 0, 0), irit.vector(0, 0, 1), 0.5, 3, 5)
irit.interact(tree2)
irit.free(tree2)


def forest3(n, m, blevel, level):
    retval = irit.nil()
    i = 0
    while (i <= n):
        j = 0
Пример #22
0
#
import math
import irit
#


# 
#  Routines to test the boolean operations among geometric objects:
# 
#  Intersection between a box and a cylinder - make a hole in the box
# 
b = irit.box( ( (-3 ), (-2 ), (-1 ) ), 6, 4, 2 )
c = irit.cylin( ( 0, 0, (-4 ) ), ( 0, 0, 8 ), 1, 3 )

save_view = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.GetViewMatrix() * irit.scale( ( 0.1, 0.1, 0.1 ) ))

a1 = ( b + c )
irit.interact( irit.list( irit.GetViewMatrix(), a1 ) )

a2 = b * c
irit.interact( a2 )

a3 = ( b - c )
irit.interact( a3 )

c = ( irit.con2( ( 0, 0, 0 ), ( 0, 0, 28 ), 17, 12, 3 ) - irit.con2( ( 0, 0, (-1 ) ), ( 0, 0, 30 ), 14, 9, 3 ) )
a4 = ( c - irit.box( ( (-50 ), (-50 ), (-1 ) ), 100, 100, 28 ) )

irit.save( "closloop", irit.list( a1, a2, a3, a4 ) )
Пример #23
0
save_mat = irit.GetViewMatrix()

square = irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 1, 1, 0 ), ( 1, 0, 0 ), ( 0, 0, 0 ) ), irit.TRUE )
irit.attrib( square, "width", irit.GenStrObject("0.02" ))
irit.color( square, irit.RED )

rectan = irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 2, 1, 0 ), ( 2, 0, 0 ), ( 0, 0, 0 ) ), irit.TRUE )
irit.attrib( rectan, "width", irit.GenStrObject("0.02" ))
irit.color( rectan, irit.RED )

triang = irit.poly( irit.list( ( 0, 0, 0 ), ( 0, 1, 0 ), ( 1.5, 0.5, 0 ), ( 0, 0, 0 ) ), irit.TRUE )
irit.attrib( triang, "width", irit.GenStrObject("0.02" ))
irit.color( triang, irit.RED )

irit.SetViewMatrix(  irit.scale( ( 0.2, 0.2, 0.2 ) ))
cube_prisa = irit.list( square, 
						square * irit.trans( ( 1, 0, 0 ) ), 
						square * irit.trans( ( 2, 0, 0 ) ), 
						square * irit.trans( ( (-1 ), 0, 0 ) ), 
						square * irit.trans( ( 0, 1, 0 ) ), 
						square * irit.trans( ( 0, (-1 ), 0 ) ) )
irit.interact( irit.list( irit.GetViewMatrix(), cube_prisa ) )
irit.save( "cubepris", cube_prisa )
irit.free( cube_prisa )

box_prisa = irit.list( rectan, square * irit.trans( ( 2, 0, 0 ) ), square * irit.trans( ( (-1 ), 0, 0 ) ), rectan * irit.trans( ( 0, 1, 0 ) ), rectan * irit.trans( ( 0, 2, 0 ) ), rectan * irit.trans( ( 0, (-1 ), 0 ) ) )
irit.interact( irit.list( irit.GetViewMatrix(), box_prisa ) )
irit.save( "box_pris", box_prisa )
irit.free( box_prisa )
Пример #24
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Display of all primitives of the system:
#  BOX, GBOX, CONE, CYLIN, SPHERE, TORUS
#
#                                Created by Gershon Elber,       Dec. 88
#

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale((0.5, 0.5, 0.5)))
axes15 = irit.GetAxes() * irit.scale((1.5, 1.5, 1.5))

#
#  Create primitive as approximated integral polynomial surfaces.
#
save_prim_rat_srfs = irit.iritstate("primratsrfs", irit.GenRealObject(0))

cyls = irit.list(irit.cylin(((-0.8), 0, 0), ((-0.5), 0.3, 0.3), 0.3, 0),
                 irit.cylin((0.8, 0, 0), (0.8, 0, 0), 0.3, 1),
                 irit.cylin((0, (-0.8), 0), (0.1, (-0.5), 0.2), 0.3, 3),
                 irit.cylin((0, 0.8, 0), (0, 0.8, 0), 0.3, 2),
                 irit.cylin((0, 0, (-0.8)), (0.4, 0.2, (-0.5)), 0.3, 3),
                 irit.cylin((0, 0, 0.8), (0, 0, 0.8), 0.3, 1))
irit.color(cyls, irit.RED)

cones = irit.list(irit.cone(((-0.5), 0, 0), ((-0.5), 0, 0), 0.5, 0),
Пример #25
0
import math
import irit
#


# 
#  Simple molecule - 8 atoms connected as a cube.
# 

t = irit.time( 1 )

save_res = irit.GetResolution()
save_view = irit.GetViewMatrix()

irit.SetViewMatrix(  irit.GetViewMatrix() * \
					 irit.scale( ( 0.6, 0.6, 0.6 ) ) * \
					 irit.rotx( 20 ) * \
					 irit.roty( 45 ) * \
					 irit.trans( ( (-0.3 ), 0.2, 0 ) ))

irit.SetResolution(  16)
s1 = irit.sphere( ( 0, 0, 0 ), 0.2 )
s2 = irit.sphere( ( 1, 0, 0 ), 0.2 )

irit.SetResolution(  8)
c1 = irit.cylin( ( 0, 0, 0 ), ( 1, 0, 0 ), 0.05, 3 )

irit.view( irit.list( irit.GetViewMatrix(), s1, s2, c1 ), irit.ON )

b1 = ( (s1 ^ s2) + c1 )
irit.free( s1 )
Пример #26
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Extrusion example of the IRIT letters created manually:
#
#                                Created by Gershon Elber,       Mar 89
#

save_mat = irit.GetViewMatrix()
save_res = irit.GetResolution()

irit.SetViewMatrix(irit.GetViewMatrix() * irit.scale(((-1), 1, 1)))

v1 = (0, 0, 0)
#  The I letter
v2 = (0.3, 0, 0)
v3 = (0.3, 0.1, 0)
v4 = (0.2, 0.1, 0)
v5 = (0.2, 0.5, 0)
v6 = (0.3, 0.5, 0)
v7 = (0.3, 0.6, 0)
v8 = (0, 0.6, 0)
v9 = (0, 0.5, 0)
v10 = (0.1, 0.5, 0)
v11 = (0.1, 0.1, 0)
v12 = (0, 0.1, 0)
Пример #27
0
all = irit.list(c123, c1, c2, c3)

irit.SetViewMatrix(irit.sc(1.1))
irit.viewobj(irit.GetViewMatrix())

tr = 0.4
proj1 = all * irit.trans(((-tr), tr, 0))
proj2 = all * irit.rotx(90) * irit.trans((tr, tr, 0))
proj3 = all * irit.roty(90) * irit.trans(((-tr), (-tr), 0))
proj4 = all * irit.roty(30) * irit.rotx(20) * irit.trans((tr, (-tr), 0))

allproj = irit.list(proj1, proj2, proj3, proj4)

irit.save("cylin3a", allproj)
irit.interact(allproj)

c123a = c123 * irit.roty(30) * irit.rotx(20) * irit.scale((3, 3, 3))
irit.attrib(c123a, "width", irit.GenRealObject(0.015))
irit.save("cylin3b", c123a)
irit.interact(c123a)

c123b = c123 * irit.roty(60) * irit.rotx(65) * irit.scale((3, 3, 3))

irit.attrib(c123b, "width", irit.GenRealObject(0.015))
irit.save("cylin3c", c123b)
irit.interact(c123b)

irit.SetViewMatrix(save_mat)
irit.SetResolution(save_res)
Пример #28
0
gcross = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0.001, 0, 0.02 ), \
                                      irit.ctlpt( irit.E3, 0.2, 0, 0.02 ), \
                                      irit.ctlpt( irit.E3, 0.22, 0, 0 ), \
                                      irit.ctlpt( irit.E3, 0.22, 0, 0.03 ), \
                                      irit.ctlpt( irit.E3, 0.03, 0, 0.03 ), \
                                      irit.ctlpt( irit.E3, 0.03, 0, 0.07 ), \
                                      irit.ctlpt( irit.E3, 0.04, 0, 0.3 ), \
                                      irit.ctlpt( irit.E3, 0.3, 0, 0.3 ), \
                                      irit.ctlpt( irit.E3, 0.4, 0, 0.4 ), \
                                      irit.ctlpt( irit.E3, 0.3, 0, 0.7 ), \
                                      irit.ctlpt( irit.E3, 0.28, 0, 0.7 ), \
                                      irit.ctlpt( irit.E3, 0.37, 0, 0.42 ), \
                                      irit.ctlpt( irit.E3, 0.31, 0, 0.32 ), \
                                      irit.ctlpt( irit.E3, 0.001, 0, 0.32 ) ), irit.list( irit.KV_OPEN ) )
srf3 = irit.surfrev(gcross * irit.trans((0, 0, (-0.45))) * irit.scale(
    (1.6, 1.6, 1.6)))
irit.free(gcross)
irit.color(srf3, irit.CYAN)

#
#  Must make them compatible before doing some morphing.
#
irit.ffcompat(srf2, srf3)

i = 0
while (i <= 1):
    irit.view(irit.smorph(srf2, srf3, i), irit.ON)
    i = i + step

#
#  Now dump 12 steps in this morphing sequence as 12 distinct files.
Пример #29
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Intersection of two boxes:
#
#                                Created by Gershon Elber,       Jan. 89
#
save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(save_mat * irit.scale((0.15, 0.15, 0.15)))

b1 = irit.box(((-3), (-2), (-1)), 6, 4, 2)
b2 = irit.box(((-4), (-3), (-2)), 2, 2, 4)

a1 = (b2 + b1)
irit.interact(irit.list(irit.GetViewMatrix(), a1))

a2 = b2 * b1
irit.interact(a2)

a3 = (b2 - b1)
irit.interact(a3)

a4 = (b1 - b2)
irit.interact(a4)

icrv = irit.iritstate("intercrv", irit.GenIntObject(1))
a5 = b2 * b1
Пример #30
0
import math
import irit
import gersktch

#

#
#  Interpolation/least square approximation of curves and surfaces.
#
#                                        gersktch.gershon Elber, March 1994
#
# ############################################################################

save_mat = irit.GetViewMatrix()

irit.SetViewMatrix(irit.scale((0.6, 0.6, 0.6)))
irit.viewobj(irit.GetViewMatrix())
irit.viewstate("polyaprx", 1)

ri = irit.iritstate("randominit", irit.GenIntObject(1964))
#  Seed-initiate the randomizer,
irit.free(ri)

# ############################################################################

len = 1
numpts = 50

pl1 = irit.nil()
i = 1
while (i <= numpts):