Skip to content

Commit

Permalink
Ability to read from a general stream. Not just a file stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmillane committed Jul 28, 2020
1 parent a7fa225 commit 5531cf1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion voxblox/include/voxblox/io/layer_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ template <typename VoxelType>
bool LoadBlocksFromStream(
const size_t num_blocks,
typename Layer<VoxelType>::BlockMergingStrategy strategy,
std::fstream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
std::istream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
uint64_t* tmp_byte_offset_ptr);

/**
Expand Down
2 changes: 1 addition & 1 deletion voxblox/include/voxblox/io/layer_io_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ template <typename VoxelType>
bool LoadBlocksFromStream(
const size_t num_blocks,
typename Layer<VoxelType>::BlockMergingStrategy strategy,
std::fstream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
std::istream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
uint64_t* tmp_byte_offset_ptr) {
CHECK_NOTNULL(proto_file_ptr);
CHECK_NOTNULL(layer_ptr);
Expand Down
4 changes: 2 additions & 2 deletions voxblox/include/voxblox/mesh/marching_cubes.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class MarchingCubes {
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

static int kTriangleTable[256][16];
static int kEdgeIndexPairs[12][2];
static const int kTriangleTable[256][16];
static const int kEdgeIndexPairs[12][2];

MarchingCubes() {}
virtual ~MarchingCubes() {}
Expand Down
5 changes: 3 additions & 2 deletions voxblox/include/voxblox/utils/protobuf_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define VOXBLOX_UTILS_PROTOBUF_UTILS_H_

#include <fstream>
#include <istream>

#include <glog/logging.h>
#include <google/protobuf/message.h>
Expand All @@ -10,14 +11,14 @@
namespace voxblox {

namespace utils {
bool readProtoMsgCountFromStream(std::fstream* stream_in,
bool readProtoMsgCountFromStream(std::istream* stream_in,
uint32_t* message_count,
uint64_t* byte_offset);

bool writeProtoMsgCountToStream(uint32_t message_count,
std::fstream* stream_out);

bool readProtoMsgFromStream(std::fstream* stream_in,
bool readProtoMsgFromStream(std::istream* stream_in,
google::protobuf::Message* message,
uint64_t* byte_offset);

Expand Down
8 changes: 4 additions & 4 deletions voxblox/src/mesh/marching_cubes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace voxblox {
// Lookup table from the 256 possible cube configurations from
// CalculateVertexConfigurationIndex() to the 0-5 triplets the give the edges
// where the triangle vertices lie.
int MarchingCubes::kTriangleTable[256][16] = {
const int MarchingCubes::kTriangleTable[256][16] = {
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
Expand Down Expand Up @@ -286,8 +286,8 @@ int MarchingCubes::kTriangleTable[256][16] = {

// Lookup table from the 12 cube edge indices to their corresponding corner
// indices.
int MarchingCubes::kEdgeIndexPairs[12][2] = {{0, 1}, {1, 2}, {2, 3}, {3, 0},
{4, 5}, {5, 6}, {6, 7}, {7, 4},
{0, 4}, {1, 5}, {2, 6}, {3, 7}};
const int MarchingCubes::kEdgeIndexPairs[12][2] = {
{0, 1}, {1, 2}, {2, 3}, {3, 0}, {4, 5}, {5, 6},
{6, 7}, {7, 4}, {0, 4}, {1, 5}, {2, 6}, {3, 7}};

} // namespace voxblox
6 changes: 2 additions & 4 deletions voxblox/src/utils/protobuf_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
namespace voxblox {

namespace utils {
bool readProtoMsgCountFromStream(std::fstream* stream_in,
bool readProtoMsgCountFromStream(std::istream* stream_in,
uint32_t* message_count,
uint64_t* byte_offset) {
CHECK_NOTNULL(stream_in);
CHECK_NOTNULL(message_count);
CHECK_NOTNULL(byte_offset);
CHECK(stream_in->is_open());
stream_in->clear();
stream_in->seekg(*byte_offset, std::ios::beg);
google::protobuf::io::IstreamInputStream raw_in(stream_in);
Expand All @@ -38,13 +37,12 @@ bool writeProtoMsgCountToStream(uint32_t message_count,
return true;
}

bool readProtoMsgFromStream(std::fstream* stream_in,
bool readProtoMsgFromStream(std::istream* stream_in,
google::protobuf::Message* message,
uint64_t* byte_offset) {
CHECK_NOTNULL(stream_in);
CHECK_NOTNULL(message);
CHECK_NOTNULL(byte_offset);
CHECK(stream_in->is_open());

stream_in->clear();
stream_in->seekg(*byte_offset, std::ios::beg);
Expand Down

0 comments on commit 5531cf1

Please sign in to comment.