Commit e956fe07 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents c0d80ec2 4be8ffe2
......@@ -25,6 +25,8 @@
#ifndef WMATRIX_H
#define WMATRIX_H
#include <iostream>
#include "WValue.h"
#include "WVector3D.h"
......@@ -314,4 +316,40 @@ template< typename T > WVector3D WMatrix< T >::operator*( const WVector3D& rhs )
}
} // End of namespace
template< typename T >
inline std::ostream& operator<<( std::ostream& os, const wmath::WMatrix< T >& m )
{
os << std::setprecision( 5 ) << std::fixed;
for( size_t i = 0; i < m.getNbRows(); ++i )
{
if( i == 0 )
{
os << "[ ";
}
else
{
os << " ";
}
for( size_t j = 0; j < m.getNbCols(); ++j )
{
os << std::setw( 12 ) << m( i, j );
if( j < m.getNbCols() - 1 )
{
os << ", ";
}
else if( i < m.getNbRows() - 1 )
{
os << " ";
}
else
{
os << " ]";
}
}
os << std::endl;
}
return os;
}
#endif // WMATRIX_H
......@@ -464,6 +464,12 @@ void WGridRegular3D::initInformationProperties()
WPropDouble xOffset = m_infoProperties->addProperty( "X offset: ", "The distance between samples in x direction", getOffsetX() );
WPropDouble yOffset = m_infoProperties->addProperty( "Y offset: ", "The distance between samples in y direction", getOffsetY() );
WPropDouble zOffset = m_infoProperties->addProperty( "Z offset: ", "The distance between samples in z direction", getOffsetZ() );
std::stringstream ss1;
ss1 << m_matrixQForm;
WPropString qForm = m_infoProperties->addProperty( "qForm-Matrix: ", "The qForm matrix in row major", ss1.str() );
std::stringstream ss2;
ss2 << m_matrixQForm;
WPropString sForm = m_infoProperties->addProperty( "sForm-Matrix: ", "The sForm matrix in row major", ss2.str() );
}
int WGridRegular3D::getXVoxelCoord( const wmath::WPosition& pos ) const
......
......@@ -697,5 +697,4 @@ inline wmath::WPosition WGridRegular3D::getOrigin() const
{
return m_origin;
}
#endif // WGRIDREGULAR3D_H
......@@ -53,6 +53,8 @@ WPropertyStringWidget::WPropertyStringWidget( WPropString property, QGridLayout*
// To have word warp work correctly -> set size policy
m_asText.setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) );
m_asText.setTextInteractionFlags( Qt::TextSelectableByMouse );
// set the initial values
update();
......
......@@ -92,6 +92,9 @@ void WMFiberTransform::properties()
m_matrix2Prop = m_properties->addProperty( "M Row 2",
"Row 2 of matrix part of the transformation. You need to press enter to make the values effective.",
wmath::WPosition( 0.0, 0.0, 1.0 ) );
m_matrix3Prop = m_properties->addProperty( "M Row 3",
"Row 3 of matrix part of the transformation. You need to press enter to make the values effective.",
wmath::WPosition( 0.0, 0.0, 0.0 ) );
WModule::properties();
}
......@@ -145,18 +148,26 @@ void WMFiberTransform::update()
boost::filesystem::path savePath = m_savePath->get();
// set the transformation matrix
wmath::WMatrix< double > transformationMatrix( 3, 3 ); //!< matrix which is multiplied with each point to linear transform it.
wmath::WMatrix< double > transformationMatrix( 4, 4 ); //!< matrix which is multiplied with each point to linear transform it.
transformationMatrix( 0, 0 ) = m_matrix0Prop->get()[0];
transformationMatrix( 0, 1 ) = m_matrix0Prop->get()[1];
transformationMatrix( 0, 2 ) = m_matrix0Prop->get()[2];
transformationMatrix( 0, 3 ) = m_translationProp->get()[0];
transformationMatrix( 1, 0 ) = m_matrix1Prop->get()[0];
transformationMatrix( 1, 1 ) = m_matrix1Prop->get()[1];
transformationMatrix( 1, 2 ) = m_matrix1Prop->get()[2];
transformationMatrix( 1, 3 ) = m_translationProp->get()[1];
transformationMatrix( 2, 0 ) = m_matrix2Prop->get()[0];
transformationMatrix( 2, 1 ) = m_matrix2Prop->get()[1];
transformationMatrix( 2, 2 ) = m_matrix2Prop->get()[2];
transformationMatrix( 2, 3 ) = m_translationProp->get()[2];
transformationMatrix( 3, 0 ) = m_matrix3Prop->get()[0];
transformationMatrix( 3, 1 ) = m_matrix3Prop->get()[1];
transformationMatrix( 3, 2 ) = m_matrix3Prop->get()[2];
transformationMatrix( 3, 3 ) = 1.0;
boost::shared_ptr< WProgress > progress( new WProgress( "Transforming", 4 + save ) );
m_progress->addSubProgress( progress );
......@@ -167,12 +178,20 @@ void WMFiberTransform::update()
++*progress;
//transform
wmath::WValue< double > vec( 4 );
wmath::WValue< double > vec_transformed( 4 );
for( std::size_t fiberID = 0; fiberID < dataset->size(); ++fiberID )
{
WFiber& fiber = (*dataset)[fiberID];
for( std::size_t positionID = 0; positionID < fiber.size(); ++positionID )
{
fiber[positionID] = transformationMatrix * fiber[positionID] + m_translationProp->get();
vec[0] = fiber[positionID][0];
vec[1] = fiber[positionID][1];
vec[2] = fiber[positionID][2];
vec[3] = 1.0;
vec_transformed = transformationMatrix * vec;
vec_transformed = ( 1.0 / vec_transformed[3] ) * vec_transformed;
fiber[positionID] = wmath::WPosition( vec_transformed[0], vec_transformed[1], vec_transformed[2] );
}
}
++*progress;
......
......@@ -104,6 +104,7 @@ private:
WPropPosition m_matrix0Prop; //!< Row 0 of matrix part of the transformation.
WPropPosition m_matrix1Prop; //!< Row 1 of matrix part of the transformation.
WPropPosition m_matrix2Prop; //!< Row 2 of matrix part of the transformation.
WPropPosition m_matrix3Prop; //!< Row 3 of matrix part of the transformation.
/**
* ReTransforms the scene.
......
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