template <typename PointInT, typename PointOutT> void pcl::MovingLeastSquares<PointInT, PointOutT>::MLSVoxelGrid::dilate () { HashMap new_voxel_grid = voxel_grid_; for (typename MLSVoxelGrid::HashMap::iterator m_it = voxel_grid_.begin (); m_it != voxel_grid_.end (); ++m_it) { Eigen::Vector3i index; getIndexIn3D (m_it->first, index); // Now dilate all of its voxels for (int x = -1; x <= 1; ++x) for (int y = -1; y <= 1; ++y) for (int z = -1; z <= 1; ++z) if (x != 0 || y != 0 || z != 0) { Eigen::Vector3i new_index; new_index = index + Eigen::Vector3i (x, y, z); uint64_t index_1d; getIndexIn1D (new_index, index_1d); Leaf leaf; new_voxel_grid[index_1d] = leaf; } } voxel_grid_ = new_voxel_grid; }
// Go through the hash table another time to extract surface BOOST_FOREACH (typename HashMap::value_type entry, cell_hash_map_) { getIndexIn3D (entry.first, index); std::vector <int> pt_union_indices; getDataPtsUnion (index, pt_union_indices); // Needs at least 10 points (?) // NOTE: set as parameter later if (pt_union_indices.size () > 10) createSurfaceForCell (index, pt_union_indices); }
template <typename PointNT> bool pcl::GridProjection<PointNT>::reconstructPolygons (std::vector<pcl::Vertices> &polygons) { data_.reset (new pcl::PointCloud<PointNT> (*input_)); getBoundingBox (); // Store the point cloud data into the voxel grid, and at the same time // create a hash map to store the information for each cell cell_hash_map_.max_load_factor (2.0); cell_hash_map_.rehash (data_->points.size () / static_cast<long unsigned int> (cell_hash_map_.max_load_factor ())); // Go over all points and insert them into the right leaf for (int cp = 0; cp < static_cast<int> (data_->points.size ()); ++cp) { // Check if the point is invalid if (!pcl_isfinite (data_->points[cp].x) || !pcl_isfinite (data_->points[cp].y) || !pcl_isfinite (data_->points[cp].z)) continue; Eigen::Vector3i index_3d; getCellIndex (data_->points[cp].getVector4fMap (), index_3d); int index_1d = getIndexIn1D (index_3d); if (cell_hash_map_.find (index_1d) == cell_hash_map_.end ()) { Leaf cell_data; cell_data.data_indices.push_back (cp); getCellCenterFromIndex (index_3d, cell_data.pt_on_surface); cell_hash_map_[index_1d] = cell_data; occupied_cell_list_[index_1d] = 1; } else { Leaf cell_data = cell_hash_map_.at (index_1d); cell_data.data_indices.push_back (cp); cell_hash_map_[index_1d] = cell_data; } } Eigen::Vector3i index; int numOfFilledPad = 0; for (int i = 0; i < data_size_; ++i) { for (int j = 0; j < data_size_; ++j) { for (int k = 0; k < data_size_; ++k) { index[0] = i; index[1] = j; index[2] = k; if (occupied_cell_list_[getIndexIn1D (index)]) { fillPad (index); numOfFilledPad++; } } } } // Update the hashtable and store the vector and point BOOST_FOREACH (typename HashMap::value_type entry, cell_hash_map_) { getIndexIn3D (entry.first, index); std::vector <int> pt_union_indices; getDataPtsUnion (index, pt_union_indices); // Needs at least 10 points (?) // NOTE: set as parameter later if (pt_union_indices.size () > 10) { storeVectAndSurfacePoint (entry.first, index, pt_union_indices, entry.second); //storeVectAndSurfacePointKNN(entry.first, index, entry.second); occupied_cell_list_[entry.first] = 1; } }