summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/prcfile.h
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-16 00:19:13 +0000
committerKarl Berry <karl@freefriends.org>2009-05-16 00:19:13 +0000
commitbab45528d65eaafe68a705dbb2a57075c7b7cbd8 (patch)
tree10b4ae2b5195c8dede153ab89359ec00f55f325f /Build/source/utils/asymptote/prcfile.h
parent8643d90372e9c31e0f461c15c596b60a545bd7d3 (diff)
asymptote 1.72 sources (not integrated into build yet)
git-svn-id: svn://tug.org/texlive/trunk@13110 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/prcfile.h')
-rw-r--r--Build/source/utils/asymptote/prcfile.h83
1 files changed, 83 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/prcfile.h b/Build/source/utils/asymptote/prcfile.h
new file mode 100644
index 00000000000..9c02470f2fa
--- /dev/null
+++ b/Build/source/utils/asymptote/prcfile.h
@@ -0,0 +1,83 @@
+#ifndef PRCFILE_H
+#define PRCFILE_H
+
+#include "prc/oPRCFile.h"
+
+namespace camp {
+
+const double scale3D=1.0/settings::cm;
+
+inline RGBAColour rgba(pen p) {
+ p.torgb();
+ return RGBAColour(p.red(),p.green(),p.blue(),p.opacity());
+}
+
+class prcfile : public oPRCFile {
+ std::list<PRCentity *> entities;
+public:
+ prcfile(string name) : oPRCFile(name.c_str()) {}
+ ~prcfile() {
+
+ for(std::list<PRCentity *>::iterator p=entities.begin();
+ p != entities.end(); ++p) {
+ assert(*p);
+ delete *p;
+ }
+ }
+
+ void add(PRCentity* e) {
+ entities.push_back(e);
+ oPRCFile::add(e);
+ }
+};
+
+inline void writeBezierKnots(PRCbitStream &out, uint32_t d, uint32_t n)
+{
+ out << (double) 1;
+ for(uint32_t i=1; i < d+n; ++i)
+ out << (double) ((i+2)/d); // integer division is intentional
+ out << (double) ((d+n+1)/d);
+}
+
+class PRCBezierCurve : public PRCcurve
+{
+ uint32_t d;
+ uint32_t n;
+public:
+ PRCBezierCurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3],
+ const RGBAColour &c) :
+ PRCcurve(p,d,n,cP,NULL,c,scale3D,false,NULL), d(d), n(n) {}
+ PRCBezierCurve(oPRCFile *p, uint32_t d, uint32_t n, double cP[][3],
+ const PRCMaterial &m) :
+ PRCcurve(p,d,n,cP,NULL,m,scale3D,false,NULL), d(d), n(n) {}
+private:
+ void writeKnots(PRCbitStream &out) {
+ writeBezierKnots(out,d,n);
+ }
+};
+
+class PRCBezierSurface : public PRCsurface
+{
+ uint32_t dU,dV;
+ uint32_t nU,nV;
+public:
+ PRCBezierSurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU,
+ uint32_t nV, double cP[][3], const RGBAColour &c,
+ double g=0.0) :
+ PRCsurface(p,dU,dV,nU,nV,cP,NULL,NULL,c,scale3D,false,NULL,g), dU(dU),
+ dV(dV), nU(nU), nV(nV) {}
+ PRCBezierSurface(oPRCFile *p, uint32_t dU, uint32_t dV, uint32_t nU,
+ uint32_t nV, double cP[][3], const PRCMaterial &m,
+ double g=0.0) :
+ PRCsurface(p,dU,dV,nU,nV,cP,NULL,NULL,m,scale3D,false,NULL,g), dU(dU),
+ dV(dV), nU(nU), nV(nV) {}
+private:
+ void writeKnots(PRCbitStream &out) {
+ writeBezierKnots(out,dU,nU);
+ writeBezierKnots(out,dV,nV);
+ }
+};
+
+} //namespace camp
+
+#endif