Skip to content

Commit

Permalink
Simplified interface for lexicographic triangulation reader
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseudomanifold committed Jul 28, 2017
1 parent e45f594 commit a4f43ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 8 additions & 3 deletions include/aleph/topology/io/LexicographicTriangulation.hh
Expand Up @@ -49,7 +49,7 @@ class LexicographicTriangulationReader
{
public:

template <class SimplicialComplex, class OutputIterator> void operator()( const std::string& filename, OutputIterator result )
template <class SimplicialComplex> void operator()( const std::string& filename, std::vector<SimplicialComplex>& result )
{
std::ifstream in( filename );
if( !in )
Expand All @@ -58,7 +58,7 @@ public:
this->operator()( in, result );
}

template <class SimplicialComplex, class OutputIterator> void operator()( std::istream& in, OutputIterator result )
template <class SimplicialComplex> void operator()( std::istream& in, std::vector<SimplicialComplex>& result )
{
using namespace aleph::utilities;

Expand All @@ -67,6 +67,9 @@ public:

Mode mode = Mode::ParsingBlocks;

result.clear();
result.shrink_to_fit();

while( std::getline( in, line ) )
{
line = trim( line );
Expand Down Expand Up @@ -95,12 +98,14 @@ public:

if( isBlockFinished( block ) )
{
*result++ = parseBlock<SimplicialComplex>( block );
result.emplace_back( parseBlock<SimplicialComplex>( block ) );
mode = Mode::ParsingBlocks;

block.clear();
}
}

result.shrink_to_fit();
}

private:
Expand Down
5 changes: 1 addition & 4 deletions tests/test_io_lexicographic_triangulation.cc
Expand Up @@ -25,10 +25,7 @@ template <class T> void test()
std::vector<SimplicialComplex> simplicialComplexes;

aleph::topology::io::LexicographicTriangulationReader reader;

// ugly!
reader.operator()<SimplicialComplex>( stream,
std::back_inserter( simplicialComplexes ) );
reader( stream, simplicialComplexes );

ALEPH_ASSERT_EQUAL( simplicialComplexes.size(), 2 );

Expand Down

0 comments on commit a4f43ca

Please sign in to comment.