EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_Parser.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2022 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
12#ifndef EBGEOMETRY_PARSER_HPP
13#define EBGEOMETRY_PARSER_HPP
14
15// Std includes
16#include <cstddef>
17#include <memory>
18#include <string>
19#include <vector>
20
21// Our includes
25#include "EBGeometry_OBJ.hpp"
26#include "EBGeometry_PLY.hpp"
27#include "EBGeometry_STL.hpp"
31#include "EBGeometry_VTK.hpp"
32
33namespace EBGeometry {
34
39namespace Parser {
40
44enum class Encoding
45{
46 ASCII,
47 Binary,
48 Unknown
49};
50
54enum class FileType
55{
56 STL,
57 PLY,
58 VTK,
59 OBJ,
61};
62
68[[nodiscard]] inline static Parser::FileType
69getFileType(const std::string& a_filename) noexcept;
70
76[[nodiscard]] inline static Parser::Encoding
77getFileEncoding(const std::string& a_filename) noexcept;
78
85template <typename T>
87readPLY(const std::string& a_filename);
88
95template <typename T>
96[[nodiscard]] std::vector<PLY<T>>
97readPLY(const std::vector<std::string>& a_filenames);
98
107template <typename T>
109readSTL(const std::string& a_filename);
110
119template <typename T>
120[[nodiscard]] std::vector<STL<T>>
121readSTL(const std::vector<std::string>& a_filenames);
122
129template <typename T>
131readOBJ(const std::string& a_filename);
132
139template <typename T>
140[[nodiscard]] std::vector<OBJ<T>>
141readOBJ(const std::vector<std::string>& a_filenames);
142
149template <typename T>
151readVTK(const std::string& a_filename);
152
159template <typename T>
160[[nodiscard]] std::vector<VTK<T>>
161readVTK(const std::vector<std::string>& a_filenames);
162
170template <typename T, typename Meta = DCEL::DefaultMetaData>
171[[nodiscard]] inline static std::shared_ptr<EBGeometry::DCEL::MeshT<T, Meta>>
172readIntoDCEL(const std::string a_filename);
173
181template <typename T, typename Meta = DCEL::DefaultMetaData>
182[[nodiscard]] inline static std::vector<std::shared_ptr<EBGeometry::DCEL::MeshT<T, Meta>>>
183readIntoDCEL(const std::vector<std::string>& a_files);
184
192template <typename T, typename Meta = DCEL::DefaultMetaData>
193[[nodiscard]] inline static std::shared_ptr<FlatMeshSDF<T, Meta>>
194readIntoMesh(const std::string a_filename);
195
203template <typename T, typename Meta = DCEL::DefaultMetaData>
204[[nodiscard]] inline static std::vector<std::shared_ptr<FlatMeshSDF<T, Meta>>>
205readIntoMesh(const std::vector<std::string>& a_files);
206
218template <typename T, typename Meta = DCEL::DefaultMetaData, size_t K = 4>
219[[nodiscard]] inline static std::shared_ptr<MeshSDF<T, Meta, K>>
220readIntoPackedBVH(const std::string a_filename, const BVH::Build a_build = BVH::Build::SAH);
221
231template <typename T, typename Meta = DCEL::DefaultMetaData, size_t K = 4>
232[[nodiscard]] inline static std::vector<std::shared_ptr<MeshSDF<T, Meta, K>>>
233readIntoPackedBVH(const std::vector<std::string>& a_files, const BVH::Build a_build = BVH::Build::SAH);
234
256template <typename T,
257 typename Meta = DCEL::DefaultMetaData,
258 size_t K = BVH::DefaultBranchingRatio<T>(),
259 size_t W = TriangleSoA::DefaultWidth<T>(),
261[[nodiscard]] inline static std::shared_ptr<TriMeshSDF<T, Meta, K, W, StoragePolicy>>
262readIntoTriangleBVH(const std::string a_filename,
263 const size_t a_maxLeafGroups = 4,
265
280template <typename T,
281 typename Meta = DCEL::DefaultMetaData,
282 size_t K = BVH::DefaultBranchingRatio<T>(),
283 size_t W = TriangleSoA::DefaultWidth<T>(),
285[[nodiscard]] inline static std::vector<std::shared_ptr<TriMeshSDF<T, Meta, K, W, StoragePolicy>>>
286readIntoTriangleBVH(const std::vector<std::string>& a_files,
287 const size_t a_maxLeafGroups = 4,
289
299template <typename T, typename Meta>
300[[nodiscard]] inline static std::vector<std::shared_ptr<Triangle<T, Meta>>>
301readIntoTriangles(const std::string a_filename);
302
310template <typename T, typename Meta>
311[[nodiscard]] inline static std::vector<std::vector<std::shared_ptr<Triangle<T, Meta>>>>
312readIntoTriangles(const std::vector<std::string>& a_files);
313} // namespace Parser
314
315} // namespace EBGeometry
316
317#include "EBGeometry_ParserImplem.hpp"
318
319#endif
Declarations of bounding volume types used in bounding volume hierarchies.
Declaration of a mesh class which stores a DCEL mesh (with signed distance functions)
Declaration of signed distance functions for DCEL meshes.
Declaration of a class for storing raw Wavefront OBJ file contents.
Declaration of a class for storing raw Stanford PLY file contents.
Declaration of a class for storing raw STL (stereolithography) file contents.
Declaration of a metadata-carrying wrapper around TriangleSoAT.
Declaration of SoA triangle group for SIMD signed-distance evaluation.
Declaration of a triangle class with signed distance functionality.
Declaration of a class for storing raw VTK legacy polydata file contents.
Three-dimensional vector class with arithmetic operators.
Definition EBGeometry_Vec.hpp:225
Build
Enum for specifying the BVH construction strategy.
Definition EBGeometry_BVH.hpp:48
short DefaultMetaData
Default meta-data type for the DCEL primitives.
Definition EBGeometry_DCEL.hpp:28
VTK< T > readVTK(const std::string &a_filename)
Read a single VTK legacy polydata file into a raw VTK data structure.
STL< T > readSTL(const std::string &a_filename)
Read a single STL file into a raw STL data structure.
Encoding
Simple enum for separating ASCII and binary files.
Definition EBGeometry_Parser.hpp:45
@ Binary
File is binary-encoded.
@ Unknown
Encoding could not be determined.
@ ASCII
File is plain text.
FileType
Various supported file types.
Definition EBGeometry_Parser.hpp:55
@ STL
Stereolithography format (.stl)
@ PLY
Polygon File Format (.ply)
@ VTK
VTK legacy or XML polydata format (.vtk)
@ Unsupported
File type is not recognised.
@ OBJ
Wavefront OBJ format (.obj)
OBJ< T > readOBJ(const std::string &a_filename)
Read a single Wavefront OBJ file into a raw OBJ data structure.
PLY< T > readPLY(const std::string &a_filename)
Read a single PLY file into a raw PLY data structure.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_AnalyticDistanceFunctions.hpp:31
Storage policy that stores primitives directly by value, with no pointer indirection at all.
Definition EBGeometry_BVH.hpp:208