14 #ifndef OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED
15 #define OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED
23 #include <type_traits>
45 template<
typename Gr
idType,
typename InterruptT>
46 typename GridType::Ptr
51 float voxelSize = 0.1
f,
52 float halfWidth =
float(LEVEL_SET_HALF_WIDTH),
53 InterruptT* interrupt =
nullptr);
67 template<
typename Gr
idType>
68 typename GridType::Ptr
73 float voxelSize = 0.1
f,
74 float halfWidth =
float(LEVEL_SET_HALF_WIDTH))
77 return createLevelSetPlatonic<GridType>(faceCount,
scale,
center, voxelSize, halfWidth, &tmp);
92 template<
typename Gr
idType,
typename InterruptT>
93 typename GridType::Ptr
97 float voxelSize = 0.1
f,
98 float halfWidth =
float(LEVEL_SET_HALF_WIDTH),
99 InterruptT* interrupt =
nullptr)
101 return createLevelSetPlatonic<GridType, InterruptT>(
102 4,
scale,
center, voxelSize, halfWidth, interrupt);
114 template<
typename Gr
idType>
115 typename GridType::Ptr
119 float voxelSize = 0.1
f,
120 float halfWidth =
float(LEVEL_SET_HALF_WIDTH))
123 return createLevelSetPlatonic<GridType>(4,
scale,
center, voxelSize, halfWidth, &tmp);
138 template<
typename Gr
idType,
typename InterruptT>
139 typename GridType::Ptr
143 float voxelSize = 0.1
f,
144 float halfWidth =
float(LEVEL_SET_HALF_WIDTH),
145 InterruptT* interrupt =
nullptr)
147 return createLevelSetPlatonic<GridType>(6,
scale,
center, voxelSize, halfWidth, interrupt);
159 template<
typename Gr
idType>
160 typename GridType::Ptr
164 float voxelSize = 0.1
f,
165 float halfWidth =
float(LEVEL_SET_HALF_WIDTH))
168 return createLevelSetPlatonic<GridType>(6,
scale,
center, voxelSize, halfWidth, &tmp);
183 template<
typename Gr
idType,
typename InterruptT>
184 typename GridType::Ptr
188 float voxelSize = 0.1
f,
189 float halfWidth =
float(LEVEL_SET_HALF_WIDTH),
190 InterruptT* interrupt =
nullptr)
192 return createLevelSetPlatonic<GridType>(8,
scale,
center, voxelSize, halfWidth, interrupt);
204 template<
typename Gr
idType>
205 typename GridType::Ptr
209 float voxelSize = 0.1
f,
210 float halfWidth =
float(LEVEL_SET_HALF_WIDTH))
213 return createLevelSetPlatonic<GridType>(8,
scale,
center, voxelSize, halfWidth, &tmp);
228 template<
typename Gr
idType,
typename InterruptT>
229 typename GridType::Ptr
233 float voxelSize = 0.1
f,
234 float halfWidth =
float(LEVEL_SET_HALF_WIDTH),
235 InterruptT* interrupt =
nullptr)
237 return createLevelSetPlatonic<GridType>(12,
scale,
center, voxelSize, halfWidth, interrupt);
249 template<
typename Gr
idType>
250 typename GridType::Ptr
254 float voxelSize = 0.1
f,
255 float halfWidth =
float(LEVEL_SET_HALF_WIDTH))
258 return createLevelSetPlatonic<GridType>(12,
scale,
center, voxelSize, halfWidth, &tmp);
273 template<
typename Gr
idType,
typename InterruptT>
274 typename GridType::Ptr
278 float voxelSize = 0.1
f,
279 float halfWidth =
float(LEVEL_SET_HALF_WIDTH),
280 InterruptT* interrupt =
nullptr)
282 return createLevelSetPlatonic<GridType>(20,
scale,
center, voxelSize, halfWidth, interrupt);
294 template<
typename Gr
idType>
295 typename GridType::Ptr
299 float voxelSize = 0.1
f,
300 float halfWidth =
float(LEVEL_SET_HALF_WIDTH))
303 return createLevelSetPlatonic<GridType>(20,
scale,
center, voxelSize, halfWidth, &tmp);
308 template<
typename Gr
idType,
typename InterruptT>
309 typename GridType::Ptr
311 float voxelSize,
float halfWidth, InterruptT *interrupt)
315 "level set grids must have scalar, floating-point value types");
319 std::vector<Vec3f> vtx;
320 std::vector<Vec3I> tri;
321 std::vector<Vec4I> qua;
323 if (faceCount == 4) {
325 vtx.push_back(
Vec3f( 0.0
f, 1.0
f, 0.0
f) );
326 vtx.push_back(
Vec3f(-0.942810297
f, -0.333329707
f, 0.0
f) );
327 vtx.push_back(
Vec3f( 0.471405149
f, -0.333329707
f, 0.816497624
f) );
328 vtx.push_back(
Vec3f( 0.471405149
f, -0.333329707
f, -0.816497624
f) );
330 tri.push_back(
Vec3I(0, 2, 3) );
331 tri.push_back(
Vec3I(0, 3, 1) );
332 tri.push_back(
Vec3I(0, 1, 2) );
333 tri.push_back(
Vec3I(1, 3, 2) );
335 }
else if (faceCount == 6) {
337 vtx.push_back(
Vec3f(-0.5
f, -0.5
f, -0.5
f) );
338 vtx.push_back(
Vec3f( 0.5
f, -0.5
f, -0.5
f) );
339 vtx.push_back(
Vec3f( 0.5
f, -0.5
f, 0.5
f) );
340 vtx.push_back(
Vec3f(-0.5
f, -0.5
f, 0.5
f) );
341 vtx.push_back(
Vec3f(-0.5
f, 0.5
f, -0.5
f) );
342 vtx.push_back(
Vec3f( 0.5
f, 0.5
f, -0.5
f) );
343 vtx.push_back(
Vec3f( 0.5
f, 0.5
f, 0.5
f) );
344 vtx.push_back(
Vec3f(-0.5
f, 0.5
f, 0.5
f) );
346 qua.push_back(
Vec4I(1, 0, 4, 5) );
347 qua.push_back(
Vec4I(2, 1, 5, 6) );
348 qua.push_back(
Vec4I(3, 2, 6, 7) );
349 qua.push_back(
Vec4I(0, 3, 7, 4) );
350 qua.push_back(
Vec4I(2, 3, 0, 1) );
351 qua.push_back(
Vec4I(5, 4, 7, 6) );
353 }
else if (faceCount == 8) {
355 vtx.push_back(
Vec3f( 0.0
f, 0.0
f, -1.0
f) );
356 vtx.push_back(
Vec3f( 1.0
f, 0.0
f, 0.0
f) );
357 vtx.push_back(
Vec3f( 0.0
f, 0.0
f, 1.0
f) );
358 vtx.push_back(
Vec3f(-1.0
f, 0.0
f, 0.0
f) );
359 vtx.push_back(
Vec3f( 0.0
f,-1.0
f, 0.0
f) );
360 vtx.push_back(
Vec3f( 0.0
f, 1.0
f, 0.0
f) );
362 tri.push_back(
Vec3I(0, 4, 3) );
363 tri.push_back(
Vec3I(0, 1, 4) );
364 tri.push_back(
Vec3I(1, 2, 4) );
365 tri.push_back(
Vec3I(2, 3, 4) );
366 tri.push_back(
Vec3I(0, 3, 5) );
367 tri.push_back(
Vec3I(0, 5, 1) );
368 tri.push_back(
Vec3I(1, 5, 2) );
369 tri.push_back(
Vec3I(2, 5, 3) );
371 }
else if (faceCount == 12) {
373 vtx.push_back(
Vec3f( 0.354437858
f, 0.487842113
f, -0.789344311
f) );
374 vtx.push_back(
Vec3f( 0.573492587
f, -0.186338872
f, -0.78934437
f) );
375 vtx.push_back(
Vec3f( 0.0
f, -0.603005826
f, -0.78934443
f) );
376 vtx.push_back(
Vec3f(-0.573492587
f, -0.186338872
f, -0.78934437
f) );
377 vtx.push_back(
Vec3f(-0.354437858
f, 0.487842113
f, -0.789344311
f) );
378 vtx.push_back(
Vec3f(-0.573492587
f, 0.789345026
f, -0.186338797
f) );
379 vtx.push_back(
Vec3f(-0.927930415
f, -0.301502913
f, -0.186338872
f) );
380 vtx.push_back(
Vec3f( 0.0
f, -0.975683928
f, -0.186338902
f) );
381 vtx.push_back(
Vec3f( 0.927930415
f, -0.301502913
f, -0.186338872
f) );
382 vtx.push_back(
Vec3f( 0.573492587
f, 0.789345026
f, -0.186338797
f) );
383 vtx.push_back(
Vec3f( 0.0
f, 0.975683868
f, 0.186338902
f) );
384 vtx.push_back(
Vec3f(-0.927930415
f, 0.301502913
f, 0.186338872
f) );
385 vtx.push_back(
Vec3f(-0.573492587
f, -0.789345026
f, 0.186338797
f) );
386 vtx.push_back(
Vec3f( 0.573492587
f, -0.789345026
f, 0.186338797
f) );
387 vtx.push_back(
Vec3f( 0.927930415
f, 0.301502913
f, 0.186338872
f) );
388 vtx.push_back(
Vec3f( 0.0
f, 0.603005826
f, 0.78934443
f) );
389 vtx.push_back(
Vec3f( 0.573492587
f, 0.186338872
f, 0.78934437
f) );
390 vtx.push_back(
Vec3f( 0.354437858
f, -0.487842113
f, 0.789344311
f) );
391 vtx.push_back(
Vec3f(-0.354437858
f, -0.487842113
f, 0.789344311
f) );
392 vtx.push_back(
Vec3f(-0.573492587
f, 0.186338872
f, 0.78934437
f) );
394 qua.push_back(
Vec4I(0, 1, 2, 3) );
395 tri.push_back(
Vec3I(0, 3, 4) );
396 qua.push_back(
Vec4I(0, 4, 5, 10) );
397 tri.push_back(
Vec3I(0, 10, 9) );
398 qua.push_back(
Vec4I(0, 9, 14, 8) );
399 tri.push_back(
Vec3I(0, 8, 1) );
400 qua.push_back(
Vec4I(1, 8, 13, 7) );
401 tri.push_back(
Vec3I(1, 7, 2) );
402 qua.push_back(
Vec4I(2, 7, 12, 6) );
403 tri.push_back(
Vec3I(2, 6, 3) );
404 qua.push_back(
Vec4I(3, 6, 11, 5) );
405 tri.push_back(
Vec3I(3, 5, 4) );
406 qua.push_back(
Vec4I(5, 11, 19, 15) );
407 tri.push_back(
Vec3I(5, 15, 10) );
408 qua.push_back(
Vec4I(6, 12, 18, 19) );
409 tri.push_back(
Vec3I(6, 19, 11) );
410 qua.push_back(
Vec4I(7, 13, 17, 18) );
411 tri.push_back(
Vec3I(7, 18, 12) );
412 qua.push_back(
Vec4I(8, 14, 16, 17) );
413 tri.push_back(
Vec3I(8, 17, 13) );
414 qua.push_back(
Vec4I(9, 10, 15, 16) );
415 tri.push_back(
Vec3I(9, 16, 14) );
416 qua.push_back(
Vec4I(15, 19, 18, 17) );
417 tri.push_back(
Vec3I(15, 17, 16) );
419 }
else if (faceCount == 20) {
421 vtx.push_back(
Vec3f(0.0
f, 0.0
f, -1.0
f) );
422 vtx.push_back(
Vec3f(0.0
f, 0.894427359
f, -0.447213143
f) );
423 vtx.push_back(
Vec3f(0.850650847
f, 0.276393682
f, -0.447213203
f) );
424 vtx.push_back(
Vec3f(0.525731206
f, -0.723606944
f, -0.447213262
f) );
425 vtx.push_back(
Vec3f(-0.525731206
f, -0.723606944
f, -0.447213262
f) );
426 vtx.push_back(
Vec3f(-0.850650847
f, 0.276393682
f, -0.447213203
f) );
427 vtx.push_back(
Vec3f(-0.525731206
f, 0.723606944
f, 0.447213262
f) );
428 vtx.push_back(
Vec3f(-0.850650847
f, -0.276393682
f, 0.447213203
f) );
429 vtx.push_back(
Vec3f(0.0
f, -0.894427359
f, 0.447213143
f) );
430 vtx.push_back(
Vec3f(0.850650847
f, -0.276393682
f, 0.447213203
f) );
431 vtx.push_back(
Vec3f(0.525731206
f, 0.723606944
f, 0.447213262
f) );
432 vtx.push_back(
Vec3f(0.0
f, 0.0
f, 1.0
f) );
434 tri.push_back(
Vec3I( 2, 0, 1) );
435 tri.push_back(
Vec3I( 3, 0, 2) );
436 tri.push_back(
Vec3I( 4, 0, 3) );
437 tri.push_back(
Vec3I( 5, 0, 4) );
438 tri.push_back(
Vec3I( 1, 0, 5) );
439 tri.push_back(
Vec3I( 6, 1, 5) );
440 tri.push_back(
Vec3I( 7, 5, 4) );
441 tri.push_back(
Vec3I( 8, 4, 3) );
442 tri.push_back(
Vec3I( 9, 3, 2) );
443 tri.push_back(
Vec3I(10, 2, 1) );
444 tri.push_back(
Vec3I(10, 1, 6) );
445 tri.push_back(
Vec3I( 6, 5, 7) );
446 tri.push_back(
Vec3I( 7, 4, 8) );
447 tri.push_back(
Vec3I( 8, 3, 9) );
448 tri.push_back(
Vec3I( 9, 2, 10) );
449 tri.push_back(
Vec3I( 6, 11, 10) );
450 tri.push_back(
Vec3I(10, 11, 9) );
451 tri.push_back(
Vec3I( 9, 11, 8) );
452 tri.push_back(
Vec3I( 8, 11, 7) );
453 tri.push_back(
Vec3I( 7, 11, 6) );
460 for (
size_t i = 0; i<vtx.size(); ++i ) vtx[i] = scale * vtx[i] + center;
462 typename GridType::Ptr grid;
464 if (interrupt ==
nullptr) {
466 grid = meshToLevelSet<GridType>(tmp, *xform, vtx, tri, qua, halfWidth);
468 grid = meshToLevelSet<GridType>(*interrupt, *xform, vtx, tri, qua, halfWidth);
478 #endif // OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED
GLenum GLenum GLenum GLenum GLenum scale
#define OPENVDB_USE_VERSION_NAMESPACE
Dummy NOOP interrupter class defining interface.
math::Vec4< Index32 > Vec4I
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
math::Vec3< Index32 > Vec3I
GLsizei const GLfloat * value
Convert polygonal meshes that consist of quads and/or triangles into signed or unsigned distance fiel...
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
#define OPENVDB_THROW(exception, message)
math::Vec3< float > Vec3f