MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
sample_io.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
10#ifndef FSSR_SAMPLE_IO_HEADER
11#define FSSR_SAMPLE_IO_HEADER
12
13#include <fstream>
14#include <string>
15
16#include "mve/mesh_io_ply.h"
17#include "fssr/defines.h"
18#include "fssr/sample.h"
19
21
28{
29public:
30 struct Options
31 {
32 Options (void);
33
35 float min_scale;
36 float max_scale;
37 };
38
39public:
41 SampleIO (Options const& opts);
42
44 void read_file (std::string const& filename, SampleList* samples);
45
47 void open_file (std::string const& filename);
49 bool next_sample (Sample* sample);
50
51private:
52 struct StreamState
53 {
54 std::string filename;
55 std::ifstream stream;
56 std::vector<mve::geom::PLYVertexProperty> props;
58 unsigned int num_vertices;
59 unsigned int current_vertex;
60 };
61
62 struct SamplesState
63 {
64 unsigned int num_skipped_zero_normal;
65 unsigned int num_skipped_invalid_confidence;
66 unsigned int num_skipped_invalid_scale;
67 unsigned int num_skipped_large_scale;
68 unsigned int num_unnormalized_normals;
69 };
70
71private:
72 bool process_sample (Sample* sample, SamplesState* state);
73 void reset_samples_state (SamplesState* state);
74 void print_samples_state (SamplesState* state);
75
76 void ply_read (float* value);
77 void ply_read (uint8_t* value);
78 void ply_read_convert (float* value);
79 bool next_sample_intern (Sample* sample);
80 void reset_stream_state (void);
81
82private:
83 Options opts;
84 StreamState stream;
85 SamplesState samples;
86};
87
88/* ---------------------------------------------------------------- */
89
90inline
91SampleIO::Options::Options (void)
92 : scale_factor(1.0f)
93 , min_scale(-1.0f)
94 , max_scale(-1.0f)
95{
96}
97
98inline
100 : opts(opts)
101{
102}
103
105
106#endif /* FSSR_SAMPLE_IO_HEADER */
Reads samples from a PLY file.
Definition sample_io.h:28
SampleIO(Options const &opts)
Default constructor setting options.
Definition sample_io.h:99
#define FSSR_NAMESPACE_END
Definition defines.h:14
#define FSSR_NAMESPACE_BEGIN
Definition defines.h:13
std::vector< Sample > SampleList
Representation of a list of samples.
Definition sample.h:31
PLYFormat
PLY data encoding formats.
Representation of a point sample.
Definition sample.h:22