opatIO-cpp 0.3.0a
Open Parametrized Array Table
Loading...
Searching...
No Matches
tableLattice.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5#include <utility>
6
7#include "opatIO.h"
8#include "indexVector.h"
9
10#include <boost/numeric/ublas/matrix.hpp>
11#include <boost/numeric/ublas/vector.hpp>
12
16namespace opat::lattice {
17
21 typedef boost::numeric::ublas::matrix<double> bmat;
25 typedef boost::numeric::ublas::vector<double> bvec;
26
38 struct Simplex {
39 std::size_t ID = static_cast<std::size_t>(-1);
40 std::vector<double> barycentricWeights;
41 };
42
51
111 public:
129 explicit TableLattice(const opat::OPAT& opat);
151 TableLattice(const opat::OPAT& opat, const InterpolationType& interpolationType);
152
153 TableLattice(const TableLattice&) = default;
155 TableLattice(TableLattice&&) noexcept = default;
156 TableLattice& operator=(TableLattice&&) noexcept = delete;
157 ~TableLattice() = default;
158
191 [[nodiscard]] DataCard get(const FloatIndexVector& indexVector) const;
196 [[nodiscard]] InterpolationType getInterpolationType() const;
197
211 void setInterpolationType(InterpolationType interpolationType);
212
232 void dumpTriangulationToAscii(const std::string &points_file, const std::string &simplices_file) const;
233 private:
234 const opat::OPAT &m_opat;
237 std::vector<FloatIndexVector> m_indexVectors;
238 std::vector<std::vector<double>> m_axisValues;
239 std::size_t m_numCorners{};
240 std::vector<std::vector<std::size_t>> m_simplices;
241 std::vector<std::vector<std::size_t>> m_simplexAdjacency;
242
250 void initialize();
251
265 void buildDelaunay();
288 [[nodiscard]] Simplex findContainingSimplex(const FloatIndexVector& indexVector) const;
289
310 void validateIndexVector(const FloatIndexVector &indexVector) const;
311
331 std::vector<double> calculateBarycentricWeights(const FloatIndexVector& queryPoint, const std::vector<FloatIndexVector>& simplexActualVertices) const;
332
334
335 };
336
363}
Definition indexVector.h:38
void dumpTriangulationToAscii(const std::string &points_file, const std::string &simplices_file) const
Dumps the Delaunay triangulation to ASCII files.
Definition tableLattice.cpp:486
void initialize()
Initializes the TableLattice internal structures.
Definition tableLattice.cpp:43
void validateIndexVector(const FloatIndexVector &indexVector) const
Validates if the given index vector is within the global bounds of the table and has the correct dime...
Definition tableLattice.cpp:326
const opat::OPAT & m_opat
Reference to the OPAT object.
Definition tableLattice.h:234
TableLattice(const opat::OPAT &opat)
Constructs a TableLattice object from an OPAT object.
Definition tableLattice.cpp:29
void buildDelaunay()
Builds the Delaunay triangulation of the index vectors.
Definition tableLattice.cpp:56
std::vector< FloatIndexVector > m_indexVectors
Stores all unique index vectors from the OPAT file, serving as the vertices of the triangulation.
Definition tableLattice.h:237
InterpolationType m_interpolationType
The type of interpolation to use.
Definition tableLattice.h:236
std::size_t m_indexVectorSize
The dimensionality of the index vectors.
Definition tableLattice.h:235
Simplex findContainingSimplex(const FloatIndexVector &indexVector) const
Finds the simplex containing the given index vector using a walk algorithm.
Definition tableLattice.cpp:152
DataCard get(const FloatIndexVector &indexVector) const
Retrieves interpolated data for a given index vector.
Definition tableLattice.cpp:426
std::vector< std::vector< double > > m_axisValues
Stores the unique values for each axis/dimension (Not currently used by Delaunay approach).
Definition tableLattice.h:238
std::size_t m_numCorners
The number of corners in a hypercube (2^m_indexVectorSize), relevant for hypercube-based approaches (...
Definition tableLattice.h:239
void setInterpolationType(InterpolationType interpolationType)
Sets the interpolation type.
Definition tableLattice.cpp:479
Simplex m_lastFoundSimplex
Stores the last found simplex (ID and barycentric weights) as a starting point for the findContaining...
Definition tableLattice.h:333
std::vector< std::vector< std::size_t > > m_simplices
Stores the simplices of the Delaunay triangulation. Each inner vector is a list of global vertex indi...
Definition tableLattice.h:240
TableLattice(const TableLattice &)=default
TableLattice(TableLattice &&) noexcept=default
std::vector< std::vector< std::size_t > > m_simplexAdjacency
Adjacency list for simplices. m_simplexAdjacency[i][j] stores the ID of the simplex adjacent to simpl...
Definition tableLattice.h:241
TableLattice & operator=(const TableLattice &)=delete
std::vector< double > calculateBarycentricWeights(const FloatIndexVector &queryPoint, const std::vector< FloatIndexVector > &simplexActualVertices) const
Calculates the barycentric weights of a query point with respect to the vertices of a given simplex.
Definition tableLattice.cpp:350
InterpolationType getInterpolationType() const
Gets the current interpolation type.
Definition tableLattice.cpp:475
Header file defining the FloatIndexVector class for handling floating-point index vectors.
Namespace for table lattice interpolation of OPAT files.
Definition tableLattice.cpp:28
boost::numeric::ublas::vector< double > bvec
Typedef for a Boost uBLAS vector of doubles.
Definition tableLattice.h:25
InterpolationType
Defines the type of interpolation to be used.
Definition tableLattice.h:46
@ Linear
Linear interpolation.
Definition tableLattice.h:47
@ Quadratic
Quadratic interpolation (Not yet implemented).
Definition tableLattice.h:48
@ Cubic
Cubic interpolation (Not yet implemented).
Definition tableLattice.h:49
boost::numeric::ublas::matrix< double > bmat
Typedef for a Boost uBLAS matrix of doubles.
Definition tableLattice.h:21
bvec solveLinearSystem(bmat A, bvec b)
Solves a linear system of equations Ax = b.
Definition tableLattice.cpp:517
Definition opatIO.cpp:37
Specialization of std::hash for FloatIndexVector.
Header file for the OPAT I/O library, providing structures and functions for reading and manipulating...
Structure to hold a DataCard, which contains multiple tables.
Definition opatIO.h:409
Structure to hold the entire OPAT file.
Definition opatIO.h:502
Represents a simplex containing a point, along with barycentric weights.
Definition tableLattice.h:38
std::vector< double > barycentricWeights
Barycentric weights of the point within this simplex.
Definition tableLattice.h:40
std::size_t ID
The ID of the simplex in the triangulation. Defaults to an invalid ID.
Definition tableLattice.h:39