diff options
author | Karl Berry <karl@freefriends.org> | 2010-04-19 23:59:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-04-19 23:59:33 +0000 |
commit | dddce3148a2bc785603576b18ffcf72d39adbe47 (patch) | |
tree | 14f4c79ef11bcf0820a8d4ff2ab0c5ac009c365c /Build/source/utils/asymptote/base/three_surface.asy | |
parent | a01e51b01f5819b6091af48cdca581e9f2a9282e (diff) |
asy 1.93
git-svn-id: svn://tug.org/texlive/trunk@17934 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/base/three_surface.asy')
-rw-r--r-- | Build/source/utils/asymptote/base/three_surface.asy | 110 |
1 files changed, 73 insertions, 37 deletions
diff --git a/Build/source/utils/asymptote/base/three_surface.asy b/Build/source/utils/asymptote/base/three_surface.asy index e520229371f..1be7eb0259c 100644 --- a/Build/source/utils/asymptote/base/three_surface.asy +++ b/Build/source/utils/asymptote/base/three_surface.asy @@ -1343,7 +1343,7 @@ triple rectify(triple dir) path3[] align(path3[] g, transform3 t=identity4, triple position, triple align, pen p=currentpen) { - if(determinant(t) == 0) return g; + if(determinant(t) == 0 || g.length == 0) return g; triple m=min(g); triple dir=rectify(inverse(t)*-align); triple a=m+realmult(dir,max(g)-m); @@ -1353,7 +1353,7 @@ path3[] align(path3[] g, transform3 t=identity4, triple position, surface align(surface s, transform3 t=identity4, triple position, triple align, pen p=currentpen) { - if(determinant(t) == 0) return s; + if(determinant(t) == 0 || s.s.length == 0) return s; triple m=min(s); triple dir=rectify(inverse(t)*-align); triple a=m+realmult(dir,max(s)-m); @@ -1367,17 +1367,11 @@ surface surface(Label L, triple position=O) shift(position)*L.T3*s; } -path[] path(Label L, pair z=0, projection P) +private path[] path(Label L, pair z=0, projection P) { path[] g=texpath(L); - if(L.defaulttransform3) { - return L.align.is3D ? align(g,z,project(L.align.dir3,P)-project(O,P),L.p) : - shift(z)*g; - } else { - path3[] G=path3(g); - return L.align.is3D ? shift(z)*project(align(G,L.T3,O,L.align.dir3,L.p),P) : - shift(z)*project(L.T3*G,P); - } + return L.align.is3D ? align(g,z,project(L.align.dir3,P)-project(O,P),L.p) : + shift(z)*g; } void label(frame f, Label L, triple position, align align=NoAlign, @@ -1397,15 +1391,18 @@ void label(frame f, Label L, triple position, align align=NoAlign, for(patch S : surface(L,position).s) draw3D(f,S,position,L.p,light,partname(name,++i),interaction); } else { - if(L.filltype == NoFill) - fill(f,path(L,project(position,P.t),P), - color(L.T3*Z,L.p,light,shiftless(P.T.modelview))); - else { - frame d; - fill(d,path(L,project(position,P.t),P), - color(L.T3*Z,L.p,light,shiftless(P.T.modelview))); - add(f,d,L.filltype); - } + pen p=color(L.T3*Z,L.p,light,shiftless(P.T.modelview)); + if(L.defaulttransform3) { + if(L.filltype == NoFill) + fill(f,path(L,project(position,P.t),P),p); + else { + frame d; + fill(d,path(L,project(position,P.t),P),p); + add(f,d,L.filltype); + } + } else + for(patch S : surface(L,position).s) + fill(f,project(S.external(),P,1),p); } } @@ -1430,22 +1427,30 @@ void label(picture pic=currentpicture, Label L, triple position, L.T=L.T*scale(abs(P.camera-v)/abs(P.vector())); if(L.defaulttransform3) L.T3=transform3(P); + if(is3D()) { int i=-1; for(patch S : surface(L,v).s) draw3D(f,S,v,L.p,light,partname(name,++i),interaction); } + if(pic != null) { - if(L.filltype == NoFill) - fill(project(v,P.t),pic,path(L,P), - color(L.T3*Z,L.p,light,shiftless(P.T.modelview))); - else { - picture d; - fill(project(v,P.t),d,path(L,P), - color(L.T3*Z,L.p,light,shiftless(P.T.modelview))); - add(pic,d,L.filltype); - } + pen p=color(L.T3*Z,L.p,light,shiftless(P.T.modelview)); + if(L.defaulttransform3) { + if(L.filltype == NoFill) + fill(project(v,P.t),pic,path(L,P),p); + else { + picture d; + fill(project(v,P.t),d,path(L,P),p); + add(pic,d,L.filltype); + } + } else + pic.add(new void(frame f, transform T) { + for(patch S : surface(L,v).s) + fill(f,T*project(S.external(),P,1),p); + }); } + },!L.defaulttransform3); Label L=L.copy(); @@ -1678,12 +1683,28 @@ void dot(picture pic=currentpicture, Label L, triple v, align align=NoAlign, label(pic,L,v); } +pair minbound(triple[] A, projection P) +{ + pair b=project(A[0],P); + for(triple v : A) + b=minbound(b,project(v,P.t)); + return b; +} + +pair maxbound(triple[] A, projection P) +{ + pair b=project(A[0],P); + for(triple v : A) + b=maxbound(b,project(v,P.t)); + return b; +} + pair minbound(triple[][] A, projection P) { pair b=project(A[0][0],P); for(triple[] a : A) { for(triple v : a) { - b=minbound(b,project(v,P)); + b=minbound(b,project(v,P.t)); } } return b; @@ -1694,7 +1715,7 @@ pair maxbound(triple[][] A, projection P) pair b=project(A[0][0],P); for(triple[] a : A) { for(triple v : a) { - b=maxbound(b,project(v,P)); + b=maxbound(b,project(v,P.t)); } } return b; @@ -1711,6 +1732,24 @@ triple[][] operator / (triple[][] a, real[][] b) return A; } +// Draw a NURBS curve. +void draw(picture pic=currentpicture, triple[] P, real[] knot, + real[] weights=new real[], pen p=currentpen, string name="") +{ + P=copy(P); + knot=copy(knot); + weights=copy(weights); + pic.add(new void(frame f, transform3 t, picture pic, projection Q) { + if(is3D()) { + triple[] P=t*P; + draw(f,P,knot,weights,p,name); + if(pic != null) + pic.addBox(minbound(P,Q),maxbound(P,Q)); + } + },true); + pic.addBox(minbound(P),maxbound(P)); +} + // Draw a NURBS surface. void draw(picture pic=currentpicture, triple[][] P, real[] uknot, real[] vknot, real[][] weights=new real[][], material m=currentpen, @@ -1734,14 +1773,11 @@ void draw(picture pic=currentpicture, triple[][] P, real[] uknot, real[] vknot, PRCshininess=PRCshininess(m.shininess); draw(f,P,uknot,vknot,weights,m.p,m.opacity,m.shininess,PRCshininess, granularity,colors,lighton,name); - if(pic != null) { - triple[][] R=weights.length > 0 ? P/weights : P; - pic.addBox(minbound(R,Q),maxbound(R,Q)); - } + if(pic != null) + pic.addBox(minbound(P,Q),maxbound(P,Q)); } },true); - triple[][] R=weights.length > 0 ? P/weights : P; - pic.addBox(minbound(R),maxbound(R)); + pic.addBox(minbound(P),maxbound(P)); } // A structure to subdivide two intersecting patches about their intersection. |