Commit 648a548c authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[MERGE]

parents bd6c7297 48393d3b
......@@ -3,17 +3,18 @@
<br>
<br>
Hello User! New to OpenWalnut? Have a look at <a href="http://www.openwalnut.org">http://www.openwalnut.org</a>!
<br>
We provide
<ul>
<li> <a href="http://www.openwalnut.org/projects/openwalnut/wiki/FirstSteps">first steps tutorial</a>,
<li> user documentation,
<li> programming tutorials
<li> <a href="http://www.openwalnut.org/projects/openwalnut/wiki/FirstSteps">a first steps tutorial</a>,
<li> a user documentation,
<li> programming tutorials,
<li> and the latest information on OpenWalnut.
</ul>
Do you have problems using OpenWalnut? Do not hesitate to ask:
<ul>
<li><a href="mailto:openwalnut@lists.informatik.uni-leipzig.de">Mailing list</a>
<li>IRC Chat on irc.freenode.net in #ow
<li>IRC Chat on irc.freenode.net, channel #ow
</ul>
Found a bug? Do you have ideas for improvements? Please <a href="http://www.openwalnut.org/projects/openwalnut/wiki/Contribute">report</a> these issues! We can improve OpenWalnut only with your help and ideas.
<br><br>
......
......@@ -44,7 +44,7 @@ COLLECT_COMPILE_FILES( "${CMAKE_CURRENT_SOURCE_DIR}" TARGET_CPP_FILES TARGET_H_F
# Setup the target
ADD_LIBRARY( ${LibName} SHARED ${TARGET_CPP_FILES} ${TARGET_H_FILES} ${OW_VERSION_HEADER} )
TARGET_LINK_LIBRARIES( ${LibName} ${Boost_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES}
TARGET_LINK_LIBRARIES( ${LibName} ${Boost_LIBRARIES} ${CMAKE_STANDARD_LIBRARIES} ${CMAKE_DL_LIBS} ${OPENGL_gl_LIBRARY} ${OPENSCENEGRAPH_LIBRARIES}
)
# Tell CMake that someone creates this file for us. See doc of SETUP_VERSION_HEADER for details why this is needed.
......
......@@ -30,132 +30,23 @@
#include "WColor.h"
/**
* A cass that stores a 1D transfer function which consits
* of a linear interpolation of alpha and color values
* A class that stores a 1D transfer function which consists
* of a linear interpolation of alpha and color values.
*/
class WTransferFunction // NOLINT problem with macro
{
private:
/**
* Prototype for a storage element
*/
struct Entry
{
/**
* Default constructor
* \param iso the iso value
*/
explicit Entry( double iso ) : iso( iso )
{
}
/**
* comparison by isovalue
* \param rhs entry to compare t
* \returns true if this->iso <= rhs.iso
*/
bool operator <= ( const Entry &rhs ) const
{
return iso <= rhs.iso;
}
/** the isovalue */
double iso;
};
/**
* Color entries are linearly interpolated colors along isovalues
*/
struct ColorEntry : public Entry
{
/** default constructor
* \param iso the isovalue
* \param color the color at the isovalue
*/
ColorEntry( double iso, WColor color ) : Entry( iso ), color( color )
{
}
/**
* comparison operator to check for changes
* \param rhs ColorEntry to compare to
* \returns true if rhs equals this
*/
bool operator==( const ColorEntry& rhs ) const
{
return iso == rhs.iso && color == rhs.color;
}
/** holds the current color at isovalue Entry::iso */
WColor color;
};
/**
* Alpha entries represent linearly interpolated transparency values
* along the isovalue scale. Alpha is in the range [ 0...1 ] where
* 1 signifies entirely opaque ( which makes it more an opacity value instead
* of alpha, but I use the commonly used language here )
*/
struct AlphaEntry : public Entry
{
/** default constructor
* \param iso the isovalue
* \param alpha the alpha at the isovalue in the range from 0 = transparent to 1 = opaque
*/
AlphaEntry( double iso, double alpha ) : Entry( iso ), alpha( alpha )
{
}
/**
* comparison operator to check for changes
* \param rhs AlphaEntry to compare to
* \returns true if rhs is equal to this
*/
bool operator==( const AlphaEntry& rhs ) const
{
return iso == rhs.iso && alpha == rhs.alpha;
}
/** holds the current alpha at isovalue Entry::iso */
double alpha;
};
public:
/**
* Templatized comparison predicate for internal searching
* Default constructor of a meaningless transfer function
*/
template<typename T>
struct LessPred
{
/** constructs a predicate that compares for less than iso
* \param iso: used iso value
*/
explicit LessPred( double iso ) : iso( iso )
{
}
/** isovalue-based comparison
* \param t the object to compare to
* \returns true if iso is less than t.iso
*/
bool operator()( const T& t )
{
return iso < t.iso;
}
/** the isovalue to compare to */
double iso;
};
public:
/** default constructor of a meaningless transfer function */
WTransferFunction() : isomin( 0. ), isomax( 0. )
{
}
/** deep copy constructor
/**
* Deep copy constructor.
*
* \param rhs the value to histogram
*/
WTransferFunction( const WTransferFunction &rhs )
......@@ -163,7 +54,9 @@ public:
{
}
/** deep copy operator
/**
* Deep copy operator
*
* \param rhs the value to copy
* \returns reference to current object
* \returns reference to current object
......@@ -179,6 +72,8 @@ public:
}
/**
* Check equivalence of two transfer functions.
*
* \returns true if this object contains exactly the same
* data as rhs
* \param rhs object to compare with
......@@ -186,17 +81,23 @@ public:
bool operator==( const WTransferFunction &rhs ) const;
/**
* Check equivalence of two transfer functions.
*
* \returns negated result of operator==
* \param rhs the value to compare with
*/
bool operator!=( const WTransferFunction &rhs ) const;
/** default destuctor */
/**
* Default destuctor.
*/
~WTransferFunction()
{
}
/**
* Get the number of alphas
*
* \returns the number of alpha points
*/
size_t numAlphas() const
......@@ -205,6 +106,8 @@ public:
}
/**
* Get the number of colors.
*
* \returns the number of color points
*/
size_t numColors() const
......@@ -213,6 +116,8 @@ public:
}
/**
* Get the isovalue at a given index in the alpha values.
*
* \param i the index of the point to query
* \returns the alpha values position/isovalue at index i
*/
......@@ -221,9 +126,10 @@ public:
return alphas.at( i ).iso;
}
/**
* \param i the index of the point to query
* The isovalue of the color at a given index.
*
* \param i the index of the point to query.
* \returns the color values position/isovalue at index i
*/
double getColorIsovalue( size_t i ) const
......@@ -232,6 +138,8 @@ public:
}
/**
* Get alpha at given index.
*
* \param i the index to query
* \returns the alpha value at index i
*/
......@@ -241,6 +149,8 @@ public:
}
/**
* Get color at given index.
*
* \param i the index to query
* \returns the color at index i
*/
......@@ -250,21 +160,23 @@ public:
}
/**
* insert a new color point
* Insert a new color point.
*
* \param iso the new iso value
* \param color the new color at the given iso value
*/
void addColor( double iso, const WColor& color );
/**
* insert a new alpha point
* Insert a new alpha point.
*
* \param iso the new iso value
* \param alpha the new alpha value at the given iso value
*/
void addAlpha( double iso, double alpha );
/**
* set the histogram going along with the transfer function
* Set the histogram going along with the transfer function
*
* This should be changed in the future to be handled in a different
* way. A good option would be to introduce an object encapsulating
......@@ -278,7 +190,7 @@ public:
}
/**
* clears the histogram data so the gui won't show any
* Clears the histogram data so the gui won't show any
*/
void removeHistogram()
{
......@@ -286,7 +198,8 @@ public:
}
/**
* returns the histogram
* Returns the histogram.
*
* \returns a reference to the internal representation of the histogram
*/
const std::vector< double >& getHistogram() const
......@@ -307,24 +220,145 @@ public:
/**
* Try to estimate a transfer function from an RGBA image.
*
* \param rgba: values between 0 and 255 representing the red, green, and blue channel
* \param size: number of color entries in rgba
* \returns approximated transfer function
*/
static WTransferFunction createFromRGBA( unsigned char const * const rgba, size_t size );
private:
/** sorted list of colors */
/**
* Prototype for a storage element
*/
struct Entry
{
/**
* Default constructor
* \param iso the iso value
*/
explicit Entry( double iso ) : iso( iso )
{
}
/**
* comparison by isovalue
* \param rhs entry to compare t
* \returns true if this->iso <= rhs.iso
*/
bool operator <= ( const Entry &rhs ) const
{
return iso <= rhs.iso;
}
/** the isovalue */
double iso;
};
/**
* Color entries are linearly interpolated colors along isovalues
*/
struct ColorEntry : public Entry
{
/** default constructor
* \param iso the isovalue
* \param color the color at the isovalue
*/
ColorEntry( double iso, WColor color ) : Entry( iso ), color( color )
{
}
/**
* comparison operator to check for changes
* \param rhs ColorEntry to compare to
* \returns true if rhs equals this
*/
bool operator==( const ColorEntry& rhs ) const
{
return iso == rhs.iso && color == rhs.color;
}
/** holds the current color at isovalue Entry::iso */
WColor color;
};
/**
* Alpha entries represent linearly interpolated transparency values
* along the isovalue scale. Alpha is in the range [ 0...1 ] where
* 1 signifies entirely opaque ( which makes it more an opacity value instead
* of alpha, but I use the commonly used language here )
*/
struct AlphaEntry : public Entry
{
/** default constructor
* \param iso the isovalue
* \param alpha the alpha at the isovalue in the range from 0 = transparent to 1 = opaque
*/
AlphaEntry( double iso, double alpha ) : Entry( iso ), alpha( alpha )
{
}
/**
* comparison operator to check for changes
* \param rhs AlphaEntry to compare to
* \returns true if rhs is equal to this
*/
bool operator==( const AlphaEntry& rhs ) const
{
return iso == rhs.iso && alpha == rhs.alpha;
}
/** holds the current alpha at isovalue Entry::iso */
double alpha;
};
/**
* Templatized comparison predicate for internal searching
*/
template<typename T>
struct LessPred
{
/** constructs a predicate that compares for less than iso
* \param iso: used iso value
*/
explicit LessPred( double iso ) : iso( iso )
{
}
/** isovalue-based comparison
* \param t the object to compare to
* \returns true if iso is less than t.iso
*/
bool operator()( const T& t )
{
return iso < t.iso;
}
/** the isovalue to compare to */
double iso;
};
/**
* Sorted list of colors
*/
std::vector<ColorEntry> colors;
/** sorted list of alpha values */
/**
* Sorted list of alpha values.
*/
std::vector<AlphaEntry> alphas;
/** the smallest used iso value */
/**
* The smallest used iso value.
*/
double isomin;
/** the largest used iso value */
/**
* The largest used iso value.
*/
double isomax;
/** stores a histogram. This is used for property-handling only
/**
* Sores a histogram. This is used for property-handling only
* and does not change the transfer function at all.
*/
std::vector< double > histogram;
......@@ -334,9 +368,11 @@ private:
/**
* Default output operator. Currently stores values the same way as it is done in the properties.
* This code should only be used for debugging and you should not realy on the interface.
* This code should only be used for debugging and you should not rely on the interface.
*
* \param tf The transfer function to output
* \param out The stream to which we write
*
* \returns reference to out
*/
std::ostream& operator << ( std::ostream& out, const WTransferFunction& tf );
......
......@@ -63,6 +63,8 @@ class WMatrixFixedTest;
* A data store with the specified dimensions and type. The possibilities are endless. This way, you can optimize data storage for certain kinds
* of matrices, like sparse or symmetric ones. It even allows the definition of a whole data block containing many matrices.
*
* \note storage is done row-major
*
* \tparam ValueT the integral type
* \tparam Rows the number of rows
* \tparam Cols the number of cols
......@@ -1178,7 +1180,7 @@ typedef WMatrixFixed< float, 4, 4 > WMatrix4f;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
* Cale the given matrix by the value. This is needed for having * to be commutative. For more details, see \ref WMatrixFixed::operator*.
* Scale the given matrix by the value. This is needed for having * to be commutative. For more details, see \ref WMatrixFixed::operator*.
*
* \tparam ScalarT Integral type of scaler
* \tparam MatrixValueT Value type of matrix
......
......@@ -68,7 +68,11 @@ class WGridRegular3DTemplate : public WGrid // NOLINT
*/
friend class WGridRegular3DTest;
public:
/**
* Convenience typedef for 3d vectors of the appropriate numerical type.
*/
typedef WMatrixFixed< T, 3, 1 > Vector3Type;
/**
* Convenience typedef for a boost::shared_ptr< WGridRegular3DTemplate >.
*/
......@@ -87,6 +91,8 @@ public:
/**
* Copy constructor.
* Copies the data from an WGridRegular3DTemplate object with arbitary numerical type.
*
* \param rhs A WGridRegular3DTemplate object, which mustn't have the same numerical type.
*/
template< typename InputType >
WGridRegular3DTemplate( WGridRegular3DTemplate< InputType > const& rhs ); // NOLINT -- no explicit, this allows casts
......@@ -660,7 +666,7 @@ inline typename WGridRegular3DTemplate< T >::Vector3Type WGridRegular3DTemplate<
}
template< typename T >
inline int WGridRegular3DTemplate< T >::getVoxelNum( const WGridRegular3DTemplate< T >::Vector3Type& pos ) const
inline int WGridRegular3DTemplate< T >::getVoxelNum( const Vector3Type& pos ) const
{
// Note: the reason for the +1 is that the first and last Voxel in a x-axis
// row are cut.
......@@ -758,7 +764,7 @@ inline size_t WGridRegular3DTemplate< T >::getCellId( const WGridRegular3DTempla
template< typename T >
inline typename WGridRegular3DTemplate< T >::CellVertexArray WGridRegular3DTemplate< T >::getCellVertexIds( size_t cellId ) const
{
WGridRegular3DTemplate< T >::CellVertexArray vertices;
typename WGridRegular3DTemplate< T >::CellVertexArray vertices;
size_t minVertexIdZ = cellId / ( ( m_nbPosX - 1 ) * ( m_nbPosY - 1 ) );
size_t remainderXY = cellId - minVertexIdZ * ( ( m_nbPosX - 1 ) * ( m_nbPosY - 1 ) );
size_t minVertexIdY = remainderXY / ( m_nbPosX - 1 );
......
......@@ -34,7 +34,7 @@
/**
* Implements an orthogonal grid transformation.
*
* \class WGridTransformOrtho
* \class WGridTransformOrthoTemplate
*/
template< typename T >
class WGridTransformOrthoTemplate
......@@ -43,7 +43,11 @@ class WGridTransformOrthoTemplate
template <class U>
friend class WGridTransformOrthoTemplate;
public:
/**
* Convenience typedef for 3d vectors of the appropriate numerical type.
*/
typedef WMatrixFixed< T, 3, 1 > Vector3Type;
/**
* Constructs an identity transform.
*/
......@@ -52,6 +56,8 @@ public:
/**
* Copy constructor.
* Copies the data from an WGridTransformOrthoTemplate object with arbitary numerical type.
*
* \param rhs A WGridTransformOrthoTemplate object, which mustn't have the same numerical type.
*/
template< typename InputType >
WGridTransformOrthoTemplate( WGridTransformOrthoTemplate< InputType > const& rhs ); // NOLINT -- no explicit, this allows casts
......@@ -81,6 +87,10 @@ public:
/**
* Assignment operator.
* Copies the data from an WGridTransformOrthoTemplate object with arbitary numerical type.
*
* \param rhs A WGridTransformOrthoTemplate object, which mustn't have the same numerical type.
*
* \return this
*/
template< typename InputType >
WGridTransformOrthoTemplate< T >& operator=( WGridTransformOrthoTemplate< InputType > const& rhs );
......@@ -223,6 +233,11 @@ public:
void scale( VecType const& scale );
private:
/**
* This is a helper function which copies the parameter of another instance to its own.
*
* \param input A WGridTransformOrthoTemplate object with the numerical type InputType.
*/
template< typename InputType >
void copyFrom( WGridTransformOrthoTemplate< InputType > const& input );
......@@ -259,11 +274,7 @@ template< typename T >
template< typename InputType >
WGridTransformOrthoTemplate< T >::WGridTransformOrthoTemplate( WGridTransformOrthoTemplate< InputType > const& rhs )
{
this->m_unitDirectionX = static_cast< Vector3Type >( rhs.m_unitDirectionX );
this->m_unitDirectionY = static_cast< Vector3Type >( rhs.m_unitDirectionY );
this->m_unitDirectionZ = static_cast< Vector3Type >( rhs.m_unitDirectionZ );
this->m_scaling = static_cast< Vector3Type >( rhs.m_scaling );
this->m_origin = static_cast< Vector3Type >( rhs.m_origin );
copyFrom( rhs );
}
template< typename T >
......
......@@ -39,15 +39,46 @@
* \param color this color gets mixed using alpha value with the new colormap color
* \param sampler the texture sampler to use
* \param coord the coordinate where to get the value
* \param size the size in voxels
* \param minV the minimum of the original value
* \param scaleV the scaler used to downscale the original value to [0-1]
* \param thresholdV a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param alpha the alpha blending value
* \param cmap the colormap index to use
*/
void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, float minV, float scaleV, float thresholdV, bool thresholdEnabled, float alpha,
void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, in vec3 size, float minV, float scaleV, float thresholdV, bool thresholdEnabled, float alpha,
int cmap, bool active )
{
// This implements a manual trilinear interpolation. Include WGETextureutils.glsl to use this
// vec3 vSize = vec3( 1.0 / float( size.x ),
// 1.0 / float( size.y ),
// 1.0 / float( size.z ) );
//
// vec3 discreteCoord = getDiscreteVoxelCoordinate( vSize, coord );
// vec3 voxelSpace = coord / vSize;
// vec3 coordDiff = voxelSpace - vec3( floor( voxelSpace.x ), floor( voxelSpace.y ), floor( voxelSpace.z ) );
//
// vec3 c000 = getNeighbourVoxel( vSize, coord, vec3( 0.0, 0.0, 0.0 ) );
// vec3 c010 = getNeighbourVoxel( vSize, coord, vec3( 0.0, 1.0, 0.0 ) );
// vec3 c001 = getNeighbourVoxel( vSize, coord, vec3( 0.0, 0.0, 1.0 ) );
// vec3 c011 = getNeighbourVoxel( vSize, coord, vec3( 0.0, 1.0, 1.0 ) );
// vec3 c100 = getNeighbourVoxel( vSize, coord, vec3( 1.0, 0.0, 0.0 ) );
// vec3 c110 = getNeighbourVoxel( vSize, coord, vec3( 1.0, 1.0, 0.0 ) );
// vec3 c101 = getNeighbourVoxel( vSize, coord, vec3( 1.0, 0.0, 1.0 ) );
// vec3 c111 = getNeighbourVoxel( vSize, coord, vec3( 1.0, 1.0, 1.0 ) );
//
// vec4 v00 = mix( colormap( texture3D( sampler, c000 ).rgba, minV, scaleV, thresholdV, thresholdEnabled, alpha, cmap, active ),
// colormap( texture3D( sampler, c100 ).rgba, minV, scaleV, thresholdV, thresholdEnabled, alpha, cmap, active ), coordDiff.x );