22 #include "openvdb/tools/Composite.h"
36 const unsigned int *
faces,
37 const unsigned int totvertices,
38 const unsigned int totfaces,
39 const openvdb::math::Transform::Ptr &xform)
41 std::vector<openvdb::Vec3s> points(totvertices);
42 std::vector<openvdb::Vec3I> triangles(totfaces);
43 std::vector<openvdb::Vec4I> quads;
45 for (
unsigned int i = 0; i < totvertices; i++) {
46 points[i] = openvdb::Vec3s(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]);
49 for (
unsigned int i = 0; i < totfaces; i++) {
50 triangles[i] = openvdb::Vec3I(
faces[i * 3],
faces[i * 3 + 1],
faces[i * 3 + 2]);
53 this->grid = openvdb::tools::meshToLevelSet<openvdb::FloatGrid>(
54 *xform, points, triangles, quads, 1);
58 const double isovalue,
59 const double adaptivity,
60 const bool relax_disoriented_triangles)
62 std::vector<openvdb::Vec3s> out_points;
63 std::vector<openvdb::Vec4I> out_quads;
64 std::vector<openvdb::Vec3I> out_tris;
65 openvdb::tools::volumeToMesh<openvdb::FloatGrid>(*this->grid,
71 relax_disoriented_triangles);
73 out_points.size(), 3 *
sizeof(
float),
"openvdb remesher out verts");
75 out_quads.size(), 4 *
sizeof(
unsigned int),
"openvdb remesh out quads");
77 if (out_tris.size() > 0) {
79 out_tris.size(), 3 *
sizeof(
unsigned int),
"openvdb remesh out tris");
82 mesh->totvertices = out_points.
size();
83 mesh->tottriangles = out_tris.
size();
86 for (
size_t i = 0; i < out_points.size(); i++) {
87 mesh->vertices[i * 3] = out_points[i].x();
88 mesh->vertices[i * 3 + 1] = out_points[i].y();
89 mesh->vertices[i * 3 + 2] = out_points[i].z();
92 for (
size_t i = 0; i < out_quads.size(); i++) {
93 mesh->quads[i * 4] = out_quads[i].x();
94 mesh->quads[i * 4 + 1] = out_quads[i].y();
95 mesh->quads[i * 4 + 2] = out_quads[i].z();
96 mesh->quads[i * 4 + 3] = out_quads[i].w();
99 for (
size_t i = 0; i < out_tris.size(); i++) {
100 mesh->triangles[i * 3] = out_tris[i].x();
101 mesh->triangles[i * 3 + 1] = out_tris[i].y();
102 mesh->triangles[i * 3 + 2] = out_tris[i].z();
116 if (this->grid->getGridClass() != openvdb::GRID_LEVEL_SET) {
120 openvdb::tools::LevelSetFilter<openvdb::FloatGrid>
filter(*this->grid);
121 filter.setSpatialScheme((openvdb::math::BiasedGradientScheme)filter_bias);
122 switch (filter_type) {
149 const openvdb::FloatGrid::Ptr &gridA,
150 const openvdb::FloatGrid::Ptr &gridB,
155 openvdb::tools::csgUnion(*gridA, *gridB);
158 openvdb::tools::csgDifference(*gridA, *gridB);
161 openvdb::tools::csgIntersection(*gridA, *gridB);
typedef float(TangentPoint)[2]
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Read Guarded memory(de)allocation.
void *(* MEM_malloc_arrayN)(size_t len, size_t size, const char *str)
OpenVDBLevelSet_CSGOperation
@ OPENVDB_LEVELSET_CSG_UNION
@ OPENVDB_LEVELSET_CSG_INTERSECTION
@ OPENVDB_LEVELSET_CSG_DIFFERENCE
OpenVDBLevelSet_FilterType
@ OPENVDB_LEVELSET_FILTER_DILATE
@ OPENVDB_LEVELSET_FILTER_MEAN_CURVATURE
@ OPENVDB_LEVELSET_FILTER_GAUSSIAN
@ OPENVDB_LEVELSET_FILTER_ERODE
@ OPENVDB_LEVELSET_FILTER_LAPLACIAN
@ OPENVDB_LEVELSET_FILTER_MEAN
@ OPENVDB_LEVELSET_FILTER_NONE
@ OPENVDB_LEVELSET_FILTER_MEDIAN
OpenVDBLevelSet_FilterBias
void set_grid(const openvdb::FloatGrid::Ptr &grid)
void volume_to_mesh(struct OpenVDBVolumeToMeshData *mesh, const double isovalue, const double adaptivity, const bool relax_disoriented_triangles)
const openvdb::FloatGrid::Ptr & get_grid()
void filter(OpenVDBLevelSet_FilterType filter_type, int width, float distance, OpenVDBLevelSet_FilterBias filter_bias)
openvdb::FloatGrid::Ptr CSG_operation_apply(const openvdb::FloatGrid::Ptr &gridA, const openvdb::FloatGrid::Ptr &gridB, OpenVDBLevelSet_CSGOperation operation)
void mesh_to_level_set(const float *vertices, const unsigned int *faces, const unsigned int totvertices, const unsigned int totfaces, const openvdb::math::Transform::Ptr &transform)
static void initialize(SubdivDisplacement *displacement)
ccl_device_inline float distance(const float2 &a, const float2 &b)