Tree @upstream/2.23 (Download .tar.gz)
- base
- doc
- examples
- GUI
- patches
- prc
- tests
- absyn.cc
- absyn.h
- access.cc
- access.h
- algebra3.cc
- algebra3.h
- allsymbols.h
- angle.h
- application.cc
- application.h
- arcball.cc
- arcball.h
- array.cc
- array.h
- arrayop.h
- aspy.py
- asy-keywords.el
- asy-list.pl
- asy.ico
- asy.rc
- asymptote.nsi
- asymptote.spec
- autogen.sh
- ax_pthread.m4
- bbox.h
- bbox3.h
- BUGS
- builtin.cc
- builtin.h
- builtin.symbols.h
- callable.cc
- callable.h
- camp.l
- camp.tab.cc
- camp.tab.h
- camp.y
- camperror.cc
- camperror.h
- castop.h
- ChangeLog
- coder.cc
- coder.h
- coenv.cc
- coenv.h
- common.h
- config.guess
- config.h.in
- config.sub
- configure
- configure.ac
- constructor.cc
- dec.cc
- dec.h
- Delaunay.cc
- Delaunay.h
- drawclipbegin.h
- drawclipend.h
- drawelement.h
- drawfill.cc
- drawfill.h
- drawgrestore.h
- drawgroup.h
- drawgsave.h
- drawimage.h
- drawlabel.cc
- drawlabel.h
- drawlayer.h
- drawpath.cc
- drawpath.h
- drawpath3.cc
- drawpath3.h
- drawsurface.cc
- drawsurface.h
- drawverbatim.h
- entry.cc
- entry.h
- env.cc
- env.h
- envcompleter.cc
- envcompleter.h
- EnvVarUpdate.nsh
- errormsg.cc
- errormsg.h
- errors
- errortest.asy
- exp.cc
- exp.h
- fftw++.cc
- fftw++.h
- fftw++asy.cc
- fileio.cc
- fileio.h
- findsym.pl
- flatguide.cc
- flatguide.h
- fpu.h
- frame.h
- fundec.cc
- fundec.h
- genv.cc
- genv.h
- getopt.c
- getopt.h
- getopt1.c
- glrender.cc
- glrender.h
- gsl.cc
- gsl.symbols.h
- guide.cc
- guide.h
- guideflags.h
- impdatum.cc
- inst.h
- INSTALL
- install-sh
- interact.cc
- interact.h
- item.h
- keywords.cc
- keywords.pl
- knot.cc
- knot.h
- lex.yy.cc
- lexical.h
- LICENSE
- LICENSE.LESSER
- lnkX64IconFix.nsh
- locate.cc
- locate.h
- main.cc
- Makefile.in
- mathop.h
- memory.h
- mod.h
- modifier.h
- name.cc
- name.h
- newexp.cc
- newexp.h
- opcodes.h
- opsymbols.h
- opsymbols.pl
- pair.h
- parser.cc
- parser.h
- path.cc
- path.h
- path3.cc
- path3.h
- pen.cc
- pen.h
- picture.cc
- picture.h
- pipestream.h
- policy.h
- prcfile.h
- predicates.cc
- predicates.h
- primitives.h
- process.cc
- process.h
- profile.py
- profiler.h
- program.cc
- program.h
- psfile.cc
- psfile.h
- quaternion.cc
- quaternion.h
- README
- record.cc
- record.h
- refaccess.cc
- refaccess.h
- ReleaseNotes
- rounding.h
- runarray.cc
- runarray.h
- runarray.in
- runarray.symbols.h
- runbacktrace.cc
- runbacktrace.h
- runbacktrace.in
- runbacktrace.symbols.h
- runfile.cc
- runfile.h
- runfile.in
- runfile.symbols.h
- runhistory.cc
- runhistory.h
- runhistory.in
- runhistory.symbols.h
- runlabel.cc
- runlabel.h
- runlabel.in
- runlabel.symbols.h
- runmath.cc
- runmath.h
- runmath.in
- runmath.symbols.h
- runpair.cc
- runpair.h
- runpair.in
- runpair.symbols.h
- runpath.cc
- runpath.h
- runpath.in
- runpath.symbols.h
- runpath3d.cc
- runpath3d.h
- runpath3d.in
- runpath3d.symbols.h
- runpicture.cc
- runpicture.h
- runpicture.in
- runpicture.symbols.h
- runstring.cc
- runstring.h
- runstring.in
- runstring.symbols.h
- runsystem.cc
- runsystem.h
- runsystem.in
- runsystem.symbols.h
- runtime.cc
- runtime.h
- runtime.in
- runtime.pl
- runtime.symbols.h
- runtimebase.in
- runtriple.cc
- runtriple.h
- runtriple.in
- runtriple.symbols.h
- seconds.h
- settings.cc
- settings.h
- simpson.cc
- stack.cc
- stack.h
- stm.cc
- stm.h
- symbol.cc
- symbol.h
- table.h
- texfile.cc
- texfile.h
- TODO
- tr.cc
- tr.h
- transform.h
- triple.h
- types.cc
- types.h
- types.symbols.h
- util.cc
- util.h
- varinit.cc
- varinit.h
- virtualfieldaccess.cc
- virtualfieldaccess.h
- vm.h
- wce
- xstream.h
bbox.h @upstream/2.23 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | /***** * bbox.h * Andy Hammerlindl 2002/06/06 * * Stores a rectangle that encloses a drawing object. *****/ #ifndef BBOX_H #define BBOX_H #include "pair.h" namespace camp { template<class T> inline T min(T a, T b) { return (a < b) ? a : b; } template<class T> inline T max(T a, T b) { return (a > b) ? a : b; } // The box that encloses a path struct bbox { bool empty; double left; double bottom; double right; double top; // Start bbox about the origin bbox() : empty(true), left(0.0), bottom(0.0), right(0.0), top(0.0) { } bbox(double left, double bottom, double right, double top) : empty(false), left(left), bottom(bottom), right(right), top(top) { } // Start a bbox with a point bbox(const pair& z) : empty(false), left(z.getx()), bottom(z.gety()), right(z.getx()), top(z.gety()) { } bool nonempty() const { return !empty; } // Add a point to a bbox bbox add(const pair& z) { double x = z.getx(), y = z.gety(); if (empty) { left = right = x; top = bottom = y; 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; } return *this; } // Add a point to a nonempty bbox void addnonempty(const pair& z) { double x = z.getx(), y = z.gety(); if (x < left) left = x; else if (x > right) right = x; if (y < bottom) bottom = y; else if (y > top) top = y; } // Add a point to a nonempty bbox, updating bounding times void addnonempty(const pair& z, bbox& times, double t) { double x = z.getx(), y = z.gety(); 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; } } bbox operator+= (const pair& z) { add(z); return *this; } bbox operator*= (double x) { left *= x; right *= x; top *= x; bottom *=x; return *this; } // Add two bounding boxes friend bbox operator+ (const bbox& b1, const bbox& b2) { if (b1.empty) return b2; else if (b2.empty) return b1; else return bbox(min(b1.left, b2.left), max(b1.right, b2.right), min(b1.bottom, b2.bottom), max(b1.top, b2.top)); } // Add one bounding box to another void add(const bbox& b) { if (this->empty) *this = b; else if (!b.empty) { left = min(left, b.left); right = max(right, b.right); bottom = min(bottom, b.bottom); top = max(top, b.top); } } bbox operator+= (const bbox& b) { add(b); return *this; } void clip(const bbox& b) { if(this->empty) return; left = max(left, b.left); right = min(right, b.right); bottom = max(bottom, b.bottom); top = min(top, b.top); if(left > right || bottom > top) *this=bbox(); } void shift(const pair& p) { left += p.getx(); right += p.getx(); bottom += p.gety(); top += p.gety(); } pair Min() const { return pair(left,bottom); } pair Max() const { return pair(right,top); } double diameter() { return (Max()-Min()).length(); } bbox LowRes() const { return bbox(floor(left),floor(bottom),ceil(right),ceil(top)); } friend ostream& operator<< (ostream& out, const bbox& b) { out << b.left << " " << b.bottom << " " << b.right << " " << b.top; return out; } }; // Add results of both bounding boxes, say for a path and a pen. inline bbox pad(bbox b1, bbox b2) { if (b1.empty) return b2; else if (b2.empty) return b1; else { bbox b; b.empty = false; b.left = b1.left + b2.left; b.right = b1.right + b2.right; b.top = b1.top + b2.top; b.bottom = b1.bottom + b2.bottom; return b; } } } // namespace camp GC_DECLARE_PTRFREE(camp::bbox); #endif |