Commit a128e87b authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

Merge branch 'main' into SIVERT-Release

parents 2ac1256f 4d535899
# This is so git does not remove the line endings from the csv fixtures of the data module
src/modules/data/io/test/fixtures/CSVs/*.csv binary
......@@ -6,12 +6,16 @@ stages:
- Build_appimage_stage
- Upload_artifacts_stage
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- build/release
- build/debug
- tools/AppImage/AppImageBuild
- doc
create_directory_and_cmake___release:
stage: Initialization_stage
cache:
key: "CacheRelease"
paths:
- build/release
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- ls
......@@ -25,10 +29,6 @@ create_directory_and_cmake___release:
create_directory_and_cmake___debug:
stage: Initialization_stage
cache:
key: "CacheDebug"
paths:
- build/debug
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- ls
......@@ -42,10 +42,6 @@ create_directory_and_cmake___debug:
stylecheck_job:
stage: Stylecheck_doc_stage
cache:
key: "CacheRelease"
paths:
- build/release
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- pwd
......@@ -56,10 +52,6 @@ stylecheck_job:
doc_job:
stage: Stylecheck_doc_stage
cache:
key: "CacheDebug"
paths:
- build/debug
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- doxygen --version
......@@ -71,10 +63,6 @@ doc_job:
buildAndTest:
stage: Build_and_test_release_stage
cache:
key: "CacheRelease"
paths:
- build/release
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- pwd
......@@ -86,10 +74,6 @@ buildAndTest:
buildAndTestDebug:
stage: Build_and_test_debug_stage
cache:
key: "CacheDebug"
paths:
- build/debug
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- pwd
......@@ -101,10 +85,6 @@ buildAndTestDebug:
buildAppImage:
stage: Build_appimage_stage
cache:
key: "CacheAppImage"
paths:
- tools/AppImage/AppImageBuild
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- pwd
......@@ -116,10 +96,6 @@ buildAppImage:
uploadArtifacts:
stage: Upload_artifacts_stage
cache:
key: "CacheAppImage"
paths:
- tools/AppImage/AppImageBuild
image: ladbukkit/openwalnut_build_environment:1.5.2
script:
- pwd
......
......@@ -28,7 +28,7 @@
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
CMAKE_MINIMUM_REQUIRED(VERSION 3.16)
PROJECT( OpenWalnut )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
......
......@@ -25,7 +25,7 @@
#ifndef WLIMITS_H
#define WLIMITS_H
#include <stdint.h> // since <cstdint> is part of c++0x upcoming standard
#include <stdint.h>
#include <cstddef>
......
......@@ -55,7 +55,7 @@ public:
{
flag = true;
// let the test's thread reach its "wait" call first
// Let the test's thread reach its "wait" call first
boost::this_thread::sleep( boost::posix_time::seconds( 1 ) );
c->notify();
};
......@@ -68,7 +68,7 @@ class WConditionOneShotTest : public CxxTest::TestSuite
{
public:
/**
* An instantiation should never throw an exception, as well as tear down.
* An instantiation as well as tear down should never throw an exception.
*/
void testInstantiation( void )
{
......@@ -88,18 +88,18 @@ public:
t.flag = false;
t.c = &c;
// start a thread
// Start a thread
boost::thread thread = boost::thread( boost::bind( &CallableHelper::threadMain, &t ) );
// wait for condition
// Wait for condition
c.wait();
// since it is a one shot condition -> another wait will not cause a freeze
// Since it is a one shot condition -> another wait will not cause a freeze
c.wait();
TS_ASSERT( t.flag );
// notifying twice should not cause exceptions (boost::lock_error)
// Notifying twice should not cause exceptions (boost::lock_error)
TS_ASSERT_THROWS_NOTHING( c.notify() );
}
};
......
......@@ -88,10 +88,10 @@ public:
t.flag = false;
t.c = &c;
// start a thread
// Start a thread
boost::thread thread = boost::thread( boost::bind( &CallableHelperCl::threadMain, &t ) );
// wait for condition
// Wait for condition
c.wait();
TS_ASSERT( t.flag );
......
......@@ -24,6 +24,7 @@
#include <algorithm>
#include <memory>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
......@@ -235,6 +236,11 @@ WDataSetFibers::VertexArray WDataSetFibers::getVertices() const
return m_vertices;
}
size_t WDataSetFibers::getNbVertices() const
{
return std::accumulate( m_lineLengths->begin(), m_lineLengths->end(), 0 );
}
WDataSetFibers::IndexArray WDataSetFibers::getLineStartIndexes() const
{
return m_lineStartIndexes;
......@@ -261,6 +267,8 @@ void WDataSetFibers::addColorScheme( WDataSetFibers::ColorArray colors, std::str
// number of verts is needed to distinguish color mode.
size_t verts = m_vertices->size() / 3;
WAssert( verts != 0, "If there is color there has to be vertices!" );
size_t cols = colors->size();
if( cols / verts == 3 )
{
......@@ -347,6 +355,10 @@ const WPropSelection WDataSetFibers::getColorSchemeProperty() const
WDataSetFibers::VertexParemeterArray WDataSetFibers::getVertexParameters( size_t parameterIndex ) const
{
if( m_vertexParameters.empty() )
{
return NULL;
}
return m_vertexParameters[ parameterIndex ];
}
......@@ -951,4 +963,3 @@ double WFiberSegmentsIterator::length() const
{
return distance( *start(), *end() );
}
......@@ -295,6 +295,12 @@ public:
*/
VertexArray getVertices() const;
/**
* Getter for the total number of vertices over all lines
* \return Overall number of vertices
*/
size_t getNbVertices() const;
/**
* Return the indices that indicate at which vertex ID each line begins in the vertex array.
* \return The start indices of the lines
......@@ -398,7 +404,7 @@ public:
/**
* Sets the selected color scheme.
*
*
* \param idx the index
*/
void setSelectedColorScheme( size_t idx );
......
......@@ -31,6 +31,7 @@
#include "../common/WTimer.h"
#include "WSelectionManager.h"
#include "../graphicsEngine/WGraphicsEngine.h"
#include "../scripting/WScriptEngine.h"
#include "WBatchLoader.h"
......@@ -41,7 +42,6 @@ class WModule;
class WModuleContainer;
class WModuleFactory;
class WROIManager;
class WSelectionManager;
class WThreadedRunner;
/**
......
......@@ -122,7 +122,7 @@ const std::string WMCoordinateSystem::getName() const
const std::string WMCoordinateSystem::getDescription() const
{
return "This module displays coordinate systems as overlay withn the main 3D view.";
return "This module displays coordinate systems as overlay within the main 3D view.";
}
void WMCoordinateSystem::properties()
......
......@@ -438,6 +438,12 @@ void WMData::cleanUp()
void WMData::load()
{
// remove old properties
if( m_dataSet )
{
m_infoProperties->removeProperty( m_dataSet->getInformationProperties() );
}
// Get the input
WDataModuleInputFile::SPtr inputFile = getInputAs< WDataModuleInputFile >();
if( !inputFile )
......@@ -597,6 +603,8 @@ void WMData::load()
// done. close file and report finish
progress1->finish();
m_infoProperties->removeProperty( m_dataSet->getInformationProperties() );
// remove old left over info properties
m_infoProperties->removeProperty( m_infoProperties->findProperty( "Data-Set Info Properties" ) );
// add current info properties
m_infoProperties->addProperty( m_dataSet->getInformationProperties() );
}
......@@ -39,6 +39,38 @@ WReaderCSV::~WReaderCSV() throw()
}
static std::istream& safeGetLine( std::istream& is, std::string& t ) // NOLINT
{
// reads a line with a non specific line ending
t.clear();
std::istream::sentry se( is, true );
std::streambuf* sb = is.rdbuf();
int c;
while( ( c = sb->sbumpc() ) != std::streambuf::traits_type::eof() )
{
switch( c )
{
case '\n': // Handle Unix linebreaks
return is;
case '\r': // Handle old mac linebreaks
if( sb->sgetc() == '\n' ) // Handle windows linebreaks
{
sb->sbumpc();
}
return is;
default:
t.push_back( c );
}
}
if( t.empty() )
{
is.setstate( std::ios::eofbit );
}
return is;
}
std::shared_ptr< WDataSetCSV > WReaderCSV::read()
{
size_t columnCount = 0;
......@@ -58,7 +90,7 @@ std::shared_ptr< WDataSetCSV > WReaderCSV::read()
}
// treat first line as header
std::getline( file, line );
safeGetLine( file, line );
if( line == "" )
{
throw WException( "CSV file is empty!" );
......@@ -69,8 +101,12 @@ std::shared_ptr< WDataSetCSV > WReaderCSV::read()
columnCount = header->at( 0 ).size();
// treat remaining lines as data
while( std::getline( file, line ) )
while( safeGetLine( file, line ) )
{
if( line.empty() && file.eof() ) // Ignore empty line at the end of a file.
{
break;
}
rawRow->push_back( line );
row = transformLineToVector( line );
if( row.size() != columnCount )
......@@ -99,13 +135,17 @@ std::shared_ptr< WDataSetCSV > WReaderCSV::read()
std::vector< std::string > WReaderCSV::transformLineToVector( std::string line )
{
std::string cell;
std::vector< std::string > row;
std::vector< std::string > row;
std::istringstream inLine( line );
while( std::getline( inLine, cell, ',' ) )
size_t pos = 0;
while( ( pos = line.find( ',' ) ) != std::string::npos )
{
cell = line.substr( 0, pos );
row.push_back( cell );
line.erase( 0, pos + 1 );
}
row.push_back( line );
return row;
}
......@@ -127,6 +127,126 @@ public:
// compare last data rows
TS_ASSERT_EQUALS( tmpCsvReader.read()->getData()->back(), testDataLastRow->front() );
}
/**
* check \\r line endings
*/
void testCRLineEnding()
{
std::string fileName = W_FIXTURE_PATH + "CSVs/cr.csv";
std::cout << std::endl << "Test loading of " << fileName << "." << std::endl;
WDataSetCSV::ContentSPtr testHeader = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
WDataSetCSV::ContentSPtr testDataFirstRow = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
testHeader->push_back(
{
"header1", "header2", "header3"
}
);
testDataFirstRow->push_back(
{
"1", "2", "3"
}
);
WReaderCSV tmpCsvReader( fileName );
TS_ASSERT_THROWS_NOTHING( tmpCsvReader.read() );
// compare headers
TS_ASSERT_EQUALS( tmpCsvReader.read()->getHeader()->front(), testHeader->front() );
// compare first data rows
TS_ASSERT_EQUALS( tmpCsvReader.read()->getData()->front(), testDataFirstRow->front() );
}
/**
* check \\n line endings
*/
void testLFLineEnding()
{
std::string fileName = W_FIXTURE_PATH + "CSVs/lf.csv";
std::cout << std::endl << "Test loading of " << fileName << "." << std::endl;
WDataSetCSV::ContentSPtr testHeader = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
WDataSetCSV::ContentSPtr testDataFirstRow = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
testHeader->push_back(
{
"header1", "header2", "header3"
}
);
testDataFirstRow->push_back(
{
"1", "2", "3"
}
);
WReaderCSV tmpCsvReader( fileName );
TS_ASSERT_THROWS_NOTHING( tmpCsvReader.read() );
// compare headers
TS_ASSERT_EQUALS( tmpCsvReader.read()->getHeader()->front(), testHeader->front() );
// compare first data rows
TS_ASSERT_EQUALS( tmpCsvReader.read()->getData()->front(), testDataFirstRow->front() );
}
/**
* check \\r\\n line endings
*/
void testCRLFLineEnding()
{
std::string fileName = W_FIXTURE_PATH + "CSVs/crlf.csv";
std::cout << std::endl << "Test loading of " << fileName << "." << std::endl;
WDataSetCSV::ContentSPtr testHeader = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
WDataSetCSV::ContentSPtr testDataFirstRow = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
testHeader->push_back(
{
"header1", "header2", "header3"
}
);
testDataFirstRow->push_back(
{
"1", "2", "3"
}
);
WReaderCSV tmpCsvReader( fileName );
TS_ASSERT_THROWS_NOTHING( tmpCsvReader.read() );
// compare headers
TS_ASSERT_EQUALS( tmpCsvReader.read()->getHeader()->front(), testHeader->front() );
// compare first data rows
TS_ASSERT_EQUALS( tmpCsvReader.read()->getData()->front(), testDataFirstRow->front() );
}
/**
* Empty columns should not prevent the reader from reading all columns
*/
void testEmptyColumns()
{
std::string fileName = W_FIXTURE_PATH + "CSVs/emptyColumns.csv";
std::cout << std::endl << "Test loading of " << fileName << "." << std::endl;
WDataSetCSV::ContentSPtr testHeader = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
WDataSetCSV::ContentSPtr testDataFirstRow = WDataSetCSV::ContentSPtr( new WDataSetCSV::Content() );
testHeader->push_back(
{
"header1", "header2", "header3"
}
);
testDataFirstRow->push_back(
{
"", "", ""
}
);
WReaderCSV tmpCsvReader( fileName );
TS_ASSERT_THROWS_NOTHING( tmpCsvReader.read() );
// compare headers
TS_ASSERT_EQUALS( tmpCsvReader.read()->getHeader()->front(), testHeader->front() );
// compare first data rows
TS_ASSERT_EQUALS( tmpCsvReader.read()->getData()->front(), testDataFirstRow->front() );
}
};
#endif // WREADERCSV_TEST_H
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
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