SAF
Loading...
Searching...
No Matches
convhull_3d.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2017-2018 Leo McCormack
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21*/
22
43#ifndef CONVHULL_3D_INCLUDED
44#define CONVHULL_3D_INCLUDED
45
46#if !defined(__cplusplus) && defined(_MSC_VER)
47# pragma warning(disable : 4201)
48#endif
49
50#ifdef __cplusplus
51extern "C" {
52#endif /* __cplusplus */
53
54#ifdef CONVHULL_3D_USE_FLOAT_PRECISION
55typedef float CH_FLOAT;
56#else
57typedef double CH_FLOAT;
58#endif
62typedef struct _ch_vertex {
63 union{
64 struct{
65 CH_FLOAT x, y, z;
66 };
67 CH_FLOAT v[3];
68 };
69} ch_vertex;
70typedef ch_vertex ch_vec3;
71
88void convhull_3d_build(/* Input arguments */
89 ch_vertex* const in_vertices,
90 const int nVert,
91 /* Output arguments */
92 int** out_faces,
93 CH_FLOAT** out_cf,
94 CH_FLOAT** out_df,
95 int* nOut_faces);
96
114void convhull_nd_build(/* Input arguments */
115 CH_FLOAT* const in_vertices,
116 const int nVert,
117 const int d,
118 /* Output arguments */
119 int** out_faces,
120 CH_FLOAT** out_cf,
121 CH_FLOAT** out_df,
122 int* nOut_faces);
123
136void convhull_3d_export_obj(/* Input arguments */
137 ch_vertex* const vertices,
138 const int nVert,
139 int* const faces,
140 const int nFaces,
141 const int keepOnlyUsedVerticesFLAG,
142 char* const obj_filename);
143
154void convhull_3d_export_m(/* Input arguments */
155 ch_vertex* const vertices,
156 const int nVert,
157 int* const faces,
158 const int nFaces,
159 char* const m_filename);
160
168void extractVerticesFromObjFile(/* Input arguments */
169 char* const obj_filename,
170 /* Output arguments */
171 ch_vertex** out_vertices,
172 int* out_nVert);
173
174#ifdef __cplusplus
175} /*extern "C"*/
176#endif /* __cplusplus */
177
178#endif /* CONVHULL_3D_INCLUDED */
179
void convhull_3d_build(ch_vertex *const in_vertices, const int nVert, int **out_faces, CH_FLOAT **out_cf, CH_FLOAT **out_df, int *nOut_faces)
Builds the 3-D convexhull using the quickhull algorithm [1].
void convhull_3d_export_m(ch_vertex *const vertices, const int nVert, int *const faces, const int nFaces, char *const m_filename)
Exports the vertices, face indices, and face normals, as an '.m' file, for Matlab verification.
void extractVerticesFromObjFile(char *const obj_filename, ch_vertex **out_vertices, int *out_nVert)
Reads an '.obj' file and extracts only the vertices.
void convhull_3d_export_obj(ch_vertex *const vertices, const int nVert, int *const faces, const int nFaces, const int keepOnlyUsedVerticesFLAG, char *const obj_filename)
Exports the vertices, face indices, and face normals, as an '.obj' file, ready for the GPU.
void convhull_nd_build(CH_FLOAT *const in_vertices, const int nVert, const int d, int **out_faces, CH_FLOAT **out_cf, CH_FLOAT **out_df, int *nOut_faces)
Builds the N-D convexhull using the quickhull algorithm [1].
vertex structure, used by convhull_3d
Definition convhull_3d.h:62