39 #ifndef PCL_SURFACE_IMPL_MARCHING_CUBES_RBF_H_
40 #define PCL_SURFACE_IMPL_MARCHING_CUBES_RBF_H_
42 #include <pcl/surface/marching_cubes_rbf.h>
45 template <
typename Po
intNT>
49 template <
typename Po
intNT>
void
53 const auto N =
static_cast<unsigned int> (input_->size ());
54 Eigen::MatrixXd M (2*N, 2*N),
57 for (
unsigned int row_i = 0; row_i < 2*N; ++row_i)
60 bool row_off = (row_i >= N);
61 for (
unsigned int col_i = 0; col_i < 2*N; ++col_i)
64 bool col_off = (col_i >= N);
65 M (row_i, col_i) =
kernel (Eigen::Vector3f ((*input_)[col_i%N].getVector3fMap ()).cast<double> () + Eigen::Vector3f ((*input_)[col_i%N].getNormalVector3fMap ()).cast<double> () * col_off * off_surface_epsilon_,
66 Eigen::Vector3f ((*input_)[row_i%N].getVector3fMap ()).cast<double> () + Eigen::Vector3f ((*input_)[row_i%N].getNormalVector3fMap ()).cast<double> () * row_off * off_surface_epsilon_);
69 d (row_i, 0) = row_off * off_surface_epsilon_;
73 Eigen::MatrixXd w (2*N, 1);
76 w = M.fullPivLu ().solve (d);
78 std::vector<double> weights (2*N);
79 std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > centers (2*N);
80 for (
unsigned int i = 0; i < N; ++i)
82 centers[i] = Eigen::Vector3f ((*input_)[i].getVector3fMap ()).cast<
double> ();
83 centers[i + N] = Eigen::Vector3f ((*input_)[i].getVector3fMap ()).cast<
double> () + Eigen::Vector3f ((*input_)[i].getNormalVector3fMap ()).cast<double> () * off_surface_epsilon_;
84 weights[i] = w (i, 0);
85 weights[i + N] = w (i + N, 0);
88 for (
int x = 0; x < res_x_; ++x)
89 for (
int y = 0; y < res_y_; ++y)
90 for (
int z = 0; z < res_z_; ++z)
92 const Eigen::Vector3f point_f = (size_voxel_ * Eigen::Array3f (x, y, z)
93 + lower_boundary_).matrix ();
94 const Eigen::Vector3d point = point_f.cast<
double> ();
97 auto w_it (weights.cbegin());
98 for (
auto c_it = centers.cbegin ();
99 c_it != centers.cend (); ++c_it, ++w_it)
100 f += *w_it *
kernel (*c_it, point);
102 grid_[x * res_y_*res_z_ + y * res_z_ + z] =
static_cast<float>(f);
107 template <
typename Po
intNT>
double
110 double r = (x - c).norm ();
114 #define PCL_INSTANTIATE_MarchingCubesRBF(T) template class PCL_EXPORTS pcl::MarchingCubesRBF<T>;
void voxelizeData() override
Convert the point cloud into voxel data.
double kernel(Eigen::Vector3d c, Eigen::Vector3d x)
the Radial Basis Function kernel.
~MarchingCubesRBF() override
Destructor.