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