Skip to content

Commit 9af2d97

Browse files
committed
NrrdToField compiles
1 parent fffa9b4 commit 9af2d97

File tree

3 files changed

+82
-68
lines changed

3 files changed

+82
-68
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#ifndef CORE_ALGORITHMS_CONVERTER_FIELDTONRRD_H
3131
#define CORE_ALGORITHMS_CONVERTER_FIELDTONRRD_H 1
3232

33+
#include <Core/Logging/LoggerFwd.h>
34+
#include <Core/Datatypes/DatatypeFwd.h>
3335
#include <Core/Algorithms/Legacy/Converter/share.h>
3436

3537
namespace SCIRun
@@ -39,11 +41,11 @@ namespace SCIRun
3941
namespace Algorithms
4042
{
4143

42-
class SCISHARE FieldToNrrdAlgo
43-
{
44-
public:
45-
bool fieldToNrrd(Core::Logging::LoggerHandle pr, FieldHandle input, NrrdDataHandle& output);
46-
};
44+
class SCISHARE FieldToNrrdAlgo
45+
{
46+
public:
47+
bool fieldToNrrd(Core::Logging::LoggerHandle pr, FieldHandle input, NrrdDataHandle& output);
48+
};
4749

4850
}}}
4951

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

Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,50 @@
2929
#include <vector>
3030

3131
#include <Core/Datatypes/Legacy/Field/Field.h>
32+
#include <Core/Datatypes/Legacy/Field/VMesh.h>
33+
#include <Core/Datatypes/Legacy/Field/VField.h>
3234
#include <Core/Datatypes/Legacy/Field/FieldInformation.h>
33-
35+
#include <Core/Datatypes/Legacy/Nrrd/NrrdData.h>
36+
#include <Core/Logging/LoggerInterface.h>
37+
#include <Core/GeometryPrimitives/Transform.h>
38+
#include <Core/GeometryPrimitives/Vector.h>
39+
#include <Core/GeometryPrimitives/Point.h>
3440
#include <Core/Algorithms/Legacy/Converter/NrrdToField.h>
3541

3642
using namespace SCIRun;
43+
using namespace SCIRun::Core::Logging;
44+
using namespace SCIRun::Core::Algorithms;
45+
using namespace SCIRun::Core::Geometry;
3746

3847
namespace detail {
3948
class NrrdToFieldAlgoT {
4049
public:
4150
// Convert a nrrd to a normal Scalar Field
4251
template<class T>
43-
bool NrrdToField(ProgressReporter* pr,NrrdDataHandle input, FieldHandle& output,std::string datalocation, std::string spaceparity);
52+
bool nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHandle& output,const std::string& datalocation, const std::string& spaceparity);
4453

4554
// Convert a nrrd to a Vector Field, we need to know which axis is the
4655
// vector dimension, if -1 it will try to detect dimension automatically
4756
// Experience tells us mostly this information is not stored in the nrrd
4857
// So we need a method to set it.
4958
template<class T>
50-
bool NrrdToVectorField(ProgressReporter* pr,NrrdDataHandle input, FieldHandle& output,std::string datalocation, std::string spaceparity,int vecdim = -1);
59+
bool nrrdToVectorField(LoggerHandle pr,NrrdDataHandle input, FieldHandle& output,const std::string& datalocation, const std::string& spaceparity,int vecdim = -1);
5160

5261
// Convert a nrrd to a Tensor Field, we need to know which axis is the
5362
// vector dimension, if -1 it will try to detect dimension automatically
5463
// Experience tells us mostly this information is not stored in the nrrd
5564
// So we need a method to set it.
5665
template<class T>
57-
bool NrrdToTensorField(ProgressReporter* pr,NrrdDataHandle input, FieldHandle& output,std::string datalocation, std::string spaceparity,int tendim = -1);
66+
bool nrrdToTensorField(LoggerHandle pr,NrrdDataHandle input, FieldHandle& output,const std::string& datalocation, const std::string& spaceparity,int tendim = -1);
5867
};
5968

6069
// Templated converter for Scalar data so we can use every type supported by the Teem library
6170
template<class T>
62-
bool NrrdToFieldAlgoT::NrrdToField(ProgressReporter* pr,NrrdDataHandle input, FieldHandle& output,std::string datalocation, std::string spaceparity)
71+
bool NrrdToFieldAlgoT::nrrdToField(LoggerHandle pr,NrrdDataHandle input, FieldHandle& output,const std::string& datalocation, const std::string& spaceparity)
6372
{
64-
Nrrd *nrrd = input->nrrd_;
73+
const Nrrd *nrrd = input->getNrrd();
6574

66-
if (nrrd == 0)
75+
if (!nrrd)
6776
{
6877
pr->error("NrrdToField: NrrdData does not contain Nrrd");
6978
return false;
@@ -528,9 +537,9 @@ bool NrrdToFieldAlgoT::NrrdToField(ProgressReporter* pr,NrrdDataHandle input, Fi
528537

529538
// Templated converter for Scalar data so we can use every type supported by the Teem library
530539
template<class T>
531-
bool NrrdToFieldAlgoT::NrrdToVectorField(ProgressReporter* pr,NrrdDataHandle input, FieldHandle& output,std::string datalocation, std::string spaceparity, int vecdim)
540+
bool NrrdToFieldAlgoT::nrrdToVectorField(LoggerHandle pr,NrrdDataHandle input, FieldHandle& output,const std::string& datalocation, const std::string& spaceparity, int vecdim)
532541
{
533-
Nrrd *nrrd = input->nrrd_;
542+
const Nrrd *nrrd = input->getNrrd();
534543
double M[3][3];
535544
M[0][0] = 1.0; M[0][1] = 0.0; M[0][2] = 0.0;
536545
M[1][0] = 0.0; M[1][1] = 1.0; M[1][2] = 0.0;
@@ -1062,9 +1071,9 @@ bool NrrdToFieldAlgoT::NrrdToVectorField(ProgressReporter* pr,NrrdDataHandle inp
10621071

10631072
// Templated converter for Scalar data so we can use every type supported by the Teem library
10641073
template<class T>
1065-
bool NrrdToFieldAlgoT::NrrdToTensorField(ProgressReporter* pr,NrrdDataHandle input, FieldHandle& output,std::string datalocation, std::string spaceparity, int vecdim)
1074+
bool NrrdToFieldAlgoT::nrrdToTensorField(LoggerHandle pr,NrrdDataHandle input, FieldHandle& output,const std::string& datalocation, const std::string& spaceparity, int vecdim)
10661075
{
1067-
Nrrd *nrrd = input->nrrd_;
1076+
const Nrrd *nrrd = input->getNrrd();
10681077

10691078
double M[3][3];
10701079
M[0][0] = 1.0; M[0][1] = 0.0; M[0][2] = 0.0;
@@ -1749,19 +1758,17 @@ bool NrrdToFieldAlgoT::NrrdToTensorField(ProgressReporter* pr,NrrdDataHandle inp
17491758

17501759

17511760
bool NrrdToFieldAlgo::nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHandle& output,
1752-
const std::string& datalocation, const std::string& fieldtype, const std::string& spaceparity)
1761+
const std::string& datalocationIn, const std::string& fieldtypeIn, const std::string& spaceparity)
17531762
{
1754-
int datadim = -1;
1755-
1756-
if (input.get_rep() == 0)
1763+
if (!input)
17571764
{
17581765
pr->error("NrrdToField: No input Nrrd");
17591766
return false;
17601767
}
17611768

1762-
Nrrd *nrrd = input->nrrd_;
1769+
const Nrrd *nrrd = input->getNrrd();
17631770

1764-
if (nrrd == 0)
1771+
if (!nrrd)
17651772
{
17661773
pr->error("NrrdToField: NrrdData does not contain Nrrd");
17671774
return (false);
@@ -1774,8 +1781,10 @@ bool NrrdToFieldAlgo::nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHa
17741781
return false;
17751782
}
17761783

1784+
std::string datalocation(datalocationIn);
1785+
17771786
// Automatically detect nrrd type Element of Node based.
1778-
if (datalocation == "Auto")
1787+
if (datalocationIn == "Auto")
17791788
{
17801789
datalocation = "Node";
17811790
for (unsigned int p = 0; p < dim; p++)
@@ -1788,6 +1797,9 @@ bool NrrdToFieldAlgo::nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHa
17881797
}
17891798
}
17901799

1800+
int datadim = -1;
1801+
1802+
std::string fieldtype(fieldtypeIn);
17911803
// Automatically detect field type based on the clues given in the nrrd
17921804
// annotation.
17931805

@@ -1926,34 +1938,34 @@ bool NrrdToFieldAlgo::nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHa
19261938
if (fieldtype == "Auto")
19271939
fieldtype = "ScalarField";
19281940

1929-
NrrdToFieldAlgoT algo;
1941+
detail::NrrdToFieldAlgoT algo;
19301942

19311943
if (fieldtype == "ScalarField")
19321944
{
19331945
switch (nrrd->type)
19341946
{
19351947
case nrrdTypeChar :
1936-
return (algo.NrrdToField<char>(pr,input,output,datalocation,spaceparity));
1948+
return (algo.nrrdToField<char>(pr,input,output,datalocation,spaceparity));
19371949
case nrrdTypeUChar :
1938-
return (algo.NrrdToField<unsigned char>(pr,input,output,datalocation,spaceparity));
1950+
return (algo.nrrdToField<unsigned char>(pr,input,output,datalocation,spaceparity));
19391951
case nrrdTypeShort :
1940-
return (algo.NrrdToField<short>(pr,input,output,datalocation,spaceparity));
1952+
return (algo.nrrdToField<short>(pr,input,output,datalocation,spaceparity));
19411953
case nrrdTypeUShort :
1942-
return (algo.NrrdToField<unsigned short>(pr,input,output,datalocation,spaceparity));
1954+
return (algo.nrrdToField<unsigned short>(pr,input,output,datalocation,spaceparity));
19431955
case nrrdTypeInt :
1944-
return (algo.NrrdToField<int>(pr,input,output,datalocation,spaceparity));
1956+
return (algo.nrrdToField<int>(pr,input,output,datalocation,spaceparity));
19451957
case nrrdTypeUInt :
1946-
return (algo.NrrdToField<unsigned int>(pr,input,output,datalocation,spaceparity));
1958+
return (algo.nrrdToField<unsigned int>(pr,input,output,datalocation,spaceparity));
19471959
case nrrdTypeLLong :
1948-
return (algo.NrrdToField<long long>(pr,input,output,datalocation,spaceparity));
1960+
return (algo.nrrdToField<long long>(pr,input,output,datalocation,spaceparity));
19491961
case nrrdTypeULLong :
1950-
return (algo.NrrdToField<unsigned long long>(pr,input,output,datalocation,spaceparity));
1962+
return (algo.nrrdToField<unsigned long long>(pr,input,output,datalocation,spaceparity));
19511963
case nrrdTypeFloat :
1952-
return (algo.NrrdToField<float>(pr,input,output,datalocation,spaceparity));
1964+
return (algo.nrrdToField<float>(pr,input,output,datalocation,spaceparity));
19531965
case nrrdTypeDouble :
1954-
return (algo.NrrdToField<double>(pr,input,output,datalocation,spaceparity));
1966+
return (algo.nrrdToField<double>(pr,input,output,datalocation,spaceparity));
19551967
default:
1956-
pr->error("NrrdToField: This datatype is not supported");
1968+
pr->error("nrrdToField: This datatype is not supported");
19571969
return false;
19581970
}
19591971
}
@@ -1962,27 +1974,27 @@ bool NrrdToFieldAlgo::nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHa
19621974
switch (nrrd->type)
19631975
{
19641976
case nrrdTypeChar :
1965-
return (algo.NrrdToVectorField<char>(pr,input,output,datalocation,spaceparity,datadim));
1977+
return (algo.nrrdToVectorField<char>(pr,input,output,datalocation,spaceparity,datadim));
19661978
case nrrdTypeUChar :
1967-
return (algo.NrrdToVectorField<unsigned char>(pr,input,output,datalocation,spaceparity,datadim));
1979+
return (algo.nrrdToVectorField<unsigned char>(pr,input,output,datalocation,spaceparity,datadim));
19681980
case nrrdTypeShort :
1969-
return (algo.NrrdToVectorField<short>(pr,input,output,datalocation,spaceparity,datadim));
1981+
return (algo.nrrdToVectorField<short>(pr,input,output,datalocation,spaceparity,datadim));
19701982
case nrrdTypeUShort :
1971-
return (algo.NrrdToVectorField<unsigned short>(pr,input,output,datalocation,spaceparity,datadim));
1983+
return (algo.nrrdToVectorField<unsigned short>(pr,input,output,datalocation,spaceparity,datadim));
19721984
case nrrdTypeInt :
1973-
return (algo.NrrdToVectorField<int>(pr,input,output,datalocation,spaceparity,datadim));
1985+
return (algo.nrrdToVectorField<int>(pr,input,output,datalocation,spaceparity,datadim));
19741986
case nrrdTypeUInt :
1975-
return (algo.NrrdToVectorField<unsigned int>(pr,input,output,datalocation,spaceparity,datadim));
1987+
return (algo.nrrdToVectorField<unsigned int>(pr,input,output,datalocation,spaceparity,datadim));
19761988
case nrrdTypeLLong :
1977-
return (algo.NrrdToVectorField<long long>(pr,input,output,datalocation,spaceparity,datadim));
1989+
return (algo.nrrdToVectorField<long long>(pr,input,output,datalocation,spaceparity,datadim));
19781990
case nrrdTypeULLong :
1979-
return (algo.NrrdToVectorField<unsigned long long>(pr,input,output,datalocation,spaceparity,datadim));
1991+
return (algo.nrrdToVectorField<unsigned long long>(pr,input,output,datalocation,spaceparity,datadim));
19801992
case nrrdTypeFloat :
1981-
return (algo.NrrdToVectorField<float>(pr,input,output,datalocation,spaceparity,datadim));
1993+
return (algo.nrrdToVectorField<float>(pr,input,output,datalocation,spaceparity,datadim));
19821994
case nrrdTypeDouble :
1983-
return (algo.NrrdToVectorField<double>(pr,input,output,datalocation,spaceparity,datadim));
1995+
return (algo.nrrdToVectorField<double>(pr,input,output,datalocation,spaceparity,datadim));
19841996
default:
1985-
pr->error("NrrdToVectorField: This datatype is not supported");
1997+
pr->error("nrrdToVectorField: This datatype is not supported");
19861998
return false;
19871999
}
19882000
}
@@ -1991,33 +2003,33 @@ bool NrrdToFieldAlgo::nrrdToField(LoggerHandle pr, NrrdDataHandle input, FieldHa
19912003
switch (nrrd->type)
19922004
{
19932005
case nrrdTypeChar :
1994-
return (algo.NrrdToTensorField<char>(pr,input,output,datalocation,spaceparity,datadim));
2006+
return (algo.nrrdToTensorField<char>(pr,input,output,datalocation,spaceparity,datadim));
19952007
case nrrdTypeUChar :
1996-
return (algo.NrrdToTensorField<unsigned char>(pr,input,output,datalocation,spaceparity,datadim));
2008+
return (algo.nrrdToTensorField<unsigned char>(pr,input,output,datalocation,spaceparity,datadim));
19972009
case nrrdTypeShort :
1998-
return (algo.NrrdToTensorField<short>(pr,input,output,datalocation,spaceparity,datadim));
2010+
return (algo.nrrdToTensorField<short>(pr,input,output,datalocation,spaceparity,datadim));
19992011
case nrrdTypeUShort :
2000-
return (algo.NrrdToTensorField<unsigned short>(pr,input,output,datalocation,spaceparity,datadim));
2012+
return (algo.nrrdToTensorField<unsigned short>(pr,input,output,datalocation,spaceparity,datadim));
20012013
case nrrdTypeInt :
2002-
return (algo.NrrdToTensorField<int>(pr,input,output,datalocation,spaceparity,datadim));
2014+
return (algo.nrrdToTensorField<int>(pr,input,output,datalocation,spaceparity,datadim));
20032015
case nrrdTypeUInt :
2004-
return (algo.NrrdToTensorField<unsigned int>(pr,input,output,datalocation,spaceparity,datadim));
2016+
return (algo.nrrdToTensorField<unsigned int>(pr,input,output,datalocation,spaceparity,datadim));
20052017
case nrrdTypeLLong :
2006-
return (algo.NrrdToTensorField<long long>(pr,input,output,datalocation,spaceparity,datadim));
2018+
return (algo.nrrdToTensorField<long long>(pr,input,output,datalocation,spaceparity,datadim));
20072019
case nrrdTypeULLong :
2008-
return (algo.NrrdToTensorField<unsigned long long>(pr,input,output,datalocation,spaceparity,datadim));
2020+
return (algo.nrrdToTensorField<unsigned long long>(pr,input,output,datalocation,spaceparity,datadim));
20092021
case nrrdTypeFloat :
2010-
return (algo.NrrdToTensorField<float>(pr,input,output,datalocation,spaceparity,datadim));
2022+
return (algo.nrrdToTensorField<float>(pr,input,output,datalocation,spaceparity,datadim));
20112023
case nrrdTypeDouble :
2012-
return (algo.NrrdToTensorField<double>(pr,input,output,datalocation,spaceparity,datadim));
2024+
return (algo.nrrdToTensorField<double>(pr,input,output,datalocation,spaceparity,datadim));
20132025
default:
2014-
pr->error("NrrdToTensorField: This datatype is not supported");
2026+
pr->error("nrrdToTensorField: This datatype is not supported");
20152027
return false;
20162028
}
20172029
}
20182030
else
20192031
{
2020-
pr->error("NrrdToField: Unknown field type");
2032+
pr->error("nrrdToField: Unknown field type");
20212033
return false;
20222034
}
20232035

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#ifndef CORE_ALGORITHMS_CONVERTER_NRRDTOFIELD_H
3131
#define CORE_ALGORITHMS_CONVERTER_NRRDTOFIELD_H 1
3232

33+
#include <Core/Logging/LoggerFwd.h>
34+
#include <Core/Datatypes/DatatypeFwd.h>
3335
#include <Core/Algorithms/Legacy/Converter/share.h>
3436

3537
namespace SCIRun
@@ -38,16 +40,14 @@ namespace SCIRun
3840
{
3941
namespace Algorithms
4042
{
41-
42-
class SCISHARE NrrdToFieldAlgo
43-
{
44-
public:
45-
bool nrrdToField(Core::Logging::LoggerHandle pr, NrrdDataHandle input, FieldHandle& output,
46-
const std::string& datalocation = "Auto",
47-
const std::string& fieldtype = "Auto",
48-
const std::string& correctparity = "Make Right Hand Sided");
49-
};
50-
43+
class SCISHARE NrrdToFieldAlgo
44+
{
45+
public:
46+
bool nrrdToField(Core::Logging::LoggerHandle pr, NrrdDataHandle input, FieldHandle& output,
47+
const std::string& datalocation = "Auto",
48+
const std::string& fieldtype = "Auto",
49+
const std::string& correctparity = "Make Right Hand Sided");
50+
};
5151
}}}
5252

5353
#endif

0 commit comments

Comments
 (0)