/*////////////////////////////////////////////////////////////////////////////// // CMT Cosmic Muon Tomography project ////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// Copyright (c) 2014, Universita' degli Studi Padova, INFN sez. di Padova All rights reserved Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it > //////////////////////////////////////////////////////////////////////////////*/ #include "vtkTessellatedSolid.h" #include #include #include namespace uLib { namespace Vtk { TessellatedSolid::TessellatedSolid(Geant::TessellatedSolid *content) : GeantSolid(content), m_TessContent(content) { this->Update(); } TessellatedSolid::~TessellatedSolid() {} void TessellatedSolid::Update() { this->UpdateGeometry(); this->UpdateTransform(); } void TessellatedSolid::UpdateGeometry() { if (!m_TessContent || m_TessContent->GetMesh().Points().empty()) { // Fallback to base tessellation if no model mesh GeantSolid::UpdateGeometry(); return; } const TriangleMesh &mesh = m_TessContent->GetMesh(); vtkNew points; for (const auto& pt : mesh.Points()) { points->InsertNextPoint(pt(0), pt(1), pt(2)); } vtkNew polys; for (const auto& trg : mesh.Triangles()) { vtkIdType ids[3] = { (vtkIdType)trg(0), (vtkIdType)trg(1), (vtkIdType)trg(2) }; polys->InsertNextCell(3, ids); } vtkPolyData *poly = GetPolyData(); if (poly) { poly->SetPoints(points); poly->SetPolys(polys); poly->Modified(); } } } // namespace Vtk } // namespace uLib