Skip to content

Commit d1c789a

Browse files
committed
FieldToNrrd compiles
1 parent 9af2d97 commit d1c789a

File tree

2 files changed

+46
-49
lines changed

2 files changed

+46
-49
lines changed

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

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,48 @@
3030
#include <Core/Algorithms/Legacy/Converter/FieldToNrrd.h>
3131

3232
#include <Core/Datatypes/Legacy/Field/Field.h>
33+
#include <Core/Datatypes/Legacy/Field/VMesh.h>
34+
#include <Core/Datatypes/Legacy/Field/VField.h>
3335
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
36+
#include <Core/Datatypes/Legacy/Nrrd/NrrdData.h>
37+
#include <Core/Logging/LoggerInterface.h>
38+
#include <Core/GeometryPrimitives/Transform.h>
39+
#include <Core/GeometryPrimitives/Vector.h>
40+
#include <Core/GeometryPrimitives/Point.h>
3441

3542
using namespace SCIRun;
43+
using namespace SCIRun::Core::Logging;
44+
using namespace SCIRun::Core::Algorithms;
45+
using namespace SCIRun::Core::Geometry;
3646

37-
namespace detail {
38-
class FieldToNrrdAlgoT {
47+
namespace detail
48+
{
49+
class FieldToNrrdAlgoT
50+
{
3951
public:
40-
bool FieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output);
41-
4252
// Converters for node centered data
4353
template<class T>
44-
bool ScalarFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output, int datatype);
45-
bool VectorFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output);
46-
bool TensorFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output);
47-
54+
bool scalarFieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHandle& output, int datatype);
55+
bool vectorFieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHandle& output);
56+
bool tensorFieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHandle& output);
4857
};
4958

5059

5160
// Templated converter for Scalar data so we can use every type supported by the Teem library
5261

5362
template<class T>
54-
bool FieldToNrrdAlgoT::ScalarFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output,int datatype)
63+
bool FieldToNrrdAlgoT::scalarFieldToNrrd(LoggerHandle pr,FieldHandle input, NrrdDataHandle& output,int datatype)
5564
{
56-
output = new NrrdData();
57-
output->nrrd_ = nrrdNew();
65+
output.reset(new NrrdData());
5866

59-
if (output->nrrd_ == 0)
67+
Nrrd* nrrd = output->getNrrd();
68+
69+
if (!nrrd)
6070
{
6171
pr->error("FieldToNrrd: Could not create new Nrrd");
6272
return (false);
6373
}
6474

65-
// Get a pointer to make program more readable
66-
Nrrd* nrrd = output->nrrd_;
67-
6875
int nrrddim = 0;
6976
int nrrdcenter = nrrdCenterNode;
7077
size_t dim[3];
@@ -269,22 +276,18 @@ bool FieldToNrrdAlgoT::ScalarFieldToNrrd(ProgressReporter* pr,FieldHandle input,
269276
return (false);
270277
}
271278

272-
273-
274-
bool FieldToNrrdAlgoT::VectorFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output)
279+
bool FieldToNrrdAlgoT::vectorFieldToNrrd(LoggerHandle pr,FieldHandle input, NrrdDataHandle& output)
275280
{
276-
output = new NrrdData();
277-
output->nrrd_ = nrrdNew();
281+
output.reset(new NrrdData());
282+
283+
Nrrd* nrrd = output->getNrrd();
278284

279-
if (output->nrrd_ == 0)
285+
if (!nrrd)
280286
{
281287
pr->error("FieldToNrrd: Could not create new Nrrd");
282288
return (false);
283289
}
284290

285-
// Get a pointer to make program more readable
286-
Nrrd* nrrd = output->nrrd_;
287-
288291
int nrrddim = 0;
289292
int nrrdcenter = nrrdCenterNode;
290293
size_t dim[4];
@@ -581,21 +584,18 @@ bool FieldToNrrdAlgoT::VectorFieldToNrrd(ProgressReporter* pr,FieldHandle input,
581584
return (false);
582585
}
583586

584-
585-
bool FieldToNrrdAlgoT::TensorFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output)
587+
bool FieldToNrrdAlgoT::tensorFieldToNrrd(LoggerHandle pr,FieldHandle input, NrrdDataHandle& output)
586588
{
587-
output = new NrrdData();
588-
output->nrrd_ = nrrdNew();
589+
output.reset(new NrrdData());
589590

590-
if (output->nrrd_ == 0)
591+
Nrrd* nrrd = output->getNrrd();
592+
593+
if (!nrrd)
591594
{
592595
pr->error("FieldToNrrd: Could not create new Nrrd");
593596
return (false);
594597
}
595598

596-
// Get a pointer to make program more readable
597-
Nrrd* nrrd = output->nrrd_;
598-
599599
int nrrddim = 0;
600600
int nrrdcenter = nrrdCenterNode;
601601
size_t dim[4];
@@ -915,8 +915,7 @@ bool FieldToNrrdAlgoT::TensorFieldToNrrd(ProgressReporter* pr,FieldHandle input,
915915

916916
bool FieldToNrrdAlgo::fieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHandle& output)
917917
{
918-
919-
if (input.get_rep() == 0)
918+
if (!input)
920919
{
921920
pr->error("FieldToNrrd: No input Field");
922921
return (false);
@@ -948,32 +947,32 @@ bool FieldToNrrdAlgo::fieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHa
948947
return (false);
949948
}
950949

951-
FieldToNrrdAlgoT algo;
950+
detail::FieldToNrrdAlgoT algo;
952951

953952
if (fi.is_scalar())
954953
{
955-
if (fi.is_double()) return(algo.ScalarFieldToNrrd<double>(pr,input,output,nrrdTypeDouble));
956-
if (fi.is_float()) return(algo.ScalarFieldToNrrd<float>(pr,input,output,nrrdTypeFloat));
957-
if (fi.is_char()) return(algo.ScalarFieldToNrrd<char>(pr,input,output,nrrdTypeChar));
958-
if (fi.is_unsigned_char()) return(algo.ScalarFieldToNrrd<unsigned char>(pr,input,output,nrrdTypeUChar));
959-
if (fi.is_short()) return(algo.ScalarFieldToNrrd<short>(pr,input,output,nrrdTypeShort));
960-
if (fi.is_unsigned_short()) return(algo.ScalarFieldToNrrd<unsigned short>(pr,input,output,nrrdTypeUShort));
961-
if (fi.is_int()) return(algo.ScalarFieldToNrrd<int>(pr,input,output,nrrdTypeInt));
962-
if (fi.is_unsigned_int()) return(algo.ScalarFieldToNrrd<unsigned int>(pr,input,output,nrrdTypeUInt));
963-
if (fi.is_longlong()) return(algo.ScalarFieldToNrrd<long long>(pr,input,output,nrrdTypeLLong));
964-
if (fi.is_unsigned_longlong()) return(algo.ScalarFieldToNrrd<unsigned long long>(pr,input,output,nrrdTypeULLong));
954+
if (fi.is_double()) return(algo.scalarFieldToNrrd<double>(pr,input,output,nrrdTypeDouble));
955+
if (fi.is_float()) return(algo.scalarFieldToNrrd<float>(pr,input,output,nrrdTypeFloat));
956+
if (fi.is_char()) return(algo.scalarFieldToNrrd<char>(pr,input,output,nrrdTypeChar));
957+
if (fi.is_unsigned_char()) return(algo.scalarFieldToNrrd<unsigned char>(pr,input,output,nrrdTypeUChar));
958+
if (fi.is_short()) return(algo.scalarFieldToNrrd<short>(pr,input,output,nrrdTypeShort));
959+
if (fi.is_unsigned_short()) return(algo.scalarFieldToNrrd<unsigned short>(pr,input,output,nrrdTypeUShort));
960+
if (fi.is_int()) return(algo.scalarFieldToNrrd<int>(pr,input,output,nrrdTypeInt));
961+
if (fi.is_unsigned_int()) return(algo.scalarFieldToNrrd<unsigned int>(pr,input,output,nrrdTypeUInt));
962+
if (fi.is_longlong()) return(algo.scalarFieldToNrrd<long long>(pr,input,output,nrrdTypeLLong));
963+
if (fi.is_unsigned_longlong()) return(algo.scalarFieldToNrrd<unsigned long long>(pr,input,output,nrrdTypeULLong));
965964
pr->error("FieldToNrrd: The field type is not supported by nrrd format, hence we cannot convert it");
966965
return (false);
967966
}
968967

969968
if (fi.is_vector())
970969
{
971-
return(algo.VectorFieldToNrrd(pr,input,output));
970+
return(algo.vectorFieldToNrrd(pr,input,output));
972971
}
973972

974973
if (fi.is_tensor())
975974
{
976-
return(algo.TensorFieldToNrrd(pr,input,output));
975+
return(algo.tensorFieldToNrrd(pr,input,output));
977976
}
978977

979978
pr->error("FieldToNrrd: Unknown Field type encountered, cannot convert Field into Nrrd");

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
DEALINGS IN THE SOFTWARE.
2727
*/
2828

29-
#include <vector>
30-
3129
#include <Core/Datatypes/Legacy/Field/Field.h>
3230
#include <Core/Datatypes/Legacy/Field/VMesh.h>
3331
#include <Core/Datatypes/Legacy/Field/VField.h>

0 commit comments

Comments
 (0)