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

Commit bbe2f50c authored by schultezub's avatar schultezub
Browse files

updated AbstractImageRepresentation so that it automatically adds itself as...

updated AbstractImageRepresentation so that it automatically adds itself as representation to the parent image

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@411 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent dcbb0d7a
......@@ -33,10 +33,11 @@
namespace campvis {
const std::string AbstractImageRepresentation::loggerCat_ = "CAMPVis.core.datastructures.AbstractImageRepresentation";
AbstractImageRepresentation::AbstractImageRepresentation(const ImageData* parent)
AbstractImageRepresentation::AbstractImageRepresentation(ImageData* parent)
: _parent(parent)
{
tgtAssert(parent != 0, "Parent ImageData must not be 0!");
parent->addRepresentation(this);
}
AbstractImageRepresentation::~AbstractImageRepresentation() {
......
......@@ -49,7 +49,7 @@ namespace campvis {
* Creates a new abstract representation for the image \a parent.
* \param parent Image this representation represents, must not be 0.
*/
AbstractImageRepresentation(const ImageData* parent);
AbstractImageRepresentation(ImageData* parent);
/**
* Virtual Destructor.
......@@ -82,9 +82,10 @@ namespace campvis {
/**
* Prototype - clone method, some people call this virtual constructor...
* \param newParent Parent image of the cloned object.
* \return A copy of this object.
*/
virtual AbstractImageRepresentation* clone() const = 0;
virtual AbstractImageRepresentation* clone(ImageData* newParent) const = 0;
/**
* Returns the local memory footprint of the data in bytes.
......@@ -102,11 +103,12 @@ namespace campvis {
* 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 parent 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(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
virtual AbstractImageRepresentation* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
protected:
......
......@@ -116,7 +116,7 @@ namespace campvis {
* Creates a new abstract representation for the image \a parent.
* \param parent Image this representation represents, must not be 0.
*/
GenericAbstractImageRepresentation(const ImageData* parent)
GenericAbstractImageRepresentation(ImageData* parent)
: AbstractImageRepresentation(parent)
{
}
......
......@@ -128,7 +128,7 @@ namespace campvis {
* \param parent Image this representation represents, must not be 0.
* \param data Pointer to the image data, must not be 0, GenericImageRepresentationLocal takes ownership of this pointer!
*/
GenericImageRepresentationLocal(const ImageData* parent, ElementType* data);
GenericImageRepresentationLocal(ImageData* parent, ElementType* data);
/**
* Destructor
......@@ -146,7 +146,7 @@ namespace campvis {
static GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* tryConvertFrom(const AbstractImageRepresentation* source);
/// \see AbstractImageRepresentation::clone()
virtual ThisType* clone() const;
virtual ThisType* clone(ImageData* newParent) const;
/// \see AbstractImageRepresentation::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
......@@ -155,7 +155,7 @@ namespace campvis {
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractImageRepresentation::getSubImage
virtual ThisType* getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
virtual ThisType* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Returns a WeaklyTypedPointer to the image data.
......@@ -251,7 +251,7 @@ namespace campvis {
// = Template implementation ======================================================================
template<typename BASETYPE, size_t NUMCHANNELS>
campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::GenericImageRepresentationLocal(const ImageData* parent, ElementType* data)
campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::GenericImageRepresentationLocal(ImageData* parent, ElementType* data)
: ImageRepresentationLocal(parent, TypeTraits<BASETYPE, NUMCHANNELS>::weaklyTypedPointerBaseType)
, _data(data)
{
......@@ -274,12 +274,12 @@ namespace campvis {
}
template<typename BASETYPE, size_t NUMCHANNELS>
GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::clone() const {
GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::clone(ImageData* newParent) const {
size_t numElements = getNumElements();
ElementType* newData = new ElementType[numElements];
memcpy(newData, _data, numElements * sizeof(ElementType));
return new ThisType(_parent, newData);
return new ThisType(newParent, newData);
}
template<typename BASETYPE, size_t NUMCHANNELS>
......@@ -293,14 +293,14 @@ namespace campvis {
}
template<typename BASETYPE, size_t NUMCHANNELS>
GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
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();
return clone(parent);
}
tgt::bvec3 tmp(tgt::greaterThan(newSize, tgt::svec3(1)));
......
......@@ -151,5 +151,15 @@ namespace campvis {
_representations.clear();
}
void ImageData::addRepresentation(const AbstractImageRepresentation* representation) {
tgtAssert(representation != 0, "Representation must not be 0.");
_representations.push_back(representation);
}
void ImageData::setInitialRepresentation(const AbstractImageRepresentation* representation) {
clearRepresentations();
addRepresentation(representation);
}
}
\ No newline at end of file
......@@ -49,6 +49,9 @@ namespace campvis {
* \todo
*/
class ImageData : public AbstractData {
// friend so that it can add itself as representation
friend class AbstractImageRepresentation;
public:
/**
* Creates a new ImageData instance with the given parameters.
......@@ -159,14 +162,6 @@ namespace campvis {
*/
tgt::svec3 indexToPosition(size_t index) const;
/**
* Sets the initial representation of this ImageData.
* \note Removes and deletes all existing representations.
* \param representation Initial representation of this image.
*/
template<typename T>
void setInitialRepresentation(const T* representation);
/**
* Returns a representation of this image of type \a T.
* Looks, whether such a representations already exists, if not and \a performConversion is
......@@ -182,6 +177,20 @@ namespace campvis {
const T* getRepresentation(bool performConversion = true) const;
protected:
/**
* Adds the given representation to the list of representations.
* \note Since this is non-publich method, no sanity checks are performed!
* \param representation representation to add, must not be 0.
*/
void addRepresentation(const AbstractImageRepresentation* representation);
/**
* Sets the initial representation of this ImageData.
* \note Removes and deletes all existing representations.
* \param representation Initial representation of this image.
*/
void setInitialRepresentation(const AbstractImageRepresentation* representation);
/**
* Clears all representations from the vector and frees the memory.
* \note Make sure to call this method only when nobody else holds pointers to the
......@@ -204,12 +213,6 @@ namespace campvis {
// = Template definition ==========================================================================
template<typename T>
void campvis::ImageData::setInitialRepresentation(const T* representation) {
clearRepresentations();
_representations.push_back(representation);
}
template<typename T>
const T* campvis::ImageData::getRepresentation(bool performConversion /*= true*/) const {
// look, whether we already have a suitable representation
......
......@@ -35,7 +35,7 @@
namespace campvis {
const std::string ImageRepresentationDisk::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationDisk";
ImageRepresentationDisk::ImageRepresentationDisk(const ImageData* parent, const std::string& url, WeaklyTypedPointer::BaseType type, size_t offset /*= 0*/, EndianHelper::Endianness endianness /*= EndianHelper::LITTLE_ENDIAN*/, const tgt::svec3& stride /*= tgt::svec2::zero */)
ImageRepresentationDisk::ImageRepresentationDisk(ImageData* parent, const std::string& url, WeaklyTypedPointer::BaseType type, size_t offset /*= 0*/, EndianHelper::Endianness endianness /*= EndianHelper::LITTLE_ENDIAN*/, const tgt::svec3& stride /*= tgt::svec2::zero */)
: GenericAbstractImageRepresentation<ImageRepresentationDisk>(parent)
, _url(url)
, _offset(offset)
......@@ -48,14 +48,14 @@ namespace campvis {
ImageRepresentationDisk::~ImageRepresentationDisk() {
}
ImageRepresentationDisk* ImageRepresentationDisk::getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
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();
return clone(parent);
}
size_t newOffset = _offset + WeaklyTypedPointer::numBytes(_type, _parent->getNumChannels()) * (llf.x + llf.y * size.y + llf.z * size.x * size.y);
......@@ -194,8 +194,8 @@ namespace campvis {
return tgt::svec3(0, size.x, size.x * size.y);
}
ImageRepresentationDisk* ImageRepresentationDisk::clone() const {
return new ImageRepresentationDisk(_parent, _url, _type, _offset, _endianess, _stride);
ImageRepresentationDisk* ImageRepresentationDisk::clone(ImageData* newParent) const {
return new ImageRepresentationDisk(newParent, _url, _type, _offset, _endianess, _stride);
}
size_t ImageRepresentationDisk::getLocalMemoryFootprint() const {
......
......@@ -55,7 +55,7 @@ namespace campvis {
* \param stride Number of _elemments_ _between_ adjacent elements for each dimension (\see ImageRepresentationDisk::_stride).
*/
ImageRepresentationDisk(
const ImageData* parent,
ImageData* parent,
const std::string& url,
WeaklyTypedPointer::BaseType type,
size_t offset = 0,
......@@ -77,8 +77,8 @@ namespace campvis {
*/
static ImageRepresentationDisk* tryConvertFrom(const AbstractImageRepresentation* source);
//\see AbstractImageRepresentation::clone()
virtual ImageRepresentationDisk* clone() const;
/// \see AbstractImageRepresentation::clone()
virtual ImageRepresentationDisk* clone(ImageData* newParent) const;
/// \see AbstractImageRepresentation::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
......@@ -87,7 +87,7 @@ namespace campvis {
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractImageRepresentation::getSubImage
virtual ImageRepresentationDisk* getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
virtual ImageRepresentationDisk* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
......
......@@ -42,14 +42,14 @@ namespace campvis {
const std::string ImageRepresentationGL::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationGL";
ImageRepresentationGL::ImageRepresentationGL(const ImageData* parent, tgt::Texture* texture)
ImageRepresentationGL::ImageRepresentationGL(ImageData* parent, tgt::Texture* texture)
: GenericAbstractImageRepresentation<ImageRepresentationGL>(parent)
, _texture(texture)
{
tgtAssert(texture != 0, "Given texture must not be 0.");
}
ImageRepresentationGL::ImageRepresentationGL(const ImageData* parent, const WeaklyTypedPointer& wtp)
ImageRepresentationGL::ImageRepresentationGL(ImageData* parent, const WeaklyTypedPointer& wtp)
: GenericAbstractImageRepresentation<ImageRepresentationGL>(parent)
{
createTexture(wtp);
......@@ -66,27 +66,27 @@ namespace campvis {
// test source image type via dynamic cast
if (const ImageRepresentationDisk* tester = dynamic_cast<const ImageRepresentationDisk*>(source)) {
WeaklyTypedPointer wtp = tester->getImageData();
ImageRepresentationGL* toReturn = new ImageRepresentationGL(tester->getParent(), wtp);
ImageRepresentationGL* toReturn = new ImageRepresentationGL(const_cast<ImageData*>(tester->getParent()), wtp);
delete wtp._pointer;
return toReturn;
}
else if (const ImageRepresentationLocal* tester = dynamic_cast<const ImageRepresentationLocal*>(source)) {
ImageRepresentationGL* toReturn = new ImageRepresentationGL(tester->getParent(), tester->getWeaklyTypedPointer());
ImageRepresentationGL* toReturn = new ImageRepresentationGL(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
return toReturn;
}
return 0;
}
ImageRepresentationGL* ImageRepresentationGL::clone() const {
ImageRepresentationGL* ImageRepresentationGL::clone(ImageData* newParent) const {
GLubyte* data = _texture->downloadTextureToBuffer();
WeaklyTypedPointer wtp(WeaklyTypedPointer::baseType(_texture->getDataType()), WeaklyTypedPointer::numChannels(_texture->getFormat()), data);
ImageRepresentationGL* toReturn = new ImageRepresentationGL(_parent, wtp);
ImageRepresentationGL* toReturn = new ImageRepresentationGL(newParent, wtp);
delete data;
return toReturn;
}
ImageRepresentationGL* ImageRepresentationGL::getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
ImageRepresentationGL* ImageRepresentationGL::getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
// TODO: implement
//LWARNING("ImageRepresentationGL::getSubImage() not implemented!");
return 0;
......
......@@ -56,7 +56,7 @@ namespace campvis {
* \param parent Image this representation represents, must not be 0.
* \param texture OpenGL texture to use, must not be 0, ImageRepresentationGL will take ownership of this texture.
*/
ImageRepresentationGL(const ImageData* parent, tgt::Texture* texture);
ImageRepresentationGL(ImageData* parent, tgt::Texture* texture);
/**
* Creates a new ImageRepresentationGL representation.
......@@ -64,7 +64,7 @@ namespace campvis {
* \param parent Image this representation represents, must not be 0.
* \param wtp WeaklyTypedPointer to the image data, must not be 0, ImageRepresentationGL does \b not take ownership of that pointer.
*/
ImageRepresentationGL(const ImageData* parent, const WeaklyTypedPointer& wtp);
ImageRepresentationGL(ImageData* parent, const WeaklyTypedPointer& wtp);
/**
* Creates a new ImageRepresentationGL representation from GenericImageRepresentationLocal.
......@@ -75,7 +75,7 @@ namespace campvis {
* \tparam NUMCHANNELS Number of channels per element
*/
template<typename BASETYPE, size_t NUMCHANNELS>
ImageRepresentationGL(const ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
/**
* Destructor
......@@ -95,7 +95,7 @@ namespace campvis {
/**
* \see AbstractImageRepresentation::clone()
**/
virtual ImageRepresentationGL* clone() const;
virtual ImageRepresentationGL* clone(ImageData* newParent) const;
/// \see AbstractImageRepresentation::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
......@@ -106,7 +106,7 @@ namespace campvis {
/**
* \see AbstractImageRepresentation::getSubImage
*/
virtual ImageRepresentationGL* getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
virtual ImageRepresentationGL* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
......@@ -164,7 +164,7 @@ namespace campvis {
// = Template definition ==========================================================================
template<typename BASETYPE, size_t NUMCHANNELS>
campvis::ImageRepresentationGL::ImageRepresentationGL(const ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data)
campvis::ImageRepresentationGL::ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data)
: AbstractImageRepresentation(parent)
{
createTexture<BASETYPE, NUMCHANNELS>(data);
......
......@@ -96,7 +96,7 @@ namespace campvis {
const std::string ImageRepresentationLocal::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationLocal";
ImageRepresentationLocal::ImageRepresentationLocal(const ImageData* parent, WeaklyTypedPointer::BaseType baseType)
ImageRepresentationLocal::ImageRepresentationLocal(ImageData* parent, WeaklyTypedPointer::BaseType baseType)
: GenericAbstractImageRepresentation<ImageRepresentationLocal>(parent)
, _baseType(baseType)
, _intensityHistogram(0)
......@@ -155,7 +155,7 @@ namespace campvis {
#define CONVERT_TO_GENERIC_LOCAL(baseType,numChannels) \
return new GenericImageRepresentationLocal<baseType, numChannels>( \
source->getParent(), \
const_cast<ImageData*>(source->getParent()), \
reinterpret_cast< TypeTraits<baseType, numChannels>::ElementType*>(wtp._pointer));
#define DISPATCH_CONVERSION(numChannels) \
......
......@@ -56,7 +56,7 @@ namespace campvis {
* \param size Size of this image (number of elements per dimension)
* \param baseType Base type of the image data.
*/
ImageRepresentationLocal(const ImageData* parent, WeaklyTypedPointer::BaseType baseType);
ImageRepresentationLocal(ImageData* parent, WeaklyTypedPointer::BaseType baseType);
/**
* Destructor
......@@ -73,10 +73,10 @@ namespace campvis {
static ImageRepresentationLocal* tryConvertFrom(const AbstractImageRepresentation* source);
/// \see AbstractData::clone()
virtual ImageRepresentationLocal* clone() const = 0;
virtual ImageRepresentationLocal* clone(ImageData* newParent) const = 0;
/// \see ImageData::getSubImage()
virtual ImageRepresentationLocal* getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
virtual ImageRepresentationLocal* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
/**
* Returns a WeaklyTypedPointer to the image data.
......
......@@ -45,11 +45,10 @@ namespace campvis {
std::pair<ImageData*, ImageRepresentationRenderTarget*> ImageRepresentationRenderTarget::createWithImageData(const tgt::svec2& size, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/) {
ImageData* id = new ImageData(2, tgt::svec3(size, 1), 4);
ImageRepresentationRenderTarget* toReturn = new ImageRepresentationRenderTarget(id, internalFormatColor, internalFormatDepth);
id->setInitialRepresentation(toReturn);
return std::make_pair(id, toReturn);
}
ImageRepresentationRenderTarget::ImageRepresentationRenderTarget(const ImageData* parent, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/)
ImageRepresentationRenderTarget::ImageRepresentationRenderTarget(ImageData* parent, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/)
: GenericAbstractImageRepresentation<ImageRepresentationRenderTarget>(parent)
, _colorTextures(0)
, _depthTexture(0)
......@@ -75,7 +74,7 @@ namespace campvis {
tgtAssert(_fbo != 0, "Framebuffer object is 0, something went terribly wrong...");
}
ImageRepresentationRenderTarget::ImageRepresentationRenderTarget(const ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture /* = 0 */)
ImageRepresentationRenderTarget::ImageRepresentationRenderTarget(ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture /* = 0 */)
: GenericAbstractImageRepresentation<ImageRepresentationRenderTarget>(parent)
, _colorTextures(0)
, _depthTexture(0)
......@@ -168,12 +167,12 @@ namespace campvis {
shader->setIgnoreUniformLocationError(tmp);
}
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::clone() const {
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::clone(ImageData* newParent) const {
tgtAssert(false, "To be implemented!");
return 0;
}
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const {
tgtAssert(false, "To be implemented!");
return 0;
}
......
......@@ -78,14 +78,14 @@ namespace campvis {
* \param internalFormatColor Internal OpenGL format for the color texture.
* \param internalFormatDepth Internal OpenGL format for the depth texture.
*/
ImageRepresentationRenderTarget(const ImageData* parent, GLint internalFormatColor = GL_RGBA8, GLint internalFormatDepth = GL_DEPTH_COMPONENT24);
ImageRepresentationRenderTarget(ImageData* parent, GLint internalFormatColor = GL_RGBA8, GLint internalFormatDepth = GL_DEPTH_COMPONENT24);
/**
* Creates a new ImageRepresentationRenderTarget from one color texture and one optional depth texture.
* \param colorTexture Color texture, must not be 0
* \param depthTexture Depth texture, optional, must have valid internal format and same dimensions as \a colorTexture
*/
ImageRepresentationRenderTarget(const ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture = 0);
ImageRepresentationRenderTarget(ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture = 0);
/**
* Destructor
......@@ -102,7 +102,7 @@ namespace campvis {
static ImageRepresentationRenderTarget* tryConvertFrom(const AbstractImageRepresentation* source);
/// \see AbstractImageRepresentation::clone()
virtual ImageRepresentationRenderTarget* clone() const;
virtual ImageRepresentationRenderTarget* clone(ImageData* newParent) const;
/// \see AbstractImageRepresentation::getLocalMemoryFootprint()
virtual size_t getLocalMemoryFootprint() const;
......@@ -111,7 +111,7 @@ namespace campvis {
virtual size_t getVideoMemoryFootprint() const;
/// \see AbstractImageRepresentation::getSubImage
virtual ImageRepresentationRenderTarget* getSubImage(const ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
virtual ImageRepresentationRenderTarget* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const;
/**
* Creates and initializes a new OpenGL texture according to \a internalFormat and attaches it to the FBO.
......
......@@ -80,7 +80,7 @@ namespace campvis {
tgt::Texture* tex = _devilTextureReader->loadTexture(p_url.getValue(), tgt::Texture::LINEAR, false, true, true, false);
if (tex != 0) {
ImageData id (2, tex->getDimensions(), tex->getNumChannels());
ImageRepresentationGL image(&id, tex);
ImageRepresentationGL* image = new ImageRepresentationGL(&id, tex);
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
......@@ -94,7 +94,7 @@ namespace campvis {
_shader->setIgnoreUniformLocationError(false);
tgt::TextureUnit texUnit;
image.bind(_shader, texUnit, "_colorTexture");
image->bind(_shader, texUnit, "_colorTexture");
rt.second->activate();
LGL_ERROR;
......
......@@ -170,7 +170,7 @@ namespace campvis {
// all parsing done - lets create the image:
ImageData* image = new ImageData(dimensionality, size, 1);
image->setInitialRepresentation(new ImageRepresentationDisk(image, url, pt, offset, e));
ImageRepresentationDisk* ird = new ImageRepresentationDisk(image, url, pt, offset, e);
image->setMappingInformation(ImageMappingInformation(size, imageOffset + p_imageOffset.getValue(), voxelSize + p_voxelSize.getValue()));
data.addData(p_targetImageID.getValue(), image);
p_targetImageID.issueWrite();
......
......@@ -115,7 +115,6 @@ namespace campvis {
asFloats[i] = img->getElementNormalized(i, 0);
ImageData* id = new ImageData(img->getDimensionality(), img->getSize(), img->getParent()->getNumChannels());
GenericImageRepresentationLocal<float, 1>* imageWithFloats = new GenericImageRepresentationLocal<float, 1>(id, asFloats);
id->setInitialRepresentation(imageWithFloats);
DataHandle dh = _data.addData("clr.input", id);
......
......@@ -107,7 +107,6 @@ namespace campvis {
GenericImageRepresentationLocal<float, 4>* output = new GenericImageRepresentationLocal<float, 4>(id, 0);
tbb::parallel_for(tbb::blocked_range<size_t>(0, input->getNumElements()), ApplyCentralDifferences(input, output));
id->setInitialRepresentation(output);
data.addData(p_targetImageID.getValue(), id);
p_targetImageID.issueWrite();
}
......
......@@ -70,7 +70,7 @@ namespace campvis {
if (input != 0 && input->getParent()->getNumChannels() == 1) {
ImageData* id = new ImageData(input->getDimensionality(), input->getSize(), 1);
ImageRepresentationLocal* output = input->clone();
ImageRepresentationLocal* output = input->clone(id);
if (p_filterMode.getOptionValue() == "median") {
tbb::parallel_for(
......@@ -83,7 +83,6 @@ namespace campvis {
ImageFilterGauss(input, output, p_kernelSize.getValue(), p_sigma.getValue()));
}
id->setInitialRepresentation(output);
data.addData(p_targetImageID.getValue(), id);
p_targetImageID.issueWrite();
}
......
......@@ -167,11 +167,9 @@ namespace campvis {
if (intensities != 0 && gradients != 0) {
ImageData* imgFl = new ImageData(intensities->getDimensionality(), intensities->getSize(), 1);
ImageRepresentationLocal* fl = new GenericImageRepresentationLocal<float, 1>(imgFl, 0);
imgFl->setInitialRepresentation(fl);
ImageData* imgFh = new ImageData(intensities->getDimensionality(), intensities->getSize(), 1);
ImageRepresentationLocal* fh = new GenericImageRepresentationLocal<float, 1>(imgFh, 0);
imgFh->setInitialRepresentation(fh);
const GenericImageRepresentationLocal<float, 4>* ggg = gradients;
tbb::parallel_for(tbb::blocked_range<size_t>(0, intensities->getNumElements()), LHGenerator(intensities, ggg, fl, fh, .003f));
......@@ -191,7 +189,6 @@ namespace campvis {
WeaklyTypedPointer wtp(WeaklyTypedPointer::FLOAT, 1, tmp);
ImageData* imgTex = new ImageData(2, tgt::svec3(256, 256, 1), 1);
ImageRepresentationGL* tex = new ImageRepresentationGL(imgTex, wtp);
imgTex->setInitialRepresentation(tex);
delete [] tmp;
data.addData("foo", imgTex);
......
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