78 lines
2.6 KiB
C++
78 lines
2.6 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.
|
|
|
|
//////////////////////////////////////////////////////////////////////////////*/
|
|
|
|
#include "QuadMesh.h"
|
|
|
|
|
|
namespace uLib {
|
|
|
|
void QuadMesh::PrintSelf(std::ostream &o)
|
|
{
|
|
o << " // ------- QUAD MESH ------- // \n" ;
|
|
o << " #Points : " << m_Points.size() << "\n";
|
|
o << " #Quads : " << m_Quads.size() << "\n";
|
|
for(int i=0; i < m_Quads.size(); ++i ) {
|
|
o << " - quad[" << i << "]" <<
|
|
" " << m_Quads[i](0) << "->(" << m_Points[m_Quads[i](0)].transpose() << ") " <<
|
|
" " << m_Quads[i](1) << "->(" << m_Points[m_Quads[i](1)].transpose() << ") " <<
|
|
" " << m_Quads[i](2) << "->(" << m_Points[m_Quads[i](2)].transpose() << ") " <<
|
|
" " << m_Quads[i](3) << "->(" << m_Points[m_Quads[i](3)].transpose() << ") " <<
|
|
" \n";
|
|
}
|
|
o << " // ------------------------- // \n";
|
|
}
|
|
|
|
void QuadMesh::AddPoint(const Vector3f &pt)
|
|
{
|
|
this->m_Points.push_back(pt);
|
|
}
|
|
|
|
void QuadMesh::AddQuad(const Id_t *id)
|
|
{
|
|
Vector4i quad(id[0],id[1],id[2],id[3]);
|
|
this->m_Quads.push_back(quad);
|
|
}
|
|
|
|
void QuadMesh::AddQuad(const Vector4i &id)
|
|
{
|
|
this->m_Quads.push_back(id);
|
|
}
|
|
|
|
Vector3f QuadMesh::GetNormal(const Id_t id) const
|
|
{
|
|
const Vector4i &quad = m_Quads.at(id);
|
|
const Vector3f &v0 = m_Points.at(quad(0));
|
|
const Vector3f &v1 = m_Points.at(quad(1));
|
|
const Vector3f &v3 = m_Points.at(quad(3));
|
|
|
|
Vector3f edge1 = v1 - v0;
|
|
Vector3f edge2 = v3 - v0;
|
|
|
|
return edge1.cross(edge2).normalized();
|
|
}
|
|
|
|
|
|
}
|