00001 #ifndef BOX_3_H // -*- C++ -*-
00002 #define BOX_3_H
00003
00004 #include <ostream>
00005 #include <utility>
00006 #include "poly.h"
00007 #include "Hexahedron_3.h"
00008
00009
00014 class Box_3
00015 {
00016 public:
00017 static const int dimension = 3;
00018 typedef float FT;
00019
00021 Box_3( FT xmin, FT xmax,
00022 FT ymin, FT ymax,
00023 FT zmin, FT zmax );
00024
00026 Box_3( const Polyhedron::Facet& );
00027
00029 Box_3( const Hexahedron_3& );
00030
00032 FT min(int d) const { return low[d]; }
00033 FT max(int d) const { return high[d]; }
00034
00035
00036 friend std::ostream& operator<< ( std::ostream& os, const Box_3& b );
00037
00042 Box_3() {};
00043
00044 private:
00045 FT low[dimension];
00046 FT high[dimension];
00047 };
00048
00049
00050 Box_3 make_bounding_box( const Polyhedron::Facet& );
00051 Box_3 make_bounding_box( const Hexahedron_3& );
00052
00053
00054
00057 class IndexBox : public Box_3
00058 {
00059 public:
00060 IndexBox( const Box_3& b ) : Box_3(b)
00061 {
00062 m_index = next_index++;
00063 }
00064
00065 int index() const { return m_index; }
00066
00067 private:
00068 int m_index;
00069 static int next_index;
00070 };
00071
00072
00073
00076 class DataIndexBox : public IndexBox
00077 {
00078 public:
00079 union { int dat; void* ptr; } data;
00080
00081 DataIndexBox( const Box_3& b, int d ) : IndexBox(b)
00082 {
00083 data.dat = d;
00084 }
00085
00086 DataIndexBox( const Box_3& b, void* p ) : IndexBox(b)
00087 {
00088 data.ptr = p;
00089 }
00090 };
00091
00092
00093
00094 #endif