예제 #1
0
def plotfunc3d(minx, maxx, miny, maxy, n, m):
    pl = plotfunc3d2poly(minx, maxx, miny, maxy, n, m)
    irit.color(pl, irit.YELLOW)
    irit.attrib(pl, "width", irit.GenRealObject(0.05))
    minz = 1e+006
    maxz = (-1e+006)
    i = 0
    while (i <= irit.SizeOf(pl) - 1):
        p = irit.coord(pl, i)
        j = 0
        while (j <= irit.SizeOf(p) - 1):
            v = irit.coord(p, i)
            if (irit.FetchRealObject(irit.coord(v, 2)) > maxz):
                maxz = irit.FetchRealObject(irit.coord(v, 2))
            if (irit.FetchRealObject(irit.coord(v, 2)) < minz):
                minz = irit.FetchRealObject(irit.coord(v, 2))
            j = j + 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.poly(
                                    irit.list((0, 0, irit.min(minz, 0)),
                                              (0, 0, irit.max(maxz, 0))), 1))

    irit.color(ax, irit.RED)
    irit.attrib(ax, "width", irit.GenRealObject(0.02))
    retval = irit.list(pl, ax)
    irit.viewobj(retval)
    irit.printf(
        "xdomain = [%lf %lf], ydomain = [%lf %lf], zdomain = [%lf %lf]\n",
        irit.list(minx, maxx, miny, maxy, minz, maxz))
    return retval
예제 #2
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
예제 #3
0
def interact( none ):
    irit.viewdclear(  )
    irit.viewobj( none )
    irit.pause(  )
예제 #4
0
a = (cone1 + cylin1)
irit.free(cylin1)
irit.free(cone1)
irit.interact(irit.list(view_mat1, a))

#
#  Currently variables can not be introduced in a loop (except the iteration
#  variable), so we prepare all variables in advance.
#
cntrs = irit.nil()
intrcrv = irit.iritstate("intercrv", irit.GenIntObject(1))
i = (-0.9)
while (i <= 2.9):
    p = irit.circpoly((0, 0, 1), (0, 0, i), 6)
    c = a * p
    irit.viewobj(c)
    irit.snoc(c, cntrs)
    i = i + 0.1

intrcrv = irit.iritstate("intercrv", intrcrv)

irit.viewremove("c")
irit.viewobj(cntrs)
irit.pause()

irit.save("contour1", cntrs)

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

irit.SetResolution(50)
view_mat1 = irit.GetViewMatrix() * irit.sc(0.9)
예제 #5
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Some examples of proper piecewise linear sampling in gpolyline.
#
save_res = irit.GetResolution()

save_mat = irit.GetViewMatrix()

irit.SetViewMatrix(irit.rotx(0))
irit.viewobj(irit.GetViewMatrix())

irit.SetViewMatrix(save_mat)

irit.viewstate("dblbuffer", 1)
irit.viewstate("depthcue", 1)

dlevel = irit.iritstate("dumplevel", irit.GenIntObject(255))

#  Faster product using Bezier decomposition.
iprod = irit.iritstate("bspprodmethod", irit.GenIntObject(0))

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

pl2 = irit.nil()
x = 0
while (x <= 5):
예제 #6
0
    while (i <= n):
        j = 0
        while (j <= m):
            irit.snoc( virttree3( irit.point( i * 5, j * 5, 0 ), irit.vector( 0, 0, 1 ), 0.3, blevel, level ),\
            retval )
            j = j + 1
        i = i + 1
    return retval

base = irit.ruledsrf( irit.ctlpt( irit.E2, (-20 ), (-20 ) ) + \
                      irit.ctlpt( irit.E2, (-20 ), 40 ), \
                      irit.ctlpt( irit.E2, 40, (-20 ) ) + \
                      irit.ctlpt( irit.E2, 40, 40 ) )
