36 #ifndef PCL_SURFACE_IMPL_MARCHING_CUBES_RBF_H_
37 #define PCL_SURFACE_IMPL_MARCHING_CUBES_RBF_H_
46 template <
typename Po
intNT>
49 off_surface_epsilon_ (0.1f)
54 template <
typename Po
intNT>
61 template <
typename Po
intNT>
void
65 unsigned int N =
static_cast<unsigned int> (input_->size ());
66 Eigen::MatrixXd M (2*N, 2*N),
70 for (
unsigned int row_i = 0; row_i < 2*N; ++row_i)
73 bool row_off = (row_i >= N) ? 1 : 0;
74 for (
unsigned int col_i = 0; col_i < 2*N; ++col_i)
77 bool col_off = (col_i >= N) ? 1 : 0;
78 M (row_i, col_i) = kernel (Eigen::Vector3f (input_->points[col_i%N].getVector3fMap ()).cast<double> () + Eigen::Vector3f (input_->points[col_i%N].getNormalVector3fMap ()).cast<double> () * col_off * off_surface_epsilon_,
79 Eigen::Vector3f (input_->points[row_i%N].getVector3fMap ()).cast<double> () + Eigen::Vector3f (input_->points[row_i%N].getNormalVector3fMap ()).cast<double> () * row_off * off_surface_epsilon_);
82 d (row_i, 0) = row_off * off_surface_epsilon_;
86 Eigen::MatrixXd w (2*N, 1);
89 w = M.fullPivLu ().solve (d);
91 std::vector<double> weights (2*N);
92 std::vector<Eigen::Vector3d> centers (2*N);
93 for (
unsigned int i = 0; i < N; ++i)
95 centers[i] = Eigen::Vector3f (input_->points[i].getVector3fMap ()).cast<double> ();
96 centers[i + N] = Eigen::Vector3f (input_->points[i].getVector3fMap ()).cast<double> () + Eigen::Vector3f (input_->points[i].getNormalVector3fMap ()).cast<double> () * off_surface_epsilon_;
97 weights[i] = w (i, 0);
98 weights[i + N] = w (i + N, 0);
103 for (
int x = 0; x < res_x_; ++x)
104 for (
int y = 0; y < res_y_; ++y)
105 for (
int z = 0; z < res_z_; ++z)
107 Eigen::Vector3d point;
108 point[0] = min_p_[0] + (max_p_[0] - min_p_[0]) * x / res_x_;
109 point[1] = min_p_[1] + (max_p_[1] - min_p_[1]) * y / res_y_;
110 point[2] = min_p_[2] + (max_p_[2] - min_p_[2]) * z / res_z_;
113 std::vector<double>::const_iterator w_it (weights.begin());
114 for (std::vector<Eigen::Vector3d>::const_iterator c_it = centers.begin ();
115 c_it != centers.end (); ++c_it, ++w_it)
116 f += *w_it * kernel (*c_it, point);
118 grid_[x * res_y_*res_z_ + y * res_z_ + z] = f;
123 template <
typename Po
intNT>
double
126 double r = (x - c).norm();
132 #define PCL_INSTANTIATE_MarchingCubesRBF(T) template class PCL_EXPORTS pcl::MarchingCubesRBF<T>;
134 #endif // PCL_SURFACE_IMPL_MARCHING_CUBES_HOPPE_H_