The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit e90692d8 authored by schultezub's avatar schultezub
Browse files

#5: Making constructors of ImageRepresentationXYZ protected - new image...

#5: Making constructors of ImageRepresentationXYZ protected - new image representations are to be created via ImageRepresentationXYZ::create().
    This makes much more sense, since the pointer of the newly create image representation is owned by the parent ImageData instead of the caller.

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@443 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent bf0a6d1b
......@@ -37,7 +37,6 @@ namespace campvis {
: _parent(parent)
{
tgtAssert(parent != 0, "Parent ImageData must not be 0!");
parent->addRepresentation(this);
}
AbstractImageRepresentation::~AbstractImageRepresentation() {
......@@ -59,5 +58,9 @@ namespace campvis {
return _parent->getNumElements();
}
void AbstractImageRepresentation::addToParent() const {
const_cast<ImageData*>(_parent)->addRepresentation(this);
}
}
\ No newline at end of file
......@@ -111,6 +111,15 @@ namespace campvis {
virtual AbstractImageRepresentation* getSubImage(ImageData* parent, const tgt::svec3& llf, const tgt::svec3& urb) const = 0;
protected:
/**
* Adds this image representations to the parent image data.
*/
void addToParent() const;
/// Not copy-constructable
AbstractImageRepresentation(const AbstractImageRepresentation& rhs);
/// Not assignable
AbstractImageRepresentation& operator=(const AbstractImageRepresentation& rhs);
const ImageData* _parent; ///< Image this representation represents, must not be 0.
......
......@@ -140,12 +140,16 @@ namespace campvis {
};
/**
* Creates a new strongly typed ImageData object storing the image in the local memory.
* Creates a new GenericImageRepresentationLocal with the given parameters and automatically
* adds it to \a parent which will take ownerwhip.
*
* \param parent Image this representation represents, must not be 0.
* \note You do \b not own the returned pointer.
*
* \param parent Image this representation represents, must not be 0, will take ownership of the returned pointer.
* \param data Pointer to the image data, must not be 0, GenericImageRepresentationLocal takes ownership of this pointer!
* \return A pointer to the newly created ImageRepresentationDisk, you do \b not own this pointer!
*/
GenericImageRepresentationLocal(ImageData* parent, ElementType* data);
static GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* create(ImageData* parent, ElementType* data);
/**
* Destructor
......@@ -156,9 +160,9 @@ namespace campvis {
/**
* Performs a conversion of \a source to an ImageRepresentationLocal if feasible.
* Returns 0 if conversion was not successful or source representation type is not compatible.
* \note The caller has to take ownership of the returned pointer if not 0.
* \note The callee, respectively the callee's parent, has the ownership of the returned pointer.
* \param source Source image representation for conversion.
* \return A pointer to a local representation of \a source or 0 on failure. The caller has to take ownership.
* \return A pointer to a local representation of \a source or 0 on failure. The caller does \b not have ownership.
*/
static GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* tryConvertFrom(const AbstractImageRepresentation* source);
......@@ -260,6 +264,13 @@ namespace campvis {
ElementType getElementLinear(const tgt::vec3 position) const;
protected:
/**
* Creates a new strongly typed ImageData object storing the image in the local memory.
*
* \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(ImageData* parent, ElementType* data);
ElementType* _data;
......@@ -267,6 +278,13 @@ namespace campvis {
// = Template implementation ======================================================================
template<typename BASETYPE, size_t NUMCHANNELS>
campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::create(ImageData* parent, ElementType* data) {
ThisType* toReturn = new ThisType(parent, data);
toReturn->addToParent();
return toReturn;
}
template<typename BASETYPE, size_t NUMCHANNELS>
campvis::GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>::GenericImageRepresentationLocal(ImageData* parent, ElementType* data)
: ImageRepresentationLocal(parent, TypeTraits<BASETYPE, NUMCHANNELS>::weaklyTypedPointerBaseType)
......@@ -296,7 +314,7 @@ namespace campvis {
ElementType* newData = new ElementType[numElements];
memcpy(newData, _data, numElements * sizeof(ElementType));
return new ThisType(newParent, newData);
return ThisType::create(newParent, newData);
}
template<typename BASETYPE, size_t NUMCHANNELS>
......
......@@ -123,6 +123,7 @@ namespace campvis {
// create sub-image of every image representation
for (std::vector<const AbstractImageRepresentation*>::iterator it = _representations.begin(); it != _representations.end(); ++it) {
AbstractImageRepresentation* si = (*it)->getSubImage(toReturn, llf, urb);
toReturn->addRepresentation(si);
}
return toReturn;
......
......@@ -35,6 +35,12 @@
namespace campvis {
const std::string ImageRepresentationDisk::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationDisk";
ImageRepresentationDisk* ImageRepresentationDisk::create(ImageData* parent, const std::string& url, WeaklyTypedPointer::BaseType type, size_t offset /*= 0*/, EndianHelper::Endianness endianness /*= EndianHelper::LITTLE_ENDIAN*/, const tgt::svec3& stride /*= tgt::svec3::zero */) {
ImageRepresentationDisk* toReturn = new ImageRepresentationDisk(parent, url, type, offset, endianness, stride);
toReturn->addToParent();
return toReturn;
}
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)
......@@ -195,7 +201,7 @@ namespace campvis {
}
ImageRepresentationDisk* ImageRepresentationDisk::clone(ImageData* newParent) const {
return new ImageRepresentationDisk(newParent, _url, _type, _offset, _endianess, _stride);
return ImageRepresentationDisk::create(newParent, _url, _type, _offset, _endianess, _stride);
}
size_t ImageRepresentationDisk::getLocalMemoryFootprint() const {
......
......@@ -45,16 +45,20 @@ namespace campvis {
class ImageRepresentationDisk : public GenericAbstractImageRepresentation<ImageRepresentationDisk> {
public:
/**
* Creates a new ImageData disk representation.
* Creates a new ImageRepresentationDisk with the given parameters and automatically
* adds it to \a parent which will take ownerwhip.
*
* \param parent Image this representation represents, must not be 0.
* \note You do \b not own the returned pointer.
*
* \param parent Image this representation represents, must not be 0, will take ownership of the returned pointer.
* \param url Path to file with raw data
* \param type Base type of data
* \param offset Offset of first data element in file (in bytes)
* \param endianness Endianess of data
* \param stride Number of _elemments_ _between_ adjacent elements for each dimension (\see ImageRepresentationDisk::_stride).
* \param stride Number of _elements_ _between_ adjacent elements for each dimension (\see ImageRepresentationDisk::_stride).
* \return A pointer to the newly created ImageRepresentationDisk, you do \b not own this pointer!
*/
ImageRepresentationDisk(
static ImageRepresentationDisk* create(
ImageData* parent,
const std::string& url,
WeaklyTypedPointer::BaseType type,
......@@ -63,6 +67,7 @@ namespace campvis {
const tgt::svec3& stride = tgt::svec3::zero
);
/**
* Destructor
*/
......@@ -71,9 +76,9 @@ namespace campvis {
/**
* Performs a conversion of \a source to an ImageRepresentationLocal if feasible.
* Returns 0 if conversion was not successful or source representation type is not compatible.
* \note The caller has to take ownership of the returned pointer if not 0.
* \note The callee, respectively the callee's parent, has the ownership of the returned pointer.
* \param source Source image representation for conversion.
* \return A pointer to a local representation of \a source or 0 on failure. The caller has to take ownership.
* \return A pointer to a local representation of \a source or 0 on failure. The caller does \b not have ownership.
*/
static ImageRepresentationDisk* tryConvertFrom(const AbstractImageRepresentation* source);
......@@ -104,7 +109,28 @@ namespace campvis {
*/
WeaklyTypedPointer::BaseType getBaseType() const;
private:
protected:
/**
* Creates a new ImageData disk representation.
* \note The Constructor is protected since image representations are not supposed to be
* created via the new operator - use ImageRepresentationDisk::create() instead.
*
* \param parent Image this representation represents, must not be 0.
* \param url Path to file with raw data
* \param type Base type of data
* \param offset Offset of first data element in file (in bytes)
* \param endianness Endianess of data
* \param stride Number of _elements_ _between_ adjacent elements for each dimension (\see ImageRepresentationDisk::_stride).
*/
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::svec3::zero
);
/**
* Calculates the canonical stride for the given image size.
* \param size Image size (number of elements per dimension).
......
......@@ -45,6 +45,18 @@ namespace campvis {
const std::string ImageRepresentationGL::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationGL";
ImageRepresentationGL* ImageRepresentationGL::create(ImageData* parent, tgt::Texture* texture) {
ImageRepresentationGL* toReturn = new ImageRepresentationGL(parent, texture);
toReturn->addToParent();
return toReturn;
}
ImageRepresentationGL* ImageRepresentationGL::create(ImageData* parent, const WeaklyTypedPointer& wtp) {
ImageRepresentationGL* toReturn = new ImageRepresentationGL(parent, wtp);
toReturn->addToParent();
return toReturn;
}
ImageRepresentationGL::ImageRepresentationGL(ImageData* parent, tgt::Texture* texture)
: GenericAbstractImageRepresentation<ImageRepresentationGL>(parent)
, _texture(texture)
......@@ -69,17 +81,17 @@ 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(const_cast<ImageData*>(tester->getParent()), wtp);
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(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(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
return toReturn;
}
#ifdef CAMPVIS_HAS_MODULE_ITK
else if (const AbstractImageRepresentationItk* tester = dynamic_cast<const AbstractImageRepresentationItk*>(source)) {
ImageRepresentationGL* toReturn = new ImageRepresentationGL(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(const_cast<ImageData*>(tester->getParent()), tester->getWeaklyTypedPointer());
return toReturn;
}
#endif
......@@ -90,7 +102,7 @@ namespace campvis {
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(newParent, wtp);
ImageRepresentationGL* toReturn = ImageRepresentationGL::create(newParent, wtp);
delete data;
return toReturn;
}
......
......@@ -49,33 +49,29 @@ namespace campvis {
*/
class ImageRepresentationGL : public GenericAbstractImageRepresentation<ImageRepresentationGL> {
public:
/**
* Creates a new ImageRepresentationGL representation from a tgt::Texture.
* Creates a new ImageRepresentationGL representation from a tgt::Texture and automatically
* adds it to \a parent which will take ownerwhip.
*
* \param parent Image this representation represents, must not be 0.
* \note You do \b not own the returned pointer.
*
* \param parent Image this representation represents, must not be 0, will take ownership of the returned pointer.
* \param texture OpenGL texture to use, must not be 0, ImageRepresentationGL will take ownership of this texture.
* \return A pointer to the newly created ImageRepresentationGL, you do \b not own this pointer!
*/
ImageRepresentationGL(ImageData* parent, tgt::Texture* texture);
static ImageRepresentationGL* create(ImageData* parent, tgt::Texture* texture);
/**
* Creates a new ImageRepresentationGL representation.
* Creates a new ImageRepresentationGL representation from a tgt::Texture and automatically
* adds it to \a parent which will take ownerwhip.
*
* \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(ImageData* parent, const WeaklyTypedPointer& wtp);
/**
* Creates a new ImageRepresentationGL representation from GenericImageRepresentationLocal.
* \note You do \b not own the returned pointer.
*
* \param parent Image this representation represents, must not be 0.
* \param data Pointer to the GenericImageRepresentationLocal instance, must not be 0
* \tparam BASETYPE Base type of image data
* \tparam NUMCHANNELS Number of channels per element
* \param parent Image this representation represents, must not be 0, will take ownership of the returned pointer.
* \param wtp WeaklyTypedPointer to the image data, must not be 0, ImageRepresentationGL does \b not take ownership of that pointer.
* \return A pointer to the newly created ImageRepresentationGL, you do \b not own this pointer!
*/
template<typename BASETYPE, size_t NUMCHANNELS>
ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
static ImageRepresentationGL* create(ImageData* parent, const WeaklyTypedPointer& wtp);
/**
* Destructor
......@@ -86,9 +82,9 @@ namespace campvis {
/**
* Performs a conversion of \a source to an ImageRepresentationLocal if feasible.
* Returns 0 if conversion was not successful or source representation type is not compatible.
* \note The caller has to take ownership of the returned pointer if not 0.
* \note The callee, respectively the callee's parent, has the ownership of the returned pointer.
* \param source Source image representation for conversion.
* \return A pointer to a local representation of \a source or 0 on failure. The caller has to take ownership.
* \return A pointer to a local representation of \a source or 0 on failure. The caller does \b not have ownership.
*/
static ImageRepresentationGL* tryConvertFrom(const AbstractImageRepresentation* source);
......@@ -139,6 +135,33 @@ namespace campvis {
protected:
/**
* Creates a new ImageRepresentationGL representation from a tgt::Texture.
*
* \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(ImageData* parent, tgt::Texture* texture);
/**
* Creates a new ImageRepresentationGL representation.
*
* \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(ImageData* parent, const WeaklyTypedPointer& wtp);
/**
* Creates a new ImageRepresentationGL representation from GenericImageRepresentationLocal.
*
* \param parent Image this representation represents, must not be 0.
* \param data Pointer to the GenericImageRepresentationLocal instance, must not be 0
* \tparam BASETYPE Base type of image data
* \tparam NUMCHANNELS Number of channels per element
*/
template<typename BASETYPE, size_t NUMCHANNELS>
ImageRepresentationGL(ImageData* parent, const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* data);
/**
* Creates the OpenGL texture from the given pointer \a wtp.
* \param wtp WeaklyTypedPointer with source image data
......
......@@ -140,7 +140,7 @@ namespace campvis {
\
PixelType* pixelDataCopy = new PixelType[tgt::hmul(size)]; \
memcpy(pixelDataCopy, pixelData, tgt::hmul(size) * TypeTraits<basetype, 1>::elementSize); \
return new GenericImageRepresentationLocal<PixelType, 1>(const_cast<ImageData*>(source->getParent()), pixelDataCopy); \
return GenericImageRepresentationLocal<PixelType, 1>::create(const_cast<ImageData*>(source->getParent()), pixelDataCopy); \
}
#define DISPATCH_ITK_TO_GENERIC_LOCAL_CONVERSION_ND(numchannels, dimensionality) \
......@@ -201,7 +201,7 @@ namespace campvis {
WeaklyTypedPointer wtp = source->getImageData();
#define CONVERT_DISK_TO_GENERIC_LOCAL(baseType,numChannels) \
return new GenericImageRepresentationLocal<baseType, numChannels>( \
return GenericImageRepresentationLocal<baseType, numChannels>::create( \
const_cast<ImageData*>(source->getParent()), \
reinterpret_cast< TypeTraits<baseType, numChannels>::ElementType*>(wtp._pointer));
......
......@@ -49,15 +49,6 @@ namespace campvis {
public:
typedef ConcurrentGenericHistogramND<float, 1> IntensityHistogramType;
/**
* Creates a new ImageData representation in local memory.
*
* \param dimensionality Dimensionality of data
* \param size Size of this image (number of elements per dimension)
* \param baseType Base type of the image data.
*/
ImageRepresentationLocal(ImageData* parent, WeaklyTypedPointer::BaseType baseType);
/**
* Destructor
*/
......@@ -66,9 +57,9 @@ namespace campvis {
/**
* Performs a conversion of \a source to an ImageRepresentationLocal if feasible.
* Returns 0 if conversion was not successful or source representation type is not compatible.
* \note The caller has to take ownership of the returned pointer if not 0.
* \note The callee, respectively the callee's parent, has the ownership of the returned pointer.
* \param source Source image representation for conversion.
* \return A pointer to a local representation of \a source or 0 on failure. The caller has to take ownership.
* \return A pointer to a local representation of \a source or 0 on failure. The caller does \b not have ownership.
*/
static ImageRepresentationLocal* tryConvertFrom(const AbstractImageRepresentation* source);
......@@ -190,6 +181,15 @@ namespace campvis {
const IntensityHistogramType& getIntensityHistogram() const;
protected:
/**
* Creates a new ImageData representation in local memory.
*
* \param dimensionality Dimensionality of data
* \param size Size of this image (number of elements per dimension)
* \param baseType Base type of the image data.
*/
ImageRepresentationLocal(ImageData* parent, WeaklyTypedPointer::BaseType baseType);
/**
* Computes the normalized intensity range.
*/
......
......@@ -42,9 +42,16 @@ namespace campvis {
const std::string ImageRepresentationRenderTarget::loggerCat_ = "CAMPVis.core.datastructures.ImageRepresentationRenderTarget";
ImageRepresentationRenderTarget* ImageRepresentationRenderTarget::create(ImageData* parent, GLint internalFormatColor /*= GL_RGBA8*/, GLint internalFormatDepth /*= GL_DEPTH_COMPONENT24*/) {
ImageRepresentationRenderTarget* toReturn = new ImageRepresentationRenderTarget(parent, internalFormatColor, internalFormatDepth);
toReturn->addToParent();
return toReturn;
}
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);
toReturn->addToParent();
return std::make_pair(id, toReturn);
}
......
......@@ -61,31 +61,28 @@ namespace campvis {
class ImageRepresentationRenderTarget : public GenericAbstractImageRepresentation<ImageRepresentationRenderTarget> {
public:
/**
* Creates a new ImageRepresentationRenderTarget and a new ImageData with the given specifications.
* Assigns the representation to the image.
* Creates a new ImageRepresentationRenderTarget representation with one color and one depth attachment
* and automatically adds it to \a parent which will take ownerwhip.
*
* \param size Size of this image (number of elements per dimension)
* \note You do \b not own the returned pointer..
*
* \param parent Image this representation represents, must not be 0, will take ownership of the returned pointer.
* \param internalFormatColor Internal OpenGL format for the color texture.
* \param internalFormatDepth Internal OpenGL format for the depth texture.
* \return A pair of the created ImageData and the created RenderTarget image representation.
* \return A pointer to the newly created ImageRepresentationRenderTarget, you do \b not own this pointer!
*/
static std::pair<ImageData*, ImageRepresentationRenderTarget*> createWithImageData(const tgt::svec2& size, GLint internalFormatColor = GL_RGBA8, GLint internalFormatDepth = GL_DEPTH_COMPONENT24);
static ImageRepresentationRenderTarget* create(ImageData* parent, GLint internalFormatColor = GL_RGBA8, GLint internalFormatDepth = GL_DEPTH_COMPONENT24);
/**
* Creates a new ImageRepresentationRenderTarget representation with one color and one depth attachment.
* Creates a new ImageRepresentationRenderTarget and a new ImageData with the given specifications.
* Assigns the representation to the image.
*
* \param parent Image this representation represents, must not be 0.
* \param size Size of this image (number of elements per dimension)
* \param internalFormatColor Internal OpenGL format for the color texture.
* \param internalFormatDepth Internal OpenGL format for the depth texture.
* \return A pair of the created ImageData and the created RenderTarget image representation.
*/
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(ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture = 0);
static std::pair<ImageData*, ImageRepresentationRenderTarget*> createWithImageData(const tgt::svec2& size, GLint internalFormatColor = GL_RGBA8, GLint internalFormatDepth = GL_DEPTH_COMPONENT24);
/**
* Destructor
......@@ -95,9 +92,9 @@ namespace campvis {
/**
* Performs a conversion of \a source to an ImageRepresentationLocal if feasible.
* Returns 0 if conversion was not successful or source representation type is not compatible.
* \note The caller has to take ownership of the returned pointer if not 0.
* \note The callee, respectively the callee's parent, has the ownership of the returned pointer.
* \param source Source image representation for conversion.
* \return A pointer to a local representation of \a source or 0 on failure. The caller has to take ownership.
* \return A pointer to a local representation of \a source or 0 on failure. The caller does \b not have ownership.
*/
static ImageRepresentationRenderTarget* tryConvertFrom(const AbstractImageRepresentation* source);
......@@ -193,6 +190,21 @@ namespace campvis {
protected:
/**
* Creates a new ImageRepresentationRenderTarget representation with one color and one depth attachment.
*
* \param parent Image this representation represents, must not be 0.
* \param internalFormatColor Internal OpenGL format for the color texture.
* \param internalFormatDepth Internal OpenGL format for the depth texture.
*/
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(ImageData* parent, const ImageRepresentationGL* colorTexture, const ImageRepresentationGL* depthTexture = 0);
std::vector<tgt::Texture*> _colorTextures; ///< color textures
tgt::Texture* _depthTexture; ///< depth texture
......
......@@ -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 = new ImageRepresentationGL(&id, tex);
ImageRepresentationGL* image = ImageRepresentationGL::create(&id, tex);
std::pair<ImageData*, ImageRepresentationRenderTarget*> rt = ImageRepresentationRenderTarget::createWithImageData(_renderTargetSize.getValue());
glPushAttrib(GL_ALL_ATTRIB_BITS);
......
......@@ -170,7 +170,7 @@ namespace campvis {
// all parsing done - lets create the image:
ImageData* image = new ImageData(dimensionality, size, 1);
ImageRepresentationDisk* ird = new ImageRepresentationDisk(image, url, pt, offset, e);
ImageRepresentationDisk::create(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();
......
......@@ -170,7 +170,7 @@ namespace campvis {
file >> tmp; \
data[i] = static_cast<C_TYPE>(tmp); \
} \
rep = new GenericImageRepresentationLocal<C_TYPE, 1>(image, data); \
rep = GenericImageRepresentationLocal<C_TYPE, 1>::create(image, data); \
} \
} while (0)
......
......@@ -46,14 +46,6 @@ namespace campvis {
*/
class AbstractImageRepresentationItk : public AbstractImageRepresentation {
public:
/**
* Creates a new AbstractImageRepresentationItk. Just calls the base constructor.
* \param parent Parent image data of this representation.
*/
AbstractImageRepresentationItk(ImageData* parent)
: AbstractImageRepresentation(parent)
{};
/// Virtual destructor
virtual ~AbstractImageRepresentationItk() {};
......@@ -64,6 +56,15 @@ namespace campvis {
* \return A WeaklyTypedPointer to the image data.
*/
virtual WeaklyTypedPointer getWeaklyTypedPointer() const = 0;
protected:
/**
* Creates a new AbstractImageRepresentationItk. Just calls the base constructor.
* \param parent Parent image data of this representation.
*/
AbstractImageRepresentationItk(ImageData* parent)
: AbstractImageRepresentation(parent)
{};
};
/**
......@@ -178,7 +179,7 @@ namespace campvis {
* \param parent Image this representation represents, must not be 0.
* \param data Pointer to the image data, must not be 0, GenericImageRepresentationItk takes ownership of this pointer!
*/
GenericImageRepresentationItk(ImageData* parent, typename ItkImageType::Pointer itkImage);
static GenericImageRepresentationItk<BASETYPE, NUMCHANNELS, DIMENSIONALITY>* create(ImageData* parent, typename ItkImageType::Pointer itkImage);
/**
* Destructor
......@@ -228,6 +229,13 @@ namespace campvis {
typename ItkImageType::ConstPointer getItkImage() const;
protected:
/**
* Creates a new strongly typed ImageData object storing the image in the local memory.
*
* \param parent Image this representation represents, must not be 0.
* \param data Pointer to the image data, must not be 0, GenericImageRepresentationItk takes ownership of this pointer!
*/
GenericImageRepresentationItk(ImageData* parent, typename ItkImageType::Pointer itkImage);
typename ItkImageType::Pointer _itkImage;
......@@ -235,6 +243,13 @@ namespace campvis {