14 #ifndef OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED 15 #define OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED 24 #include <type_traits> 46 template<
typename Gr
idType,
typename InterruptT>
47 typename GridType::Ptr
51 const Vec3f& center =
Vec3f(0.0f),
52 float voxelSize = 0.1f,
54 InterruptT* interrupt =
nullptr);
68 template<
typename Gr
idType>
69 typename GridType::Ptr
74 float voxelSize = 0.1f,
78 return createLevelSetPlatonic<GridType>(faceCount,
scale, center, voxelSize, halfWidth, &tmp);
93 template<
typename Gr
idType,
typename InterruptT>
94 typename GridType::Ptr
98 float voxelSize = 0.1f,
100 InterruptT* interrupt =
nullptr)
102 return createLevelSetPlatonic<GridType, InterruptT>(
103 4,
scale, center, voxelSize, halfWidth, interrupt);
115 template<
typename Gr
idType>
116 typename GridType::Ptr
120 float voxelSize = 0.1f,
124 return createLevelSetPlatonic<GridType>(4,
scale, center, voxelSize, halfWidth, &tmp);
139 template<
typename Gr
idType,
typename InterruptT>
140 typename GridType::Ptr
144 float voxelSize = 0.1f,
146 InterruptT* interrupt =
nullptr)
148 return createLevelSetPlatonic<GridType>(6,
scale, center, voxelSize, halfWidth, interrupt);
160 template<
typename Gr
idType>
161 typename GridType::Ptr
165 float voxelSize = 0.1f,
169 return createLevelSetPlatonic<GridType>(6,
scale, center, voxelSize, halfWidth, &tmp);
184 template<
typename Gr
idType,
typename InterruptT>
185 typename GridType::Ptr
189 float voxelSize = 0.1f,
191 InterruptT* interrupt =
nullptr)
193 return createLevelSetPlatonic<GridType>(8,
scale, center, voxelSize, halfWidth, interrupt);
205 template<
typename Gr
idType>
206 typename GridType::Ptr
210 float voxelSize = 0.1f,
214 return createLevelSetPlatonic<GridType>(8,
scale, center, voxelSize, halfWidth, &tmp);
229 template<
typename Gr
idType,
typename InterruptT>
230 typename GridType::Ptr
234 float voxelSize = 0.1f,
236 InterruptT* interrupt =
nullptr)
238 return createLevelSetPlatonic<GridType>(12,
scale, center, voxelSize, halfWidth, interrupt);
250 template<
typename Gr
idType>
251 typename GridType::Ptr
255 float voxelSize = 0.1f,
259 return createLevelSetPlatonic<GridType>(12,
scale, center, voxelSize, halfWidth, &tmp);
274 template<
typename Gr
idType,
typename InterruptT>
275 typename GridType::Ptr
279 float voxelSize = 0.1f,
281 InterruptT* interrupt =
nullptr)
283 return createLevelSetPlatonic<GridType>(20,
scale, center, voxelSize, halfWidth, interrupt);
295 template<
typename Gr
idType>
296 typename GridType::Ptr
300 float voxelSize = 0.1f,
304 return createLevelSetPlatonic<GridType>(20,
scale, center, voxelSize, halfWidth, &tmp);
309 template<
typename Gr
idType,
typename InterruptT>
310 typename GridType::Ptr
312 float voxelSize,
float halfWidth, InterruptT *interrupt)
316 "level set grids must have scalar, floating-point value types");
320 std::vector<Vec3f> vtx;
321 std::vector<Vec3I> tri;
322 std::vector<Vec4I> qua;
324 if (faceCount == 4) {
326 vtx.push_back(
Vec3f( 0.0f, 1.0f, 0.0f) );
327 vtx.push_back(
Vec3f(-0.942810297f, -0.333329707f, 0.0f) );
328 vtx.push_back(
Vec3f( 0.471405149f, -0.333329707f, 0.816497624f) );
329 vtx.push_back(
Vec3f( 0.471405149f, -0.333329707f, -0.816497624f) );
331 tri.push_back(
Vec3I(0, 2, 3) );
332 tri.push_back(
Vec3I(0, 3, 1) );
333 tri.push_back(
Vec3I(0, 1, 2) );
334 tri.push_back(
Vec3I(1, 3, 2) );
336 }
else if (faceCount == 6) {
338 vtx.push_back(
Vec3f(-0.5f, -0.5f, -0.5f) );
339 vtx.push_back(
Vec3f( 0.5f, -0.5f, -0.5f) );
340 vtx.push_back(
Vec3f( 0.5f, -0.5f, 0.5f) );
341 vtx.push_back(
Vec3f(-0.5f, -0.5f, 0.5f) );
342 vtx.push_back(
Vec3f(-0.5f, 0.5f, -0.5f) );
343 vtx.push_back(
Vec3f( 0.5f, 0.5f, -0.5f) );
344 vtx.push_back(
Vec3f( 0.5f, 0.5f, 0.5f) );
345 vtx.push_back(
Vec3f(-0.5f, 0.5f, 0.5f) );
347 qua.push_back(
Vec4I(1, 0, 4, 5) );
348 qua.push_back(
Vec4I(2, 1, 5, 6) );
349 qua.push_back(
Vec4I(3, 2, 6, 7) );
350 qua.push_back(
Vec4I(0, 3, 7, 4) );
351 qua.push_back(
Vec4I(2, 3, 0, 1) );
352 qua.push_back(
Vec4I(5, 4, 7, 6) );
354 }
else if (faceCount == 8) {
356 vtx.push_back(
Vec3f( 0.0f, 0.0f, -1.0f) );
357 vtx.push_back(
Vec3f( 1.0f, 0.0f, 0.0f) );
358 vtx.push_back(
Vec3f( 0.0f, 0.0f, 1.0f) );
359 vtx.push_back(
Vec3f(-1.0f, 0.0f, 0.0f) );
360 vtx.push_back(
Vec3f( 0.0f,-1.0f, 0.0f) );
361 vtx.push_back(
Vec3f( 0.0f, 1.0f, 0.0f) );
363 tri.push_back(
Vec3I(0, 4, 3) );
364 tri.push_back(
Vec3I(0, 1, 4) );
365 tri.push_back(
Vec3I(1, 2, 4) );
366 tri.push_back(
Vec3I(2, 3, 4) );
367 tri.push_back(
Vec3I(0, 3, 5) );
368 tri.push_back(
Vec3I(0, 5, 1) );
369 tri.push_back(
Vec3I(1, 5, 2) );
370 tri.push_back(
Vec3I(2, 5, 3) );
372 }
else if (faceCount == 12) {
374 vtx.push_back(
Vec3f( 0.354437858f, 0.487842113f, -0.789344311f) );
375 vtx.push_back(
Vec3f( 0.573492587f, -0.186338872f, -0.78934437f) );
376 vtx.push_back(
Vec3f( 0.0f, -0.603005826f, -0.78934443f) );
377 vtx.push_back(
Vec3f(-0.573492587f, -0.186338872f, -0.78934437f) );
378 vtx.push_back(
Vec3f(-0.354437858f, 0.487842113f, -0.789344311f) );
379 vtx.push_back(
Vec3f(-0.573492587f, 0.789345026f, -0.186338797f) );
380 vtx.push_back(
Vec3f(-0.927930415f, -0.301502913f, -0.186338872f) );
381 vtx.push_back(
Vec3f( 0.0f, -0.975683928f, -0.186338902f) );
382 vtx.push_back(
Vec3f( 0.927930415f, -0.301502913f, -0.186338872f) );
383 vtx.push_back(
Vec3f( 0.573492587f, 0.789345026f, -0.186338797f) );
384 vtx.push_back(
Vec3f( 0.0f, 0.975683868f, 0.186338902f) );
385 vtx.push_back(
Vec3f(-0.927930415f, 0.301502913f, 0.186338872f) );
386 vtx.push_back(
Vec3f(-0.573492587f, -0.789345026f, 0.186338797f) );
387 vtx.push_back(
Vec3f( 0.573492587f, -0.789345026f, 0.186338797f) );
388 vtx.push_back(
Vec3f( 0.927930415f, 0.301502913f, 0.186338872f) );
389 vtx.push_back(
Vec3f( 0.0f, 0.603005826f, 0.78934443f) );
390 vtx.push_back(
Vec3f( 0.573492587f, 0.186338872f, 0.78934437f) );
391 vtx.push_back(
Vec3f( 0.354437858f, -0.487842113f, 0.789344311f) );
392 vtx.push_back(
Vec3f(-0.354437858f, -0.487842113f, 0.789344311f) );
393 vtx.push_back(
Vec3f(-0.573492587f, 0.186338872f, 0.78934437f) );
395 qua.push_back(
Vec4I(0, 1, 2, 3) );
396 tri.push_back(
Vec3I(0, 3, 4) );
397 qua.push_back(
Vec4I(0, 4, 5, 10) );
398 tri.push_back(
Vec3I(0, 10, 9) );
399 qua.push_back(
Vec4I(0, 9, 14, 8) );
400 tri.push_back(
Vec3I(0, 8, 1) );
401 qua.push_back(
Vec4I(1, 8, 13, 7) );
402 tri.push_back(
Vec3I(1, 7, 2) );
403 qua.push_back(
Vec4I(2, 7, 12, 6) );
404 tri.push_back(
Vec3I(2, 6, 3) );
405 qua.push_back(
Vec4I(3, 6, 11, 5) );
406 tri.push_back(
Vec3I(3, 5, 4) );
407 qua.push_back(
Vec4I(5, 11, 19, 15) );
408 tri.push_back(
Vec3I(5, 15, 10) );
409 qua.push_back(
Vec4I(6, 12, 18, 19) );
410 tri.push_back(
Vec3I(6, 19, 11) );
411 qua.push_back(
Vec4I(7, 13, 17, 18) );
412 tri.push_back(
Vec3I(7, 18, 12) );
413 qua.push_back(
Vec4I(8, 14, 16, 17) );
414 tri.push_back(
Vec3I(8, 17, 13) );
415 qua.push_back(
Vec4I(9, 10, 15, 16) );
416 tri.push_back(
Vec3I(9, 16, 14) );
417 qua.push_back(
Vec4I(15, 19, 18, 17) );
418 tri.push_back(
Vec3I(15, 17, 16) );
420 }
else if (faceCount == 20) {
422 vtx.push_back(
Vec3f(0.0f, 0.0f, -1.0f) );
423 vtx.push_back(
Vec3f(0.0f, 0.894427359f, -0.447213143f) );
424 vtx.push_back(
Vec3f(0.850650847f, 0.276393682f, -0.447213203f) );
425 vtx.push_back(
Vec3f(0.525731206f, -0.723606944f, -0.447213262f) );
426 vtx.push_back(
Vec3f(-0.525731206f, -0.723606944f, -0.447213262f) );
427 vtx.push_back(
Vec3f(-0.850650847f, 0.276393682f, -0.447213203f) );
428 vtx.push_back(
Vec3f(-0.525731206f, 0.723606944f, 0.447213262f) );
429 vtx.push_back(
Vec3f(-0.850650847f, -0.276393682f, 0.447213203f) );
430 vtx.push_back(
Vec3f(0.0f, -0.894427359f, 0.447213143f) );
431 vtx.push_back(
Vec3f(0.850650847f, -0.276393682f, 0.447213203f) );
432 vtx.push_back(
Vec3f(0.525731206f, 0.723606944f, 0.447213262f) );
433 vtx.push_back(
Vec3f(0.0f, 0.0f, 1.0f) );
435 tri.push_back(
Vec3I( 2, 0, 1) );
436 tri.push_back(
Vec3I( 3, 0, 2) );
437 tri.push_back(
Vec3I( 4, 0, 3) );
438 tri.push_back(
Vec3I( 5, 0, 4) );
439 tri.push_back(
Vec3I( 1, 0, 5) );
440 tri.push_back(
Vec3I( 6, 1, 5) );
441 tri.push_back(
Vec3I( 7, 5, 4) );
442 tri.push_back(
Vec3I( 8, 4, 3) );
443 tri.push_back(
Vec3I( 9, 3, 2) );
444 tri.push_back(
Vec3I(10, 2, 1) );
445 tri.push_back(
Vec3I(10, 1, 6) );
446 tri.push_back(
Vec3I( 6, 5, 7) );
447 tri.push_back(
Vec3I( 7, 4, 8) );
448 tri.push_back(
Vec3I( 8, 3, 9) );
449 tri.push_back(
Vec3I( 9, 2, 10) );
450 tri.push_back(
Vec3I( 6, 11, 10) );
451 tri.push_back(
Vec3I(10, 11, 9) );
452 tri.push_back(
Vec3I( 9, 11, 8) );
453 tri.push_back(
Vec3I( 8, 11, 7) );
454 tri.push_back(
Vec3I( 7, 11, 6) );
461 for (
size_t i = 0; i<vtx.size(); ++i ) vtx[i] = scale * vtx[i] + center;
463 typename GridType::Ptr grid;
465 if (interrupt ==
nullptr) {
467 grid = meshToLevelSet<GridType>(tmp, *xform, vtx, tri, qua, halfWidth);
469 grid = meshToLevelSet<GridType>(*interrupt, *xform, vtx, tri, qua, halfWidth);
481 #ifdef OPENVDB_USE_EXPLICIT_INSTANTIATION 483 #ifdef OPENVDB_INSTANTIATE_LEVELSETPLATONIC 487 #define _FUNCTION(TreeT) \ 488 Grid<TreeT>::Ptr createLevelSetPlatonic<Grid<TreeT>>(int, float, const Vec3f&, float, float, \ 489 util::NullInterrupter*) 493 #define _FUNCTION(TreeT) \ 494 Grid<TreeT>::Ptr createLevelSetTetrahedron<Grid<TreeT>>(float, const Vec3f&, float, float, \ 495 util::NullInterrupter*) 499 #define _FUNCTION(TreeT) \ 500 Grid<TreeT>::Ptr createLevelSetCube<Grid<TreeT>>(float, const Vec3f&, float, float, \ 501 util::NullInterrupter*) 505 #define _FUNCTION(TreeT) \ 506 Grid<TreeT>::Ptr createLevelSetOctahedron<Grid<TreeT>>(float, const Vec3f&, float, float, \ 507 util::NullInterrupter*) 511 #define _FUNCTION(TreeT) \ 512 Grid<TreeT>::Ptr createLevelSetDodecahedron<Grid<TreeT>>(float, const Vec3f&, float, float, \ 513 util::NullInterrupter*) 517 #define _FUNCTION(TreeT) \ 518 Grid<TreeT>::Ptr createLevelSetIcosahedron<Grid<TreeT>>(float, const Vec3f&, float, float, \ 519 util::NullInterrupter*) 523 #endif // OPENVDB_USE_EXPLICIT_INSTANTIATION 530 #endif // OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED #define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Base class for interrupters.
Definition: NullInterrupter.h:25
math::Vec3< Index32 > Vec3I
Definition: Types.h:73
math::Vec3< float > Vec3f
Definition: Types.h:74
Convert polygonal meshes that consist of quads and/or triangles into signed or unsigned distance fiel...
Definition: Exceptions.h:13
ValueT value
Definition: GridBuilder.h:1287
Definition: Exceptions.h:63
MatType scale(const Vec3< typename MatType::value_type > &s)
Return a matrix that scales by s.
Definition: Mat.h:637
math::Vec4< Index32 > Vec4I
Definition: Types.h:88
#define OPENVDB_REAL_TREE_INSTANTIATE(Function)
Definition: version.h.in:147
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:116
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:422
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:202