open_iA  2020.01
A tool for the visual analysis and processing of volumetric datasets, with a focus on industrial computed tomography.
Functions
iAToolsVTK.cpp File Reference
#include "iAToolsVTK.h"
#include "iAConnector.h"
#include "iAConsole.h"
#include "iAVtkDraw.h"
#include "io/iAITKIO.h"
#include <vtkBMPWriter.h>
#include <vtkCamera.h>
#include <vtkImageCast.h>
#include <vtkImageData.h>
#include <vtkImageWriter.h>
#include <vtkJPEGWriter.h>
#include <vtkObjectFactory.h>
#include <vtkPNGWriter.h>
#include <vtkTIFFWriter.h>
#include <vtkSmartVolumeMapper.h>
#include <QFileInfo>
#include <QRegularExpression>
#include <QStringList>
Include dependency graph for iAToolsVTK.cpp:

Functions

vtkSmartPointer< vtkImageData > allocateImage (int vtkType, int const dimensions[3], double const spacing[3])
 Create a VTK image with the given properties. More...
 
vtkSmartPointer< vtkImageData > allocateImage (int vtkType, int const dimensions[3], double const spacing[3], int numComponents)
 Create a VTK image with the given properties. More...
 
vtkSmartPointer< vtkImageData > allocateImage (vtkSmartPointer< vtkImageData > img)
 Create a VTK image that has the same properties (type, size, spacing) as the given image. More...
 
vtkSmartPointer< vtkImageData > castVTKImage (vtkSmartPointer< vtkImageData > img, int destType)
 Cast the given VTK image to another data type. More...
 
bool isVtkIntegerType (int type)
 Check whether the given type is integer. More...
 
open_iA_Core_API int mapReadableDataTypeToVTKType (QString const &dataTypeName)
 Maps a given data type string to the corresponding VTK type identifier. More...
 
int mapRenderModeToEnum (QString const &modeName)
 
open_iA_Core_API QString mapVTKTypeToReadableDataType (int vtkType)
 Maps a given VTK type to the corresponding readable data type. More...
 
size_t mapVTKTypeToSize (int vtkType)
 Returns the size (in bytes) of the given VTK type. More...
 
const QStringList & readableDataTypeList (bool withLongLongTypes)
 Returns a human-readable list of available data types for a single pixel/voxel. More...
 
vtkSmartPointer< vtkImageData > readImage (QString const &filename, bool releaseFlag)
 Read an image from disk into a VTK image. More...
 
const QMap< int, QString > & RenderModeMap ()
 
void setCamPosition (vtkCamera *cam, iACameraPosition pos)
 
void storeImage (vtkSmartPointer< vtkImageData > image, QString const &filename, bool useCompression)
 Stores an image on disk (typically in .mhd format). More...
 
 vtkStandardNewMacro (iAvtkImageData)
 
void writeSingleSliceImage (QString const &filename, vtkImageData *imageData)
 Write a single slice image to a common 2D picture format. More...
 

Function Documentation

◆ allocateImage() [1/3]

vtkSmartPointer<vtkImageData> allocateImage ( int  vtkType,
int const  dimensions[3],
double const  spacing[3] 
)

Create a VTK image with the given properties.

Parameters
vtkTypethe VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...) for the voxel data type to use in the new image
dimensionsthe size of the image in the 3 dimensions.
spacingthe spacing (distance of voxels) in each of the 3 dimension directions.
Returns
an image with a single component and the type, size and spacing as the given parameters, with allocated but uninitialized pixel data.

◆ allocateImage() [2/3]

vtkSmartPointer<vtkImageData> allocateImage ( int  vtkType,
int const  dimensions[3],
double const  spacing[3],
int  numComponents 
)

Create a VTK image with the given properties.

Parameters
vtkTypethe VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...) for the voxel data type to use in the new image
dimensionsthe size of the image in the 3 dimensions.
spacingthe spacing (distance of voxels) in each of the 3 dimension directions.
numComponentsthe number of components in each voxel.
Returns
an image with the type, size, spacing and number of components as the given parameters, with allocated but uninitialized pixel data.

