MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/CompactNSearch / main

Function main

demo/main.cpp:142–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142int main(int argc, char* argv[])
143{
144 Real min_x = std::numeric_limits<Real>::max();
145 Real max_x = std::numeric_limits<Real>::min();
146 positions.reserve(N * N * N);
147 for (unsigned int i = 0; i < N; ++i)
148 {
149 for (unsigned int j = 0; j < N; ++j)
150 {
151 for (unsigned int k = 0; k < N; ++k)
152 {
153 std::array<Real, 3> x = {{
154 r_omega * (2.0 * static_cast<Real>(i) / static_cast<Real>(N-1)-1.0),
155 r_omega * (2.0 * static_cast<Real>(j) / static_cast<Real>(N-1)-1.0),
156 r_omega * (2.0 * static_cast<Real>(k) / static_cast<Real>(N-1)-1.0)}};
157
158 Real l2 = x[0] * x[0] + x[1] * x[1] + x[2] * x[2];
159 if (l2 < r_omega2)
160 {
161 x[0] += 0.35;
162 x[1] += 0.35;
163 x[2] += 0.35;
164 positions.push_back(x);
165 if (min_x > x[0])
166 {
167 min_x = x[0];
168 }
169 if (max_x < x[0])
170 {
171 max_x = x[0];
172 }
173 }
174 }
175 }
176 }
177 std::random_shuffle(positions.begin(), positions.end());
178
179 NeighborhoodSearch nsearch(radius, true);
180 nsearch.add_point_set(positions.front().data(), positions.size(), true, true);
181 nsearch.find_neighbors();
182
183 std::cout << "#Points = " << positions.size() << std::endl;
184 std::cout << "Search radius = " << radius << std::endl;
185 std::cout << "Min x = " << min_x << std::endl;
186 std::cout << "Max x = " << max_x << std::endl;
187 std::cout << "Average number of neighbors = " << compute_average_number_of_neighbors(nsearch) << std::endl;
188 std::cout << "Average index distance prior to z-sort = " << compute_average_distance(nsearch) << std::endl;
189
190 nsearch.z_sort();
191 for (auto const& d : nsearch.point_sets())
192 {
193 d.sort_field(positions.data());
194 }
195 nsearch.find_neighbors();
196 //compare_with_bruteforce_search(nsearch);
197
198 std::cout << "Average index distance after z-sort = " << compute_average_distance(nsearch) << std::endl;
199

Callers

nothing calls this directly

Calls 7

compute_average_distanceFunction · 0.85
advectFunction · 0.85
add_point_setMethod · 0.80
find_neighborsMethod · 0.80
z_sortMethod · 0.80
sort_fieldMethod · 0.80

Tested by

no test coverage detected