Notice to GitKraken users: A vulnerability has been found in the SSH key generation of GitKraken versions 7.6.0 to 8.0.0 (https://www.gitkraken.com/blog/weak-ssh-key-fix). If you use GitKraken and have generated a SSH key using one of these versions, please remove it both from your local workstation and from your LRZ GitLab profile.

21.10.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

Commit 39064903 authored by schultezub's avatar schultezub
Browse files

* added AbstractProcessor::getDescription

 * added offset and voxelSize to ImageMappingInformation
 * introducing early EEPGenerator processor and DVRVis pipeline

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@215 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent 01342928
...@@ -73,6 +73,8 @@ namespace TUMVis { ...@@ -73,6 +73,8 @@ namespace TUMVis {
case Qt::DisplayRole: case Qt::DisplayRole:
if (column == 0) if (column == 0)
return QVariant(QString::fromStdString(_processor->getName())); return QVariant(QString::fromStdString(_processor->getName()));
if (column == 1)
return QVariant(QString::fromStdString(_processor->getDescription()));
case Qt::UserRole: case Qt::UserRole:
return qVariantFromValue(static_cast<void*>(_processor)); return qVariantFromValue(static_cast<void*>(_processor));
default: default:
...@@ -185,6 +187,9 @@ namespace TUMVis { ...@@ -185,6 +187,9 @@ namespace TUMVis {
} }
void PipelineTreeModel::setData(const std::vector<AbstractPipeline*>& pipelines) { void PipelineTreeModel::setData(const std::vector<AbstractPipeline*>& pipelines) {
delete _rootItem;
_rootItem = new RootTreeItem();
for (std::vector<AbstractPipeline*>::const_iterator pipe = pipelines.begin(); pipe != pipelines.end(); ++pipe) { for (std::vector<AbstractPipeline*>::const_iterator pipe = pipelines.begin(); pipe != pipelines.end(); ++pipe) {
PipelineTreeItem* pipeti = new PipelineTreeItem(*pipe, _rootItem); PipelineTreeItem* pipeti = new PipelineTreeItem(*pipe, _rootItem);
......
#include "application/tumvisapplication.h" #include "application/tumvisapplication.h"
#include "modules/pipelines/dvrvis.h"
#include "modules/pipelines/slicevis.h" #include "modules/pipelines/slicevis.h"
using namespace TUMVis; using namespace TUMVis;
...@@ -13,6 +14,7 @@ using namespace TUMVis; ...@@ -13,6 +14,7 @@ using namespace TUMVis;
int main(int argc, char** argv) { int main(int argc, char** argv) {
TumVisApplication app(argc, argv); TumVisApplication app(argc, argv);
app.addVisualizationPipeline("SliceVis", new SliceVis()); app.addVisualizationPipeline("SliceVis", new SliceVis());
app.addVisualizationPipeline("DVRVis", new DVRVis());
app.init(); app.init();
int toReturn = app.run(); int toReturn = app.run();
......
...@@ -8,6 +8,7 @@ namespace TUMVis { ...@@ -8,6 +8,7 @@ namespace TUMVis {
, _dimensionality(dimensionality) , _dimensionality(dimensionality)
, _size(size) , _size(size)
, _numElements(tgt::hmul(size)) , _numElements(tgt::hmul(size))
, _mappingInformation(tgt::vec3(0.f), tgt::vec3(1.f)) // TODO: get offset/voxel size as parameter or put default values into ImageMappingInformation ctor.
{ {
} }
...@@ -26,8 +27,8 @@ namespace TUMVis { ...@@ -26,8 +27,8 @@ namespace TUMVis {
return _mappingInformation; return _mappingInformation;
} }
ImageMappingInformation& ImageData::getMappingInformation() { tgt::Bounds ImageData::getWorldBounds() const {
return _mappingInformation; return tgt::Bounds(_mappingInformation.getOffset(), _mappingInformation.getOffset() + (tgt::vec3(_size) * _mappingInformation.getVoxelSize()));
} }
size_t ImageData::getNumElements() const { size_t ImageData::getNumElements() const {
......
#ifndef IMAGEDATA_H__ #ifndef IMAGEDATA_H__
#define IMAGEDATA_H__ #define IMAGEDATA_H__
#include "tgt/bounds.h"
#include "tgt/vector.h"
#include "core/datastructures/abstractdata.h" #include "core/datastructures/abstractdata.h"
#include "core/datastructures/imagemappinginformation.h" #include "core/datastructures/imagemappinginformation.h"
#include "tgt/vector.h"
namespace TUMVis { namespace TUMVis {
...@@ -45,10 +46,10 @@ namespace TUMVis { ...@@ -45,10 +46,10 @@ namespace TUMVis {
const ImageMappingInformation& getMappingInformation() const; const ImageMappingInformation& getMappingInformation() const;
/** /**
* Mapping information of this image * Returns the image extent in world coordinates.
* \return _mappingInformation * \return The image extent in world coordinates.
*/ */
ImageMappingInformation& getMappingInformation(); tgt::Bounds getWorldBounds() const;
/** /**
* Returns the subimage of this image given by \a llf and \a urb. * Returns the subimage of this image given by \a llf and \a urb.
......
...@@ -2,17 +2,30 @@ ...@@ -2,17 +2,30 @@
namespace TUMVis { namespace TUMVis {
ImageMappingInformation::ImageMappingInformation()
: _realWorldValueMapping(LinearMaping<float>::identity) ImageMappingInformation::ImageMappingInformation(const tgt::vec3& offset, const tgt::vec3& voxelSize, const LinearMapping<float>& realWorldValueMapping /*= LinearMapping<float>::identity*/)
, _voxelToWorldTransformation(tgt::mat4::identity) : _offset(offset)
, _voxelSize(voxelSize)
, _realWorldValueMapping(realWorldValueMapping)
{ {
}
const tgt::vec3& ImageMappingInformation::getOffset() const {
return _offset;
}
const tgt::vec3& ImageMappingInformation::getVoxelSize() const {
return _voxelSize;
} }
const LinearMaping<float>& ImageMappingInformation::getRealWorldMapping() const { const LinearMapping<float>& ImageMappingInformation::getRealWorldMapping() const {
return _realWorldValueMapping; return _realWorldValueMapping;
} }
void ImageMappingInformation::setRealWorldMapping(const LinearMaping<float>& rwvm) { void ImageMappingInformation::setRealWorldMapping(const LinearMapping<float>& rwvm) {
_realWorldValueMapping = rwvm; _realWorldValueMapping = rwvm;
} }
} }
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define imagemapping_h__ #define imagemapping_h__
#include "tgt/matrix.h" #include "tgt/matrix.h"
#include "tgt/vector.h"
#include "core/tools/mapping.h" #include "core/tools/mapping.h"
namespace TUMVis { namespace TUMVis {
...@@ -15,26 +16,46 @@ namespace TUMVis { ...@@ -15,26 +16,46 @@ namespace TUMVis {
class ImageMappingInformation { class ImageMappingInformation {
public: public:
/** /**
* Creates a new default ImageMappingInformation. All mappings are identity. * Creates a new default ImageMappingInformation.
* \param offset Position of LLF corner in world coordinates (mm)
* \param voxelSize Voxel size in (mm)
* \param realWorldValueMapping Linear mapping for mapping element values to real world values, defaults to identity.
*/ */
ImageMappingInformation(); ImageMappingInformation(
const tgt::vec3& offset,
const tgt::vec3& voxelSize,
const LinearMapping<float>& realWorldValueMapping = LinearMapping<float>::identity);
/**
* Returns the position of LLF corner in world coordinates (mm).
* \return _offset
*/
const tgt::vec3& getOffset() const;
/**
* Returns the voxel size in mm.
* \return _voxelSize
*/
const tgt::vec3& getVoxelSize() const;
/** /**
* Get the real world value mapping. * Get the real world value mapping.
* \return Linear mapping for mapping element values to real world values. * \return Linear mapping for mapping element values to real world values.
*/ */
const LinearMaping<float>& getRealWorldMapping() const; const LinearMapping<float>& getRealWorldMapping() const;
/** /**
* Set the real world value mapping. * Set the real world value mapping.
* \param rwvm Linear mapping for mapping element values to real world values. * \param rwvm Linear mapping for mapping element values to real world values.
*/ */
void setRealWorldMapping(const LinearMaping<float>& rwvm); void setRealWorldMapping(const LinearMapping<float>& rwvm);
private: private:
LinearMaping<float> _realWorldValueMapping; ///< Linear mapping for mapping element values to real world values tgt::vec3 _offset; ///< Position of LLF corner in world coordinates (mm)
tgt::mat4 _voxelToWorldTransformation; ///< Transformation matrix from voxel to world coordinates tgt::vec3 _voxelSize; ///< Voxel size in (mm)
LinearMapping<float> _realWorldValueMapping; ///< Linear mapping for mapping element values to real world values
//tgt::mat4 _voxelToWorldTransformation; ///< Transformation matrix from voxel to world coordinates
static const std::string loggerCat_; static const std::string loggerCat_;
}; };
......
...@@ -82,6 +82,12 @@ namespace TUMVis { ...@@ -82,6 +82,12 @@ namespace TUMVis {
*/ */
virtual const std::string getName() const = 0; virtual const std::string getName() const = 0;
/**
* Gets a description of this processor. To be defined by every subclass.
* \return A description what this processor does.
*/
virtual const std::string getDescription() const = 0;
/** /**
* Update the processor's invalidation level by \a nl. * Update the processor's invalidation level by \a nl.
* If \a nl is VALID, the processor's invalidation level will be set to VALID. * If \a nl is VALID, the processor's invalidation level will be set to VALID.
......
...@@ -98,6 +98,7 @@ namespace TUMVis { ...@@ -98,6 +98,7 @@ namespace TUMVis {
// = Typedefs ===================================================================================== // = Typedefs =====================================================================================
typedef GenericProperty<bool> BoolProperty;
typedef GenericProperty<std::string> StringProperty; typedef GenericProperty<std::string> StringProperty;
// = Template Implementation ====================================================================== // = Template Implementation ======================================================================
......
...@@ -22,7 +22,7 @@ namespace TUMVis { ...@@ -22,7 +22,7 @@ namespace TUMVis {
**/ **/
virtual ~TransferFunctionProperty(); virtual ~TransferFunctionProperty();
/// \overload /// \see AbstractProperty::deinit()
virtual void deinit(); virtual void deinit();
AbstractTransferFunction* getTF(); AbstractTransferFunction* getTF();
......
...@@ -9,15 +9,15 @@ namespace TUMVis { ...@@ -9,15 +9,15 @@ namespace TUMVis {
* \tparam T Numeric type for mapping * \tparam T Numeric type for mapping
**/ **/
template<typename T> template<typename T>
struct LinearMaping { struct LinearMapping {
public: public:
/** /**
* Creates a new LinearMaping object * Creates a new LinearMapping object
* \param shift Shifting coefficient of mapping * \param shift Shifting coefficient of mapping
* \param scale Scaling coefficient of mapping * \param scale Scaling coefficient of mapping
* \return * \return
*/ */
LinearMaping(T shift, T scale) LinearMapping(T shift, T scale)
: _shift(shift) : _shift(shift)
, _scale(scale) , _scale(scale)
{}; {};
...@@ -47,11 +47,11 @@ namespace TUMVis { ...@@ -47,11 +47,11 @@ namespace TUMVis {
/** /**
* Identity mapping (shift = 0, scale = 1). * Identity mapping (shift = 0, scale = 1).
*/ */
static const LinearMaping<T> identity; static const LinearMapping<T> identity;
}; };
template<typename T> template<typename T>
const LinearMaping<T> LinearMaping<T>::identity = LinearMaping<T>(T(0), T(1)); const LinearMapping<T> LinearMapping<T>::identity = LinearMapping<T>(T(0), T(1));
} }
#endif // mapping_h__ #endif // mapping_h__
\ No newline at end of file
...@@ -33,6 +33,8 @@ namespace TUMVis { ...@@ -33,6 +33,8 @@ namespace TUMVis {
/// \see AbstractProcessor::getName() /// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "MhdImageReader"; }; virtual const std::string getName() const { return "MhdImageReader"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Reads an MHD image into the pipeline."; };
GenericProperty<std::string> _url; ///< URL for file to read GenericProperty<std::string> _url; ///< URL for file to read
GenericProperty<std::string> _targetImageID; ///< image ID for read image GenericProperty<std::string> _targetImageID; ///< image ID for read image
......
#include "dvrvis.h"
#include "tgt/event/keyevent.h"
#include "tgt/glcontext.h"
#include "core/datastructures/imagedataconverter.h"
namespace TUMVis {
DVRVis::DVRVis()
: VisualizationPipeline()
, _imageReader()
, _eepGenerator(_renderTargetSize)
{
_processors.push_back(&_imageReader);
_processors.push_back(&_eepGenerator);
}
DVRVis::~DVRVis() {
}
void DVRVis::init() {
VisualizationPipeline::init();
_imageReader._url.setValue("D:\\Medical Data\\smallHeart.mhd");
_imageReader._targetImageID.setValue("reader.output");
_eepGenerator._sourceImageID.setValue("eep.input");
_eepGenerator._entryImageID.setValue("eep.entry");
_eepGenerator._exitImageID.setValue("eep.exit");
_renderTargetID.setValue("renderTarget");
_renderTargetID.addSharedProperty(&(_eepGenerator._entryImageID));
_imageReader.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
_eepGenerator.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
}
void DVRVis::execute() {
{
tbb::spin_mutex::scoped_lock lock(_localMutex);
_invalidationLevel.setValid();
// TODO: think whether we want to lock all processors already here.
}
if (! _imageReader.getInvalidationLevel().isValid()) {
executeProcessor(_imageReader);
// convert data
DataContainer::ScopedTypedData<ImageData> img(_data, "reader.output");
{
tgt::GLContextScopedLock lock(_canvas->getContext());
ImageDataGL* gl = ImageDataConverter::tryConvert<ImageDataGL>(img);
if (gl != 0) {
_data.addData("eep.input", gl);
}
}
}
if (! _eepGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(_eepGenerator);
}
}
const std::string DVRVis::getName() const {
return "DVRVis";
}
}
\ No newline at end of file
#ifndef DVRVIS_H__
#define DVRVIS_H__
#include "core/datastructures/imagedatalocal.h"
#include "core/eventhandlers/mwheeltonumericpropertyeventhandler.h"
#include "core/pipeline/visualizationpipeline.h"
#include "modules/io/mhdimagereader.h"
#include "modules/vis/eepgenerator.h"
namespace TUMVis {
class DVRVis : public VisualizationPipeline {
public:
/**
* Creates a VisualizationPipeline.
* \param canvas Canvas hosting the OpenGL context for this pipeline.
*/
DVRVis();
/**
* Virtual Destructor
**/
virtual ~DVRVis();
/// \see VisualizationPipeline::init()
virtual void init();
/// \see AbstractPipeline::getName()
virtual const std::string getName() const;
/**
* Execute this pipeline.
**/
virtual void execute();
protected:
MhdImageReader _imageReader;
EEPGenerator _eepGenerator;
};
}
#endif // DVRVIS_H__
#include "eepgenerator.h"
#include "tgt/glmath.h"
#include "tgt/logmanager.h"
#include "tgt/quadrenderer.h"
#include "tgt/shadermanager.h"
#include "tgt/textureunit.h"
#include "core/datastructures/imagedata.h"
#include "core/datastructures/imagedatagl.h"
#include "core/datastructures/imagedatarendertarget.h"
#include "core/datastructures/imagedataconverter.h"
#include "core/classification/simpletransferfunction.h"
namespace TUMVis {
const std::string EEPGenerator::loggerCat_ = "TUMVis.modules.vis.EEPGenerator";
EEPGenerator::EEPGenerator(GenericProperty<tgt::ivec2>& canvasSize)
: VisualizationProcessor(canvasSize)
, _sourceImageID("sourceImageID", "Input Image", "")
, _entryImageID("entryImageID", "Output Entry Points Image", "")
, _exitImageID("exitImageID", "Output Exit Points Image", "")
, _camera("camera", "Camera")
, _jitterEntryPoints("jitterEntryPoints", "Jitter Entry Points", true)
, _shader(0)
{
addProperty(&_sourceImageID);
addProperty(&_entryImageID);
addProperty(&_exitImageID);
addProperty(&_camera);
}
EEPGenerator::~EEPGenerator() {
}
void EEPGenerator::init() {
VisualizationProcessor::init();
_shader = ShdrMgr.loadSeparate("core/glsl/passthrough.vert", "modules/vis/eepgenerator.frag", "", false);
}
void EEPGenerator::deinit() {
ShdrMgr.dispose(_shader);
VisualizationProcessor::deinit();
}
void EEPGenerator::process(DataContainer& data) {
DataContainer::ScopedTypedData<ImageDataGL> img(data, _sourceImageID.getValue());
if (img != 0) {
if (img->getDimensionality() == 3) {
// TODO: implement some kind of proxy geometry...
tgt::Bounds volumeExtent = img->getWorldBounds();
//tgt::Bounds volumeExtent(tgt::vec3(-1.f), tgt::vec3(1.f));
tgt::Bounds textureBounds(tgt::vec3(0.f), tgt::vec3(1.f));
tgt::vec3 pos = volumeExtent.center() - tgt::vec3(0, 0, tgt::length(volumeExtent.diagonal()));
tgt::Camera cam(pos, volumeExtent.center());
cam.setFarDist(500.f);
// set modelview and projection matrices
glPushAttrib(GL_ALL_ATTRIB_BITS);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
tgt::loadMatrix(cam.getProjectionMatrix());
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
tgt::loadMatrix(cam.getViewMatrix());
_shader->activate();
// create entry points texture
ImageDataRenderTarget* entrypoints = new ImageDataRenderTarget(tgt::svec3(_renderTargetSize.getValue(), 1));
entrypoints->activate();
glDepthFunc(GL_LESS);
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCullFace(GL_BACK);
_shader->setUniform("_jitterPoints", _jitterEntryPoints.getValue());
renderProxyGeometry(volumeExtent, textureBounds);
entrypoints->deactivate();
// create exit points texture
ImageDataRenderTarget* exitpoints = new ImageDataRenderTarget(tgt::svec3(_renderTargetSize.getValue(), 1));
exitpoints->activate();
glDepthFunc(GL_GREATER);
glClearDepth(0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCullFace(GL_FRONT);
_shader->setUniform("_jitterPoints", false);
renderProxyGeometry(volumeExtent, textureBounds);
exitpoints->deactivate();
_shader->deactivate();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopAttrib();
data.addData(_entryImageID.getValue(), entrypoints);
data.addData(_exitImageID.getValue(), exitpoints);
}
else {
LERROR("Input image must have dimensionality of 3.");
}
}
else {
LERROR("No suitable input image found.");
}
_invalidationLevel.setValid();
}
void EEPGenerator::renderProxyGeometry(const tgt::Bounds& bounds, const tgt::Bounds& texBounds) {
const tgt::vec3& llf = bounds.getLLF();
const tgt::vec3& urb = bounds.getURB();
const tgt::vec3& tLlf = texBounds.getLLF();
const tgt::vec3& tUrb = texBounds.getURB();
// TODO: get fuckin' rid of intermediate mode, it simply sucks...
glColor3f(1.f, 0.f, 1.f);
glBegin(GL_QUADS);
// front
glTexCoord3f(tLlf.x, tLlf.y, tLlf.z);
glVertex3fv(llf.elem);
glTexCoord3f(tUrb.x, tLlf.y, tLlf.z);
glVertex3f(urb.x, llf.y, llf.z);
glTexCoord3f(tUrb.x, tUrb.y, tLlf.z);