def testccdistfunc(crv1, crv2, refs): if (irit.SizeOf(refs) > 0): crv1 = irit.crefine(crv1, 0, refs) crv2 = irit.crefine(crv2, 0, refs) irit.view(irit.list(irit.GetAxes(), crv1, crv2), irit.ON) bb = irit.bbox(irit.dist2ff(crv1, crv2, 1)) if (irit.FetchRealObject(irit.nth(bb, 1)) * irit.FetchRealObject(irit.nth(bb, 2)) > 0): res = "successful" else: res = "failed" all1 = irit.list(irit.nth(bb, 1), irit.nth(bb, 2), res) irit.printf("distance square bound from %8.5lf to %8.5lf (%s)\n", all1) bb = irit.bbox(irit.dist2ff(crv1, crv2, 2)) if (irit.FetchRealObject(irit.nth(bb, 1)) * irit.FetchRealObject(irit.nth(bb, 2)) > 0): res = "successful" else: res = "failed" all2 = irit.list(irit.nth(bb, 1), irit.nth(bb, 2), res) irit.printf("projection on crv1nrml bound from %8.5lf to %8.5lf (%s)\n", all2) bb = irit.bbox(irit.dist2ff(crv1, crv2, 3)) if (irit.FetchRealObject(irit.nth(bb, 1)) * irit.FetchRealObject(irit.nth(bb, 2)) > 0): res = "successful" else: res = "failed" all3 = irit.list(irit.nth(bb, 1), irit.nth(bb, 2), res) irit.printf("projection on crv2nrml bound from %8.5lf to %8.5lf (%s)\n", all3) irit.pause() retval = irit.list(all1, all2, all3) return retval
def rook(s, clr): rookbase = (-irit.surfprev( ( irit.ctlpt( irit.E2, 0.001, 0.55 ) + \ irit.ctlpt( irit.E2, 0.11, 0.55 ) + \ irit.ctlpt( irit.E2, 0.11, 0.63 ) + \ irit.ctlpt( irit.E2, 0.13, 0.63 ) + irit.cbspline( 3, irit.list( \ irit.ctlpt( irit.E2, 0.13, 0.53 ), \ irit.ctlpt( irit.E2, 0.05, 0.51 ), \ irit.ctlpt( irit.E2, 0.07, 0.29 ), \ irit.ctlpt( irit.E2, 0.18, 0.12 ), \ irit.ctlpt( irit.E2, 0.18, 0 ) ), irit.list( irit.KV_OPEN ) ) ) * irit.rx( 90 ) ) ) axs = irit.crefine( irit.creparam( irit.pcircle( ( 0, 0, 0 ), 1 ), 0, 1 ),\ 0, irit.list( 0.05, 0.1, 0.15, 0.2, 0.3, 0.35,\ 0.4, 0.45, 0.55, 0.6, 0.65, 0.7,\ 0.8, 0.85, 0.9, 0.95 ) ) scl = irit.cbspline( 2, irit.list( \ irit.ctlpt( irit.E2, 0, 0.01 ), \ irit.ctlpt( irit.E2, 0.5, 0.01 ), \ irit.ctlpt( irit.E2, 0.5, 1 ), \ irit.ctlpt( irit.E2, 1, 1 ), \ irit.ctlpt( irit.E2, 0, 0.01 ) ), irit.list( 0, 0, 0.7, 0.701, 1.999, 2,\ 3 ) ) scl = irit.creparam( scl + scl * irit.tx( 1 ) + scl * irit.tx( 2 ) + scl * irit.tx( 3 ) + scl * irit.tx( 4 ) + scl * irit.tx( 5 ) + \ irit.ctlpt( irit.E2, 6, 0.01 ), 0, 1 ) rookwall = irit.swpsclsrf( \ irit.ctlpt( irit.E2, (-0.08 ), 0 ) + \ irit.ctlpt( irit.E2, 0.08, 0 ) + \ irit.ctlpt( irit.E2, 0.08, 0.6 ) + \ irit.ctlpt( irit.E2, (-0.08 ), 0.6 ) + \ irit.ctlpt( irit.E2, (-0.08 ), 0 ), axs, scl, irit.point( 0, 0, 1 ), 2 ) * irit.sc( 0.12 ) * irit.tz( 0.63 ) irit.attrib(rookwall, "rgb", irit.GenStrObject("255,255,100")) irit.attrib(rookbase, "rgb", irit.GenStrObject(clr)) retval = irit.list(rookbase, rookwall) * irit.sc(s) return retval
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() irit.viewstate("dsrfmesh", 0) irit.pause() # # Curve refinement (note the returned curve is a bspline curve). # cb_ref = irit.crefine(cb, 0, irit.list(0.25, 0.5, 0.75)) irit.color(cb_ref, irit.YELLOW) if (display == 1): irit.interact(irit.list(irit.GetAxes(), cb, cb_ref)) # # Curve subdivision. # cb_lst = irit.cdivide(cb, 0.5) cb1 = irit.nth(cb_lst, 1) irit.color(cb1, irit.GREEN) cb2 = irit.nth(cb_lst, 2) irit.color(cb2, irit.YELLOW) if (display == 1): irit.interact(irit.list(irit.GetAxes(), cb, cb1, cb2))
c1r1 = irit.knotremove(c1, 0.01) irit.printf("size of c1 is %d and c1r1 is %d\n", irit.list(irit.SizeOf(c1), irit.SizeOf(c1r1))) c1r2 = irit.coerce(c1r1, irit.E3) irit.color(c1r2, irit.MAGENTA) irit.adwidth(c1r2, 3) irit.interact(irit.list(c1r2, c2)) irit.save("crv2rdc", irit.list(c1r2, c2)) # ############################################################################ c1 = irit.pcircle((0, 0, 0), 1) c1r1 = irit.crefine( c1, 0, irit.list( 0.1, 0.3, 0.7, 1.5, 1.7, 1.7,\ 1.7, 1.7, 2.3, 2.3, 2.7, 3.5,\ 3.5, 3.5 ) ) c1r2 = irit.knotclean(c1r1) irit.save("crv3rdc", irit.list(c1r2 == c1, c1r2)) # ############################################################################ c1 = irit.circle((0, 0, 0), 1) c1r1 = irit.crefine( c1, 0, irit.list( 0.1, 0.3, 0.7, 1.5, 1.7, 1.7,\ 1.7, 2.3, 2.3, 2.7, 3.5, 3.5,\ 3.5 ) ) c1r2 = irit.knotclean(c1r1) irit.save("crv4rdc", irit.list(c1 == c1r2, c1r2))
while ( i <= 7 ): irit.snoc( irit.point( math.cos( i * 2 * math.pi/8 ), math.sin( i * 2 * 3.14159/8 ), 0 ), ptlist ) i = i + 1 c1 = irit.coerce( irit.cbspline( 3, ptlist, irit.list( irit.KV_PERIODIC ) ), irit.KV_OPEN ) * irit.rz( (-22.5 ) ) c2 = irit.coerce( irit.cbspline( 2, ptlist, irit.list( irit.KV_PERIODIC ) ), irit.KV_OPEN ) * irit.sc( 1.1 ) minsize = 0.01 body = irit.sfromcrvs( irit.list( c2 * irit.sc( minsize ) * irit.tz( 0.05 ), c2 * irit.sc( 0.7 ) * irit.tz( 0.05 ), c2 * irit.sc( 0.8 ) * irit.tz( 0.05 ), c2 * irit.sc( 0.9 ), c2, c2 * irit.tz( 2 ), c2 * irit.tz( 2.2 ), c1 * irit.tz( 2.2 ), c1 * irit.tz( 2 ), c1 * irit.tz( 0.4 ), c1 * irit.sc( 0.5 ) * irit.tz( 0.2 ), c1 * irit.sc( minsize ) * irit.tz( 0.2 ) ), 3, irit.KV_OPEN ) handaxis = irit.crefine( irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 0.3, 0, 0.1 ), \ irit.ctlpt( irit.E3, 0.5, 0, 0.5 ), \ irit.ctlpt( irit.E3, 0.5, 0, 0.8 ), \ irit.ctlpt( irit.E3, 0, 0, 0.8 ) ), irit.list( irit.KV_OPEN ) ), 0, irit.list( 0.1, 0.23, 0.43, 0.57 ) ) handle = irit.swpsclsrf( c1 * irit.sx( 0.7 ), handaxis * irit.sc( 1.5 ), irit.GenRealObject(0.15), irit.list( 0, 1, 0 ), 1 ) * irit.trans( ( 1, 0, 0.4 ) ) cup = irit.list( body, handle ) irit.color( cup, irit.WHITE ) irit.save( "cup", cup ) irit.interact( cup ) bodyin = irit.sregion( body, irit.ROW, 0.6, 1 ) irit.color( bodyin, irit.RED ) bodyout = irit.sregion( body, irit.ROW, 0, 0.6 ) irit.color( bodyout, irit.GREEN )
irit.GenRealObject(irit.GetMeshSize(mc, 0))) printtest("meshsize", irit.GenRealObject(irit.GetMeshSize(s, irit.COL)), irit.GenRealObject(irit.GetMeshSize(ms, 0))) printtest("meshsize", irit.GenRealObject(irit.GetMeshSize(s, irit.ROW)), irit.GenRealObject(irit.GetMeshSize(ms, 1))) printtest("meshsize", irit.GenRealObject(irit.GetMeshSize(s3, irit.ROW)), irit.GenRealObject(irit.GetMeshSize(ms3, 1))) printtest("meshsize", irit.GenRealObject(irit.GetMeshSize(t, irit.COL)), irit.GenRealObject(irit.GetMeshSize(mt, 0))) printtest("meshsize", irit.GenRealObject(irit.GetMeshSize(t, irit.ROW)), irit.GenRealObject(irit.GetMeshSize(mt, 1))) printtest("meshsize", irit.GenRealObject(irit.GetMeshSize(t, irit.DEPTH)), irit.GenRealObject(irit.GetMeshSize(mt, 2))) printtest( "mrefine", irit.crefine(c, 0, irit.list(0.15, 0.25, 0.65, 0.85)), irit.coerce(irit.mrefine(mc, 0, 0, irit.list(0.15, 0.25, 0.65, 0.85)), irit.CURVE_TYPE)) printtest("mrefine", irit.srefine(s, irit.COL, 0, irit.list(0.5, 0.6, 0.7)), irit.coerce(irit.mrefine(ms, 0, 0, irit.list(0.5, 0.6, 0.7)), 8)) printtest( "mrefine", irit.srefine(s, irit.ROW, 0, irit.list(0.15, 0.25, 0.75)), irit.coerce(irit.mrefine(ms, 1, 0, irit.list(0.15, 0.25, 0.75)), irit.SURFACE_TYPE)) printtest( "mrefine", irit.srefine(irit.coerce(s3, irit.KV_FLOAT), irit.ROW, 0, irit.list(0.15, 0.25, 0.75)), irit.coerce(irit.mrefine(ms3, 1, 0, irit.list(0.15, 0.25, 0.75)), irit.SURFACE_TYPE))
irit.attrib( chairbase, "rgb", irit.GenStrObject("244,164,96" )) irit.free( chairbasemain ) irit.free( chairbasecover1 ) irit.free( chairbasecover2 ) # # A full free form chair. # chairswpcrv = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E3, 0.6, 0, 0.5 ), \ irit.ctlpt( irit.E3, 0.3, 0, 0.6 ), \ irit.ctlpt( irit.E3, 0, 0, 0.5 ), \ irit.ctlpt( irit.E3, (-0.1 ), 0, 0.5 ), \ irit.ctlpt( irit.E3, (-0.1 ), 0, 0.6 ), \ irit.ctlpt( irit.E3, 0, 0, 0.9 ), \ irit.ctlpt( irit.E3, (-0.1 ), 0, 1.2 ) ), irit.list( irit.KV_OPEN ) ) chairswpcrv = irit.crefine( chairswpcrv, 0, irit.list( 0.002, 0.02, 0.04, 0.06, 0.94, 0.96,\ 0.98, 0.998 ) ) chaircovermain = (-irit.sweepsrf( chairbasecross * irit.rz( 90 ), chairswpcrv, irit.GenRealObject(0 ) )) irit.color( chaircovermain, irit.YELLOW ) irit.attrib( chaircovermain, "texture", irit.GenStrObject("wood" )) irit.attrib( chaircovermain, "rgb", irit.GenStrObject("244,164,96" )) irit.free( chairswpcrv ) irit.free( chairbasecross ) chaircover1 = irit.cmesh( chaircovermain, irit.ROW, 14 ) chaircover1a = chaircover1 * irit.trans( ( (-0.018 ), 0, 0.06 ) ) chaircover1b = chaircover1 * irit.scale( ( 0, 0.83, 0 ) ) * irit.trans( ( (-0.124 ), 0, 1.26 ) ) chaircovertop = irit.sfromcrvs( irit.list( chaircover1, chaircover1a, chaircover1b ), 3, irit.KV_OPEN ) irit.color( chaircovertop, irit.YELLOW ) irit.attrib( chaircovertop, "texture", irit.GenStrObject("wood" )) irit.attrib( chaircovertop, "rgb", irit.GenStrObject("244,164,96" ))
c1 = irit.cbspline( 3, irit.list( irit.ctlpt( irit.E2, (-0.324 ), (-0.29 ) ), \ irit.ctlpt( irit.E2, 0.1, 0.414 ), \ irit.ctlpt( irit.E2, 0.431, 0.899 ), \ irit.ctlpt( irit.E2, 0.082, 0.978 ), \ irit.ctlpt( irit.E2, (-0.403 ), 0.132 ), \ irit.ctlpt( irit.E2, (-0.521 ), (-0.984 ) ) ), irit.list( irit.KV_OPEN ) ) irit.color(c1, irit.CYAN) irit.interact(irit.list(ptlist, c1)) c1 = irit.cbsp_fit(ptlist, c1, 2, irit.list(5, 0, 0, 0.001)) c1 = irit.creparam(c1, 0, 1) irit.color(c1, irit.CYAN) irit.interact(irit.list(ptlist, c1)) c1a = irit.crefine(c1, 0, irit.list(1 / 8, 3 / 8, 5 / 8, 7 / 8)) c1a = irit.cbsp_fit(ptlist, c1a, 2, irit.list(15, 0, 0, 5e-005)) irit.color(c1a, irit.YELLOW) irit.interact(irit.list(ptlist, c1a)) irit.save("cbsp6fit", irit.list(ptlist, c1, c1a)) # ############################################################################ # Slower examples # ############################################################################ ## ############################################################################ #
irit.ctlpt( irit.E2, 0.6, 0.75 ), \ irit.ctlpt( irit.E2, 0.6, 0.9 ), \ irit.ctlpt( irit.E2, 0.4, 0.9 ), \ irit.ctlpt( irit.E2, 0.4, 0.75 ), \ irit.ctlpt( irit.E2, 0.2, 0.75 ), \ irit.ctlpt( irit.E2, 0.2, 0.25 ), \ irit.ctlpt( irit.E2, 0.5, 0.25 ) ), irit.list( irit.KV_OPEN ) ) tsrf1 = irit.trimsrf(srf1, tcrv1, 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))
1 ) irit.color(sbopencol, irit.CYAN) if (display == 1): irit.view(irit.list(sb, sbopencol), irit.ON) irit.viewstate("dsrfmesh", 1) irit.pause() irit.viewstate("dsrfmesh", 0) irit.pause() irit.free(sb) irit.free(sbopenrow) irit.free(sbopencol) # # Curve refinement. # cb_ref = irit.crefine(cb, 0, irit.list(0.25, 0.5, 0.75)) irit.color(cb_ref, irit.YELLOW) if (display == 1): irit.interact(irit.list(irit.GetAxes(), cb, cb_ref)) irit.free(cb_ref) # # Knot substitution (One internal knot is moved from 0.1 to 0.9). # cb_ref = irit.crefine(cb, 0, irit.list(0.5)) cb_all = irit.list(irit.GetAxes()) t = 0.1 while (t <= 0.9): cb1 = irit.crefine( cb_ref, 1, irit.list( 0, 0, 0, t, 1, 1,\ 1 ) ) irit.color(cb1, irit.GREEN)
irit.ctlpt( irit.P2, s45, s45, s45 ), \ irit.ctlpt( irit.P2, 1, 0, 1 ) ), irit.list( irit.KV_FLOAT ) ) srf = irit.sbspline( 3, 3, irit.list( irit.list( irit.ctlpt( irit.E3, 0.1, 0, 1 ), \ irit.ctlpt( irit.E3, 0.3, 1, 0 ), \ irit.ctlpt( irit.E3, 0, 2, 1 ) ), irit.list( \ irit.ctlpt( irit.E3, 3.1, 0, 0 ), \ irit.ctlpt( irit.E3, 3.3, 1, 2 ), \ irit.ctlpt( irit.E3, 3, 2, 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 ) ) ), irit.list( irit.list( irit.KV_FLOAT ), irit.list( irit.KV_FLOAT ) ) ) irit.snoc( irit.coerce( crv, irit.KV_OPEN ), results ) irit.snoc( irit.coerce( crv, irit.BEZIER_TYPE ), results ) irit.snoc( irit.coerce( irit.coerce( crv, irit.POWER_TYPE ), irit.BEZIER_TYPE ), results ) irit.snoc( irit.coerce( irit.crefine( crv, 0, irit.list( 0.3, 0.6 ) ), irit.BEZIER_TYPE ), results ) irit.snoc( irit.coerce( srf, irit.KV_OPEN ), results ) irit.snoc( irit.coerce( srf, irit.BEZIER_TYPE ), results ) irit.snoc( irit.coerce( srf, irit.POWER_TYPE ), results ) irit.snoc( irit.coerce( irit.coerce( srf, irit.POWER_TYPE ), irit.BEZIER_TYPE ), results ) irit.snoc( irit.coerce( irit.srefine( irit.srefine( srf, irit.ROW, 0, irit.list( 0.3, 0.6 ) ), irit.COL, 0, irit.list( 0.3, 0.6 ) ), irit.BEZIER_TYPE ), results ) irit.save( "coerce", results ) irit.free( results ) irit.free( crv ) irit.free( srf )
# Diana Pekerman, Dec 2004. # ############################################################################ # # Example 1 # e1_c1 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 8, 12, 13 ) ) ) # Modifying E1_C1 e1_c1 = irit.coerce( e1_c1, irit.BSPLINE_TYPE ) e1_c1 = irit.cregion( e1_c1, 0.1, 0.9 ) e1_c1 = irit.crefine( e1_c1, 0, irit.list( 0.25, 0.4, 0.45, 0.8 ) ) e1_c1 = irit.craise( e1_c1, 2 + irit.FetchRealObject(irit.nref( irit.fforder( e1_c1 ), 1 ) )) e1_c2 = irit.cbezier( irit.list( irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 0, 0, 0 ), \ irit.ctlpt( irit.E3, 8, 12, 13 ) ) ) # Modifying E1_C2 e1_c2 = irit.coerce( e1_c2, irit.BSPLINE_TYPE ) e1_c2 = irit.cregion( e1_c2, 0.3, 0.6 ) e1_c2 = irit.crefine( e1_c2, 0, irit.list( 0.35, 0.4, 0.55 ) ) e1_c2 = irit.craise( e1_c2, 1 + irit.FetchRealObject(irit.nref( irit.fforder( e1_c2 ), 1 ) )) # Overlapping with domain [0.3, 0.6] for both curves E1_C1 and E1_C2. res1 = irit.ffcmpcrvs( e1_c1, e1_c2, 1e-006 )