@@ -57,23 +57,46 @@ void first_test()
5757 const geode::Point3D p1{ { 2.4 , 8.1 , 7.6 } };
5858 const geode::Point3D p2{ { 8.1 , 4.2 , 3.8 } };
5959 const geode::Point3D p3{ { 3.1 , 9.4 , 9.7 } };
60- const geode::NNSearch3D colocator ( { p0, p0, p1, p0, p2, p1, p3 } );
60+ std::vector< geode::Point3D > points{ p0, p0, p1, p0, p2, p1, p3 };
61+ const geode::NNSearch3D colocator ( points );
6162
6263 const auto colocated_info =
6364 colocator.colocated_index_mapping ( geode::GLOBAL_EPSILON );
6465 OPENGEODE_EXCEPTION ( colocated_info.nb_colocated_points () == 3 ,
65- " [Test] Should be 3 colocated points" );
66- const std::vector< geode::index_t > mapping_answer{ 0 , 0 , 1 , 0 , 2 , 1 , 3 };
67- OPENGEODE_EXCEPTION ( colocated_info.colocated_mapping == mapping_answer,
68- " [Test] Error in colocated mapping" );
69- const std::vector< geode::Point3D > points_answer{ p0, p1, p2, p3 };
70- OPENGEODE_EXCEPTION ( colocated_info.unique_points == points_answer,
71- " [Test] Error in unique points" );
66+ " [Test 1] Should be 3 colocated points" );
67+ for ( const auto p : geode::Indices{ points } )
68+ {
69+ OPENGEODE_EXCEPTION ( colocated_info.colocated_mapping [p]
70+ < colocated_info.unique_points .size (),
71+ " [Test 1] Wrong value of colocated_mapping (bigger than unique "
72+ " points size)" );
73+ const auto & colocated_point =
74+ colocated_info.unique_points [colocated_info.colocated_mapping [p]];
75+ OPENGEODE_EXCEPTION (
76+ geode::point_point_distance ( points[p], colocated_point )
77+ <= geode::GLOBAL_EPSILON,
78+ " [Test 1] Colocated point is not close enough to original point" );
79+ }
80+ for ( const auto up0 : geode::Indices{ colocated_info.unique_points } )
81+ {
82+ for ( const auto up1 : geode::Indices{ colocated_info.unique_points } )
83+ {
84+ if ( up1 <= up0 )
85+ {
86+ continue ;
87+ }
88+ OPENGEODE_EXCEPTION (
89+ geode::point_point_distance ( colocated_info.unique_points [up0],
90+ colocated_info.unique_points [up1] )
91+ > geode::GLOBAL_EPSILON,
92+ " [Test 1] Colocated points are too close" );
93+ }
94+ }
7295}
7396
7497void second_test ()
7598{
76- geode::Logger::set_level ( geode::Logger::LEVEL::debug );
99+ geode::Logger::set_level ( geode::Logger::LEVEL::trace );
77100 std::vector< geode::Point2D > points{
78101 geode::Point2D{ { 0 , 0.2 } },
79102 geode::Point2D{ { 0.25 , 0 } },
@@ -87,18 +110,24 @@ void second_test()
87110
88111 const auto colocated_info = colocator.colocated_index_mapping ( DISTANCE );
89112 DEBUG ( colocated_info.nb_unique_points () );
113+ for ( const auto v : geode::Range{ 6 } )
114+ {
115+ geode::Logger::trace ( v, " : " ,
116+ colocated_info.colocated_input_points [v], " / " ,
117+ colocated_info.colocated_mapping [v] );
118+ }
90119 for ( const auto p : geode::Indices{ points } )
91120 {
92121 OPENGEODE_EXCEPTION ( colocated_info.colocated_mapping [p]
93122 < colocated_info.unique_points .size (),
94- " [Test] Wrong value of colocated_mapping (bigger than unique "
123+ " [Test 2 ] Wrong value of colocated_mapping (bigger than unique "
95124 " points size)" );
96125 const auto & colocated_point =
97126 colocated_info.unique_points [colocated_info.colocated_mapping [p]];
98127 OPENGEODE_EXCEPTION (
99128 geode::point_point_distance ( points[p], colocated_point )
100129 <= DISTANCE,
101- " [Test] Colocated point is not close enough to original point" );
130+ " [Test 2 ] Colocated point is not close enough to original point" );
102131 }
103132 for ( const auto up0 : geode::Indices{ colocated_info.unique_points } )
104133 {
@@ -112,11 +141,11 @@ void second_test()
112141 geode::point_point_distance ( colocated_info.unique_points [up0],
113142 colocated_info.unique_points [up1] )
114143 > DISTANCE,
115- " [Test] Colocated points are too close" );
144+ " [Test 2 ] Colocated points are too close" );
116145 }
117146 }
118147 OPENGEODE_EXCEPTION ( colocated_info.nb_unique_points () == 2 ,
119- " [Test] Should be 2 unique points" );
148+ " [Test 2 ] Should be 2 unique points" );
120149}
121150
122151void test ()
0 commit comments