dune-grid 2.8.0
Loading...
Searching...
No Matches
polygon.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=2 sw=2 sts=2:
3#ifndef DUNE_POLYGON_HH
4#define DUNE_POLYGON_HH
5
6#include <iostream>
7#include <vector>
8
9#include <dune/common/typetraits.hh>
11
12namespace Dune
13{
14
15 namespace dgf
16 {
17
18 // PolygonBlock
19 // ------------
20
22 : public BasicBlock
23 {
24 PolygonBlock ( std::istream &in, int numVtx, int vtxOfs )
25 : BasicBlock( in, "Polygon" ), vtxBegin_( vtxOfs ), vtxEnd_( vtxOfs + numVtx )
26 {}
27
28 int get ( std::vector< std::vector< int > > &polygons )
29 {
30 reset();
31 std::vector< int > polygon;
32 while( getnextline() )
33 {
34 polygon.clear();
35 for( int vtxIdx; getnextentry( vtxIdx ); )
36 {
37 if( (vtxBegin_ > vtxIdx) || (vtxIdx >= vtxEnd_) )
38 DUNE_THROW( DGFException, "Error in " << *this << ": Invalid vertex index (" << vtxIdx << " not int [" << vtxBegin_ << ", " << vtxEnd_ << "[)" );
39 polygon.push_back( vtxIdx - vtxBegin_ );
40 }
41
42 polygons.push_back( polygon );
43 }
44 return polygons.size();
45 }
46
47 protected:
49 };
50
51 } // namespace dgf
52} // end namespace Dune
53
54#endif // #ifndef DUNE_POLYGON_HH
Include standard header files.
Definition: agrid.hh:58
Definition: basic.hh:29
void reset()
Definition: basic.hh:49
bool getnextline()
Definition: basic.cc:92
bool getnextentry(ENTRY &entry)
Definition: basic.hh:61
Definition: polygon.hh:23
PolygonBlock(std::istream &in, int numVtx, int vtxOfs)
Definition: polygon.hh:24
int get(std::vector< std::vector< int > > &polygons)
Definition: polygon.hh:28
int vtxEnd_
Definition: polygon.hh:48
int vtxBegin_
Definition: polygon.hh:48
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:14