reorganization of sources, moving cmt pertaining structures into HEP folder
This commit is contained in:
22
src/Vtk/Math/CMakeLists.txt
Normal file
22
src/Vtk/Math/CMakeLists.txt
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
################################################################################
|
||||
##### Vtk/Math - VTK wrappers for Math module objects #########################
|
||||
################################################################################
|
||||
|
||||
set(MATH_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkStructuredGrid.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkTriangleMesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkVoxImage.cpp
|
||||
PARENT_SCOPE)
|
||||
|
||||
set(MATH_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkHLineRepresentation.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkStructuredGrid.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkTriangleMesh.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/vtkVoxImage.h
|
||||
PARENT_SCOPE)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
include(uLibTargetMacros)
|
||||
add_subdirectory(testing)
|
||||
endif()
|
||||
16
src/Vtk/Math/testing/CMakeLists.txt
Normal file
16
src/Vtk/Math/testing/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
||||
# TESTS
|
||||
set(TESTS
|
||||
vtkStructuredGridTest
|
||||
vtkTriangleMeshTest
|
||||
vtkVoxImageTest
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
${PACKAGE_LIBPREFIX}Core
|
||||
${PACKAGE_LIBPREFIX}Math
|
||||
${PACKAGE_LIBPREFIX}Vtk
|
||||
${VTK_LIBRARIES}
|
||||
Boost::unit_test_framework
|
||||
)
|
||||
|
||||
uLib_add_tests(VtkMath)
|
||||
48
src/Vtk/Math/testing/vtkStructuredGridTest.cpp
Normal file
48
src/Vtk/Math/testing/vtkStructuredGridTest.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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/Math/vtkStructuredGrid.h"
|
||||
#include "Math/StructuredGrid.h"
|
||||
#include "Vtk/uLibVtkViewer.h"
|
||||
|
||||
#define BOOST_TEST_MODULE VtkStructuredGridTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(vtkStructuredGridTest) {
|
||||
StructuredGrid grid(Vector3i(10, 10, 100));
|
||||
grid.SetSpacing(Vector3f(3, 1, 1));
|
||||
|
||||
Vtk::vtkStructuredGrid grid_viewer(grid);
|
||||
|
||||
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
|
||||
Vtk::Viewer viewer;
|
||||
viewer.AddPuppet(grid_viewer);
|
||||
viewer.Start();
|
||||
}
|
||||
|
||||
BOOST_CHECK(grid_viewer.GetWidget() != nullptr);
|
||||
}
|
||||
53
src/Vtk/Math/testing/vtkTriangleMeshTest.cpp
Normal file
53
src/Vtk/Math/testing/vtkTriangleMeshTest.cpp
Normal 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/Math/vtkTriangleMesh.h"
|
||||
#include "Math/TriangleMesh.h"
|
||||
|
||||
#define BOOST_TEST_MODULE VtkTriangleMeshTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
BOOST_AUTO_TEST_CASE(vtkTriangleMeshConstruction) {
|
||||
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));
|
||||
|
||||
Vtk::vtkTriangleMesh v_mesh(mesh);
|
||||
v_mesh.Update();
|
||||
|
||||
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
|
||||
Vtk::Viewer viewer;
|
||||
viewer.AddPuppet(v_mesh);
|
||||
viewer.Start();
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(mesh.Points().size(), 3u);
|
||||
BOOST_CHECK_EQUAL(mesh.Triangles().size(), 1u);
|
||||
}
|
||||
58
src/Vtk/Math/testing/vtkVoxImageTest.cpp
Normal file
58
src/Vtk/Math/testing/vtkVoxImageTest.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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/Math/vtkVoxImage.h"
|
||||
#include "Math/VoxImage.h"
|
||||
|
||||
#define BOOST_TEST_MODULE VtkVoxImageTest
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
using namespace uLib;
|
||||
|
||||
struct TestVoxel {
|
||||
Scalarf Value;
|
||||
unsigned int Count;
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE(vtkVoxImageConstruction) {
|
||||
TestVoxel zero = {0, 0};
|
||||
TestVoxel nonzero = {5.5f * 1e-6f, 100};
|
||||
|
||||
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_vtkvoximage.vti");
|
||||
|
||||
if (std::getenv("CTEST_PROJECT_NAME") == nullptr) {
|
||||
Vtk::Viewer viewer;
|
||||
viewer.AddPuppet(vtk_img);
|
||||
viewer.Start();
|
||||
}
|
||||
|
||||
BOOST_CHECK(vtk_img.GetImageData() != nullptr);
|
||||
}
|
||||
42
src/Vtk/Math/vtkHLineRepresentation.h
Normal file
42
src/Vtk/Math/vtkHLineRepresentation.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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();
|
||||
};
|
||||
|
||||
} // namespace uLib
|
||||
|
||||
#endif // VTKHLINEREPRESENTATION_H
|
||||
114
src/Vtk/Math/vtkStructuredGrid.cpp
Normal file
114
src/Vtk/Math/vtkStructuredGrid.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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 "Math/StructuredGrid.h"
|
||||
#include "Vtk/Math/vtkStructuredGrid.h"
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////// VTK STRUCTURED GRID /////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
vtkStructuredGrid::vtkStructuredGrid(Content &content)
|
||||
: m_Content(&content), m_Actor(vtkActor::New()),
|
||||
m_Widget(vtkBoxWidget::New()), m_Transform(vtkTransform::New()) {
|
||||
vtkSmartPointer<vtkWidgetCallback> callback =
|
||||
vtkSmartPointer<vtkWidgetCallback>::New();
|
||||
callback->SetGrid(this);
|
||||
m_Widget->AddObserver(vtkCommand::InteractionEvent, callback);
|
||||
|
||||
this->InstallPipe();
|
||||
}
|
||||
|
||||
vtkStructuredGrid::~vtkStructuredGrid() {
|
||||
m_Actor->Delete();
|
||||
m_Widget->Delete();
|
||||
m_Transform->Delete();
|
||||
}
|
||||
|
||||
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);
|
||||
m_Content->SetMatrix(mat);
|
||||
|
||||
vtkSmartPointer<vtkMatrix4x4> vmat2 = vtkSmartPointer<vtkMatrix4x4>::New();
|
||||
mat = m_Content->GetWorldMatrix();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 4; ++j)
|
||||
vmat2->SetElement(i, j, mat(i, j));
|
||||
m_Transform->SetMatrix(vmat2);
|
||||
m_Transform->Update();
|
||||
this->Update();
|
||||
}
|
||||
|
||||
vtkBoxWidget *vtkStructuredGrid::GetWidget() { return m_Widget; }
|
||||
|
||||
void vtkStructuredGrid::Update() { 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 = m_Content->GetWorldMatrix();
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 4; ++j)
|
||||
vmat->SetElement(i, j, mat(i, j));
|
||||
m_Transform->SetMatrix(vmat);
|
||||
filter->SetTransform(m_Transform);
|
||||
filter->SetInputConnection(cube->GetOutputPort());
|
||||
|
||||
Vector3i dims = 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());
|
||||
|
||||
m_Actor->SetMapper(mapper);
|
||||
m_Actor->GetProperty()->SetRepresentationToSurface();
|
||||
m_Actor->GetProperty()->SetEdgeVisibility(true);
|
||||
m_Actor->GetProperty()->SetOpacity(0.4);
|
||||
m_Actor->GetProperty()->SetAmbient(0.7);
|
||||
this->Update();
|
||||
m_Widget->SetProp3D(m_Actor);
|
||||
|
||||
this->SetProp(m_Actor);
|
||||
}
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
92
src/Vtk/Math/vtkStructuredGrid.h
Normal file
92
src/Vtk/Math/vtkStructuredGrid.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <vtkActor.h>
|
||||
#include <vtkBoundingBox.h>
|
||||
#include <vtkCubeSource.h>
|
||||
#include <vtkLineSource.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkProperty.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
|
||||
#include <vtkBoxWidget.h>
|
||||
#include <vtkCommand.h>
|
||||
#include <vtkTransform.h>
|
||||
#include <vtkTransformPolyDataFilter.h>
|
||||
|
||||
#include "Math/Dense.h"
|
||||
|
||||
#include "Math/StructuredGrid.h"
|
||||
#include "Vtk/uLibVtkInterface.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();
|
||||
|
||||
class vtkWidgetCallback : public vtkCommand {
|
||||
public:
|
||||
static vtkWidgetCallback *New() { return new vtkWidgetCallback; }
|
||||
|
||||
void SetGrid(uLib::Vtk::vtkStructuredGrid *grid) { this->grid = grid; }
|
||||
|
||||
virtual void Execute(vtkObject *caller, unsigned long, void *) {
|
||||
vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();
|
||||
vtkBoxWidget *widget = reinterpret_cast<vtkBoxWidget *>(caller);
|
||||
widget->GetTransform(t);
|
||||
grid->SetTransform(t);
|
||||
}
|
||||
|
||||
private:
|
||||
uLib::Vtk::vtkStructuredGrid *grid;
|
||||
};
|
||||
|
||||
vtkActor *m_Actor;
|
||||
vtkBoxWidget *m_Widget;
|
||||
StructuredGrid *m_Content;
|
||||
vtkTransform *m_Transform;
|
||||
};
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
|
||||
#endif // VTKSTRUCTUREDGRID_H
|
||||
166
src/Vtk/Math/vtkTriangleMesh.cpp
Normal file
166
src/Vtk/Math/vtkTriangleMesh.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <vtkOBJReader.h>
|
||||
#include <vtkPolyDataReader.h>
|
||||
#include <vtkSTLReader.h>
|
||||
#include <vtkXMLPolyDataReader.h>
|
||||
|
||||
#include <vtkActor.h>
|
||||
#include <vtkCellArray.h>
|
||||
#include <vtkPoints.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
|
||||
#include "Vtk/Math/vtkTriangleMesh.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
void vtkTriangleMesh::vtk2uLib_update() {
|
||||
vtkIdType number_of_points = m_Poly->GetNumberOfPoints();
|
||||
vtkIdType number_of_triangles = m_Poly->GetNumberOfPolys();
|
||||
|
||||
std::cout << "//////\n"
|
||||
<< "number of points = " << number_of_points << "\n"
|
||||
<< "number 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];
|
||||
}
|
||||
|
||||
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->Modified();
|
||||
m_Actor->GetMapper()->Update();
|
||||
}
|
||||
|
||||
void vtkTriangleMesh::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->Modified();
|
||||
m_Actor->GetMapper()->Update();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------- //
|
||||
|
||||
vtkTriangleMesh::vtkTriangleMesh(vtkTriangleMesh::Content &content)
|
||||
: m_content(content), m_Poly(vtkPolyData::New()), m_Actor(vtkActor::New()) {
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputData(m_Poly);
|
||||
m_Actor->SetMapper(mapper);
|
||||
this->SetProp(m_Actor);
|
||||
}
|
||||
|
||||
vtkTriangleMesh::~vtkTriangleMesh() {
|
||||
m_Poly->Delete();
|
||||
m_Actor->Delete();
|
||||
}
|
||||
|
||||
void vtkTriangleMesh::ReadFromFile(const char *filename) {
|
||||
vtkSmartPointer<vtkPolyDataReader> reader =
|
||||
vtkSmartPointer<vtkPolyDataReader>::New();
|
||||
reader->SetFileName(filename);
|
||||
reader->Update();
|
||||
m_Poly->DeepCopy(reader->GetOutput());
|
||||
vtk2uLib_update();
|
||||
}
|
||||
|
||||
void vtkTriangleMesh::ReadFromXMLFile(const char *filename) {
|
||||
vtkSmartPointer<vtkXMLPolyDataReader> reader =
|
||||
vtkSmartPointer<vtkXMLPolyDataReader>::New();
|
||||
reader->SetFileName(filename);
|
||||
reader->Update();
|
||||
m_Poly->DeepCopy(reader->GetOutput());
|
||||
vtk2uLib_update();
|
||||
}
|
||||
|
||||
void vtkTriangleMesh::ReadFromObjFile(const char *filename) {
|
||||
vtkSmartPointer<vtkOBJReader> reader = vtkSmartPointer<vtkOBJReader>::New();
|
||||
reader->SetFileName(filename);
|
||||
reader->Update();
|
||||
m_Poly->DeepCopy(reader->GetOutput());
|
||||
vtk2uLib_update();
|
||||
}
|
||||
|
||||
void vtkTriangleMesh::ReadFromStlFile(const char *filename) {
|
||||
vtkSmartPointer<vtkSTLReader> reader = vtkSmartPointer<vtkSTLReader>::New();
|
||||
reader->SetFileName(filename);
|
||||
reader->Update();
|
||||
m_Poly->DeepCopy(reader->GetOutput());
|
||||
vtk2uLib_update();
|
||||
}
|
||||
|
||||
vtkPolyData *vtkTriangleMesh::GetPolyData() const { return m_Poly; }
|
||||
|
||||
void vtkTriangleMesh::Update() { uLib2vtk_update(); }
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
69
src/Vtk/Math/vtkTriangleMesh.h
Normal file
69
src/Vtk/Math/vtkTriangleMesh.h
Normal 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 "Math/TriangleMesh.h"
|
||||
#include "Vtk/uLibVtkInterface.h"
|
||||
|
||||
class vtkPolyData;
|
||||
class vtkActor;
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
class vtkTriangleMesh : public Puppet, public Polydata {
|
||||
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 vtkPolyData *GetPolyData() const;
|
||||
|
||||
void Update();
|
||||
|
||||
private:
|
||||
void vtk2uLib_update();
|
||||
void uLib2vtk_update();
|
||||
|
||||
TriangleMesh &m_content;
|
||||
vtkPolyData *m_Poly;
|
||||
vtkActor *m_Actor;
|
||||
};
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
|
||||
#endif // VTKTRIANGLEMESH_H
|
||||
286
src/Vtk/Math/vtkVoxImage.cpp
Normal file
286
src/Vtk/Math/vtkVoxImage.cpp
Normal file
@@ -0,0 +1,286 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <vtkImageExport.h>
|
||||
#include <vtkImageImport.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
|
||||
#include <vtkFloatArray.h>
|
||||
#include <vtkPointData.h>
|
||||
|
||||
#include <vtkGenericDataObjectReader.h>
|
||||
#include <vtkImageShiftScale.h>
|
||||
|
||||
#include <vtkColorTransferFunction.h>
|
||||
#include <vtkPiecewiseFunction.h>
|
||||
#include <vtkSmartVolumeMapper.h>
|
||||
#include <vtkVolumeProperty.h>
|
||||
|
||||
#include <vtkActor.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkProperty.h>
|
||||
|
||||
#include <Math/VoxImage.h>
|
||||
|
||||
#include "Vtk/Math/vtkVoxImage.h"
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
void vtkVoxImage::GetContent() {
|
||||
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]);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void vtkVoxImage::SetContent() {
|
||||
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]));
|
||||
|
||||
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)
|
||||
: m_Content(content), m_Actor(vtkVolume::New()),
|
||||
m_Image(vtkImageData::New()), m_Outline(vtkCubeSource::New()),
|
||||
m_Reader(NULL), m_Writer(NULL), writer_factor(1.E6) {
|
||||
GetContent();
|
||||
InstallPipe();
|
||||
}
|
||||
|
||||
vtkVoxImage::~vtkVoxImage() {
|
||||
m_Image->Delete();
|
||||
m_Actor->Delete();
|
||||
m_Outline->Delete();
|
||||
}
|
||||
|
||||
vtkImageData *vtkVoxImage::GetImageData() {
|
||||
GetContent();
|
||||
return m_Image;
|
||||
}
|
||||
|
||||
void vtkVoxImage::SaveToXMLFile(const char *fname) {
|
||||
vtkSmartPointer<vtkXMLImageDataWriter> writer =
|
||||
vtkSmartPointer<vtkXMLImageDataWriter>::New();
|
||||
writer->SetFileName(fname);
|
||||
GetContent();
|
||||
vtkSmartPointer<vtkImageShiftScale> vtkscale =
|
||||
vtkSmartPointer<vtkImageShiftScale>::New();
|
||||
|
||||
#if VTK_MAJOR_VERSION <= 5
|
||||
vtkscale->SetInputConnection(m_Image->GetProducerPort());
|
||||
#else
|
||||
vtkscale->SetInputData(m_Image);
|
||||
#endif
|
||||
vtkscale->SetScale(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 / writer_factor);
|
||||
vtkscale->Update();
|
||||
|
||||
m_Image->DeepCopy(vtkscale->GetOutput());
|
||||
SetContent();
|
||||
} else {
|
||||
std::cerr << "Error: file does not contain structured points\n";
|
||||
}
|
||||
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 / writer_factor);
|
||||
vtkscale->Update();
|
||||
|
||||
m_Image->DeepCopy(vtkscale->GetOutput());
|
||||
SetContent();
|
||||
}
|
||||
|
||||
void vtkVoxImage::setShadingPreset(int blendType) {
|
||||
vtkSmartVolumeMapper *mapper = (vtkSmartVolumeMapper *)m_Actor->GetMapper();
|
||||
vtkVolumeProperty *property = 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) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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() {
|
||||
m_Actor->Update();
|
||||
m_Outline->SetBounds(m_Image->GetBounds());
|
||||
m_Outline->Update();
|
||||
}
|
||||
|
||||
void vtkVoxImage::InstallPipe() {
|
||||
vtkSmartPointer<vtkSmartVolumeMapper> mapper =
|
||||
vtkSmartPointer<vtkSmartVolumeMapper>::New();
|
||||
#if VTK_MAJOR_VERSION <= 5
|
||||
mapper->SetInputConnection(m_Image->GetProducerPort());
|
||||
#else
|
||||
mapper->SetInputData(m_Image);
|
||||
#endif
|
||||
mapper->Update();
|
||||
|
||||
m_Actor->SetMapper(mapper);
|
||||
this->setShadingPreset(0);
|
||||
mapper->Update();
|
||||
|
||||
m_Outline->SetBounds(m_Image->GetBounds());
|
||||
vtkSmartPointer<vtkPolyDataMapper> mmapper =
|
||||
vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mmapper->SetInputConnection(m_Outline->GetOutputPort());
|
||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||
actor->SetMapper(mmapper);
|
||||
actor->GetProperty()->SetRepresentationToWireframe();
|
||||
actor->GetProperty()->SetAmbient(0.7);
|
||||
|
||||
this->SetProp(m_Actor);
|
||||
}
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
89
src/Vtk/Math/vtkVoxImage.h
Normal file
89
src/Vtk/Math/vtkVoxImage.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// 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 <vtkCubeSource.h>
|
||||
#include <vtkImageData.h>
|
||||
#include <vtkVolume.h>
|
||||
#include <vtkXMLImageDataReader.h>
|
||||
#include <vtkXMLImageDataWriter.h>
|
||||
|
||||
#include <Math/VoxImage.h>
|
||||
|
||||
#include "Vtk/uLibVtkInterface.h"
|
||||
|
||||
class vtkImageData;
|
||||
|
||||
namespace uLib {
|
||||
namespace Vtk {
|
||||
|
||||
class vtkVoxImage : public Puppet {
|
||||
public:
|
||||
typedef Abstract::VoxImage Content;
|
||||
|
||||
vtkVoxImage(Content &content);
|
||||
|
||||
~vtkVoxImage();
|
||||
|
||||
void GetContent();
|
||||
|
||||
void SetContent();
|
||||
|
||||
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();
|
||||
float writer_factor;
|
||||
|
||||
private:
|
||||
vtkVolume *m_Actor;
|
||||
vtkImageData *m_Image;
|
||||
vtkCubeSource *m_Outline;
|
||||
|
||||
vtkXMLImageDataReader *m_Reader;
|
||||
vtkXMLImageDataWriter *m_Writer;
|
||||
|
||||
vtkVoxImage::Content &m_Content;
|
||||
|
||||
float m_Window;
|
||||
float m_Level;
|
||||
};
|
||||
|
||||
} // namespace Vtk
|
||||
} // namespace uLib
|
||||
|
||||
#endif // VTKVOXIMAGE_H
|
||||
Reference in New Issue
Block a user