Skip to content

Commit 5531cf1

Browse files
committed
Ability to read from a general stream. Not just a file stream.
1 parent a7fa225 commit 5531cf1

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

voxblox/include/voxblox/io/layer_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ template <typename VoxelType>
3535
bool LoadBlocksFromStream(
3636
const size_t num_blocks,
3737
typename Layer<VoxelType>::BlockMergingStrategy strategy,
38-
std::fstream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
38+
std::istream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
3939
uint64_t* tmp_byte_offset_ptr);
4040

4141
/**

voxblox/include/voxblox/io/layer_io_inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ template <typename VoxelType>
104104
bool LoadBlocksFromStream(
105105
const size_t num_blocks,
106106
typename Layer<VoxelType>::BlockMergingStrategy strategy,
107-
std::fstream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
107+
std::istream* proto_file_ptr, Layer<VoxelType>* layer_ptr,
108108
uint64_t* tmp_byte_offset_ptr) {
109109
CHECK_NOTNULL(proto_file_ptr);
110110
CHECK_NOTNULL(layer_ptr);

voxblox/include/voxblox/mesh/marching_cubes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class MarchingCubes {
3636
public:
3737
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
3838

39-
static int kTriangleTable[256][16];
40-
static int kEdgeIndexPairs[12][2];
39+
static const int kTriangleTable[256][16];
40+
static const int kEdgeIndexPairs[12][2];
4141

4242
MarchingCubes() {}
4343
virtual ~MarchingCubes() {}

voxblox/include/voxblox/utils/protobuf_utils.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define VOXBLOX_UTILS_PROTOBUF_UTILS_H_
33

44
#include <fstream>
5+
#include <istream>
56

67
#include <glog/logging.h>
78
#include <google/protobuf/message.h>
@@ -10,14 +11,14 @@
1011
namespace voxblox {
1112

1213
namespace utils {
13-
bool readProtoMsgCountFromStream(std::fstream* stream_in,
14+
bool readProtoMsgCountFromStream(std::istream* stream_in,
1415
uint32_t* message_count,
1516
uint64_t* byte_offset);
1617

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

20-
bool readProtoMsgFromStream(std::fstream* stream_in,
21+
bool readProtoMsgFromStream(std::istream* stream_in,
2122
google::protobuf::Message* message,
2223
uint64_t* byte_offset);
2324

voxblox/src/mesh/marching_cubes.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace voxblox {
2626
// Lookup table from the 256 possible cube configurations from
2727
// CalculateVertexConfigurationIndex() to the 0-5 triplets the give the edges
2828
// where the triangle vertices lie.
29-
int MarchingCubes::kTriangleTable[256][16] = {
29+
const int MarchingCubes::kTriangleTable[256][16] = {
3030
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
3131
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
3232
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
@@ -286,8 +286,8 @@ int MarchingCubes::kTriangleTable[256][16] = {
286286

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

293293
} // namespace voxblox

voxblox/src/utils/protobuf_utils.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
namespace voxblox {
88

99
namespace utils {
10-
bool readProtoMsgCountFromStream(std::fstream* stream_in,
10+
bool readProtoMsgCountFromStream(std::istream* stream_in,
1111
uint32_t* message_count,
1212
uint64_t* byte_offset) {
1313
CHECK_NOTNULL(stream_in);
1414
CHECK_NOTNULL(message_count);
1515
CHECK_NOTNULL(byte_offset);
16-
CHECK(stream_in->is_open());
1716
stream_in->clear();
1817
stream_in->seekg(*byte_offset, std::ios::beg);
1918
google::protobuf::io::IstreamInputStream raw_in(stream_in);
@@ -38,13 +37,12 @@ bool writeProtoMsgCountToStream(uint32_t message_count,
3837
return true;
3938
}
4039

41-
bool readProtoMsgFromStream(std::fstream* stream_in,
40+
bool readProtoMsgFromStream(std::istream* stream_in,
4241
google::protobuf::Message* message,
4342
uint64_t* byte_offset) {
4443
CHECK_NOTNULL(stream_in);
4544
CHECK_NOTNULL(message);
4645
CHECK_NOTNULL(byte_offset);
47-
CHECK(stream_in->is_open());
4846

4947
stream_in->clear();
5048
stream_in->seekg(*byte_offset, std::ios::beg);

0 commit comments

Comments
 (0)