◆ allocateImage() [3/3]

vtkSmartPointer<vtkImageData> allocateImage ( vtkSmartPointer< vtkImageData >  img)

Create a VTK image that has the same properties (type, size, spacing) as the given image.

Parameters
imgimage whose type, size and spacing will be used to create the result image; its data will not be copied over to the new image
Returns
an image that has the same type, size and spacing as the image given as parameter, with allocated but uninitialized pixel data.

◆ castVTKImage()

vtkSmartPointer<vtkImageData> castVTKImage ( vtkSmartPointer< vtkImageData >  img,
int  dstType 
)

Cast the given VTK image to another data type.

Parameters
imgthe input image
dstTypethe VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...) to cast to
Returns
a VTK image of the specified type

◆ isVtkIntegerType()

bool isVtkIntegerType ( int  type)

Check whether the given type is integer.

Parameters
typea VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...)
Returns
true if the given VTK type holds integer numbers, false if it holds floating point numbers

◆ mapReadableDataTypeToVTKType()

open_iA_Core_API int mapReadableDataTypeToVTKType ( QString const &  dataTypeName)

Maps a given data type string to the corresponding VTK type identifier.

Parameters
dataTypeNamean entry from the list of readable data types (see readableDataTypeList())
Returns
the VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...) for the given readable data type name, or -1 if the given name is not on the list

◆ mapRenderModeToEnum()

int mapRenderModeToEnum ( QString const &  modeName)

◆ mapVTKTypeToReadableDataType()

open_iA_Core_API QString mapVTKTypeToReadableDataType ( int  vtkType)

Maps a given VTK type to the corresponding readable data type.

Parameters
vtkTypethe VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...)
Returns
the name (in the list as returned by readableDataTypeList()) of the given VTK type identifier, or -1 if the given VTK type identifier is unknown

◆ mapVTKTypeToSize()

size_t mapVTKTypeToSize ( int  vtkType)

Returns the size (in bytes) of the given VTK type.

Parameters
vtkTypea VTK type identifier (VTK_INT, VTK_UNSIGNED_CHAR, ...)
Returns
the size in bytes of the given type (VTK_CHAR -> 1, ...), or 0 if it's an unknown type

◆ readableDataTypeList()

const QStringList& readableDataTypeList ( bool  withLongLongTypes)

Returns a human-readable list of available data types for a single pixel/voxel.

Parameters
withLongLongTypes

◆ readImage()

vtkSmartPointer<vtkImageData> readImage ( QString const &  filename,
bool  releaseFlag 
)

Read an image from disk into a VTK image.

Parameters
filenamethe name of the file to read.
releaseFlagwhether the ITK release flag should be set on the ITK image reader
Returns
the vtk image as read from the given file

◆ RenderModeMap()

const QMap<int, QString>& RenderModeMap ( )

◆ setCamPosition()

void setCamPosition ( vtkCamera *  cam,
iACameraPosition  pos 
)

◆ storeImage()

void storeImage ( vtkSmartPointer< vtkImageData >  image,
QString const &  filename,
bool  useCompression = true 
)

Stores an image on disk (typically in .mhd format).

Parameters
imagethe image to store
filenamethe name of the file to write to.
useCompressionwhether the file should be compressed (.zraw) or not (.raw) in case we are storing .mhd files

◆ vtkStandardNewMacro()

vtkStandardNewMacro ( iAvtkImageData  )

◆ writeSingleSliceImage()

void writeSingleSliceImage ( QString const &  filename,
vtkImageData *  imageData 
)

Write a single slice image to a common 2D picture format.

Parameters
filenamethe name of the file to write to; this is expected to have an extension of tif, png, jpg or bmp; the type of the file written will be chosen according to this extension
imageDatathe image to write; this already needs to be a 2D image (i.e., size in Z dimension = 1)