EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Enumerations | Functions
EBGeometry::Parser Namespace Reference

Namespace which encapsulates possible file parsers for building EBGeometry data structures. More...

Classes

class  ParseError
 Thrown by the file readers, and by PolygonSoup::clean() and convertToDCEL(), when a file cannot be read into a mesh. More...
 

Enumerations

enum class  OnDefect { Throw , Warn }
 What a file reader does with a mesh whose faces do not form a clean, closed surface. More...
 
enum class  Encoding { ASCII , Binary , Unknown }
 Simple enum for separating ASCII and binary files. More...
 
enum class  FileType {
  STL , PLY , VTK , OBJ ,
  Unsupported
}
 Various supported file types. More...
 

Functions

template<typename T >
PolygonSoup< T > readPLY (const std::string &a_filename)
 Read a Stanford PLY file, ASCII or binary.
 
template<typename T >
std::vector< PolygonSoup< T > > readPLY (const std::vector< std::string > &a_filenames)
 Read several Stanford PLY files.
 
template<typename T >
PolygonSoup< T > readSTL (const std::string &a_filename)
 Read an STL file, ASCII or binary.
 
template<typename T >
std::vector< PolygonSoup< T > > readSTL (const std::vector< std::string > &a_filenames)
 Read several STL files.
 
template<typename T >
PolygonSoup< T > readOBJ (const std::string &a_filename)
 Read a Wavefront OBJ file.
 
template<typename T >
std::vector< PolygonSoup< T > > readOBJ (const std::vector< std::string > &a_filenames)
 Read several Wavefront OBJ files.
 
template<typename T >
PolygonSoup< T > readVTK (const std::string &a_filename)
 Read a legacy VTK POLYDATA file, ASCII or binary.
 
template<typename T >
std::vector< PolygonSoup< T > > readVTK (const std::vector< std::string > &a_filenames)
 Read several legacy VTK POLYDATA files.
 

Detailed Description

Namespace which encapsulates possible file parsers for building EBGeometry data structures.

Enumeration Type Documentation

◆ Encoding

enum class EBGeometry::Parser::Encoding
strong

Simple enum for separating ASCII and binary files.

Enumerator
ASCII 

File is plain text.

Binary 

File is binary-encoded.

Unknown 

Encoding could not be determined.

◆ FileType

enum class EBGeometry::Parser::FileType
strong

Various supported file types.

Enumerator
STL 

Stereolithography format (.stl)

PLY 

Polygon File Format (.ply)

VTK 

Legacy VTK polydata format (.vtk)

OBJ 

Wavefront OBJ format (.obj)

Unsupported 

File type is not recognized.

◆ OnDefect

enum class EBGeometry::Parser::OnDefect
strong

What a file reader does with a mesh whose faces do not form a clean, closed surface.

Covers the defects a reader can survive: neighboring faces oriented inconsistently, an edge shared by three or more faces, and faces that fold back onto each other. Such a mesh loads and gives correct distances, but the sign of the distance near the defect is unreliable. Faults that would corrupt the half-edge mesh itself (an index out of range, a non-finite coordinate, a face that visits a vertex twice) always throw. Holes are never a defect.

Enumerator
Throw 

Throw a ParseError naming the defect. The default.

Warn 

Print a warning to std::cerr and load the mesh anyway.

Function Documentation

◆ readOBJ() [1/2]

template<typename T >
PolygonSoup< T > EBGeometry::Parser::readOBJ ( const std::string &  a_filename)

Read a Wavefront OBJ file.

Only the vertices and faces are read; texture coordinates, normals, groups and materials are ignored. A face record with fewer than three vertices is not a face.

Template Parameters
TFloating-point precision for vertex coordinates.
Parameters
[in]a_filenameOBJ file name.
Returns
The soup, cleaned (see PolygonSoup::clean()).
Exceptions
ParseErrorif the file cannot be read or is malformed.

◆ readOBJ() [2/2]

template<typename T >
std::vector< PolygonSoup< T > > EBGeometry::Parser::readOBJ ( const std::vector< std::string > &  a_filenames)

Read several Wavefront OBJ files.

Template Parameters
TFloating-point precision for vertex coordinates.
Parameters
[in]a_filenamesOBJ file names.
Returns
One cleaned soup per file.
Exceptions
ParseErrorif any of the files cannot be read or is malformed.

◆ readPLY() [1/2]

template<typename T >
PolygonSoup< T > EBGeometry::Parser::readPLY ( const std::string &  a_filename)

Read a Stanford PLY file, ASCII or binary.

The scalar vertex properties other than x, y and z, and the scalar face properties, are kept as the soup's properties.

Template Parameters
TFloating-point precision for vertex coordinates and properties.
Parameters
[in]a_filenamePLY file name.
Returns
The soup, cleaned (see PolygonSoup::clean()).
Exceptions
ParseErrorif the file cannot be read or is malformed.

◆ readPLY() [2/2]

template<typename T >
std::vector< PolygonSoup< T > > EBGeometry::Parser::readPLY ( const std::vector< std::string > &  a_filenames)

Read several Stanford PLY files.

Template Parameters
TFloating-point precision for vertex coordinates and properties.
Parameters
[in]a_filenamesPLY file names.
Returns
One cleaned soup per file.
Exceptions
ParseErrorif any of the files cannot be read or is malformed.

◆ readSTL() [1/2]

template<typename T >
PolygonSoup< T > EBGeometry::Parser::readSTL ( const std::string &  a_filename)

Read an STL file, ASCII or binary.

The facet normals in the file are ignored. If the file holds several solids (uncommon, but allowed), only the first is read.

Template Parameters
TFloating-point precision for vertex coordinates.
Parameters
[in]a_filenameSTL file name.
Returns
The soup, cleaned (see PolygonSoup::clean()).
Exceptions
ParseErrorif the file cannot be read or is malformed.

◆ readSTL() [2/2]

template<typename T >
std::vector< PolygonSoup< T > > EBGeometry::Parser::readSTL ( const std::vector< std::string > &  a_filenames)

Read several STL files.

Template Parameters
TFloating-point precision for vertex coordinates.
Parameters
[in]a_filenamesSTL file names.
Returns
One cleaned soup per file.
Exceptions
ParseErrorif any of the files cannot be read or is malformed.

◆ readVTK() [1/2]

template<typename T >
PolygonSoup< T > EBGeometry::Parser::readVTK ( const std::string &  a_filename)

Read a legacy VTK POLYDATA file, ASCII or binary.

The first component of each POINT_DATA and CELL_DATA scalar array is kept as a vertex or face property. An array with a different number of values than there are points or polygons (as when CELL_DATA also covers lines or vertices) is dropped with a warning.

Template Parameters
TFloating-point precision for vertex coordinates and properties.
Parameters
[in]a_filenameVTK file name.
Returns
The soup, cleaned (see PolygonSoup::clean()).
Exceptions
ParseErrorif the file cannot be read or is malformed.

◆ readVTK() [2/2]

template<typename T >
std::vector< PolygonSoup< T > > EBGeometry::Parser::readVTK ( const std::vector< std::string > &  a_filenames)

Read several legacy VTK POLYDATA files.

Template Parameters
TFloating-point precision for vertex coordinates and properties.
Parameters
[in]a_filenamesVTK file names.
Returns
One cleaned soup per file.
Exceptions
ParseErrorif any of the files cannot be read or is malformed.