The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit d81408b6 authored by schultezub's avatar schultezub
Browse files

* added Vector support to NumericProperty

 * introducing ProxyGeometryGenerator
 * updated DVRVis
 * updated TumVisApplication to check for OpenGL and GLSL 3.3

git-svn-id: https://camplinux.in.tum.de/svn/campvis/trunk@276 bb408c1c-ae56-11e1-83d9-df6b3e0c105e
parent e92090bd
......@@ -100,15 +100,14 @@ namespace TUMVis {
tgt::GLContextScopedLock lock(_localContext->getContext());
tgt::initGL(featureset);
//ShdrMgr.setGlobalHeader("#version 130\n");
LGL_ERROR;
// ensure matching OpenGL specs
if (GpuCaps.getGlVersion() < tgt::GpuCapabilities::GlVersion::TGT_GL_VERSION_3_0) {
LERROR("Your system does not support OpenGL 3.0, which is mandatory. TUMVis will probably not work as intendet.");
if (GpuCaps.getGlVersion() < tgt::GpuCapabilities::GlVersion::TGT_GL_VERSION_3_3) {
LERROR("Your system does not support OpenGL 3.3, which is mandatory. TUMVis will probably not work as intendet.");
}
if (GpuCaps.getShaderVersion() < tgt::GpuCapabilities::GlVersion::SHADER_VERSION_130) {
LERROR("Your system does not support GLSL Shader Version 1.30, which is mandatory. TUMVis will probably not work as intendet.");
if (GpuCaps.getShaderVersion() < tgt::GpuCapabilities::GlVersion::SHADER_VERSION_330) {
LERROR("Your system does not support GLSL Shader Version 3.30, which is mandatory. TUMVis will probably not work as intendet.");
}
QuadRenderer::init();
......
......@@ -87,7 +87,7 @@ namespace TUMVis {
return _faceNormal;
}
void FaceGeometry::render() {
void FaceGeometry::render() const {
createGLBuffers();
if (! _buffersInitialized) {
LERROR("Cannot render without initialized OpenGL buffers.");
......@@ -112,7 +112,7 @@ namespace TUMVis {
LGL_ERROR;
}
void FaceGeometry::createGLBuffers() {
void FaceGeometry::createGLBuffers() const {
if (! _buffersInitialized) {
try {
_verticesBuffer = new tgt::BufferObject(tgt::BufferObject::ARRAY_BUFFER, tgt::BufferObject::USAGE_STATIC_DRAW);
......
......@@ -112,13 +112,13 @@ namespace TUMVis {
* Renders this FaceGeometry.
* Must be called from a valid OpenGL context.
*/
virtual void render();
virtual void render() const;
/**
* Creates the OpenGL VBOs and the VAO for this face's geometry.
* Must be called from a valid OpenGL context.
*/
virtual void createGLBuffers();
virtual void createGLBuffers() const;
protected:
......
......@@ -60,13 +60,13 @@ namespace TUMVis {
* Renders this GeometryData.
* Must be called from a valid OpenGL context.
*/
virtual void render() = 0;
virtual void render() const = 0;
/**
* Creates the OpenGL VBOs and the VAO for this geometry.
* Must be called from a valid OpenGL context.
*/
virtual void createGLBuffers() = 0;
virtual void createGLBuffers() const = 0;
const tgt::BufferObject* getVerticesBuffer() const;
......@@ -77,12 +77,12 @@ namespace TUMVis {
const tgt::BufferObject* getNormalsBuffer() const;
protected:
bool _buffersInitialized;
tgt::BufferObject* _verticesBuffer;
tgt::BufferObject* _texCoordsBuffer;
tgt::BufferObject* _colorsBuffer;
tgt::BufferObject* _normalsBuffer;
// mutable to support const lazy initialization
mutable bool _buffersInitialized;
mutable tgt::BufferObject* _verticesBuffer;
mutable tgt::BufferObject* _texCoordsBuffer;
mutable tgt::BufferObject* _colorsBuffer;
mutable tgt::BufferObject* _normalsBuffer;
};
}
......
......@@ -60,7 +60,7 @@ namespace TUMVis {
}
void MeshGeometry::render() {
void MeshGeometry::render() const {
createGLBuffers();
if (! _buffersInitialized) {
LERROR("Cannot render without initialized OpenGL buffers.");
......@@ -90,7 +90,7 @@ namespace TUMVis {
LGL_ERROR;
}
void MeshGeometry::createGLBuffers() {
void MeshGeometry::createGLBuffers() const {
if (! _buffersInitialized) {
bool createTexCoordsBuffer = true;
bool createColorsBuffer = true;
......@@ -162,7 +162,7 @@ namespace TUMVis {
}
}
TUMVis::MeshGeometry MeshGeometry::createCube(const tgt::Bounds& bounds, const tgt::Bounds& texBounds) {
TUMVis::MeshGeometry* MeshGeometry::createCube(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();
......@@ -250,7 +250,7 @@ namespace TUMVis {
vertices.clear();
texCoords.clear();
return MeshGeometry(faces);
return new MeshGeometry(faces);
}
}
\ No newline at end of file
......@@ -76,21 +76,22 @@ namespace TUMVis {
* Renders this MeshGeometry.
* Must be called from a valid OpenGL context.
*/
virtual void render();
virtual void render() const;
/**
* Creates the OpenGL VBOs and the VAO for this face's geometry.
* Must be called from a valid OpenGL context.
*/
virtual void createGLBuffers();
virtual void createGLBuffers() const;
/**
* Creates a MeshGeometry building a cube with the given bounds and texture coordinates
* Creates a MeshGeometry building a cube with the given bounds and texture coordinates.
* \note The caller owns the returned pointer.
* \param bounds coordinates of the cube bounds
* \param texBounds texture coordinates at the cube bounds
* \return A MeshGeometry building a cube with the given bounds and texture coordinates
*/
static MeshGeometry createCube(const tgt::Bounds& bounds, const tgt::Bounds& texBounds);
static MeshGeometry* createCube(const tgt::Bounds& bounds, const tgt::Bounds& texBounds);
protected:
......
......@@ -29,8 +29,54 @@
#ifndef NUMERICPROPERTY_H__
#define NUMERICPROPERTY_H__
#include "tgt/vector.h"
#include "core/tools/interval.h"
#include "core/properties/genericproperty.h"
#include <limits>
namespace {
/**
* Helper struct for template specialization regarding scalar/vector types.
*/
template<typename T, bool IsScalar>
struct NumericPropertyTraits {
};
/**
* Specialized traits for scalar NumericProperties.
*/
template<typename T>
struct NumericPropertyTraits<T, true> {
static T validateValue(const T& value, const T& minValue, const T& maxValue) {
if (value >= minValue && value <= maxValue)
return value;
else {
return (value < minValue) ? minValue : maxValue;
}
}
};
/**
* Specialized traits for vector NumericProperties.
*/
template<typename T>
struct NumericPropertyTraits<T, false> {
static T validateValue(const T& value, const T& minValue, const T& maxValue) {
T toReturn(value);
for (size_t i = 0; i < value.size; ++i) {
if (toReturn[i] < minValue[i])
toReturn[i] = minValue[i];
else if (toReturn[i] > maxValue[i])
toReturn[i] = maxValue[i];
}
return toReturn;
}
};
}
namespace TUMVis {
/**
* Interface for numeric properties.
......@@ -146,6 +192,13 @@ namespace TUMVis {
typedef NumericProperty<int> IntProperty;
typedef NumericProperty<float> FloatProperty;
typedef NumericProperty<tgt::ivec2> IVec2Property;
typedef NumericProperty<tgt::vec2> Vec2Property;
typedef NumericProperty<tgt::ivec3> IVec3Property;
typedef NumericProperty<tgt::vec3> Vec3Property;
typedef NumericProperty<tgt::ivec4> IVec4Property;
typedef NumericProperty<tgt::vec4> Vec4Property;
// = Template Implementation ======================================================================
template<typename T>
......@@ -175,11 +228,7 @@ namespace TUMVis {
template<typename T>
T TUMVis::NumericProperty<T>::validateValue(const T& value) {
if (value >= _minValue && value <= _maxValue)
return value;
else {
return (value < _minValue) ? _minValue : _maxValue;
}
return NumericPropertyTraits<T, std::numeric_limits<T>::is_specialized>::validateValue(value, _minValue, _maxValue);
}
template<typename T>
......
......@@ -39,6 +39,7 @@ namespace TUMVis {
: VisualizationPipeline()
, _camera("camera", "Camera")
, _imageReader()
, _pgGenerator()
, _eepGenerator(_renderTargetSize)
, _drrraycater(_renderTargetSize)
, _simpleRaycaster(_renderTargetSize)
......@@ -56,6 +57,7 @@ namespace TUMVis {
_eventHandlers.push_back(_trackballEH);
_processors.push_back(&_imageReader);
_processors.push_back(&_pgGenerator);
_processors.push_back(&_eepGenerator);
_processors.push_back(&_drrraycater);
_processors.push_back(&_simpleRaycaster);
......@@ -98,6 +100,9 @@ namespace TUMVis {
_eepGenerator._entryImageID.setValue("eep.entry");
_eepGenerator._exitImageID.setValue("eep.exit");
_pgGenerator._sourceImageID.setValue("eep.input");
_pgGenerator._geometryID.setValue("pg.input");
_renderTargetID.setValue("drr.output");
_imageReader.s_invalidated.connect<DVRVis>(this, &DVRVis::onProcessorInvalidated);
......@@ -139,6 +144,9 @@ namespace TUMVis {
_trackballEH->setCenter(volumeExtent.center());
_trackballEH->reinitializeCamera(pos, volumeExtent.center(), _camera.getValue().getUpVector());
}
if (! _pgGenerator.getInvalidationLevel().isValid()) {
executeProcessor(&_pgGenerator);
}
if (! _eepGenerator.getInvalidationLevel().isValid()) {
lockGLContextAndExecuteProcessor(&_eepGenerator);
}
......
......@@ -34,6 +34,7 @@
#include "core/pipeline/visualizationpipeline.h"
#include "core/properties/cameraproperty.h"
#include "modules/io/mhdimagereader.h"
#include "modules/vis/proxygeometrygenerator.h"
#include "modules/vis/eepgenerator.h"
#include "modules/vis/drrraycaster.h"
#include "modules/vis/simpleraycaster.h"
......@@ -68,6 +69,7 @@ namespace TUMVis {
protected:
CameraProperty _camera;
MhdImageReader _imageReader;
ProxyGeometryGenerator _pgGenerator;
EEPGenerator _eepGenerator;
DRRRaycaster _drrraycater;
SimpleRaycaster _simpleRaycaster;
......
......@@ -35,7 +35,7 @@
#include "core/datastructures/imagedatagl.h"
#include "core/datastructures/imagedatarendertarget.h"
#include "core/datastructures/meshgeometry.h"
#include "core/datastructures/geometrydata.h"
namespace TUMVis {
const std::string EEPGenerator::loggerCat_ = "TUMVis.modules.vis.EEPGenerator";
......@@ -43,6 +43,7 @@ namespace TUMVis {
EEPGenerator::EEPGenerator(GenericProperty<tgt::ivec2>& canvasSize)
: VisualizationProcessor(canvasSize)
, _sourceImageID("sourceImageID", "Input Image", "")
, _geometryID("geometryID", "Input Geometry ID", "pg.input")
, _entryImageID("entryImageID", "Output Entry Points Image", "")
, _exitImageID("exitImageID", "Output Exit Points Image", "")
, _camera("camera", "Camera")
......@@ -71,15 +72,14 @@ namespace TUMVis {
void EEPGenerator::process(DataContainer& data) {
DataContainer::ScopedTypedData<ImageDataGL> img(data, _sourceImageID.getValue());
DataContainer::ScopedTypedData<GeometryData> proxyGeometry(data, _geometryID.getValue());
if (img != 0) {
if (img != 0 && proxyGeometry != 0) {
if (img->getDimensionality() == 3) {
// TODO: implement some kind of cool proxy geometry supporting clipping (camera in volume)...
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::Bounds textureBounds(tgt::vec3(0.f), tgt::vec3(1.f));
MeshGeometry cube = MeshGeometry::createCube(volumeExtent, textureBounds);
// set modelview and projection matrices
glPushAttrib(GL_ALL_ATTRIB_BITS);
......@@ -98,7 +98,7 @@ namespace TUMVis {
glClearDepth(1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCullFace(GL_BACK);
cube.render();
proxyGeometry->render();
entrypoints->deactivate();
......@@ -110,7 +110,7 @@ namespace TUMVis {
glClearDepth(0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCullFace(GL_FRONT);
cube.render();
proxyGeometry->render();
exitpoints->deactivate();
......@@ -126,7 +126,7 @@ namespace TUMVis {
}
}
else {
LERROR("No suitable input image found.");
LERROR("No suitable input image or proxy geometry found.");
}
_invalidationLevel.setValid();
......
......@@ -72,6 +72,7 @@ namespace TUMVis {
virtual void process(DataContainer& data);
StringProperty _sourceImageID; ///< image ID for input image
StringProperty _geometryID; ///< ID for input geometry
StringProperty _entryImageID; ///< image ID for output entry points image
StringProperty _exitImageID; ///< image ID for output exit points image
......
// ================================================================================================
//
// 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 "proxygeometrygenerator.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/meshgeometry.h"
namespace TUMVis {
const std::string ProxyGeometryGenerator::loggerCat_ = "TUMVis.modules.vis.ProxyGeometryGenerator";
ProxyGeometryGenerator::ProxyGeometryGenerator()
: AbstractProcessor()
, _sourceImageID("sourceImageID", "Input Image", "")
, _geometryID("geometryID", "Output Geometry ID", "pg.output")
, _clipX("clipX", "X Axis Clip Coordinates", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(0))
, _clipY("clipY", "Y Axis Clip Coordinates", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(0))
, _clipZ("clipZ", "Z Axis Clip Coordinates", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(0))
{
addProperty(&_sourceImageID);
addProperty(&_geometryID);
addProperty(&_clipX);
addProperty(&_clipY);
addProperty(&_clipZ);
}
ProxyGeometryGenerator::~ProxyGeometryGenerator() {
}
void ProxyGeometryGenerator::process(DataContainer& data) {
DataContainer::ScopedTypedData<ImageData> img(data, _sourceImageID.getValue());
if (img != 0) {
if (img->getDimensionality() == 3) {
if (img.getDataHandle()->getTimestamp() != _sourceTimestamp) {
_clipX.setMaxValue(tgt::ivec2(img->getSize().x, img->getSize().x));
_clipY.setMaxValue(tgt::ivec2(img->getSize().y, img->getSize().y));
_clipZ.setMaxValue(tgt::ivec2(img->getSize().z, img->getSize().z));
_clipX.setValue(tgt::ivec2(0, img->getSize().x));
_clipY.setValue(tgt::ivec2(0, img->getSize().y));
_clipZ.setValue(tgt::ivec2(0, img->getSize().z));
_sourceTimestamp = img.getDataHandle()->getTimestamp();
}
// TODO: implement some kind of cool proxy geometry supporting clipping (camera in volume)...
tgt::Bounds volumeExtent = img->getWorldBounds();
tgt::vec3 numSlices = tgt::vec3(img->getSize());
tgt::vec3 texLLF(static_cast<float>(_clipX.getValue().x), static_cast<float>(_clipY.getValue().x), static_cast<float>(_clipZ.getValue().x));
texLLF /= numSlices;
tgt::vec3 texURB(static_cast<float>(_clipX.getValue().y), static_cast<float>(_clipY.getValue().y), static_cast<float>(_clipZ.getValue().y));
texURB /= numSlices;
MeshGeometry* cube = MeshGeometry::createCube(volumeExtent, tgt::Bounds(texLLF, texURB));
data.addData(_geometryID.getValue(), cube);
}
else {
LERROR("Input image must have dimensionality of 3.");
}
}
else {
LERROR("No suitable input image 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
// 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 PROXYGEOMETRYGENERATOR_H__
#define PROXYGEOMETRYGENERATOR_H__
#include <string>
#include "core/classification/abstracttransferfunction.h"
#include "core/pipeline/visualizationprocessor.h"
#include "core/properties/genericproperty.h"
#include "core/properties/numericproperty.h"
namespace TUMVis {
/**
* Genereates entry-/exit point textures for the given image and camera.
*/
class ProxyGeometryGenerator : public AbstractProcessor {
public:
/**
* Constructs a new ProxyGeometryGenerator Processor
**/
ProxyGeometryGenerator();
/**
* Destructor
**/
virtual ~ProxyGeometryGenerator();
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "ProxyGeometryGenerator"; };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Genereates entry-/exit point textures for the given image and camera."; };
virtual void process(DataContainer& data);
StringProperty _sourceImageID; ///< image ID for input image
StringProperty _geometryID; ///< ID for output geometry
IVec2Property _clipX; ///< clip coordinates for x axis
IVec2Property _clipY; ///< clip coordinates for y axis
IVec2Property _clipZ; ///< clip coordinates for z axis
protected:
void updateClipProperties();
clock_t _sourceTimestamp;
static const std::string loggerCat_;
};
}
#endif // PROXYGEOMETRYGENERATOR_H__
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