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"
30#include "EBGeometry_VTK.hpp"
31
32namespace EBGeometry {
33
38namespace Parser {
39
43enum class Encoding
44{
45 ASCII,
46 Binary,
47 Unknown
48};
49
53enum class FileType
54{
55 STL,
56 PLY,
57 VTK,
58 OBJ,
60};
61
67[[nodiscard]] inline static Parser::FileType
68getFileType(const std::string& a_filename) noexcept;
69
75[[nodiscard]] inline static Parser::Encoding
76getFileEncoding(const std::string& a_filename) noexcept;
77
84template <typename T>
86readPLY(const std::string& a_filename);
87
94template <typename T>
95[[nodiscard]] std::vector<PLY<T>>
96readPLY(const std::vector<std::string>& a_filenames);
97
106template <typename T>
108readSTL(const std::string& a_filename);
109
118template <typename T>
119[[nodiscard]] std::vector<STL<T>>
120readSTL(const std::vector<std::string>& a_filenames);
121
128template <typename T>
130readOBJ(const std::string& a_filename);
131
138template <typename T>
139[[nodiscard]] std::vector<OBJ<T>>
140readOBJ(const std::vector<std::string>& a_filenames);
141
148template <typename T>
150readVTK(const std::string& a_filename);
151
158template <typename T>
159[[nodiscard]] std::vector<VTK<T>>
160readVTK(const std::vector<std::string>& a_filenames);
161
169template <typename T, typename Meta = DCEL::DefaultMetaData>
170[[nodiscard]] inline static std::shared_ptr<EBGeometry::DCEL::MeshT<T, Meta>>
171readIntoDCEL(const std::string a_filename);
172
180template <typename T, typename Meta = DCEL::DefaultMetaData>
181[[nodiscard]] inline static std::vector<std::shared_ptr<EBGeometry::DCEL::MeshT<T, Meta>>>
182readIntoDCEL(const std::vector<std::string>& a_files);
183
191template <typename T, typename Meta = DCEL::DefaultMetaData>
192[[nodiscard]] inline static std::shared_ptr<FlatMeshSDF<T, Meta>>
193readIntoMesh(const std::string a_filename);
194
202template <typename T, typename Meta = DCEL::DefaultMetaData>
203[[nodiscard]] inline static std::vector<std::shared_ptr<FlatMeshSDF<T, Meta>>>
204readIntoMesh(const std::vector<std::string>& a_files);
205
217template <typename T, typename Meta = DCEL::DefaultMetaData, size_t K = 4>
218[[nodiscard]] inline static std::shared_ptr<MeshSDF<T, Meta, K>>
219readIntoPackedBVH(const std::string a_filename, const BVH::Build a_build = BVH::Build::SAH);
220
230template <typename T, typename Meta = DCEL::DefaultMetaData, size_t K = 4>
231[[nodiscard]] inline static std::vector<std::shared_ptr<MeshSDF<T, Meta, K>>>
232readIntoPackedBVH(const std::vector<std::string>& a_files, const BVH::Build a_build = BVH::Build::SAH);
233
255template <typename T,
256 typename Meta = DCEL::DefaultMetaData,
257 size_t K = BVH::DefaultBranchingRatio<T>(),
258 size_t W = TriangleSoA::DefaultWidth<T>(),
260[[nodiscard]] inline static std::shared_ptr<TriMeshSDF<T, Meta, K, W, StoragePolicy>>
261readIntoTriangleBVH(const std::string a_filename,
262 const size_t a_maxLeafGroups = 4,
264
279template <typename T,
280 typename Meta = DCEL::DefaultMetaData,
281 size_t K = BVH::DefaultBranchingRatio<T>(),
282 size_t W = TriangleSoA::DefaultWidth<T>(),
284[[nodiscard]] inline static std::vector<std::shared_ptr<TriMeshSDF<T, Meta, K, W, StoragePolicy>>>
285readIntoTriangleBVH(const std::vector<std::string>& a_files,
286 const size_t a_maxLeafGroups = 4,
288
298template <typename T, typename Meta>
299[[nodiscard]] inline static std::vector<std::shared_ptr<Triangle<T, Meta>>>
300readIntoTriangles(const std::string a_filename);
301
309template <typename T, typename Meta>
310[[nodiscard]] inline static std::vector<std::vector<std::shared_ptr<Triangle<T, Meta>>>>
311readIntoTriangles(const std::vector<std::string>& a_files);
312} // namespace Parser
313
314} // namespace EBGeometry
315
316#include "EBGeometry_ParserImplem.hpp"
317
318#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 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:44
@ 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:54
@ 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