Commit dc93112c authored by remi cresson's avatar remi cresson

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

parent 84c4d6fd
//#include "lsgrmGraphOperations.h"
#include <unistd.h>
//#include <unistd.h>
#include <cstdio>
namespace lsgrm
{
......@@ -836,9 +837,9 @@ void ReadGraph(TSegmenter& segmenter,
const std::string& nodesPath,
const std::string& edgesPath)
{
FILE * nodeStream = fopen(nodesPath.c_str(), "r");
FILE * nodeStream = fopen(nodesPath.c_str(), "rb");
assert(nodeStream != NULL);
FILE * edgeStream = fopen(edgesPath.c_str(), "r");
FILE * edgeStream = fopen(edgesPath.c_str(), "rb");
assert(edgeStream != NULL);
segmenter.ReadGraph(nodeStream, edgeStream);
......
......@@ -87,12 +87,13 @@ public:
std::size_t contourSize = node->m_Contour.size();
fwrite(&(contourSize), sizeof(contourSize), 1, nodeStream);
short moves[contourSize];
std::vector<short> moves;
moves.reserve(contourSize);
for(unsigned int b = 0; b < contourSize; 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:
{
std::size_t contourSize;
fread(&(contourSize), sizeof(contourSize), 1, nodeStream);
short moves[contourSize];
fread(&moves, sizeof(short), contourSize, nodeStream);
std::vector<short> moves;
moves.reserve(contourSize);
fread(&moves.front(), sizeof(short), contourSize, nodeStream);
for(unsigned int b = 0; b < contourSize; b++)
{
node->m_Contour.push_back(moves[b]);
......@@ -236,7 +238,3 @@ public:
} // end of namespace lsgrm
#endif
Markdown is supported
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