irit.attrib(base, "rgb", irit.GenStrObject("244,164,96"))
irit.attrib(base, "ptexture", irit.GenStrObject("ground.rle"))
irit.viewobj(base)
irit.save("base", base)

frst = forest3(1, 1, 2, 4)
irit.view(irit.list(frst, base), irit.ON)

#
#  Be prepared, this one is quite large.
#
#  frst = forest3( 4, 4, 3, 5 );
#  viewstate( "PolyAprx", 0 );
#  viewstate( "PolyAprx", 0 );
#  viewstate( "PolyAprx", 0 );
#  viewstate( "NumIsos", 0 );
#  viewstate( "NumIsos", 0 );
#  viewstate( "NumIsos", 0 );
예제 #7
0
import math
import irit
#

#
#  Some examples of K-orthotomics (See Fundamentals of Computer Aided
#  Geometric Design, by J. Hoschek and D. Lasser.)
#
#                        Gershon Elber, August 1996.
#

save_mat = irit.GetViewMatrix()
view_mat3d = save_mat * irit.ry(15) * irit.sc(0.6)
view_mat2d = irit.sc(0.6)

irit.viewobj(view_mat2d)
irit.viewstate("widthlines", 1)

# ############################################################################
#
#  A cubic curve
#

pt = irit.point(0, 0.35, 0)
irit.color(pt, irit.CYAN)

#
#  Modifying the curve.
#
a = 0
while (a >= (-1)):
예제 #8
0
import irit
#

#
#  A simple simulation of page flipping.
#
#                                Gershon Elber, March 1994.
#

page1 = irit.ruledsrf( irit.ctlpt( irit.E2, 0, 0 ) + \
                       irit.ctlpt( irit.E2, 1, 0 ), \
                       irit.ctlpt( irit.E2, 0, 1.5 ) + \
                       irit.ctlpt( irit.E2, 1, 1.5 ) )
page1 = irit.sraise(irit.sraise(page1, irit.ROW, 4), irit.COL, 4)
irit.color(page1, irit.GREEN)
irit.viewobj(page1)

page2 = irit.seditpt(irit.coerce(page1, irit.E3),
                     irit.ctlpt(irit.E3, 0.9, 1.35, 0.5), 3, 3)
irit.color(page2, irit.RED)
irit.viewobj(page2)

page3 = irit.srefine(page2, irit.COL, 0, irit.list(0.3, 0.6))
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 1.5, 0.4), 5, 3)
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 1, 0.4), 5, 2)
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 0.5, 0.4), 5, 1)
page3 = irit.seditpt(irit.coerce(page3, irit.E3),
                     irit.ctlpt(irit.E3, 0.6, 0, 0.4), 5, 0)
예제 #9
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#


# 
#  Examples of constructing uniform point distributions on freeforms.
# 
#                                        Gershon Elber, August 1996.
# 

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(  irit.rotx( 0 ))
irit.viewobj( irit.GetViewMatrix() )

# 
#  Some examples for curves.
# 

c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E2, (-1 ), 0 ), \
                              irit.ctlpt( irit.E2, (-1 ), 0.1 ), \
                              irit.ctlpt( irit.E2, (-0.9 ), (-0.1 ) ), \
                              irit.ctlpt( irit.E2, 0.9, 0 ) ) )
irit.color( c1, irit.MAGENTA )

pts = irit.ffptdist( c1, 0, 1000 )
e2pts = irit.nil(  )
i = 1
while ( i <= irit.SizeOf( pts ) ):
예제 #10
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Curve Curve Intersection properties.
#

view_mat2 = irit.sc(1)
irit.viewobj(view_mat2)

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

view_mat2 = irit.sc(0.5) * irit.ty(0.5)
irit.viewobj(view_mat2)

c1 = irit.cbspline( 2, irit.list( irit.ctlpt( irit.E3, (-2 ), 0, 0 ), \
                                  irit.ctlpt( irit.E2, 0, (-2 ) ), \
                                  irit.ctlpt( irit.E2, 2, 0 ) ), \
                    irit.list( irit.KV_OPEN ) )
