OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
octree_isocont.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_IMPL_OCTREE_ISOCONT_HH
20 #define OST_GFX_IMPL_OCTREE_ISOCONT_HH
21 
22 /*
23  Author: Marco Biasini
24  */
25 #include <boost/unordered_map.hpp>
26 
27 #include <ost/img/image_handle.hh>
28 #include <ost/img/image_state.hh>
29 #include <ost/gfx/module_config.hh>
30 #include <ost/gfx/vertex_array.hh>
32 
33 namespace ost { namespace gfx { namespace impl {
34 
35 struct EdgeDesc {
36  EdgeDesc(uint8_t d, const img::Point& o,
37  uint8_t ac1, uint8_t ac2, bool l):
38  dir(d), off(o), c1(ac1), c2(ac2), lv(l)
39  { }
41  {
42  img::Point k=p+off;
43  return 4*ext.Point2Offset(k)+dir;
44  }
49  bool lv;
50 };
55 private:
56  static uint16_t EDGE_FLAGS[];
57  static img::Point POINT_OFFSETS[];
58  static int8_t TRIANGLES[256][16];
59  static EdgeDesc EDGE_DESC[12];
60 public:
61  typedef boost::unordered_map<uint32_t, VertexID> EdgeMap;
62  OctreeIsocont(IndexedVertexArray& va, float level, bool triangles,
63  const Color& color):
64  va_(va), level_(level), triangles_(triangles), color_(color)
65  { }
66  bool VisitNode(const impl::OctreeNode& node, uint8_t level,
67  const img::Extent& ext)
68  {
69  return (node.GetMin()<level_ && level_<=node.GetMax());
70  }
71  void VisitLeaf(img::RealSpatialImageState* map,
72  const img::Point& point);
73 
74  VertexID GetOrGenVert(img::RealSpatialImageState* map, const img::Point& p,
75  EdgeDesc* desc);
76 private:
77  IndexedVertexArray& va_;
78  float level_;
79  EdgeMap edge_map_;
80  bool triangles_;
81  Color color_;
82 };
83 
84 
85 }}}
86 
87 #endif
88 
EdgeDesc(uint8_t d, const img::Point &o, uint8_t ac1, uint8_t ac2, bool l)
OctreeIsocont(IndexedVertexArray &va, float level, bool triangles, const Color &color)
isocontouring of maps using an octree-optimization
uint32_t GetKey(const img::Point &p, img::Extent &ext)
unsigned int uint32_t
Definition: stdint_msc.hh:80
unsigned char uint8_t
Definition: stdint_msc.hh:78
#define DLLEXPORT_OST_GFX
Defines lower and upper valid indices.
Definition: extent.hh:60
signed char int8_t
Definition: stdint_msc.hh:75
unsigned int Point2Offset(const Point &p)
Generates a continues, uniqe index per point contained within extent.
boost::unordered_map< uint32_t, VertexID > EdgeMap
unsigned int VertexID
Definition: vertex_array.hh:46
unsigned short uint16_t
Definition: stdint_msc.hh:79
ImageStateImpl< Real, SpatialDomain > RealSpatialImageState
bool VisitNode(const impl::OctreeNode &node, uint8_t level, const img::Extent &ext)
class encapsulating 1D to 3D point
Definition: point.hh:43