dune-grid
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
grid
io
file
dgfparser
blocks
polygon.hh
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright © 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>
12
#include <
dune/grid/io/file/dgfparser/blocks/basic.hh
>
13
14
namespace
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
basic.hh
Dune
Include standard header files.
Definition
agrid.hh:60
Dune::dgf
Definition
basic.cc:12
Dune::dgf::BasicBlock::reset
void reset()
Definition
basic.hh:51
Dune::dgf::BasicBlock::getnextline
bool getnextline()
Definition
basic.cc:93
Dune::dgf::BasicBlock::BasicBlock
BasicBlock(std::istream &in, const char *id)
Definition
basic.cc:17
Dune::dgf::BasicBlock::getnextentry
bool getnextentry(ENTRY &entry)
Definition
basic.hh:63
Dune::dgf::PolygonBlock::PolygonBlock
PolygonBlock(std::istream &in, int numVtx, int vtxOfs)
Definition
polygon.hh:26
Dune::dgf::PolygonBlock::get
int get(std::vector< std::vector< int > > &polygons)
Definition
polygon.hh:30
Dune::dgf::PolygonBlock::vtxEnd_
int vtxEnd_
Definition
polygon.hh:50
Dune::dgf::PolygonBlock::vtxBegin_
int vtxBegin_
Definition
polygon.hh:50
Dune::DGFException
exception class for IO errors in the DGF parser
Definition
dgfexception.hh:16
Generated by
1.17.0