8 #include "PlusConfigure.h" 10 #include "PlusRevision.h" 13 #include <vtkMatrix4x4.h> 14 #include <vtkXMLDataElement.h> 15 #include <vtksys/SystemTools.hxx> 18 #include "metaImage.h" 24 #ifdef PLUS_USE_OpenIGTLink 26 #include <igtlImageMessage.h> 32 std::string plusLibVersion = std::string(
"Plus-") + std::string(PLUSLIB_VERSION) +
"." + std::string(PLUSLIB_SHORT_REVISION);
34 plusLibVersion +=
" (debug build)";
37 plusLibVersion +=
" - Win64";
39 plusLibVersion +=
" - Win32";
40 #elif defined __APPLE__ 41 plusLibVersion +=
" - Mac";
43 plusLibVersion +=
" - Linux";
45 return plusLibVersion;
52 vtkImageData* volumeToSave = frame->GetImageData()->GetImage();
54 MET_ValueEnumType scalarType = MET_NONE;
55 switch (volumeToSave->GetScalarType())
57 case VTK_UNSIGNED_CHAR:
58 scalarType = MET_UCHAR;
61 scalarType = MET_FLOAT;
64 LOG_ERROR(
"Scalar type is not supported!");
68 MetaImage metaImage(volumeToSave->GetDimensions()[0], volumeToSave->GetDimensions()[1], volumeToSave->GetDimensions()[2],
69 volumeToSave->GetSpacing()[0], volumeToSave->GetSpacing()[1], volumeToSave->GetSpacing()[2],
70 scalarType, volumeToSave->GetNumberOfScalarComponents(), volumeToSave->GetScalarPointer());
72 origin[0] = imageToTracker->Element[0][3];
73 origin[1] = imageToTracker->Element[1][3];
74 origin[2] = imageToTracker->Element[2][3];
75 metaImage.Origin(origin);
76 for (
int i = 0;
i < 3; ++
i)
78 for (
int j = 0; j < 3; ++j)
80 metaImage.Orientation(
i, j, imageToTracker->Element[
i][j]);
85 metaImage.AnatomicalOrientation(
"RAI");
86 metaImage.BinaryData(
true);
87 metaImage.CompressedData(
true);
88 metaImage.ElementDataFileName(
"LOCAL");
89 if (metaImage.Write(filename.c_str()) ==
false)
91 LOG_ERROR(
"Failed to save reconstructed volume in sequence metafile!");
97 #ifdef PLUS_USE_OpenIGTLink 102 switch (igtlPixelType)
104 case igtl::ImageMessage::TYPE_INT8:
106 case igtl::ImageMessage::TYPE_UINT8:
107 return VTK_UNSIGNED_CHAR;
108 case igtl::ImageMessage::TYPE_INT16:
110 case igtl::ImageMessage::TYPE_UINT16:
111 return VTK_UNSIGNED_SHORT;
112 case igtl::ImageMessage::TYPE_INT32:
114 case igtl::ImageMessage::TYPE_UINT32:
115 return VTK_UNSIGNED_INT;
116 case igtl::ImageMessage::TYPE_FLOAT32:
118 case igtl::ImageMessage::TYPE_FLOAT64:
132 return igtl::ImageMessage::TYPE_INT8;
133 case VTK_UNSIGNED_CHAR:
134 return igtl::ImageMessage::TYPE_UINT8;
136 return igtl::ImageMessage::TYPE_INT16;
137 case VTK_UNSIGNED_SHORT:
138 return igtl::ImageMessage::TYPE_UINT16;
140 return igtl::ImageMessage::TYPE_INT32;
141 case VTK_UNSIGNED_INT:
142 return igtl::ImageMessage::TYPE_UINT32;
144 return igtl::ImageMessage::TYPE_FLOAT32;
146 return igtl::ImageMessage::TYPE_FLOAT64;
150 return igtl::ImageMessage::TYPE_INT8;
vtkPlusCommonExport PlusStatus WriteToFile(igsioTrackedFrame *frame, const std::string &filename, vtkMatrix4x4 *imageToTracker)
vtkPlusCommonExport std::string GetPlusLibVersionString()