Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit 31ba23bf authored by Jakob Weiss's avatar Jakob Weiss

Fixed glimageresampler and added assert

* glImageResampler now sets the mapping information correctly
* ImageData now asserts that an associated imagemappinginformation has the
  same dimensionality
parent aee5eb16
......@@ -84,6 +84,7 @@ namespace campvis {
}
void ImageData::setMappingInformation(const ImageMappingInformation& imi) {
cgtAssert(cgt::vec3(_size) == imi.getImageSize(), "Image Mapping Information must have the same voxel dimensions!");
_mappingInformation = imi;
}
......@@ -134,4 +135,4 @@ namespace campvis {
return "Image Data";
}
}
\ No newline at end of file
}
......@@ -88,6 +88,11 @@ namespace campvis {
return _worldToVoxelTransformation;
}
const cgt::vec3 & ImageMappingInformation::getImageSize() const
{
return _size;
}
bool ImageMappingInformation::operator==(const ImageMappingInformation& obj) const{
return (this->_offset == obj._offset)
&& (this->_size == obj._size)
......
......@@ -108,6 +108,12 @@ namespace campvis {
*/
const cgt::mat4& getWorldToVoxelMatrix() const;
/**
* Returns the image size information, as specified in the constructor as the
* number of voxels in each direction.
*/
const cgt::vec3& getImageSize() const;
/**
* Overloaded equal operator
* \param obj Object to compare with.
......
......@@ -26,7 +26,7 @@ in vec3 ex_TexCoord;
out vec4 out_Color;
#ifdef GLRESAMPLER_3D
uniform sampler3D _texture;
uniform TextureParameters3D _textureParams;
uniform float _zTexCoord;
#endif
......
......@@ -39,7 +39,7 @@ namespace campvis {
: AutoEvaluationPipeline(dc, getId())
, _lsp()
, _imageReader()
, _resampler()
, _resampler(&_canvasSize)
, _ve(&_canvasSize)
{
addProcessor(&_lsp);
......@@ -78,4 +78,4 @@ namespace campvis {
}
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@
#include "modules/modulesapi.h"
#include "modules/base/processors/lightsourceprovider.h"
#include "modules/io/processors/mhdimagereader.h"
#include "modules/preprocessing/processors/medianfilter.h"
#include "modules/preprocessing/processors/glimageresampler.h"
#include "modules/vis/processors/volumeexplorer.h"
namespace campvis {
......@@ -58,7 +58,7 @@ namespace campvis {
protected:
LightSourceProvider _lsp;
MhdImageReader _imageReader;
MedianFilter _resampler;
GlImageResampler _resampler;
VolumeExplorer _ve;
};
}
......
......@@ -79,8 +79,11 @@ namespace campvis {
if (img != 0) {
cgt::vec3 originalSize(img->getSize());
cgt::ivec3 resampledSize = p_targetSize.getValue();
cgt::vec3 resampleScale = p_resampleScale.getValue();
if (p_relativeScale.getValue())
resampledSize = cgt::ivec3(p_resampleScale.getValue() * cgt::vec3(img->getSize()));
resampledSize = cgt::ivec3(resampleScale * originalSize);
else
resampleScale = cgt::vec3(resampledSize) / cgt::vec3(originalSize);
bool isTexture2D = img->getParent()->getDimensionality() == 2;
......@@ -124,7 +127,7 @@ namespace campvis {
ImageData* id = new ImageData(img->getParent()->getDimensionality(), resampledSize, img->getParent()->getNumChannels());
ImageRepresentationGL::create(id, resultTexture);
const ImageMappingInformation& imi = img->getParent()->getMappingInformation();
id->setMappingInformation(ImageMappingInformation(img->getSize(), imi.getOffset(), imi.getVoxelSize() / p_resampleScale.getValue(), imi.getCustomTransformation()));
id->setMappingInformation(ImageMappingInformation(resampledSize, imi.getOffset(), imi.getVoxelSize() / resampleScale, imi.getCustomTransformation()));
data.addData(p_outputImage.getValue(), id);
cgt::TextureUnit::setZeroUnit();
......
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