Commit 25b1737c authored by Christian Schulte zu Berge's avatar Christian Schulte zu Berge
Browse files

Removed AbstractImage::getSubImage() interface since it's implementation in...

Removed AbstractImage::getSubImage() interface since it's implementation in all subclasses is far from trivial and therefore was not done thoroughly. Since the functionality was not used anywhere so far, it was removed to avoid unexperienced users trying to use it and getting confused if it does not work as intended.
Could be reimplemented in extra processors for special cases.

closes #339
parent 87203f92
......@@ -96,17 +96,6 @@ namespace campvis {
*/
virtual size_t getVideoMemoryFootprint() const = 0;
/**
* Returns the subimage representation of this representation given by \a llf and \a urb.
* TODO: Check whether it is necessary to adjust image mapping!
*
* \param newParent Parent image of the newly created subimage
* \param llf Lower-Left-Front coordinates of subimage
* \param urb Upper-Right-Back coordinates of subimage
* \return An image representation containing the subimage of this with the given coordinates.
*/
virtual AbstractImageRepresentation* getSubImage(ImageData* newParent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
protected:
/**
* Adds this image representations to the newParent image data.
......
......@@ -177,9 +177,6 @@ namespace campvis {
/// \see AbstractImageRepresentation::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractImageRepresentation::getSubImage
virtual ThisType* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Returns a WeaklyTypedPointer to the image data.
* \note The pointer is still owned by this ImageRepresentationLocal. If you want a copy, use clone().
......@@ -335,41 +332,6 @@ namespace campvis {
return 0;
}
template<typename BASETYPE, size_t NUMCHANNELS>
GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
tgtAssert(tgt::hand(tgt::lessThan(llf, urb)), "Coordinates in LLF must be component-wise smaller than the ones in URB!");
const tgt::svec3& size = getSize();
tgt::svec3 newSize = urb - llf;
if (newSize == size) {
// nothing has changed, just provide a copy:
return clone(parent);
}
tgt::bvec3 tmp(tgt::greaterThan(newSize, tgt::svec3(1)));
size_t newDimensionality = 0;
for (size_t i = 0; i < 3; ++i) {
if (tmp[i] == true)
++newDimensionality;
}
size_t numBytesPerElement = sizeof(ElementType);
size_t numElements = tgt::hmul(newSize);
ElementType* newData = new ElementType[numElements];
// slice image data into new array
size_t index = 0;
for (size_t z = llf.z; z < urb.z; ++z) {
for (size_t y = llf.y; y < urb.y; ++y) {
size_t offset = llf.x + (y * size.x) + (z * size.y * size.x);
memcpy(newData + index, _data + offset, newSize.x * numBytesPerElement);
index += newSize.x;
}
}
return new ThisType(parent, newData);
}
template<typename BASETYPE, size_t NUMCHANNELS>
const WeaklyTypedPointer campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getWeaklyTypedPointer() const {
return WeaklyTypedPointer(TypeTraits<BASETYPE, NUMCHANNELS>::weaklyTypedPointerBaseType, NUMCHANNELS, _data);
......
......@@ -105,35 +105,6 @@ namespace campvis {
_mappingInformation.getOffset() + (tgt::vec3(urb) * _mappingInformation.getVoxelSize()));
}
ImageData* ImageData::getSubImage(const tgt::svec3& llf, const tgt::svec3& urb) const {
tgtAssert(tgt::hand(tgt::lessThan(llf, urb)), "Coordinates in LLF must be component-wise smaller than the ones in URB!");
tgt::svec3 newSize = urb - llf;
if (newSize == getSize()) {
// nothing has changed, just provide a copy:
return clone();
}
// compute new dimensionality
size_t newDimensionality = 1;
if (newSize.y > 1)
newDimensionality = 2;
if (newSize.z > 1)
newDimensionality = 3;
// create new ImageData object and assign mapping information
ImageData* toReturn = new ImageData(newDimensionality, newSize, _numChannels);
toReturn->_mappingInformation = ImageMappingInformation(newSize, _mappingInformation.getOffset(), _mappingInformation.getVoxelSize(), _mappingInformation.getRealWorldMapping());
// create sub-image of every image representation
for (tbb::concurrent_vector<const AbstractImageRepresentation*>::const_iterator it = _representations.begin(); it != _representations.end(); ++it) {
AbstractImageRepresentation* si = (*it)->getSubImage(toReturn, llf, urb);
toReturn->addRepresentation(si);
}
return toReturn;
}
size_t ImageData::getNumElements() const {
return _numElements;
}
......
......@@ -132,17 +132,6 @@ namespace campvis {
*/
tgt::Bounds getWorldBounds(const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Returns the subimage of this image given by \a llf and \a urb.
* TODO: Check whether it is necessary to adjust image mapping!
*
* \note Creates sub-images of all representations.
* \param llf Lower-Left-Front coordinates of subimage
* \param urb Upper-Right-Back coordinates of subimage
* \return An image containing the sub-image of this image with the given coordinates.
*/
virtual ImageData* getSubImage(const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Transforms a vector based position to the corresponding array index.
* \note Caution, this method might return wrong results for non-continuous storage.
......
......@@ -50,22 +50,6 @@ namespace campvis {
ImageRepresentationDisk::~ImageRepresentationDisk() {
}
ImageRepresentationDisk* ImageRepresentationDisk::getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
tgtAssert(tgt::hand(tgt::lessThan(llf, urb)), "Coordinates in LLF must be component-wise smaller than the ones in URB!");
const tgt::svec3& size = getSize();
tgt::svec3 newSize = urb - llf;
if (newSize == size) {
// nothing has changed, just provide a copy:
return clone(parent);
}
size_t newOffset = _offset + WeaklyTypedPointer::numBytes(_type, _parent->getNumChannels()) * (llf.x + llf.y * size.y + llf.z * size.x * size.y);
// the stride doesn't change!
tgt::svec3 newStride = (_stride == tgt::svec3::zero) ? getCanonicStride(getSize()) : _stride;
return new ImageRepresentationDisk(parent, _url, _type, newOffset, _endianess, newStride);
}
campvis::WeaklyTypedPointer ImageRepresentationDisk::getImageData() const {
const tgt::svec3& size = getSize();
size_t numElements = tgt::hmul(size);
......
......@@ -88,9 +88,6 @@ namespace campvis {
/// \see AbstractImageRepresentation::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractImageRepresentation::getSubImage
virtual ImageRepresentationDisk* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Downloads the whole image data to local memory.
......
......@@ -139,12 +139,6 @@ namespace campvis {
return toReturn;
}
ImageRepresentationGL* ImageRepresentationGL::getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
// TODO: implement
//LWARNING("ImageRepresentationGL::getSubImage() not implemented!");
return 0;
}
void ImageRepresentationGL::createTexture(const WeaklyTypedPointer& wtp) {
tgtAssert(wtp._pointer != 0, "Pointer to image data must not be 0!");
......
......@@ -94,11 +94,6 @@ namespace campvis {
/// \see AbstractImageRepresentation::getVideoMemoryFootprint()
virtual size_t getVideoMemoryFootprint() const;
/**
* \see AbstractImageRepresentation::getSubImage
*/
virtual ImageRepresentationGL* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Binds the image to the given shader using \a texUnit as texture unit and \a texUniform as shader uniform.
......
......@@ -61,9 +61,6 @@ namespace campvis {
/// \see AbstractData::clone()
virtual ImageRepresentationLocal* clone(ImageData* newParent) const = 0;
/// \see ImageData::getSubImage()
virtual ImageRepresentationLocal* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
/**
* Returns a WeaklyTypedPointer to the image data.
* \note The pointer is still owned by this ImageRepresentationLocal. If you want a copy, use clone().
......
......@@ -364,7 +364,7 @@ namespace {
};
/**
* Template specialization for unsigned integer types, map from [min, max] to [0.0, 1.0]
* Template specialization for signed integer types, map from [min, max] to [0.0, 1.0]
*/
template<typename T>
struct TypeNormalizerHelper<T, false, true> {
......
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