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

Removed a bunch of TODOs and FIXMEs.

parent 2247936f
......@@ -65,16 +65,16 @@ float rayBoxIntersection(in vec3 rayOrigin, in vec3 rayDirection, in vec3 boxLlf
return min(min(tMin.x, min(tMin.y, tMin.z)) , min(tMax.x, min(tMax.y, tMax.z)));
}
// compute the near and far intersections of the cube (stored in the x and y components) using the slab method
// no intersection means vec.x > vec.y (really tNear > tFar)
vec2 intersectAABB(vec3 rayOrigin, vec3 rayDirection, in vec3 boxLlf, in vec3 boxUrb) {
vec3 tMin = (boxLlf - rayOrigin) / rayDirection;
vec3 tMax = (boxUrb - rayOrigin) / rayDirection;
vec3 t1 = min(tMin, tMax);
vec3 t2 = max(tMin, tMax);
float tNear = max(max(t1.x, t1.y), t1.z);
float tFar = min(min(t2.x, t2.y), t2.z);
return vec2(tNear, tFar);
// compute the near and far intersections of the cube (stored in the x and y components) using the slab method
// no intersection means vec.x > vec.y (really tNear > tFar)
vec2 intersectAABB(vec3 rayOrigin, vec3 rayDirection, in vec3 boxLlf, in vec3 boxUrb) {
vec3 tMin = (boxLlf - rayOrigin) / rayDirection;
vec3 tMax = (boxUrb - rayOrigin) / rayDirection;
vec3 t1 = min(tMin, tMax);
vec3 t2 = max(tMin, tMax);
float tNear = max(max(t1.x, t1.y), t1.z);
float tFar = min(min(t2.x, t2.y), t2.z);
return vec2(tNear, tFar);
};
/**
......
......@@ -57,7 +57,8 @@ namespace campvis {
void AbstractProcessor::lockProcessor() {
while (_locked.compare_and_swap(true, false) == true) // TODO: busy waiting us fu**ing ugly...
// hopefully, it does not take too long.
while (_locked.compare_and_swap(true, false) == true)
std::this_thread::yield();
_locked = true;
lockAllProperties();
......
......@@ -62,7 +62,7 @@ namespace campvis {
*
* \param str Input string to parse.
*
* \note TODO: The detection algorithm is a little simplified and will not yield correct results
* \note The detection algorithm is a little simplified and may not yield correct results
* in every case.
**/
static std::vector<std::string> parseFloats(const std::string& str);
......
......@@ -49,7 +49,6 @@
//Interaction
//#include "glcanvas.h"
// FIXME: include glcanvas and guiapplication, include glut/qt/sdl-canvas/application/libs depending on macros
#include "cgt/mouse.h"
#include "cgt/camera.h"
#include "cgt/navigation/navigation.h"
......
......@@ -53,9 +53,6 @@
using std::string;
//TODO: should really switch to exceptions instead of just logging with LERROR. joerg
// see http://en.wikipedia.org/wiki/Aliasing_%28computing%29#Conflicts_with_optimization
// anonymous namespace
namespace {
......
......@@ -48,7 +48,6 @@ GLCanvas::GLCanvas(const std::string& title,
stereoViewing_(false),
fullscreen_(false),
autoFlush_(true),
initialized_(false),
painter_(0) ,
eventHandler_(new EventHandler())
{}
......@@ -78,8 +77,7 @@ void GLCanvas::paint() {
}
void GLCanvas::init() {
if (!initialized_)
initialized_ = true;
// nothing here, may be implemented in sub classes.
}
void GLCanvas::setPainter(Painter* p, bool initP) {
......
......@@ -179,9 +179,6 @@ public:
/// Getter
bool isDoubleBuffered() const { return doubleBuffered_; }
/// Getter
bool isInitialized() const { return initialized_; }
/// Acqures this canvas as current context
virtual void acquireAsCurrentContext() = 0;
/// Releases this canvas as current context
......@@ -204,7 +201,6 @@ protected:
bool stereoViewing_;
bool fullscreen_;
bool autoFlush_; ///< whether to call glFlush or swap automatically
bool initialized_; // FIXME: does this make sense?
Painter* painter_; ///< the painter that will be used for rendering
......
......@@ -195,10 +195,9 @@ void ResourceManager<T>::dispose(T* ptr) {
template <class T>
void ResourceManager<T>::addPath(std::string path) {
tbb::spin_mutex::scoped_lock lock(this->mutex_);
pathList_.push_front(path);
// remove duplicates
//TODO: better use std::set<> here
pathList_.sort();
pathList_.unique();
}
......
......@@ -35,7 +35,7 @@
#include "cgt/assert.h"
/*
FIXME build a SSE-optimized mat4
TODO: build a SSE-optimized mat4
*/
/*
......
......@@ -57,9 +57,7 @@ void Navigation::rotateView(float angle, const vec3& axis) {
// Rotate the Camera about horizontal and vertical angles given by the user
void Navigation::rotateViewHV(float anglehorz, float anglevert) {
// FIXME: rotateViewHorz(anglehorz);rotateViewVert(anglevert) would be much more generic ... but maybe more expensive ...
// rotateViewHorz(anglehorz);rotateViewVert(anglevert) would be much more generic ... but maybe more expensive ...
// for now, we use quaternion rotation... we'll have to benchmark this
quat horz = quat::createQuat(anglehorz, getCamera()->getUpVector());
quat vert = quat::createQuat(anglevert, getCamera()->getStrafe());
......@@ -79,8 +77,6 @@ void Navigation::rotateViewHV(float anglehorz, float anglevert) {
updateClippingPlanes();
}
// FIXME: the following few functions should be inline
void Navigation::rotateView(float angle, float x, float y, float z) {
rotateView(angle, vec3(x, y, z));
}
......
......@@ -325,7 +325,7 @@ class CGT_API Trackball : public Navigation {
KeyEvent::KeyCode keyRotateUp_ ; ///< at which key code rotate up
KeyEvent::KeyCode keyRotateDown_ ; ///< at which key code rotate down
int keyRotateMod_ ; ///< at which modifiers to rotate by keys
bool keyRotatePressed_ ; // FIXME: cannot remember. not in use anyway...
bool keyRotatePressed_ ;
MouseEvent::MouseButtons mouseMoveButton_ ;
int mouseMoveMod_ ;
float keyMoveAcuteness_ ;
......@@ -334,7 +334,7 @@ class CGT_API Trackball : public Navigation {
KeyEvent::KeyCode keyMoveUp_ ;
KeyEvent::KeyCode keyMoveDown_ ;
int keyMoveMod_ ;
bool keyMovePressed_ ; // FIXME: cannot remember, not in use
bool keyMovePressed_ ;
MouseEvent::MouseButtons mouseZoomButton_ ;
vec2 mouseZoomInDirection_ ;
int mouseZoomMod_ ;
......@@ -346,7 +346,7 @@ class CGT_API Trackball : public Navigation {
KeyEvent::KeyCode keyZoomIn_ ;
KeyEvent::KeyCode keyZoomOut_ ;
int keyZoomMod_ ;
bool keyZoomPressed_ ; // FIXME: cannot remember, not in use
bool keyZoomPressed_ ;
MouseEvent::MouseButtons mouseRollButton_ ;
float mouseRollAcuteness_ ;
int mouseRollMod_ ;
......@@ -358,7 +358,7 @@ class CGT_API Trackball : public Navigation {
KeyEvent::KeyCode keyRollLeft_ ;
KeyEvent::KeyCode keyRollRight_ ;
int keyRollMod_ ;
bool keyRollPressed_ ; // FIXME: cannot remember, not in use
bool keyRollPressed_ ;
bool tracking_; ///< Are we tracking mouse move events? Only when we received a
///< mousePressEvent before.
......
......@@ -84,10 +84,6 @@ QtCanvas::QtCanvas(QWidget* parent, bool shared, Qt::WFlags f, char* /*name*/)
QtCanvas::~QtCanvas() {}
void QtCanvas::init() {
GLCanvas::init();
}
void QtCanvas::initializeGL() {
}
......@@ -273,7 +269,7 @@ KeyEvent::KeyCode QtCanvas::getKey(int key) {
case Qt::Key_Down : return cgt::KeyEvent::K_DOWN;
case Qt::Key_PageUp : return cgt::KeyEvent::K_PAGEUP;
case Qt::Key_PageDown : return cgt::KeyEvent::K_PAGEDOWN;
case Qt::Key_Shift : return cgt::KeyEvent::K_LSHIFT; //TODO: qt only knows one shift, control, meta and alt
case Qt::Key_Shift : return cgt::KeyEvent::K_LSHIFT; // Qt only knows one shift, control, meta and alt
case Qt::Key_Control : return cgt::KeyEvent::K_LCTRL;//...
case Qt::Key_Meta : return cgt::KeyEvent::K_RMETA;//...
case Qt::Key_Alt : return cgt::KeyEvent::K_LALT;//...
......
......@@ -70,9 +70,6 @@ public:
virtual ~QtCanvas();
/// initialize canvas
virtual void init();
/**
* Called by the Qt framework once at the beginning, before rendering starts.
* This function calls the corresponding GLCanvas method \a initialize.
......
......@@ -951,14 +951,7 @@ bool Shader::setUniform(const string& name, Vector2f* vectors, GLsizei count) {
GLint l = getUniformLocation(name);
if (l == -1)
return false;
//TODO: use the adress directly, without copying, same below. joerg
GLfloat* values = new GLfloat[2*count];
for (int i=0; i < count; i++){
values[2*i] = vectors[i].x;
values[2*i+1] = vectors[i].y;
}
glUniform2fv(l, count, values);
delete[] values;
glUniform2fv(l, count, vectors[0].elem);
return true;
}
......@@ -974,14 +967,7 @@ bool Shader::setUniform(const string& name, Vector3f* vectors, GLsizei count) {
GLint l = getUniformLocation(name);
if (l == -1)
return false;
GLfloat* values = new GLfloat[3*count];
for (int i=0; i < count; i++) {
values[3*i] = vectors[i].x;
values[3*i+1] = vectors[i].y;
values[3*i+2] = vectors[i].z;
}
glUniform3fv(l, count, values);
delete[] values;
glUniform3fv(l, count, vectors[0].elem);
return true;
}
......@@ -997,15 +983,7 @@ bool Shader::setUniform(const string& name, Vector4f* vectors, GLsizei count) {
GLint l = getUniformLocation(name);
if (l == -1)
return false;
GLfloat* values = new GLfloat[4*count];
for (int i=0; i < count; i++) {
values[4*i] = vectors[i].x;
values[4*i+1] = vectors[i].y;
values[4*i+2] = vectors[i].z;
values[4*i+3] = vectors[i].a;
}
glUniform4fv(l, count, values);
delete[] values;
glUniform4fv(l, count, vectors[0].elem);
return true;
}
......@@ -1021,13 +999,7 @@ bool Shader::setUniform(const string& name, ivec2* vectors, GLsizei count) {
GLint l = getUniformLocation(name);
if (l == -1)
return false;
GLint* values = new GLint[2*count];
for (int i=0; i < count; i++) {
values[2*i] = vectors[i].x;
values[2*i+1] = vectors[i].y;
}
glUniform2iv(l, count, values);
delete[] values;
glUniform2iv(l, count, vectors[0].elem);
return true;
}
......@@ -1043,14 +1015,7 @@ bool Shader::setUniform(const string& name, ivec3* vectors, GLsizei count) {
GLint l = getUniformLocation(name);
if (l == -1)
return false;
GLint* values = new GLint[3*count];
for (int i=0; i < count; i++) {
values[3*i] = vectors[i].x;
values[3*i+1] = vectors[i].y;
values[3*i+2] = vectors[i].z;
}
glUniform3iv(l, count, values);
delete[] values;
glUniform3iv(l, count, vectors[0].elem);
return true;
}
......@@ -1066,15 +1031,7 @@ bool Shader::setUniform(const string& name, ivec4* vectors, GLsizei count) {
GLint l = getUniformLocation(name);
if (l == -1)
return false;
GLint* values = new GLint[4*count];
for (int i=0; i < count; i++) {
values[4*i] = vectors[i].x;
values[4*i+1] = vectors[i].y;
values[4*i+2] = vectors[i].z;
values[4*i+3] = vectors[i].a;
}
glUniform4iv(l, count, values);
delete[] values;
glUniform4iv(l, count, vectors[0].elem);
return true;
}
......
......@@ -246,7 +246,6 @@ namespace campvis {
rd->addColorTexture(id);
// create fake depth image
// TODO: think of a better solution to this...
ImageData* idDepth = new ImageData(dimensionality, imageSize, 1);
float* ptr = new float[cgt::hmul(imageSize)];
memset(ptr, 0, cgt::hmul(imageSize) * sizeof(float));
......
......@@ -719,7 +719,6 @@ namespace campvis {
// Nifti transformations give us the center of the first voxel, we translate to correct:
// pToW = pToW * cgt::mat4::createTranslation(-spacing * 0.5f);
// TODO: implement arbitrary transformations into ImageMappingInformation
cgt::svec3 imageSize(dimensions);
if (numVolumes <= 1) {
......
......@@ -34,9 +34,8 @@
namespace campvis {
static const GenericOption<std::string> filterModes[2] = {
GenericOption<std::string>("median", "Median"),
GenericOption<std::string>("gauss", "Gauss"),
static const GenericOption<std::string> filterModes[1] = {
GenericOption<std::string>("median", "Median")
};
const std::string ImageFilter::loggerCat_ = "CAMPVis.modules.classification.ImageFilter";
......@@ -45,7 +44,7 @@ namespace campvis {
: AbstractProcessor()
, p_sourceImageID("InputVolume", "Input Volume ID", "volume", DataNameProperty::READ)
, p_targetImageID("OutputGradients", "Output Gradient Volume ID", "gradients", DataNameProperty::WRITE)
, p_filterMode("FilterMode", "Filter Mode", filterModes, 2)
, p_filterMode("FilterMode", "Filter Mode", filterModes, 1)
, p_kernelSize("KernelSize", "Kernel Size", 3, 3, 15)
, p_sigma("Sigma", "Sigma", 1.f, .1f, 10.f, 0.1f)
{
......@@ -72,11 +71,6 @@ namespace campvis {
tbb::blocked_range<size_t>(0, input->getNumElements()),
ImageFilterMedian(input, output, p_kernelSize.getValue()));
}
else if (p_filterMode.getOptionValue() == "gauss") {
tbb::parallel_for(
tbb::blocked_range<size_t>(0, input->getNumElements()),
ImageFilterGauss(input, output, p_kernelSize.getValue(), p_sigma.getValue()));
}
data.addData(p_targetImageID.getValue(), id);
}
......
......@@ -32,9 +32,12 @@
namespace campvis {
ImageFilterMedian::ImageFilterMedian(const ImageRepresentationLocal* input, ImageRepresentationLocal* output, size_t kernelSize)
: AbstractImageFilter(input, output)
: _input(input)
, _output(output)
, _kernelSize(kernelSize)
{
cgtAssert(input != 0, "Input image must not be 0.");
cgtAssert(output != 0, "Output image must not be 0.");
cgtAssert(kernelSize > 0, "Kernel Size must be greater 0.");
}
......@@ -67,81 +70,4 @@ namespace campvis {
}
}
// ================================================================================================
ImageFilterGauss::ImageFilterGauss(const ImageRepresentationLocal* input, ImageRepresentationLocal* output, size_t kernelSize, float sigma)
: AbstractImageFilter(input, output)
, _kernelSize(kernelSize)
, _halfKernelSize(kernelSize / 2)
, _sigma(sigma)
, _norm(0.f)
{
cgtAssert(kernelSize > 0, "Kernel Size must be greater 0.");
// compute Gauss kernel and corresponding norm
// it is sufficient to compute only one half of the 1D kernel
_kernel.resize(_halfKernelSize + 1, 0.f);
for (size_t i = 0; i <= _halfKernelSize; ++i) {
float f = static_cast<float>(i);
_kernel[i] = exp(-(f * f) / (2.f * _sigma * _sigma));
_norm += _kernel[i];
}
_norm = (2.f * _norm) - _kernel[0];
}
void ImageFilterGauss::operator()(const tbb::blocked_range<size_t>& range) const {
size_t halfKernelDim = static_cast<size_t>(_kernelSize / 2);
const cgt::svec3& size = _input->getSize();
for (size_t index = range.begin(); index < range.end(); ++index) {
cgt::svec3 position = _input->getParent()->indexToPosition(index);
cgt::svec3 npos = position;
float sum = 0.f;
// The gauss convolution filter is separable so it is sufficient to perform
// three 1D convolutions - one for each axis.
size_t zmin = position.z >= halfKernelDim ? position.z - halfKernelDim : 0;
size_t zmax = std::min(position.z+halfKernelDim, size.z-1);
for (npos.z = zmin; npos.z <= zmax; npos.z++) {
int i = abs(static_cast<int>(position.z) - static_cast<int>(npos.z));
sum += _input->getElementNormalized(npos, 0) * _kernel[i];
}
sum /= _norm;
_output->setElementNormalized(index, 0, sum);
npos.z = position.z;
sum = 0.f;
// FIXME: barrier sync needed!
size_t ymin = position.y >= halfKernelDim ? position.y - halfKernelDim : 0;
size_t ymax = std::min(position.y+halfKernelDim, size.y-1);
for (npos.y=ymin; npos.y<=ymax; npos.y++) {
int i = abs(static_cast<int>(position.y) - static_cast<int>(npos.y));
sum += _output->getElementNormalized(npos, 0) * _kernel[i];
}
sum /= _norm;
_output->setElementNormalized(index, 0, sum);
npos.y = position.y;
sum = 0.f;
// FIXME: barrier sync needed!
size_t xmin = position.x >= halfKernelDim ? position.x - halfKernelDim : 0;
size_t xmax = std::min(position.x+halfKernelDim, size.x-1);
for (npos.x=xmin; npos.x<=xmax; npos.x++) {
int i = abs(static_cast<int>(position.x) - static_cast<int>(npos.x));
sum += _output->getElementNormalized(npos, 0) * _kernel[i];
}
sum /= _norm;
_output->setElementNormalized(index, 0, sum);
}
}
}
......@@ -34,49 +34,18 @@
namespace campvis {
class ImageRepresentationLocal;
struct CAMPVIS_MODULES_API AbstractImageFilter {
AbstractImageFilter(const ImageRepresentationLocal* input, ImageRepresentationLocal* output)
: _input(input)
, _output(output)
{
cgtAssert(input != 0, "Input image must not be 0.");
cgtAssert(output != 0, "Output image must not be 0.");
}
virtual void operator() (const tbb::blocked_range<size_t>& range) const = 0;
protected:
const ImageRepresentationLocal* _input;
ImageRepresentationLocal* _output;
};
// ================================================================================================
struct CAMPVIS_MODULES_API ImageFilterMedian : public AbstractImageFilter {
struct CAMPVIS_MODULES_API ImageFilterMedian {
public:
ImageFilterMedian(const ImageRepresentationLocal* input, ImageRepresentationLocal* output, size_t kernelSize);
void operator() (const tbb::blocked_range<size_t>& range) const;
protected:
const ImageRepresentationLocal* _input;
ImageRepresentationLocal* _output;
size_t _kernelSize;
};
// ================================================================================================
struct CAMPVIS_MODULES_API ImageFilterGauss : public AbstractImageFilter {
public:
ImageFilterGauss(const ImageRepresentationLocal* input, ImageRepresentationLocal* output, size_t kernelSize, float sigma);
void operator() (const tbb::blocked_range<size_t>& range) const;
protected:
size_t _kernelSize;
size_t _halfKernelSize;
float _sigma;
std::vector<float> _kernel;
float _norm;
};
}
#endif // ABSTRACTIMAGEFILTER_H__
......@@ -67,7 +67,6 @@ uniform float _maxDepth; ///< Maximum depth of exit points
uniform float _kappaS; ///< k_s parameter from the paper
uniform float _kappaT; ///< l_t parameter from the paper
// TODO: copy+paste from Voreen - eliminate or improve.
const float SAMPLING_BASE_INTERVAL_RCP = 200.0;
/**
......
......@@ -52,7 +52,6 @@ uniform float _samplingStepSize;
uniform float _shift;
uniform float _scale;
// TODO: copy+paste from Voreen - eliminate or improve.
const float SAMPLING_BASE_INTERVAL_RCP = 200.0;
/**
......
......@@ -76,7 +76,6 @@ bool _inVoid = false;
uniform float _shadowIntensity;
#endif
// TODO: copy+paste from Voreen - eliminate or improve.
const float SAMPLING_BASE_INTERVAL_RCP = 200.0;
ivec3 voxelToBrick(in vec3 voxel) {
......
......@@ -65,7 +65,6 @@ uniform float _samplingStepSize;
uniform float _shadowIntensity;
#endif
// TODO: copy+paste from Voreen - eliminate or improve.
const float SAMPLING_BASE_INTERVAL_RCP = 200.0;
/**
......
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