Notice: If you are member of any public project or group, please make sure that your GitLab username is not the same as the LRZ identifier/Kennung (see https://gitlab.lrz.de/profile/account). Please change your username if necessary. For more information see the section "Public projects / Öffentliche Projekte" at https://doku.lrz.de/display/PUBLIC/GitLab . Thank you!

Commit 2123a4af authored by Jakob Weiss's avatar Jakob Weiss

Various minor fixes:

* added buildClang to .gitignore
* Minimum required glsl version is now 430 by default (might be possible to downgrade again by checking on a per-module basis)
* More of the base modules now register their processors into the factory.
* Minor bugfixes in optimizedraycaster (inverted gradient dir) and glimageresampler (renamed variable)
parent 5cbfe490
......@@ -53,4 +53,5 @@ ext/tbb
build/
build14/
build15/
.vscode/
\ No newline at end of file
.vscode/
buildClang/
......@@ -61,7 +61,7 @@ namespace campvis {
LERRORC("CAMPVis.core.init", "Your system does not support GLSL Shader Version 3.30, which is mandatory. CAMPVis will probably not work as intended.");
}
ShdrMgr.setDefaultGlslVersion("330");
ShdrMgr.setDefaultGlslVersion("430");
for (auto it = searchPaths.cbegin(); it != searchPaths.cend(); ++it) {
ShdrMgr.addPath(*it);
ShdrMgr.addPath(*it + "/core/glsl");
......
......@@ -46,6 +46,9 @@ namespace campvis {
class AbstractProcessor;
class DataContainer;
template <typename T>
using has_ivec2_constructor = decltype(T::foobar);
/**
* Factory for creating processors by their name.
* Using some template-magic, ProcessorFactory is able to register processors during static
......@@ -211,7 +214,7 @@ namespace campvis {
};
template<typename T>
const size_t campvis::SmartProcessorRegistrar<T>::_helperField = ProcessorRegistrarSwitch< T, std::is_base_of<VisualizationProcessor, T>::value >::_factoryId;
const size_t campvis::SmartProcessorRegistrar<T>::_helperField = ProcessorRegistrarSwitch< T, std::is_constructible<T, IVec2Property*>::value>::_factoryId;
}
......
......@@ -2,7 +2,8 @@
IF(${ModuleEnabled})
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/base/base.cpp
modules/base/processors/*.cpp
)
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "core/pipeline/pipelinefactory.h"
#include "core/pipeline/processorfactory.h"
#include "modules/base/processors/lightsourceprovider.h"
#include "modules/base/processors/dataseriessplitter.h"
#include "modules/base/processors/matrixprocessor.h"
#include "modules/base/processors/trackballcameraprovider.h"
namespace campvis {
// explicitly instantiate templates to register the processors
template class SmartProcessorRegistrar<DataSeriesSplitter>;
template class SmartProcessorRegistrar<LightSourceProvider>;
template class SmartProcessorRegistrar<MatrixProcessor>;
template class SmartProcessorRegistrar<TrackballCameraProvider>;
}
......@@ -57,8 +57,10 @@ namespace campvis {
/// \see AbstractProcessor::updateResult()
virtual void updateResult(DataContainer& dataContainer);
/// To be used in ProcessorFactory static methods
static const std::string getId() { return "CameraProvider"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "CameraProvider"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Generates CameraData objects."; };
/// \see AbstractProcessor::getAuthor()
......@@ -85,4 +87,4 @@ namespace campvis {
}
#endif // CAMERAPROVIDER_H__
\ No newline at end of file
#endif // CAMERAPROVIDER_H__
......@@ -45,8 +45,10 @@ namespace campvis {
**/
virtual ~DataSeriesSplitter();
/// To be used in ProcessorFactory static methods
static const std::string getId() { return "DataSeriesSplitter"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "DataSeriesSplitter"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Extracts a single AbstractData instance from a DataSeries."; };
/// \see AbstractProcessor::getAuthor()
......
......@@ -39,11 +39,11 @@
namespace campvis {
/**
* Matrix processor to perform some basic matrix arithmatic like combining two matrices.
*
* Takes two matrices as an input either from a string or from the data container
* (see \a processMatrixString()), preprocesses them according to the specified modifiers (see \a processModiferString())
* and puts the result of multiplying A*B into the data container as a \a TransformData entry.
*
*
* Takes two matrices as an input either from a string or from the data container
* (see \a processMatrixString()), preprocesses them according to the specified modifiers (see \a processModiferString())
* and puts the result of multiplying A*B into the data container as a \a TransformData entry.
*
* As an alternative, the "Parser Mode" is offered. This offers a possibility to evaluate more complicated formulas
* without the need for multiple MatrixProcessor instances. For details on the syntax, see \a parseString(). The parsing is
* slower than the "basic" mode, but for most applications this performance hit should not be a problem.
......@@ -54,10 +54,10 @@ namespace campvis {
* the property as a target for a TrackballEventHandler) as this feature only modifies the position, lookat and up vector of the
* camera.
*
* Example use case: OpenIGTLink client outputs matrices TrackerToReference and TrackerToProbe. Configure
* matrixA as "TrackerToProbe" with modifier "I" and matrixB as "TrackerToReference" with empty modifier
* to compute the "ProbeToReference" matrix. If an additional calibration matrix is needed, this can be achieved by
* adding a new MatrixProcessor that multiplies a hardcoded calibration matrix to the result or the inputs.
* Example use case: OpenIGTLink client outputs matrices TrackerToReference and TrackerToProbe. Configure
* matrixA as "TrackerToProbe" with modifier "I" and matrixB as "TrackerToReference" with empty modifier
* to compute the "ProbeToReference" matrix. If an additional calibration matrix is needed, this can be achieved by
* adding a new MatrixProcessor that multiplies a hardcoded calibration matrix to the result or the inputs.
*/
class CAMPVIS_MODULES_API MatrixProcessor : public AbstractProcessor {
public:
......@@ -77,12 +77,14 @@ namespace campvis {
/// \see AbstractProcessor::deinit()
virtual void deinit();
/// To be used in ProcessorFactory static methods
static const std::string getId() { return "MatrixProcessor"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "MatrixProcessor"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Matrix Processor to process/combine matrices and write the result into the data container"; };
/// \see AbstractProcessor::getAuthor()
virtual const std::string getAuthor() const { return "Jakob Weiss <weissj@in.tum.de>"; };
virtual const std::string getAuthor() const { return "Jakob Weiss <jakob.weiss@tum.de>"; };
/// \see AbstractProcessor::getProcessorState()
virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
......@@ -102,55 +104,55 @@ namespace campvis {
DataNameProperty p_targetMatrixID; ///< name for the output matrix
void DataContainerDataAdded(std::string name, DataHandle data);
void DataContainerDataAdded(std::string name, DataHandle data);
protected:
/// \see AbstractProcessor::updateResult()
virtual void updateResult(DataContainer& dataContainer);
/// \see AbstractProcessor::updateProperties()
virtual void updateProperties(DataContainer& dataContainer);
/// \see AbstractProcessor::updateProperties()
virtual void updateProperties(DataContainer& dataContainer);
/**
* Processes a modifier string and returns the modified matrix.
*
* \param matrix the input matrix to be modified
* \param modifiers a string containing modifiers that will be applied to the matrix from left to right.
* Possible Modifiers are:
* - _I_: invert matrix
* - _T_: transpose matrix
* - _r_: extract rotational part \see cgt::mat4::getRotationalPart()
* - _s_: extract scaling part \see cgt::mat4::getScalingPart()
* - _-_: negate componentwise
*
* i.e. a call with a modifier string "IT" will calculate the transpose of the inverse.
*/
cgt::mat4 processModifierString(cgt::mat4 matrix, std::string modifiers);
/**
* Processes a modifier string and returns the modified matrix.
*
* \param matrix the input matrix to be modified
* \param modifiers a string containing modifiers that will be applied to the matrix from left to right.
* Possible Modifiers are:
* - _I_: invert matrix
* - _T_: transpose matrix
* - _r_: extract rotational part \see cgt::mat4::getRotationalPart()
* - _s_: extract scaling part \see cgt::mat4::getScalingPart()
* - _-_: negate componentwise
*
* i.e. a call with a modifier string "IT" will calculate the transpose of the inverse.
*/
cgt::mat4 processModifierString(cgt::mat4 matrix, std::string modifiers);
/**
* Processes a matrix string and returns the resulting matrix.
*
* \param matrixString the matrix string to be parsed
* \param data the data container that is used to read data from
* Processes a matrix string and returns the resulting matrix.
*
* \param matrixString the matrix string to be parsed
* \param data the data container that is used to read data from
* \param localDefs map of local definitions. if supplied, matrix names will be looked for in this
* map prior to a datacontainer lookup
*
* The matrix string can either be a name to a data handle or a string specifying a matrix directly.
* The string is split into tokens with space as a delimiter and is parsed according to the following rules:
* - an empty string or "identity" creates an identity matrix
* - if the string contains exactly 16 tokens, a direct matrix input is assumed: all
* tokens are converted to floats and are used as coefficients. The parsing is done row-major: a
* string "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 creates a matrix with first row 1,2,3,4, second row
* 5,6,7,8 and so on
* - "rot <angle> <ax> <ay> <az>" creates a rotation matrix around axis (ax,ay,az) with specified angle in radians.
* \see cgt::mat4::createRotation()
* - "trans <tx> <ty> <tz>" creates a translation matrix with translation (tx,ty,tz)
* - "scale <sx> [<sy> <sz>]" creates a scaling matrix. if only one coefficient is specified, a uniform scaling
* is created, otherwise all three scaling factors are used.
* - if any of the above fails, a warning is emitted and identity is returned
* - if none of the above cases apply, the name is assumed to be a name of a data handle in the supplied data container
* or the localDefs map, containing an entry of type \a TransformData
*/
*
* The matrix string can either be a name to a data handle or a string specifying a matrix directly.
* The string is split into tokens with space as a delimiter and is parsed according to the following rules:
* - an empty string or "identity" creates an identity matrix
* - if the string contains exactly 16 tokens, a direct matrix input is assumed: all
* tokens are converted to floats and are used as coefficients. The parsing is done row-major: a
* string "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 creates a matrix with first row 1,2,3,4, second row
* 5,6,7,8 and so on
* - "rot <angle> <ax> <ay> <az>" creates a rotation matrix around axis (ax,ay,az) with specified angle in radians.
* \see cgt::mat4::createRotation()
* - "trans <tx> <ty> <tz>" creates a translation matrix with translation (tx,ty,tz)
* - "scale <sx> [<sy> <sz>]" creates a scaling matrix. if only one coefficient is specified, a uniform scaling
* is created, otherwise all three scaling factors are used.
* - if any of the above fails, a warning is emitted and identity is returned
* - if none of the above cases apply, the name is assumed to be a name of a data handle in the supplied data container
* or the localDefs map, containing an entry of type \a TransformData
*/
cgt::mat4 processMatrixString(std::string matrixString, DataContainer& data, std::map<std::string, cgt::mat4> *localDefs = nullptr);
......
......@@ -62,9 +62,10 @@ namespace campvis {
**/
virtual ~TrackballCameraProvider();
/// To be used in ProcessorFactory static methods
static const std::string getId() { return "TrackballCameraProvider"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "TrackballCameraProvider"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Provides trackball navigation interaction metaphors when generating CameraData objects."; };
/// \see AbstractProcessor::getAuthor()
......@@ -150,4 +151,4 @@ namespace campvis {
}
#endif // TRACKBALLCAMERAPROVIDER_H__
\ No newline at end of file
#endif // TRACKBALLCAMERAPROVIDER_H__
......@@ -3,6 +3,7 @@
IF(${ModuleEnabled})
# Source files:
FILE(GLOB ThisModSources RELATIVE ${ModulesDir}
modules/io/io.cpp
modules/io/processors/*.cpp
)
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "core/pipeline/pipelinefactory.h"
#include "core/pipeline/processorfactory.h"
#include "modules/io/processors/genericimagereader.h"
#include "modules/io/processors/mhdimagewriter.h"
#include "modules/base/processors/matrixprocessor.h"
#include "modules/base/processors/trackballcameraprovider.h"
namespace campvis {
// explicitly instantiate templates to register the processors
template class SmartProcessorRegistrar<GenericImageReader>;
template class SmartProcessorRegistrar<MhdImageWriter>;
}
......@@ -64,8 +64,12 @@ namespace campvis {
/// \see AutoEvaluationPipeline::deinit()
virtual void deinit();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "GenericImageReader"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "GenericImageReader"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Reads an image into the pipeline."; };
/// \see AbstractProcessor::getAuthor()
......
......@@ -52,8 +52,12 @@ namespace campvis {
**/
virtual ~MhdImageWriter();
/**
* To be used in ProcessorFactory static methods
*/
static const std::string getId() { return "MhdImageWriter"; };
/// \see AbstractProcessor::getName()
virtual const std::string getName() const { return "MhdImageWriter"; };
virtual const std::string getName() const { return getId(); };
/// \see AbstractProcessor::getDescription()
virtual const std::string getDescription() const { return "Writes an image into an MHD file."; };
/// \see AbstractProcessor::getAuthor()
......
......@@ -38,12 +38,12 @@ uniform sampler2D _texture;
void main() {
#ifdef GLRESAMPLER_3D
vec4 sample = texture(_texture, vec3(ex_TexCoord.xy, _zTexCoord));
vec4 textureSample = texture(_texture, vec3(ex_TexCoord.xy, _zTexCoord));
#endif
#ifdef GLRESAMPLER_2D
vec4 sample = texture(_texture, ex_TexCoord.xy);
vec4 textureSample = texture(_texture, ex_TexCoord.xy);
#endif
out_Color = sample;
out_Color = textureSample;
}
......@@ -168,7 +168,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
if (color.a > 0.0) {
#ifdef ENABLE_SHADING
// compute gradient (needed for shading and normals)
vec3 gradient = computeGradient(_volume, _volumeTextureParams, samplePosition);
vec3 gradient = -computeGradient(_volume, _volumeTextureParams, samplePosition);
color.rgb = calculatePhongShading(textureToWorld(_volumeTextureParams, samplePosition), _lightSource, _cameraPosition, gradient, color.rgb, color.rgb, vec3(1.0, 1.0, 1.0));
#endif
......@@ -182,7 +182,7 @@ vec4 performRaycasting(in vec3 entryPoint, in vec3 exitPoint, in vec2 texCoords)
if (firstHitT < 0.0 && result.a > 0.0) {
firstHitT = t;
out_FHP = vec4(samplePosition, 1.0);
out_FHN = vec4(normalize(computeGradient(_volume, _volumeTextureParams, samplePosition)), 1.0);
out_FHN = vec4(normalize(-computeGradient(_volume, _volumeTextureParams, samplePosition)), 1.0);
}
// early ray termination
......
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