Skip to content

Commit d4f7e1d

Browse files
committed
correctly adding invalid voxels for visualization.
1 parent 9d84777 commit d4f7e1d

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

assets/settings.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
max scans: 100
22
min range: 2.5
33
max range: 25.0
4-
ignore: 0,250,251,252,253,254
4+
ignore: [0,250,251,252,253,254]
55

66

src/data/VoxelGrid.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ bool VoxelGrid::isOccluded(int32_t i, int32_t j, int32_t k) const { return occlu
6363
bool VoxelGrid::isFree(int32_t i, int32_t j, int32_t k) const { return occlusions_[index(i, j, k)] == -1; }
6464

6565
bool VoxelGrid::isInvalid(int32_t i, int32_t j, int32_t k) const {
66-
return (invalid_[index(i, j, k)] > -1) && (invalid_[index(i, j, k)] == index(i, j, k));
66+
if (int32_t(invalid_.size()) < index(i, j, k)) return true;
67+
68+
return (invalid_[index(i, j, k)] > -1) && (invalid_[index(i, j, k)] != index(i, j, k));
6769
}
6870

6971
void VoxelGrid::insertOcclusionLabels() {
@@ -101,6 +103,8 @@ void VoxelGrid::updateOcclusions() {
101103
}
102104

103105
void VoxelGrid::updateInvalid(const Eigen::Vector3f& position) {
106+
if (!occlusionsValid_) updateOcclusions();
107+
104108
for (uint32_t x = 0; x < sizex_; ++x) {
105109
for (uint32_t y = 0; y < sizey_; ++y) {
106110
for (uint32_t z = 0; z < sizez_; ++z) {

src/widget/Mainframe.cpp

+15-17
Original file line numberDiff line numberDiff line change
@@ -323,29 +323,27 @@ void Mainframe::updateOccludedVoxels() {
323323
}
324324

325325
void Mainframe::updateInvalidVoxels() {
326-
if (invalidVoxels_.size() > 0) {
327-
std::vector<LabeledVoxel> voxels;
326+
std::vector<LabeledVoxel> voxels;
328327

329-
float voxelSize = pastVoxelGrid_.resolution();
330-
Eigen::Vector4f offset = pastVoxelGrid_.offset();
328+
float voxelSize = pastVoxelGrid_.resolution();
329+
Eigen::Vector4f offset = pastVoxelGrid_.offset();
331330

332-
for (uint32_t x = 0; x < pastVoxelGrid_.size(0); ++x) {
333-
for (uint32_t y = 0; y < pastVoxelGrid_.size(1); ++y) {
334-
for (uint32_t z = 0; z < pastVoxelGrid_.size(2); ++z) {
335-
if (!pastVoxelGrid_.isInvalid(x, y, z)) continue;
331+
for (uint32_t x = 0; x < pastVoxelGrid_.size(0); ++x) {
332+
for (uint32_t y = 0; y < pastVoxelGrid_.size(1); ++y) {
333+
for (uint32_t z = 0; z < pastVoxelGrid_.size(2); ++z) {
334+
if (!pastVoxelGrid_.isInvalid(x, y, z)) continue;
336335

337-
LabeledVoxel lv;
338-
Eigen::Vector4f pos =
339-
offset + Eigen::Vector4f(x * voxelSize + 0.1, y * voxelSize + 0.1, z * voxelSize + 0.1, 0.0f);
340-
lv.position = vec3(pos.x(), pos.y(), pos.z());
341-
lv.label = 11;
342-
voxels.push_back(lv);
343-
}
336+
LabeledVoxel lv;
337+
Eigen::Vector4f pos =
338+
offset + Eigen::Vector4f(x * voxelSize + 0.1, y * voxelSize + 0.1, z * voxelSize + 0.1, 0.0f);
339+
lv.position = vec3(pos.x(), pos.y(), pos.z());
340+
lv.label = 11;
341+
voxels.push_back(lv);
344342
}
345343
}
346-
347-
ui.mViewportXYZ->setInvalidVoxels(voxels);
348344
}
345+
346+
ui.mViewportXYZ->setInvalidVoxels(voxels);
349347
}
350348

351349
void Mainframe::extractLabeledVoxels(const VoxelGrid& grid, std::vector<LabeledVoxel>& labeledVoxels) {

0 commit comments

Comments
 (0)