Input#

Overview#

The Polyhedral Gravity Model comes with multiple ways of processing input. In general, there are is one abstract interface ConfigSource to specify a model evaluation. Its implementation is realized in the class YAMLConfigReader.

The file input is delegated from the YAMLConfigReader to the functions in the namespace MeshReader which vice-versa delegates calls to Tetgen’s file formats to the TetgenAdapter.

Configuration Input#

class ConfigSource#

Interface defining methods giving the calculation some input. This includes the points of interest as well as the source of the data.

Subclassed by polyhedralGravity::YAMLConfigReader

Public Functions

virtual ~ConfigSource() = default#

Default Virtual Destructor

virtual std::string getOutputFileName() = 0#

Returns the specified output file name.

Returns:

a std::string with the filename

virtual double getDensity() = 0#

Returns the constant density rho of the given polyhedron. The unit must match to the mesh, e.g., mesh in \([m]\) requires density in \([kg/m^3]\). The density is required for the calculation.

Returns:

density as double

virtual std::vector<std::array<double, 3>> getPointsOfInterest() = 0#

The vector contains the points for which the polyhedral gravity model should be evaluated.

Returns:

vector of points

virtual bool getMeshInputCheckStatus() = 0#

Returns the activation status of the input polyhedron mesh sanity check.

Returns:

true if enabled

virtual PolyhedralSource getPolyhedralSource() = 0#

The source structure of a Polyhedron consisting of vertices and faces

Returns:

a polyhedral source consisting of vertices and faces

virtual MetricUnit getMeshUnit() = 0#

Returns the unit of measurement used for the polyhedron mesh. This specifies the physical unit in which the mesh dimensions are defined. Could be metric units such as meters, kilometers, or unitless.

Returns:

the unit of the polyhedral mesh as a MetricUnit enum

class YAMLConfigReader : public polyhedralGravity::ConfigSource#

A class to read configuration parameters from a YAML file. Provides methods to fetch specific configuration data such as density, computation points, mesh check status, and output file details.

Public Functions

inline explicit YAMLConfigReader(const std::string &filename)#

Creates a new YAML Config Reader.

Parameters:

filename – a reference to a string

Throws:

an – exception if the file is malformed or cannot be loaded or if the ROOT node is not found

inline explicit YAMLConfigReader(std::string &&filename)#

Creates a new YAML Config Reader.

Parameters:

filename – a movable string

Throws:

an – exception if the file is malformed or cannot be loaded or if the ROOT node is not found

virtual std::string getOutputFileName() override#

Returns the specified output filename. If none is specified an empty string will be returned.

Returns:

a filename a std::string or an empty string if none is specified

virtual double getDensity() override#

Reads the density from the yaml configuration file.

Returns:

density as double

virtual std::vector<std::array<double, 3>> getPointsOfInterest() override#

Reads the computation points from the yaml configuration file.

Returns:

vector of computation points

virtual bool getMeshInputCheckStatus() override#

Reads the enablement of the input sanity check from the yaml file.

Returns:

true or false if explicitly enabled, otherwise per-default true

virtual std::tuple<std::vector<Array3>, std::vector<IndexArray3>> getPolyhedralSource() override#

Reads the DataSource from the yaml configuration file.

Returns:

shared_ptr to the DataSource Object created

virtual MetricUnit getMeshUnit() override#

Retrieves the metric unit of the mesh as specified in the configuration. Can return meter, kilometer, or unitless depending on the configuration data.

Returns:

the metric unit of the mesh as an instance of MetricUnit (if not present defaults to meter)

Mesh File Input#

namespace MeshReader#

Namespace containing various mesh reading functionalities

Functions

PolyhedralSource getPolyhedralSource(const std::vector<std::string> &fileNames)#

Returns a polyhedral source consisting of vertices and faces by reading mesh input files.

Parameters:

fileNames – files specifying a polyhedron

Throws:

std::invalid_argument – exception if the file type is unsupported by the implementation

Returns:

polyhedral source consisting of vertices and faces

PolyhedralSource readObj(const std::string &filename)#

Reads elements from a .obj file (Wavefront OBJ file format) This method only supports vertex (v) and faces (f) as input.

This is also the file format of polyhedrons in some datasets, e.g.,in https://pds.nasa.gov/ds-view/pds/viewDataset.jsp?dsid=EAR-A-5-DDR-RADARSHAPE-MODELS-V2.0 However, the suffix for these files is .tab

See also

Refer to https://de.wikipedia.org/wiki/Wavefront_OBJ for further help with the format

Parameters:

filename – of the input source without suffix

PolyhedralSource readTetgenFormat(const std::vector<std::string> &fileNames)#

Reads elements from a file format supported by Tegen (.node/.face, .off, .ply, .stl, .mesh)

Delegates the processing to a TetgenAdapter.

Parameters:

fileNames – two files (.node/.face) or one file supported by Tetgen

Returns:

Polyhedral Source consisting of vertices and faces

class TetgenAdapter#

An adapter to the Tetgen Library. This is the interface between tetgen’s data structures and I/O capabilities and the here implemented polyhedral gravity model. The adapter always converts tetgen’s data structure into the structure utilized by the Polyhedral Gravity Model.

The Adapter further keeps en eye on the already read-in files in order to give feedback if data is in conflict.

Public Functions

explicit TetgenAdapter(const std::vector<std::string> &fileNames)#

Constructs a new TetgenAdapter from a vector of filenames. These filenames should end on the supported suffixes

Parameters:

fileNames – vector of filenames

PolyhedralSource getPolyhedralSource()#

Use this function to get a Polyhedron. This function consists of two steps. First, the Adapter will delegate I/O to the tetgen library and read in the Polyhedron data in the library’s data structure. Second, tetgen’s data structure is then converted to a Polyhedron.

Throws:

std::invalid_argument – exception in case the filetype is not supported!

Returns:

a Polyhedron

void readNode(const std::string &filename)#

Reads nodes from a .node file

Parameters:

filename – of the input source without suffix

Throws:

an – exception if the nodes already have been defined

void readFace(const std::string &filename)#

Reads faces from a .face file

Parameters:

filename – of the input source without suffix

Throws:

an – exception if the faces already have been defined

void readOff(const std::string &filename)#

Reads elements from a .off file (Geomview’s polyhedral file format)

Parameters:

filename – of the input source without suffix

Throws:

an – exception if the elements already have been defined

void readPly(const std::string &filename)#

Reads elements from a .ply file (Polyhedral file format)

Parameters:

filename – of the input source without suffix

Throws:

an – exception if the elements already have been defined

void readStl(const std::string &filename)#

Reads elements from a .stl file (Stereolithography format)

Parameters:

filename – of the input source without suffix

Throws:

an – exception if the elements already have been defined

void readMesh(const std::string &filename)#

Reads elements from a .mesh file (Medit’s mesh file format)

Parameters:

filename – of the input source without suffix

Throws:

an – exception if the elements already have been defined