00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_IMPL_OCTREE_ISOCONT_HH
00020 #define OST_GFX_IMPL_OCTREE_ISOCONT_HH
00021
00022
00023
00024
00025 #include <boost/unordered_map.hpp>
00026
00027 #include <ost/img/image_handle.hh>
00028 #include <ost/img/image_state.hh>
00029 #include <ost/gfx/module_config.hh>
00030 #include <ost/gfx/vertex_array.hh>
00031 #include <ost/gfx/impl/map_octree.hh>
00032
00033 namespace ost { namespace gfx { namespace impl {
00034
00035 struct EdgeDesc {
00036 EdgeDesc(uint8_t d, const img::Point& o,
00037 uint8_t ac1, uint8_t ac2, bool l):
00038 dir(d), off(o), c1(ac1), c2(ac2), lv(l)
00039 { }
00040 uint32_t GetKey(const img::Point& p, img::Extent& ext)
00041 {
00042 img::Point k=p+off;
00043 return 4*ext.Point2Offset(k)+dir;
00044 }
00045 uint8_t dir;
00046 img::Point off;
00047 uint8_t c1;
00048 uint8_t c2;
00049 bool lv;
00050 };
00054 struct DLLEXPORT_OST_GFX OctreeIsocont {
00055 private:
00056 static uint16_t EDGE_FLAGS[];
00057 static img::Point POINT_OFFSETS[];
00058 static int8_t TRIANGLES[256][16];
00059 static EdgeDesc EDGE_DESC[12];
00060 public:
00061 typedef boost::unordered_map<uint32_t, VertexID> EdgeMap;
00062 OctreeIsocont(IndexedVertexArray& va, float level, bool triangles,
00063 const Color& color):
00064 va_(va), level_(level), triangles_(triangles), color_(color)
00065 { }
00066 bool VisitNode(const impl::OctreeNode& node, uint8_t level,
00067 const img::Extent& ext)
00068 {
00069 return (node.GetMin()<level_ && level_<=node.GetMax());
00070 }
00071 void VisitLeaf(img::RealSpatialImageState* map,
00072 const img::Point& point);
00073
00074 VertexID GetOrGenVert(img::RealSpatialImageState* map, const img::Point& p,
00075 EdgeDesc* desc);
00076 private:
00077 IndexedVertexArray& va_;
00078 float level_;
00079 EdgeMap edge_map_;
00080 bool triangles_;
00081 Color color_;
00082 };
00083
00084
00085 }}}
00086
00087 #endif
00088