Dune Core Modules (2.6.0)

polygon.hh
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
10#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
11
12namespace 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:
48 int vtxBegin_, vtxEnd_;
49 };
50
51 } // namespace dgf
52} // end namespace Dune
53
54#endif // #ifndef DUNE_POLYGON_HH
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignedallocator.hh:10
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)