diff --git a/src/isosurface.cpp b/src/isosurface.cpp index f8a4e6b..38a9680 100644 --- a/src/isosurface.cpp +++ b/src/isosurface.cpp @@ -503,9 +503,11 @@ void IsoSurface::construct_triangles_from_tetrahedra(float _isovalue) { p[1] = this->interpolate_from_tetrahedra(tetrahedra_table[i], 3, 2, _isovalue); p[2] = this->interpolate_from_tetrahedra(tetrahedra_table[i], 3, 1, _isovalue); this->triangles.push_back(Triangle(p[0], p[1], p[2])); - break; + break; } } + + std::cout << "Identified " << this->triangles.size() << " faces." << std::endl; } Vec3 IsoSurface::interpolate_from_cubes(const Cube &_cub, unsigned int _p1, diff --git a/src/test/test_isosurface.cpp b/src/test/test_isosurface.cpp index 8b16d89..496a47a 100644 --- a/src/test/test_isosurface.cpp +++ b/src/test/test_isosurface.cpp @@ -76,6 +76,53 @@ void TestIsosurface::test_marching_cubes() { } } +void TestIsosurface::test_marching_tetrahedra() { + // construct isosurface + IsoSurface is(this->sf.get()); + is.marching_tetrahedra(0.01); + + // construct mesh storage object + IsoSurfaceMesh ism(sf.get(), &is); + ism.construct_mesh(true); + + CPPUNIT_ASSERT_EQUAL((size_t)24433, ism.get_vertices().size()); + CPPUNIT_ASSERT_EQUAL((size_t)24433, ism.get_normals().size()); + CPPUNIT_ASSERT_EQUAL((size_t)146124, ism.get_texcoords().size()); + + // get minimum and maximum value + float minx = 0.0; + float miny = 0.0; + float minz = 0.0; + float maxx = 0.0; + float maxy = 0.0; + float maxz = 0.0; + for(unsigned int i=0; isf.get()); diff --git a/src/test/test_isosurface.h b/src/test/test_isosurface.h index bc3c489..617c074 100644 --- a/src/test/test_isosurface.h +++ b/src/test/test_isosurface.h @@ -34,6 +34,7 @@ class TestIsosurface : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE( TestIsosurface ); CPPUNIT_TEST( test_marching_cubes ); + CPPUNIT_TEST( test_marching_tetrahedra ); CPPUNIT_TEST( test_obj ); CPPUNIT_TEST( test_ply ); CPPUNIT_TEST( test_stl ); @@ -42,6 +43,7 @@ class TestIsosurface : public CppUnit::TestFixture public: void setUp(); void test_marching_cubes(); + void test_marching_tetrahedra(); void test_obj(); void test_ply(); void test_stl();