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
def evalonebitangency(srfs, pts): ruling = irit.nil() tmp1pts = irit.nil() tmp2pts = irit.nil() if (irit.ThisObject(srfs) == irit.SURFACE_TYPE): srf1 = srfs srf2 = srfs else: srf1 = irit.nth(srfs, 1) srf2 = irit.nth(srfs, 2) i = 1 while (i <= irit.SizeOf(pts)): pt = irit.nth(pts, i) pt1 = irit.seval(srf1, irit.FetchRealObject(irit.coord(pt, 1)), irit.FetchRealObject(irit.coord(pt, 2))) pt2 = irit.seval(srf2, irit.FetchRealObject(irit.coord(pt, 3)), irit.FetchRealObject(irit.coord(pt, 4))) irit.snoc(pt1 + pt2, ruling) irit.snoc(pt1 * irit.tx(0), tmp1pts) irit.snoc(pt2 * irit.tx(0), tmp2pts) i = i + 1 irit.attrib(ruling, "rgb", irit.GenStrObject("255, 128, 128")) if (irit.SizeOf(tmp1pts) > 1 and irit.SizeOf(tmp2pts) > 1): tmp1pts = irit.poly(tmp1pts, irit.TRUE) tmp2pts = irit.poly(tmp2pts, irit.TRUE) irit.attrib(tmp1pts, "rgb", irit.GenStrObject("128, 255, 128")) irit.attrib(tmp2pts, "rgb", irit.GenStrObject("128, 255, 128")) retval = irit.list(ruling, tmp1pts, tmp2pts) else: retval = irit.nil() return retval
def evalantipodalptsonsrf( srf ): aps = irit.antipodal( srf, 0.001, (-1e-012 ) ) irit.printf( "%d antipodal points detected\n", irit.list( irit.SizeOf( aps ) ) ) retval = irit.nil( ) diam = 0 i = 1 while ( i <= irit.SizeOf( aps ) ): ap = irit.nth( aps, i ) u1 = irit.coord( ap, 1 ) v1 = irit.coord( ap, 2 ) u2 = irit.coord( ap, 3 ) v2 = irit.coord( ap, 4 ) pt1 = irit.seval( srf, irit.FetchRealObject(u1), irit.FetchRealObject(v1) ) pt2 = irit.seval( srf, irit.FetchRealObject(u2), irit.FetchRealObject(v2) ) if ( irit.dstptpt( irit.coerce( pt1, irit.POINT_TYPE ), irit.coerce( pt2, irit.POINT_TYPE ) ) > diam ): diam = irit.dstptpt( irit.coerce( pt1, irit.POINT_TYPE ), irit.coerce( pt2, irit.POINT_TYPE ) ) diamline = pt1 + pt2 irit.snoc( irit.list( pt1 + pt2, pt1 * irit.tx( 0 ), pt2 * irit.tx( 0 ) ), retval ) i = i + 1 irit.color( retval, irit.YELLOW ) irit.color( diamline, irit.CYAN ) irit.adwidth( diamline, 3 ) irit.snoc( irit.list( diamline ), retval ) return retval
def raytraptris3d(srfs, subeps, numeps): pts = irit.raytraps(srfs, 1, subeps, numeps, 1) retval = irit.nil() if (irit.SizeOf(pts) > 1): irit.printf("%d solution(s) found\n", irit.list(irit.SizeOf(pts))) i = 1 while (i <= irit.SizeOf(pts)): pt = irit.coord(pts, i) err = irit.getattr(pt, "rngerror") if (irit.ThisObject(err) == irit.NUMERIC_TYPE): irit.printf("error = %16.14f\n", irit.list(err)) else: irit.printf("error is not provided\n", irit.nil()) points = irit.nil() j = 1 while (j <= irit.SizeOf(srfs)): irit.snoc( irit.seval( irit.nth(srfs, j), irit.FetchRealObject(irit.coord(pt, 1 + (j - 1) * 2)), irit.FetchRealObject(irit.coord(pt, 2 + (j - 1) * 2))), points) j = j + 1 irit.snoc(irit.poly(points, 0), retval) i = i + 1 return retval
def testssi(s1, s2, eps): tm = irit.time(1) inter = irit.ssinter(s1, s2, 1, eps, 0) tm = irit.time(0) irit.color(inter, irit.GREEN) irit.view(irit.list(s1, s2, inter), irit.ON) irit.printf( "no alignment: length of intersection curve %d, time = %f sec.\n", irit.list(irit.SizeOf(irit.nth(irit.nth(inter, 1), 1)), tm)) tm = irit.time(1) inter = irit.ssinter(s1, s2, 1, eps, 1) tm = irit.time(0) irit.color(inter, irit.GREEN) irit.view(irit.list(s1, s2, inter), irit.ON) irit.printf( "z alignment: length of intersection curve %d, time = %f sec.\n", irit.list(irit.SizeOf(irit.nth(irit.nth(inter, 1), 1)), tm)) tm = irit.time(1) inter = irit.ssinter(s1, s2, 1, eps, 2) tm = irit.time(0) irit.color(inter, irit.GREEN) irit.view(irit.list(s1, s2, inter), irit.ON) irit.printf( "rz alignment: length of intersection curve %d, time = %f sec.\n", irit.list(irit.SizeOf(irit.nth(irit.nth(inter, 1), 1)), tm))
def computeviews( c, dms, fname ): ranges = irit.nil( ) i = 1 while ( i <= irit.SizeOf( dms ) ): irit.snoc( cnvrtcrvs2ranges( irit.nth( dms, i ), i, 1 ), ranges ) i = i + 1 irit.printf( "%d views are considered\n", irit.list( irit.SizeOf( dms ) ) ) retval = irit.setcover( ranges, 0.001 ) return retval
def evalflecnodalpts(srfs, pts): if (irit.SizeOf(pts) == 1): retval = evaloneflecnodalpts(srfs, pts) else: retval = irit.nil() i = 1 while (i <= irit.SizeOf(pts)): irit.snoc(evaloneflecnodalpts(srfs, irit.nth(pts, i)), retval) i = i + 1 return retval
def makepolylines(listofctlpts): retval = irit.nil() i = 1 while (i <= irit.SizeOf(listofctlpts)): pl = irit.nth(listofctlpts, i) if (irit.SizeOf(pl) > 1): irit.snoc(irit.poly(irit.nth(listofctlpts, i), 1), retval) i = i + 1 return retval
def genanimationorthomatchcrvpts(ppl, crv, scl): pt1 = irit.point(0, 0, 0) pt2 = irit.point(0, 0, 0) vec1 = ( irit.ctlpt( irit.E2, 0, 0 ) + \ irit.ctlpt( irit.E2, 0, scl ) ) irit.color(vec1, irit.YELLOW) vec2 = ( \ irit.ctlpt( irit.E2, 0, 0 ) + \ irit.ctlpt( irit.E2, 0, scl ) ) irit.color(vec2, irit.CYAN) pos1 = irit.nil() pos2 = irit.nil() rot1 = irit.nil() rot2 = irit.nil() i = 0 while (i <= irit.SizeOf(ppl) - 1): pl = irit.coord(ppl, i) j = 0 while (j <= irit.SizeOf(pl) - 1): pt = irit.coord(pl, j) t1 = irit.coord(pt, 0) t2 = irit.coord(pt, 1) if (t1 > t2): irit.snoc( irit.coerce(irit.ceval(crv, irit.FetchRealObject(t1)), irit.POINT_TYPE), pos1) irit.snoc( irit.coerce(irit.ceval(crv, irit.FetchRealObject(t2)), irit.POINT_TYPE), pos2) n1 = irit.cnormal(crv, irit.FetchRealObject(t1)) n2 = irit.cnormal(crv, irit.FetchRealObject(t2)) irit.snoc( irit.vector( math.atan2(irit.FetchRealObject(irit.coord(n1, 0)), irit.FetchRealObject(irit.coord(n1, 1))) * 180 / math.pi, 0, 0), rot1) irit.snoc( irit.vector( math.atan2(irit.FetchRealObject(irit.coord(n2, 0)), irit.FetchRealObject(irit.coord(n2, 1))) * 180 / math.pi, 0, 0), rot2) j = j + 1 if (t1 > t2): irit.snoc(irit.vector(10000, 0, 0), pos1) irit.snoc(irit.vector(10000, 0, 0), pos2) irit.snoc(irit.vector(0, 0, 0), rot1) irit.snoc(irit.vector(0, 0, 0), rot2) i = i + 1 irit.attrib(pt1, "animation", makerottransanimobj(irit.nil(), pos1)) irit.attrib(pt2, "animation", makerottransanimobj(irit.nil(), pos2)) irit.attrib(vec1, "animation", makerottransanimobj(rot1, pos1)) irit.attrib(vec2, "animation", makerottransanimobj(rot2, pos2)) retval = irit.list(pt1, pt2, vec1, vec2) return retval
def extracte3pts(uvxyzpts): retval = irit.nil() irit.printf("found %d points\n", irit.list(irit.SizeOf(uvxyzpts))) i = 1 while (i <= irit.SizeOf(uvxyzpts)): uvxyzpt = irit.nth(uvxyzpts, i) irit.snoc( irit.ctlpt(irit.E3, irit.coord(uvxyzpt, 3), irit.coord(uvxyzpt, 4), irit.coord(uvxyzpt, 5)), retval) i = i + 1 return retval
def testinter(s1, s2): retval = irit.ssintr2(s1, s2, step, subdivtol, numerictol, euclidean) if (irit.SizeOf(retval) == 2): n = (irit.SizeOf(irit.nth(retval, 1)) + irit.SizeOf(irit.nth(retval, 2))) / 2.0 else: if (irit.SizeOf(retval) == 1): n = irit.SizeOf(irit.nth(retval, 1)) / 2.0 else: n = 0 irit.printf("found %d intersection connected components.\n", irit.list(n)) return retval
def putrgbonvertices(pl, rgb): retval = irit.nil() i = 0 while (i <= irit.SizeOf(pl) - 1): p = irit.coord(pl, i) j = 0 while (j <= irit.SizeOf(p) - 1): a = irit.pattrib(p, j, "rgb", rgb) j = j + 1 irit.snoc(p * irit.tx(0), retval) i = i + 1 retval = irit.mergepoly(retval) return retval
def drawbiarcs(crv, tol, maxangle): arcs = irit.cbiarcs(crv, tol, maxangle) * irit.tz(0.01) i = 1 while (i <= irit.SizeOf(arcs)): if (isodd(i)): irit.color(irit.nref(arcs, i), irit.YELLOW) else: irit.color(irit.nref(arcs, i), irit.MAGENTA) i = i + 1 irit.printf("%d arcs were used in this approximation\n", irit.list(irit.SizeOf(arcs))) irit.color(crv, irit.CYAN) irit.interact(irit.list(irit.GetAxes(), crv, arcs))
def animateorthomatchpts(ppl, crv, scl): bg_obj = irit.list(unitsquare, crv, ppl) i = 0 while (i <= irit.SizeOf(ppl) - 1): pl = irit.coord(ppl, i) j = 0 while (j <= irit.SizeOf(pl) - 1): pt = irit.coord(pl, j) t1 = irit.coord(pt, 0) t2 = irit.coord(pt, 1) if (t1 > t2): displayposnormal(crv, t1, t2, scl, bg_obj) j = j + 1 i = i + 1
def meanmeanval( pl ): n = 0 mean = 0 i = 0 while ( i <= irit.SizeOf( pl ) - 1 ): p = irit.coord( pl, i ) j = 0 while ( j <= irit.SizeOf( p ) - 1 ): h = irit.pattrib( p, j, "hcurv", irit.nil( ) ) mean = mean + h n = n + 1 j = j + 1 i = i + 1 retval = mean/float(n) return retval
def offsetcrvlist( clst, ofst ): retval = irit.nil( ) i = 1 while ( i <= irit.SizeOf( clst ) ): irit.snoc( irit.offset( irit.nth( clst, i ), irit.GenRealObject(ofst), 1e-006, 1 ), retval ) i = i + 1 return retval
def subdivtodepth(tsrf, dpth, vu, vv): if (dpth <= 0): retval = tsrf else: if (dpth / 2.0 != math.floor(dpth / 2.0)): v = vu * (2 ^ (dpth - 1)) umin = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 1)) umax = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 2)) tsrfs = irit.sdivide(tsrf, irit.COL, umin * 0.4999 + umax * 0.5001) else: v = vv * (2 ^ (dpth - 1)) vmin = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 3)) vmax = irit.FetchRealObject(irit.nth(irit.pdomain(tsrf), 4)) tsrfs = irit.sdivide(tsrf, irit.ROW, vmin * 0.4999 + vmax * 0.5001) if (irit.SizeOf(tsrfs) == 2): retval = irit.list( subdivtodepth( irit.nth( tsrfs, 1 ) * \ irit.trans( irit.Fetch3TupleObject(-v) ), dpth - 1, vu, vv ), subdivtodepth( irit.nth( tsrfs, 2 ) * \ irit.trans( irit.Fetch3TupleObject(v) ), dpth - 1, vu, vv ) ) else: retval = subdivtodepth(irit.nth(tsrfs, 1), dpth - 1, vu, vv) return retval
def srflistframecrvs(srflist, width): retval = irit.nil() i = 1 while (i <= irit.SizeOf(srflist)): retval = retval + srfframecrvs(irit.nth(srflist, i), width) i = i + 1 return retval
def getlistwithoutlast( lst ): retval = irit.nil( ) i = 1 while ( i <= irit.SizeOf( lst ) - 1 ): irit.snoc( irit.nth( lst, i ), retval ) i = i + 1 return retval
def getlistproduct( lst ): retval = 1 i = 1 while ( i <= irit.SizeOf( lst ) ): retval = retval * irit.FetchRealObject(irit.nth( lst, i )) i = i + 1 return retval
def printknotvector( str, kv ): irit.printf( " [%sknotvector:", irit.list( str ) ) i = 1 while ( i <= irit.SizeOf( kv ) ): irit.printf( " %-.6lg", irit.list( irit.nth( kv, i ) ) ) i = i + 1 irit.printf( "]\n", irit.nil( ) )
def evaltritangency(srfs, pts): retval = irit.nil() if (irit.ThisObject(srfs) == irit.SURFACE_TYPE): srf1 = srfs srf2 = srfs srf3 = srfs else: srf1 = irit.nth(srfs, 1) srf2 = irit.nth(srfs, 2) srf3 = irit.nth(srfs, 3) i = 1 while (i <= irit.SizeOf(pts)): pt = irit.nth(pts, i) irit.snoc( irit.seval(srf1, irit.FetchRealObject(irit.coord(pt, 1)), irit.FetchRealObject(irit.coord(pt, 2))) + irit.seval(srf2, irit.FetchRealObject(irit.coord(pt, 3)), irit.FetchRealObject(irit.coord(pt, 4))), retval) irit.snoc( irit.seval(srf1, irit.FetchRealObject(irit.coord(pt, 1)), irit.FetchRealObject(irit.coord(pt, 2))) + irit.seval(srf3, irit.FetchRealObject(irit.coord(pt, 5)), irit.FetchRealObject(irit.coord(pt, 6))), retval) irit.snoc( irit.seval(srf2, irit.FetchRealObject(irit.coord(pt, 3)), irit.FetchRealObject(irit.coord(pt, 4))) + irit.seval(srf3, irit.FetchRealObject(irit.coord(pt, 5)), irit.FetchRealObject(irit.coord(pt, 6))), retval) i = i + 1 return retval
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 interptseval(crvs): retval = irit.nil() i = 1 while (i <= irit.SizeOf(crvs)): crv = irit.nth(crvs, i) interpts = irit.getattr(crv, "interpts") j = 1 while (j <= irit.SizeOf(interpts)): irit.snoc( irit.ceval(crv, irit.FetchRealObject(irit.nth(interpts, j))), retval) j = j + 1 i = i + 1 irit.printf("numer of intersections detected = %d\n", irit.list(irit.SizeOf(retval))) return retval
def animbisectcrv2( crv1, crv2, data, cntr ): irit.color( crv1, irit.YELLOW ) irit.color( crv2, irit.YELLOW ) irit.adwidth( crv1, 4 ) irit.adwidth( crv2, 4 ) i = 0 while ( i <= irit.SizeOf( cntr ) - 1 ): pt = irit.coord( cntr, i ) pt1 = irit.ceval( crv1, irit.FetchRealObject(irit.coord( pt, 0 ) )) pt2 = irit.ceval( crv2, irit.FetchRealObject(irit.coord( pt, 1 ) )) nrml1 = cnormalplnr( crv1, irit.coord( pt, 0 ) ) nrml2 = cnormalplnr( crv2, irit.coord( pt, 1 ) ) aaa = irit.ptslnln( irit.Fetch3TupleObject(irit.coerce( pt1, irit.POINT_TYPE )), irit.Fetch3TupleObject(nrml1), irit.Fetch3TupleObject(irit.coerce( pt2, irit.POINT_TYPE )), irit.Fetch3TupleObject(nrml2 )) if (irit.IsNullObject(aaa)): interpt = irit.GenNullObject(); else: interpt = irit.nth( aaa, 1 ) if ( irit.ThisObject(interpt) == irit.POINT_TYPE ): irit.color( pt1, irit.GREEN ) irit.color( pt2, irit.GREEN ) irit.color( interpt, irit.WHITE ) bisectlns = irit.coerce( pt1, irit.E2 ) + irit.coerce( interpt, irit.E2 ) + irit.coerce( pt2, irit.E2 ) irit.color( bisectlns, irit.MAGENTA ) if ( irit.FetchRealObject(irit.coord( interpt, 1 )) < 10 and \ irit.FetchRealObject(irit.coord( interpt, 1 )) > (-10 ) and \ irit.FetchRealObject(irit.coord( interpt, 2 )) < 10 and \ irit.FetchRealObject(irit.coord( interpt, 2 )) > (-10 ) ): irit.view( irit.list( crv1, crv2, data, pt1, pt2, interpt, \ bisectlns ), irit.ON ) i = i + 1
def printfitresult(str, fittedsrf): global fitting irit.snoc(fittedsrf, fitting) irit.printf("%s:\n", irit.list(str)) i = 1 while (i <= irit.SizeOf(fittedsrf)): irit.printf("\t%9.6pf\n", irit.list(irit.nth(fittedsrf, i))) i = i + 1
def getpointtype( cpt ): s = irit.SizeOf( cpt ) if ( s < 0 ): ptype = "p" else: ptype = "e" retval = ( ptype + str( int( abs( s ) ) ) ) return retval
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
def gausscrvrtdomain( pl ): kmin = 1e+010 kmax = (-1e+010 ) i = 0 while ( i <= irit.SizeOf( pl ) - 1 ): p = irit.coord( pl, i ) j = 0 while ( j <= irit.SizeOf( p ) - 1 ): k = irit.FetchRealObject(irit.pattrib( p, j, "kcurv", irit.nil( ) )) if ( kmin > k ): kmin = k if ( kmax < k ): kmax = k j = j + 1 i = i + 1 retval = irit.list( kmin, kmax ) return retval
def meancrvrtdomain( pl ): hmin = 1e+010 hmax = (-1e+010 ) i = 0 while ( i <= irit.SizeOf( pl ) - 1 ): p = irit.coord( pl, i ) j = 0 while ( j <= irit.SizeOf( p ) - 1 ): h = irit.FetchRealObject(irit.pattrib( p, j, "hcurv", irit.nil( ) )) if ( hmin > h ): hmin = h if ( hmax < h ): hmax = h j = j + 1 i = i + 1 retval = irit.list( hmin, hmax ) return retval