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
110template <typename T>
111[[nodiscard]] PolygonSoup<T>
112readSTL(const std::string& a_filename);
113
121template <typename T>
122[[nodiscard]] std::vector<PolygonSoup<T>>
123readSTL(const std::vector<std::string>& a_filenames);
124
134template <typename T>
135[[nodiscard]] PolygonSoup<T>
136readOBJ(const std::string& a_filename);
137
145template <typename T>
146[[nodiscard]] std::vector<PolygonSoup<T>>
147readOBJ(const std::vector<std::string>& a_filenames);
148
159template <typename T>
160[[nodiscard]] PolygonSoup<T>
161readVTK(const std::string& a_filename);
162
170template <typename T>
171[[nodiscard]] std::vector<PolygonSoup<T>>
172readVTK(const std::vector<std::string>& a_filenames);
173
181template <typename T>
182[[nodiscard]] inline static PolygonSoup<T>
183readIntoPolygonSoup(const std::string& a_filename);
184
192template <typename T>
193[[nodiscard]] inline static std::vector<PolygonSoup<T>>
194readIntoPolygonSoup(const std::vector<std::string>& a_files);
195
211template <typename T>
212[[nodiscard]] inline static EBGeometry::DCEL::MeshT<T>
213readIntoDCEL(const std::string& a_filename, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
214
224template <typename T>
225[[nodiscard]] inline static std::vector<EBGeometry::DCEL::MeshT<T>>
226readIntoDCEL(const std::vector<std::string>& a_files, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
227
238template <typename T>
239[[nodiscard]] inline static FlatMeshSDF<T>
240readIntoFlatMeshSDF(const std::string& a_filename, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
241
251template <typename T>
252[[nodiscard]] inline static std::vector<FlatMeshSDF<T>>
253readIntoFlatMeshSDF(const std::vector<std::string>& a_files, Pool& a_pool, const OnDefect a_onDefect = OnDefect::Throw);
254
268template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
269[[nodiscard]] inline static MeshSDF<T, K>
270readIntoMeshSDF(const std::string& a_filename,
271 Pool& a_pool,
272 const BVH::Construction a_construction = BVH::Construction::SAH,
273 const OnDefect a_onDefect = OnDefect::Throw);
274
288template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
289[[nodiscard]] inline static MeshSDF<T, K>
290readIntoMeshSDF(const std::string& a_filename,
291 Pool& a_pool,
292 const BVH::Construction a_construction,
293 const BVH::ConstructionOptions& a_options,
294 const OnDefect a_onDefect = OnDefect::Throw);
295
307template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
308[[nodiscard]] inline static std::vector<MeshSDF<T, K>>
309readIntoMeshSDF(const std::vector<std::string>& a_files,
310 Pool& a_pool,
311 const BVH::Construction a_construction = BVH::Construction::SAH,
312 const OnDefect a_onDefect = OnDefect::Throw);
313
326template <typename T, size_t K = BVH::DefaultBranchingRatio<T>()>
327[[nodiscard]] inline static std::vector<MeshSDF<T, K>>
328readIntoMeshSDF(const std::vector<std::string>& a_files,
329 Pool& a_pool,
330 const BVH::Construction a_construction,
331 const BVH::ConstructionOptions& a_options,
332 const OnDefect a_onDefect = OnDefect::Throw);
333
351template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
352[[nodiscard]] inline static TriMeshSDF<T, K, W>
353readIntoTriMeshSDF(const std::string& a_filename,
354 Pool& a_pool,
355 const BVH::Construction a_construction = BVH::Construction::SAH,
356 const OnDefect a_onDefect = OnDefect::Throw);
357
372template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
373[[nodiscard]] inline static TriMeshSDF<T, K, W>
374readIntoTriMeshSDF(const std::string& a_filename,
375 Pool& a_pool,
376 const BVH::Construction a_construction,
377 const BVH::ConstructionOptions& a_options,
378 const OnDefect a_onDefect = OnDefect::Throw);
379
392template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
393[[nodiscard]] inline static std::vector<TriMeshSDF<T, K, W>>
394readIntoTriMeshSDF(const std::vector<std::string>& a_files,
395 Pool& a_pool,
396 const BVH::Construction a_construction = BVH::Construction::SAH,
397 const OnDefect a_onDefect = OnDefect::Throw);
398
412template <typename T, size_t K = BVH::DefaultBranchingRatio<T>(), size_t W = TriangleSoA::DefaultWidth<T>()>
413[[nodiscard]] inline static std::vector<TriMeshSDF<T, K, W>>
414readIntoTriMeshSDF(const std::vector<std::string>& a_files,
415 Pool& a_pool,
416 const BVH::Construction a_construction,
417 const BVH::ConstructionOptions& a_options,
418 const OnDefect a_onDefect = OnDefect::Throw);
419
432template <typename T>
433[[nodiscard]] inline static std::vector<Triangle<T>>
434readIntoTriangles(const std::string& a_filename, const OnDefect a_onDefect = OnDefect::Throw);
435
444template <typename T>
445[[nodiscard]] inline static std::vector<std::vector<Triangle<T>>>
446readIntoTriangles(const std::vector<std::string>& a_files, const OnDefect a_onDefect = OnDefect::Throw);
447} // namespace Parser
448
449} // namespace EBGeometry
450
451#include "EBGeometry_ParserImplem.hpp"
452
453#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:100
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:249
Polygons as a file stores them: vertex coordinates, faces as lists of vertex indices,...
Definition EBGeometry_PolygonSoup.hpp:47
Growable bump arena over a MemoryResource.
Definition EBGeometry_Pool.hpp:183
Signed distance function for a pure triangle mesh using SoA-grouped primitives in a compact (lineariz...
Definition EBGeometry_MeshDistanceFunctions.hpp:514
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