Commit 09e28d4b authored by schultezub's avatar schultezub
Browse files

* introducing DataNameProperty

 * introducing geometryrenderer.cpp
 * updated DVRVis pipeline and various processors

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@283 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 253cb13f
......@@ -44,9 +44,9 @@ namespace TUMVis {
RaycastingProcessor::RaycastingProcessor(GenericProperty<tgt::ivec2>& renderTargetSize, const std::string& fragmentShaderFileName, bool bindEntryExitDepthTextures)
: VisualizationProcessor(renderTargetSize)
, _sourceImageID("sourceImageID", "Input Image", "")
, _entryImageID("entryImageID", "Input Entry Points Image", "")
, _exitImageID("exitImageID", "Input Exit Points Image", "")
, _sourceImageID("sourceImageID", "Input Image", "", DataNameProperty::READ)
, _entryImageID("entryImageID", "Input Entry Points Image", "", DataNameProperty::READ)
, _exitImageID("exitImageID", "Input Exit Points Image", "", DataNameProperty::READ)
, _camera("camera", "Camera")
, _transferFunction("transferFunction", "Transfer Function", new SimpleTransferFunction(256))
, _samplingStepSize("samplingStepSize", "Sampling Step Size", .1f, 0.001f, 1.f)
......
......@@ -33,6 +33,7 @@
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/cameraproperty.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/transferfunctionproperty.h"
......@@ -95,9 +96,9 @@ namespace TUMVis {
*/
virtual void process(DataContainer& data);
GenericProperty<std::string> _sourceImageID; ///< image ID for input image
GenericProperty<std::string> _entryImageID; ///< image ID for output entry points image
GenericProperty<std::string> _exitImageID; ///< image ID for output exit points image
DataNameProperty _sourceImageID; ///< image ID for input image
DataNameProperty _entryImageID; ///< image ID for output entry points image
DataNameProperty _exitImageID; ///< image ID for output exit points image
CameraProperty _camera; ///< Camera used for ray casting
TransferFunctionProperty _transferFunction; ///< Transfer function
......
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "datanameproperty.h"
namespace TUMVis {
const std::string DataNameProperty::loggerCat_ = "TUMVis.core.datastructures.DataNameProperty";
DataNameProperty::DataNameProperty(const std::string& name, const std::string& title, const std::string& value, DataAccessInfo access, InvalidationLevel il /*= InvalidationLevel::INVALID_RESULT*/)
: GenericProperty<std::string>(name, title, value, il)
, _accessInfo(access)
{
}
DataNameProperty::~DataNameProperty() {
}
void DataNameProperty::connect(DataNameProperty* reader) {
tgtAssert(reader != 0, "Reader must not be 0");
tgtAssert(_accessInfo == WRITE, "Can only connect writing properties to reading properties.");
tgtAssert(reader->_accessInfo == READ, "Can only connect writing properties to reading properties.");
if (_connectedReaders.insert(reader).second)
addSharedProperty(reader);
}
void DataNameProperty::disconnect(DataNameProperty* reader) {
tgtAssert(reader != 0, "Reader must not be 0");
if (_connectedReaders.erase(reader) > 0)
removeSharedProperty(reader);
}
void DataNameProperty::issueWrite() {
tgtAssert(_accessInfo == WRITE, "Write access not specified.");
for (std::set<DataNameProperty*>::iterator it = _connectedReaders.begin(); it != _connectedReaders.end(); ++it) {
(*it)->notifyReaders();
}
}
void DataNameProperty::notifyReaders() {
s_changed(this);
}
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universität München
// Boltzmannstr. 3, 85748 Garching b. München, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#ifndef DATANAMEPROPERTY_H__
#define DATANAMEPROPERTY_H__
#include "core/properties/genericproperty.h"
#include <ctime>
#include <set>
#include <string>
namespace TUMVis {
class DataNameProperty : public GenericProperty<std::string> {
public:
/**
* DataAccessInfo flag defining whether processor will read or write from/to the corresponding DataHandle.
*/
enum DataAccessInfo {
READ,
WRITE
};
/**
* Creates a new DataNameProperty
* \param name Property name (unchangable!)
* \param title Property title (e.g. used for GUI)
* \param value Initial value
* \param access DataAccessInfo flag defining whether processor will read or write from/to the DataHandle with the given ID.
* \param il Invalidation level that this property triggers
*/
DataNameProperty(const std::string& name, const std::string& title, const std::string& value, DataAccessInfo access, InvalidationLevel il = InvalidationLevel::INVALID_RESULT);
/**
* Virtual Destructor
**/
virtual ~DataNameProperty();
/**
* Connects this property with the given DataNameProperty \a reader.
* \param reader DataNameProperty to connect to, must be have read access.
*/
void connect(DataNameProperty* reader);
/**
* Disconnects this property from the given DataNameProperty \a reader.
* \param reader DataNameProperty to disconnect from, must be have read access.
*/
void disconnect(DataNameProperty* reader);
void issueWrite();
protected:
void notifyReaders();
DataAccessInfo _accessInfo;
std::set<DataNameProperty*> _connectedReaders;
static const std::string loggerCat_;
};
}
#endif // DATANAMEPROPERTY_H__
......@@ -218,8 +218,10 @@ std::string ResourceManager<T>::completePath(std::string filename) {
if (foundFile)
return cplFileName;
else
else {
LERROR("Could not complete path for file " << filename);
return "";
}
}
template <class T>
......
......@@ -40,6 +40,8 @@ namespace TUMVis {
, _camera("camera", "Camera")
, _imageReader()
, _pgGenerator()
, _vmgGenerator()
, _vmRenderer(_renderTargetSize)
, _eepGenerator(_renderTargetSize)
, _drrraycater(_renderTargetSize)
, _simpleRaycaster(_renderTargetSize)
......@@ -58,6 +60,8 @@ namespace TUMVis {
_processors.push_back(&_imageReader);
_processors.push_back(&_pgGenerator);
_processors.push_back(&_vmgGenerator);
_processors.push_back(&_vmRenderer);
_processors.push_back(&_eepGenerator);
_processors.push_back(&_drrraycater);
_processors.push_back(&_simpleRaycaster);
......@@ -71,6 +75,8 @@ namespace TUMVis {
void DVRVis::init() {
VisualizationPipeline::init();
_camera.addSharedProperty(&_vmgGenerator._camera);
_camera.addSharedProperty(&_vmRenderer._camera);
_camera.addSharedProperty(&_eepGenerator._camera);
_camera.addSharedProperty(&_drrraycater._camera);
_camera.addSharedProperty(&_simpleRaycaster._camera);
......@@ -79,14 +85,6 @@ namespace TUMVis {
_imageReader._url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader._targetImageID.setValue("reader.output");
_eepGenerator._entryImageID.addSharedProperty(&_drrraycater._entryImageID);
_eepGenerator._entryImageID.addSharedProperty(&_simpleRaycaster._entryImageID);
_eepGenerator._entryImageID.addSharedProperty(&_clRaycaster._entryImageID);
_eepGenerator._exitImageID.addSharedProperty(&_drrraycater._exitImageID);
_eepGenerator._exitImageID.addSharedProperty(&_simpleRaycaster._exitImageID);
_eepGenerator._exitImageID.addSharedProperty(&_clRaycaster._exitImageID);
_drrraycater._targetImageID.setValue("drr.output");
_drrraycater._sourceImageID.setValue("eep.input");
......@@ -97,14 +95,25 @@ namespace TUMVis {
_clRaycaster._sourceImageID.setValue("clr.input");
_eepGenerator._sourceImageID.setValue("eep.input");
_eepGenerator._entryImageID.setValue("eep.entry");
_eepGenerator._exitImageID.setValue("eep.exit");
_pgGenerator._sourceImageID.setValue("eep.input");
_renderTargetID.setValue("eep.entry");
_pgGenerator._geometryID.connect(&_eepGenerator._geometryID);
_vmgGenerator._mirrorID.connect(&_eepGenerator._mirrorID);
_vmgGenerator._mirrorID.connect(&_vmRenderer._geometryID);
_eepGenerator._entryImageID.connect(&_drrraycater._entryImageID);
_eepGenerator._entryImageID.connect(&_simpleRaycaster._entryImageID);
_eepGenerator._entryImageID.connect(&_clRaycaster._entryImageID);
_eepGenerator._exitImageID.connect(&_drrraycater._exitImageID);
_eepGenerator._exitImageID.connect(&_simpleRaycaster._exitImageID);
_eepGenerator._exitImageID.connect(&_clRaycaster._exitImageID);
_imageReader.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_vmgGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_vmRenderer.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_pgGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_drrraycater.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
......@@ -147,6 +156,12 @@ namespace TUMVis {
if (! _pgGenerator.getInvalidationLevel().isValid()) {
executeProcessor(&_pgGenerator);
}
if (! _vmgGenerator.getInvalidationLevel().isValid()) {
executeProcessor(&_vmgGenerator);
}
if (! _vmRenderer.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_vmRenderer);
}
if (! _eepGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_eepGenerator);
}
......
......@@ -34,7 +34,9 @@
#include "core/pipeline/visualizationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/io/mhdimagereader.h"
#include "modules/vis/virtualmirrorgeometrygenerator.h"
#include "modules/vis/proxygeometrygenerator.h"
#include "modules/vis/geometryrenderer.h"
#include "modules/vis/eepgenerator.h"
#include "modules/vis/drrraycaster.h"
#include "modules/vis/simpleraycaster.h"
......@@ -70,6 +72,8 @@ namespace TUMVis {
CameraProperty _camera;
MhdImageReader _imageReader;
ProxyGeometryGenerator _pgGenerator;
VirtualMirrorGeometryGenerator _vmgGenerator;
GeometryRenderer _vmRenderer;
EEPGenerator _eepGenerator;
DRRRaycaster _drrraycater;
SimpleRaycaster _simpleRaycaster;
......
......@@ -51,10 +51,10 @@ namespace TUMVis {
CLRaycaster::CLRaycaster(GenericProperty<tgt::ivec2>& renderTargetSize)
: VisualizationProcessor(renderTargetSize)
, _sourceImageID("sourceImageID", "Input Image", "")
, _entryImageID("entryImageID", "Output Entry Points Image", "")
, _exitImageID("exitImageID", "Output Exit Points Image", "")
, _targetImageID("targetImageID", "Target image ID", "")
, _sourceImageID("sourceImageID", "Input Image", "", DataNameProperty::READ)
, _entryImageID("entryImageID", "Output Entry Points Image", "", DataNameProperty::READ)
, _exitImageID("exitImageID", "Output Exit Points Image", "", DataNameProperty::READ)
, _targetImageID("targetImageID", "Target image ID", "", DataNameProperty::WRITE)
, _camera("camera", "Camera")
, _transferFunction("transferFunction", "Transfer Function", new SimpleTransferFunction(256))
, _samplingStepSize("samplingStepSize", "Sampling Step Size", .1f, 0.001f, 1.f)
......
......@@ -33,6 +33,7 @@
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/cameraproperty.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/transferfunctionproperty.h"
......@@ -98,10 +99,10 @@ namespace TUMVis {
*/
virtual void process(DataContainer& data);
GenericProperty<std::string> _sourceImageID; ///< image ID for input image
GenericProperty<std::string> _entryImageID; ///< image ID for output entry points image
GenericProperty<std::string> _exitImageID; ///< image ID for output exit points image
GenericProperty<std::string> _targetImageID; ///< image ID for output image
DataNameProperty _sourceImageID; ///< image ID for input image
DataNameProperty _entryImageID; ///< image ID for output entry points image
DataNameProperty _exitImageID; ///< image ID for output exit points image
DataNameProperty _targetImageID; ///< image ID for output image
CameraProperty _camera; ///< Camera used for ray casting
TransferFunctionProperty _transferFunction; ///< Transfer function
......
......@@ -42,25 +42,22 @@ namespace TUMVis {
EEPGenerator::EEPGenerator(GenericProperty<tgt::ivec2>& canvasSize)
: VisualizationProcessor(canvasSize)
, _sourceImageID("sourceImageID", "Input Image", "")
, _geometryID("geometryID", "Input Geometry ID", "proxygeometry")
, _mirrorID("mirrorID", "Input Mirror ID", "mirror")
, _entryImageID("entryImageID", "Output Entry Points Image", "")
, _exitImageID("exitImageID", "Output Exit Points Image", "")
, _sourceImageID("sourceImageID", "Input Image", "", DataNameProperty::READ)
, _geometryID("geometryID", "Input Geometry ID", "proxygeometry", DataNameProperty::READ)
, _mirrorID("mirrorID", "Input Mirror ID", "mirror", DataNameProperty::READ)
, _entryImageID("entryImageID", "Output Entry Points Image", "eep.entry", DataNameProperty::WRITE)
, _exitImageID("exitImageID", "Output Exit Points Image", "eep.exit", DataNameProperty::WRITE)
, _camera("camera", "Camera")
, _enableMirror("enableMirror", "Enable Virtual Mirror Feature", false)
, _mirrorPoint("mirrorPoint", "Point on Mirror Plane", 0.f, -1000.f, 1000.f)
, _mirrorNormal("mirrorNormal", "Normal of Mirror Plane", tgt::vec3(1.f), tgt::vec3(-1.f), tgt::vec3(1.f))
, _shader(0)
{
addProperty(&_sourceImageID);
addProperty(&_geometryID);
addProperty(&_mirrorID);
addProperty(&_entryImageID);
addProperty(&_exitImageID);
addProperty(&_camera);
addProperty(&_enableMirror);
addProperty(&_mirrorPoint);
addProperty(&_mirrorNormal);
}
EEPGenerator::~EEPGenerator() {
......@@ -100,29 +97,31 @@ namespace TUMVis {
glPushAttrib(GL_ALL_ATTRIB_BITS);
_shader->activate();
_shader->setUniform("_projectionMatrix", _camera.getValue().getProjectionMatrix());
tgt::mat4 mirrorMatrix = tgt::mat4::identity;
if (_enableMirror.getValue()) {
// TODO: make use of mirror geometry
tgt::vec3 n = tgt::normalize(_mirrorNormal.getValue());
tgt::vec3 p = n * _mirrorPoint.getValue();
float k = tgt::dot(p, n);
// mirror matrix sponsored by:
// Jiang
tgt::mat4 mirrorMatrix = tgt::mat4(
1 - 2*n.x*n.x, -2*n.y*n.x , -2*n.z*n.x , 0,
-2*n.x*n.y , 1 - 2*n.y*n.y, -2*n.z*n.y , 0,
-2*n.x*n.z , -2*n.y*n.z , 1 - 2*n.z*n.z, 0,
2*n.x*k , 2*n.y*k , 2*n.z*k , 1);
// TODO: double check, whether matrix transpose is necessary
_shader->setUniform("_modelMatrix", mirrorMatrix);
}
else {
_shader->setUniform("_modelMatrix", tgt::mat4::identity);
DataContainer::ScopedTypedData<FaceGeometry> mirrorGeometry(data, _mirrorID.getValue());
if (mirrorGeometry && mirrorGeometry->size() > 0) {
const tgt::vec3& p = mirrorGeometry->getVertices()[0];
tgt::vec3 n = tgt::normalize(tgt::cross(mirrorGeometry->getVertices()[1] - mirrorGeometry->getVertices()[0], mirrorGeometry->getVertices()[2] - mirrorGeometry->getVertices()[0]));
float k = tgt::dot(p, n);
// mirror matrix sponsored by:
// Jiang
mirrorMatrix = tgt::mat4(
1 - 2*n.x*n.x, -2*n.y*n.x , -2*n.z*n.x , 0,
-2*n.x*n.y , 1 - 2*n.y*n.y, -2*n.z*n.y , 0,
-2*n.x*n.z , -2*n.y*n.z , 1 - 2*n.z*n.z, 0,
2*n.x*k , 2*n.y*k , 2*n.z*k , 1);
// TODO: double check, whether matrix transpose is necessary
}
else {
LERROR("No suitable virtual mirror geometry found.");
}
}
_shader->setUniform("_modelMatrix", mirrorMatrix);
_shader->setUniform("_projectionMatrix", _camera.getValue().getProjectionMatrix());
_shader->setUniform("_viewMatrix", _camera.getValue().getViewMatrix());
glEnable(GL_CULL_FACE);
......
......@@ -34,6 +34,7 @@
#include "core/classification/abstracttransferfunction.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/cameraproperty.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
#include "core/properties/transferfunctionproperty.h"
......@@ -71,17 +72,15 @@ namespace TUMVis {
virtual void process(DataContainer& data);
StringProperty _sourceImageID; ///< image ID for input image
StringProperty _geometryID; ///< ID for input geometry
StringProperty _mirrorID; ///< ID for input mirror geometry
StringProperty _entryImageID; ///< image ID for output entry points image
StringProperty _exitImageID; ///< image ID for output exit points image
DataNameProperty _sourceImageID; ///< image ID for input image
DataNameProperty _geometryID; ///< ID for input geometry
DataNameProperty _mirrorID; ///< ID for input mirror geometry
DataNameProperty _entryImageID; ///< image ID for output entry points image
DataNameProperty _exitImageID; ///< image ID for output exit points image
CameraProperty _camera;
BoolProperty _enableMirror; ///< Enable Virtual Mirror Feature
FloatProperty _mirrorPoint; ///< Point on mirror plane
Vec3Property _mirrorNormal; ///< Normal of mirror plane
protected:
......
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
// Boltzmannstr. 3, 85748 Garching b. Mnchen, Germany
//
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
//
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ================================================================================================
#include "geometryrenderer.h"
#include "tgt/glmath.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedatagl.h"
#include "core/datastructures/imagedatarendertarget.h"
#include "core/datastructures/meshgeometry.h"
namespace TUMVis {
const std::string GeometryRenderer::loggerCat_ = "TUMVis.modules.vis.GeometryRenderer";
GeometryRenderer::GeometryRenderer(GenericProperty<tgt::ivec2>& canvasSize)
: VisualizationProcessor(canvasSize)
, _geometryID("geometryID", "Input Geometry ID", "gr.input", DataNameProperty::READ)
, _renderTargetID("_renderTargetID", "Output Image", "gr.output", DataNameProperty::WRITE)
, _camera("camera", "Camera")
, _shader(0)
{
addProperty(&_geometryID);
addProperty(&_renderTargetID);
addProperty(&_camera);
}
GeometryRenderer::~GeometryRenderer() {
}
void GeometryRenderer::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/geometryrenderer.frag", "", false);
if (_shader != 0) {
_shader->setAttributeLocation(0, "in_Position");
}
}
void GeometryRenderer::deinit() {
ShdrMgr.dispose(_shader);
_shader = 0;
VisualizationProcessor::deinit();
}
void GeometryRenderer::process(DataContainer& data) {
DataContainer::ScopedTypedData<GeometryData> proxyGeometry(data, _geometryID.getValue());
if (proxyGeometry != 0 && _shader != 0) {
// set modelview and projection matrices
glPushAttrib(GL_ALL_ATTRIB_BITS);
_shader->activate();
_shader->setUniform("_projectionMatrix", _camera.getValue().getProjectionMatrix());
_shader->setUniform("_viewMatrix", _camera.getValue().getViewMatrix());
_shader->setUniform("_color", tgt::vec4(1.f));
// create entry points texture
ImageDataRenderTarget* rt = new ImageDataRenderTarget(tgt::svec3(_renderTargetSize.getValue(), 1), GL_RGBA16);
rt->activate();
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
proxyGeometry->render();
rt->deactivate();
_shader->deactivate();
glPopAttrib();
LGL_ERROR;
data.addData(_renderTargetID.getValue(), rt);
_renderTargetID.issueWrite();
}
else {
LERROR("No suitable input geometry found.");
}
_invalidationLevel.setValid();
}
}
// ================================================================================================
//
// This file is part of the TUMVis Visualization Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// Christian Schulte zu Berge (christian.szb@in.tum.de)
// Chair for Computer Aided Medical Procedures
// Technische Universität München