MCPcopy Create free account
hub / github.com/PDAL/PDAL / movableFilter

Method movableFilter

filters/private/csf/Cloth.cpp:148–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148void Cloth::movableFilter() {
149 vector<Particle> tmpParticles;
150
151 for (int x = 0; x < num_particles_width; x++) {
152 for (int y = 0; y < num_particles_height; y++) {
153 Particle *ptc = getParticle(x, y);
154
155 if (ptc->isMovable() && !ptc->isVisited) {
156 queue<int> que;
157 vector<XY> connected; // store the connected component
158 vector<vector<int> > neibors;
159 int sum = 1;
160 int index = y * num_particles_width + x;
161
162 // visit the init node
163 connected.push_back(XY(x, y));
164 particles[index].isVisited = true;
165
166 // enqueue the init node
167 que.push(index);
168
169 while (!que.empty()) {
170 Particle *ptc_f = &particles[que.front()];
171 que.pop();
172 int cur_x = ptc_f->pos_x;
173 int cur_y = ptc_f->pos_y;
174 vector<int> neibor;
175
176 if (cur_x > 0) {
177 Particle *ptc_left = getParticle(cur_x - 1, cur_y);
178
179 if (ptc_left->isMovable()) {
180 if (!ptc_left->isVisited) {
181 sum++;
182 ptc_left->isVisited = true;
183 connected.push_back(XY(cur_x - 1, cur_y));
184 que.push(num_particles_width * cur_y + cur_x - 1);
185 neibor.push_back(sum - 1);
186 ptc_left->c_pos = sum - 1;
187 } else {
188 neibor.push_back(ptc_left->c_pos);
189 }
190 }
191 }
192
193 if (cur_x < num_particles_width - 1) {
194 Particle *ptc_right = getParticle(cur_x + 1, cur_y);
195
196 if (ptc_right->isMovable()) {
197 if (!ptc_right->isVisited) {
198 sum++;
199 ptc_right->isVisited = true;
200 connected.push_back(XY(cur_x + 1, cur_y));
201 que.push(num_particles_width * cur_y + cur_x + 1);
202 neibor.push_back(sum - 1);
203 ptc_right->c_pos = sum - 1;
204 } else {
205 neibor.push_back(ptc_right->c_pos);

Callers 1

do_filteringMethod · 0.80

Calls 4

XYClass · 0.85
isMovableMethod · 0.80
pushMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected