2 This file is part of I am car.
4 I am car is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 I am car is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with I am car. If not, see <http://www.gnu.org/licenses/>.
24 std::vector<RRTNode *> &nodes,
26 float (*cost)(RRTNode *, RRTNode *))
28 RRTNode *root = nodes[0];
29 std::vector<RRTNode *> s; // DFS stack
30 std::vector<RRTNode *> r; // reset visited_
33 float mcost = (*cost)(root, node);
36 while (s.size() > 0) {
41 if ((*cost)(tmp, node) < mcost) {
43 mcost = (*cost)(tmp, node);
45 for (auto ch: tmp->children()) {
57 std::vector<RRTNode *> &nodes,
59 float (*cost)(RRTNode *, RRTNode *))
61 RRTNode *nn = nodes[0];
62 float mcost = (*cost)(nn, node);
64 // TODO fix see, user-defined reductions
65 #pragma omp parallel for
66 for (i = 0; i < nodes.size(); i++) {
67 if ((*cost)(nodes[i], node) < mcost) {
69 mcost = (*cost)(nodes[i], node);
76 std::vector<RRTNode *> (&nodes)[IYSIZE],
78 float (*cost)(RRTNode *, RRTNode *))
80 int iy = IYI(node->y());
84 unsigned int i = 0; // vector step
85 unsigned int j = 0; // array step
87 while (nn.mc > j * IYSTEP) {
91 #pragma omp parallel for reduction(minn: nn)
92 for (i = 0; i < nodes[iyj].size(); i++) {
93 if ((*cost)(nodes[iyj][i], node) < nn.mc) {
94 nn.mc = (*cost)(nodes[iyj][i], node);
95 nn.nn = nodes[iyj][i];
102 #pragma omp parallel for reduction(minn: nn)
103 for (i = 0; i < nodes[iyj].size(); i++) {
104 if ((*cost)(nodes[iyj][i], node) < nn.mc) {
105 nn.mc = (*cost)(nodes[iyj][i], node);
106 nn.nn = nodes[iyj][i];
116 std::vector<RRTNode *> (&nodes)[IYSIZE],
118 float (*cost)(RRTNode *, RRTNode *))
120 int iy = IYI(node->y());
124 unsigned int i = 0; // vector step
125 unsigned int j = 0; // array step
127 while (nn.mc > j * IYSTEP) {
128 iyj = (int) (iy + j);
131 #pragma omp parallel for reduction(minn: nn)
132 for (i = 0; i < nodes[iyj].size(); i++) {
133 if (EDIST(nodes[iyj][i], node) < nn.mc) {
134 nn.mc = EDIST(nodes[iyj][i], node);
135 nn.nn = nodes[iyj][i];
139 iyj = (int) (iy - j);
142 #pragma omp parallel for reduction(minn: nn)
143 for (i = 0; i < nodes[iyj].size(); i++) {
144 if (EDIST(nodes[iyj][i], node) < nn.mc) {
145 nn.mc = EDIST(nodes[iyj][i], node);
146 nn.nn = nodes[iyj][i];
156 std::vector<RRTNode *> (&nodes)[IYSIZE],
158 float (*cost)(RRTNode *, RRTNode *),
161 int iy = IYI(node->y());
165 unsigned int i = 0; // vector step
166 unsigned int j = 0; // array step
168 while (nn.mc > j * IYSTEP) {
169 iyj = (int) (iy + j);
172 #pragma omp parallel for reduction(minn: nn)
173 for (i = 0; i < nodes[iyj].size(); i++) {
174 if (EDIST(nodes[iyj][i], node) < nn.mc &&
176 nodes[iyj][i]->tree() == tree) {
177 nn.mc = EDIST(nodes[iyj][i], node);
178 nn.nn = nodes[iyj][i];
182 iyj = (int) (iy - j);
185 #pragma omp parallel for reduction(minn: nn)
186 for (i = 0; i < nodes[iyj].size(); i++) {
187 if (EDIST(nodes[iyj][i], node) < nn.mc &&
189 nodes[iyj][i]->tree() == tree) {
190 nn.mc = EDIST(nodes[iyj][i], node);
191 nn.nn = nodes[iyj][i];