You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An arbitrary number of point clouds can then be added to the data structure using the method ```add_point_set```. The library expects the point positions to be contiguously stored in an array-like structure. The method will return a unique id associated with the initialized point set.
29
29
```c++
30
-
std::vector<std::array<Real, 3>> positions;
31
30
// ... Fill array with 3 * n real numbers representing three-dimensional point positions.
32
-
unsigned int point_set_id = nsearch.add_point_set(positions.front().data(), positions.size());
33
-
nsearch.find_neighbors();
31
+
std::vector<std::array<Real, 3>> point_set_1;
32
+
std::vector<std::array<Real, 3>> point_set_2;
33
+
34
+
unsigned int point_set_1_id = nsearch.add_point_set(positions.front().data(), positions.size());
35
+
unsigned int point_set_2_id = nsearch.add_point_set(positions.front().data(), positions.size());
34
36
```
35
37
In order to generate the neighborhood information simply execute the following command
36
38
```c++
37
39
nsearch.find_neighbors();
38
40
```
39
41
Finally, the neighborhood information can be accessed as follows
for (size_t j = 0; j < ps.n_neighbors(neighbor_point_set_id, i); ++j)
45
-
{
46
-
// Return the point id of the jth neighbor of the ith particle in the 0th point set.
47
-
const unsigned int pid = ps.neighbor(0, i, j);
48
-
// ...
49
-
// Do whatever you want with the point id. The id contains two indices.
50
-
// The first field pid.point_set_id represents the unique point set id returnd by add_point_set.
51
-
// The second field pid.point_id stands for the index of the neighboring particle within
52
-
// the containing point set.
53
-
// ...
54
-
}
46
+
// Get point set 1 neighbors of point set 1.
47
+
for (size_t j = 0; j < ps_1.n_neighbors(point_set_1_id, i); ++j)
48
+
{
49
+
// Return the point id of the jth neighbor of the ith particle in the point_set_1.
50
+
const unsigned int pid = ps_1.neighbor(point_set_1_id, i, j);
51
+
}
52
+
53
+
// Get point set 2 neighbors of point set 1.
54
+
for (size_t j = 0; j < ps_1.n_neighbors(point_set_2_id, i); ++j)
55
+
{
56
+
// Return the point id of the jth neighbor of the ith particle in the point_set_1.
57
+
const unsigned int pid = ps_1.neighbor(point_set_2_id, i, j);
58
+
}
55
59
}
56
60
```
57
61
@@ -61,7 +65,7 @@ nsearch.z_sort();
61
65
```
62
66
Please note that the actual reordering must be invoked by the user by
63
67
```c++
64
-
ps.sort_field(positions.data());
68
+
ps_1.sort_field(positions.data());
65
69
```
66
70
Assuming that there is additional information stored per-point (e.g. velocity, color, mass etc.) the information **must** also be reorded using the same method to maintain consistency. Subsequently, the ```find_neighbors``` function has to be invoked again to update the neighborhood information.
67
71
@@ -71,7 +75,8 @@ Another self-explaining (benchmark) [demo](demo/main.cpp) is contained in the pr
71
75
72
76
When maintaining multiple it is sometimes desired that only certain point sets can find points from other point sets. Therefore an activation table is implemented where the user can specify whether a point set i searches points in another point set j. When nothing else is specified all point sets will search points in all other point sets. The activation table can be modified with e.g.
73
77
```c++
74
-
nsearch.set_active(i, j, false)
78
+
// Point set 2 will not look for neighbors within its own points
0 commit comments