MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / second_test

Function second_test

tests/geometry/test-nnsearch.cpp:99–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99void second_test()
100{
101 geode::Logger::set_level( geode::Logger::LEVEL::trace );
102 std::vector< geode::Point2D > points{
103 geode::Point2D{ { 0, 0.2 } },
104 geode::Point2D{ { 0.25, 0 } },
105 geode::Point2D{ { -0.25, 0 } },
106 geode::Point2D{ { 0, 0.8 } },
107 geode::Point2D{ { 0.25, 1 } },
108 geode::Point2D{ { -0.25, 1 } },
109 };
110 const geode::NNSearch2D colocator{ points };
111 const double DISTANCE{ 0.8 };
112
113 const auto colocated_info = colocator.colocated_index_mapping( DISTANCE );
114 DEBUG( colocated_info.nb_unique_points() );
115 for( const auto v : geode::Range{ 6 } )
116 {
117 geode::Logger::trace( v, " : ",
118 colocated_info.colocated_input_points[v], " / ",
119 colocated_info.colocated_mapping[v] );
120 }
121 for( const auto p : geode::Indices{ points } )
122 {
123 geode::OpenGeodeGeometryException::test(
124 colocated_info.colocated_mapping[p]
125 < colocated_info.unique_points.size(),
126 "[Test 2] Wrong value of colocated_mapping (bigger than unique "
127 "points size)" );
128 const auto& colocated_point =
129 colocated_info.unique_points[colocated_info.colocated_mapping[p]];
130 geode::OpenGeodeGeometryException::test(
131 geode::point_point_distance( points[p], colocated_point )
132 <= DISTANCE,
133 "[Test 2] Colocated point is not close enough to original point" );
134 }
135 for( const auto up0 : geode::Indices{ colocated_info.unique_points } )
136 {
137 for( const auto up1 : geode::Indices{ colocated_info.unique_points } )
138 {
139 if( up1 <= up0 )
140 {
141 continue;
142 }
143 geode::OpenGeodeGeometryException::test(
144 geode::point_point_distance( colocated_info.unique_points[up0],
145 colocated_info.unique_points[up1] )
146 > DISTANCE,
147 "[Test 2] Colocated points are too close" );
148 }
149 }
150 geode::OpenGeodeGeometryException::test(
151 colocated_info.nb_unique_points() == 2,
152 "[Test 2] Should be 2 unique points" );
153}
154
155void test()
156{

Callers 1

testFunction · 0.85

Calls 6

traceFunction · 0.85
point_point_distanceFunction · 0.85
nb_unique_pointsMethod · 0.80
testFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected