|
@@ -78,8 +78,13 @@ IGL_INLINE bool igl::readDMAT(const std::string file_name,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- // Resize output to fit matrix
|
|
|
- W.resize(num_rows,num_cols);
|
|
|
+ // Resize output to fit matrix, only if non-empty since this will trigger an
|
|
|
+ // error on fixed size matrices before reaching binary data.
|
|
|
+ bool empty = num_rows == 0 || num_cols == 0;
|
|
|
+ if(!empty)
|
|
|
+ {
|
|
|
+ W.resize(num_rows,num_cols);
|
|
|
+ }
|
|
|
|
|
|
// Loop over columns slowly
|
|
|
for(int j = 0;j < num_cols;j++)
|
|
@@ -119,6 +124,14 @@ IGL_INLINE bool igl::readDMAT(const std::string file_name,
|
|
|
W(i,j) = Wraw[j*num_rows+i];
|
|
|
}
|
|
|
}
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ // we skipped resizing before in case there was binary data
|
|
|
+ if(empty)
|
|
|
+ {
|
|
|
+ // This could trigger an error if using fixed size matrices.
|
|
|
+ W.resize(num_rows,num_cols);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
fclose(fp);
|