c2 = irit.cbspline( 2, irit.list( irit.ctlpt( irit.E3, 2, (-2 ), 0 ), \
                                  irit.ctlpt( irit.E2, 0, 0 ), \
                                  irit.ctlpt( irit.E2, (-2 ), (-2 ) ) ), \
                    irit.list( irit.KV_OPEN ) )

ip = irit.ccintrprop(c1, c2, 1e-008)
irit.printf("number of intersection loops = %d\n",
            irit.list(irit.SizeOf(ip) - 1))
예제 #11
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

a = irit.GetAxes() * irit.GetViewMatrix()

ared = a
irit.color(ared, irit.RED)
irit.viewobj(ared)
irit.free(ared)

agreen = a * irit.rotz(15)
irit.color(agreen, irit.GREEN)
irit.viewobj(agreen)
irit.free(agreen)

ablue = a * irit.rotz(30)
irit.color(ablue, irit.BLUE)
irit.viewobj(ablue)
irit.free(ablue)

ayellow = a * irit.rotz(45)
irit.color(ayellow, irit.YELLOW)
irit.viewobj(ayellow)
irit.free(ayellow)

acyan = a * irit.rotz(60)
irit.color(acyan, irit.CYAN)
irit.viewobj(acyan)
예제 #12
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  A simple example of multi resolution decomposition of curves.
#
#                                        Gershon Elber, July 1994.
#

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.rotx(0))
irit.viewobj(irit.GetViewMatrix())
irit.SetViewMatrix(save_mat)

crv1 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, 0, 0 ), \
                                    irit.ctlpt( irit.E2, 0, 0.1 ), \
                                    irit.ctlpt( irit.E2, 0.1, 0.1 ), \
                                    irit.ctlpt( irit.E2, 0.1, (-0.1 ) ), \
                                    irit.ctlpt( irit.E2, (-0.1 ), (-0.1 ) ), \
                                    irit.ctlpt( irit.E2, (-0.1 ), 0.2 ), \
                                    irit.ctlpt( irit.E2, 0.2, 0.2 ), \
                                    irit.ctlpt( irit.E2, 0.2, (-0.2 ) ), \
                                    irit.ctlpt( irit.E2, (-0.2 ), (-0.2 ) ), \
                                    irit.ctlpt( irit.E2, (-0.2 ), 0.3 ), \
                                    irit.ctlpt( irit.E2, 0, 0.3 ) ), irit.list( irit.KV_OPEN ) )
irit.color(crv1, irit.GREEN)
irit.view(crv1, irit.ON)
예제 #13
0
                             irit.ctlpt( irit.E3, 2, 1, 0.8 ), \
                             irit.ctlpt( irit.E3, 2, 2.1, 1 ) ), irit.list( \
                             irit.ctlpt( irit.E3, 3, 0, 2 ), \
                             irit.ctlpt( irit.E3, 3.1, 1, 1.8 ), \
                             irit.ctlpt( irit.E3, 3, 2.1, 2 ) ) )
s = irit.sbspline(3, 4, sbsp,
                  irit.list(irit.list(irit.KV_OPEN), irit.list(irit.KV_OPEN)))
irit.color(s, irit.WHITE)
irit.free(sbsp)

dus = irit.sderive(s, irit.ROW) * irit.scale((0.5, 0.5, 0.5))
irit.color(dus, irit.GREEN)
dvs = irit.sderive(s, irit.COL) * irit.scale((0.5, 0.5, 0.5))
irit.color(dvs, irit.MAGENTA)
if (display == 1):
    irit.viewobj(irit.GetAxes())
    irit.viewstate("dsrfmesh", 1)
    irit.interact(irit.list(irit.GetAxes(), s, dus, dvs))
    irit.viewstate("dsrfmesh", 0)

ns = irit.snrmlsrf(s) * irit.scale((0.3, 0.3, 0.3))
irit.color(ns, irit.GREEN)
if (display == 1):
    irit.interact(irit.list(irit.GetAxes(), s, ns))

#  Compute the normal at the center of the surface, in three ways.

irit.save(
    "nrml1srf",
    irit.list(
        irit.GetAxes(), s, ns, dus, dvs,
예제 #14
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Some tests for the PRISA (planar layout) code.
#

save_res = irit.GetResolution()
save_mat = irit.GetViewMatrix()
samppercrv = 64
irit.viewobj(irit.GetViewMatrix())

irit.viewstate("numisos", 0)
irit.viewstate("numisos", 0)

# ############################################################################
#
#  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 ), \
예제 #15
0
#This is an IRIT script and as such requires both math and irit import:
#
import math
import irit
#

#
#  Convex Hull and related computation for freeform curves.
#
#                                Gershon Elber, February 1996
#

save_mat = irit.GetViewMatrix()
irit.SetViewMatrix(irit.sc(0.5))
irit.viewobj(irit.GetViewMatrix())
ri = irit.iritstate("randominit", irit.GenIntObject(1964))
#  Seed-initiate the randomizer,
irit.free(ri)

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

pts = irit.nil()
len = 1
numpts = 5
i = 0
while (i <= numpts):
    r = irit.random(0, 2)
    pt = irit.ctlpt(irit.E2, len * r * math.cos(i * 2 * math.pi / numpts),
                    len * r * math.sin(i * 2 * 3.14159 / numpts))
    irit.snoc(pt, pts)
    i = i + 1
예제 #16
0
playnetwork = network * irit.trans( ( (-4 ), (-1.5 ), 0 ) )

irit.free( swing )
irit.free( slide )
irit.free( rslide )
irit.free( tswing )
irit.free( network )
irit.free( carousel )
irit.free( sandbox )

all = irit.list( playground, playcarousel, playswing, playslidesand, playslide2, playrslide,\
playtswing1, playtswing2, playnetwork )

irit.free( playground )
irit.free( playcarousel )
irit.free( playswing )
irit.free( playslidesand )
irit.free( playslide2 )
irit.free( playrslide )
irit.free( playtswing1 )
irit.free( playtswing2 )
irit.free( playnetwork )

irit.save( "playgrnd", all )

irit.viewobj( all )
irit.pause()

irit.free( all )

예제 #17
0
irit.free(cross1)
irit.free(cross2)

legs = irit.list(leg1, leg1 * irit.tx(80), leg2 * irit.trans((0, 190, 0)),
                 leg2 * irit.trans((80, 190, 0)))
irit.attrib(legs, "rgb", irit.GenStrObject("244,164,96"))
irit.free(leg1)
irit.free(leg2)

skel = irit.list( irit.box( ( (-1 ), (-1 ), 25 ), 80, 2, 20 ),\
irit.box( ( (-1 ), (-1 ), 25 ), 2, 190, 20 ),\
irit.box( ( (-1 ), 189, 25 ), 80, 2, 20 ),\
irit.box( ( 79, (-1 ), 25 ), 2, 190, 20 ),\
irit.box( ( (-1 ), 90, 25 ), 80, 2, 20 ) )
irit.attrib(skel, "rgb", irit.GenStrObject("255,255,100"))
irit.viewobj(skel)

cover = irit.box((0, 0, 45), 80, 190, 1)
irit.attrib(cover, "rgb", irit.GenStrObject("244,164,96"))

backcross = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, 0, 75 ), \
                                         irit.ctlpt( irit.E3, 15, 0, 75 ), \
                                         irit.ctlpt( irit.E3, 30, 0, 95 ), \
                                         irit.ctlpt( irit.E3, 50, 0, 95 ), \
                                         irit.ctlpt( irit.E3, 65, 0, 75 ), \
                                         irit.ctlpt( irit.E3, 80, 0, 75 ) ), irit.list( irit.KV_OPEN ) )
