Skip to content

Commit 0e6f53e

Browse files
committed
Enable other Nrrd readers
1 parent f2c9e9e commit 0e6f53e

File tree

7 files changed

+90
-100
lines changed

7 files changed

+90
-100
lines changed

src/Core/Algorithms/Legacy/Converter/ConverterAlgo.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,13 @@ bool ConverterAlgo::MatrixToField(MatrixHandle input, FieldHandle& output, const
620620
}
621621
#endif
622622

623-
bool ConverterAlgo::NrrdToField(NrrdDataHandle input, FieldHandle& output, const std::string& datalocation, const std::string& fieldtype, const std::string& convertparity)
623+
bool ConverterAlgo::nrrdToField(NrrdDataHandle input, FieldHandle& output, const std::string& datalocation, const std::string& fieldtype, const std::string& convertparity)
624624
{
625625
NrrdToFieldAlgo algo;
626626
return(algo.nrrdToField(pr_,input,output,datalocation,fieldtype,convertparity));
627627
}
628628

629-
bool ConverterAlgo::FieldToNrrd(FieldHandle input, NrrdDataHandle& output)
629+
bool ConverterAlgo::fieldToNrrd(FieldHandle input, NrrdDataHandle& output)
630630
{
631631
FieldToNrrdAlgo algo;
632632
return(algo.fieldToNrrd(pr_,input,output));
@@ -801,7 +801,7 @@ bool ConverterAlgo::MatrixToString(MatrixHandle input, StringHandle& output)
801801
}
802802
#endif
803803

804-
AlgorithmOutput ConverterAlgo::run_generic(const AlgorithmInput& input) const
804+
AlgorithmOutput ConverterAlgo::run_generic(const AlgorithmInput& input) const
805805
{
806806
throw "not implemented";
807-
}
807+
}

src/Core/Algorithms/Legacy/Converter/ConverterAlgo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class SCISHARE ConverterAlgo : public AlgorithmBase
8181
// datalocation specifies whether the data is "Node" or "Element" based
8282
bool MatrixToField(Datatypes::MatrixHandle input, FieldHandle& output, const std::string& datalocation);
8383
#endif
84-
bool NrrdToField(NrrdDataHandle input, FieldHandle& output, const std::string& datalocation = "Auto", const std::string& fieldtype = "Auto", const std::string& convertparity= "Make Right Hand Sided");
84+
bool nrrdToField(NrrdDataHandle input, FieldHandle& output, const std::string& datalocation = "Auto", const std::string& fieldtype = "Auto", const std::string& convertparity= "Make Right Hand Sided");
8585

86-
bool FieldToNrrd(FieldHandle input, NrrdDataHandle& output);
86+
bool fieldToNrrd(FieldHandle input, NrrdDataHandle& output);
8787

8888
#ifdef SCIRUN4_CODE_TO_BE_CONVERTER_LATER
8989
bool NrrdToMatrix(NrrdDataHandle input, Datatypes::MatrixHandle& output);

src/Core/Algorithms/Legacy/DataIO/DataIOAlgo.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ bool DataIOAlgo::ReadBundle(const std::string& filename, BundleHandle& bundle, c
143143
return (true);
144144
}
145145
#endif
146-
bool DataIOAlgo::ReadNrrd(const std::string& filename, NrrdDataHandle& nrrd, const std::string& importer)
146+
147+
bool DataIOAlgo::readNrrd(const std::string& filename, NrrdDataHandle& nrrd, const std::string& importer)
147148
{
148149
if (!importer.empty())
149150
{
@@ -423,7 +424,7 @@ bool DataIOAlgo::WriteBundle(const std::string& filename, BundleHandle& bundle,
423424
#endif
424425

425426

426-
bool DataIOAlgo::WriteNrrd(const std::string& filename, NrrdDataHandle nrrd, const std::string& exporter)
427+
bool DataIOAlgo::writeNrrd(const std::string& filename, NrrdDataHandle nrrd, const std::string& exporter)
427428
{
428429
if (!nrrd) return (false);
429430

src/Core/Algorithms/Legacy/DataIO/DataIOAlgo.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2009 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -34,7 +34,7 @@
3434
#include <Core/Datatypes/DatatypeFwd.h>
3535
#include <Core/Algorithms/Legacy/DataIO/share.h>
3636

37-
namespace SCIRun
37+
namespace SCIRun
3838
{
3939
namespace Core
4040
{
@@ -53,13 +53,13 @@ class SCISHARE DataIOAlgo : public AlgorithmBase {
5353
bool WriteMatrix(const std::string& filename, Datatypes::MatrixHandle matrix, const std::string& exporter = "");
5454
#endif
5555

56-
bool ReadNrrd(const std::string& filename, NrrdDataHandle& nrrd, const std::string& importer = "");
57-
bool WriteNrrd(const std::string& filename, NrrdDataHandle nrrd, const std::string& exporter = "");
56+
bool readNrrd(const std::string& filename, NrrdDataHandle& nrrd, const std::string& importer = "");
57+
bool writeNrrd(const std::string& filename, NrrdDataHandle nrrd, const std::string& exporter = "");
5858

5959
#ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
6060
bool ReadBundle(const std::string& filename, Datatypes::BundleHandle& bundle, const std::string& importer = "");
6161
bool WriteBundle(const std::string& filename, Datatypes::BundleHandle bundle, const std::string& exporter = "");
62-
62+
6363
bool ReadColorMap(const std::string& filename, Datatypes::ColorMapHandle& colorMap, const std::string& importer = "");
6464
bool WriteColorMap(const std::string& filename, Datatypes::ColorMapHandle colorMap, const std::string& exporter = "");
6565
#endif

src/Core/IEPlugin/IEPluginInit.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ void IEPluginManager::Initialize()
4343
{
4444
static FieldIEPluginLegacyAdapter ObjToField_plugin("ObjToField", "*.obj", "", ObjToField_reader, FieldToObj_writer);
4545

46-
static FieldIEPluginLegacyAdapter NrrdToField_plugin("NrrdFile","*.nhdr *.nrrd", "*.nrrd", NrrdToField_reader, FieldToNrrd_writer);
47-
// static FieldIEPluginLegacyAdapter NodalNrrdToField_plugin("NrrdFile[DataOnNodes]","{.nhdr} {.nrrd}", "", Nodal_NrrdToField_reader, 0);
48-
// static FieldIEPluginLegacyAdapter ModalNrrdToField_plugin("NrrdFile[DataOnElements]","{.nhdr} {.nrrd}", "", Modal_NrrdToField_reader, 0);
49-
// static FieldIEPluginLegacyAdapter IPNodalNrrdToField_plugin("NrrdFile[DataOnNodes,InvertParity]","{.nhdr} {.nrrd}", "", IPNodal_NrrdToField_reader, 0);
50-
// static FieldIEPluginLegacyAdapter IPModalNrrdToField_plugin("NrrdFile[DataOnElements,InvertParity]","{.nhdr} {.nrrd}", "", IPModal_NrrdToField_reader, 0);
46+
static FieldIEPluginLegacyAdapter NrrdToField_plugin("NrrdFile","*.nhdr *.nrrd", "*.nrrd", NrrdToField_reader, FieldToNrrd_writer);
47+
static FieldIEPluginLegacyAdapter NodalNrrdToField_plugin("NrrdFile[DataOnNodes]","*.nhdr *.nrrd", "", Nodal_NrrdToField_reader, 0);
48+
static FieldIEPluginLegacyAdapter ModalNrrdToField_plugin("NrrdFile[DataOnElements]","*.nhdr *.nrrd", "", Modal_NrrdToField_reader, 0);
49+
static FieldIEPluginLegacyAdapter IPNodalNrrdToField_plugin("NrrdFile[DataOnNodes,InvertParity]","*.nhdr *.nrrd", "", IPNodal_NrrdToField_reader, 0);
50+
static FieldIEPluginLegacyAdapter IPModalNrrdToField_plugin("NrrdFile[DataOnElements,InvertParity]","*.nhdr *.nrrd", "", IPModal_NrrdToField_reader, 0);
5151
}

src/Core/IEPlugin/NrrdField_Plugin.cc

Lines changed: 51 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Copyright (c) 2009 Scientific Computing and Imaging Institute,
88
University of Utah.
99
10-
10+
1111
Permission is hereby granted, free of charge, to any person obtaining a
1212
copy of this software and associated documentation files (the "Software"),
1313
to deal in the Software without restriction, including without limitation
@@ -36,139 +36,110 @@ using namespace SCIRun;
3636
using namespace SCIRun::Core::Logging;
3737
using namespace SCIRun::Core::Algorithms;
3838

39-
// This file contains readers for nrrds as fields. We currently have 5 variations
40-
// depending on whether data is defined on the nodes or the elements and what the
41-
// parity of the data is.
42-
//
43-
// Although these properties are defined in the nrrd file format, most nrrds are
44-
// annotated improperly and hence corrections have to made.
45-
46-
//// Default reader use the definitions in the nrrd
47-
//FieldHandle NrrdToField_reader(ProgressReporter *pr, const char *filename);
48-
//// Override the location settings and force data on the nodes
49-
//FieldHandle Nodal_NrrdToField_reader(ProgressReporter *pr, const char *filename);
50-
//// Override the location settings and force data on the elements
51-
//FieldHandle Modal_NrrdToField_reader(ProgressReporter *pr, const char *filename);
52-
//// Override the location settings and force data on the nodes and invert space parity
53-
//FieldHandle IPNodal_NrrdToField_reader(ProgressReporter *pr, const char *filename);
54-
//// Override the location settings and force data on the elements and invert space parity
55-
//FieldHandle IPModal_NrrdToField_reader(ProgressReporter *pr, const char *filename);
56-
//
57-
//// Default writer
58-
//bool FieldToNrrd_writer(ProgressReporter *pr, FieldHandle fh, const char *filename);
59-
6039
FieldHandle SCIRun::NrrdToField_reader(LoggerHandle pr, const char *filename)
6140
{
6241
FieldHandle field;
6342
NrrdDataHandle nrrd;
64-
43+
6544
DataIOAlgo dalgo(pr);
6645
ConverterAlgo calgo(pr);
6746

6847
std::string fn(filename);
69-
70-
if (dalgo.ReadNrrd(fn,nrrd))
48+
49+
if (dalgo.readNrrd(fn,nrrd))
7150
{
72-
calgo.NrrdToField(nrrd,field);
51+
calgo.nrrdToField(nrrd,field);
7352
}
74-
53+
7554
return (field);
7655
}
7756

7857
bool
7958
SCIRun::FieldToNrrd_writer(LoggerHandle pr, FieldHandle fh, const char *filename)
80-
{
59+
{
8160
FieldHandle field;
8261
NrrdDataHandle nrrd;
83-
62+
8463
DataIOAlgo dalgo(pr);
8564
ConverterAlgo calgo(pr);
8665

87-
if (calgo.FieldToNrrd(fh,nrrd))
66+
if (calgo.fieldToNrrd(fh,nrrd))
8867
{
8968
std::string fn(filename);
90-
return(dalgo.WriteNrrd(fn,nrrd));
69+
return dalgo.writeNrrd(fn,nrrd);
9170
}
92-
71+
9372
return (false);
9473
}
9574

96-
#ifdef SCIRUN4_ESSENTIAL_CODE_TO_BE_PORTED
97-
FieldHandle Nodal_NrrdToField_reader(ProgressReporter *pr, const char *filename)
75+
FieldHandle SCIRun::Nodal_NrrdToField_reader(LoggerHandle pr, const char *filename)
9876
{
99-
FieldHandle field = 0;
100-
NrrdDataHandle nrrd = 0;
101-
102-
SCIRunAlgo::DataIOAlgo dalgo(pr);
103-
SCIRunAlgo::ConverterAlgo calgo(pr);
77+
FieldHandle field;
78+
NrrdDataHandle nrrd;
79+
80+
DataIOAlgo dalgo(pr);
81+
ConverterAlgo calgo(pr);
10482

10583
std::string fn(filename);
106-
107-
if (dalgo.ReadNrrd(fn,nrrd))
84+
85+
if (dalgo.readNrrd(fn,nrrd))
10886
{
109-
calgo.NrrdToField(nrrd,field,"Node");
87+
calgo.nrrdToField(nrrd,field,"Node");
11088
}
111-
89+
11290
return (field);
11391
}
11492

115-
FieldHandle Modal_NrrdToField_reader(ProgressReporter *pr, const char *filename)
93+
FieldHandle SCIRun::Modal_NrrdToField_reader(LoggerHandle pr, const char *filename)
11694
{
117-
FieldHandle field = 0;
118-
NrrdDataHandle nrrd = 0;
119-
120-
SCIRunAlgo::DataIOAlgo dalgo(pr);
121-
SCIRunAlgo::ConverterAlgo calgo(pr);
95+
FieldHandle field;
96+
NrrdDataHandle nrrd;
97+
98+
DataIOAlgo dalgo(pr);
99+
ConverterAlgo calgo(pr);
122100

123101
std::string fn(filename);
124-
125-
if (dalgo.ReadNrrd(fn,nrrd))
102+
103+
if (dalgo.readNrrd(fn,nrrd))
126104
{
127-
calgo.NrrdToField(nrrd,field,"Element");
105+
calgo.nrrdToField(nrrd,field,"Element");
128106
}
129-
107+
130108
return (field);
131109
}
132110

133-
FieldHandle IPNodal_NrrdToField_reader(ProgressReporter *pr, const char *filename)
111+
FieldHandle SCIRun::IPNodal_NrrdToField_reader(LoggerHandle pr, const char *filename)
134112
{
135-
FieldHandle field = 0;
136-
NrrdDataHandle nrrd = 0;
137-
138-
SCIRunAlgo::DataIOAlgo dalgo(pr);
139-
SCIRunAlgo::ConverterAlgo calgo(pr);
113+
FieldHandle field;
114+
NrrdDataHandle nrrd;
115+
116+
DataIOAlgo dalgo(pr);
117+
ConverterAlgo calgo(pr);
140118

141119
std::string fn(filename);
142-
143-
if (dalgo.ReadNrrd(fn,nrrd))
120+
121+
if (dalgo.readNrrd(fn,nrrd))
144122
{
145-
calgo.NrrdToField(nrrd,field,"Node","Auto","Invert");
123+
calgo.nrrdToField(nrrd,field,"Node","Auto","Invert");
146124
}
147-
125+
148126
return (field);
149127
}
150128

151-
FieldHandle IPModal_NrrdToField_reader(ProgressReporter *pr, const char *filename)
129+
FieldHandle SCIRun::IPModal_NrrdToField_reader(LoggerHandle pr, const char *filename)
152130
{
153-
FieldHandle field = 0;
154-
NrrdDataHandle nrrd = 0;
155-
156-
SCIRunAlgo::DataIOAlgo dalgo(pr);
157-
SCIRunAlgo::ConverterAlgo calgo(pr);
131+
FieldHandle field;
132+
NrrdDataHandle nrrd;
133+
134+
DataIOAlgo dalgo(pr);
135+
ConverterAlgo calgo(pr);
158136

159137
std::string fn(filename);
160-
161-
if (dalgo.ReadNrrd(fn,nrrd))
138+
139+
if (dalgo.readNrrd(fn,nrrd))
162140
{
163-
calgo.NrrdToField(nrrd,field,"Element","Auto","Invert");
141+
calgo.nrrdToField(nrrd,field,"Element","Auto","Invert");
164142
}
165-
143+
166144
return (field);
167145
}
168-
#endif
169-
//
170-
//static FieldIEPlugin NrrdToField_plugin("NrrdFile","{.nhdr} {.nrrd}", "*.nrrd", NrrdToField_reader, FieldToNrrd_writer);
171-
//static FieldIEPlugin NodalNrrdToField_plugin("NrrdFile[DataOnNodes]","{.nhdr} {.nrrd}", "", Nodal_NrrdToField_reader, 0);
172-
//static FieldIEPlugin ModalNrrdToField_plugin("NrrdFile[DataOnElements]","{.nhdr} {.nrrd}", "", Modal_NrrdToField_reader, 0);
173-
//static FieldIEPlugin IPNodalNrrdToField_plugin("NrrdFile[DataOnNodes,InvertParity]","{.nhdr} {.nrrd}", "", IPNodal_NrrdToField_reader, 0);
174-
//static FieldIEPlugin IPModalNrrdToField_plugin("NrrdFile[DataOnElements,InvertParity]","{.nhdr} {.nrrd}", "", IPModal_NrrdToField_reader, 0);

src/Core/IEPlugin/NrrdField_Plugin.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Copyright (c) 2009 Scientific Computing and Imaging Institute,
77
University of Utah.
88
9-
9+
1010
Permission is hereby granted, free of charge, to any person obtaining a
1111
copy of this software and associated documentation files (the "Software"),
1212
to deal in the Software without restriction, including without limitation
@@ -33,9 +33,27 @@
3333
#include <Core/Datatypes/Legacy/Field/FieldFwd.h>
3434
#include <Core/IEPlugin/share.h>
3535

36-
namespace SCIRun
36+
namespace SCIRun
3737
{
38+
// This file contains readers for nrrds as fields. We currently have 5 variations
39+
// depending on whether data is defined on the nodes or the elements and what the
40+
// parity of the data is.
41+
//
42+
// Although these properties are defined in the nrrd file format, most nrrds are
43+
// annotated improperly and hence corrections have to made.
44+
45+
// Default reader use the definitions in the nrrd
3846
SCISHARE FieldHandle NrrdToField_reader(Core::Logging::LoggerHandle pr, const char *filename);
47+
// Override the location settings and force data on the nodes
48+
SCISHARE FieldHandle Nodal_NrrdToField_reader(Core::Logging::LoggerHandle pr, const char *filename);
49+
// Override the location settings and force data on the elements
50+
SCISHARE FieldHandle Modal_NrrdToField_reader(Core::Logging::LoggerHandle pr, const char *filename);
51+
// Override the location settings and force data on the nodes and invert space parity
52+
SCISHARE FieldHandle IPNodal_NrrdToField_reader(Core::Logging::LoggerHandle pr, const char *filename);
53+
// Override the location settings and force data on the elements and invert space parity
54+
SCISHARE FieldHandle IPModal_NrrdToField_reader(Core::Logging::LoggerHandle pr, const char *filename);
55+
56+
// Default writer
3957
SCISHARE bool FieldToNrrd_writer(Core::Logging::LoggerHandle pr, FieldHandle fh, const char* filename);
4058
}
4159

0 commit comments

Comments
 (0)