Dune Core Modules (2.9.0)

polygon.hh
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
12#include <dune/grid/io/file/dgfparser/blocks/basic.hh>
13
14namespace Dune
15{
16
17 namespace dgf
18 {
19
20 // PolygonBlock
21 // ------------
22
23 struct PolygonBlock
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:
50 int vtxBegin_, vtxEnd_;
51 };
52
53 } // namespace dgf
54} // end namespace Dune
55
56#endif // #ifndef DUNE_POLYGON_HH
Traits for type conversions and type information.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)