Commit 1be9911b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[MERGE]

parents 44466c5a 848b2fd5
......@@ -74,28 +74,20 @@ void WGEGraphicsWindow::createContext( int x, int y, int width, int height )
osg::ref_ptr<osg::DisplaySettings> ds = osg::DisplaySettings::instance();
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
// ensure correct $DISPLAY variable
traits->readDISPLAY();
if( traits->displayNum < 0 )
{
traits->displayNum = 0;
}
// set a lot of values
traits->windowName = "OpenWalnut";
traits->screenNum = 0; // XXX is this a good idea?
traits->x = x;
traits->y = y;
traits->width = width;
traits->height = height;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
// traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext = 0;
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();
traits->inheritedWindowData = m_WindowData;
traits->vsync = true;
// finally create graphics context and window
m_GraphicsContext = osg::GraphicsContext::createGraphicsContext( traits.get() );
......
......@@ -47,6 +47,7 @@
#include "io/WReaderELC.h"
#include "io/WReaderFiberVTK.h"
#include "io/WReaderLibeep.h"
#include "io/WReaderVTK.h"
#include "io/WPagerEEGLibeep.h"
#include "WMData.h"
......@@ -285,6 +286,11 @@ void WMData::moduleMain()
WReaderFiberVTK fibReader( fileName );
m_dataSet = fibReader.read();
}
else if ( suffix == ".vtk" )
{
WReaderVTK vtkReader( fileName );
m_dataSet = vtkReader.read();
}
else
{
throw WDHException( std::string( "Could not load \"" + fileName + "\". Reason: unknown file type: \"" + suffix + "\"" ) );
......
This diff is collapsed.
......@@ -44,7 +44,8 @@
* Currently only a subset of the legacy format is supported.
*
* Formats read: Original ASCII and BINARY. The xml format is not supported.
* Grids read are: STRUCTURED_POINTS
* Grids read are: STRUCTURED_POINTS, RECTILINEAR_GRID is interpreted as a grid with
* equal spacing per coordinate axis
* Data types read: SCALARS, VECTORS, TENSORS
*
* Endianess is kept as on the platform, so for intel hosts, most files,
......@@ -55,8 +56,10 @@
*/
class WReaderVTK : public WReader // NOLINT
{
//! allow member access by the test class
friend class WReaderVTKTest;
public:
public:
/**
* Constructs and makes a new VTK reader for separate thread start.
*
......@@ -71,30 +74,42 @@ class WReaderVTK : public WReader // NOLINT
virtual ~WReaderVTK() throw();
/**
* Reads the fiber file and creates a dataset out of it.
* Reads the data file and creates a dataset out of it.
*
* \return Reference to the dataset.
*/
virtual boost::shared_ptr< WDataSet > read();
protected:
protected:
/**
* Read VTK header from file.
* Read VTK header from file. Sets the m_isASCII member accordingly.
*
* \return The offset where header ends, so we may skip this next operation.
* \throws WDHIOFailure, WDHParseError
* \return true, if the header was valid
*/
void readHeader();
bool readHeader();
/**
* Read VTK POINT_DATA field from input stream.
* Read VTK Domain specification and create a matching grid.
*
* \return The constructed grid or an invalid pointer if any problem occurred.
*/
void readPointData();
boost::shared_ptr< WGridRegular3D > readStructuredPoints();
/**
* Read VTK STRUCTURED_POINTS field
* Read VTK Domain specification and create a matching grid.
*
* \return The constructed grid or an invalid pointer if any problem occurred.
*/
void readStructuredPoints();
boost::shared_ptr< WGridRegular3D > readRectilinearGrid();
/**
* Read domain information for structured points.
*
* \param grid The grid constructed from the domain information.
*
* \return The value set containing the values read from the file or an invalid pointer if anything went wrong.
*/
boost::shared_ptr< WValueSetBase > readData( boost::shared_ptr< WGridRegular3D > const& grid );
/**
* Read VTK SCALARS field
......@@ -104,8 +119,10 @@ class WReaderVTK : public WReader // NOLINT
* the number of scalars to read
* \param name
* the name of the data set that may be overwritten by information in the scalars line
*
* \return The resulting value set.
*/
void readScalars( size_t nbScalars, const std::string & name );
boost::shared_ptr< WValueSetBase > readScalars( size_t nbScalars, const std::string & name );
/**
* Read VTK SCALARS field
......@@ -115,8 +132,10 @@ class WReaderVTK : public WReader // NOLINT
* the number of vectors to read
* \param name
* the name of the data set that may be overwritten by information in the vectors line
*/
void readVectors( size_t nbVectors, const std::string & name );
*
* \return The resulting value set.
*/
boost::shared_ptr< WValueSetBase > readVectors( size_t nbVectors, const std::string & name );
/**
* Read VTK TENSORS field
......@@ -126,33 +145,49 @@ class WReaderVTK : public WReader // NOLINT
* the number of tensors to read
* \param name
* the name of the data set that may be overwritten by information in the tensors line
*/
void readTensors( size_t nbTensors, const std::string & name );
*
* \return The resulting value set.
*/
boost::shared_ptr< WValueSetBase > readTensors( size_t nbTensors, const std::string & name );
std::vector< std::string > m_header; //!< VTK header of the read file
/**
* Stores for every point its x,y and z float value successivley.
* \note The i'th point starts at the 3*i index since every point consumes
* 3 elements.
*/
boost::shared_ptr< std::vector< float > > m_points;
boost::shared_ptr< std::ifstream > m_ifs; //!< Pointer to the input file stream reader.
//boost::shared_ptr< std::vector< size_t > > m_fiberStartIndices; //!< Stores the start indices (in the point array) for every fiber
private:
//boost::shared_ptr< std::vector< size_t > > m_fiberLengths; //!< Stores the length of every fiber
//! The types of domains supported so far.
enum DomainType
{
//! structured points
STRUCTURED_POINTS,
/**
* Stores for every point the fiber where it belongs to.
* \note This vector has as many components as there are points, hence its
* length is just a third of the length of the points vector.
*/
//boost::shared_ptr< std::vector< size_t > > m_pointFiberMapping;
//! rectilinear grid
RECTILINEAR_GRID,
boost::shared_ptr< std::ifstream > m_ifs; //!< Pointer to the input file stream reader.
//! anything else
UNSUPPORTED_DOMAIN
};
//! The types of attributes supported so far.
enum AttributeType
{
//! scalar data
SCALARS,
//! vector data
VECTORS,
//! tensor data
TENSORS,
//! array data
ARRAYS,
//! anything else
UNSUPPORTED_ATTRIBUTE
};
private:
/**
* Reads the next line from current position in stream of the fiber VTK file.
*
......@@ -163,6 +198,23 @@ class WReaderVTK : public WReader // NOLINT
*/
std::string getLine( const std::string& desc );
/**
* Read the coordinates of the dataset's domain.
*
* \param name The name to look for in the first line.
* \param dim The number of coordinates.
* \param coords The resulting vector of coordinates.
*/
void readCoords( std::string const& name, std::size_t dim, std::vector< float >& coords );
/**
* Read values from the file. The m_isASCII flag must be initialized accordingly.
*
* \param values The values read from the file.
* \param numValues The number of values to read.
*/
void readValuesFromFile( std::vector< float >& values, std::size_t numValues );
/**
* Try to cast from the given string to the template value T. If the cast fails a
* WDHParseError is thrown.
......@@ -174,22 +226,26 @@ class WReaderVTK : public WReader // NOLINT
*/
template< typename T > T getLexicalCast( std::string stringValue, const std::string& errMsg ) const;
/**
* reference to the currently loading data set
*/
boost::shared_ptr< WDataSet > newDataSet;
boost::shared_ptr< WDataSet > m_newDataSet;
/**
* reference to the currently loading grid
*/
boost::shared_ptr< WGridRegular3D > newGrid;
boost::shared_ptr< WGridRegular3D > m_newGrid;
/**
* internal flag whether we read ascii or binary
*/
bool isAscii;
bool m_isASCII;
//! The type of domain specified in the file.
DomainType m_domainType;
//! The type of the attributes first read from the file.
AttributeType m_attributeType;
};
template< typename T > inline T WReaderVTK::getLexicalCast( std::string stringValue, const std::string& errMsg ) const
......@@ -206,4 +262,5 @@ template< typename T > inline T WReaderVTK::getLexicalCast( std::string stringVa
return result;
}
#endif // WREADERVTK_H
......@@ -672,7 +672,7 @@ void WMainWindow::openLoadDialog()
fd.setFileMode( QFileDialog::ExistingFiles );
QStringList filters;
filters << "Known file types (*.cnt *.edf *.asc *.nii *.nii.gz *.fib *.owproj *.owp)"
filters << "Known file types (*.cnt *.edf *.asc *.nii *.nii.gz *.vtk *.fib *.owproj *.owp)"
<< "Simple Project File (*.owproj *.owp)"
<< "EEG files (*.cnt *.edf *.asc)"
<< "NIfTI (*.nii *.nii.gz)"
......
......@@ -40,6 +40,9 @@ SERVER=http://ftp.de.debian.org/debian
# the prefix-name of each build chroot dir
CHROOTDIR=owbuildchroot-$SUITE-$ARCH
# if set to 1, the chroot gets archived after creation
ARCHIVECHROOT=0
#############################################################################################################
# Functions
#############################################################################################################
......@@ -366,11 +369,13 @@ chroot_build()
exit 1
fi
echo " * Archiving chroot."
tar czf $CHROOTDIR.tar.gz ./$CHROOTDIR
if [ $? -ne 0 ]; then
echo " * Failed archving. Not enough space?"
exit 1
if [ $ARCHIVECHROOT -ne 0 ]; then
echo " * Archiving chroot."
tar czf $CHROOTDIR.tar.gz ./$CHROOTDIR
if [ $? -ne 0 ]; then
echo " * Failed archving. Not enough space?"
exit 1
fi
fi
fi
}
......
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