dune-grid  2.5.0
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 
12 namespace Dune
13 {
14 
15  namespace dgf
16  {
17 
18  // PolygonBlock
19  // ------------
20 
21  struct PolygonBlock
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
bool getnextentry(ENTRY &entry)
Definition: basic.hh:61
int vtxBegin_
Definition: polygon.hh:48
bool getnextline()
Definition: basic.cc:92
PolygonBlock(std::istream &in, int numVtx, int vtxOfs)
Definition: polygon.hh:24
Definition: common.hh:182
Definition: polygon.hh:21
void reset()
Definition: basic.hh:49
Include standard header files.
Definition: agrid.hh:59
exception class for IO errors in the DGF parser
Definition: dgfexception.hh:12
Definition: basic.hh:28
int vtxEnd_
Definition: polygon.hh:48