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

Fixed invalidation handling in MhdImageWriter processor. Updated campvis Lua...

Fixed invalidation handling in MhdImageWriter processor. Updated campvis Lua bindings to support image access (added bindings for ImageData and ImageRepresentationLocal).
parent 08569981
......@@ -12,6 +12,7 @@
#include "core/datastructures/abstractdata.h"
#include "core/datastructures/dataseries.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationlocal.h"
#include "core/properties/allproperties.h"
#include "core/pipeline/abstractprocessor.h"
#include "core/pipeline/abstractworkflow.h"
......@@ -375,10 +376,103 @@ namespace campvis {
ImageData(size_t dimensionality, const cgt::svec3& size, size_t numChannels);
virtual ~ImageData();
virtual ImageData* clone() const;
virtual AbstractData* clone() const;
virtual size_t getLocalMemoryFootprint() const;
virtual size_t getVideoMemoryFootprint() const;
virtual std::string getTypeAsString() const;
size_t getDimensionality() const;
const cgt::svec3& getSize() const;
size_t getNumChannels() const;
size_t getNumElements() const;
virtual cgt::Bounds getWorldBounds() const;
cgt::Bounds getWorldBounds(const cgt::svec3& llf, const cgt::svec3& urb) const;
size_t positionToIndex(const cgt::svec3& position) const;
cgt::svec3 indexToPosition(size_t index) const;
template<typename T>
const T* getRepresentation(bool performConversion = true) const;
%template(getRepresentationLocal) ImageData::getRepresentation<campvis::ImageRepresentationLocal>;
struct WeaklyTypedPointer {
enum BaseType {
UINT8, ///< unsigned 8 bit integer
INT8, ///< signed 8 bit integer
UINT16, ///< unsigned 16 bit integer
INT16, ///< signed 16 bit integer
UINT32, ///< unsigned 32 bit integer
INT32, ///< signed 32 bit integer
FLOAT ///< float
static size_t numBytes(BaseType bt, size_t numChannels = 1);
WeaklyTypedPointer(BaseType pt, size_t numChannels, void* ptr);
virtual ~WeaklyTypedPointer();
bool operator==(const WeaklyTypedPointer& rhs) const;
size_t getNumBytesPerElement() const;
GLint getGlFormat() const;
GLenum getGlDataType() const;
GLint getGlInternalFormat() const;
bool isInteger() const;
bool isSigned() const;
BaseType _baseType; ///< Base data type of the pointer
size_t _numChannels; ///< Number of channels, must be in [1, 4]!
void* _pointer; ///< Pointer to the data
/* AbstractImageRepresentation */
%nodefaultctor AbstractImageRepresentation;
class AbstractImageRepresentation {
virtual ~AbstractImageRepresentation();
const ImageData* getParent() const;
size_t getDimensionality() const;
const cgt::svec3& getSize() const;
size_t getNumElements() const;
explicit AbstractImageRepresentation(const AbstractImageRepresentation& rhs);
AbstractImageRepresentation& operator=(const AbstractImageRepresentation& rhs);
/* ImageRepresentationLocal */
%nodefaultctor ImageRepresentationLocal;
class ImageRepresentationLocal : public AbstractImageRepresentation {
virtual ~ImageRepresentationLocal();
static ImageRepresentationLocal* create(const ImageData* parent, WeaklyTypedPointer wtp);
virtual const WeaklyTypedPointer getWeaklyTypedPointer() const = 0;
virtual float getElementNormalized(size_t index, size_t channel) const = 0;
virtual float getElementNormalized(const cgt::svec3& position, size_t channel) const = 0;
virtual float getElementNormalizedLinear(const cgt::vec3& position, size_t channel) const = 0;
virtual void setElementNormalized(size_t index, size_t channel, float value) = 0;
virtual void setElementNormalized(const cgt::svec3& position, size_t channel, float value) = 0;
ImageRepresentationLocal(ImageData* parent, WeaklyTypedPointer::BaseType baseType);
explicit ImageRepresentationLocal(const ImageRepresentationLocal& rhs);
ImageRepresentationLocal& operator=(const ImageRepresentationLocal& rhs);
/* DataContainer */
class DataContainer {
......@@ -48,7 +48,7 @@ namespace campvis {
addProperty(p_inputImage, VALID);
addProperty(p_fileName, VALID);
MhdImageWriter::~MhdImageWriter() {
......@@ -56,6 +56,9 @@ namespace campvis {
void MhdImageWriter::updateResult(DataContainer& dataContainer) {
if (! (getInvalidationLevel() & FIRST_FREE_TO_USE_INVALIDATION_LEVEL))
ImageRepresentationLocal::ScopedRepresentation image(dataContainer, p_inputImage.getValue());
if (image != 0) {
......@@ -139,6 +142,8 @@ namespace campvis {
else {
LDEBUG("Could not get Image to write from DataContainer.");
\ No newline at end of file
Supports Markdown
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