Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
5e2f3264
Commit
5e2f3264
authored
2 years ago
by
Ned Coltman
Committed by
Timo Koch
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[io][rasterimagereader] Move types to a separate header
parent
47693c4c
No related branches found
No related tags found
1 merge request
!3340
[io][rasterimagereader] Add a method to write a modified image file
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dumux/io/rasterimagedata.hh
+96
-0
96 additions, 0 deletions
dumux/io/rasterimagedata.hh
dumux/io/rasterimagereader.hh
+6
-59
6 additions, 59 deletions
dumux/io/rasterimagereader.hh
with
102 additions
and
59 deletions
dumux/io/rasterimagedata.hh
0 → 100644
+
96
−
0
View file @
5e2f3264
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup InputOutput
* \brief A data class for raster image information
*/
#ifndef DUMUX_RASTER_IMAGE_DATA_HH
#define DUMUX_RASTER_IMAGE_DATA_HH
#include
<string>
#include
<vector>
#include
<fstream>
namespace
Dumux
::
Detail
::
RasterImageData
{
/*!
* \brief A struct that holds all information of the image format.
*/
struct
Format
{
std
::
string
magicNumber
;
std
::
string
type
;
std
::
string
encoding
;
};
/*!
* \brief A struct that contains all header data of the image.
*/
struct
HeaderData
{
Format
format
;
std
::
size_t
nCols
;
std
::
size_t
nRows
;
std
::
size_t
maxValue
=
1
;
};
/*!
* \brief The return type of the reading functions.
* Holds the actual pixel values and the header data.
*/
template
<
class
T
>
class
Result
:
private
std
::
vector
<
T
>
{
using
Parent
=
std
::
vector
<
T
>
;
public:
Result
()
=
delete
;
/*!
* \brief Construct from data and header by copy
*/
Result
(
const
std
::
vector
<
T
>&
data
,
const
HeaderData
&
header
)
:
Parent
(
data
)
,
header_
(
header
)
{}
/*!
* \brief Construct from data and header by move
*/
Result
(
std
::
vector
<
T
>&&
data
,
HeaderData
&&
header
)
:
Parent
(
std
::
move
(
data
))
,
header_
(
std
::
move
(
header
))
{}
//! Returns the header data.
const
HeaderData
&
header
()
const
{
return
header_
;
}
// expose some methods of std::vector
using
Parent
::
operator
[];
using
Parent
::
begin
;
using
Parent
::
end
;
using
Parent
::
size
;
private
:
HeaderData
header_
;
};
}
// end namespace Dumux::Detail::RasterImageData
#endif
This diff is collapsed.
Click to expand it.
dumux/io/rasterimagereader.hh
+
6
−
59
View file @
5e2f3264
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include
<dune/common/exceptions.hh>
#include
<dune/common/exceptions.hh>
#include
<dumux/common/stringutilities.hh>
#include
<dumux/common/stringutilities.hh>
#include
<dumux/io/rasterimagedata.hh>
namespace
Dumux
{
namespace
Dumux
{
...
@@ -46,67 +47,13 @@ namespace Dumux {
...
@@ -46,67 +47,13 @@ namespace Dumux {
*/
*/
class
NetPBMReader
class
NetPBMReader
{
{
public:
template
<
typename
T
>
/*!
using
Result
=
Detail
::
RasterImageData
::
Result
<
T
>
;
* \brief A struct that holds all information of the image format.
*/
struct
Format
{
std
::
string
magicNumber
;
std
::
string
type
;
std
::
string
encoding
;
};
/*!
using
HeaderData
=
Detail
::
RasterImageData
::
HeaderData
;
* \brief A struct that contains all header data of the image.
using
Format
=
Detail
::
RasterImageData
::
Format
;
*/
struct
HeaderData
{
Format
format
;
std
::
size_t
nCols
;
std
::
size_t
nRows
;
std
::
size_t
maxValue
=
1
;
};
/*!
public:
* \brief The return type of the reading functions.
* Holds the actual pixel values and the header data.
*/
template
<
class
T
>
class
Result
:
private
std
::
vector
<
T
>
{
using
Parent
=
std
::
vector
<
T
>
;
public:
Result
()
=
delete
;
/*!
* \brief Construct from data and header by copy
*/
Result
(
const
std
::
vector
<
T
>&
data
,
const
HeaderData
&
header
)
:
Parent
(
data
)
,
header_
(
header
)
{}
/*!
* \brief Construct from data and header by move
*/
Result
(
std
::
vector
<
T
>&&
data
,
HeaderData
&&
header
)
:
Parent
(
std
::
move
(
data
))
,
header_
(
std
::
move
(
header
))
{}
//! Returns the header data.
const
HeaderData
&
header
()
const
{
return
header_
;
}
// expose some methods of std::vector
using
Parent
::
operator
[];
using
Parent
::
begin
;
using
Parent
::
end
;
using
Parent
::
size
;
private
:
HeaderData
header_
;
};
/*!
/*!
* \brief A helper function to retrieve the format from tokens of the file's first line.
* \brief A helper function to retrieve the format from tokens of the file's first line.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment