| 178 | } |
| 179 | |
| 180 | void M3C2Filter::done(PointTableRef _) |
| 181 | { |
| 182 | if (!m_p->v1) |
| 183 | throwError("Missing first view."); |
| 184 | if (!m_p->v2) |
| 185 | throwError("Missing second view."); |
| 186 | if (!m_p->cores) |
| 187 | throwError("Missing core points."); |
| 188 | |
| 189 | BOX3D v1Bounds; |
| 190 | m_p->v1->calculateBounds(v1Bounds); |
| 191 | |
| 192 | PointView& v1 = *m_p->v1; |
| 193 | PointGrid g1(v1Bounds.to2d(), v1); |
| 194 | for (PointId id = 0; id < v1.size(); ++id) |
| 195 | g1.add(v1.getFieldAs<double>(Dimension::Id::X, id), |
| 196 | v1.getFieldAs<double>(Dimension::Id::Y, id), id); |
| 197 | |
| 198 | BOX3D v2Bounds; |
| 199 | m_p->v2->calculateBounds(v2Bounds); |
| 200 | |
| 201 | PointView& v2 = *m_p->v2; |
| 202 | PointGrid g2(v2Bounds.to2d(), v2); |
| 203 | for (PointId id = 0; id < v2.size(); ++id) |
| 204 | g2.add(v2.getFieldAs<double>(Dimension::Id::X, id), |
| 205 | v2.getFieldAs<double>(Dimension::Id::Y, id), id); |
| 206 | |
| 207 | for (PointRef ref : *m_p->cores) |
| 208 | { |
| 209 | PointIdList pts1; |
| 210 | PointIdList pts2; |
| 211 | |
| 212 | Eigen::Vector3d core(ref.getFieldAs<double>(Dimension::Id::X), |
| 213 | ref.getFieldAs<double>(Dimension::Id::Y), |
| 214 | ref.getFieldAs<double>(Dimension::Id::Z)); |
| 215 | |
| 216 | Eigen::Vector3d normal = findNormal(core, g1); |
| 217 | if (m_args->orientation == NormalOrientation::Up) |
| 218 | normal = math::orientUp(normal); |
| 219 | else if (m_args->orientation == NormalOrientation::Down) |
| 220 | if (normal(2) > 0) normal = -normal; |
| 221 | |
| 222 | Eigen::Vector3d radius(m_args->cylRadius, m_args->cylRadius, m_args->cylRadius); |
| 223 | Eigen::Vector3d end1 = core + (normal * m_args->cylHalfLen); |
| 224 | Eigen::Vector3d end2 = core - (normal * m_args->cylHalfLen); |
| 225 | Eigen::Vector3d c1 = end1 + radius; |
| 226 | Eigen::Vector3d c2 = end1 - radius; |
| 227 | Eigen::Vector3d c3 = end2 + radius; |
| 228 | Eigen::Vector3d c4 = end2 - radius; |
| 229 | BOX2D box; |
| 230 | box.grow(c1(0), c1(1)); |
| 231 | box.grow(c2(0), c2(1)); |
| 232 | box.grow(c3(0), c3(1)); |
| 233 | box.grow(c4(0), c4(1)); |
| 234 | |
| 235 | PointIdList pts = g1.findNeighbors(box); |
| 236 | std::vector<double> dists1 = filterPoints(core, normal, g1.view(), pts); |
| 237 |
nothing calls this directly
no test coverage detected