Commit 945dc85e authored by Declara Denis's avatar Declara Denis Committed by Christian Schulte zu Berge

Added fan-geometry streaming support

* ConfidenceMapsDemo pipeline can now interpret voxel size as fan
  geometry. This is actually a quick quirk. The fan geometry is encoded in
  (x, y, z) as (fan-angle, inner-radius, 1.0f)
* Added support for the current cusp version on git
parent 80477cef
......@@ -2,7 +2,12 @@
#include "cudautils.h"
#include "cuspmonitors.h"
#ifndef GIT_CUSP_VERSION
#include <cusp/blas.h>
#else
#include <algorithm>
#include <cusp/blas/blas.h>
#endif
#include <cusp/dia_matrix.h>
#include <cusp/krylov/cg.h>
#include <cusp/precond/diagonal.h>
......
......@@ -13,10 +13,17 @@ namespace cuda {
* norm when the iteration count is reached.
*/
template <typename ValueType>
#ifndef GIT_CUSP_VERSION
class iteration_monitor : public cusp::default_monitor<ValueType>
{
typedef typename cusp::norm_type<ValueType>::type Real;
typedef cusp::default_monitor<ValueType> super;
#else
class iteration_monitor : public cusp::monitor<ValueType>
{
typedef typename cusp::detail::norm_type<ValueType>::type Real;
typedef cusp::monitor<ValueType> super;
#endif
public:
template <typename Vector>
......@@ -42,10 +49,17 @@ namespace cuda {
* This monitor allows to set a deadline, after which the computation has to stop.
*/
template <typename ValueType>
#ifndef GIT_CUSP_VERSION
class deadline_monitor : public cusp::default_monitor<ValueType>
{
typedef typename cusp::norm_type<ValueType>::type Real;
typedef cusp::default_monitor<ValueType> super;
#else
class deadline_monitor : public cusp::monitor<ValueType>
{
typedef typename cusp::detail::norm_type<ValueType>::type Real;
typedef cusp::monitor<ValueType> super;
#endif
public:
template <typename Vector>
......@@ -54,18 +68,24 @@ namespace cuda {
{ }
template <typename Vector>
bool finished(const Vector& r)
{
bool finished(const Vector& r) {
// Only if the deadline is reached, stop and compute the error
if ((tbb::tick_count::now() - _startTime).seconds() > _seconds) {
super::r_norm = cusp::blas::nrm2(r);
r_norm = cusp::blas::nrm2(r);
return true;
}
return false;
}
Real residual_norm(void) const {
return r_norm;
}
private:
Real r_norm;
tbb::tick_count _startTime;
float _seconds;
};
......
......@@ -60,8 +60,9 @@ namespace campvis {
, p_gradientScaling("GradientScaling", "Scaling factor for gradients", 2.0f, 0.001, 10)
, p_alpha("Alpha", "Alpha", 2.0f, 0.0f, 10.0f)
, p_gamma("Gamma", "Gamma", 0.03f, 0.0f, 0.4f, 0.001, 4)
, p_fanHalfAngle("FanHalfAngle", "Fan Half Angle", 37.0f, 1.0f, 90.0f)
, p_fanHalfAngle("FanHalfAngle", "Fan Half Angle", 28.0f, 1.0f, 90.0f)
, p_fanInnerRadius("FanInnerRadius", "Fan Inner Radius", 0.222f, 0.001f, 0.999f)
, p_useSpacingEncodedFanGeometry("UseSpacingEncodedFanGeomtry", "Use spacing encoded fan geometry", true)
, p_recordingDirectory("RecordingDirectory", "Recording output direcotry", "D:\\us_acquisitions\\")
, p_enableRecording("EnableRecording", "Enable recording", false)
, _recordedFrames(0)
......@@ -188,6 +189,17 @@ namespace campvis {
executeProcessorAndCheckOpenGLState(&_usMapsSolver);
auto solverEndTime = tbb::tick_count::now();
// Read fan geomtry from encoded image...
if (p_useSpacingEncodedFanGeometry.getValue()) {
ImageRepresentationGL::ScopedRepresentation img(*_data, _usCropFilter.p_inputImage.getValue());
auto image = reinterpret_cast<const ImageData*>(_data->getData(_usCropFilter.p_inputImage.getValue()).getData());
if (image != nullptr) {
cgt::vec3 encodedData = image->getMappingInformation().getVoxelSize();
p_fanHalfAngle.setValue(encodedData.x / 2.0f);
p_fanInnerRadius.setValue(encodedData.y);
}
}
executeProcessorAndCheckOpenGLState(&_usFusion);
executeProcessorAndCheckOpenGLState(&_usFanRenderer);
......
......@@ -97,6 +97,7 @@ namespace campvis {
FloatProperty p_gamma;
FloatProperty p_fanHalfAngle;
FloatProperty p_fanInnerRadius;
BoolProperty p_useSpacingEncodedFanGeometry; // Fan geometry is transmitted to campvis encoded in the x and y component of the voxel size (FOV in deg, innerRadius)
StringProperty p_recordingDirectory;
BoolProperty p_enableRecording;
......
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