Commit d8937c0f by Mathias Goldau

[FIX] Make LIC now working...

parent 1ffe7913
......@@ -24,13 +24,13 @@
#include <string>
#include "exceptions/WDHException.h"
#include "WDataTexture3D.h"
#include "../common/WAssert.h"
#include "../common/WTransferable.h"
#include "../common/WCondition.h"
#include "../common/WTransferable.h"
#include "exceptions/WDHException.h"
#include "WDataSet.h"
#include "WDataSetVector.h"
#include "WDataTexture3D.h"
// prototype instance as singleton
boost::shared_ptr< WPrototyped > WDataSet::m_prototype = boost::shared_ptr< WPrototyped >();
......@@ -94,3 +94,7 @@ boost::shared_ptr< WCondition > WDataSet::getChangeCondition()
return boost::shared_ptr< WCondition >();
}
boost::shared_ptr< WDataSetVector > WDataSet::isVectorDataSet()
{
return boost::shared_ptr< WDataSetVector >();
}
......@@ -27,11 +27,13 @@
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include "../common/WTransferable.h"
class WDataTexture3D;
class WCondition;
class WDataSetVector;
/**
* Base class for all data set types. This class has a number of subclasses
......@@ -40,7 +42,7 @@ class WCondition;
* steps) respectively.
* \ingroup dataHandler
*/
class WDataSet: public WTransferable
class WDataSet: public WTransferable, public boost::enable_shared_from_this< WDataSet >
{
public:
/**
......@@ -76,6 +78,8 @@ public:
// TODO(schurade): pure virtual? Are WDataSet instances useful?
virtual bool isTexture() const;
virtual boost::shared_ptr< WDataSetVector > isVectorDataSet();
/**
* Returns the texture- representation of the dataset. May throw an exception if no texture is available.
*
......
......@@ -81,6 +81,8 @@ public:
*/
wmath::WVector3D getVectorAt( size_t index ) const;
boost::shared_ptr< WDataSetVector > isVectorDataSet();
protected:
/**
......@@ -91,4 +93,9 @@ protected:
private:
};
inline boost::shared_ptr< WDataSetVector > WDataSetVector::isVectorDataSet()
{
return boost::shared_static_cast< WDataSetVector >( shared_from_this() );
}
#endif // WDATASETVECTOR_H
......@@ -27,6 +27,10 @@
#include <osg/LightModel>
#include "../../common/WSharedSequenceContainer.h"
#include "../../dataHandler/exceptions/WDHNoSuchSubject.h"
#include "../../dataHandler/WDataHandler.h"
#include "../../dataHandler/WSubject.h"
#include "../../graphicsEngine/WGEUtils.h"
#include "../../kernel/WKernel.h"
#include "fibernavigator/SurfaceLIC.h"
......@@ -65,10 +69,17 @@ void WMLIC::connectors()
new WModuleInputData< WTriangleMesh2 >( shared_from_this(),
"inMesh", "The triangle mesh used for painting the LIC" )
);
// TODO(math): reenable the connector when selecting of two input in GUI is possible.
// The reason for disabling is just that you can choose the lic on a surface without project files due to its two inputs
// Alternatively the vector dataset is choosen from first subject dataset containing evec in its file name, see moduleMain
// for more informations.
//
m_vectorIC = boost::shared_ptr< WModuleInputData < WDataSetVector > >(
new WModuleInputData< WDataSetVector >( shared_from_this(),
"inVectorDS", "The vectors used for computing the Streamlines used for the LIC" )
);
// TODO(math): ATM we are unsure about providing an output. Caution the input mesh is modified!
// m_meshOC = boost::shared_ptr< WModuleOutputData < WTriangleMesh2 > >(
// new WModuleOutputData< WTriangleMesh2 >( shared_from_this(),
// "outMesh", "The LIC" )
......@@ -159,15 +170,20 @@ void WMLIC::moduleMain()
}
boost::shared_ptr< WTriangleMesh2 > newMesh = m_meshIC->getData();
// TODO(math): if the vector input is available again please enable this again too
boost::shared_ptr< WDataSetVector > newVector = m_vectorIC->getData();
bool dataChanged = ( m_inMesh != newMesh ) || ( m_inVector != newVector );
bool dataValid = ( newMesh.get() && newVector.get() );
// bool dataChanged = ( m_inMesh != newMesh );
// bool dataValid = newMesh.get();
if ( dataChanged && dataValid )
{
debugLog() << "Received Data.";
m_inMesh = newMesh;
m_inVector = newVector;
// m_inVector = searchVectorDS();
m_inMesh->doLoopSubD();
m_inMesh->doLoopSubD();
SurfaceLIC lic( m_inVector, m_inMesh );
......@@ -178,3 +194,56 @@ void WMLIC::moduleMain()
}
}
}
boost::shared_ptr< WDataSetVector > WMLIC::searchVectorDS() const
{
boost::shared_ptr< WDataSetVector > result;
boost::shared_ptr< WSubject > subject;
try
{
subject = WDataHandler::getDefaultSubject();
}
catch( WDHNoSuchSubject )
{
return result;
}
if( !subject )
{
return result;
}
WSubject::DatasetAccess da = subject->getAccessObject();
da->beginRead();
for( std::vector< boost::shared_ptr< WDataSet > >::iterator it = da->get().begin(); it != da->get().end(); ++it )
{
if( ( *it )->isTexture() )
{
da->endRead();
// dataSetAccess->beginWrite();
// dataSetAccess->get().insert( dataSetAccess->get().begin(), *it );
// dataSetAccess->endWrite();
da->beginRead();
}
}
da->endRead();
return result;
}
void WMLIC::activate()
{
if( m_moduleNode )
{
if ( m_active->get() )
{
m_moduleNode->setNodeMask( 0xFFFFFFFF );
}
else
{
m_moduleNode->setNodeMask( 0x0 );
}
}
WModule::activate();
}
......@@ -97,13 +97,22 @@ protected:
*/
void renderMesh( boost::shared_ptr< WTriangleMesh2 > mesh );
void activate();
private:
/**
* Searches for the first dataset in subject 0 containing the phrase "evec" in its filename and check if its a vector dataset.
*
* \return reference to the vector dataset
*/
boost::shared_ptr< WDataSetVector > searchVectorDS() const;
boost::shared_ptr< WModuleInputData< WTriangleMesh2 > > m_meshIC; //!< The InputConnector for the mesh on which to paint
boost::shared_ptr< WModuleInputData< WDataSetVector > > m_vectorIC; //!< The InputConnector for the vectors that are used to build the streamlines
boost::shared_ptr< WTriangleMesh2 > m_inMesh; //!< The mesh given from the input connector
boost::shared_ptr< WDataSetVector > m_inVector; //!< The vector field used to compute the LIC given from the input connector
// boost::shared_ptr< WModuleOutputData< WTriangleMesh2 > > m_meshOC; //!< OutputConnector for the LIC'ed mesh
// boost::shared_ptr< WModuleOutputData< WTriangleMesh2 > > m_meshOC; //!< OutputConnector for the LIC'ed mesh
osg::ref_ptr< WGEGroupNode > m_moduleNode; //!< Pointer to the modules group node.
osg::ref_ptr< osg::Geode > m_surfaceGeode; //!< Pointer to geode containing the surface.
......
......@@ -68,6 +68,7 @@ FStreamlineOnSurfaceEuler::FStreamlineOnSurfaceEuler( boost::shared_ptr< WDataSe
Vector center( m_mesh->getTriangleCenter(i) );
FTensor t = m_tensorField->getInterpolatedVector(center.x, center.y, center.z);
// std::cout << "interpolat: " << t << std::endl;
cell_vectors[i] = FArray(t).normalize();
}
// m_dh->printDebug(_T("done"), 1);
......
......@@ -52,8 +52,7 @@ FTensor TensorField::getInterpolatedVector(float x, float y, float z)
WAssert( grid->encloses( pos ), "Grid does not enclose position to interpolate" );
std::vector< size_t > vertexIds = grid->getCellVertexIds( grid->getCellId( pos ) );
wmath::WPosition localPos = pos - grid->getPosition( vertexIds[0] );
// wmath::WPosition localPos = pos - grid->getPosition( vertexIds[0] );
// double xMult = localPos[0] / grid->getOffsetX();
// double yMult = localPos[1] / grid->getOffsetY();
// double zMult = localPos[2] / grid->getOffsetZ();
......@@ -70,6 +69,16 @@ FTensor TensorField::getInterpolatedVector(float x, float y, float z)
FTensor txy1z1 = FTensor( m_vectors->getVectorAt( vertexIds[6] ) );
FTensor tx1y1z1 = FTensor( m_vectors->getVectorAt( vertexIds[7] ) );
// std::cout << pos << "::" << grid->getCellId( pos ) << " ";
// std::cout << txyz << "::" << vertexIds[0] << " ";
// std::cout << tx1yz << "::" << vertexIds[1] << " ";
// std::cout << txy1z << "::" << vertexIds[2] << " ";
// std::cout << tx1y1z << "::" << vertexIds[3] << " ";
// std::cout << txyz1 << "::" << vertexIds[4] << " ";
// std::cout << tx1yz1 << "::" << vertexIds[5] << " ";
// std::cout << txy1z1 << "::" << vertexIds[6] << " ";
// std::cout << tx1y1z1 << "::" << vertexIds[7] << std::endl;
FMatrix matxyz = createMatrix(txyz, txyz);
FMatrix matx1yz = createMatrix(tx1yz, tx1yz);
FMatrix matxy1z = createMatrix(txy1z, txy1z);
......
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