summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/base/solids.asy
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/base/solids.asy')
-rw-r--r--Build/source/utils/asymptote/base/solids.asy70
1 files changed, 41 insertions, 29 deletions
diff --git a/Build/source/utils/asymptote/base/solids.asy b/Build/source/utils/asymptote/base/solids.asy
index 239bce4b9a0..e6613fc29c5 100644
--- a/Build/source/utils/asymptote/base/solids.asy
+++ b/Build/source/utils/asymptote/base/solids.asy
@@ -35,8 +35,7 @@ path line(path p, path q, real[] t)
// Return the projection of a generalized cylinder of height h constructed
// from area base in the XY plane and aligned with axis.
-path[] cylinder(path3 base, real h, triple axis=Z,
- projection P=currentprojection)
+path[] cylinder(path3 base, real h, triple axis=Z, projection P)
{
base=rotate(-colatitude(axis),cross(axis,Z))*base;
path3 top=shift(h*axis)*base;
@@ -84,14 +83,6 @@ struct revolution {
m=min(g);
}
- // Return the surface of rotation obtain by rotating the path3 (x,0,f(x))
- // sampled n times between x=a and x=b about an axis lying in the XZ plane.
- void operator init(triple c=O, real f(real x), real a, real b, int n=ngraph,
- interpolate3 join=operator --, triple axis=Z,
- real angle1=0, real angle2=360) {
- operator init(c,graph(new triple(real x) {return (x,0,f(x));},a,b,n,
- join),axis,angle1,angle2);
- }
revolution copy() {
return revolution(c,g,axis,angle1,angle2);
@@ -134,9 +125,7 @@ struct revolution {
}
// add transverse slice to skeleton s;
- // must be recomputed if camera is adjusted
- void transverse(skeleton s, real t, int n=nslice,
- projection P=currentprojection) {
+ void transverse(skeleton s, real t, int n=nslice, projection P) {
skeleton.curve s=s.transverse;
path3 S=slice(t,n);
triple camera=camera(P);
@@ -192,8 +181,7 @@ struct revolution {
}
// add m evenly spaced transverse slices to skeleton s
- void transverse(skeleton s, int m=0, int n=nslice,
- projection P=currentprojection) {
+ void transverse(skeleton s, int m=0, int n=nslice, projection P) {
if(m == 0) {
int N=size(g);
for(int i=0; i < N; ++i)
@@ -281,8 +269,7 @@ struct revolution {
}
// add longitudinal curves to skeleton;
- // must be recomputed if camera is adjusted
- void longitudinal(skeleton s, int n=nslice, projection P=currentprojection) {
+ void longitudinal(skeleton s, int n=nslice, projection P) {
real t, d=0;
// Find a point on g of maximal distance from the axis.
int N=size(g);
@@ -326,7 +313,7 @@ struct revolution {
push(t2);
}
- skeleton skeleton(int m=0, int n=nslice, projection P=currentprojection) {
+ skeleton skeleton(int m=0, int n=nslice, projection P) {
skeleton s;
transverse(s,m,n,P);
longitudinal(s,n,P);
@@ -349,18 +336,43 @@ void draw(picture pic=currentpicture, revolution r, int m=0, int n=nslice,
light light=currentlight, string name="",
render render=defaultrender, projection P=currentprojection)
{
- pen thin=is3D() ? thin() : defaultpen;
- skeleton s=r.skeleton(m,n,P);
- begingroup3(pic,name == "" ? "skeleton" : name,render);
- if(frontpen != nullpen) {
- draw(pic,s.transverse.back,thin+defaultbackpen+backpen,light);
- draw(pic,s.transverse.front,thin+frontpen,light);
- }
- if(longitudinalpen != nullpen) {
- draw(pic,s.longitudinal.back,thin+defaultbackpen+longitudinalbackpen,light);
- draw(pic,s.longitudinal.front,thin+longitudinalpen,light);
+ if(is3D()) {
+ pen thin=thin();
+ void drawskeleton(frame f, transform3 t, projection P) {
+ skeleton s=r.skeleton(m,n,inverse(t)*P);
+ if(frontpen != nullpen) {
+ draw(f,t*s.transverse.back,thin+defaultbackpen+backpen,light);
+ draw(f,t*s.transverse.front,thin+frontpen,light);
+ }
+ if(longitudinalpen != nullpen) {
+ draw(f,t*s.longitudinal.back,thin+defaultbackpen+longitudinalbackpen,
+ light);
+ draw(f,t*s.longitudinal.front,thin+longitudinalpen,light);
+ }
+ }
+
+ begingroup3(pic,name == "" ? "skeleton" : name,render);
+ pic.add(new void(frame f, transform3 t, picture pic, projection P) {
+ drawskeleton(f,t,P);
+ if(pic != null)
+ pic.addBox(min(f,P),max(f,P),min(frontpen),max(frontpen));
+ });
+ frame f;
+ drawskeleton(f,identity4,P);
+ pic.addBox(min3(f),max3(f));
+ endgroup3(pic);
+ } else {
+ skeleton s=r.skeleton(m,n,P);
+ if(frontpen != nullpen) {
+ draw(pic,s.transverse.back,defaultbackpen+backpen,light);
+ draw(pic,s.transverse.front,frontpen,light);
+ }
+ if(longitudinalpen != nullpen) {
+ draw(pic,s.longitudinal.back,defaultbackpen+longitudinalbackpen,
+ light);
+ draw(pic,s.longitudinal.front,longitudinalpen,light);
+ }
}
- endgroup3(pic);
}
revolution operator * (transform3 t, revolution r)