MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
iso_surface.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 *
9 * Isosurface extraction for octrees. The algorithm is based on the paper:
10 *
11 * Unconstrained Isosurface Extraction on Arbitrary Octrees
12 * Michael Kazhdan, Allison Klein, Ketan Dalal, Hugues Hoppe
13 * Symposium on Geometry Processing, 2007
14 */
15
16#ifndef FSSR_ISO_SURFACE_HEADER
17#define FSSR_ISO_SURFACE_HEADER
18
19#include <vector>
20#include <map>
21#include <cstdint>
22
23#include "math/algo.h"
24#include "fssr/defines.h"
25#include "fssr/hermite.h"
26#include "fssr/iso_octree.h"
27#include "fssr/octree.h"
28#include "fssr/voxel.h"
29
31
38{
39public:
40 IsoSurface (IsoOctree* octree,
41 InterpolationType interpolation_type = INTERPOLATION_CUBIC);
42 mve::TriangleMesh::Ptr extract_mesh (void);
43
44private:
46 struct IsoVertex
47 {
48 math::Vec3f pos;
49 VoxelData data;
50 };
51
53 typedef std::pair<uint64_t, uint64_t> EdgeIndex;
54
56 struct EdgeInfo
57 {
59 int edge_id;
60 };
61
63 struct IsoEdge
64 {
65 EdgeIndex first;
66 EdgeIndex second;
67 EdgeInfo first_info;
68 EdgeInfo second_info;
69 };
70
72 typedef std::vector<IsoVertex> IsoVertexVector;
74 typedef std::map<EdgeIndex, std::size_t> EdgeVertexMap;
76 typedef std::vector<std::vector<std::size_t> > PolygonList;
78 typedef std::vector<IsoEdge> IsoEdgeList;
79
80private:
81 void sanity_checks (void);
82 void compute_mc_index (Octree::Iterator const& iter);
83 void compute_isovertices (Octree::Iterator const& iter,
84 EdgeVertexMap* edgemap, IsoVertexVector* isovertices);
85 bool is_isovertex_on_edge (int mc_index, int edge_id);
86 void get_finest_cube_edge (Octree::Iterator const& iter,
87 int edge_id, EdgeIndex* edge_index, EdgeInfo* edge_info);
88 void get_finest_isoedges (Octree::Iterator const& iter,
89 int face_id, IsoEdgeList* isoedges, bool descend_only);
90 void get_isovertex (EdgeIndex const& edge_index,
91 int edge_id, IsoVertex* iso_vertex);
92 void compute_isopolygons(Octree::Iterator const& iter,
93 EdgeVertexMap const& edgemap, PolygonList* polygons);
94 void compute_triangulation(IsoVertexVector const& isovertices,
95 PolygonList const& polygons, mve::TriangleMesh::Ptr mesh);
96 VoxelData const* get_voxel_data (VoxelIndex const& index);
97 std::size_t lookup_edge_vertex (EdgeVertexMap const& edgemap,
98 EdgeIndex const& edge);
99 void find_twin_vertex(EdgeInfo const& edge_info,
100 EdgeIndex* twin, EdgeInfo* twin_info);
101
102private:
103 Octree* octree;
104 IsoOctree::VoxelVector const* voxels;
105 InterpolationType interpolation_type;
106};
107
108/* --------------------------------------------------------------------- */
109
110inline
111IsoSurface::IsoSurface (IsoOctree* octree, InterpolationType interpolation_type)
112 : octree(octree)
113 , voxels(&octree->get_voxels())
114 , interpolation_type(interpolation_type)
115{
116}
117
118inline VoxelData const*
119IsoSurface::get_voxel_data (VoxelIndex const& index)
120{
121 return math::algo::binary_search(*this->voxels, index);
122}
123
125
126#endif // FSSR_ISO_SURFACE_HEADER
This class computes the implicit function by querying function values at the octree primal vertices o...
Definition iso_octree.h:26
std::vector< std::pair< VoxelIndex, VoxelData > > VoxelVector
Definition iso_octree.h:28
The surfacing algorithm requires the octree hierarchy and the vector of voxels.
Definition iso_surface.h:38
A regular octree data structure (each node has zero or eight child nodes).
Definition octree.h:30
Vector class for arbitrary dimensions and types.
Definition vector.h:87
std::shared_ptr< TriangleMesh > Ptr
Definition mesh.h:92
#define FSSR_NAMESPACE_END
Definition defines.h:14
#define FSSR_NAMESPACE_BEGIN
Definition defines.h:13
std::size_t second
Definition mesh_info.cc:47
std::size_t first
Definition mesh_info.cc:46
std::size_t face_id
Definition mesh_info.cc:45
InterpolationType
Definition hermite.h:18
@ INTERPOLATION_CUBIC
Definition hermite.h:22
Value const * binary_search(std::vector< std::pair< Key, Value > > const &vec, Key const &key)
Algorithm that finds the value corresponding to a key in sorted vector of key-value pairs.
Definition algo.h:83
Octree iterator that keeps track of level and path through the octree.
Definition octree.h:58
Stores per voxel data.
Definition voxel.h:61
The voxel index is a unique 64 bit ID for each voxel in the octree.
Definition voxel.h:38