SPH
MeshFile.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "io/Path.h"
8 #include "post/Mesh.h"
9 
11 
13 class IMeshFile : public Polymorphic {
14 public:
15  virtual Outcome save(const Path& path, ArrayView<const Triangle> triangles) = 0;
16 
17  virtual Expected<Array<Triangle>> load(const Path& path) = 0;
18 };
19 
23 class PlyFile : public IMeshFile {
24 public:
25  virtual Outcome save(const Path& path, ArrayView<const Triangle> triangles) override;
26 
27  virtual Expected<Array<Triangle>> load(const Path& path) override;
28 };
29 
33 class TabFile : public IMeshFile {
34 private:
35  Float lengthUnit;
36 
37 public:
39  explicit TabFile(const Float lengthUnit = 1.e3_f);
40 
41  virtual Outcome save(const Path& path, ArrayView<const Triangle> triangles) override;
42 
43  virtual Expected<Array<Triangle>> load(const Path& path) override;
44 };
45 
47 class ObjFile : public IMeshFile {
48 public:
49  virtual Outcome save(const Path& path, ArrayView<const Triangle> triangles) override;
50 
51  virtual Expected<Array<Triangle>> load(const Path& path) override;
52 };
53 
56 
Simplified implementation of std::unique_ptr, using only default deleter.
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
Wrapper of type containing either a value or an error message.
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
AutoPtr< IMeshFile > getMeshFile(const Path &path)
Deduces mesh type from extension of given path.
Definition: MeshFile.cpp:212
#define NAMESPACE_SPH_END
Definition: Object.h:12
Helper object defining permutation.
Return value of function that may fail, containing either SUCCEES (true) or error message.
Object representing a path on a filesystem, similar to std::filesystem::path in c++17.
Object providing safe access to continuous memory of data.
Definition: ArrayView.h:17
Wrapper of pointer that deletes the resource from destructor.
Definition: AutoPtr.h:15
Wrapper of type that either contains a value of given type, or an error message.
Definition: Expected.h:25
Interface for mesh exporters.
Definition: MeshFile.h:13
virtual Outcome save(const Path &path, ArrayView< const Triangle > triangles)=0
virtual Expected< Array< Triangle > > load(const Path &path)=0
Text format containing mesh vertices (prefixed by 'v') and triangle indices (prefixed by 'f')
Definition: MeshFile.h:47
virtual Expected< Array< Triangle > > load(const Path &path) override
Definition: MeshFile.cpp:185
virtual Outcome save(const Path &path, ArrayView< const Triangle > triangles) override
Definition: MeshFile.cpp:179
Object representing a path on a filesystem.
Definition: Path.h:17
Exports meshes into a Polygon File Format (.ply file).
Definition: MeshFile.h:23
virtual Expected< Array< Triangle > > load(const Path &path) override
Definition: MeshFile.cpp:51
virtual Outcome save(const Path &path, ArrayView< const Triangle > triangles) override
Definition: MeshFile.cpp:7
Simple text format containing mesh vertices and triangle indices.
Definition: MeshFile.h:33
virtual Expected< Array< Triangle > > load(const Path &path) override
Definition: MeshFile.cpp:147
virtual Outcome save(const Path &path, ArrayView< const Triangle > triangles) override
Definition: MeshFile.cpp:141
TabFile(const Float lengthUnit=1.e3_f)
Definition: MeshFile.cpp:138
Base class for all polymorphic objects.
Definition: Object.h:88