Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

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

Added (silencable) debug messages to ScopedTypedData, and ScopedRepresentation...

Added (silencable) debug messages to ScopedTypedData, and ScopedRepresentation structs in cases where no data with the given key could be found or the data found is of wrong type.
parent f67886eb
......@@ -69,8 +69,14 @@ namespace campvis {
glViewport(0, 0, size.x, size.y);
// try get Data
ScopedTypedData<RenderData> rd(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
ImageRepresentationGL::ScopedRepresentation repGL(_pipeline->getDataContainer(), _pipeline->getRenderTargetID());
DataHandle dh = _pipeline->getDataContainer().getData(_pipeline->getRenderTargetID());
const RenderData* rd = nullptr;
const ImageRepresentationGL* repGL = nullptr;
if (dh.getData() != nullptr) {
rd = dynamic_cast<const RenderData*>(dh.getData());
repGL = dynamic_cast<const ImageRepresentationGL*>(dh.getData());
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// activate the shader
......
......@@ -25,10 +25,14 @@
#ifndef GENERICABSTRACTIMAGEREPRESENTATION_H__
#define GENERICABSTRACTIMAGEREPRESENTATION_H__
#include "cgt/logmanager.h"
#include "core/datastructures/abstractimagerepresentation.h"
#include "core/datastructures/datacontainer.h"
#include "core/datastructures/imagedata.h"
#include <typeinfo>
namespace campvis {
/**
* Generic wrapper around an AbstractImageRepresentation that provides a ScopedRepresentation proxy.
......@@ -48,8 +52,9 @@ namespace campvis {
* Creates a new DataHandle to the data item with the key \a name in \a dc, that behaves like a T*.
* \param dc DataContainer to grab data from
* \param name Key of the DataHandle to search for
* \param silent Flag whether debug messages when no matching data is found should be silenced (defaults to false).
*/
ScopedRepresentation(const DataContainer& dc, const std::string& name)
ScopedRepresentation(const DataContainer& dc, const std::string& name, bool silent = false)
: dh(dc.getData(name))
, data(0)
, representation(0)
......@@ -59,10 +64,19 @@ namespace campvis {
if (data != 0) {
representation = data->getRepresentation<T>();
}
else {
if (!silent)
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) {
dh = DataHandle(0);
}
}
else {
if (!silent)
LDEBUGC("CAMPVis.core.ScopedRepresentation", "Could not find a DataHandle with id '" << name << "' in DataContainer '" << dc.getName() << "'.");
}
};
/**
......
......@@ -58,8 +58,9 @@ namespace campvis {
* Creates a new DataHandle to the data item with the key \a name in \a dc, that behaves like a const GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS>*.
* \param dc DataContainer to grab data from
* \param name Key of the DataHandle to search for
* \param silent Flag whether debug messages when no matching data is found should be silenced (defaults to false).
*/
ScopedRepresentation(const DataContainer& dc, const std::string& name)
ScopedRepresentation(const DataContainer& dc, const std::string& name, bool silent = false)
: dh(dc.getData(name))
, data(0)
, representation(0)
......@@ -69,10 +70,19 @@ namespace campvis {
if (data != 0) {
representation = data->getRepresentation< GenericImageRepresentationLocal<BASETYPE, NUMCHANNELS> >();
}
else {
if (!silent)
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) {
dh = DataHandle(0);
}
}
else {
if (!silent)
LDEBUGC("CAMPVis.core.ScopedRepresentation", "Could not find a DataHandle with id '" << name << "' in DataContainer '" << dc.getName() << "'.");
}
};
/**
......
......@@ -25,8 +25,11 @@
#ifndef SCOPEDTYPEDDATA_H__
#define SCOPEDTYPEDDATA_H__
#include "cgt/logmanager.h"
#include "core/datastructures/datacontainer.h"
#include <typeinfo>
namespace campvis {
/**
......@@ -43,16 +46,25 @@ namespace campvis {
* Creates a new DataHandle to the data item with the key \a name in \a dc, that behaves like a T*.
* \param dc DataContainer to grab data from
* \param name Key of the DataHandle to search for
* \param silent Flag whether debug messages when no matching data is found should be silenced (defaults to false).
*/
ScopedTypedData(const DataContainer& dc, const std::string& name)
ScopedTypedData(const DataContainer& dc, const std::string& name, bool silent = false)
: dh(dc.getData(name))
, data(0)
{
if (dh.getData() != 0) {
data = dynamic_cast<const T*>(dh.getData());
if (data == 0)
if (data == 0) {
if (!silent)
LDEBUGC("CAMPVis.core.ScopedTypedData", "Found DataHandle with id '" << name << "', but it is of wrong type (" << typeid(*dh.getData()).name() << " instead of " << typeid(T).name() << ").");
dh = DataHandle(0);
}
}
else {
if (! silent)
LDEBUGC("CAMPVis.core.ScopedTypedData", "Could not find a DataHandle with id '" << name << "' in DataContainer '" << dc.getName() << "'.");
}
};
/**
......
......@@ -95,7 +95,7 @@ namespace campvis {
if (img != nullptr && proxyGeometry != nullptr && _shader != nullptr && camera != nullptr) {
if (img->getDimensionality() == 3) {
const cgt::Camera& cam = camera->getCamera();
ScopedTypedData<RenderData> geometryImage(data, p_geometryImageId.getValue());
ScopedTypedData<RenderData> geometryImage(data, p_geometryImageId.getValue(), true);
cgt::Bounds textureBounds(cgt::vec3(0.f), cgt::vec3(1.f));
......
......@@ -116,8 +116,8 @@ namespace campvis {
ScopedTypedData<GeometryData> proxyGeometry(data, p_geometryID.getValue());
ScopedTypedData<LightSourceData> light(data, p_lightId.getValue());
ScopedTypedData<CameraData> camera(data, p_camera.getValue());
ScopedTypedData<RenderData> rd(data, p_textureID.getValue());
ImageRepresentationGL::ScopedRepresentation repGl(data, p_textureID.getValue());
ScopedTypedData<RenderData> rd(data, p_textureID.getValue(), true);
ImageRepresentationGL::ScopedRepresentation repGl(data, p_textureID.getValue(), true);
const ImageRepresentationGL* texture = nullptr;
if (p_coloringMode.getOptionValue() == TEXTURE_COLOR) {
......@@ -126,6 +126,8 @@ namespace campvis {
texture = rd->getColorTexture()->getRepresentation<ImageRepresentationGL>();
else if (repGl != nullptr)
texture = repGl;
else
LERROR("Could not find suitable texture in DataConatiner.");
}
else {
LERROR("Cannot use textured rendering since input geometry has no texture coordinates!");
......@@ -220,7 +222,7 @@ namespace campvis {
data.addData(p_renderTargetID.getValue(), new RenderData(_fbo));
}
else {
LDEBUG("No suitable input geometry found.");
LDEBUG("No suitable input data found.");
}
}
......
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