dune-grid
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
grid
io
file
dgfparser
blocks
polyhedron.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_POLYHEDRON_HH
6
#define DUNE_POLYHEDRON_HH
7
8
#include <algorithm>
9
10
#include <
dune/grid/io/file/dgfparser/blocks/polygon.hh
>
11
12
namespace
Dune
13
{
14
15
namespace
dgf
16
{
17
18
// PolyhedronBlock
19
// ---------------
20
21
struct
PolyhedronBlock
22
:
public
BasicBlock
23
{
24
explicit
PolyhedronBlock
( std::istream &in,
int
numPolys )
25
:
BasicBlock
( in,
"Polyhedron"
),
numPolys_
( numPolys )
26
{}
27
28
int
get
( std::vector< std::vector< int > > &polyhedra )
29
{
30
reset
();
31
std::vector< int > polyhedron;
32
int
minPolyId = 1;
33
while
(
getnextline
() )
34
{
35
polyhedron.clear();
36
for
(
int
polyIdx;
getnextentry
( polyIdx ); )
37
{
38
if
( (polyIdx < 0) || (polyIdx >
numPolys_
) )
39
DUNE_THROW(
DGFException
,
"Error in "
<< *
this
<<
": Invalid polygon index ("
<< polyIdx <<
" not int [0, "
<<
numPolys_
<<
"])"
);
40
41
minPolyId = std::min( minPolyId, polyIdx );
42
polyhedron.push_back( polyIdx );
43
}
44
45
polyhedra.push_back( polyhedron );
46
}
47
48
// subtract minimal number to have 0 starting numbering
49
if
( minPolyId > 0 )
50
{
51
const
size_t
polySize = polyhedra.size();
52
for
(
size_t
i=0; i<polySize; ++i )
53
{
54
const
size_t
pSize = polyhedra[ i ].size();
55
for
(
size_t
j=0; j<pSize; ++j )
56
{
57
polyhedra[ i ][ j ] -= minPolyId;
58
}
59
}
60
}
61
return
polyhedra.size();
62
}
63
64
protected
:
65
const
int
numPolys_
;
66
};
67
68
}
// namespace dgf
69
}
// end namespace Dune
70
71
#endif
// #ifndef DUNE_POLYHEDRON_HH
polygon.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::PolyhedronBlock::numPolys_
const int numPolys_
Definition
polyhedron.hh:65
Dune::dgf::PolyhedronBlock::PolyhedronBlock
PolyhedronBlock(std::istream &in, int numPolys)
Definition
polyhedron.hh:24
Dune::dgf::PolyhedronBlock::get
int get(std::vector< std::vector< int > > &polyhedra)
Definition
polyhedron.hh:28
Dune::DGFException
exception class for IO errors in the DGF parser
Definition
dgfexception.hh:16
Generated by
1.17.0