Commit 22ef73e9 authored by Jakob Weiss's avatar Jakob Weiss

Image representation adapted to cope with new API

Only minimum necessary changes to get image representations to work, no real writable representations.
parent cd8768b5
...@@ -56,12 +56,11 @@ namespace campvis { ...@@ -56,12 +56,11 @@ namespace campvis {
*/ */
ScopedRepresentation(const DataContainer& dc, const std::string& name, bool silent = false) ScopedRepresentation(const DataContainer& dc, const std::string& name, bool silent = false)
: dh(dc.getData(name)) : dh(dc.getData(name))
, data(0) , data(dh, silent)
, representation(0) , representation(nullptr)
{ {
if (dh.getData() != 0) { if (dh) {
data = dynamic_cast<const ImageData*>(dh.getData()); if (data != nullptr) {
if (data != 0) {
representation = data->getRepresentation<T>(); representation = data->getRepresentation<T>();
} }
else { else {
...@@ -69,8 +68,8 @@ namespace campvis { ...@@ -69,8 +68,8 @@ namespace campvis {
LDEBUGC("CAMPVis.core.ScopedTypedData", "Found DataHandle with id '" << name << "', but it is of wrong type (" << typeid(*dh.getData()).name() << " instead of " << typeid(T).name() << ")."); LDEBUGC("CAMPVis.core.ScopedTypedData", "Found DataHandle with id '" << name << "', but it is of wrong type (" << typeid(*dh.getData()).name() << " instead of " << typeid(T).name() << ").");
} }
if (data == 0 || representation == 0) { if (data == nullptr || representation == nullptr) {
dh = DataHandle(0); dh = DataHandle(nullptr);
} }
} }
else { else {
...@@ -85,16 +84,15 @@ namespace campvis { ...@@ -85,16 +84,15 @@ namespace campvis {
*/ */
ScopedRepresentation(DataHandle dataHandle) ScopedRepresentation(DataHandle dataHandle)
: dh(dataHandle) : dh(dataHandle)
, data(0) , data(dh)
, representation(0) , representation(nullptr)
{ {
if (dh.getData() != 0) { if (dh) {
data = dynamic_cast<const ImageData*>(dh.getData()); if (data != nullptr) {
if (data != 0) {
representation = data->getRepresentation<T>(); representation = data->getRepresentation<T>();
} }
if (data == 0 || representation == 0) { if (data == nullptr || representation == nullptr) {
dh = DataHandle(0); dh = DataHandle(nullptr);
} }
} }
}; };
...@@ -129,7 +127,7 @@ namespace campvis { ...@@ -129,7 +127,7 @@ namespace campvis {
* Returns the parent ImageData of this image representation. * Returns the parent ImageData of this image representation.
* \return data * \return data
*/ */
const ImageData* getImageData() const { const ScopedTypedData<ImageData>& getImageData() const {
return data; return data;
} }
...@@ -140,7 +138,7 @@ namespace campvis { ...@@ -140,7 +138,7 @@ namespace campvis {
ScopedRepresentation& operator=(const ScopedRepresentation& rhs); ScopedRepresentation& operator=(const ScopedRepresentation& rhs);
DataHandle dh; ///< DataHandle DataHandle dh; ///< DataHandle
const ImageData* data; ///< strongly-typed pointer to data, may be 0 ScopedTypedData<ImageData> data;///< strongly-typed pointer to data, may be 0
const T* representation; ///< strongly-typed pointer to the image representation, may be 0 const T* representation; ///< strongly-typed pointer to the image representation, may be 0
}; };
......
...@@ -62,12 +62,11 @@ namespace campvis { ...@@ -62,12 +62,11 @@ namespace campvis {
*/ */
ScopedRepresentation(const DataContainer& dc, const std::string& name, bool silent = false) ScopedRepresentation(const DataContainer& dc, const std::string& name, bool silent = false)
: dh(dc.getData(name)) : dh(dc.getData(name))
, data(0) , data(dh)
, representation(0) , representation(nullptr)
{ {
if (dh.getData() != 0) { if (dh) {
data = dynamic_cast<const ImageData*>(dh.getData()); if (data != nullptr) {
if (data != 0) {
representation = data->getRepresentation< GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS> >(); representation = data->getRepresentation< GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS> >();
} }
else { else {
...@@ -75,8 +74,8 @@ namespace campvis { ...@@ -75,8 +74,8 @@ namespace campvis {
LDEBUGC("CAMPVis.core.ScopedTypedData", "Found DataHandle with id '" << name << "', but it is of wrong type (" << typeid(*dh.getData()).name() << " instead of " << typeid(GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>).name() << ")."); LDEBUGC("CAMPVis.core.ScopedTypedData", "Found DataHandle with id '" << name << "', but it is of wrong type (" << typeid(*dh.getData()).name() << " instead of " << typeid(GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>).name() << ").");
} }
if (data == 0 || representation == 0) { if (data == nullptr || representation == nullptr) {
dh = DataHandle(0); dh = DataHandle(nullptr);
} }
} }
else { else {
...@@ -91,16 +90,15 @@ namespace campvis { ...@@ -91,16 +90,15 @@ namespace campvis {
*/ */
ScopedRepresentation(DataHandle dataHandle) ScopedRepresentation(DataHandle dataHandle)
: dh(dataHandle) : dh(dataHandle)
, data(0) , data(dh)
, representation(0) , representation(nullptr)
{ {
if (dh.getData() != 0) { if (dh.getData() != nullptr) {
data = dynamic_cast<const ImageData*>(dh.getData()); if (data != nullptr) {
if (data != 0) {
representation = data->getRepresentation<ThisType>(); representation = data->getRepresentation<ThisType>();
} }
if (data == 0 || representation == 0) { if (data == nullptr || representation == nullptr) {
dh = DataHandle(0); dh = DataHandle(nullptr);
} }
} }
}; };
...@@ -146,7 +144,7 @@ namespace campvis { ...@@ -146,7 +144,7 @@ namespace campvis {
ScopedRepresentation& operator=(const ScopedRepresentation& rhs); ScopedRepresentation& operator=(const ScopedRepresentation& rhs);
DataHandle dh; ///< DataHandle DataHandle dh; ///< DataHandle
const ImageData* data; ///< strongly-typed pointer to data, may be 0 ScopedTypedData<ImageData> data; ///< strongly-typed pointer to data, may be 0
const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* representation; ///< strongly-typed pointer to the image representation, may be 0 const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>* representation; ///< strongly-typed pointer to the image representation, may be 0
}; };
......
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