switch to git no-history version

This commit is contained in:
AndreaRigoni
2018-04-17 15:39:10 +02:00
commit b14311ce09
274 changed files with 27340 additions and 0 deletions

39
src/Vtk/CMakeLists.txt Normal file
View File

@@ -0,0 +1,39 @@
set(HEADERS
uLibVtkInterface.h
uLibVtkViewer.h
vtkContainerBox.h
vtkMuonScatter.h
vtkStructuredGrid.h
vtkVoxRaytracerRepresentation.h
vtkVoxImage.h
# vtkHLineRepresentation.h
# vtkTriangleMesh.h
)
SET(SOURCES
uLibVtkInterface.cxx
uLibVtkViewer.cpp
vtkContainerBox.cpp
vtkMuonScatter.cxx
vtkStructuredGrid.cpp
vtkVoxRaytracerRepresentation.cpp
vtkVoxImage.cpp
)
set(LIBRARIES
${Boost_SERIALIZATION_LIBRARY}
${Boost_SIGNALS_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Eigen_LIBRARY}
${ROOT_LIBRARIES}
${Geant4_LIBRARIES}
${VTK_LIBRARIES}
${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Math
${PACKAGE_LIBPREFIX}Detectors
${PACKAGE_LIBPREFIX}Vtk
)
uLib_add_shared_library(${uLib-module})
add_subdirectory(testing)

34
src/Vtk/Makefile.am Normal file
View File

@@ -0,0 +1,34 @@
SUBDIRS = .
include $(top_srcdir)/Common.am
include Vtk.am
library_includedir = $(includedir)/libmutom-${PACKAGE_VERSION}/Vtk
library_include_HEADERS = uLibVtkInterface.h \
uLibVtkViewer.h \
vtkContainerBox.h \
vtkMuonScatter.h \
vtkStructuredGrid.h \
vtkVoxRaytracerRepresentation.h \
vtkVoxImage.h
# vtkHLineRepresentation.h \
# vtkTriangleMesh.h
_VTK_SOURCES = uLibVtkInterface.cxx \
uLibVtkViewer.cpp \
vtkContainerBox.cpp \
vtkMuonScatter.cxx \
vtkStructuredGrid.cpp \
vtkVoxRaytracerRepresentation.cpp \
vtkVoxImage.cpp
#vtkTriangleMesh.cpp
noinst_LTLIBRARIES = libconvtk.la
libconvtk_la_SOURCES = ${_VTK_SOURCES}
libconvtk_la_LIBADD = $(AM_LIBS_ALL)

93
src/Vtk/Vtk.am Normal file
View File

@@ -0,0 +1,93 @@
#if VTK_5_x
_VTK_LIBS = -lQVTK \
-lLSDyna \
-lMapReduceMPI \
-lmpistubs \
-lvtkalglib \
-lvtkCharts \
-lvtkCommon \
-lvtkDICOMParser \
-lvtkexoIIc \
-lvtkFiltering \
-lvtkftgl \
-lvtkGenericFiltering \
-lvtkGraphics \
-lvtkHybrid \
-lvtkImaging \
-lvtkInfovis \
-lvtkmetaio \
-lvtkNetCDF_cxx \
-lvtkNetCDF \
-lvtkproj4 \
-lvtkRendering \
-lvtksqlite \
-lvtksys \
-lvtkverdict \
-lvtkViews \
-lvtkVolumeRendering \
-lvtkWidgets
AM_CFLAGS += $(VTK_CFLAGS)
AM_CXXFLAGS += $(VTK_CXXFLAGS)
AM_LDFLAGS += $(VTK_LDFLAGS) $(_VTK_LIBS)
#else
#_VTK_LIBS = \
# -lvtkRenderingOpenGL-6.0 \
# -lvtkImagingHybrid-6.0 \
# -lvtkIOImage-6.0 \
# -lvtkCommonDataModel-6.0 \
# -lvtkCommonMath-6.0 \
# -lvtkCommonCore-6.0 \
# -lvtksys-6.0 \
# -lvtkCommonMisc-6.0 \
# -lvtkCommonSystem-6.0 \
# -lvtkCommonTransforms-6.0 \
# -lvtkCommonExecutionModel-6.0 \
# -lvtkDICOMParser-6.0 \
# -lvtkIOCore-6.0 \
# -lvtkzlib-6.0 \
# -lvtkmetaio-6.0 \
# -lvtkjpeg-6.0 \
# -lvtkpng-6.0 \
# -lvtktiff-6.0 \
# -lvtkImagingCore-6.0 \
# -lvtkRenderingCore-6.0 \
# -lvtkFiltersExtraction-6.0 \
# -lvtkFiltersCore-6.0 \
# -lvtkFiltersGeneral-6.0 \
# -lvtkCommonComputationalGeometry-6.0 \
# -lvtkFiltersStatistics-6.0 \
# -lvtkImagingFourier-6.0 \
# -lvtkalglib-6.0 \
# -lvtkFiltersGeometry-6.0 \
# -lvtkFiltersSources-6.0 \
# -lvtkIOXMLParser-6.0 \
# -lvtkexpat-6.0 \
# -lvtkRenderingAnnotation-6.0 \
# -lvtkImagingColor-6.0 \
# -lvtkRenderingFreeType-6.0 \
# -lvtkfreetype-6.0 \
# -lvtkftgl-6.0 \
# -lvtkInteractionStyle-6.0 \
# -lvtkRenderingVolumeOpenGL-6.0 \
# -lvtkRenderingVolume-6.0 \
# -lvtkIOXML-6.0 \
# -lvtkIOGeometry-6.0 \
# -lvtkjsoncpp-6.0 \
# -lvtkInteractionWidgets-6.0 \
# -lvtkFiltersHybrid-6.0 \
# -lvtkImagingSources-6.0 \
# -lvtkFiltersModeling-6.0 \
# -lvtkImagingGeneral-6.0 \
# -lvtkIOLegacy-6.0 \
# -lvtkRenderingFreeTypeOpenGL-6.0
#AM_CFLAGS += $(VTK_CFLAGS)
#AM_CXXFLAGS += $(VTK_CXXFLAGS) -rdynamic
#AM_LDFLAGS += $(VTK_LDFLAGS) $(_VTK_LIBS) -lGLU -lSM -lICE -lX11 -lXext -lSM -lICE -lX11 -lXext -lXt -lm -ldl -lGL
#endif

View File

@@ -0,0 +1,13 @@
# TESTS
set( TESTS
vtkViewerTest
vtkContainerBoxTest
vtkMuonScatter
vtkStructuredGridTest
vtkVoxRaytracerTest
vtkVoxImageTest
# vtkTriangleMeshTest
)
include(${VTK_USE_FILE})
uLib_add_tests(${uLib-module})

View File

@@ -0,0 +1,21 @@
include $(top_srcdir)/Common.am
include ../Vtk.am
#AM_DEFAULT_SOURCE_EXT = .cpp
# if HAVE_CHECK
TESTS = \
vtkViewerTest \
vtkContainerBoxTest \
vtkMuonScatter \
vtkStructuredGridTest \
vtkVoxRaytracerTest \
vtkVoxImageTest
# vtkTriangleMeshTest
all: $(TESTS)
LDADD = $(top_srcdir)/libmutom-${PACKAGE_VERSION}.la $(AM_LIBS_ALL)
check_PROGRAMS = $(TESTS)

View File

@@ -0,0 +1,95 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 <vtkVersion.h>
#include <vtkSmartPointer.h>
#include <vtkImageData.h>
#include <vtkStructuredPoints.h>
#include <vtkStructuredPointsWriter.h>
#include <vtkPointDataToCellData.h>
#include <vtkCellData.h>
#include <vtkPointData.h>
int main(int, char *[])
{
// Create an image data
vtkSmartPointer<vtkImageData> imageData =
vtkSmartPointer<vtkImageData>::New();
// Specify the size of the image data
imageData->SetDimensions(10,20,15);
#if VTK_MAJOR_VERSION <= 5
imageData->SetNumberOfScalarComponents(1);
imageData->SetScalarTypeToDouble();
#else
imageData->AllocateScalars(VTK_DOUBLE,1);
#endif
int* dims = imageData->GetDimensions();
// int dims[3]; // can't do this
std::cout << "Dims: " << " x: " << dims[0] << " y: " << dims[1] << " z: " << dims[2] << std::endl;
std::cout << "Number of points: " << imageData->GetNumberOfPoints() << std::endl;
std::cout << "Number of cells: " << imageData->GetNumberOfCells() << std::endl;
// Fill every entry of the image data with "2.0"
for (int z = 0; z < dims[2]; z++)
{
for (int y = 0; y < dims[1]; y++)
{
for (int x = 0; x < dims[0]; x++)
{
double* pixel = static_cast<double*>(imageData->GetScalarPointer(x,y,z));
pixel[0] = (double)x+y+z;
}
}
}
// imageData->GetCellData()->SetScalars(imageData->GetPointData()->GetScalars());
vtkSmartPointer<vtkPointDataToCellData> ptoc =
vtkSmartPointer<vtkPointDataToCellData>::New();
ptoc->SetInputConnection(imageData->GetProducerPort());
ptoc->Update();
vtkSmartPointer<vtkStructuredPointsWriter> writer =
vtkSmartPointer<vtkStructuredPointsWriter>::New();
writer->SetInput(ptoc->GetImageDataOutput());
writer->SetFileTypeToASCII();
writer->SetFileName("output.vtk");
writer->Update();
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,41 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 <stdio.h>
#include "Vtk/uLibVtkInterface.h"
#define BEGIN_TESTING(name) \
static int _fail = 0; \
printf("..:: Testing " #name " ::..\n");
#define TEST1(val) _fail += (val)==0
#define TEST0(val) _fail += (val)!=0
#define END_TESTING return _fail;

View File

@@ -0,0 +1,53 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 "Vtk/uLibVtkViewer.h"
#include "Math/ContainerBox.h"
#include "Vtk/vtkContainerBox.h"
#include "testing-prototype.h"
using namespace uLib;
int main() {
BEGIN_TESTING(vtk ContainerBox Test);
Vtk::Viewer v_viewer;
ContainerBox box;
box.SetSize(Vector3f(2,3,4));
box.SetPosition(Vector3f(1,2,3));
Vtk::vtkContainerBox v_box(box);
v_viewer.AddPuppet(v_box);
v_viewer.Start();
END_TESTING;
}

View File

@@ -0,0 +1,62 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 "Detectors/MuonScatter.h"
#include "Vtk/vtkMuonScatter.h"
#include "Vtk/uLibVtkViewer.h"
#include "testing-prototype.h"
using namespace uLib;
int main()
{
MuonScatter event;
event.LineIn().direction << 0, -1, 1, 0;
event.LineIn().origin << 0, 1, -1, 1;
event.LineOut().direction << 0, -1, 0, 0;
event.LineOut().origin << 0, -1, 0, 1;
Vtk::vtkMuonScatter v_event(event);
v_event.AddPocaPoint(HPoint3f(0,0,0));
v_event.SaveToXMLFile("vtk_testing_muonevent.vtp");
Vtk::Viewer viewer;
// Vtk::Tie<Vtk::vtkMuonScatter> tms;
// tms.DoAction();
// Vtk::Tie<Vtk::Viewer> vms;
// vms.DoAction();
viewer.AddPuppet(v_event);
viewer.Start();
return 0;
}

View File

@@ -0,0 +1,51 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 "Math/StructuredGrid.h"
#include "Vtk/vtkStructuredGrid.h"
#include "Vtk/uLibVtkViewer.h"
#include "testing-prototype.h"
using namespace uLib;
int main()
{
StructuredGrid grid(Vector3i(10,10,100));
grid.SetSpacing(Vector3f(3,1,1));
Vtk::vtkStructuredGrid grid_viewer(grid);
Vtk::Viewer viewer;
viewer.AddPuppet(grid_viewer);
viewer.Start();
return 0;
}

View File

@@ -0,0 +1,75 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 "Math/TriangleMesh.h"
#include "Vtk/vtkTriangleMesh.h"
#include "testing-prototype.h"
using namespace uLib;
int main()
{
BEGIN_TESTING(Vtk Triangle Mesh);
// { // SIMPLE TESTS //
// TriangleMesh mesh;
// mesh.AddPoint(Vector3f(0,0,0));
// mesh.AddPoint(Vector3f(0,1,0));
// mesh.AddPoint(Vector3f(1,0,0));
// mesh.AddTriangle(Vector3i(0,1,2));
// mesh.PrintSelf(std::cout);
// vtkTriangleMesh v_mesh(mesh);
// v_mesh.Update();
// TestingRenderWidow(&v_mesh);
// }
{ // SIMPLE TESTS //
TriangleMesh mesh;
vtkTriangleMesh v_mesh(mesh);
v_mesh.ReadFromStlFile("prova.stl");
mesh.PrintSelf(std::cout);
TestingRenderWidow(&v_mesh);
}
END_TESTING;
}

View File

@@ -0,0 +1,71 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Vtk/uLibVtkViewer.h>
#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkPolyDataMapper.h>
#include <vtkCubeSource.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include "testing-prototype.h"
using namespace uLib;
int main()
{
BEGIN_TESTING(vtk Viewer Test);
Vtk::Viewer v_viewer;
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
cube->SetXLength(10);
cube->SetYLength(10);
cube->SetZLength(10);
cube->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(cube->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
v_viewer.addProp(actor);
v_viewer.GetRenderer()->Render();
v_viewer.Start();
END_TESTING;
}

View File

@@ -0,0 +1,102 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 "Math/VoxImage.h"
#include "Vtk/vtkVoxImage.h"
#include "Vtk/uLibVtkViewer.h"
#include "testing-prototype.h"
using namespace uLib;
struct TestVoxel {
Scalarf Value;
unsigned int Count;
};
int main()
{
BEGIN_TESTING(Vtk Vox Image);
TestVoxel zero = {0,0};
TestVoxel nonzero = {5.5*1E-6,100};
// { // SIMPLE TESTS //
// VoxImage<TestVoxel> img(Vector3i(10,10,10));
// img.SetSpacing(Vector3f(3,3,3));
// img.InitVoxels(zero);
// img[Vector3i(3,3,3)] = nonzero;
// Vtk::vtkVoxImage vtk_img(img);
// vtk_img.SaveToXMLFile("test.vti");
// vtk_img.setShadingPreset(0);
// // vtk_img.ReadFromVKTFile("error.vtk");
// // VoxImage<TestVoxel> img2 = img;
// // Vtk::vtkVoxImage vtk_img2(img2);
// // img2.ExportToVtk("error_saved.vtk",0);
// // vtk_img2.SaveToXMLFile("error_saved.vti");
// Vtk::Viewer viewer;
// viewer.AddPuppet(vtk_img);
// viewer.Start();
// }
{ // SIMPLE TESTS //
VoxImage<TestVoxel> img(Vector3i(10,10,1));
img.SetSpacing(Vector3f(3,3,3));
img.InitVoxels(zero);
img[Vector3i(3,3,0)] = nonzero;
Vtk::vtkVoxImage vtk_img(img);
vtk_img.ReadFromVKTFile("test.vtk");
vtk_img.Update();
// vtk_img.SaveToXMLFile("test.vti");
// vtk_img.setShadingPreset(0);
// Vtk::vtkVoxImage vtk_img2(img2);
// img2.ExportToVtk("error_saved.vtk",0);
// vtk_img2.SaveToXMLFile("error_saved.vti");
Vtk::Viewer viewer;
viewer.AddPuppet(vtk_img);
viewer.Start();
}
END_TESTING;
}

View File

@@ -0,0 +1,156 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 <vtkBoxWidget.h>
#include <vtkSmartPointer.h>
#include <vtkCommand.h>
#include <Detectors/MuonScatter.h>
#include <Math/VoxRaytracer.h>
#include "Vtk/vtkMuonScatter.h"
#include "Vtk/vtkStructuredGrid.h"
#include "Vtk/vtkVoxRaytracerRepresentation.h"
#include "Vtk/uLibVtkViewer.h"
// remove
#include <vtkCornerAnnotation.h>
#include "testing-prototype.h"
using namespace uLib;
class vtkWidgetCallback : public vtkCommand
{
public:
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
void SetTracer(Vtk::vtkVoxRaytracerRepresentation *parent)
{
this->vtk_raytr = parent;
}
void SetMuon (uLib::MuonScatter *muon) { this->muon = muon; }
void SetAnnotation ( vtkCornerAnnotation *annotation) {
this->annotation = annotation;
}
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
char str[40];
vtk_raytr->SetMuon(*muon);
if(annotation)
{
sprintf(str,"total length = %f",vtk_raytr->GetRay().TotalLength());
annotation->SetText(1,str);
for(int i=0; i<vtk_raytr->GetRay().Data().size(); ++i)
{
std::cout << "L[" << i << "] = "
<< vtk_raytr->GetRay().Data().at(i).L << "\n";
}
std::cout << "\n";
}
}
private:
vtkWidgetCallback() :
vtk_raytr(NULL),
muon(NULL),
annotation(NULL) {}
uLib::VoxRaytracer *raytracer;
Vtk::vtkVoxRaytracerRepresentation *vtk_raytr;
uLib::MuonScatter *muon;
vtkCornerAnnotation *annotation;
};
int main()
{
BEGIN_TESTING(vtk VoxRaytracer);
// muon scatter //
MuonScatter muon;
muon.LineIn().origin << -6, 12, -6, 1;
muon.LineIn().direction << 1 , -1 , 1 , 0;
muon.LineOut().origin << 6 , -4 , 6 , 1;
muon.LineOut().direction << 1 , -1 , 1 , 0;
Vtk::vtkMuonScatter v_muon(muon);
// structured grid //
StructuredGrid grid(Vector3i(12,10,12));
grid.SetSpacing(Vector3f(1,1,1));
grid.SetPosition(Vector3f(0,0,0));
Vtk::vtkStructuredGrid v_grid(grid);
// voxraytracer //
VoxRaytracer rt(grid);
HPoint3f pt;
rt.GetEntryPoint(muon.LineIn(),pt);
std::cout << pt.transpose() << "\n";
Vtk::vtkVoxRaytracerRepresentation v_rt(rt);
v_rt.SetMuon(muon);
v_rt.SetRayColor(Vector4f(1,0,0,1));
// // renderer //
Vtk::Viewer viewer;
// widget //
vtkBoxWidget *widget = v_grid.GetWidget();
vtkWidgetCallback *cbk = vtkWidgetCallback::New();
cbk->SetTracer(&v_rt);
cbk->SetMuon(&muon);
cbk->SetAnnotation(viewer.GetAnnotation());
widget->AddObserver(vtkCommand::InteractionEvent, cbk);
widget->SetInteractor(viewer.GetInteractor());
widget->PlaceWidget();
widget->On();
viewer.AddPuppet(v_grid);
viewer.AddPuppet(v_rt);
viewer.AddPuppet(v_muon);
viewer.Start();
END_TESTING;
}

View File

@@ -0,0 +1,238 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#if VTK_MAJOR_VERSION <= 5
#
#else
# include <vtkAutoInit.h>
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkConfigure.h>
#include <vtkProp.h>
#include <vtkActor.h>
#include <vtkSmartPointer.h>
#include <vtkActor.h>
#include <vtkPropCollection.h>
#include <vtkRendererCollection.h>
#include <vtkPropAssembly.h>
#include <vtkPolyData.h>
#include <vtkPolyDataWriter.h>
#include <vtkXMLPolyDataWriter.h>
#include "uLibVtkInterface.h"
namespace uLib {
namespace Vtk {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// POLYDATA //
void Polydata::SaveToFile(const char *vtk_file)
{
vtkSmartPointer<vtkPolyDataWriter> writer =
vtkSmartPointer<vtkPolyDataWriter>::New();
writer->SetFileName(vtk_file);
vtkPolyData * data = GetPolyData();
if(data) {
# if VTK_MAJOR_VERSION <= 5
writer->SetInputConnection(data->GetProducerPort());
# else
writer->SetInputData(data);
# endif
writer->Update();
}
}
void Polydata::SaveToXMLFile(const char *vtp_file)
{
vtkSmartPointer<vtkXMLPolyDataWriter> writer =
vtkSmartPointer<vtkXMLPolyDataWriter>::New();
writer->SetFileName(vtp_file);
vtkPolyData * data = GetPolyData();
if(data) {
# if VTK_MAJOR_VERSION <= 5
writer->SetInputConnection(data->GetProducerPort());
# else
writer->SetInputData(data);
# endif
writer->Update();
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// PUPPET //
// PIMPL -------------------------------------------------------------------- //
class PuppetData {
public:
PuppetData() :
m_Renderers(vtkRendererCollection::New()),
m_Assembly(vtkPropAssembly::New())
{}
~PuppetData() {
m_Renderers->RemoveAllItems();
m_Assembly->GetParts()->RemoveAllItems();
m_Renderers->Delete();
m_Assembly->Delete();
}
// members //
vtkRendererCollection *m_Renderers;
vtkPropAssembly *m_Assembly;
};
// -------------------------------------------------------------------------- //
Puppet::Puppet() : d(new PuppetData) { }
Puppet::~Puppet()
{
delete d;
}
vtkProp *Puppet::GetProp()
{
if (d->m_Assembly->GetParts()->GetNumberOfItems() == 1)
{
// d->m_Assembly->GetParts()->InitTraversal();
// return d->m_Assembly->GetParts()->GetNextProp();
return d->m_Assembly->GetParts()->GetLastProp();
}
else return d->m_Assembly;
}
void Puppet::SetProp(vtkProp *prop)
{
if(prop) d->m_Assembly->AddPart(prop);
}
void Puppet::RemoveProp(vtkProp *prop)
{
// TODO
}
vtkPropCollection *Puppet::GetProps()
{
return d->m_Assembly->GetParts();
}
void Puppet::ConnectRenderer(vtkRenderer *renderer)
{
if(renderer) {
this->GetRenderers()->AddItem(renderer);
if(d->m_Assembly->GetParts()->GetNumberOfItems() == 1)
renderer->AddActor(this->GetProp());
else if(d->m_Assembly->GetParts()->GetNumberOfItems() >0)
{
vtkPropCollection *props = d->m_Assembly->GetParts();
props->InitTraversal();
for (int i=0; i<props->GetNumberOfItems(); ++i)
renderer->AddActor(props->GetNextProp());
}
}
}
void Puppet::DisconnectRenderer(vtkRenderer *renderer)
{
if(renderer) {
if(this->GetProp())
renderer->RemoveViewProp(this->GetProp());
else if(d->m_Assembly->GetParts()->GetNumberOfItems() >0)
{
vtkPropCollection *props = d->m_Assembly->GetParts();
props->InitTraversal();
for (int i=0; i<props->GetNumberOfItems(); ++i)
renderer->RemoveViewProp(props->GetNextProp());
}
this->GetRenderers()->RemoveItem(renderer);
}
}
void Puppet::ConnectViewer(Viewer *viewer)
{
// TODO
}
void Puppet::DisonnectViewer(Viewer *viewer)
{
// TODO
}
vtkRendererCollection *Puppet::GetRenderers() const
{
return d->m_Renderers;
}
void Puppet::PrintSelf(std::ostream &o) const
{
o << "Props Assembly: \n";
d->m_Assembly->PrintSelf(o,vtkIndent(1));
o << "Connected Renderers: \n";
d->m_Renderers->PrintSelf(o,vtkIndent(1));
}
} // Vtk
} // uLib

124
src/Vtk/uLibVtkInterface.h Normal file
View File

@@ -0,0 +1,124 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 ULIBVTKINTERFACE_H
#define ULIBVTKINTERFACE_H
#include <ostream>
#include <iomanip>
#include <Core/Vector.h>
#include <Core/Object.h>
// vtk classes forward declaration //
class vtkProp;
class vtkPolyData;
class vtkPropCollection;
class vtkRenderer;
class vtkRendererCollection;
namespace uLib {
namespace Vtk {
//template <class T>
//class Tie {
//public:
// typedef T Content;
//};
class Puppet : public Object
{
uLibTypeMacro(Puppet, Object)
public:
Puppet();
~Puppet();
virtual vtkProp * GetProp();
virtual vtkPropCollection * GetProps();
void ConnectRenderer(vtkRenderer *renderer);
void DisconnectRenderer(vtkRenderer *renderer);
void ConnectViewer(class Viewer *viewer);
void DisonnectViewer(class Viewer *viewer);
vtkRendererCollection * GetRenderers() const;
virtual void PrintSelf(std::ostream &o) const;
virtual void ConnectInteractor(class vtkRenderWindowInteractor *interactor) { (void)interactor; }
protected:
void SetProp(vtkProp *prop);
void RemoveProp(vtkProp *prop);
private:
friend class PuppetData;
class PuppetData *d;
};
class Polydata {
public:
virtual vtkPolyData * GetPolyData() const { return NULL; }
virtual void SaveToFile(const char *vtk_file);
virtual void SaveToXMLFile(const char *vtp_file);
protected:
virtual ~Polydata() {}
};
} // vtk
} // uLib
#endif // ULIBVTKINTERFACE_H

190
src/Vtk/uLibVtkViewer.cpp Normal file
View File

@@ -0,0 +1,190 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkSmartPointer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRendererCollection.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCornerAnnotation.h>
#include <vtkTextProperty.h>
#include <vtkAxesActor.h>
#include <vtkOrientationMarkerWidget.h>
#include <vtkCamera.h>
#include "uLibVtkViewer.h"
namespace uLib {
namespace Vtk {
template <>
class Tie<Viewer> {
public:
void DoAction() {
std::cout << " VIEWER TIE !!! \n";
}
};
//// PIMPL /////////////////////////////////////////////////////////////////////
class ViewerPimpl {
public:
ViewerPimpl() :
m_RenderWindow(vtkRenderWindow::New()),
m_Renderer(vtkRenderer::New()),
m_Annotation(vtkCornerAnnotation::New()),
m_Marker(vtkOrientationMarkerWidget::New())
{
this->InstallPipe();
}
~ViewerPimpl() {
this->UninstallPipe();
m_Annotation->Delete();
m_Marker->Delete();
m_Renderer->Delete();
m_RenderWindow->Delete();
}
// members //
vtkRenderer *m_Renderer;
vtkRenderWindow *m_RenderWindow;
vtkCornerAnnotation *m_Annotation;
vtkOrientationMarkerWidget *m_Marker;
private:
void InstallPipe()
{
m_RenderWindow->AddRenderer(m_Renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(m_RenderWindow);
// annotation //
m_Annotation->GetTextProperty()->SetColor(1,1,1);
m_Annotation->GetTextProperty()->SetFontFamilyToArial();
m_Annotation->GetTextProperty()->SetOpacity(0.5);
m_Annotation->SetMaximumFontSize(10);
m_Annotation->SetText(0,"uLib VTK Viewer - OpenCMT all right reserved.");
m_Renderer->AddViewProp(m_Annotation);
// orientation marker //
vtkSmartPointer<vtkAxesActor> axes =
vtkSmartPointer<vtkAxesActor>::New();
m_Marker->SetInteractor(renderWindowInteractor);
m_Marker->SetOrientationMarker(axes);
m_Marker->SetViewport(0.0,0.0,0.2,0.2);
m_Marker->SetEnabled(true);
m_Marker->InteractiveOff();
// Must be rendered here in Vtk-6.0 or seg-fault //
m_RenderWindow->Render();
}
void UninstallPipe() {
m_Renderer->RemoveAllViewProps();
m_Renderer->Clear();
}
};
////////////////////////////////////////////////////////////////////////////////
///// VTK VIEWER //////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
Viewer::Viewer() : d(new ViewerPimpl) {}
Viewer::~Viewer() { delete d; }
void Viewer::addProp(vtkProp *prop)
{
d->m_Renderer->AddActor(prop);
d->m_Renderer->Render();
}
void Viewer::RemoveProp(vtkProp *prop)
{
d->m_Renderer->RemoveViewProp(prop);
d->m_Renderer->Render();
}
void Viewer::AddPuppet(Puppet &prop)
{
prop.ConnectRenderer(d->m_Renderer);
d->m_Renderer->Render();
}
void Viewer::RemovePuppet(Puppet &prop)
{
prop.DisconnectRenderer(d->m_Renderer);
d->m_Renderer->Render();
}
void Viewer::Start()
{
d->m_RenderWindow->GetInteractor()->Start();
}
vtkCornerAnnotation *Viewer::GetAnnotation()
{
return d->m_Annotation;
}
vtkRenderer *Viewer::GetRenderer()
{
return d->m_Renderer;
}
vtkRenderWindowInteractor *Viewer::GetInteractor()
{
return d->m_RenderWindow->GetInteractor();
}
void Viewer::Reset()
{
d->m_Renderer->ResetCameraClippingRange();
d->m_Renderer->ResetCamera();
d->m_Renderer->Render();
}
} // vtk
} // uLib

90
src/Vtk/uLibVtkViewer.h Normal file
View File

@@ -0,0 +1,90 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 ULIBVTKVIEWER_H
#define ULIBVTKVIEWER_H
#include "uLibVtkInterface.h"
class vtkProp;
class vtk3DWidget;
class vtkCornerAnnotation;
class vtkRenderWindowInteractor;
class vtkRenderer;
namespace uLib {
namespace Vtk {
template <class T>
class Tie {
public:
void DoAction() {
std::cout << "Tie::DoAction -> generic Tie does nothing\n";
}
};
class Viewer {
public:
Viewer();
~Viewer();
void AddPuppet(Puppet &prop);
void RemovePuppet(Puppet &prop);
void AddWidget(vtk3DWidget *widget);
void Reset();
void Start();
vtkCornerAnnotation *GetAnnotation();
vtkRenderer * GetRenderer();
vtkRenderWindowInteractor * GetInteractor();
void addProp(vtkProp *prop);
void RemoveProp(vtkProp *prop);
private:
class ViewerPimpl *d;
};
template <> class Tie<Viewer>;
} // vtk
} // uLib
#endif // ULIBVTKVIEWER_H

154
src/Vtk/vtkContainerBox.cpp Normal file
View File

@@ -0,0 +1,154 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkSmartPointer.h>
#include <vtkCubeSource.h>
#include <vtkActor.h>
#include <vtkAxes.h>
#include <vtkAssembly.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkLineSource.h>
#include "vtkContainerBox.h"
namespace uLib {
namespace Vtk {
// PIMPL -------------------------------------------------------------------- //
class vtkContainerBoxPimpl {
public:
vtkContainerBoxPimpl() :
m_Cube(vtkActor::New()),
m_Axes(vtkActor::New()),
m_Pivot(vtkActor::New()),
m_Content(NULL)
{}
~vtkContainerBoxPimpl()
{
m_Cube->Delete();
m_Axes->Delete();
m_Pivot->Delete();
}
// MEMBERS //
vtkActor *m_Cube;
vtkActor *m_Axes;
vtkActor *m_Pivot;
vtkContainerBox::Content *m_Content;
};
// -------------------------------------------------------------------------- //
vtkContainerBox::vtkContainerBox(vtkContainerBox::Content &content) :
d( new vtkContainerBoxPimpl)
{
d->m_Content = &content;
this->InstallPipe();
}
vtkContainerBox::~vtkContainerBox()
{
delete d;
}
vtkPolyData *vtkContainerBox::GetPolyData() const
{
// TODO
}
void vtkContainerBox::InstallPipe()
{
if(!d->m_Content) return;
Content *c = d->m_Content;
// CUBE
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New();
Vector3f p = c->GetPosition();
cube->SetCenter(p(0),p(1),p(2));
Vector4f p1 = c->GetWorldPoint(HPoint3f(0,0,0));
Vector4f p2 = c->GetWorldPoint(HPoint3f(1,1,1));
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
line->SetPoint1(p1(0),p1(1),p1(2));
line->SetPoint2(p2(0),p2(1),p2(2));
line->Update();
cube->SetBounds(line->GetOutput()->GetBounds());
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(cube->GetOutputPort());
mapper->Update();
d->m_Cube->SetMapper(mapper);
d->m_Cube->GetProperty()->SetRepresentationToWireframe();
d->m_Cube->GetProperty()->SetAmbient(0.7);
// AXES //
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New();
axes->SetOrigin(p1(0),p1(1),p1(2));
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(axes->GetOutputPort());
mapper->Update();
d->m_Axes->SetMapper(mapper);
Vector3f s = c->GetSize();
// d->m_Axes->SetScale(s(0),s(1),s(2));
d->m_Axes->GetProperty()->SetLineWidth(3);
d->m_Axes->GetProperty()->SetAmbient(0.4);
d->m_Axes->GetProperty()->SetSpecular(0);
// PIVOT //
axes = vtkSmartPointer<vtkAxes>::New();
axes->SetOrigin(p(0),p(1),p(2));
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(axes->GetOutputPort());
mapper->Update();
d->m_Pivot->SetMapper(mapper);
s = c->GetScale();
// d->m_Pivot->SetScale(s(0),s(1),s(2));
d->m_Pivot->GetProperty()->SetLineWidth(3);
d->m_Pivot->GetProperty()->SetAmbient(0.4);
d->m_Pivot->GetProperty()->SetSpecular(0);
this->SetProp(d->m_Cube);
this->SetProp(d->m_Axes);
this->SetProp(d->m_Pivot);
}
} // vtk
} // uLib

57
src/Vtk/vtkContainerBox.h Normal file
View File

@@ -0,0 +1,57 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 U_VTKCONTAINERBOX_H
#define U_VTKCONTAINERBOX_H
#include "uLibVtkInterface.h"
#include "Math/ContainerBox.h"
namespace uLib {
namespace Vtk {
class vtkContainerBox : public Puppet, public Polydata {
typedef ContainerBox Content;
public:
vtkContainerBox(Content &content);
~vtkContainerBox();
virtual class vtkPolyData *GetPolyData() const;
private:
void InstallPipe();
friend class vtkContainerBoxPimpl;
class vtkContainerBoxPimpl *d;
};
} // vtk
} // uLib
#endif // VTKCONTAINERBOX_H

View File

@@ -0,0 +1,52 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 VTKHLINEREPRESENTATION_H
#define VTKHLINEREPRESENTATION_H
class vtkProp;
class vtkPolyData;
namespace uLib {
class vtkHLineRepresentationDefault {
public:
vtkHLineRepresentationDefault();
};
}
#endif // VTKHLINEREPRESENTATION_H

View File

@@ -0,0 +1,35 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Vtk/vtkMuonContainerScattering.h>
// TO BE CONTINUED //

View File

@@ -0,0 +1,77 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 VTKMUONCONTAINERSCATTERING_H
#define VTKMUONCONTAINERSCATTERING_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "uLibVtkInterface.h"
#include "Detectors/MuonScatter.h"
class vtkRenderWindowInteractor;
namespace uLib {
class vtkMuonContainerScattering : public Abstract::uLibVtkPolydata {
typedef MuonScatter Content;
public:
vtkMuonContainerScattering(const MuonScatter &content);
~vtkMuonScatter();
Content& GetContent();
void PrintSelf(std::ostream &o) const;
virtual vtkProp *GetProp();
virtual vtkPolyData* GetPolyData() const;
void AddPocaPoint(HPoint3f poca);
HPoint3f GetPocaPoint();
void vtkStartInteractive();
protected:
void ConnectInteractor(vtkRenderWindowInteractor *interactor);
private:
void InstallPipe();
friend class vtkMuonContainerScatteringPimpl;
class vtkMuonContainerScatteringPimpl *d;
};
}
#endif // VTKMUONCONTAINERSCATTERING_H

214
src/Vtk/vtkMuonEvent.cxx Normal file
View File

@@ -0,0 +1,214 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkAppendPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkLineSource.h>
#include <vtkActor.h>
#include <vtk3DWidget.h>
#include <vtkBoxWidget.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCommand.h>
#include <vtkTransform.h>
#include "vtkMuonEvent.h"
#include "Math/Dense.h"
namespace uLib {
///// CALLBACK /////////////////////////////////////////////////////////////////
class vtkWidgetCallback : public vtkCommand
{
public:
static vtkWidgetCallback *New()
{ return new vtkWidgetCallback; }
void SetParent(uLib::vtkMuonEvent *parent) { this->parent = parent; }
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
widget->GetTransform(t);
//parent->SetTransform(t);
//std::cout << "event\n";
}
private:
uLib::vtkMuonEvent *parent;
};
//// PIMPL /////////////////////////////////////////////////////////////////////
class vtkMuonEventPimpl {
typedef vtkWidgetCallback Callback;
public:
vtkMuonEventPimpl() :
m_Prop(vtkActor::New()),
m_PolyData(NULL),
m_Appender(vtkAppendPolyData::New()),
content(NULL)
{}
~vtkMuonEventPimpl()
{
m_Prop->Delete();
}
// members //
vtkMuonEvent::Content *content;
vtkPolyData *m_PolyData;
vtkActor *m_Prop;
vtkAppendPolyData *m_Appender;
vtkBoxWidget *m_WidgetIN, *m_WidgetOUT;
HPoint3f m_Poca;
};
////////////////////////////////////////////////////////////////////////////////
///// VTK MUON EVENT /////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkMuonEvent::vtkMuonEvent(MuonEventData &content) :
d(new vtkMuonEventPimpl)
{
d->content = &content;
InstallPipe();
}
vtkMuonEvent::vtkMuonEvent(const MuonEventData &content) :
d(new vtkMuonEventPimpl)
{
d->content = const_cast<MuonEventData *>(&content);
InstallPipe();
}
vtkMuonEvent::~vtkMuonEvent()
{
if (d->m_Prop) d->m_Prop->Delete();
}
vtkMuonEvent::Content &vtkMuonEvent::GetContent()
{
return *d->content;
}
void vtkMuonEvent::PrintSelf(std::ostream &o) const
{
o << "..:: MuonEvent ::..\n" \
"\t[in] Origin > " << d->content->LineIn().origin.transpose() << "\n" <<
"\t[in] Direction > " << d->content->LineIn().direction.transpose() << "\n" <<
"\t[out] Origin > " << d->content->LineOut().origin.transpose() << "\n" <<
"\t[out] Direction > " << d->content->LineOut().direction.transpose()<< "\n" <<
"\tMomentum > " << d->content->GetMomentum() << "\n" <<
"...................\n";
}
vtkProp *vtkMuonEvent::GetProp()
{
return d->m_Prop;
}
void vtkMuonEvent::InstallPipe()
{
vtkAppendPolyData *appender = d->m_Appender;
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
if(d->content) {
vtkSmartPointer<vtkLineSource> line_in = vtkSmartPointer<vtkLineSource>::New();
vtkSmartPointer<vtkLineSource> line_out = vtkSmartPointer<vtkLineSource>::New();
float distance = (d->content->LineIn().origin - d->content->LineOut().origin).norm() / 10;
HPoint3f pt;
pt = d->content->LineIn().origin;
line_in->SetPoint1(pt(0),pt(1),pt(2));
pt= d->content->LineIn().origin + d->content->LineIn().direction * distance;
line_in->SetPoint2(pt(0),pt(1),pt(2));
pt = d->content->LineOut().origin;
line_out->SetPoint1(pt(0),pt(1),pt(2));
pt = d->content->LineOut().origin + d->content->LineOut().direction * distance;
line_out->SetPoint2(pt(0),pt(1),pt(2));
appender->AddInputConnection(line_in->GetOutputPort());
appender->AddInputConnection(line_out->GetOutputPort());
}
appender->Update();
mapper->SetInputConnection(appender->GetOutputPort());
mapper->Update();
d->m_Prop->SetMapper(mapper);
}
vtkPolyData *vtkMuonEvent::GetPolyData() const
{
return d->m_Appender->GetOutput();
}
void vtkMuonEvent::AddPocaPoint(HPoint3f poca)
{
d->m_Poca = poca;
vtkSmartPointer<vtkSphereSource> sphere =
vtkSmartPointer<vtkSphereSource>::New();
float size = (d->content->LineIn().origin - d->content->LineOut().origin).head(3).norm();
size /= 100;
sphere->SetRadius(size);
sphere->SetCenter(poca(0),poca(1),poca(2));
sphere->Update();
d->m_Appender->AddInputConnection(sphere->GetOutputPort());
d->m_Appender->Update();
}
HPoint3f vtkMuonEvent::GetPocaPoint()
{
return d->m_Poca;
}
}

74
src/Vtk/vtkMuonEvent.h Normal file
View File

@@ -0,0 +1,74 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 VTKMUONEVENT_H
#define VTKMUONEVENT_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "uLibVtkInterface.h"
#include "Detectors/MuonEvent.h"
namespace uLib {
class vtkMuonEvent : public Abstract::uLibVtkPolydata {
typedef MuonEventData Content;
public:
vtkMuonEvent(const MuonEventData &content);
vtkMuonEvent(MuonEventData &content);
~vtkMuonEvent();
Content& GetContent();
void PrintSelf(std::ostream &o) const;
virtual vtkProp *GetProp();
virtual vtkPolyData* GetPolyData() const;
void AddPocaPoint(HPoint3f poca);
HPoint3f GetPocaPoint();
void vtkStartInteractive();
private:
void InstallPipe();
friend class vtkMuonEventPimpl;
class vtkMuonEventPimpl *d;
};
}
#endif // VTKMUONSCATTER_H

236
src/Vtk/vtkMuonScatter.cxx Normal file
View File

@@ -0,0 +1,236 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkConfigure.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkAppendPolyData.h>
#include <vtkPolyDataMapper.h>
#include <vtkLineSource.h>
#include <vtkActor.h>
#include <vtk3DWidget.h>
#include <vtkBoxWidget.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkCommand.h>
#include <vtkTransform.h>
#include "vtkMuonScatter.h"
#include "Math/Dense.h"
namespace uLib {
namespace Vtk {
///// CALLBACK /////////////////////////////////////////////////////////////////
//namespace {
//class vtkWidgetCallback : public vtkCommand
//{
//public:
// static vtkWidgetCallback *New()
// { return new vtkWidgetCallback; }
// void SetParent(uLib::vtkMuonScatter *parent) { this->parent = parent; }
// virtual void Execute(vtkObject *caller, unsigned long, void*)
// {
// vtkSmartPointer<vtkTransform> t =
// vtkSmartPointer<vtkTransform>::New();
// vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
// widget->GetTransform(t);
// //parent->SetTransform(t);
// //std::cout << "Scatter\n";
// }
//private:
// uLib::vtkMuonScatter *parent;
//};
//}
//// PIMPL /////////////////////////////////////////////////////////////////////
class vtkMuonScatterPimpl {
public:
vtkMuonScatterPimpl() :
m_Content(NULL),
m_LineIn(vtkLineSource::New()),
m_LineOut(vtkLineSource::New()),
m_PolyData(vtkPolyData::New()),
m_SpherePoca(NULL)
{}
~vtkMuonScatterPimpl()
{
m_LineIn->Delete();
m_LineOut->Delete();
if(m_SpherePoca) m_SpherePoca->Delete();
}
// members //
vtkMuonScatter::Content *m_Content;
vtkLineSource *m_LineIn, *m_LineOut;
vtkSphereSource *m_SpherePoca;
vtkPolyData *m_PolyData;
};
////////////////////////////////////////////////////////////////////////////////
///// VTK MUON Scatter /////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkMuonScatter::vtkMuonScatter(MuonScatter &content) :
d(new vtkMuonScatterPimpl)
{
d->m_Content = &content;
InstallPipe();
}
vtkMuonScatter::vtkMuonScatter(const MuonScatter &content) :
d(new vtkMuonScatterPimpl)
{
d->m_Content = const_cast<MuonScatter *>(&content);
InstallPipe();
}
vtkMuonScatter::~vtkMuonScatter()
{
delete d;
}
vtkMuonScatter::Content &vtkMuonScatter::GetContent()
{
return *d->m_Content;
}
void vtkMuonScatter::PrintSelf(std::ostream &o) const
{
// o << d->content;
}
void vtkMuonScatter::InstallPipe()
{
if(d->m_Content) {
vtkLineSource *line_in = d->m_LineIn;
vtkLineSource *line_out = d->m_LineOut;
float distance = (d->m_Content->LineIn().origin - d->m_Content->LineOut().origin).norm() / 10;
HPoint3f pt;
pt = d->m_Content->LineIn().origin;
line_in->SetPoint1(pt(0),pt(1),pt(2));
pt= d->m_Content->LineIn().origin + d->m_Content->LineIn().direction * distance;
line_in->SetPoint2(pt(0),pt(1),pt(2));
pt = d->m_Content->LineOut().origin;
line_out->SetPoint1(pt(0),pt(1),pt(2));
pt = d->m_Content->LineOut().origin + d->m_Content->LineOut().direction * distance;
line_out->SetPoint2(pt(0),pt(1),pt(2));
}
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(d->m_LineIn->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(d->m_LineOut->GetOutputPort());
actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
}
vtkPolyData *vtkMuonScatter::GetPolyData() const
{
vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
//# if VTK_MAJOR_VERSION <= 5
append->AddInputConnection(d->m_LineIn->GetOutputPort());
append->AddInputConnection(d->m_LineOut->GetOutputPort());
if(d->m_SpherePoca) append->AddInputConnection(d->m_SpherePoca->GetOutputPort());
//# else
// append->AddInputData(d->m_LineIn->GetOutput());
// append->AddInputData(d->m_LineOut->GetOutput());
// if(d->m_SpherePoca) append->AddInputData(d->m_SpherePoca->GetOutput());
//# endif
append->Update();
d->m_PolyData->DeepCopy(append->GetOutput());
return d->m_PolyData;
}
void vtkMuonScatter::AddPocaPoint(HPoint3f poca)
{
vtkSphereSource *sphere = vtkSphereSource::New();
float size = (d->m_Content->LineIn().origin - d->m_Content->LineOut().origin).head(3).norm();
size /= 100;
sphere->SetRadius(size);
sphere->SetCenter(poca(0),poca(1),poca(2));
sphere->Update();
d->m_SpherePoca = sphere;
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(d->m_SpherePoca->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
this->SetProp(actor);
}
HPoint3f vtkMuonScatter::GetPocaPoint()
{
double center[3];
if(d->m_SpherePoca) {
d->m_SpherePoca->GetCenter(center);
return HPoint3f(center[0],center[1],center[2]);
}
else {
return HPoint3f(0,0,0);
}
}
void vtkMuonScatter::ConnectInteractor(vtkRenderWindowInteractor *interactor)
{
// TODO
}
} // vtk
} // uLib

76
src/Vtk/vtkMuonScatter.h Normal file
View File

@@ -0,0 +1,76 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 VTKMUONSCATTER_H
#define VTKMUONSCATTER_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "uLibVtkInterface.h"
#include "Detectors/MuonScatter.h"
class vtkRenderWindowInteractor;
namespace uLib {
namespace Vtk {
class vtkMuonScatter : public Puppet, public Polydata {
typedef MuonScatter Content;
public:
vtkMuonScatter(const MuonScatter &content);
vtkMuonScatter(MuonScatter &content);
~vtkMuonScatter();
Content &GetContent();
void PrintSelf(std::ostream &o) const;
virtual vtkPolyData* GetPolyData() const;
void AddPocaPoint(HPoint3f poca);
HPoint3f GetPocaPoint();
void vtkStartInteractive();
protected:
void ConnectInteractor(vtkRenderWindowInteractor *interactor);
private:
void InstallPipe();
friend class vtkMuonScatterPimpl;
class vtkMuonScatterPimpl *d;
};
} // vtk
} // uLib
#endif // VTKMUONSCATTER_H

49
src/Vtk/vtkPolydata.h Normal file
View File

@@ -0,0 +1,49 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 VTKPOLYDATA_H
#define VTKPOLYDATA_H
#include "uLibVtkInterface.h"
namespace uLib {
class vtkPolyData : public Abstract::uLibVtkPolydata {
typedef ::vtkPolyData Content;
public:
};
}
#endif // VTKPOLYDATA_H

View File

@@ -0,0 +1,195 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkLineSource.h>
#include <vtkBoundingBox.h>
#include <vtkCubeSource.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkProperty.h>
#include <vtkTransform.h>
#include <vtkTransformPolyDataFilter.h>
#include <vtkBoxWidget.h>
#include <vtkCommand.h>
#include "Math/StructuredGrid.h"
#include "Vtk/vtkStructuredGrid.h"
namespace uLib {
namespace Vtk {
////////////////////////////////////////////////////////////////////////////////
////// PIMPL //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
class vtkStructuredGridPimpl {
// ---- WIDGET CBK ------------------------------------------------------ //
class vtkWidgetCallback : public vtkCommand
{
public:
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
void SetParent(uLib::Vtk::vtkStructuredGrid *parent) { this->parent = parent; }
virtual void Execute(vtkObject *caller, unsigned long, void*)
{
vtkSmartPointer<vtkTransform> t =
vtkSmartPointer<vtkTransform>::New();
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget*>(caller);
widget->GetTransform(t);
parent->SetTransform(t);
//std::cout << "event\n";
}
private:
uLib::Vtk::vtkStructuredGrid *parent;
};
// ---------------------------------------------------------------------- //
public:
vtkStructuredGridPimpl(vtkStructuredGrid *parent, StructuredGrid &content) :
p(parent),
m_Content(&content),
m_Actor(vtkActor::New()),
m_Widget(vtkBoxWidget::New()),
m_Transform(vtkTransform::New())
{
vtkSmartPointer<vtkWidgetCallback> callback =
vtkSmartPointer<vtkWidgetCallback>::New();
callback->SetParent(p);
m_Widget->AddObserver(vtkCommand::InteractionEvent, callback);
}
~vtkStructuredGridPimpl()
{
m_Actor->Delete();
m_Widget->Delete();
m_Transform->Delete();
}
// members //
vtkActor *m_Actor;
vtkBoxWidget *m_Widget;
StructuredGrid *m_Content;
vtkTransform *m_Transform;
private:
vtkStructuredGrid *p;
};
////////////////////////////////////////////////////////////////////////////////
////// VTK STRUCTURED GRID /////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkStructuredGrid::vtkStructuredGrid(Content &content) :
d(new vtkStructuredGridPimpl(this,content))
{
this->InstallPipe();
}
vtkStructuredGrid::~vtkStructuredGrid()
{
delete d;
}
void vtkStructuredGrid::SetTransform(vtkTransform *t)
{
vtkMatrix4x4 *vmat = t->GetMatrix();
Matrix4f mat;
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j)
mat(i,j) = vmat->GetElement(i,j);
d->m_Content->SetMatrix(mat);
vtkSmartPointer<vtkMatrix4x4> vmat2 = vtkSmartPointer<vtkMatrix4x4>::New();
mat = d->m_Content->GetWorldMatrix();
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j)
vmat2->SetElement(i,j,mat(i,j));
d->m_Transform->SetMatrix(vmat2);
d->m_Transform->Update();
this->Update();
}
vtkBoxWidget *vtkStructuredGrid::GetWidget()
{
return d->m_Widget;
}
void vtkStructuredGrid::Update()
{
d->m_Actor->GetMapper()->Update();
}
void vtkStructuredGrid::InstallPipe()
{
vtkSmartPointer<vtkCubeSource> cube =
vtkSmartPointer<vtkCubeSource>::New();
vtkSmartPointer<vtkTransformPolyDataFilter> filter =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = d->m_Content->GetWorldMatrix();
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j)
vmat->SetElement(i,j,mat(i,j));
d->m_Transform->SetMatrix(vmat);
filter->SetTransform(d->m_Transform);
filter->SetInputConnection(cube->GetOutputPort());
Vector3i dims = d->m_Content->GetDims();
cube->SetBounds(0,dims(0),0,dims(1),0,dims(2));
cube->Update();
filter->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(filter->GetOutputPort());
d->m_Actor->SetMapper(mapper);
d->m_Actor->GetProperty()->SetRepresentationToSurface();
d->m_Actor->GetProperty()->SetEdgeVisibility(true);
d->m_Actor->GetProperty()->SetOpacity(0.4);
d->m_Actor->GetProperty()->SetAmbient(0.7);
// set content transform to actor //
this->Update();
d->m_Widget->SetProp3D(d->m_Actor);
this->SetProp(d->m_Actor);
}
} // vtk
} // uLib

View File

@@ -0,0 +1,67 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 U_VTKSTRUCTUREDGRID_H
#define U_VTKSTRUCTUREDGRID_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "uLibVtkInterface.h"
#include "Math/StructuredGrid.h"
namespace uLib {
namespace Vtk {
class vtkStructuredGrid : public Puppet {
typedef StructuredGrid Content;
public:
vtkStructuredGrid(Content &content);
~vtkStructuredGrid();
void SetTransform(class vtkTransform *t);
class vtkBoxWidget * GetWidget();
void Update();
private:
void InstallPipe();
friend class vtkStructuredGridPimpl;
class vtkStructuredGridPimpl *d;
};
} // vtk
} // uLib
#endif // VTKSTRUCTUREDGRID_H

227
src/Vtk/vtkTriangleMesh.cpp Normal file
View File

@@ -0,0 +1,227 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkSmartPointer.h>
#include <vtkPolyDataReader.h>
#include <vtkXMLPolyDataReader.h>
#include <vtkOBJReader.h>
#include <vtkSTLReader.h>
#include <vtkPolyData.h>
#include <vtkPoints.h>
#include <vtkCellArray.h>
#include <vtkActor.h>
#include <vtkPolyDataMapper.h>
#include "Vtk/vtkTriangleMesh.h"
namespace uLib {
class vtkTriangleMeshPimpl {
public:
vtkTriangleMeshPimpl(vtkTriangleMesh::Content &content) :
m_content(content),
m_Poly(vtkPolyData::New()),
m_Actor(vtkActor::New())
{
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(m_Poly->GetProducerPort());
m_Actor->SetMapper(mapper);
}
~vtkTriangleMeshPimpl() {
m_Poly->Delete();
m_Actor->Delete();
}
void vtk2uLib_update();
void uLib2vtk_update();
// members //
TriangleMesh &m_content;
vtkPolyData *m_Poly;
vtkActor *m_Actor;
};
void vtkTriangleMeshPimpl::vtk2uLib_update()
{
// Assumes that Polys are Triangles !!! //
vtkIdType number_of_points = m_Poly->GetNumberOfPoints();
vtkIdType number_of_triangles = m_Poly->GetNumberOfPolys();
std::cout << "//////\n" <<
"number of points = " << number_of_points << "\n" <<
"muiber of polys = " << number_of_triangles << "\n" <<
"//////\n";
m_content.Points().resize(number_of_points);
for (int i=0; i<number_of_points; ++i)
{
double *point = m_Poly->GetPoint(i);
m_content.Points()[i](0) = point[0];
m_content.Points()[i](1) = point[1];
m_content.Points()[i](2) = point[2];
// std::cout << "pt" << i << " = " << m_content.Points()[i].transpose() << "\n";
}
m_content.Triangles().resize(number_of_triangles);
m_Poly->GetPolys()->InitTraversal();
vtkSmartPointer<vtkIdList> idList = vtkSmartPointer<vtkIdList>::New();
for (int i=0; i<number_of_triangles; ++i)
{
m_Poly->GetPolys()->GetNextCell(idList);
m_content.Triangles()[i](0) = idList->GetId(0);
m_content.Triangles()[i](1) = idList->GetId(1);
m_content.Triangles()[i](2) = idList->GetId(2);
}
m_Poly->Update();
m_Actor->GetMapper()->Update();
}
void vtkTriangleMeshPimpl::uLib2vtk_update()
{
vtkIdType number_of_points = m_content.Points().size();
vtkIdType number_of_triangles = m_content.Triangles().size();
vtkSmartPointer<vtkPoints> points
= vtkSmartPointer<vtkPoints>::New();
points->SetNumberOfPoints(number_of_points);
for (vtkIdType i = 0; i < number_of_points; i++)
{
double x, y, z;
x = m_content.Points().at(i)(0);
y = m_content.Points().at(i)(1);
z = m_content.Points().at(i)(2);
points->SetPoint(i, x, y, z);
}
vtkSmartPointer<vtkCellArray> polys
= vtkSmartPointer<vtkCellArray>::New();
for (vtkIdType i = 0; i < number_of_triangles; i++)
{
vtkIdType a, b, c;
a = m_content.Triangles().at(i)(0);
b = m_content.Triangles().at(i)(1);
c = m_content.Triangles().at(i)(2);
polys->InsertNextCell(3);
polys->InsertCellPoint(a);
polys->InsertCellPoint(b);
polys->InsertCellPoint(c);
}
m_Poly->SetPoints(points);
m_Poly->SetPolys(polys);
m_Poly->Update();
m_Actor->GetMapper()->Update();
}
// -------------------------------------------------------------------------- //
vtkTriangleMesh::vtkTriangleMesh(vtkTriangleMesh::Content &content) :
d(new vtkTriangleMeshPimpl(content))
{}
vtkTriangleMesh::~vtkTriangleMesh()
{
delete d;
}
void vtkTriangleMesh::ReadFromFile(const char *filename)
{
vtkSmartPointer<vtkPolyDataReader> reader =
vtkSmartPointer<vtkPolyDataReader>::New();
reader->SetFileName(filename);
reader->Update();
d->m_Poly->DeepCopy(reader->GetOutput());
d->vtk2uLib_update();
}
void vtkTriangleMesh::ReadFromXMLFile(const char *filename)
{
vtkSmartPointer<vtkXMLPolyDataReader> reader =
vtkSmartPointer<vtkXMLPolyDataReader>::New();
reader->SetFileName(filename);
reader->Update();
d->m_Poly->DeepCopy(reader->GetOutput());
d->vtk2uLib_update();
}
void vtkTriangleMesh::ReadFromObjFile(const char *filename)
{
vtkSmartPointer<vtkOBJReader> reader =
vtkSmartPointer<vtkOBJReader>::New();
reader->SetFileName(filename);
reader->Update();
d->m_Poly->DeepCopy(reader->GetOutput());
d->vtk2uLib_update();
}
void vtkTriangleMesh::ReadFromStlFile(const char *filename)
{
vtkSmartPointer<vtkSTLReader> reader =
vtkSmartPointer<vtkSTLReader>::New();
reader->SetFileName(filename);
reader->Update();
d->m_Poly->DeepCopy(reader->GetOutput());
d->vtk2uLib_update();
}
vtkProp *vtkTriangleMesh::GetProp()
{
return d->m_Actor;
}
vtkPolyData *vtkTriangleMesh::GetPolyData() const
{
return d->m_Poly;
}
void vtkTriangleMesh::Update()
{
d->uLib2vtk_update();
}
}

69
src/Vtk/vtkTriangleMesh.h Normal file
View File

@@ -0,0 +1,69 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 VTKTRIANGLEMESH_H
#define VTKTRIANGLEMESH_H
#include "uLibVtkInterface.h"
#include "Math/TriangleMesh.h"
class vtkPolyData;
namespace uLib {
class vtkTriangleMesh : public Abstract::uLibVtkPolydata {
typedef TriangleMesh Content;
public:
vtkTriangleMesh(Content &content);
~vtkTriangleMesh();
void ReadFromFile(const char *filename);
void ReadFromXMLFile(const char *filename);
void ReadFromObjFile(const char *filename);
void ReadFromStlFile(const char *filename);
virtual class vtkProp *GetProp();
virtual class vtkPolyData *GetPolyData() const;
void Update();
private:
friend class vtkTriangleMeshPimpl;
class vtkTriangleMeshPimpl *d;
};
}
#endif // VTKTRIANGLEMESH_H

383
src/Vtk/vtkVoxImage.cpp Normal file
View File

@@ -0,0 +1,383 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkSmartPointer.h>
#include <vtkVolume.h>
#include <vtkImageData.h>
#include <vtkImageImport.h>
#include <vtkImageExport.h>
#include <vtkFloatArray.h>
#include <vtkPointData.h>
#include <vtkXMLImageDataReader.h>
#include <vtkXMLImageDataWriter.h>
#include <vtkGenericDataObjectReader.h>
#include <vtkImageShiftScale.h>
#include <vtkSmartVolumeMapper.h>
#include <vtkColorTransferFunction.h>
#include <vtkPiecewiseFunction.h>
#include <vtkVolumeProperty.h>
#include <vtkActor.h>
#include <vtkProperty.h>
#include <vtkCubeSource.h>
#include <vtkPolyDataMapper.h>
#include <Math/VoxImage.h>
#include "vtkVoxImage.h"
namespace uLib {
namespace Vtk {
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// PIMPL
class vtkVoxImagePimpl {
public:
vtkVoxImagePimpl(vtkVoxImage::Content &content) :
m_Content(content),
m_Actor(vtkVolume::New()),
m_Image(vtkImageData::New()),
m_Outline(vtkCubeSource::New()),
m_Reader(NULL),
m_Writer(NULL)
{}
~vtkVoxImagePimpl()
{
m_Image->Delete();
m_Actor->Delete();
m_Outline->Delete();
}
void GetContent();
void SetContent();
// members //
vtkVolume *m_Actor;
vtkImageData *m_Image;
vtkCubeSource *m_Outline;
// io //
vtkXMLImageDataReader *m_Reader;
vtkXMLImageDataWriter *m_Writer;
// content //
vtkVoxImage::Content &m_Content;
// visual //
float m_Window;
float m_Level;
};
void vtkVoxImagePimpl::GetContent()
{
// ULIB -> VTK //
const int *dims = static_cast<const int *>(m_Content.GetDims().data());
m_Image->SetDimensions(dims);
float *spacing = m_Content.GetSpacing().data();
m_Image->SetSpacing(spacing[0],spacing[1],spacing[2]);
// Warning .. TODO: Read complete Transform matrix //
float *pos = m_Content.GetPosition().data();
m_Image->SetOrigin(pos[0],pos[1],pos[2]);
vtkFloatArray *array = vtkFloatArray::SafeDownCast
(m_Image->GetPointData()->GetScalars());
array->SetNumberOfTuples(m_Content.GetDims().prod());
Vector3i index(0,0,0);
int i=0;
for (int zv = 0; zv < dims[2]; ++zv) {
for (int yv = 0; yv < dims[1]; ++yv) {
for (int xv = 0; xv < dims[0]; ++xv) {
index << xv,yv,zv;
array->SetValue(i++,m_Content.GetValue(index));
}
}
}
m_Image->GetPointData()->SetScalars(array);
// m_Image->Update();
}
void vtkVoxImagePimpl::SetContent()
{
// VTK -> ULIB //
int *ext = m_Image->GetExtent();
int dims[3] = { ext[1]-ext[0] + 1, ext[3]-ext[2] + 1, ext[5]-ext[4] + 1 };
m_Content.SetDims(Vector3i(dims[0],dims[1],dims[2]));
double *spacing = m_Image->GetSpacing();
m_Content.SetSpacing(Vector3f(spacing[0],spacing[1],spacing[2]));
// Warning .. TODO: Read complete Transform matrix //
double *pos = m_Image->GetOrigin();
m_Content.SetPosition(Vector3f(pos[0],pos[1],pos[2]));
vtkFloatArray *array = vtkFloatArray::SafeDownCast
(m_Image->GetPointData()->GetScalars());
if(array) {
Vector3i index(0,0,0);
int i=0;
for (int zv = 0; zv < dims[2]; ++zv) {
for (int yv = 0; yv < dims[1]; ++yv) {
for (int xv = 0; xv < dims[0]; ++xv) {
index << xv,yv,zv;
m_Content.SetValue(index,array->GetValue(i++));
}
}
}
}
else {
std::cerr << "Error reading array Value Data\n";
}
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// VTK VOXIMAGE
vtkVoxImage::vtkVoxImage(Content &content) :
d(new vtkVoxImagePimpl(content))
{
init_properties();
d->GetContent();
InstallPipe();
}
vtkVoxImage::~vtkVoxImage()
{
delete d;
}
vtkImageData *vtkVoxImage::GetImageData()
{
d->GetContent();
return d->m_Image;
}
void vtkVoxImage::SaveToXMLFile(const char *fname)
{
vtkSmartPointer<vtkXMLImageDataWriter> writer =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
writer->SetFileName(fname);
d->GetContent();
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
# if VTK_MAJOR_VERSION <= 5
vtkscale->SetInputConnection(d->m_Image->GetProducerPort());
# else
vtkscale->SetInputData(d->m_Image);
# endif
vtkscale->SetScale(p().writer_factor);
vtkscale->Update();
writer->SetInputConnection(vtkscale->GetOutputPort());
writer->Update();
writer->Write();
}
void vtkVoxImage::ReadFromVKTFile(const char *fname)
{
vtkSmartPointer<vtkGenericDataObjectReader> reader =
vtkSmartPointer<vtkGenericDataObjectReader>::New();
reader->SetFileName(fname);
reader->Update();
if(reader->IsFileStructuredPoints())
{
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
vtkscale->SetInputConnection(reader->GetOutputPort());
vtkscale->SetScale(1/p().writer_factor);
vtkscale->Update();
d->m_Image->DeepCopy(vtkscale->GetOutput()); // FIX! (pipe connection)
d->SetContent();
}
else {
std::cerr << "Error: file does not contain structured points\n";
}
d->m_Actor->Update();
}
void vtkVoxImage::ReadFromXMLFile(const char *fname)
{
vtkSmartPointer<vtkXMLImageDataReader> reader =
vtkSmartPointer<vtkXMLImageDataReader>::New();
reader->SetFileName(fname);
reader->Update();
vtkSmartPointer<vtkImageShiftScale> vtkscale =
vtkSmartPointer<vtkImageShiftScale>::New();
vtkscale->SetInputConnection(reader->GetOutputPort());
vtkscale->SetScale(1/p().writer_factor);
vtkscale->Update();
d->m_Image->DeepCopy(vtkscale->GetOutput());
d->SetContent();
}
void vtkVoxImage::setShadingPreset(int blendType)
{
vtkSmartVolumeMapper *mapper =
(vtkSmartVolumeMapper *)d->m_Actor->GetMapper();
vtkVolumeProperty *property = d->m_Actor->GetProperty();
static vtkColorTransferFunction *colorFun = vtkColorTransferFunction::New();
static vtkPiecewiseFunction *opacityFun = vtkPiecewiseFunction::New();
float window = 40 / $$.writer_factor;
float level = 20 / $$.writer_factor;
property->SetColor(colorFun);
property->SetScalarOpacity(opacityFun);
property->SetInterpolationTypeToLinear();
if(blendType != 6) {
colorFun->RemoveAllPoints();
opacityFun->RemoveAllPoints();
}
switch (blendType) {
// MIP
// Create an opacity ramp from the window and level values.
// Color is white. Blending is MIP.
case 0:
colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0);
opacityFun->AddSegment(level - 0.5 * window, 0.0,
level + 0.5 * window, 1.0);
mapper->SetBlendModeToMaximumIntensity();
break;
// CompositeRamp
// Create a ramp from the window and level values. Use compositing
// without shading. Color is a ramp from black to white.
case 1:
colorFun->AddRGBSegment(level - 0.5 * window, 0.0, 0.0, 0.0,
level + 0.5 * window, 1.0, 1.0, 1.0);
opacityFun->AddSegment(level - 0.5 * window, 0.0,
level + 0.5 * window, 1.0);
mapper->SetBlendModeToComposite();
property->ShadeOff();
break;
// CompositeShadeRamp
// Create a ramp from the window and level values. Use compositing
// with shading. Color is white.
case 2:
colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0);
opacityFun->AddSegment(level - 0.5 * window, 0.0,
level + 0.5 * window, 1.0);
mapper->SetBlendModeToComposite();
property->ShadeOn();
break;
// CT_Skin
// Use compositing and functions set to highlight skin in CT data
// Not for use on RGB data
case 3:
colorFun->AddRGBPoint(-3024, 0, 0, 0, 0.5, 0.0);
colorFun->AddRGBPoint(-1000, .62, .36, .18, 0.5, 0.0);
colorFun->AddRGBPoint(-500, .88, .60, .29, 0.33, 0.45);
colorFun->AddRGBPoint(3071, .83, .66, 1, 0.5, 0.0);
opacityFun->AddPoint(-3024, 0, 0.5, 0.0);
opacityFun->AddPoint(-1000, 0, 0.5, 0.0);
opacityFun->AddPoint(-500, 1.0, 0.33, 0.45);
opacityFun->AddPoint(3071, 1.0, 0.5, 0.0);
mapper->SetBlendModeToComposite();
property->ShadeOn();
property->SetAmbient(0.1);
property->SetDiffuse(0.9);
property->SetSpecular(0.2);
property->SetSpecularPower(10.0);
property->SetScalarOpacityUnitDistance(0.8919);
break;
default:
vtkGenericWarningMacro("Unknown blend type.");
break;
}
}
void vtkVoxImage::Update() {
d->m_Actor->Update();
d->m_Outline->SetBounds(d->m_Image->GetBounds());
d->m_Outline->Update();
}
void vtkVoxImage::InstallPipe()
{
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
vtkSmartPointer<vtkSmartVolumeMapper>::New();
# if VTK_MAJOR_VERSION <= 5
mapper->SetInputConnection(d->m_Image->GetProducerPort());
# else
mapper->SetInputData(d->m_Image);
# endif
mapper->Update();
d->m_Actor->SetMapper(mapper);
this->setShadingPreset(0);
mapper->Update();
d->m_Outline->SetBounds(d->m_Image->GetBounds());
vtkSmartPointer<vtkPolyDataMapper> mmapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mmapper->SetInputConnection(d->m_Outline->GetOutputPort());
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mmapper);
actor->GetProperty()->SetRepresentationToWireframe();
actor->GetProperty()->SetAmbient(0.7);
// this->SetProp(actor);
this->SetProp(d->m_Actor);
}
} // vtk
} // uLib

88
src/Vtk/vtkVoxImage.h Normal file
View File

@@ -0,0 +1,88 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 U_VTKVOXIMAGE_H
#define U_VTKVOXIMAGE_H
#include <Core/Object.h>
#include <Math/VoxImage.h>
#include "uLibVtkInterface.h"
class vtkImageData;
namespace uLib {
namespace Vtk {
class vtkVoxImage : public Puppet {
uLibTypeMacro(vtkVoxImage,Puppet)
public:
properties()
{
float writer_factor;
};
public:
typedef Abstract::VoxImage Content;
vtkVoxImage(Content &content);
~vtkVoxImage();
vtkImageData * GetImageData();
void SaveToXMLFile(const char *fname);
void ReadFromVKTFile(const char *fname);
void ReadFromXMLFile(const char *fname);
void setShadingPreset(int blendType = 2);
void Update();
protected:
void InstallPipe();
private:
class vtkVoxImagePimpl *d;
};
inline void vtkVoxImage::init_properties()
{
$_init();
$$.writer_factor = 1.E6;
}
} // vtk
} // uLib
#endif // VTKVOXIMAGE_H

View File

@@ -0,0 +1,459 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <vtkLine.h>
#include <vtkCellArray.h>
#include <vtkLineSource.h>
#include <vtkSphereSource.h>
#include <vtkBoundingBox.h>
#include <vtkCubeSource.h>
#include <vtkSmartPointer.h>
#include <vtkPolyDataMapper.h>
#include <vtkAppendPolyData.h>
#include <vtkActor.h>
#include <vtkAssembly.h>
#include <vtkProp3DCollection.h>
#include <vtkProperty.h>
#include <vtkPolyData.h>
#include <vtkTransform.h>
#include <vtkTransformPolyDataFilter.h>
#include "vtkVoxRaytracerRepresentation.h"
#include "Math/VoxRaytracer.h"
//#include "vtkMuonEvent.h"
#include "vtkMuonScatter.h"
namespace uLib {
namespace Vtk {
///// PIMPL ////////////////////////////////////////////////////////////////////
class vtkVoxRaytracerRepresentationPimpl {
public:
vtkVoxRaytracerRepresentationPimpl(VoxRaytracer &content) :
m_Content(&content),
m_Assembly(vtkAssembly::New()),
m_Sphere1(vtkSphereSource::New()),
m_Sphere2(vtkSphereSource::New()),
m_Line1(vtkLineSource::New()),
m_Line2(vtkLineSource::New()),
m_Line3(vtkLineSource::New()),
m_RayLine(vtkAppendPolyData::New()),
m_RayLineActor(vtkActor::New()),
m_RayRepresentation(vtkAppendPolyData::New()),
m_RayRepresentationActor(vtkActor::New()),
m_Transform(vtkTransform::New())
{
default_radius = content.GetImage()->GetSpacing()(0)/4;
m_Sphere1->SetRadius(default_radius);
m_Sphere2->SetRadius(default_radius);
m_SelectedElement = m_RayLine;
}
~vtkVoxRaytracerRepresentationPimpl()
{
m_Assembly->Delete();
m_RayLine->Delete();
m_RayLineActor->Delete();
m_RayRepresentationActor->Delete();
m_Transform->Delete();
}
// members //
VoxRaytracer *m_Content;
Scalarf default_radius;
vtkAssembly *m_Assembly;
vtkAppendPolyData *m_RayLine;
vtkActor *m_RayLineActor;
vtkActor *m_RayRepresentationActor;
vtkSmartPointer<vtkTransform> m_Transform;
VoxRaytracer::RayData m_Ray;
vtkSmartPointer<vtkSphereSource> m_Sphere1,m_Sphere2;
vtkSmartPointer<vtkLineSource> m_Line1, m_Line2, m_Line3;
vtkSmartPointer<vtkAppendPolyData> m_RayRepresentation;
vtkAppendPolyData *m_SelectedElement;
};
////////////////////////////////////////////////////////////////////////////////
////// VOX RAYTRACER REPRESENTATION ///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &content) :
d(new vtkVoxRaytracerRepresentationPimpl(content))
{
InstallPipe();
}
vtkVoxRaytracerRepresentation::~vtkVoxRaytracerRepresentation()
{
delete d;
}
VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm()
{
return d->m_Content;
}
vtkProp *vtkVoxRaytracerRepresentation::GetProp()
{
return d->m_Assembly;
}
vtkPolyData *vtkVoxRaytracerRepresentation::GetPolyData() const
{
std::cout << "get Raytracer polydata\n";
d->m_SelectedElement->Update();
return d->m_SelectedElement->GetOutput();
}
void vtkVoxRaytracerRepresentation::SetRepresentationElements(vtkVoxRaytracerRepresentation::RepresentationElements el)
{
switch(el) {
case Vtk::vtkVoxRaytracerRepresentation::RayElements:
d->m_SelectedElement = d->m_RayLine;
break;
case Vtk::vtkVoxRaytracerRepresentation::VoxelsElements:
d->m_SelectedElement = d->m_RayRepresentation;
break;
default:
d->m_SelectedElement = d->m_RayLine;
break;
}
}
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon)
{
HPoint3f pt1,pt2,src;
src = muon.LineIn().origin;
d->m_Content->GetEntryPoint(muon.LineIn(),pt1);
d->m_Sphere1->SetCenter(pt1(0),pt1(1),pt1(2));
d->m_Line1->SetPoint1(src(0),src(1),src(2));
d->m_Line1->SetPoint2(pt1(0),pt1(1),pt1(2));
HLine3f line_out = muon.LineOut();
src = line_out.origin;
float *direction = line_out.direction.data();
for(int i=0;i<3;++i) direction[i] *= -1;
d->m_Content->GetEntryPoint(line_out,pt2);
d->m_Sphere2->SetCenter(pt2(0),pt2(1),pt2(2));
d->m_Line2->SetPoint1(src(0),src(1),src(2));
d->m_Line2->SetPoint2(pt2(0),pt2(1),pt2(2));
d->m_Line3->SetPoint1(pt1(0),pt1(1),pt1(2));
d->m_Line3->SetPoint2(pt2(0),pt2(1),pt2(2));
// Create a vtkPoints object and store the points in it
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(pt1(0),pt1(1),pt1(2));
points->InsertNextPoint(pt2(0),pt2(1),pt2(2));
// Create a cell array to store the lines in and add the lines to it
vtkSmartPointer<vtkCellArray> lines =
vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkLine> line =
vtkSmartPointer<vtkLine>::New();
line->GetPointIds()->SetId(0,0);
line->GetPointIds()->SetId(1,1);
lines->InsertNextCell(line);
// Create a polydata to store everything in
vtkSmartPointer<vtkPolyData> linesPolyData =
vtkSmartPointer<vtkPolyData>::New();
// Add the points to the dataset
linesPolyData->SetPoints(points);
// Add the lines to the dataset
linesPolyData->SetLines(lines);
d->m_RayLine->RemoveAllInputs();
# if VTK_MAJOR_VERSION <= 5
d->m_RayLine->AddInputConnection(linesPolyData->GetProducerPort());
# else
d->m_RayLine->AddInputData(linesPolyData);
# endif
d->m_RayLine->AddInputConnection(d->m_Line1->GetOutputPort());
d->m_RayLine->AddInputConnection(d->m_Sphere1->GetOutputPort());
d->m_RayLine->AddInputConnection(d->m_Line2->GetOutputPort());
d->m_RayLine->AddInputConnection(d->m_Sphere2->GetOutputPort());
// d->m_RayLine->AddInputConnection(d->m_Line3->GetOutputPort());
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = d->m_Content->GetImage()->GetWorldMatrix();
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j)
vmat->SetElement(i,j,mat(i,j));
d->m_Transform->SetMatrix(vmat);
this->SetRay(pt1,pt2);
}
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca)
{
HPoint3f pt1,pt2,src;
src = muon.LineIn().origin;
d->m_Content->GetEntryPoint(muon.LineIn(),pt1);
d->m_Sphere1->SetCenter(pt1(0),pt1(1),pt1(2));
d->m_Line1->SetPoint1(src(0),src(1),src(2));
d->m_Line1->SetPoint2(pt1(0),pt1(1),pt1(2));
HLine3f line_out = muon.LineOut();
src = line_out.origin;
float *direction = line_out.direction.data();
for(int i=0;i<3;++i) direction[i] *= -1;
d->m_Content->GetEntryPoint(line_out,pt2);
d->m_Sphere2->SetCenter(pt2(0),pt2(1),pt2(2));
d->m_Line2->SetPoint1(src(0),src(1),src(2));
d->m_Line2->SetPoint2(pt2(0),pt2(1),pt2(2));
d->m_Line3->SetPoint1(pt1(0),pt1(1),pt1(2));
d->m_Line3->SetPoint2(pt2(0),pt2(1),pt2(2));
// Create a vtkPoints object and store the points in it
vtkSmartPointer<vtkPoints> points =
vtkSmartPointer<vtkPoints>::New();
points->InsertNextPoint(pt1(0),pt1(1),pt1(2));
points->InsertNextPoint(poca(0),poca(1),poca(2));
points->InsertNextPoint(pt2(0),pt2(1),pt2(2));
// Create a cell array to store the lines in and add the lines to it
vtkSmartPointer<vtkCellArray> lines =
vtkSmartPointer<vtkCellArray>::New();
for(unsigned int i = 0; i < 2; i++)
{
vtkSmartPointer<vtkLine> line =
vtkSmartPointer<vtkLine>::New();
line->GetPointIds()->SetId(0,i);
line->GetPointIds()->SetId(1,i+1);
lines->InsertNextCell(line);
}
// Create a polydata to store everything in
vtkSmartPointer<vtkPolyData> linesPolyData =
vtkSmartPointer<vtkPolyData>::New();
// Add the points to the dataset
linesPolyData->SetPoints(points);
// Add the lines to the dataset
linesPolyData->SetLines(lines);
d->m_RayLine->RemoveAllInputs();
# if VTK_MAJOR_VERSION <= 5
d->m_RayLine->AddInputConnection(linesPolyData->GetProducerPort());
# else
d->m_RayLine->AddInputData(linesPolyData);
# endif
d->m_RayLine->AddInputConnection(d->m_Line1->GetOutputPort());
d->m_RayLine->AddInputConnection(d->m_Sphere1->GetOutputPort());
d->m_RayLine->AddInputConnection(d->m_Line2->GetOutputPort());
d->m_RayLine->AddInputConnection(d->m_Sphere2->GetOutputPort());
// d->m_RayLine->AddInputConnection(d->m_Line3->GetOutputPort());
vtkSmartPointer<vtkSphereSource> poca_sphere =
vtkSmartPointer<vtkSphereSource>::New();
poca_sphere->SetRadius(d->default_radius);
poca_sphere->SetCenter(poca(0),poca(1),poca(2));
d->m_RayLine->AddInputConnection(poca_sphere->GetOutputPort());
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = d->m_Content->GetImage()->GetWorldMatrix();
for(int i=0; i<4; ++i)
for(int j=0; j<4; ++j)
vmat->SetElement(i,j,mat(i,j));
d->m_Transform->SetMatrix(vmat);
if(d->m_Content->GetImage()->IsInsideBounds(poca))
this->SetRay(pt1,poca,pt2);
else
this->SetRay(pt1,pt2);
}
void vtkVoxRaytracerRepresentation::SetMuon(vtkMuonScatter &muon)
{
HPoint3f poca = muon.GetPocaPoint();
MuonScatter &mu = muon.GetContent();
this->SetMuon(mu,poca);
}
VoxRaytracer::RayData vtkVoxRaytracerRepresentation::GetRay()
{
return d->m_Ray;
}
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f out)
{
d->m_Ray = d->m_Content->TraceBetweenPoints(in,out);
this->SetRay(&d->m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f mid, HPoint3f out)
{
d->m_Ray = d->m_Content->TraceBetweenPoints(in,mid);
d->m_Ray.AppendRay( d->m_Content->TraceBetweenPoints(mid,out) );
this->SetRay(&d->m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray)
{
vtkAppendPolyData *appender = d->m_RayRepresentation;
appender->RemoveAllInputs();
for(int i=0; i<ray->Data().size(); ++i) {
int id = ray->Data().at(i).vox_id;
Vector3i idv = d->m_Content->GetImage()->UnMap(id);
vtkSmartPointer<vtkCubeSource> cube =
vtkSmartPointer<vtkCubeSource>::New();
cube->SetBounds(idv(0),idv(0)+1,idv(1),idv(1)+1,idv(2),idv(2)+1);
cube->Update();
# if VTK_MAJOR_VERSION <= 5
appender->AddInput(cube->GetOutput());
# else
appender->AddInputData(cube->GetOutput());
# endif
appender->Update();
}
}
void vtkVoxRaytracerRepresentation::SetVoxelsColor(Vector4f rgba)
{
this->SetColor(d->m_RayRepresentationActor,rgba);
}
void vtkVoxRaytracerRepresentation::SetRayColor(Vector4f rgba)
{
this->SetColor(d->m_RayLineActor,rgba);
}
void vtkVoxRaytracerRepresentation::SetColor(vtkActor *actor, Vector4f rgba)
{
if(!actor) return;
vtkProperty *pr = actor->GetProperty();
pr->SetDiffuseColor( rgba(0),
rgba(1),
rgba(2) );
pr->SetOpacity( rgba(3) );
pr->SetDiffuse(1);
}
void vtkVoxRaytracerRepresentation::InstallPipe()
{
vtkSmartPointer<vtkAppendPolyData> append =
vtkSmartPointer<vtkAppendPolyData>::New();
append->AddInputConnection(d->m_Sphere1->GetOutputPort());
append->AddInputConnection(d->m_Sphere2->GetOutputPort());
append->AddInputConnection(d->m_Line1->GetOutputPort());
append->AddInputConnection(d->m_Line2->GetOutputPort());
append->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(append->GetOutputPort());
mapper->Update();
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(0.6,0.6,1);
this->SetProp(actor);
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(d->m_RayLine->GetOutputPort());
mapper->Update();
d->m_RayLineActor->SetMapper(mapper);
d->m_RayLineActor->GetProperty()->SetColor(1,0,0);
this->SetProp(d->m_RayLineActor);
// mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
// mapper->SetInputConnection(d->m_Line3->GetOutputPort());
// mapper->Update();
// actor = vtkSmartPointer<vtkActor>::New();
// actor->SetMapper(mapper);
// actor->GetProperty()->SetColor(1,0,0);
// d->m_Assembly->AddPart(actor);
vtkSmartPointer<vtkTransformPolyDataFilter> polyfilter =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
polyfilter->SetInputConnection(d->m_RayRepresentation->GetOutputPort());
polyfilter->SetTransform(d->m_Transform);
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(polyfilter->GetOutputPort());
mapper->Update();
vtkActor *vra = d->m_RayRepresentationActor;
vra->SetMapper(mapper);
vra->GetProperty()->SetOpacity(0.2);
vra->GetProperty()->SetEdgeVisibility(true);
vra->GetProperty()->SetColor(0.5,0.5,0.5);
this->SetProp(vra);
}
} // vtk
} // uLib