backcrosspts = irit.list(irit.vector(80, 0, 75), irit.vector(80, 0, 45),
                         irit.vector(0, 0, 45))

heartcross = ( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, 0, (-10 ) ), \
                                            irit.ctlpt( irit.E3, 3, 0, 0 ), \
예제 #18
0
#
import math
import irit
#

#
#  Demonstrates and adaptively reduced the degeneracies of Gimbell Lock.
#
#                                                Gershon Elber, April 1995.
#

#
#  Extracts and displays a half a sphere.
#
s = irit.sregion(irit.spheresrf(1), irit.ROW, 0, 1)
irit.viewobj(s)


#
#  Computes a curve on a sphere between two spheical angles by interpolating
#  between the two angles a piecewise linear curve.
#
def computesphericalcrv(theta1, theta2, phi1, phi2):
    ptlist = irit.nil()
    t = 0
    while (t <= 100):
        theta = (theta2 * t + theta1 * (100 - t)) * math.pi / (180 * 100)
        phi = (phi2 * t + phi1 * (100 - t)) * math.pi / (180 * 100)
        irit.snoc(
            irit.point(
                math.cos(theta) * math.cos(phi),
예제 #19
0
    while ( j <= irit.SizeOf( pl ) - 1 ):
        irit.snoc( irit.coord( pl, j ), retval )
        j = j + 1
    irit.snoc( irit.coord( pl, 0 ), retval )
    retval = irit.poly( retval, irit.TRUE )
    irit.attrib( retval, "dwidth", irit.GenIntObject(3 ))
    return retval

def extractgammasrf( tv, t, clr ):
    retval = irit.strivar( tv, irit.ROW, t )
    irit.color( retval, clr )
    return retval

view_mat1 = irit.sc( 1 )

irit.viewobj( view_mat1 )

irit.viewstate( "numisos", 1 )
irit.viewstate( "numisos", 1 )
irit.viewstate( "polyaprx", 1 )
irit.viewstate( "polyaprx", 1 )
irit.viewstate( "polyaprx", 1 )
irit.viewstate( "drawstyle", 1 )
irit.viewstate( "depthcue", 0 )
irit.viewstate( "dsrfpoly", 1 )

# ############################################################################
# 
#  Polygons:
# 
# ############################################################################
예제 #20
0
threecyls = irit.trefine( irit.trefine( irit.trefine( threecyls, irit.ROW, 0, reflist ), irit.COL, 0,\
reflist ), irit.DEPTH, 0, reflist )
irit.free(reflist)

isoval = 0.12
size = 0.04
srf1 = irit.mrchcube(irit.list(threecyls, 1, 1, 1), (size, size, size), 1,
                     isoval)
irit.color(srf1, irit.RED)
irit.interact(srf1)

cover1 = irit.coveriso(threecyls, 100, 1, (1, 5, 1), 0.2, isoval,
                       (0, 0, 1)) * irit.sc(size)
irit.color(cover1, irit.YELLOW)
irit.viewobj(cover1)
irit.save("tvcover1", irit.list(srf1, cover1))
irit.pause()

cover1 = irit.coveriso(threecyls, 100, 2, (1, 5, 1), 0.2, isoval,
                       (0, 0, 1)) * irit.sc(size)
irit.color(cover1, irit.YELLOW)
irit.viewobj(cover1)
irit.save("tvcover2", irit.list(srf1, cover1))
irit.pause()

cover1 = irit.coveriso(threecyls, 100, 4, (1, 5, 1), 0.2, isoval,
                       (0, 0, 1)) * irit.sc(size)
irit.color(cover1, irit.YELLOW)
irit.viewobj(cover1)
irit.save("tvcover3", irit.list(srf1, cover1))