Download this file

101 lines (80 with data), 2.7 kB

  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
#ifndef EXAMPLE_H_INCLUDED
#define EXAMPLE_H_INCLUDED
/// \file example.h
/// \author Dominik Wodniok
/// \date 2009
// std includes
#include <string>
// stl includes
#include <vector>
// dual mc builder vertex and quad definitions
#include "dualmc.h"
/// Example application for demonstrating the dual marching cubes builder.
class DualMCExample {
public:
/// run example
void run(int const argc, char** argv);
private:
/// Structure for the program options.
struct AppOptions {
std::string inputFile;
int32_t dimX;
int32_t dimY;
int32_t dimZ;
float isoValue;
bool generateCaffeine;
bool generateQuadSoup;
bool generateManifold;
std::string outputFile;
};
/// Parse program arguments.
bool parseArgs(int const argc, char** argv, AppOptions & options);
/// Generate an example volume for the dual mc builder.
void generateCaffeine();
/// Load volume from raw file.
bool loadRawFile(std::string const & fileName, int32_t dimX, int32_t dimY, int32_t dimZ);
/// Compute the iso surface for the specified iso value. Optionally generate
/// a quad soup.
void computeSurface(float const iso, bool const generateSoup, bool const generateManifold);
/// Write a Wavefront OBJ model for the extracted ISO surface.
void writeOBJ(std::string const & fileName) const;
/// Print program arguments.
void printArgs() const;
/// Print program help hint.
void printHelpHint() const;
private:
/// struct for volume data information
struct Volume {
// volume grid extents
int32_t dimX;
int32_t dimY;
int32_t dimZ;
// bit depth, should be 8 or 16
int32_t bitDepth;
/// volume data
std::vector<uint8_t> data;
};
/// example volume
Volume volume;
/// Class for a volumetric sphere with gaussian fall-off.
class RadialGaussian {
public:
/// Initialize with center coordinates and half density radius.
RadialGaussian(float cX, float cY, float cZ, float variance);
// evaluate the sphere function
float eval(float x, float y, float z) const;
private:
// Coordinates of the sphere center.
float cX;
float cY;
float cZ;
// precomputed factors
float normalization;
float falloff;
};
/// array of vertices for the extracted surface
std::vector<dualmc::Vertex> vertices;
/// array of quad indices for the extracted surface
std::vector<dualmc::Quad> quads;
};
#endif // EXAMPLE_H_INCLUDED