[cig-commits] r13489 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Tue Dec 9 18:12:25 PST 2008
Author: luis
Date: 2008-12-09 18:12:25 -0800 (Tue, 09 Dec 2008)
New Revision: 13489
Modified:
cs/cigma/trunk/src/io_text_reader.cpp
Log:
Use only one file source in TextReader
Modified: cs/cigma/trunk/src/io_text_reader.cpp
===================================================================
--- cs/cigma/trunk/src/io_text_reader.cpp 2008-12-10 02:12:22 UTC (rev 13488)
+++ cs/cigma/trunk/src/io_text_reader.cpp 2008-12-10 02:12:25 UTC (rev 13489)
@@ -50,6 +50,7 @@
// ----------------------------------------------------------------------------
// XXX: rethink this method (usage is awkward...see unit tests)
+/*
static FILE *get_fp(const char *loc, FILE *default_fp)
{
FILE *fp = default_fp;
@@ -58,11 +59,11 @@
fp = fopen(loc, "r");
}
return fp;
-}
+} */
static bool read_dmat(FILE *fp, double **mat, int *rows, int *cols)
{
- assert(fp != NULL);
+ if (fp == NULL) { return false; }
int nrows, ncols;
int ret;
@@ -96,7 +97,7 @@
static bool read_imat(FILE *fp, int **mat, int *rows, int *cols)
{
- assert(fp != NULL);
+ if (fp == NULL) { return false; }
int nrows, ncols;
int ret;
@@ -131,10 +132,9 @@
int TextReader::getDataset(const char *loc, double **data, int *num, int *dim)
{
- FILE *loc_fp = get_fp(loc, fp);
- if (loc_fp != NULL)
+ if (fp != NULL)
{
- read_dmat(loc_fp, data, num, dim);
+ read_dmat(fp, data, num, dim);
return 0;
}
return -1;
@@ -143,12 +143,9 @@
int TextReader::getConnectivity(const char *loc, int **connectivity, int *nel, int *ndofs)
{
- // XXX: support for sections? (for reading coords/connectivity from single file)
- FILE *loc_fp = get_fp(loc, fp);
- assert(loc_fp != NULL);
- if (loc_fp != NULL)
+ if (fp != NULL)
{
- read_imat(loc_fp, connectivity, nel, ndofs);
+ read_imat(fp, connectivity, nel, ndofs);
return 0;
}
return -1;
@@ -156,11 +153,9 @@
int TextReader::getCoordinates(const char *loc, double **coordinates, int *nno, int *nsd)
{
- // XXX: support for sections? (for reading coords/connectivity from single file)
- FILE *loc_fp = get_fp(loc, fp);
- if (loc_fp != NULL)
+ if (fp != NULL)
{
- read_dmat(loc_fp, coordinates, nno, nsd);
+ read_dmat(fp, coordinates, nno, nsd);
return 0;
}
return -1;
More information about the CIG-COMMITS
mailing list