Files
uLib/src/Math/TriangleMesh.h
2026-03-19 13:11:49 +00:00

72 lines
2.2 KiB
C++

/*//////////////////////////////////////////////////////////////////////////////
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
All rights reserved
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3.0 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef TRIANGLEMESH_H
#define TRIANGLEMESH_H
#include <vector>
#include "Math/Dense.h"
#include "Core/Object.h"
#include "Math/Transform.h"
namespace uLib {
class TriangleMesh : public AffineTransform, public Object
{
public:
void PrintSelf(std::ostream &o);
/** @brief Adds a point in global coordinates. Stored in local coordinates. */
void AddPoint(const Vector3f &pt);
void AddTriangle(const Id_t *id);
void AddTriangle(const Vector3i &id);
/** @brief Returns point in global coordinates. */
Vector3f GetPoint(const Id_t id) const;
inline std::vector<Vector3f> & Points() { return this->m_Points; }
inline std::vector<Vector3i> & Triangles() { return this->m_Triangles; }
const Vector3i & GetTriangle(const Id_t id) const { return m_Triangles.at(id); }
Vector3f GetNormal(const Id_t id) const;
virtual void Updated() override { ULIB_SIGNAL_EMIT(TriangleMesh::Updated); }
private:
std::vector<Vector3f> m_Points;
std::vector<Vector3i> m_Triangles;
};
}
#endif // TRIANGLEMESH_H