OpenMEEG
Toggle main menu visibility
Loading...
Searching...
No Matches
OpenMEEG
include
GeometryIO.h
Go to the documentation of this file.
1
// Project Name: OpenMEEG (http://openmeeg.github.io)
2
// © INRIA and ENPC under the French open source license CeCILL-B.
3
// See full copyright notice in the file LICENSE.txt
4
// If you make a copy of this file, you must either:
5
// - provide also LICENSE.txt and modify this header to refer to it.
6
// - replace this header by the LICENSE.txt content.
7
8
#pragma once
9
10
#include <map>
11
#include <string>
12
13
#include <
geometry.h
>
14
#include <
matrix.h
>
15
#include <
filenames.h
>
16
17
namespace
OpenMEEG
{
18
19
// Geometry IO class
20
21
class
OPENMEEG_EXPORT
GeometryIO
{
22
public
:
23
24
static
GeometryIO
*
create
(
const
std::string& filename) {
25
const
std::string& extension =
tolower
(
getFilenameExtension
(filename));
26
try
{
27
return
registery
.at(extension)->clone(filename);
28
}
catch
(std::out_of_range&) {
29
throw
UnknownFileSuffix(extension);
30
}
31
}
32
33
virtual
const
char
*
name
()
const
= 0;
34
35
void
load
(
Geometry
& geometry) {
36
load_meshes
(geometry);
37
load_domains
(geometry);
38
}
39
40
void
load
(
Geometry
& geometry,
Matrix
& matrix) {
41
load
(geometry);
42
matrix =
load_data
();
43
}
44
45
void
save
(
const
Geometry
& geometry) {
46
save_geom
(geometry);
47
write
();
48
}
49
50
void
save
(
const
Geometry
& geometry,
const
Matrix
& matrix) {
51
save_geom
(geometry);
52
save_data
(geometry,matrix);
53
write
();
54
}
55
56
virtual
~GeometryIO
() =
default
;
57
58
protected
:
59
60
virtual
void
load_meshes
(
Geometry
& geometry) = 0;
61
virtual
void
load_domains
(
Geometry
&) { }
62
virtual
Matrix
load_data
()
const
= 0;
63
64
virtual
void
save_geom
(
const
Geometry
& geometry) = 0;
65
virtual
void
save_data
(
const
Geometry
& geometry,
const
Matrix
& matrix)
const
= 0;
66
virtual
void
write
()
const
= 0;
67
68
virtual
GeometryIO
*
clone
(
const
std::string& filename)
const
= 0;
69
70
typedef
std::map<std::string,GeometryIO*>
Registery
;
71
72
static
Registery
registery
;
73
74
GeometryIO
(
const
std::string& filename,
const
char
*
name
):
fname
(filename) {
registery
.insert({
name
,
this
}); }
75
76
std::string
fname
;
77
};
78
}
OpenMEEG::GeometryIO::create
static GeometryIO * create(const std::string &filename)
Definition
GeometryIO.h:24
OpenMEEG::GeometryIO::load_meshes
virtual void load_meshes(Geometry &geometry)=0
OpenMEEG::GeometryIO::write
virtual void write() const =0
OpenMEEG::GeometryIO::save_data
virtual void save_data(const Geometry &geometry, const Matrix &matrix) const =0
OpenMEEG::GeometryIO::GeometryIO
GeometryIO(const std::string &filename, const char *name)
Definition
GeometryIO.h:74
OpenMEEG::GeometryIO::Registery
std::map< std::string, GeometryIO * > Registery
Definition
GeometryIO.h:70
OpenMEEG::GeometryIO::name
virtual const char * name() const =0
OpenMEEG::GeometryIO::save_geom
virtual void save_geom(const Geometry &geometry)=0
OpenMEEG::GeometryIO::load
void load(Geometry &geometry)
Definition
GeometryIO.h:35
OpenMEEG::GeometryIO::fname
std::string fname
Definition
GeometryIO.h:76
OpenMEEG::GeometryIO::clone
virtual GeometryIO * clone(const std::string &filename) const =0
OpenMEEG::GeometryIO::~GeometryIO
virtual ~GeometryIO()=default
OpenMEEG::GeometryIO::load
void load(Geometry &geometry, Matrix &matrix)
Definition
GeometryIO.h:40
OpenMEEG::GeometryIO::save
void save(const Geometry &geometry, const Matrix &matrix)
Definition
GeometryIO.h:50
OpenMEEG::GeometryIO::load_domains
virtual void load_domains(Geometry &)
Definition
GeometryIO.h:61
OpenMEEG::GeometryIO::save
void save(const Geometry &geometry)
Definition
GeometryIO.h:45
OpenMEEG::GeometryIO::load_data
virtual Matrix load_data() const =0
OpenMEEG::GeometryIO::registery
static Registery registery
Definition
GeometryIO.h:72
OpenMEEG::Geometry
Geometry contains the electrophysiological model Vertices, meshes and domains are stored in this geom...
Definition
geometry.h:31
OpenMEEG::Matrix
Matrix class Matrix class.
Definition
matrix.h:28
filenames.h
geometry.h
matrix.h
OpenMEEG
Definition
analytics.h:14
OpenMEEG::tolower
std::string tolower(const std::string &s)
Definition
filenames.h:26
OpenMEEG::getFilenameExtension
std::string getFilenameExtension(const std::string &name)
Definition
filenames.h:18
Generated by
1.17.0