|
30 | 30 | #include <Core/Algorithms/Legacy/Converter/FieldToNrrd.h> |
31 | 31 |
|
32 | 32 | #include <Core/Datatypes/Legacy/Field/Field.h> |
| 33 | +#include <Core/Datatypes/Legacy/Field/VMesh.h> |
| 34 | +#include <Core/Datatypes/Legacy/Field/VField.h> |
33 | 35 | #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> |
34 | 41 |
|
35 | 42 | using namespace SCIRun; |
| 43 | +using namespace SCIRun::Core::Logging; |
| 44 | +using namespace SCIRun::Core::Algorithms; |
| 45 | +using namespace SCIRun::Core::Geometry; |
36 | 46 |
|
37 | | -namespace detail { |
38 | | -class FieldToNrrdAlgoT { |
| 47 | +namespace detail |
| 48 | +{ |
| 49 | +class FieldToNrrdAlgoT |
| 50 | +{ |
39 | 51 | public: |
40 | | - bool FieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output); |
41 | | - |
42 | 52 | // Converters for node centered data |
43 | 53 | 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); |
48 | 57 | }; |
49 | 58 |
|
50 | 59 |
|
51 | 60 | // Templated converter for Scalar data so we can use every type supported by the Teem library |
52 | 61 |
|
53 | 62 | 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) |
55 | 64 | { |
56 | | - output = new NrrdData(); |
57 | | - output->nrrd_ = nrrdNew(); |
| 65 | + output.reset(new NrrdData()); |
58 | 66 |
|
59 | | - if (output->nrrd_ == 0) |
| 67 | + Nrrd* nrrd = output->getNrrd(); |
| 68 | + |
| 69 | + if (!nrrd) |
60 | 70 | { |
61 | 71 | pr->error("FieldToNrrd: Could not create new Nrrd"); |
62 | 72 | return (false); |
63 | 73 | } |
64 | 74 |
|
65 | | - // Get a pointer to make program more readable |
66 | | - Nrrd* nrrd = output->nrrd_; |
67 | | - |
68 | 75 | int nrrddim = 0; |
69 | 76 | int nrrdcenter = nrrdCenterNode; |
70 | 77 | size_t dim[3]; |
@@ -269,22 +276,18 @@ bool FieldToNrrdAlgoT::ScalarFieldToNrrd(ProgressReporter* pr,FieldHandle input, |
269 | 276 | return (false); |
270 | 277 | } |
271 | 278 |
|
272 | | - |
273 | | - |
274 | | -bool FieldToNrrdAlgoT::VectorFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output) |
| 279 | +bool FieldToNrrdAlgoT::vectorFieldToNrrd(LoggerHandle pr,FieldHandle input, NrrdDataHandle& output) |
275 | 280 | { |
276 | | - output = new NrrdData(); |
277 | | - output->nrrd_ = nrrdNew(); |
| 281 | + output.reset(new NrrdData()); |
| 282 | + |
| 283 | + Nrrd* nrrd = output->getNrrd(); |
278 | 284 |
|
279 | | - if (output->nrrd_ == 0) |
| 285 | + if (!nrrd) |
280 | 286 | { |
281 | 287 | pr->error("FieldToNrrd: Could not create new Nrrd"); |
282 | 288 | return (false); |
283 | 289 | } |
284 | 290 |
|
285 | | - // Get a pointer to make program more readable |
286 | | - Nrrd* nrrd = output->nrrd_; |
287 | | - |
288 | 291 | int nrrddim = 0; |
289 | 292 | int nrrdcenter = nrrdCenterNode; |
290 | 293 | size_t dim[4]; |
@@ -581,21 +584,18 @@ bool FieldToNrrdAlgoT::VectorFieldToNrrd(ProgressReporter* pr,FieldHandle input, |
581 | 584 | return (false); |
582 | 585 | } |
583 | 586 |
|
584 | | - |
585 | | -bool FieldToNrrdAlgoT::TensorFieldToNrrd(ProgressReporter* pr,FieldHandle input, NrrdDataHandle& output) |
| 587 | +bool FieldToNrrdAlgoT::tensorFieldToNrrd(LoggerHandle pr,FieldHandle input, NrrdDataHandle& output) |
586 | 588 | { |
587 | | - output = new NrrdData(); |
588 | | - output->nrrd_ = nrrdNew(); |
| 589 | + output.reset(new NrrdData()); |
589 | 590 |
|
590 | | - if (output->nrrd_ == 0) |
| 591 | + Nrrd* nrrd = output->getNrrd(); |
| 592 | + |
| 593 | + if (!nrrd) |
591 | 594 | { |
592 | 595 | pr->error("FieldToNrrd: Could not create new Nrrd"); |
593 | 596 | return (false); |
594 | 597 | } |
595 | 598 |
|
596 | | - // Get a pointer to make program more readable |
597 | | - Nrrd* nrrd = output->nrrd_; |
598 | | - |
599 | 599 | int nrrddim = 0; |
600 | 600 | int nrrdcenter = nrrdCenterNode; |
601 | 601 | size_t dim[4]; |
@@ -915,8 +915,7 @@ bool FieldToNrrdAlgoT::TensorFieldToNrrd(ProgressReporter* pr,FieldHandle input, |
915 | 915 |
|
916 | 916 | bool FieldToNrrdAlgo::fieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHandle& output) |
917 | 917 | { |
918 | | - |
919 | | - if (input.get_rep() == 0) |
| 918 | + if (!input) |
920 | 919 | { |
921 | 920 | pr->error("FieldToNrrd: No input Field"); |
922 | 921 | return (false); |
@@ -948,32 +947,32 @@ bool FieldToNrrdAlgo::fieldToNrrd(LoggerHandle pr, FieldHandle input, NrrdDataHa |
948 | 947 | return (false); |
949 | 948 | } |
950 | 949 |
|
951 | | - FieldToNrrdAlgoT algo; |
| 950 | + detail::FieldToNrrdAlgoT algo; |
952 | 951 |
|
953 | 952 | if (fi.is_scalar()) |
954 | 953 | { |
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)); |
965 | 964 | pr->error("FieldToNrrd: The field type is not supported by nrrd format, hence we cannot convert it"); |
966 | 965 | return (false); |
967 | 966 | } |
968 | 967 |
|
969 | 968 | if (fi.is_vector()) |
970 | 969 | { |
971 | | - return(algo.VectorFieldToNrrd(pr,input,output)); |
| 970 | + return(algo.vectorFieldToNrrd(pr,input,output)); |
972 | 971 | } |
973 | 972 |
|
974 | 973 | if (fi.is_tensor()) |
975 | 974 | { |
976 | | - return(algo.TensorFieldToNrrd(pr,input,output)); |
| 975 | + return(algo.tensorFieldToNrrd(pr,input,output)); |
977 | 976 | } |
978 | 977 |
|
979 | 978 | pr->error("FieldToNrrd: Unknown Field type encountered, cannot convert Field into Nrrd"); |
|
0 commit comments