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 { ...@@ -56,6 +56,10 @@ namespace campvis {
return _mappingInformation; return _mappingInformation;
} }
void ImageData::setMappingInformation(const ImageMappingInformation& imi) {
_mappingInformation = imi;
}
tgt::Bounds ImageData::getWorldBounds() const { tgt::Bounds ImageData::getWorldBounds() const {
return tgt::Bounds(_mappingInformation.getOffset(), _mappingInformation.getOffset() + (tgt::vec3(_size) * _mappingInformation.getVoxelSize())); return tgt::Bounds(_mappingInformation.getOffset(), _mappingInformation.getOffset() + (tgt::vec3(_size) * _mappingInformation.getVoxelSize()));
} }
......
...@@ -74,6 +74,12 @@ namespace campvis { ...@@ -74,6 +74,12 @@ namespace campvis {
*/ */
const ImageMappingInformation& getMappingInformation() const; 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. * Returns the image extent in world coordinates.
* \return The image extent in world coordinates. * \return The image extent in world coordinates.
......
...@@ -73,13 +73,16 @@ namespace campvis { ...@@ -73,13 +73,16 @@ namespace campvis {
campvis::ImageDataGL* ImageDataConverter::convert(const ImageDataDisk* source) { campvis::ImageDataGL* ImageDataConverter::convert(const ImageDataDisk* source) {
WeaklyTypedPointer wtp = source->getImageData(); WeaklyTypedPointer wtp = source->getImageData();
ImageDataGL* toReturn = new ImageDataGL(source->getDimensionality(), source->getSize(), wtp); ImageDataGL* toReturn = new ImageDataGL(source->getDimensionality(), source->getSize(), wtp);
toReturn->setMappingInformation(source->getMappingInformation());
delete wtp._pointer; delete wtp._pointer;
return toReturn; return toReturn;
} }
template<> template<>
campvis::ImageDataGL* ImageDataConverter::convert(const ImageDataLocal* source) { 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 { ...@@ -127,10 +127,13 @@ namespace campvis {
// TODO: check (un)signed int/float? // TODO: check (un)signed int/float?
WeaklyTypedPointer wtp = source->getImageData(); WeaklyTypedPointer wtp = source->getImageData();
return new GenericImageDataLocal<BASETYPE, NUMCHANNELS>( GenericImageDataLocal<BASETYPE, NUMCHANNELS>* toReturn = new GenericImageDataLocal<BASETYPE, NUMCHANNELS>(
source->getDimensionality(), source->getDimensionality(),
source->getSize(), source->getSize(),
reinterpret_cast<typename TypeTraits<BASETYPE, NUMCHANNELS>::ElementType*>(wtp._pointer)); reinterpret_cast<typename TypeTraits<BASETYPE, NUMCHANNELS>::ElementType*>(wtp._pointer));
toReturn->setMappingInformation(source->getMappingInformation());
return toReturn;
} }
} }
......
...@@ -46,6 +46,7 @@ namespace campvis { ...@@ -46,6 +46,7 @@ namespace campvis {
VALID = 0, VALID = 0,
INVALID_RESULT = 1 << 0, INVALID_RESULT = 1 << 0,
INVALID_SHADER = 1 << 1, INVALID_SHADER = 1 << 1,
INVALID_FILE = 1 << 2,
}; };
/** /**
......
...@@ -47,9 +47,13 @@ namespace campvis { ...@@ -47,9 +47,13 @@ namespace campvis {
: AbstractProcessor() : AbstractProcessor()
, p_url("url", "Image URL", "") , p_url("url", "Image URL", "")
, p_targetImageID("targetImageName", "Target Image ID", "MhdImageReader.output", DataNameProperty::WRITE) , 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_url);
addProperty(&p_targetImageID); addProperty(&p_targetImageID);
addProperty(&p_imageOffset);
addProperty(&p_voxelSize);
} }
MhdImageReader::~MhdImageReader() { MhdImageReader::~MhdImageReader() {
...@@ -70,6 +74,9 @@ namespace campvis { ...@@ -70,6 +74,9 @@ namespace campvis {
size_t offset = 0; size_t offset = 0;
EndianHelper::Endianness e = EndianHelper::LITTLE_ENDIAN; EndianHelper::Endianness e = EndianHelper::LITTLE_ENDIAN;
tgt::vec3 voxelSize(1.f);
tgt::vec3 imageOffset(0.f);
// image type // image type
if (tfp.hasKey("ObjectType")) { if (tfp.hasKey("ObjectType")) {
if (tfp.getString("ObjectType") != "Image") { if (tfp.getString("ObjectType") != "Image") {
...@@ -124,6 +131,12 @@ namespace campvis { ...@@ -124,6 +131,12 @@ namespace campvis {
e = (tfp.getBool("ElementByteOrderMSB") ? EndianHelper::BIG_ENDIAN : EndianHelper::LITTLE_ENDIAN); e = (tfp.getBool("ElementByteOrderMSB") ? EndianHelper::BIG_ENDIAN : EndianHelper::LITTLE_ENDIAN);
// TODO: spacing, element size, etc. // 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: // get raw image location:
...@@ -156,6 +169,7 @@ namespace campvis { ...@@ -156,6 +169,7 @@ namespace campvis {
// all parsing done - lets create the image: // all parsing done - lets create the image:
ImageDataDisk* image = new ImageDataDisk(url, dimensionality, size, pt, 1, offset, e); 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); data.addData(p_targetImageID.getValue(), image);
p_targetImageID.issueWrite(); p_targetImageID.issueWrite();
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "core/pipeline/abstractprocessor.h" #include "core/pipeline/abstractprocessor.h"
#include "core/properties/datanameproperty.h" #include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h" #include "core/properties/numericproperty.h"
namespace campvis { namespace campvis {
/** /**
...@@ -69,6 +69,9 @@ namespace campvis { ...@@ -69,6 +69,9 @@ namespace campvis {
StringProperty p_url; ///< URL for file to read StringProperty p_url; ///< URL for file to read
DataNameProperty p_targetImageID; ///< image ID for read image DataNameProperty p_targetImageID; ///< image ID for read image
Vec3Property p_imageOffset; ///< Image Offset in mm
Vec3Property p_voxelSize; ///< Voxel Size in mm
protected: protected:
static const std::string loggerCat_; 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