Commit dc93112c authored by remi cresson's avatar remi cresson
Browse files

FIX: Win32/64 bugfix provided by Raffaele Gaetano (CIRAD)

Showing with 10 additions and 11 deletions
+10 -11
//#include "lsgrmGraphOperations.h" //#include "lsgrmGraphOperations.h"
#include <unistd.h> //#include <unistd.h>
#include <cstdio>
namespace lsgrm namespace lsgrm
{ {
...@@ -836,9 +837,9 @@ void ReadGraph(TSegmenter& segmenter, ...@@ -836,9 +837,9 @@ void ReadGraph(TSegmenter& segmenter,
const std::string& nodesPath, const std::string& nodesPath,
const std::string& edgesPath) const std::string& edgesPath)
{ {
FILE * nodeStream = fopen(nodesPath.c_str(), "r"); FILE * nodeStream = fopen(nodesPath.c_str(), "rb");
assert(nodeStream != NULL); assert(nodeStream != NULL);
FILE * edgeStream = fopen(edgesPath.c_str(), "r"); FILE * edgeStream = fopen(edgesPath.c_str(), "rb");
assert(edgeStream != NULL); assert(edgeStream != NULL);
segmenter.ReadGraph(nodeStream, edgeStream); segmenter.ReadGraph(nodeStream, edgeStream);
......
...@@ -87,12 +87,13 @@ public: ...@@ -87,12 +87,13 @@ public:
std::size_t contourSize = node->m_Contour.size(); std::size_t contourSize = node->m_Contour.size();
fwrite(&(contourSize), sizeof(contourSize), 1, nodeStream); fwrite(&(contourSize), sizeof(contourSize), 1, nodeStream);
short moves[contourSize]; std::vector<short> moves;
moves.reserve(contourSize);
for(unsigned int b = 0; b < contourSize; b++) for(unsigned int b = 0; b < contourSize; b++)
{ {
moves[b] = node->m_Contour[b]; moves[b] = node->m_Contour[b];
} }
fwrite(moves, sizeof(short), contourSize, nodeStream); fwrite(&moves.front(), sizeof(short), contourSize, nodeStream);
} }
/* /*
...@@ -135,8 +136,9 @@ public: ...@@ -135,8 +136,9 @@ public:
{ {
std::size_t contourSize; std::size_t contourSize;
fread(&(contourSize), sizeof(contourSize), 1, nodeStream); fread(&(contourSize), sizeof(contourSize), 1, nodeStream);
short moves[contourSize]; std::vector<short> moves;
fread(&moves, sizeof(short), contourSize, nodeStream); moves.reserve(contourSize);
fread(&moves.front(), sizeof(short), contourSize, nodeStream);
for(unsigned int b = 0; b < contourSize; b++) for(unsigned int b = 0; b < contourSize; b++)
{ {
node->m_Contour.push_back(moves[b]); node->m_Contour.push_back(moves[b]);
...@@ -236,7 +238,3 @@ public: ...@@ -236,7 +238,3 @@ public:
} // end of namespace lsgrm } // end of namespace lsgrm
#endif #endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment