19 #ifndef SNARK_PERCEPTION_VOXELGRID_HEADER_GUARD
20 #define SNARK_PERCEPTION_VOXELGRID_HEADER_GUARD
24 #include <boost/none_t.hpp>
26 #include <boost/optional.hpp>
27 #include <snark/math/interval.h>
28 #include <snark/point_cloud/impl/pin_screen.h>
36 template <
typename V = boost::none_t,
typename P = Eigen::Vector3d >
53 ,
bool adjusted =
false );
62 index_type
index_of(
const point_type& p )
const;
65 bool covers(
const point_type& p )
const;
68 voxel_type*
touch_at(
const point_type& d );
71 void erase_at(
const point_type& p );
74 point_type
origin(
const index_type& i )
const;
77 point_type
origin_at(
const point_type& p )
const;
80 const column_type*
column(
const point_type& p )
const;
90 point_type resolution_;
95 template <
typename P >
101 template <
typename P >
102 inline static Eigen::Matrix< std::size_t, 1, 2 > size(
const math::closed_interval< typename P::Scalar, P::RowsAtCompileTime >& e,
const P& r,
bool adjusted =
true )
104 math::closed_interval< typename P::Scalar, P::RowsAtCompileTime > f = extents( e, r, adjusted );
105 P diff = f.max() - f.min();
106 return Eigen::Matrix< std::size_t, 1, 2 >( std::ceil( diff.x() / r.x() ), std::ceil( diff.y() / r.y() ) );
111 template <
typename V,
typename P >
113 ,
const typename voxel_grid< V, P >::point_type& resolution
115 :
pin_screen< V >( detail::size( extents, resolution, adjusted ) )
116 , extents_( detail::extents( extents, resolution, adjusted ) )
117 , resolution_( resolution )
121 template <
typename V,
typename P >
124 template <
typename V,
typename P >
127 template <
typename V,
typename P >
130 return index_type( std::floor( ( p.x() - extents_.min().x() ) / resolution_.x() )
131 , std::floor( ( p.y() - extents_.min().y() ) / resolution_.y() )
132 , std::floor( ( p.z() - extents_.min().z() ) / resolution_.z() ) );
135 template <
typename V,
typename P >
138 return extents_.contains( p );
141 template <
typename V,
typename P >
144 if( !covers( p ) ) {
return NULL; }
145 const index_type& i = index_of( p );
149 template <
typename V,
typename P >
152 if( !covers( point ) ) {
return; }
156 template <
typename V,
typename P >
159 P p( resolution_[0] * i[0], resolution_[1] * i[1], resolution_[2] * i[2] );
160 return extents_.min() + p;
163 template <
typename V,
typename P >
166 return origin( index_of( p ) );
169 template <
typename V,
typename P >
172 if( !covers( p ) ) {
return NULL; }
173 index_type index = index_of( p );
187 #endif // SNARK_PERCEPTION_VOXELGRID_HEADER_GUARD