Commit 778afee4 authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[CHANGE] Removed std::pair of WVector3D as bounding box replacement. Now WBoundingBox is used...

parent 7ccd5d2d
......@@ -113,11 +113,11 @@ public:
using osg::BoundingBoxImpl< VT >::corner;
/**
* Converts this bounding box to the osg::BoundingBoxImpl< VT >.
* Explicit type conversion function to use a WBoundingBox as osg::BoundingBox.
*
* \return Copy of this casted to the osg::BoundingBoxImpl< VT > type
* \return A copy of this bounding box as osg::BoundingBox.
*/
osg::BoundingBoxImpl< VT > toOSGBB() const;
osg::BoundingBox toOSGBB() const;
using osg::BoundingBoxImpl< VT >::expandBy;
......@@ -202,9 +202,9 @@ inline typename WBoundingBoxImpl< VT >::value_type WBoundingBoxImpl< VT >::radiu
}
template< class VT >
inline osg::BoundingBoxImpl< VT > WBoundingBoxImpl< VT >::toOSGBB() const
inline osg::BoundingBox WBoundingBoxImpl< VT >::toOSGBB() const
{
return *this;
return osg::BoundingBox( osg::BoundingBoxImpl< VT >::_min, osg::BoundingBoxImpl< VT >::_max );
}
template< class VT >
......
......@@ -22,14 +22,16 @@
//
//---------------------------------------------------------------------------
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <iostream>
#include <boost/filesystem/fstream.hpp>
#include <boost/lexical_cast.hpp>
#include "../common/datastructures/WFiber.h"
#include "../common/WBoundingBox.h"
#include "../common/WColor.h"
#include "../common/WLogger.h"
......@@ -37,9 +39,9 @@
#include "../common/WPropertyHelper.h"
#include "../graphicsEngine/WGEUtils.h"
#include "exceptions/WDHNoSuchDataSet.h"
#include "WCreateColorArraysThread.h"
#include "WDataSet.h"
#include "WDataSetFibers.h"
#include "WCreateColorArraysThread.h"
// prototype instance as singleton
boost::shared_ptr< WPrototyped > WDataSetFibers::m_prototype = boost::shared_ptr< WPrototyped >();
......@@ -54,15 +56,13 @@ WDataSetFibers::WDataSetFibers( WDataSetFibers::VertexArray vertices,
WDataSetFibers::IndexArray lineStartIndexes,
WDataSetFibers::LengthArray lineLengths,
WDataSetFibers::IndexArray verticesReverse,
std::pair< wmath::WPosition, wmath::WPosition > boundingBox )
WBoundingBox boundingBox )
: WDataSet(),
m_vertices( vertices ),
m_lineStartIndexes( lineStartIndexes ),
m_lineLengths( lineLengths ),
m_verticesReverse( verticesReverse ),
m_bbMin( boundingBox.first ),
m_bbMax( boundingBox.second )
m_vertices( vertices ),
m_lineStartIndexes( lineStartIndexes ),
m_lineLengths( lineLengths ),
m_verticesReverse( verticesReverse ),
m_bb( boundingBox )
{
WAssert( m_vertices->size() % 3 == 0, "Invalid vertex array." );
init();
......@@ -73,23 +73,16 @@ WDataSetFibers::WDataSetFibers( WDataSetFibers::VertexArray vertices,
WDataSetFibers::LengthArray lineLengths,
WDataSetFibers::IndexArray verticesReverse )
: WDataSet(),
m_vertices( vertices ),
m_lineStartIndexes( lineStartIndexes ),
m_lineLengths( lineLengths ),
m_verticesReverse( verticesReverse )
m_vertices( vertices ),
m_lineStartIndexes( lineStartIndexes ),
m_lineLengths( lineLengths ),
m_verticesReverse( verticesReverse )
{
WAssert( m_vertices->size() % 3 == 0, "Invalid vertex array." );
// determine bounding box
m_bbMin = wmath::WPosition( wlimits::MAX_DOUBLE, wlimits::MAX_DOUBLE, wlimits::MAX_DOUBLE );
m_bbMax = wmath::WPosition( -wlimits::MAX_DOUBLE, -wlimits::MAX_DOUBLE, -wlimits::MAX_DOUBLE );
for( size_t i = 0; i < vertices->size()/3; ++i )
{
if( (*vertices)[ 3 * i + 0 ] > m_bbMax[0] ) m_bbMax[0] = (*vertices)[ 3 * i + 0 ];
if( (*vertices)[ 3 * i + 1 ] > m_bbMax[1] ) m_bbMax[1] = (*vertices)[ 3 * i + 1 ];
if( (*vertices)[ 3 * i + 2 ] > m_bbMax[2] ) m_bbMax[2] = (*vertices)[ 3 * i + 2 ];
if( (*vertices)[ 3 * i + 0 ] < m_bbMin[0] ) m_bbMin[0] = (*vertices)[ 3 * i + 0 ];
if( (*vertices)[ 3 * i + 1 ] < m_bbMin[1] ) m_bbMin[1] = (*vertices)[ 3 * i + 1 ];
if( (*vertices)[ 3 * i + 2 ] < m_bbMin[2] ) m_bbMin[2] = (*vertices)[ 3 * i + 2 ];
m_bb.expandBy( (*vertices)[ 3 * i + 0 ], (*vertices)[ 3 * i + 1 ], (*vertices)[ 3 * i + 2 ] );
}
// remaining initilisation
init();
......@@ -339,6 +332,30 @@ wmath::WPosition WDataSetFibers::getTangent( size_t fiber, size_t vertex ) const
return tangent;
}
/**
* Special helper functions for the saveSelected member function.
*/
namespace
{
/**
* converts an integer into a byte array and back
*/
union converterByteINT32
{
unsigned char b[4]; //!< the bytes
int i; //!< the int
};
/**
* converts a float into a byte array and back
*/
union converterByteFloat
{
unsigned char b[4]; //!< the bytes
float f; //!< the float
};
}
void WDataSetFibers::saveSelected( std::string filename, boost::shared_ptr< std::vector< bool > > active ) const
{
std::vector< float > pointsToSave;
......@@ -450,9 +467,9 @@ void WDataSetFibers::saveSelected( std::string filename, boost::shared_ptr< std:
}
}
std::pair< wmath::WPosition, wmath::WPosition > WDataSetFibers::getBoundingBox() const
WBoundingBox WDataSetFibers::getBoundingBox() const
{
return std::make_pair( m_bbMin, m_bbMax );
return m_bb;
}
WFiber WDataSetFibers::operator[]( size_t numTract ) const
......
......@@ -32,29 +32,14 @@
#include <boost/shared_ptr.hpp>
#include <boost/tuple/tuple.hpp>
#include "../common/datastructures/WFiber.h"
#include "../common/math/WPosition.h"
#include "../common/WBoundingBox.h"
#include "../common/WProperties.h"
#include "WDataSet.h"
#include "WExportDataHandler.h"
/**
* converts an integer into a byte array and back
*/
union converterByteINT32
{
unsigned char b[4]; //!< the bytes
int i; //!< the int
};
/**
* converts a float into a byte array and back
*/
union converterByteFloat
{
unsigned char b[4]; //!< the bytes
float f; //!< the float
};
// forward declarations
class WFiber;
/**
* Represents a simple set of WFibers.
......@@ -184,7 +169,7 @@ public:
boost::shared_ptr< std::vector< size_t > > lineStartIndexes,
boost::shared_ptr< std::vector< size_t > > lineLengths,
boost::shared_ptr< std::vector< size_t > > verticesReverse,
std::pair< wmath::WPosition, wmath::WPosition > boundingBox );
WBoundingBox boundingBox );
/**
* Constructs a new set of fibers. This constructor determines the bounding box by using the coordinates of the vertices.
......@@ -200,12 +185,12 @@ public:
boost::shared_ptr< std::vector< size_t > > verticesReverse );
/**
* Constructs a new set of WFibers. The constructed instance is not usable.
* Constructs a new set of tracts. The constructed instance is not usable but needed for prototype mechanism.
*/
WDataSetFibers();
/**
* Get number of fibers in this data set.
* Get number of tracts in this data set.
*/
size_t size() const;
......@@ -361,9 +346,9 @@ public:
void saveSelected( std::string filename, boost::shared_ptr< std::vector< bool > > active ) const;
/**
* Get the bounding box as pair of WPositions.
* Get the bounding box.
*/
std::pair< wmath::WPosition, wmath::WPosition > getBoundingBox() const;
WBoundingBox getBoundingBox() const;
/**
* Constructs a WFiber out of the given tract number.
......@@ -426,8 +411,10 @@ private:
*/
IndexArray m_verticesReverse;
wmath::WPosition m_bbMin; //!< Minimum position of bounding box of all fibers.
wmath::WPosition m_bbMax; //!< Maximum position of bounding box of all fibers.
/**
* Axis aligned bounding box for all tract-vertices of this dataset.
*/
WBoundingBox m_bb;
};
#endif // WDATASETFIBERS_H
......@@ -98,11 +98,7 @@ public:
*/
void setUseTubes( bool flag );
/**
* Set the bounding box of all fibers.
* \param bb The new bounding box.
*/
void setBoundingBox( const osg::BoundingBox & bb );
using osg::Drawable::setBound;
/**
* setter
......@@ -172,11 +168,6 @@ inline void WFiberDrawable::setUseTubes( bool flag )
m_useTubes = flag;
}
inline void WFiberDrawable::setBoundingBox( const osg::BoundingBox & bb )
{
setBound( bb );
}
inline void WFiberDrawable::setBitfield( boost::shared_ptr< std::vector< bool > > bitField )
{
m_active = bitField;
......
......@@ -981,13 +981,7 @@ void WMClusterDisplay::dendrogramClick( WPickInfo pickInfo )
void WMClusterDisplay::createFiberGeode()
{
m_fiberDrawable = osg::ref_ptr< WFiberDrawable >( new WFiberDrawable );
m_fiberDrawable->setBoundingBox( osg::BoundingBox( m_dataSet->getBoundingBox().first[0],
m_dataSet->getBoundingBox().first[1],
m_dataSet->getBoundingBox().first[2],
m_dataSet->getBoundingBox().second[0],
m_dataSet->getBoundingBox().second[1],
m_dataSet->getBoundingBox().second[2] ) );
m_fiberDrawable->setBound( m_dataSet->getBoundingBox().toOSGBB() );
m_fiberDrawable->setStartIndexes( m_dataSet->getLineStartIndexes() );
m_fiberDrawable->setPointsPerLine( m_dataSet->getLineLengths() );
m_fiberDrawable->setVerts( m_dataSet->getVertices() );
......
......@@ -285,13 +285,7 @@ void WMFiberDisplay::create()
osg::ref_ptr< osg::Group > osgNodeNew = osg::ref_ptr< osg::Group >( new osg::Group );
m_fiberDrawable = osg::ref_ptr< WFiberDrawable >( new WFiberDrawable );
m_fiberDrawable->setBoundingBox( osg::BoundingBox( m_dataset->getBoundingBox().first[0],
m_dataset->getBoundingBox().first[1],
m_dataset->getBoundingBox().first[2],
m_dataset->getBoundingBox().second[0],
m_dataset->getBoundingBox().second[1],
m_dataset->getBoundingBox().second[2] ) );
m_fiberDrawable->setBound( m_dataset->getBoundingBox().toOSGBB() );
m_fiberDrawable->setStartIndexes( m_dataset->getLineStartIndexes() );
m_fiberDrawable->setPointsPerLine( m_dataset->getLineLengths() );
m_fiberDrawable->setVerts( m_dataset->getVertices() );
......@@ -463,7 +457,6 @@ void WMFiberDisplay::updateOutput()
boost::shared_ptr< std::vector< size_t > > lineStartIndexes = boost::shared_ptr< std::vector< size_t > > ( new std::vector< size_t >() );
boost::shared_ptr< std::vector< size_t > > lineLengths = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
boost::shared_ptr< std::vector< size_t > > verticesReverse = boost::shared_ptr< std::vector< size_t > >( new std::vector< size_t >() );
std::pair< wmath::WPosition, wmath::WPosition > boundingBox = m_dataset->getBoundingBox();
size_t countLines = 0;
......@@ -489,7 +482,7 @@ void WMFiberDisplay::updateOutput()
++countLines;
}
}
boost::shared_ptr< WDataSetFibers> newOutput =
boost::shared_ptr< WDataSetFibers>( new WDataSetFibers( vertices, lineStartIndexes, lineLengths, verticesReverse, boundingBox ) );
boost::shared_ptr< WDataSetFibers> newOutput( new WDataSetFibers( vertices, lineStartIndexes, lineLengths, verticesReverse,
m_dataset->getBoundingBox() ) );
m_fiberOutput->updateData( newOutput );
}
......@@ -25,9 +25,10 @@
#include <osg/Geometry>
#include "../../common/datastructures/WFiber.h"
#include "../../common/exceptions/WTypeMismatch.h"
#include "../../common/WLogger.h"
#include "../../common/math/WPosition.h"
#include "../../common/WLogger.h"
#include "../../graphicsEngine/WGEGeodeUtils.h"
#include "WSPSliceGeodeBuilder.h"
......
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