summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/drawpath3.h
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/drawpath3.h')
-rw-r--r--Build/source/utils/asymptote/drawpath3.h113
1 files changed, 108 insertions, 5 deletions
diff --git a/Build/source/utils/asymptote/drawpath3.h b/Build/source/utils/asymptote/drawpath3.h
index d956e49e243..1285e7656da 100644
--- a/Build/source/utils/asymptote/drawpath3.h
+++ b/Build/source/utils/asymptote/drawpath3.h
@@ -22,7 +22,7 @@ protected:
Triple *controls;
string name;
public:
- drawPath3(path3 g, const pen&p, const string& name) :
+ drawPath3(path3 g, const pen& p, const string& name) :
g(g), straight(g.piecewisestraight()), color(rgba(p)),
invisible(p.invisible()), Min(g.min()), Max(g.max()), controls(NULL),
name(name) {}
@@ -32,9 +32,7 @@ public:
invisible(s->invisible), Min(g.min()), Max(g.max()), controls(NULL),
name(s->name) {}
- virtual ~drawPath3() {
- if(controls) delete controls;
- }
+ virtual ~drawPath3() {}
bool is3D() {return true;}
@@ -43,7 +41,7 @@ public:
B.add(Max);
}
- void ratio(pair &b, double (*m)(double, double), bool &first) {
+ void ratio(pair &b, double (*m)(double, double), double, bool &first) {
pair z=g.ratio(m);
if(first) {
b=z;
@@ -60,6 +58,111 @@ public:
drawElement *transformed(const vm::array& t);
};
+class drawNurbsPath3 : public drawElement {
+protected:
+ size_t degree;
+ size_t n;
+ Triple *controls;
+ double *weights;
+ double *knots;
+ RGBAColour color;
+ bool invisible;
+ string name;
+ triple Min,Max;
+
+#ifdef HAVE_GL
+ GLfloat *Controls;
+ GLfloat *Knots;
+#endif
+
+public:
+ drawNurbsPath3(const vm::array& g, const vm::array* knot,
+ const vm::array* weight, const pen& p, const string& name) :
+ color(rgba(p)), invisible(p.invisible()), name(name) {
+ size_t weightsize=checkArray(weight);
+
+ string wrongsize="Inconsistent NURBS data";
+ n=checkArray(&g);
+
+ if(n == 0 || (weightsize != 0 && weightsize != n))
+ reportError(wrongsize);
+
+ controls=new(UseGC) Triple[n];
+
+ size_t k=0;
+ for(size_t i=0; i < n; ++i)
+ store(controls[k++],vm::read<triple>(g,i));
+
+ if(weightsize > 0) {
+ size_t k=0;
+ weights=new(UseGC) double[n];
+ for(size_t i=0; i < n; ++i)
+ weights[k++]=vm::read<double>(weight,i);
+ } else weights=NULL;
+
+ size_t nknots=checkArray(knot);
+
+ if(nknots <= n+1 || nknots > 2*n)
+ reportError(wrongsize);
+
+ degree=nknots-n-1;
+
+ knots=run::copyArrayC(knot,0,NoGC);
+
+#ifdef HAVE_GL
+ Controls=NULL;
+#endif
+ }
+
+ drawNurbsPath3(const vm::array& t, const drawNurbsPath3 *s) :
+ degree(s->degree), n(s->n), color(s->color), invisible(s->invisible),
+ name(s->name) {
+ controls=new(UseGC) Triple[n];
+
+ for(size_t i=0; i < n; ++i) {
+ const double *c=s->controls[i];
+ triple v=run::operator *(t,triple(c[0],c[1],c[2]));
+ controls[i][0]=v.getx();
+ controls[i][1]=v.gety();
+ controls[i][2]=v.getz();
+ }
+
+ if(s->weights) {
+ weights=new(UseGC) double[n];
+ for(size_t i=0; i < n; ++i)
+ weights[i]=s->weights[i];
+ } else weights=NULL;
+
+ size_t nknots=degree+n+1;
+ knots=new(UseGC) double[nknots];
+
+ for(size_t i=0; i < nknots; ++i)
+ knots[i]=s->knots[i];
+
+#ifdef HAVE_GL
+ Controls=NULL;
+#endif
+ }
+
+ bool is3D() {return true;}
+
+ void bounds(bbox3& b);
+
+ virtual ~drawNurbsPath3() {}
+
+ bool write(prcfile *out, unsigned int *count, vm::array *index,
+ vm::array *origin);
+
+ void displacement();
+ void ratio(pair &b, double (*m)(double, double), double fuzz, bool &first);
+
+ void render(GLUnurbs *nurb, double size2,
+ const triple& Min, const triple& Max,
+ double perspective, bool transparent);
+
+ drawElement *transformed(const vm::array& t);
+};
+
}
#endif