VPTissue Reference Manual
Hdf5Exporter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 Universiteit Antwerpen
3  *
4  * Licensed under the EUPL, Version 1.1 or as soon they will be approved by
5  * the European Commission - subsequent versions of the EUPL (the "Licence");
6  * You may not use this work except in compliance with the Licence.
7  * You may obtain a copy of the Licence at: http://ec.europa.eu/idabc/eupl5
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the Licence is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the Licence for the specific language governing
13  * permissions and limitations under the Licence.
14  */
20 #include "../../cpp_simptshell/exporters/Hdf5Exporter.h"
21 
22 #include "fileformats/Hdf5File.h"
23 #include "sim/Sim.h"
24 
25 #include <fstream>
26 
27 namespace SimPT_Shell {
28 
29 using namespace std;
30 using SimPT_Sim::Sim;
31 
32 bool Hdf5Exporter::Export(shared_ptr<Sim> sim, const string& file_path, bool overwrite)
33 {
34  if (!overwrite && ifstream(file_path).good()) {
35  return false;
36  }
37 
38  bool status = false;
39  Hdf5File file(file_path);
40  if (file.IsOpen()) {
41  file.Write(sim);
42  status = file.Close();
43  }
44  return status;
45 }
46 
48 {
49  return "h5";
50 }
51 
52 
53 } // namespace
STL namespace.
Simulator: mesh & parameters, model & algorithms.
Definition: Sim.h:50
void Write(std::shared_ptr< const SimPT_Sim::Sim > sim)
Writes the mesh state to the HDF5 file currently associated with exporter object. ...
Definition: Hdf5File.cpp:1134
Namespace for SimPT shell package.
Definition: Client.cpp:50
static bool Export(std::shared_ptr< SimPT_Sim::Sim > mesh, std::string const &file_path, bool overwrite=true)
Export mesh state to hdf5 format.
Interface for VirtualLeaf::Hdf5File.
Contains facilities for storing the simulation Mesh to HDF5 files.
Definition: Hdf5File.h:38
bool IsOpen()
Returns true if exporter is associated with a HDF5 file that has been successfully opened...
Definition: Hdf5File.cpp:339
Sim, the actual simulator.
bool Close()
Closes the HDF5 file associated with exporter, dissociates it from this exporter object and returns t...
Definition: Hdf5File.cpp:318
static std::string GetFileExtension()
File extension associated with this export format.