41 #ifndef OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED 42 #define OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED 51 #include <boost/utility.hpp> 52 #include <boost/type_traits/is_floating_point.hpp> 72 template<
typename Gr
idType,
typename InterruptT>
73 typename GridType::Ptr
77 float voxelSize = 0.1f,
79 InterruptT* interrupt = NULL);
93 template<
typename Gr
idType>
94 typename GridType::Ptr
98 float voxelSize = 0.1f,
102 return createLevelSetPlatonic<GridType>(faceCount,
scale, center, voxelSize, halfWidth, &tmp);
117 template<
typename Gr
idType,
typename InterruptT>
118 typename GridType::Ptr
121 float voxelSize = 0.1f,
123 InterruptT* interrupt = NULL)
125 return createLevelSetPlatonic<GridType, InterruptT>(4,
scale, center,
126 voxelSize, halfWidth, interrupt);
138 template<
typename Gr
idType>
139 typename GridType::Ptr
142 float voxelSize = 0.1f,
146 return createLevelSetPlatonic<GridType>(4,
scale, center, voxelSize, halfWidth, &tmp);
161 template<
typename Gr
idType,
typename InterruptT>
162 typename GridType::Ptr
165 float voxelSize = 0.1f,
167 InterruptT* interrupt = NULL)
169 return createLevelSetPlatonic<GridType>(6,
scale, center, voxelSize, halfWidth, interrupt);
181 template<
typename Gr
idType>
182 typename GridType::Ptr
185 float voxelSize = 0.1f,
189 return createLevelSetPlatonic<GridType>(6,
scale, center, voxelSize, halfWidth, &tmp);
204 template<
typename Gr
idType,
typename InterruptT>
205 typename GridType::Ptr
208 float voxelSize = 0.1f,
210 InterruptT* interrupt = NULL)
212 return createLevelSetPlatonic<GridType>(8,
scale, center, voxelSize, halfWidth, interrupt);
224 template<
typename Gr
idType>
225 typename GridType::Ptr
228 float voxelSize = 0.1f,
232 return createLevelSetPlatonic<GridType>(8,
scale, center, voxelSize, halfWidth, &tmp);
247 template<
typename Gr
idType,
typename InterruptT>
248 typename GridType::Ptr
251 float voxelSize = 0.1f,
253 InterruptT* interrupt = NULL)
255 return createLevelSetPlatonic<GridType>(12,
scale, center, voxelSize, halfWidth, interrupt);
267 template<
typename Gr
idType>
268 typename GridType::Ptr
271 float voxelSize = 0.1f,
275 return createLevelSetPlatonic<GridType>(12,
scale, center, voxelSize, halfWidth, &tmp);
290 template<
typename Gr
idType,
typename InterruptT>
291 typename GridType::Ptr
294 float voxelSize = 0.1f,
296 InterruptT* interrupt = NULL)
298 return createLevelSetPlatonic<GridType>(20,
scale, center, voxelSize, halfWidth, interrupt);
310 template<
typename Gr
idType>
311 typename GridType::Ptr
314 float voxelSize = 0.1f,
318 return createLevelSetPlatonic<GridType>(20,
scale, center, voxelSize, halfWidth, &tmp);
323 template<
typename Gr
idType,
typename InterruptT>
324 typename GridType::Ptr
326 float voxelSize,
float halfWidth, InterruptT *interrupt)
329 BOOST_STATIC_ASSERT(boost::is_floating_point<typename GridType::ValueType>::value);
333 std::vector<Vec3f> vtx;
334 std::vector<Vec3I> tri;
335 std::vector<Vec4I> qua;
337 if (faceCount == 4) {
339 vtx.push_back(
Vec3f( 0.0f, 1.0f, 0.0f) );
340 vtx.push_back(
Vec3f(-0.942810297f, -0.333329707f, 0.0f) );
341 vtx.push_back(
Vec3f( 0.471405149f, -0.333329707f, 0.816497624) );
342 vtx.push_back(
Vec3f( 0.471405149f, -0.333329707f, -0.816497624f) );
344 tri.push_back(
Vec3I(0, 2, 3) );
345 tri.push_back(
Vec3I(0, 3, 1) );
346 tri.push_back(
Vec3I(0, 1, 2) );
347 tri.push_back(
Vec3I(1, 3, 2) );
349 }
else if (faceCount == 6) {
351 vtx.push_back(
Vec3f(-0.5f, -0.5f, -0.5f) );
352 vtx.push_back(
Vec3f( 0.5f, -0.5f, -0.5f) );
353 vtx.push_back(
Vec3f( 0.5f, -0.5f, 0.5f) );
354 vtx.push_back(
Vec3f(-0.5f, -0.5f, 0.5f) );
355 vtx.push_back(
Vec3f(-0.5f, 0.5f, -0.5f) );
356 vtx.push_back(
Vec3f( 0.5f, 0.5f, -0.5f) );
357 vtx.push_back(
Vec3f( 0.5f, 0.5f, 0.5f) );
358 vtx.push_back(
Vec3f(-0.5f, 0.5f, 0.5f) );
360 qua.push_back(
Vec4I(1, 0, 4, 5) );
361 qua.push_back(
Vec4I(2, 1, 5, 6) );
362 qua.push_back(
Vec4I(3, 2, 6, 7) );
363 qua.push_back(
Vec4I(0, 3, 7, 4) );
364 qua.push_back(
Vec4I(2, 3, 0, 1) );
365 qua.push_back(
Vec4I(5, 4, 7, 6) );
367 }
else if (faceCount == 8) {
369 vtx.push_back(
Vec3f( 0.0f, 0.0f, -1.0f) );
370 vtx.push_back(
Vec3f( 1.0f, 0.0f, 0.0f) );
371 vtx.push_back(
Vec3f( 0.0f, 0.0f, 1.0f) );
372 vtx.push_back(
Vec3f(-1.0f, 0.0f, 0.0f) );
373 vtx.push_back(
Vec3f( 0.0f,-1.0f, 0.0f) );
374 vtx.push_back(
Vec3f( 0.0f, 1.0f, 0.0f) );
376 tri.push_back(
Vec3I(0, 4, 3) );
377 tri.push_back(
Vec3I(0, 1, 4) );
378 tri.push_back(
Vec3I(1, 2, 4) );
379 tri.push_back(
Vec3I(2, 3, 4) );
380 tri.push_back(
Vec3I(0, 3, 5) );
381 tri.push_back(
Vec3I(0, 5, 1) );
382 tri.push_back(
Vec3I(1, 5, 2) );
383 tri.push_back(
Vec3I(2, 5, 3) );
385 }
else if (faceCount == 12) {
387 vtx.push_back(
Vec3f( 0.354437858f, 0.487842113f, -0.789344311f) );
388 vtx.push_back(
Vec3f( 0.573492587f, -0.186338872f, -0.78934437f) );
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.573492587f, 0.789345026f, -0.186338797f) );
393 vtx.push_back(
Vec3f(-0.927930415f, -0.301502913f, -0.186338872f) );
394 vtx.push_back(
Vec3f( 0.0f, -0.975683928f, -0.186338902f) );
395 vtx.push_back(
Vec3f( 0.927930415f, -0.301502913f, -0.186338872f) );
396 vtx.push_back(
Vec3f( 0.573492587f, 0.789345026f, -0.186338797f) );
397 vtx.push_back(
Vec3f( 0.0f, 0.975683868f, 0.186338902f) );
398 vtx.push_back(
Vec3f(-0.927930415f, 0.301502913f, 0.186338872f) );
399 vtx.push_back(
Vec3f(-0.573492587f, -0.789345026f, 0.186338797f) );
400 vtx.push_back(
Vec3f( 0.573492587f, -0.789345026f, 0.186338797f) );
401 vtx.push_back(
Vec3f( 0.927930415f, 0.301502913f, 0.186338872f) );
402 vtx.push_back(
Vec3f( 0.0f, 0.603005826f, 0.78934443f) );
403 vtx.push_back(
Vec3f( 0.573492587f, 0.186338872f, 0.78934437f) );
404 vtx.push_back(
Vec3f( 0.354437858f, -0.487842113f, 0.789344311f) );
405 vtx.push_back(
Vec3f(-0.354437858f, -0.487842113f, 0.789344311f) );
406 vtx.push_back(
Vec3f(-0.573492587f, 0.186338872f, 0.78934437f) );
408 qua.push_back(
Vec4I(0, 1, 2, 3) );
409 tri.push_back(
Vec3I(0, 3, 4) );
410 qua.push_back(
Vec4I(0, 4, 5, 10) );
411 tri.push_back(
Vec3I(0, 10, 9) );
412 qua.push_back(
Vec4I(0, 9, 14, 8) );
413 tri.push_back(
Vec3I(0, 8, 1) );
414 qua.push_back(
Vec4I(1, 8, 13, 7) );
415 tri.push_back(
Vec3I(1, 7, 2) );
416 qua.push_back(
Vec4I(2, 7, 12, 6) );
417 tri.push_back(
Vec3I(2, 6, 3) );
418 qua.push_back(
Vec4I(3, 6, 11, 5) );
419 tri.push_back(
Vec3I(3, 5, 4) );
420 qua.push_back(
Vec4I(5, 11, 19, 15) );
421 tri.push_back(
Vec3I(5, 15, 10) );
422 qua.push_back(
Vec4I(6, 12, 18, 19) );
423 tri.push_back(
Vec3I(6, 19, 11) );
424 qua.push_back(
Vec4I(7, 13, 17, 18) );
425 tri.push_back(
Vec3I(7, 18, 12) );
426 qua.push_back(
Vec4I(8, 14, 16, 17) );
427 tri.push_back(
Vec3I(8, 17, 13) );
428 qua.push_back(
Vec4I(9, 10, 15, 16) );
429 tri.push_back(
Vec3I(9, 16, 14) );
430 qua.push_back(
Vec4I(15, 19, 18, 17) );
431 tri.push_back(
Vec3I(15, 17, 16) );
433 }
else if (faceCount == 20) {
435 vtx.push_back(
Vec3f(0.0f, 0.0f, -1.0f) );
436 vtx.push_back(
Vec3f(0.0f, 0.894427359f, -0.447213143f) );
437 vtx.push_back(
Vec3f(0.850650847f, 0.276393682f, -0.447213203f) );
438 vtx.push_back(
Vec3f(0.525731206f, -0.723606944f, -0.447213262f) );
439 vtx.push_back(
Vec3f(-0.525731206f, -0.723606944f, -0.447213262f) );
440 vtx.push_back(
Vec3f(-0.850650847f, 0.276393682f, -0.447213203f) );
441 vtx.push_back(
Vec3f(-0.525731206f, 0.723606944f, 0.447213262f) );
442 vtx.push_back(
Vec3f(-0.850650847f, -0.276393682f, 0.447213203f) );
443 vtx.push_back(
Vec3f(0.0f, -0.894427359f, 0.447213143f) );
444 vtx.push_back(
Vec3f(0.850650847f, -0.276393682f, 0.447213203f) );
445 vtx.push_back(
Vec3f(0.525731206f, 0.723606944f, 0.447213262f) );
446 vtx.push_back(
Vec3f(0.0f, 0.0f, 1.0f) );
448 tri.push_back(
Vec3I( 2, 0, 1) );
449 tri.push_back(
Vec3I( 3, 0, 2) );
450 tri.push_back(
Vec3I( 4, 0, 3) );
451 tri.push_back(
Vec3I( 5, 0, 4) );
452 tri.push_back(
Vec3I( 1, 0, 5) );
453 tri.push_back(
Vec3I( 6, 1, 5) );
454 tri.push_back(
Vec3I( 7, 5, 4) );
455 tri.push_back(
Vec3I( 8, 4, 3) );
456 tri.push_back(
Vec3I( 9, 3, 2) );
457 tri.push_back(
Vec3I(10, 2, 1) );
458 tri.push_back(
Vec3I(10, 1, 6) );
459 tri.push_back(
Vec3I( 6, 5, 7) );
460 tri.push_back(
Vec3I( 7, 4, 8) );
461 tri.push_back(
Vec3I( 8, 3, 9) );
462 tri.push_back(
Vec3I( 9, 2, 10) );
463 tri.push_back(
Vec3I( 6, 11, 10) );
464 tri.push_back(
Vec3I(10, 11, 9) );
465 tri.push_back(
Vec3I( 9, 11, 8) );
466 tri.push_back(
Vec3I( 8, 11, 7) );
467 tri.push_back(
Vec3I( 7, 11, 6) );
474 for (
size_t i = 0; i<vtx.size(); ++i ) vtx[i] = scale * vtx[i] + center;
476 typename GridType::Ptr grid;
478 if (interrupt == NULL) {
480 grid = meshToLevelSet<GridType>(tmp, *xform, vtx, tri, qua, halfWidth);
482 grid = meshToLevelSet<GridType>(*interrupt, *xform, vtx, tri, qua, halfWidth);
492 #endif // OPENVDB_TOOLS_LEVELSETPLATONIC_HAS_BEEN_INCLUDED
math::Vec4< Index32 > Vec4I
Definition: Types.h:90
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Dummy NOOP interrupter class defining interface.
Definition: NullInterrupter.h:52
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:97
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:219
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Definition: Exceptions.h:86
math::Vec3< Index32 > Vec3I
Definition: Types.h:77
Convert polygonal meshes that consist of quads and/or triangles into signed or unsigned distance fiel...
Definition: Exceptions.h:39
MatType scale(const Vec3< typename MatType::value_type > &s)
Return a matrix that scales by s.
Definition: Mat.h:594
math::Vec3< float > Vec3f
Definition: Types.h:78
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71