Skip to content

Commit

Permalink
add error check
Browse files Browse the repository at this point in the history
  • Loading branch information
unlclearness committed Apr 9, 2019
1 parent 3331814 commit e12c2d3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vacancy/voxel_carver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ VoxelGrid::~VoxelGrid() {}

bool VoxelGrid::Init(const Eigen::Vector3f& bb_max,
const Eigen::Vector3f& bb_min, float resolution) {
if (resolution < 0) {
if (resolution < std::numeric_limits<float>::min()) {
LOGE("resolution must be positive %f\n", resolution);
return false;
}
Expand All @@ -199,6 +199,12 @@ bool VoxelGrid::Init(const Eigen::Vector3f& bb_max,
voxel_num_[i] = static_cast<int>(diff[i] / resolution_);
}

if (voxel_num_.x() * voxel_num_.y() * voxel_num_.z() >
std::numeric_limits<int>::max()) {
LOGE("too many voxels\n");
return false;
}

xy_slice_num_ = voxel_num_[0] * voxel_num_[1];

voxels_.clear();
Expand Down

0 comments on commit e12c2d3

Please sign in to comment.