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 <string>
18#include <vector>
19
20// Our includes
26#include "EBGeometry_Pool.hpp"
30
31namespace EBGeometry {
32
37namespace Parser {
38
42enum class Encoding
43{
44 ASCII,
45 Binary,
46 Unknown
47};
48
52enum class FileType
53{
54 STL,
55 PLY,
56 VTK,
57 OBJ,
59};
60
66[[nodiscard]] inline static Parser::FileType
67getFileType(const std::string& a_filename);
68
74[[nodiscard]] inline static Parser::Encoding
75getFileEncoding(const std::string& a_filename);
76
86template <typename T>
87[[nodiscard]] PolygonSoup<T>
88readPLY(const std::string& a_filename);
89
97template <typename T>
98[[nodiscard]] std::vector<PolygonSoup<T>>
99readPLY(const std::vector<std::string>& a_filenames);
100
111template <typename T>
112[[nodiscard]] PolygonSoup<T>
113readSTL(const std::string& a_filename);
114
122template <typename T>
123[[nodiscard]] std::vector<PolygonSoup<T>>
124readSTL(const std::vector<std::string>& a_filenames);
125
136template <typename T>
137[[nodiscard]] PolygonSoup<T>
138readOBJ(const std::string& a_filename);
139
147template <typename T>
148[[nodiscard]] std::vector<PolygonSoup<T>>
149readOBJ(const std::vector<std::string>& a_filenames);
150
161template <typename T>
162[[nodiscard]] PolygonSoup<T>
163readVTK(const std::string& a_filename);
164
172template <typename T>
173[[nodiscard]] std::vector<PolygonSoup<T>>
174readVTK(const std::vector<std::string>& a_filenames);
175
183template <typename T>
184[[nodiscard]] inline static PolygonSoup<T>
185readIntoPolygonSoup(const std::string& a_filename);
186
194template <typename T>
195[[nodiscard]] inline static std::vector<PolygonSoup<T>>
196readIntoPolygonSoup(const std::vector<std::string>& a_files);
197
213template <typename T>
214[[nodiscard]] inline static EBGeometry::DCEL::MeshT<T>
215readIntoDCEL(const std::string& a_filename, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
216
226template <typename T>
227[[nodiscard]] inline static std::vector<EBGeometry::DCEL::MeshT<T>>
228readIntoDCEL(const std::vector<std::string>& a_files, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
229
240template <typename T>
241[[nodiscard]] inline static FlatMeshSDF<T>
242readIntoFlatMeshSDF(const std::string& a_filename, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
243
253template <typename T>
254[[nodiscard]] inline static std::vector<FlatMeshSDF<T>>
255readIntoFlatMeshSDF(const std::vector<std::string>& a_files, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
256
270template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
271[[nodiscard]] inline static MeshSDF<T, K>
272readIntoMeshSDF(const std::string& a_filename,
273 Pool& a_pool,
274 const BVH::Construction a_construction = BVH::Construction::SAH,
275 const OnDefect a_onDefect = OnDefect::Throw);
276
290template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
291[[nodiscard]] inline static MeshSDF<T, K>
292readIntoMeshSDF(const std::string& a_filename,
293 Pool& a_pool,
294 const BVH::Construction a_construction,
295 const BVH::ConstructionOptions& a_options,
296 const OnDefect a_onDefect = OnDefect::Throw);
297
309template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
310[[nodiscard]] inline static std::vector<MeshSDF<T, K>>
311readIntoMeshSDF(const std::vector<std::string>& a_files,
312 Pool& a_pool,
313 const BVH::Construction a_construction = BVH::Construction::SAH,
314 const OnDefect a_onDefect = OnDefect::Throw);
315
328template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
329[[nodiscard]] inline static std::vector<MeshSDF<T, K>>
330readIntoMeshSDF(const std::vector<std::string>& a_files,
331 Pool& a_pool,
332 const BVH::Construction a_construction,
333 const BVH::ConstructionOptions& a_options,
334 const OnDefect a_onDefect = OnDefect::Throw);
335
353template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
354[[nodiscard]] inline static TriMeshSDF<T, K, W>
355readIntoTriMeshSDF(const std::string& a_filename,
356 Pool& a_pool,
357 const BVH::Construction a_construction = BVH::Construction::SAH,
358 const OnDefect a_onDefect = OnDefect::Throw);
359
374template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
375[[nodiscard]] inline static TriMeshSDF<T, K, W>
376readIntoTriMeshSDF(const std::string& a_filename,
377 Pool& a_pool,
378 const BVH::Construction a_construction,
379 const BVH::ConstructionOptions& a_options,
380 const OnDefect a_onDefect = OnDefect::Throw);
381
394template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
395[[nodiscard]] inline static std::vector<TriMeshSDF<T, K, W>>
396readIntoTriMeshSDF(const std::vector<std::string>& a_files,
397 Pool& a_pool,
398 const BVH::Construction a_construction = BVH::Construction::SAH,
399 const OnDefect a_onDefect = OnDefect::Throw);
400
414template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
415[[nodiscard]] inline static std::vector<TriMeshSDF<T, K, W>>
416readIntoTriMeshSDF(const std::vector<std::string>& a_files,
417 Pool& a_pool,
418 const BVH::Construction a_construction,
419 const BVH::ConstructionOptions& a_options,
420 const OnDefect a_onDefect = OnDefect::Throw);
421
434template <typename T>
435[[nodiscard]] inline static std::vector<Triangle<T>>
436readIntoTriangles(const std::string& a_filename, const OnDefect a_onDefect = OnDefect::Throw);
437
446template <typename T>
447[[nodiscard]] inline static std::vector<std::vector<Triangle<T>>>
448readIntoTriangles(const std::vector<std::string>& a_files, const OnDefect a_onDefect = OnDefect::Throw);
449} // namespace Parser
450
451} // namespace EBGeometry
452
453#include "EBGeometry_ParserImplem.hpp"
454
455#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 the exception the file readers throw.
Declaration of the polygon soup the file readers return.
Growable bump arena for the GPU memory foundation.
Declaration of a face-id-carrying wrapper around TriangleSoAT.
Declaration of SoA triangle group for SIMD signed-distance evaluation.
Declaration of a triangle class with signed distance functionality.
DCEL mesh class - stores a doubly-connected edge mesh.
Definition EBGeometry_DCEL_Mesh.hpp:102
Signed distance function for a DCEL mesh. Does not use BVHs.
Definition EBGeometry_MeshDistanceFunctions.hpp:79
A FlatMeshSDF must be trivially copyable: that is what lets a rebasedView() be byte-copied into a dev...
Definition EBGeometry_MeshDistanceFunctions.hpp:267
Polygons as a file stores them: vertex coordinates, faces as lists of vertex indices,...
Definition EBGeometry_PolygonSoup.hpp:48
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:188
Signed distance function for a pure triangle mesh using SoA-grouped primitives in a compact (lineariz...
Definition EBGeometry_MeshDistanceFunctions.hpp:551
Construction
The preset BVH construction methods that the library's own BVH users accept.
Definition EBGeometry_PackedBVH.hpp:65
PolygonSoup< T > readOBJ(const std::string &a_filename)
Read a Wavefront OBJ file.
Encoding
Simple enum for separating ASCII and binary files.
Definition EBGeometry_Parser.hpp:43
@ 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:53
@ STL
Stereolithography format (.stl)
@ PLY
Polygon File Format (.ply)
@ VTK
Legacy VTK polydata format (.vtk)
@ Unsupported
File type is not recognized.
@ OBJ
Wavefront OBJ format (.obj)
PolygonSoup< T > readPLY(const std::string &a_filename)
Read a Stanford PLY file, ASCII or binary.
OnDefect
What a file reader does with a mesh whose faces do not form a clean, closed surface.
Definition EBGeometry_ParseError.hpp:89
@ Throw
Throw a ParseError naming the defect. The default.
PolygonSoup< T > readVTK(const std::string &a_filename)
Read a legacy VTK POLYDATA file, ASCII or binary.
PolygonSoup< T > readSTL(const std::string &a_filename)
Read an STL file, ASCII or binary.
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
Leaf-size settings for the preset construction methods, one per family of methods.
Definition EBGeometry_PackedBVH.hpp:115