diff --git a/Mesh_3/include/CGAL/Mesh_3/Implicit_to_labeling_function_wrapper.h b/Mesh_3/include/CGAL/Mesh_3/Implicit_to_labeling_function_wrapper.h index f22d629af7b..069f5605fe4 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Implicit_to_labeling_function_wrapper.h +++ b/Mesh_3/include/CGAL/Mesh_3/Implicit_to_labeling_function_wrapper.h @@ -220,6 +220,7 @@ public: } } bmasks.pop_back(); + std::sort(bmasks.begin(), bmasks.end()); } Implicit_multi_domain_to_labeling_function_wrapper (const Function_vector& vf, const std::vector& vps) diff --git a/Mesh_3/test/Mesh_3/CMakeLists.txt b/Mesh_3/test/Mesh_3/CMakeLists.txt index 42254a629b1..5f7cc3028e0 100644 --- a/Mesh_3/test/Mesh_3/CMakeLists.txt +++ b/Mesh_3/test/Mesh_3/CMakeLists.txt @@ -25,6 +25,7 @@ if ( CGAL_FOUND ) create_single_source_cgal_program( "test_backward_compatibility.cpp" ) create_single_source_cgal_program( "test_boost_has_xxx.cpp" ) create_single_source_cgal_program( "test_c3t3.cpp" ) + create_single_source_cgal_program( "test_implicit_multi_domain_to_labeling_function_wrapper.cpp" ) create_single_source_cgal_program( "test_c3t3_io.cpp" ) create_single_source_cgal_program( "test_c3t3_with_features.cpp" ) create_single_source_cgal_program( "test_criteria.cpp" ) diff --git a/Mesh_3/test/Mesh_3/test_implicit_multi_domain_to_labeling_function_wrapper.cpp b/Mesh_3/test/Mesh_3/test_implicit_multi_domain_to_labeling_function_wrapper.cpp new file mode 100644 index 00000000000..663829f551a --- /dev/null +++ b/Mesh_3/test/Mesh_3/test_implicit_multi_domain_to_labeling_function_wrapper.cpp @@ -0,0 +1,141 @@ +#include +#include + + +typedef CGAL::Exact_predicates_inexact_constructions_kernel K_e_i; +typedef typename K_e_i::Point_3 Point_3; +typedef double (Function) (const Point_3&); + +typedef CGAL::Mesh_3::Implicit_multi_domain_to_labeling_function_wrapper Labeling_function; +typedef Labeling_function::Function_vector Function_vector; + + +double cube_function_1 (const Point_3& p) +{ + if( p.x() > 0 && p.x() < 2 && + p.y() > 0 && p.y() < 2 && + p.z() > 0 && p.z() < 2 ) + return -1.; + return 1.; +} + +double cube_function_2 (const Point_3& p) +{ + if( p.x() > 1 && p.x() < 3 && + p.y() > 1 && p.y() < 3 && + p.z() > 1 && p.z() < 3 ) + return -1.; + return 1.; +} + + +void test_constructor_vfunc () +{ + Function_vector vfunc; + vfunc.push_back(cube_function_1); + vfunc.push_back(cube_function_2); + + Labeling_function lfunc(vfunc); + + Point_3 p1(0.5, 0.5, 0.5); + Point_3 p2(2.5, 2.5, 2.5); + Point_3 p3(1.5, 1.5, 1.5); + Point_3 p_out(4., 4., 4.); + + Labeling_function::return_type rp1 = lfunc(p1); + Labeling_function::return_type rp2 = lfunc(p2); + Labeling_function::return_type rp3 = lfunc(p3); + Labeling_function::return_type rp_out = lfunc(p_out); + + assert(rp1 != 0); + assert(rp2 != 0); + assert(rp3 != 0); + assert(rp_out == 0); + + assert(rp1 != rp2); + assert(rp1 != rp3); + assert(rp2 != rp3); +} + +void test_constructor_vfunc_vvpos () +{ + Function_vector vfunc; + vfunc.push_back(cube_function_1); + vfunc.push_back(cube_function_2); + + std::vector > vvpos; + std::vector vpos1; + vpos1.push_back(CGAL::NEGATIVE); + vpos1.push_back(CGAL::POSITIVE); + vvpos.push_back(vpos1); + std::vector vpos2; + vpos2.push_back(CGAL::POSITIVE); + vpos2.push_back(CGAL::NEGATIVE); + vvpos.push_back(vpos2); + std::vector vpos3; + vpos3.push_back(CGAL::NEGATIVE); + vpos3.push_back(CGAL::NEGATIVE); + vvpos.push_back(vpos3); + + Labeling_function lfunc(vfunc, vvpos); + + Point_3 p1(0.5, 0.5, 0.5); + Point_3 p2(2.5, 2.5, 2.5); + Point_3 p3(1.5, 1.5, 1.5); + Point_3 p_out(4., 4., 4.); + + Labeling_function::return_type rp1 = lfunc(p1); + Labeling_function::return_type rp2 = lfunc(p2); + Labeling_function::return_type rp3 = lfunc(p3); + Labeling_function::return_type rp_out = lfunc(p_out); + + assert(rp1 != 0); + assert(rp2 != 0); + assert(rp3 != 0); + assert(rp_out == 0); + + assert(rp1 != rp2); + assert(rp1 != rp3); + assert(rp2 != rp3); +} + +void test_constructor_vfunc_vstr () +{ + Function_vector vfunc; + vfunc.push_back(cube_function_1); + vfunc.push_back(cube_function_2); + + std::vector vstr; + vstr.push_back("-+"); + vstr.push_back("+-"); + vstr.push_back("--"); + + Labeling_function lfunc(vfunc, vstr); + + Point_3 p1(0.5, 0.5, 0.5); + Point_3 p2(2.5, 2.5, 2.5); + Point_3 p3(1.5, 1.5, 1.5); + Point_3 p_out(4., 4., 4.); + + Labeling_function::return_type rp1 = lfunc(p1); + Labeling_function::return_type rp2 = lfunc(p2); + Labeling_function::return_type rp3 = lfunc(p3); + Labeling_function::return_type rp_out = lfunc(p_out); + + assert(rp1 != 0); + assert(rp2 != 0); + assert(rp3 != 0); + assert(rp_out == 0); + + assert(rp1 != rp2); + assert(rp1 != rp3); + assert(rp2 != rp3); +} + +int main () +{ + test_constructor_vfunc(); + test_constructor_vfunc_vvpos(); + test_constructor_vfunc_vstr(); + return 0; +}