1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2015 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 #ifndef __OPENVDB_CAPI_H__ 21 #define __OPENVDB_CAPI_H__ 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Level Set Filters */ 28 typedef enum OpenVDBLevelSet_FilterType { 29 OPENVDB_LEVELSET_FILTER_NONE = 0, 30 OPENVDB_LEVELSET_FILTER_GAUSSIAN = 1, 31 OPENVDB_LEVELSET_FILTER_MEAN = 2, 32 OPENVDB_LEVELSET_FILTER_MEDIAN = 3, 33 OPENVDB_LEVELSET_FILTER_MEAN_CURVATURE = 4, 34 OPENVDB_LEVELSET_FILTER_LAPLACIAN = 5, 35 OPENVDB_LEVELSET_FILTER_DILATE = 6, 36 OPENVDB_LEVELSET_FILTER_ERODE = 7, 37 } OpenVDBLevelSet_FilterType; 38 39 typedef enum OpenVDBLevelSet_FilterBias { 40 OPENVDB_LEVELSET_FIRST_BIAS = 0, 41 OPENVDB_LEVELSET_SECOND_BIAS, 42 OPENVDB_LEVELSET_THIRD_BIAS, 43 OPENVDB_LEVELSET_WENO5_BIAS, 44 OPENVDB_LEVELSET_HJWENO5_BIAS, 45 } OpenVDBLevelSet_FilterBias; 46 47 /* Level Set CSG Operations */ 48 typedef enum OpenVDBLevelSet_CSGOperation { 49 OPENVDB_LEVELSET_CSG_UNION = 0, 50 OPENVDB_LEVELSET_CSG_DIFFERENCE = 1, 51 OPENVDB_LEVELSET_CSG_INTERSECTION = 2, 52 } OpenVDBLevelSet_CSGOperation; 53 54 typedef enum OpenVDBLevelSet_GridSampler { 55 OPENVDB_LEVELSET_GRIDSAMPLER_NONE = 0, 56 OPENVDB_LEVELSET_GRIDSAMPLER_POINT = 1, 57 OPENVDB_LEVELSET_GRIDSAMPLER_BOX = 2, 58 OPENVDB_LEVELSET_GRIDSAMPLER_QUADRATIC = 3, 59 } OpenVDBLevelSet_Gridsampler; 60 61 struct OpenVDBTransform; 62 struct OpenVDBLevelSet; 63 64 struct OpenVDBVolumeToMeshData { 65 int tottriangles; 66 int totquads; 67 int totvertices; 68 69 float *vertices; 70 unsigned int *quads; 71 unsigned int *triangles; 72 }; 73 74 struct OpenVDBRemeshData { 75 float *verts; 76 unsigned int *faces; 77 int totfaces; 78 int totverts; 79 80 float *out_verts; 81 unsigned int *out_faces; 82 unsigned int *out_tris; 83 int out_totverts; 84 int out_totfaces; 85 int out_tottris; 86 int filter_type; 87 enum OpenVDBLevelSet_FilterType filter_bias; 88 enum OpenVDBLevelSet_FilterBias filter_width; /* Parameter for gaussian, median, mean*/ 89 90 float voxel_size; 91 float isovalue; 92 float adaptivity; 93 int relax_disoriented_triangles; 94 }; 95 96 int OpenVDB_getVersionHex(void); 97 98 enum { 99 VEC_INVARIANT = 0, 100 VEC_COVARIANT = 1, 101 VEC_COVARIANT_NORMALIZE = 2, 102 VEC_CONTRAVARIANT_RELATIVE = 3, 103 VEC_CONTRAVARIANT_ABSOLUTE = 4, 104 }; 105 106 struct OpenVDBTransform *OpenVDBTransform_create(void); 107 void OpenVDBTransform_free(struct OpenVDBTransform *transform); 108 void OpenVDBTransform_create_linear_transform(struct OpenVDBTransform *transform, 109 double voxel_size); 110 111 struct OpenVDBLevelSet *OpenVDBLevelSet_create(bool initGrid, struct OpenVDBTransform *xform); 112 void OpenVDBLevelSet_free(struct OpenVDBLevelSet *level_set); 113 void OpenVDBLevelSet_mesh_to_level_set(struct OpenVDBLevelSet *level_set, 114 const float *vertices, 115 const unsigned int *faces, 116 const unsigned int totvertices, 117 const unsigned int totfaces, 118 struct OpenVDBTransform *xform); 119 void OpenVDBLevelSet_mesh_to_level_set_transform(struct OpenVDBLevelSet *level_set, 120 const float *vertices, 121 const unsigned int *faces, 122 const unsigned int totvertices, 123 const unsigned int totfaces, 124 struct OpenVDBTransform *transform); 125 void OpenVDBLevelSet_volume_to_mesh(struct OpenVDBLevelSet *level_set, 126 struct OpenVDBVolumeToMeshData *mesh, 127 const double isovalue, 128 const double adaptivity, 129 const bool relax_disoriented_triangles); 130 void OpenVDBLevelSet_filter(struct OpenVDBLevelSet *level_set, 131 OpenVDBLevelSet_FilterType filter_type, 132 int width, 133 float distance, 134 OpenVDBLevelSet_FilterBias bias); 135 void OpenVDBLevelSet_CSG_operation(struct OpenVDBLevelSet *out, 136 struct OpenVDBLevelSet *gridA, 137 struct OpenVDBLevelSet *gridB, 138 OpenVDBLevelSet_CSGOperation operation); 139 140 struct OpenVDBLevelSet *OpenVDBLevelSet_transform_and_resample(struct OpenVDBLevelSet *level_setA, 141 struct OpenVDBLevelSet *level_setB, 142 char sampler, 143 float isolevel); 144 145 #ifdef __cplusplus 146 } 147 #endif 148 149 #endif /* __OPENVDB_CAPI_H__ */ 150