BRL-CAD
spsr.h
Go to the documentation of this file.
1/* S P S R . H
2 *
3 * Copyright (c) 2015 mkazhdan
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
24 * All rights reserved.
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions are met:
28 *
29 * Redistributions of source code must retain the above copyright notice, this
30 * list of conditions and the following disclaimer. Redistributions in binary
31 * form must reproduce the above copyright notice, this list of conditions and
32 * the following disclaimer in the documentation and/or other materials
33 * provided with the distribution.
34 *
35 * Neither the name of the Johns Hopkins University nor the names of its
36 * contributors may be used to endorse or promote products derived from this
37 * software without specific prior written permission.
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
40 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
43 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
44 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
45 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
46 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 * POSSIBILITY OF SUCH DAMAGE.
50 */
51
52/*----------------------------------------------------------------------*/
53/* @file spsr.h */
54/** @addtogroup bg_surf_recon_spsr */
55/** @{ */
56
57/**
58 * @brief Screened Poisson Surface Reconstruction from oriented point sets
59 *
60 * This functionality is a refactoring of work published by Dr. Michael
61 * Kazhdan et. al. at https://github.com/mkazhdan/PoissonRecon implementing a
62 * technique for fitting surfaces to oriented point sets by expressing the
63 * surface reconstruction as the solution to a Poisson equation.
64 */
65
66#ifndef BG_SPSR_H
67#define BG_SPSR_H
68
69#include "common.h"
70#include "vmath.h"
71#include "bg/defines.h"
72
73__BEGIN_DECLS
74
75/**
76 * Options passed when running a Screened Poisson Surface Reconstruction
77 * process to control how it performs the fitting
78 */
80 int degree; /**< finite element degree */
81 int btype; /**< finite element boundary type */
82 int depth; /**< maximum reconstruction depth */
83 int kerneldepth; /**< kernelDepth */
84 int iterations; /**< iterations */
85 int full_depth; /**< full depth */
86 int base_depth; /**< coarse MG solver depth */
87 int baseVcycles; /**< coarse MG solver v-cycles */
88 int max_memory_GB; /**< maximum memory (in GB) */
89 size_t threads; /**< number of threads to use (default is max available) */
90 fastf_t samples_per_node; /**< minimum number of samples per node */
91 fastf_t scale; /**< scale factor */
92 fastf_t width; /**< voxel width */
93 fastf_t confidence; /**< normal confidence exponent */
94 fastf_t confidence_bias; /**< normal confidence bias exponent */
95 fastf_t cgsolver_accuracy; /**< cg solver accuracy */
96 fastf_t point_weight; /**< interpolation weight */
97 int nonManifold; /**< NonManifold */
98 int linearFit; /**< LinearFit */
99 int exact; /**< exact interpolation */
100};
101
102
103/**
104 * Default Screened Poisson Surface Reconstruction options based on
105 * upstream code.
106 */
107#define BG_3D_SPSR_BOUNDARY_FREE 1
108#define BG_3D_SPSR_BOUNDARY_NEUMANN 2
109#define BG_3D_SPSR_BOUNDARY_DIRICHLET 3
110
111#define BG_3D_SPSR_DEFAULT_DEGREE 1 /* DEFAULT_FEM_DEGREE */
112#define BG_3D_SPSR_DEFAULT_DEPTH 11
113#define BG_3D_SPSR_DEFAULT_KERNELDEPTH 0
114#define BG_3D_SPSR_DEFAULT_ITERATIONS 0
115#define BG_3D_SPSR_DEFAULT_FULL_DEPTH 0
116#define BG_3D_SPSR_DEFAULT_BASE_DEPTH 0
117#define BG_3D_SPSR_DEFAULT_BASEVCYCLES 0
118#define BG_3D_SPSR_DEFAULT_MAX_MEM 0
119#define BG_3D_SPSR_DEFAULT_THREADS 0
120#define BG_3D_SPSR_DEFAULT_SAMPLES_PER_NODE 1.1
121#define BG_3D_SPSR_DEFAULT_SCALE 1.0
122#define BG_3D_SPSR_DEFAULT_WIDTH 0.0
123#define BG_3D_SPSR_DEFAULT_CONFIDENCE 0.0
124#define BG_3D_SPSR_DEFAULT_CONFIDENCE_BIAS 0.0
125#define BG_3D_SPSR_DEFAULT_CGSOLVER_ACCURACY 1.0e-3
126#define BG_3D_SPSR_DEFAULT_POINT_WEIGHT 8.0 /* DefaultPointWeightMultiplier * Degree */
127#define BG_3D_SPSR_DEFAULT_NONMANIFOLD 0
128#define BG_3D_SPSR_DEFAULT_LINEARFIT 0
129#define BG_3D_SPSR_DEFAULT_EXACT 1
130
131#define BG_3D_SPSR_OPTS_DEFAULT { \
132 BG_3D_SPSR_DEFAULT_DEGREE , \
133 BG_3D_SPSR_BOUNDARY_NEUMANN , \
134 BG_3D_SPSR_DEFAULT_DEPTH , \
135 BG_3D_SPSR_DEFAULT_KERNELDEPTH , \
136 BG_3D_SPSR_DEFAULT_ITERATIONS , \
137 BG_3D_SPSR_DEFAULT_FULL_DEPTH , \
138 BG_3D_SPSR_DEFAULT_BASE_DEPTH , \
139 BG_3D_SPSR_DEFAULT_BASEVCYCLES , \
140 BG_3D_SPSR_DEFAULT_MAX_MEM , \
141 BG_3D_SPSR_DEFAULT_THREADS , \
142 BG_3D_SPSR_DEFAULT_SAMPLES_PER_NODE , \
143 BG_3D_SPSR_DEFAULT_SCALE , \
144 BG_3D_SPSR_DEFAULT_WIDTH , \
145 BG_3D_SPSR_DEFAULT_CONFIDENCE , \
146 BG_3D_SPSR_DEFAULT_CONFIDENCE_BIAS , \
147 BG_3D_SPSR_DEFAULT_CGSOLVER_ACCURACY, \
148 BG_3D_SPSR_DEFAULT_POINT_WEIGHT , \
149 BG_3D_SPSR_DEFAULT_NONMANIFOLD , \
150 BG_3D_SPSR_DEFAULT_LINEARFIT , \
151 BG_3D_SPSR_DEFAULT_EXACT }
152
153/**
154 *@brief
155 * Applies Screened Poisson Surface Reconstruction to build a
156 * triangle mesh defining a surface, based on a set of points
157 * with associated normals
158 *
159 * @param[out] faces set of faces in the output surface, stored as integer indices to the vertices. The first three indices are the vertices of the face, the second three define the second face, and so forth.
160 * @param[out] num_faces the number of faces in the faces array
161 * @param[out] vertices the set of vertices used by the surface.
162 * @param[out] num_vertices the number of vertices in the surface.
163 * @param input_points_3d The input points
164 * @param input_normals_3d The normals associated with the points
165 * @param num_input_pnts the number of points in the input set
166 * @param opts container holding options to be used in SPSR processing
167 * @return 0 if successful, else error
168 *
169 */
170BG_EXPORT int bg_3d_spsr(int **faces, int *num_faces, point_t **vertices, int *num_vertices,
171 const point_t *input_points_3d, const vect_t *input_normals_3d,
172 int num_input_pnts, struct bg_3d_spsr_opts *opts);
173
174__END_DECLS
175
176#endif /* BG_SPSR_H */
177/** @} */
178/*
179 * Local Variables:
180 * mode: C
181 * tab-width: 8
182 * indent-tabs-mode: t
183 * c-file-style: "stroustrup"
184 * End:
185 * ex: shiftwidth=4 tabstop=8
186 */
Header file for the BRL-CAD common definitions.
int bg_3d_spsr(int **faces, int *num_faces, point_t **vertices, int *num_vertices, const point_t *input_points_3d, const vect_t *input_normals_3d, int num_input_pnts, struct bg_3d_spsr_opts *opts)
Applies Screened Poisson Surface Reconstruction to build a triangle mesh defining a surface,...
fastf_t vect_t[ELEMENTS_PER_VECT]
3-tuple vector
Definition: vmath.h:345
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:330
fastf_t point_t[ELEMENTS_PER_POINT]
3-tuple point
Definition: vmath.h:351
Screened Poisson Surface Reconstruction from oriented point sets.
Definition: spsr.h:79
fastf_t point_weight
Definition: spsr.h:96
fastf_t samples_per_node
Definition: spsr.h:90
int iterations
Definition: spsr.h:84
fastf_t cgsolver_accuracy
Definition: spsr.h:95
fastf_t scale
Definition: spsr.h:91
int btype
Definition: spsr.h:81
int degree
Definition: spsr.h:80
int exact
Definition: spsr.h:99
int kerneldepth
Definition: spsr.h:83
size_t threads
Definition: spsr.h:89
int full_depth
Definition: spsr.h:85
fastf_t width
Definition: spsr.h:92
fastf_t confidence_bias
Definition: spsr.h:94
int max_memory_GB
Definition: spsr.h:88
int linearFit
Definition: spsr.h:98
int depth
Definition: spsr.h:82
int baseVcycles
Definition: spsr.h:87
int base_depth
Definition: spsr.h:86
fastf_t confidence
Definition: spsr.h:93
int nonManifold
Definition: spsr.h:97
fundamental vector, matrix, quaternion math macros