diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_strategies.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_strategies.cpp index 15487eecb80..38ad1261158 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_strategies.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_strategies.cpp @@ -84,7 +84,7 @@ int main(int argc, char** argv) std::cout << "Output #vertices: " << points.size() << std::endl; std::cout << "Output #triangles: " << triangles.size() << std::endl; std::cout << "Elapsed time: " << timer.time() << " seconds" << std::endl; - CGAL::IO::write_polygon_soup("marching_cubes.off", points, triangles); + CGAL::IO::write_polygon_soup("marching_cubes_TMC.off", points, triangles); } std::cout << "Done" << std::endl; diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/marching_cubes_functors.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/marching_cubes_functors.h index c079609d138..9ac3d395d5a 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/marching_cubes_functors.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/marching_cubes_functors.h @@ -278,13 +278,18 @@ public: CGAL_precondition(m_domain.cell_vertices(cell).size() == 8); CGAL_precondition(m_domain.cell_edges(cell).size() == 12); - std::array values; - std::array corners; - const int i_case = get_cell_corners(m_domain, cell, m_isovalue, corners, values); + // @todo for SDFs, we could query at the center of the voxel an early exit + + constexpr std::size_t vpc = Domain::VERTICES_PER_CELL; + + std::array values; + std::array corners; + const std::size_t i_case = get_cell_corners(m_domain, cell, m_isovalue, corners, values); // skip empty cells - const int all_bits_set = (1 << (8 + 1)) - 1; // last 8 bits are 1 - if(i_case == 0 || i_case == all_bits_set) + constexpr std::size_t ones = (1 << vpc) - 1; + if((i_case & ones) == ones || // all bits set + (i_case & ones) == 0) // no bits set return; std::array vertices; diff --git a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h index 61cf2d78a79..9a72fb43d51 100644 --- a/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h +++ b/Isosurfacing_3/include/CGAL/Isosurfacing_3/internal/topologically_correct_marching_cubes_functors.h @@ -128,7 +128,7 @@ public: { std::array values; std::array corners; - const int i_case = get_cell_corners(m_domain, cell, m_isovalue, corners, values); + const std::size_t i_case = get_cell_corners(m_domain, cell, m_isovalue, corners, values); // this is the only difference to mc const int tcm = Cube_table::t_ambig[i_case]; @@ -142,8 +142,9 @@ public: #endif } - constexpr int all_bits_set = (1 << (8 + 1)) - 1; // last 8 bits are 1 - if(i_case == 0 || i_case == all_bits_set) + constexpr std::size_t ones = (1 << 8) - 1; + if((i_case & ones) == ones || // all bits set + (i_case & ones) == 0) // no bits set return; std::array vertices;