Commit 3777e515 authored by schultezub's avatar schultezub
Browse files

* introducing VolumeRenderer as first draft for macro/meta processors (#14)

* fixed DataNameProperty not updating shared properties when being notified

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@485 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 8b9986d2
......@@ -10,20 +10,20 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0 FATAL_ERROR)
# Global Build Options
#
OPTION(CAMPVIS_SHARED_LIBS "Build shared libraries?" ON )
#OPTION(CAMPVIS_PRECOMPILED_HEADER "Use pre-compiled headers?" ON )
OPTION(CAMPVIS_DEBUG "Activate debug code?" ON )
OPTION(CAMPVIS_BUILD_APPLICATION "Build CAMPVis Application" ON )
OPTION(CAMPVIS_BUILD_CORE "Build CAMPVis Core" ON )
OPTION(CAMPVIS_BUILD_MODULES "Build CAMPVis Modules" ON )
OPTION(CAMPVIS_BUILD_LIB_TGT "Build TGT Library" ON )
OPTION(CAMPVIS_SHARED_LIBS "Build shared libraries?" ON)
#OPTION(CAMPVIS_PRECOMPILED_HEADER "Use pre-compiled headers?" ON)
OPTION(CAMPVIS_DEBUG "Activate debug code?" ON)
OPTION(CAMPVIS_BUILD_APPLICATION "Build CAMPVis Application" ON)
OPTION(CAMPVIS_BUILD_CORE "Build CAMPVis Core" ON)
OPTION(CAMPVIS_BUILD_MODULES "Build CAMPVis Modules" ON)
OPTION(CAMPVIS_BUILD_LIB_TGT "Build TGT Library" ON)
OPTION(CAMPVIS_BUILD_LIB_KISSCL "Build KissCL Library" OFF)
OPTION(CAMPVIS_DEPLOY_SHADERS "Deploy Shader files to binary directory" OFF)
IF(WIN32)
OPTION(CAMPVIS_COPY_EXTERNAL_DLLS "Copy external DLLs to bin directory?" ON )
OPTION(CAMPVIS_INCREMENTAL_LINKING "Enable incremental linking in Visual Studio debug builds?" ON )
OPTION(CAMPVIS_COPY_EXTERNAL_DLLS "Copy external DLLs to bin directory?" ON)
OPTION(CAMPVIS_INCREMENTAL_LINKING "Enable incremental linking in Visual Studio debug builds?" ON)
OPTION(CAMPVIS_GENERATE_MANIFEST "Generate manifest in Visual Studio debug builds (switch on when encountering errors using incremental linking)?" OFF)
ENDIF()
......
......@@ -68,6 +68,10 @@ namespace campvis {
}
void DataNameProperty::notifyReaders() {
for (std::set<AbstractProperty*>::iterator it = _sharedProperties.begin(); it != _sharedProperties.end(); ++it) {
// static_cast ist safe here since correct type is ensured during add of shared property
static_cast<DataNameProperty*>(*it)->notifyReaders();
}
s_changed(this);
}
......
// ================================================================================================
//
// This file is part of the CAMPVis Software 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
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// 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 "volumerenderer.h"
#include "tgt/logmanager.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagerepresentationgl.h"
#include "core/datastructures/imagerepresentationrendertarget.h"
#include "core/classification/simpletransferfunction.h"
namespace campvis {
const std::string VolumeRenderer::loggerCat_ = "CAMPVis.modules.vis.VolumeRenderer";
VolumeRenderer::VolumeRenderer(IVec2Property& canvasSize)
: VisualizationProcessor(canvasSize)
, p_inputVolume("InputVolume", "Input Volume", "", DataNameProperty::READ, AbstractProcessor::VALID)
, p_camera("Camera", "Camera", tgt::Camera(), AbstractProcessor::VALID)
, p_outputImage("OutputImage", "Output Image", "dd.output", DataNameProperty::WRITE, AbstractProcessor::VALID)
, _pgGenerator()
, _eepGenerator(canvasSize)
, _raycaster(canvasSize)
{
addProperty(&p_inputVolume);
addProperty(&p_camera);
addProperty(&_raycaster.p_transferFunction);
addProperty(&_raycaster.p_samplingRate);
addProperty(&p_outputImage);
// setup shared properties
p_inputVolume.addSharedProperty(&_pgGenerator.p_sourceImageID);
p_inputVolume.addSharedProperty(&_eepGenerator.p_sourceImageID);
p_inputVolume.addSharedProperty(&_raycaster.p_sourceImageID);
p_camera.addSharedProperty(&_eepGenerator.p_camera);
p_camera.addSharedProperty(&_raycaster.p_camera);
p_outputImage.addSharedProperty(&_raycaster.p_targetImageID);
}
VolumeRenderer::~VolumeRenderer() {
}
void VolumeRenderer::init() {
VisualizationProcessor::init();
_pgGenerator.init();
_eepGenerator.init();
_raycaster.init();
// connect the three processors together
_pgGenerator.p_geometryID.connect(&_eepGenerator.p_geometryID);
_eepGenerator.p_entryImageID.connect(&_raycaster.p_entryImageID);
_eepGenerator.p_exitImageID.connect(&_raycaster.p_exitImageID);
_pgGenerator.s_invalidated.connect(this, &VolumeRenderer::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect(this, &VolumeRenderer::onProcessorInvalidated);
_raycaster.s_invalidated.connect(this, &VolumeRenderer::onProcessorInvalidated);
}
void VolumeRenderer::deinit() {
_pgGenerator.deinit();
_eepGenerator.deinit();
_raycaster.deinit();
VisualizationProcessor::deinit();
}
void VolumeRenderer::process(DataContainer& data) {
if (getInvalidationLevel() & PG_INVALID) {
_pgGenerator.process(data);
}
else if (getInvalidationLevel() & EEP_INVALID) {
_eepGenerator.process(data);
}
else if (getInvalidationLevel() & RAYCASTER_INVALID) {
_raycaster.process(data);
}
validate(INVALID_RESULT | PG_INVALID | EEP_INVALID | RAYCASTER_INVALID);
}
void VolumeRenderer::onProcessorInvalidated(AbstractProcessor* processor) {
if (processor == &_pgGenerator) {
invalidate(PG_INVALID);
}
else if (processor == &_eepGenerator) {
invalidate(EEP_INVALID);
}
else if (processor == &_raycaster) {
invalidate(RAYCASTER_INVALID);
}
invalidate(AbstractProcessor::INVALID_RESULT);
}
void VolumeRenderer::onPropertyChanged(const AbstractProperty* prop) {
if (prop == &p_outputImage) {
_pgGenerator.p_geometryID.setValue(p_outputImage.getValue() + ".geometry");
_eepGenerator.p_entryImageID.setValue(p_outputImage.getValue() + ".entrypoints");
_eepGenerator.p_exitImageID.setValue(p_outputImage.getValue() + ".exitpoints");
}
VisualizationProcessor::onPropertyChanged(prop);
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software 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
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// 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 VOLUMERENDERER_H__
#define VOLUMERENDERER_H__
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/datanameproperty.h"
#include "core/properties/numericproperty.h"
#include "modules/vis/processors/eepgenerator.h"
#include "modules/vis/processors/proxygeometrygenerator.h"
#include "modules/vis/processors/simpleraycaster.h"
namespace tgt {
class Shader;
}
namespace campvis {
/**
* Combines proxy geometry generator, entry/exit point generator and raycasting into one
* easy-to-use volume renderer.
*/
class VolumeRenderer : public VisualizationProcessor {
public:
/**
* Constructs a new VolumeRenderer Processor
**/
VolumeRenderer(IVec2Property& canvasSize);
/**
* Destructor
**/
virtual ~VolumeRenderer();
/// \see AbstractProcessor::init
virtual void init();
/// \see AbstractProcessor::deinit
virtual void deinit();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "VolumeRenderer"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Combines proxy geometry generator, entry/exit point generator and raycasting into one easy-to-use volume renderer."; };
virtual void process(DataContainer& data);
DataNameProperty p_inputVolume; ///< image ID for first input image
CameraProperty p_camera;
DataNameProperty p_outputImage; ///< image ID for output image
protected:
/// Additional invalidation levels for this processor.
/// Not the most beautiful design though.
enum ProcessorInvalidationLevel {
PG_INVALID = 1 << 4,
EEP_INVALID = 1 << 5,
RAYCASTER_INVALID = 1 << 6
};
/**
* Slot getting called when one of the observed processors got invalidated.
* The default behaviour is to dispatch a job to execute the invalidated processor and emit the s_invalidated signal.
* \param processor The processor that emitted the signal
*/
virtual void onProcessorInvalidated(AbstractProcessor* processor);
virtual void onPropertyChanged(const AbstractProperty* prop);
ProxyGeometryGenerator _pgGenerator;
EEPGenerator _eepGenerator;
SimpleRaycaster _raycaster;
static const std::string loggerCat_;
};
}
#endif // VOLUMERENDERER_H__
......@@ -10,7 +10,7 @@ legal_notice_begin = """// =====================================================
"""
legal_notice = """// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitt Mnchen
......
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