|
37 | 37 | */ |
38 | 38 |
|
39 | 39 |
|
40 | | -// This is a plugin is meant to read simple text files with pure data |
41 | | -// in ascii format into a SCIRun matrix. |
42 | | - |
| 40 | +#include <Core/ImportExport/Matrix/MatrixIEPlugin.h> |
| 41 | +#include <Core/IEPlugin/EcgsimFileToMatrix_Plugin.h> |
| 42 | +#include <Core/Datatypes/DenseMatrix.h> |
| 43 | +#include <Core/Datatypes/MatrixTypeConversions.h> |
| 44 | +#include <Core/Utils/Legacy/StringUtil.h> |
| 45 | +#include <Core/Logging/LoggerInterface.h> |
43 | 46 | #include <Core/ImportExport/Matrix/MatrixIEPlugin.h> |
44 | 47 | #include <Core/Datatypes/DenseMatrix.h> |
45 | 48 |
|
46 | 49 | #include <iostream> |
47 | 50 | #include <fstream> |
48 | 51 | #include <sstream> |
49 | 52 |
|
50 | | -namespace SCIRun { |
51 | | - |
52 | | -MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename); |
53 | | -bool EcgsimFileMatrix_writer(ProgressReporter *pr, MatrixHandle matrix, const char *filename); |
| 53 | +using namespace SCIRun; |
| 54 | +using namespace SCIRun::Core; |
| 55 | +using namespace SCIRun::Core::Logging; |
| 56 | +using namespace SCIRun::Core::Datatypes; |
54 | 57 |
|
55 | | -MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename) |
| 58 | +MatrixHandle SCIRun::EcgsimFileMatrix_reader(LoggerHandle pr, const char *filename) |
56 | 59 | { |
57 | | - MatrixHandle result; |
| 60 | + DenseMatrixHandle result; |
58 | 61 |
|
59 | 62 | int ncols = 0; |
60 | 63 | int nrows = 0; |
@@ -154,14 +157,14 @@ MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename) |
154 | 157 | std::ifstream inputfile; |
155 | 158 | inputfile.exceptions( std::ifstream::badbit ); |
156 | 159 |
|
157 | | - result = new DenseMatrix(header_rows,header_cols); |
158 | | - if (result.get_rep() == 0) |
| 160 | + result.reset(new DenseMatrix(header_rows,header_cols)); |
| 161 | + if (!result) |
159 | 162 | { |
160 | 163 | if (pr) pr->error("Could not allocate matrix"); |
161 | 164 | return(result); |
162 | 165 | } |
163 | 166 |
|
164 | | - double* dataptr = result->get_data_pointer(); |
| 167 | + double* dataptr = result->data(); |
165 | 168 | int k = 0; |
166 | 169 |
|
167 | 170 | try |
@@ -211,23 +214,22 @@ MatrixHandle EcgsimFileMatrix_reader(ProgressReporter *pr, const char *filename) |
211 | 214 | } |
212 | 215 |
|
213 | 216 |
|
214 | | -bool EcgsimFileMatrix_writer(ProgressReporter *pr, MatrixHandle matrix, const char *filename) |
| 217 | +bool SCIRun::EcgsimFileMatrix_writer(LoggerHandle pr, MatrixHandle matrixInput, const char *filename) |
215 | 218 | { |
216 | 219 |
|
217 | 220 | std::ofstream outputfile; |
218 | 221 | outputfile.exceptions( std::ofstream::failbit | std::ofstream::badbit ); |
219 | 222 |
|
220 | | - MatrixHandle temp = matrix->dense(); |
221 | | - matrix = temp; |
| 223 | + DenseMatrixHandle matrix = matrix_cast::as_dense(matrixInput); |
222 | 224 |
|
223 | | - if (matrix.get_rep() == 0) |
| 225 | + if (!matrix) |
224 | 226 | { |
225 | 227 | if (pr) pr->error("Empty matrix detected"); |
226 | 228 | return(false); |
227 | 229 | } |
228 | 230 |
|
229 | | - double* dataptr = matrix->get_data_pointer(); |
230 | | - if (dataptr == 0) |
| 231 | + double* dataptr = matrix->data(); |
| 232 | + if (!dataptr) |
231 | 233 | { |
232 | 234 | if (pr) pr->error("Empty matrix detected"); |
233 | 235 | return(false); |
@@ -261,7 +263,5 @@ bool EcgsimFileMatrix_writer(ProgressReporter *pr, MatrixHandle matrix, const ch |
261 | 263 | return (true); |
262 | 264 | } |
263 | 265 |
|
264 | | -static MatrixIEPlugin EcgsimFileMatrix_plugin("ECGSimFile","", "",EcgsimFileMatrix_reader,EcgsimFileMatrix_writer); |
265 | 266 |
|
266 | | -} // end namespace |
267 | 267 |
|
0 commit comments