2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 46eb03ea authored by schultezub's avatar schultezub
Browse files

enabling ImageMappingInformation in ImageData classes and MhdImageReader

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@392 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 2b03c390
......@@ -56,6 +56,10 @@ namespace campvis {
return _mappingInformation;
}
void ImageData::setMappingInformation(const ImageMappingInformation& imi) {
_mappingInformation = imi;
}
tgt::Bounds ImageData::getWorldBounds() const {
return tgt::Bounds(_mappingInformation.getOffset(), _mappingInformation.getOffset() + (tgt::vec3(_size) * _mappingInformation.getVoxelSize()));
}
......
......@@ -74,6 +74,12 @@ namespace campvis {
*/
const ImageMappingInformation& getMappingInformation() const;
/**
* Sets the mapping information for this image to \a imi.
* \param imi The new ImageMappingInformation for this image.
*/
void setMappingInformation(const ImageMappingInformation& imi);
/**
* Returns the image extent in world coordinates.
* \return The image extent in world coordinates.
......
......@@ -73,13 +73,16 @@ namespace campvis {
campvis::ImageDataGL* ImageDataConverter::convert(const ImageDataDisk* source) {
WeaklyTypedPointer wtp = source->getImageData();
ImageDataGL* toReturn = new ImageDataGL(source->getDimensionality(), source->getSize(), wtp);
toReturn->setMappingInformation(source->getMappingInformation());
delete wtp._pointer;
return toReturn;
}
template<>
campvis::ImageDataGL* ImageDataConverter::convert(const ImageDataLocal* source) {
return new ImageDataGL(source->getDimensionality(), source->getSize(), source->getWeaklyTypedPointer());
ImageDataGL* toReturn = new ImageDataGL(source->getDimensionality(), source->getSize(), source->getWeaklyTypedPointer());
toReturn->setMappingInformation(source->getMappingInformation());
return toReturn;
}
}
\ No newline at end of file
......@@ -127,10 +127,13 @@ namespace campvis {
// TODO: check (un)signed int/float?
WeaklyTypedPointer wtp = source->getImageData();
return new GenericImageDataLocal<BASETYPE, NUMCHANNELS>(
GenericImageDataLocal<BASETYPE, NUMCHANNELS>* toReturn = new GenericImageDataLocal<BASETYPE, NUMCHANNELS>(
source->getDimensionality(),
source->getSize(),
reinterpret_cast<typename TypeTraits<BASETYPE, NUMCHANNELS>::ElementType*>(wtp._pointer));
toReturn->setMappingInformation(source->getMappingInformation());
return toReturn;
}
}
......
......@@ -46,6 +46,7 @@ namespace campvis {
VALID = 0,
INVALID_RESULT = 1 << 0,
INVALID_SHADER = 1 << 1,
INVALID_FILE = 1 << 2,
};
/**
......
......@@ -47,9 +47,13 @@ namespace campvis {
: AbstractProcessor()
, p_url("url", "Image URL", "")
, p_targetImageID("targetImageName", "Target Image ID", "MhdImageReader.output", DataNameProperty::WRITE)
, p_imageOffset("ImageOffset", "Image Offset in mm", tgt::vec3(0.f), tgt::vec3(-10000.f), tgt::vec3(10000.f))
, p_voxelSize("VoxelSize", "Voxel Size in mm", tgt::vec3(1.f), tgt::vec3(-100.f), tgt::vec3(100.f))
{
addProperty(&p_url);
addProperty(&p_targetImageID);
addProperty(&p_imageOffset);
addProperty(&p_voxelSize);
}
MhdImageReader::~MhdImageReader() {
......@@ -70,6 +74,9 @@ namespace campvis {
size_t offset = 0;
EndianHelper::Endianness e = EndianHelper::LITTLE_ENDIAN;
tgt::vec3 voxelSize(1.f);
tgt::vec3 imageOffset(0.f);
// image type
if (tfp.hasKey("ObjectType")) {
if (tfp.getString("ObjectType") != "Image") {
......@@ -124,6 +131,12 @@ namespace campvis {
e = (tfp.getBool("ElementByteOrderMSB") ? EndianHelper::BIG_ENDIAN : EndianHelper::LITTLE_ENDIAN);
// TODO: spacing, element size, etc.
if (tfp.hasKey("ElementSpacing")) {
voxelSize = tfp.getVec3("ElementSpacing");
}
if (tfp.hasKey("Position")) {
imageOffset = tfp.getVec3("Position");
}
// get raw image location:
......@@ -156,6 +169,7 @@ namespace campvis {
// all parsing done - lets create the image:
ImageDataDisk* image = new ImageDataDisk(url, dimensionality, size, pt, 1, offset, e);
image->setMappingInformation(ImageMappingInformation(size, imageOffset + p_imageOffset.getValue(), voxelSize + p_voxelSize.getValue()));
data.addData(p_targetImageID.getValue(), image);
p_targetImageID.issueWrite();
}
......
......@@ -34,7 +34,7 @@
#include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
namespace campvis {
/**
......@@ -69,6 +69,9 @@ namespace campvis {
StringProperty p_url; ///< URL for file to read
DataNameProperty p_targetImageID; ///< image ID for read image
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
protected:
static const std::string loggerCat_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment