5 changed files with 74 additions and 230 deletions
@ -1,84 +0,0 @@ |
|||
#pragma once |
|||
|
|||
#include <core.h> |
|||
|
|||
#include <vector> |
|||
#include <cassert> |
|||
|
|||
|
|||
template<typename TScalar, typename TIndex> |
|||
class GenericMesh { |
|||
public: |
|||
using Scalar = TScalar; |
|||
using Index = TIndex; |
|||
using Vector = Eigen::Matrix<Scalar, 3, 1>; |
|||
|
|||
public: |
|||
GenericMesh() = default; |
|||
GenericMesh(const GenericMesh&) = delete; |
|||
GenericMesh(GenericMesh&&) = default; |
|||
~GenericMesh() = default; |
|||
|
|||
GenericMesh& operator=(const GenericMesh&) = delete; |
|||
GenericMesh& operator=(GenericMesh&&) = default; |
|||
|
|||
inline size_t vertexCount() const { |
|||
return m_positions.size(); |
|||
} |
|||
inline size_t indexCount() const { |
|||
return m_indices.size(); |
|||
} |
|||
|
|||
inline void resizeVertex(Index vertexCount) { |
|||
m_positions.resize(vertexCount); |
|||
} |
|||
inline void resizeIndices(Index indexCount) { |
|||
m_indices.resize(indexCount); |
|||
} |
|||
|
|||
inline const Vector& position(Index vertexIndex) const { |
|||
assert(vertexIndex < m_positions.size()); |
|||
return m_positions[vertexIndex]; |
|||
} |
|||
inline Vector& position(Index vertexIndex) { |
|||
assert(vertexIndex < m_positions.size()); |
|||
return m_positions[vertexIndex]; |
|||
} |
|||
|
|||
inline Index index(Index indexIndex) const { |
|||
assert(indexIndex < m_indices.size()); |
|||
return m_indices[indexIndex]; |
|||
} |
|||
inline Index& index(Index indexIndex) { |
|||
assert(indexIndex < m_indices.size()); |
|||
return m_indices[indexIndex]; |
|||
} |
|||
|
|||
inline const Vector* positionData() const { |
|||
return m_positions.data(); |
|||
} |
|||
inline Vector* positionData() { |
|||
return m_positions.data(); |
|||
} |
|||
|
|||
inline const Index* indexData() const { |
|||
return m_indices.data(); |
|||
} |
|||
inline Index* indexData() { |
|||
return m_indices.data(); |
|||
} |
|||
|
|||
inline const std::vector<Vector>& positions() const { |
|||
return m_positions; |
|||
} |
|||
|
|||
inline const std::vector<Index>& indices() const { |
|||
return m_indices; |
|||
} |
|||
|
|||
private: |
|||
std::vector<Vector> m_positions; |
|||
std::vector<Index> m_indices; |
|||
}; |
|||
|
|||
using Mesh = GenericMesh<Real, uint32_t>; |
|||
Loading…
Reference in new issue