diff options
Diffstat (limited to 'Build/source/utils/asymptote/drawsurface.h')
-rw-r--r-- | Build/source/utils/asymptote/drawsurface.h | 90 |
1 files changed, 29 insertions, 61 deletions
diff --git a/Build/source/utils/asymptote/drawsurface.h b/Build/source/utils/asymptote/drawsurface.h index c498c469068..8e9fa28827a 100644 --- a/Build/source/utils/asymptote/drawsurface.h +++ b/Build/source/utils/asymptote/drawsurface.h @@ -12,15 +12,11 @@ #include "arrayop.h" #include "path3.h" -namespace run { -extern double *copyArrayC(const array *a, size_t dim); -} - namespace camp { enum Interaction {EMBEDDED=0,BILLBOARD}; -#ifdef HAVE_LIBGL +#ifdef HAVE_GL void storecolor(GLfloat *colors, int i, const vm::array &pens, int j); #endif @@ -46,7 +42,7 @@ protected: triple Min,Max; -#ifdef HAVE_LIBGL +#ifdef HAVE_GL GLfloat *colors; triple d; // Maximum deviation of surface from a quadrilateral. triple dperp; @@ -81,7 +77,7 @@ public: if(!havenormal || !straight) { size_t k=0; - controls=new Triple[16]; + controls=new(UseGC) Triple[16]; for(size_t i=0; i < 4; ++i) { vm::array *gi=vm::read<vm::array*>(g,i); if(checkArray(gi) != 4) @@ -99,11 +95,11 @@ public: emissive=rgba(vm::read<camp::pen>(p,2)); specular=rgba(vm::read<camp::pen>(p,3)); -#ifdef HAVE_LIBGL +#ifdef HAVE_GL int size=checkArray(&pens); if(size > 0) { if(size != 4) reportError(wrongsize); - colors=new GLfloat[16]; + colors=new(UseGC) GLfloat[16]; storecolor(colors,0,pens,0); storecolor(colors,8,pens,1); storecolor(colors,12,pens,2); @@ -125,7 +121,7 @@ public: } if(s->controls) { - controls=new Triple[16]; + controls=new(UseGC) Triple[16]; for(size_t i=0; i < 16; ++i) { const double *c=s->controls[i]; store(controls[i],run::operator *(t,triple(c[0],c[1],c[2]))); @@ -135,9 +131,9 @@ public: center=run::operator *(t,s->center); normal=run::multshiftless(t,s->normal); -#ifdef HAVE_LIBGL +#ifdef HAVE_GL if(s->colors) { - colors=new GLfloat[16]; + colors=new(UseGC) GLfloat[16]; for(int i=0; i < 16; ++i) colors[i]=s->colors[i]; } else colors=NULL; @@ -148,17 +144,9 @@ public: void bounds(bbox3& b); - void ratio(pair &b, double (*m)(double, double), bool &first); + void ratio(pair &b, double (*m)(double, double), double fuzz, bool &first); - virtual ~drawSurface() { - if(controls) - delete[] controls; - -#ifdef HAVE_LIBGL - if(colors) - delete[] colors; -#endif - } + virtual ~drawSurface() {} bool write(prcfile *out, unsigned int *count, vm::array *index, vm::array *origin); @@ -192,7 +180,7 @@ protected: triple Min,Max; -#ifdef HAVE_LIBGL +#ifdef HAVE_GL GLfloat *colors; GLfloat *Controls; GLfloat *uKnots; @@ -218,7 +206,7 @@ public: nv=checkArray(g0); size_t n=nu*nv; - controls=new Triple[n]; + controls=new(UseGC) Triple[n]; size_t k=0; for(size_t i=0; i < nu; ++i) { @@ -231,15 +219,13 @@ public: if(weightsize > 0) { size_t k=0; - weights=new double[n]; + weights=new(UseGC) double[n]; for(size_t i=0; i < nu; ++i) { vm::array *weighti=vm::read<vm::array*>(weight,i); if(checkArray(weighti) != nv) reportError(wrongsize); - for(size_t j=0; j < nv; ++j) { - weights[k]=vm::read<double>(weighti,j); - ++k; - } + for(size_t j=0; j < nv; ++j) + weights[k++]=vm::read<double>(weighti,j); } } else weights=NULL; @@ -252,8 +238,8 @@ public: udegree=nuknots-nu-1; vdegree=nvknots-nv-1; - uknots=run::copyArrayC(uknot,0); - vknots=run::copyArrayC(vknot,0); + uknots=run::copyArrayC(uknot,0,NoGC); + vknots=run::copyArrayC(vknot,0,NoGC); pen surfacepen=vm::read<camp::pen>(p,0); invisible=surfacepen.invisible(); @@ -262,14 +248,12 @@ public: ambient=rgba(vm::read<camp::pen>(p,1)); emissive=rgba(vm::read<camp::pen>(p,2)); specular=rgba(vm::read<camp::pen>(p,3)); -#ifdef HAVE_LIBGL - uKnots=new GLfloat[nuknots]; - vKnots=new GLfloat[nvknots]; - Controls=new GLfloat[(weights ? 4 : 3)*n]; +#ifdef HAVE_GL + Controls=NULL; int size=checkArray(&pens); if(size > 0) { - colors=new GLfloat[16]; + colors=new(UseGC) GLfloat[16]; if(size != 4) reportError(wrongsize); storecolor(colors,0,pens,0); storecolor(colors,8,pens,1); @@ -288,7 +272,7 @@ public: name(s->name) { size_t n=nu*nv; - controls=new double[n][3]; + controls=new(UseGC) Triple[n]; for(size_t i=0; i < n; ++i) { const double *c=s->controls[i]; @@ -299,15 +283,15 @@ public: } if(s->weights) { - weights=new double[n]; + weights=new(UseGC) double[n]; for(size_t i=0; i < n; ++i) weights[i]=s->weights[i]; } else weights=NULL; size_t nuknots=udegree+nu+1; size_t nvknots=vdegree+nv+1; - uknots=new double[nuknots]; - vknots=new double[nvknots]; + uknots=new(UseGC) double[nuknots]; + vknots=new(UseGC) double[nvknots]; for(size_t i=0; i < nuknots; ++i) uknots[i]=s->uknots[i]; @@ -315,13 +299,10 @@ public: for(size_t i=0; i < nvknots; ++i) vknots[i]=s->vknots[i]; -#ifdef HAVE_LIBGL - uKnots=new GLfloat[nuknots]; - vKnots=new GLfloat[nvknots]; - Controls=new GLfloat[(weights ? 4 : 3)*n]; - +#ifdef HAVE_GL + Controls=NULL; if(s->colors) { - colors=new GLfloat[16]; + colors=new(UseGC) GLfloat[16]; for(int i=0; i < 16; ++i) colors[i]=s->colors[i]; } else colors=NULL; @@ -332,26 +313,13 @@ public: void bounds(bbox3& b); - virtual ~drawNurbs() { - delete[] vknots; - delete[] uknots; - if(weights) - delete[] weights; - delete[] controls; -#ifdef HAVE_LIBGL - if(colors) - delete[] colors; - delete[] Controls; - delete[] vKnots; - delete[] uKnots; -#endif - } + virtual ~drawNurbs() {} bool write(prcfile *out, unsigned int *count, vm::array *index, vm::array *origin); void displacement(); - void ratio(pair &b, double (*m)(double, double), bool &first); + void ratio(pair &b, double (*m)(double, double), double, bool &first); void render(GLUnurbs *nurb, double size2, const triple& Min, const triple& Max, |