View File

@@ -0,0 +1,101 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 U_VTKVOXRAYTRACERREPRESENTATION_H
#define U_VTKVOXRAYTRACERREPRESENTATION_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "uLibVtkInterface.h"
#include "Detectors/MuonScatter.h"
#include "Math/StructuredGrid.h"
#include "Math/VoxRaytracer.h"
class vtkActor;
namespace uLib {
namespace Vtk {
class vtkVoxRaytracerRepresentation : public Puppet {
typedef VoxRaytracer Content;
public:
vtkVoxRaytracerRepresentation(Content &content);
~vtkVoxRaytracerRepresentation();
uLib::VoxRaytracer *GetRaytracerAlgorithm();
vtkProp *GetProp();
vtkPolyData *GetPolyData() const;
enum RepresentationElements {
RayElements,
VoxelsElements
};
void SetRepresentationElements(enum RepresentationElements el);
void SetMuon(MuonScatter &muon);
void SetMuon(MuonScatter &muon, HPoint3f poca);
void SetMuon(class vtkMuonEvent &muon);
void SetMuon(class vtkMuonScatter &muon);
VoxRaytracer::RayData GetRay();
void SetRay(HPoint3f in, HPoint3f out);
void SetRay(HPoint3f in, HPoint3f mid, HPoint3f out);
void SetRay(VoxRaytracer::RayData *ray);
void SetVoxelsColor(Vector4f rgba);
void SetRayColor(Vector4f rgba);
private:
void InstallPipe();
void SetColor(vtkActor *actor, Vector4f rgba);
friend class vtkVoxRaytracerRepresentationPimpl;
class vtkVoxRaytracerRepresentationPimpl *d;
};
} // vtk
} // uLib
#endif // VTKVOXRAYTRACERREPRESENTATION_H

51
src/Vtk/vtkuLibProp.h Normal file
View File

@@ -0,0 +1,51 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 U_VTKULIBPROP_H
#define U_VTKULIBPROP_H
class vtkProp;
namespace uLib {
namespace Abstract {
class uLibVtkProp {
public:
virtual vtkProp *GetProp() = 0;
protected:
~uLibVtkProp() {}
};
}
}
#endif // VTKULIBPROP_H