summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/bbox3.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/bbox3.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/bbox3.h')
-rw-r--r--Build/source/utils/asymptote/bbox3.h153
1 files changed, 153 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/bbox3.h b/Build/source/utils/asymptote/bbox3.h
new file mode 100644
index 00000000000..5659f24b6ee
--- /dev/null
+++ b/Build/source/utils/asymptote/bbox3.h
@@ -0,0 +1,153 @@
+/*****
+ * bbox3.h
+ * Andy Hammerlindl 2002/06/06
+ *
+ * Stores a rectangle that encloses a drawing object.
+ *****/
+
+#ifndef BBOX3_H
+#define BBOX3_H
+
+#include "triple.h"
+
+namespace camp {
+
+// The box that encloses a path
+struct bbox3 {
+ bool empty;
+ double left;
+ double bottom;
+ double lower;
+ double right;
+ double top;
+ double upper;
+
+ // Start bbox3 about the origin
+ bbox3()
+ : empty(true), left(0.0), bottom(0.0), lower(0.0),
+ right(0.0), top(0.0), upper(0.0)
+ {
+ }
+
+ bbox3(double left, double bottom, double lower,
+ double right, double top, double upper)
+ : empty(false), left(left), bottom(bottom), lower(lower),
+ right(right), top(top), upper(upper)
+ {
+ }
+
+ // Start a bbox3 with a point
+ bbox3(double x, double y, double z)
+ : empty(false), left(x), bottom(y), lower(z), right(x), top(y), upper(z)
+ {
+ }
+
+ // Start a bbox3 with a point
+ bbox3(const triple& v)
+ : empty(false), left(v.getx()), bottom(v.gety()), lower(v.getz()),
+ right(v.getx()), top(v.gety()), upper(v.getz())
+ {
+ }
+
+ // Add a point to a bbox3
+ void add(const triple& v)
+ {
+ double x = v.getx(), y = v.gety(), z = v.getz();
+
+ if (empty) {
+ left = right = x;
+ top = bottom = y;
+ lower = upper = z;
+ empty = false;
+ }
+ else {
+ if(x < left)
+ left = x;
+ else if(x > right)
+ right = x;
+ if(y < bottom)
+ bottom = y;
+ else if(y > top)
+ top = y;
+ if(z < lower)
+ lower = z;
+ else if(z > upper)
+ upper = z;
+ }
+ }
+
+ // Add a point to a nonempty bbox3
+ void addnonempty(double x, double y, double z)
+ {
+ if(x < left)
+ left = x;
+ else if(x > right)
+ right = x;
+ if(y < bottom)
+ bottom = y;
+ else if(y > top)
+ top = y;
+ if(z < lower)
+ lower = z;
+ else if(z > upper)
+ upper = z;
+ }
+
+ // Add a point to a nonempty bbox3
+ void addnonempty(const triple& v)
+ {
+ addnonempty(v.getx(),v.gety(),v.getz());
+ }
+
+ // Add a point to a nonempty bbox, updating bounding times
+ void addnonempty(const triple& v, bbox3& times, double t)
+ {
+ double x = v.getx(), y = v.gety(), z = v.getz();
+
+ if(x < left) {
+ left = x;
+ times.left = t;
+ }
+ else if(x > right) {
+ right = x;
+ times.right = t;
+ }
+ if(y < bottom) {
+ bottom = y;
+ times.bottom = t;
+ }
+ else if(y > top) {
+ top = y;
+ times.top = t;
+ }
+ if(z < lower) {
+ lower = z;
+ times.lower=t;
+ }
+ else if(z > upper) {
+ upper = z;
+ times.upper=t;
+ }
+ }
+
+ bbox3 operator+= (const triple& v)
+ {
+ add(v);
+ return *this;
+ }
+
+ triple Min() const {
+ return triple(left,bottom,lower);
+ }
+
+ triple Max() const {
+ return triple(right,top,upper);
+ }
+
+};
+
+} // namespace camp
+
+GC_DECLARE_PTRFREE(camp::bbox3);
+
+#endif