feat: add CUDA raytracing benchmark and refactor VoxRaytracer::RayData to use DataAllocator for host/device memory management.

This commit is contained in:
AndreaRigoni
2026-03-04 17:47:18 +00:00
parent eb76521060
commit adedbcc37c
12 changed files with 1013 additions and 364 deletions

View File

@@ -19,6 +19,11 @@ set(LIBRARIES Eigen3::Eigen
${VTK_LIBRARIES}
${PACKAGE_LIBPREFIX}Math)
if(USE_CUDA)
find_package(CUDAToolkit REQUIRED)
list(APPEND LIBRARIES CUDA::cudart)
endif()
set(libname ${PACKAGE_LIBPREFIX}Vtk)
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Vtk PARENT_SCOPE)

View File

@@ -23,21 +23,17 @@
//////////////////////////////////////////////////////////////////////////////*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "vtkVoxRaytracerRepresentation.h"
#include "Math/VoxRaytracer.h"
//#include "vtkMuonEvent.h"
// #include "vtkMuonEvent.h"
#include "vtkMuonScatter.h"
namespace uLib {
namespace Vtk {
@@ -45,345 +41,297 @@ namespace Vtk {
////// VOX RAYTRACER REPRESENTATION ///////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &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;
InstallPipe();
}
vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &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);
vtkVoxRaytracerRepresentation::~vtkVoxRaytracerRepresentation() {
m_Assembly->Delete();
m_RayLine->Delete();
m_RayLineActor->Delete();
m_RayRepresentationActor->Delete();
m_Transform->Delete();
}
VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm() {
return m_Content;
}
vtkProp *vtkVoxRaytracerRepresentation::GetProp() { return m_Assembly; }
vtkPolyData *vtkVoxRaytracerRepresentation::GetPolyData() const {
std::cout << "get Raytracer polydata\n";
m_SelectedElement->Update();
return m_SelectedElement->GetOutput();
}
void vtkVoxRaytracerRepresentation::SetRepresentationElements(
vtkVoxRaytracerRepresentation::RepresentationElements el) {
switch (el) {
case Vtk::vtkVoxRaytracerRepresentation::RayElements:
m_SelectedElement = m_RayLine;
InstallPipe();
break;
case Vtk::vtkVoxRaytracerRepresentation::VoxelsElements:
m_SelectedElement = m_RayRepresentation;
break;
default:
m_SelectedElement = m_RayLine;
break;
}
}
vtkVoxRaytracerRepresentation::~vtkVoxRaytracerRepresentation()
{
m_Assembly->Delete();
m_RayLine->Delete();
m_RayLineActor->Delete();
m_RayRepresentationActor->Delete();
m_Transform->Delete();
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon) {
HPoint3f pt1, pt2, src;
src = muon.LineIn().origin;
m_Content->GetEntryPoint(muon.LineIn(), pt1);
m_Sphere1->SetCenter(pt1(0), pt1(1), pt1(2));
m_Line1->SetPoint1(src(0), src(1), src(2));
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;
m_Content->GetEntryPoint(line_out, pt2);
m_Sphere2->SetCenter(pt2(0), pt2(1), pt2(2));
m_Line2->SetPoint1(src(0), src(1), src(2));
m_Line2->SetPoint2(pt2(0), pt2(1), pt2(2));
m_Line3->SetPoint1(pt1(0), pt1(1), pt1(2));
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);
m_RayLine->RemoveAllInputs();
#if VTK_MAJOR_VERSION <= 5
m_RayLine->AddInputConnection(linesPolyData->GetProducerPort());
#endif
m_RayLine->AddInputConnection(m_Line1->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere1->GetOutputPort());
m_RayLine->AddInputConnection(m_Line2->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere2->GetOutputPort());
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = 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));
m_Transform->SetMatrix(vmat);
this->SetRay(pt1, pt2);
}
VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm()
{
return m_Content;
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca) {
HPoint3f pt1, pt2, src;
src = muon.LineIn().origin;
m_Content->GetEntryPoint(muon.LineIn(), pt1);
m_Sphere1->SetCenter(pt1(0), pt1(1), pt1(2));
m_Line1->SetPoint1(src(0), src(1), src(2));
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;
m_Content->GetEntryPoint(line_out, pt2);
m_Sphere2->SetCenter(pt2(0), pt2(1), pt2(2));
m_Line2->SetPoint1(src(0), src(1), src(2));
m_Line2->SetPoint2(pt2(0), pt2(1), pt2(2));
m_Line3->SetPoint1(pt1(0), pt1(1), pt1(2));
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);
m_RayLine->RemoveAllInputs();
#if VTK_MAJOR_VERSION <= 5
m_RayLine->AddInputConnection(linesPolyData->GetProducerPort());
#endif
m_RayLine->AddInputConnection(m_Line1->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere1->GetOutputPort());
m_RayLine->AddInputConnection(m_Line2->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere2->GetOutputPort());
vtkSmartPointer<vtkSphereSource> poca_sphere =
vtkSmartPointer<vtkSphereSource>::New();
poca_sphere->SetRadius(default_radius);
poca_sphere->SetCenter(poca(0), poca(1), poca(2));
m_RayLine->AddInputConnection(poca_sphere->GetOutputPort());
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = 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));
m_Transform->SetMatrix(vmat);
if (m_Content->GetImage()->IsInsideBounds(poca))
this->SetRay(pt1, poca, pt2);
else
this->SetRay(pt1, pt2);
}
vtkProp *vtkVoxRaytracerRepresentation::GetProp()
{
return m_Assembly;
void vtkVoxRaytracerRepresentation::SetMuon(vtkMuonScatter &muon) {
HPoint3f poca = muon.GetPocaPoint();
MuonScatter &mu = muon.GetContent();
this->SetMuon(mu, poca);
}
vtkPolyData *vtkVoxRaytracerRepresentation::GetPolyData() const
{
std::cout << "get Raytracer polydata\n";
m_SelectedElement->Update();
return m_SelectedElement->GetOutput();
VoxRaytracer::RayData vtkVoxRaytracerRepresentation::GetRay() { return m_Ray; }
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f out) {
m_Ray = m_Content->TraceBetweenPoints(in, out);
this->SetRay(&m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRepresentationElements(vtkVoxRaytracerRepresentation::RepresentationElements el)
{
switch(el) {
case Vtk::vtkVoxRaytracerRepresentation::RayElements:
m_SelectedElement = m_RayLine;
break;
case Vtk::vtkVoxRaytracerRepresentation::VoxelsElements:
m_SelectedElement = m_RayRepresentation;
break;
default:
m_SelectedElement = m_RayLine;
break;
}
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f mid,
HPoint3f out) {
m_Ray = m_Content->TraceBetweenPoints(in, mid);
m_Ray.AppendRay(m_Content->TraceBetweenPoints(mid, out));
this->SetRay(&m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray) {
vtkAppendPolyData *appender = m_RayRepresentation;
appender->RemoveAllInputs();
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon)
{
HPoint3f pt1,pt2,src;
src = muon.LineIn().origin;
m_Content->GetEntryPoint(muon.LineIn(),pt1);
m_Sphere1->SetCenter(pt1(0),pt1(1),pt1(2));
m_Line1->SetPoint1(src(0),src(1),src(2));
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;
m_Content->GetEntryPoint(line_out,pt2);
m_Sphere2->SetCenter(pt2(0),pt2(1),pt2(2));
m_Line2->SetPoint1(src(0),src(1),src(2));
m_Line2->SetPoint2(pt2(0),pt2(1),pt2(2));
m_Line3->SetPoint1(pt1(0),pt1(1),pt1(2));
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);
m_RayLine->RemoveAllInputs();
# if VTK_MAJOR_VERSION <= 5
m_RayLine->AddInputConnection(linesPolyData->GetProducerPort());
# endif
m_RayLine->AddInputConnection(m_Line1->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere1->GetOutputPort());
m_RayLine->AddInputConnection(m_Line2->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere2->GetOutputPort());
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = 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));
m_Transform->SetMatrix(vmat);
this->SetRay(pt1,pt2);
for (size_t i = 0; i < ray->Count(); ++i) {
int id = ray->Data().at(i).vox_id;
Vector3i idv = 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());
#endif
appender->Update();
}
}
void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca)
{
HPoint3f pt1,pt2,src;
src = muon.LineIn().origin;
m_Content->GetEntryPoint(muon.LineIn(),pt1);
m_Sphere1->SetCenter(pt1(0),pt1(1),pt1(2));
m_Line1->SetPoint1(src(0),src(1),src(2));
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;
m_Content->GetEntryPoint(line_out,pt2);
m_Sphere2->SetCenter(pt2(0),pt2(1),pt2(2));
m_Line2->SetPoint1(src(0),src(1),src(2));
m_Line2->SetPoint2(pt2(0),pt2(1),pt2(2));
m_Line3->SetPoint1(pt1(0),pt1(1),pt1(2));
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);
m_RayLine->RemoveAllInputs();
# if VTK_MAJOR_VERSION <= 5
m_RayLine->AddInputConnection(linesPolyData->GetProducerPort());
# endif
m_RayLine->AddInputConnection(m_Line1->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere1->GetOutputPort());
m_RayLine->AddInputConnection(m_Line2->GetOutputPort());
m_RayLine->AddInputConnection(m_Sphere2->GetOutputPort());
vtkSmartPointer<vtkSphereSource> poca_sphere =
vtkSmartPointer<vtkSphereSource>::New();
poca_sphere->SetRadius(default_radius);
poca_sphere->SetCenter(poca(0),poca(1),poca(2));
m_RayLine->AddInputConnection(poca_sphere->GetOutputPort());
vtkSmartPointer<vtkMatrix4x4> vmat = vtkSmartPointer<vtkMatrix4x4>::New();
Matrix4f mat = 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));
m_Transform->SetMatrix(vmat);
if(m_Content->GetImage()->IsInsideBounds(poca))
this->SetRay(pt1,poca,pt2);
else
this->SetRay(pt1,pt2);
void vtkVoxRaytracerRepresentation::SetVoxelsColor(Vector4f rgba) {
this->SetColor(m_RayRepresentationActor, rgba);
}
void vtkVoxRaytracerRepresentation::SetMuon(vtkMuonScatter &muon)
{
HPoint3f poca = muon.GetPocaPoint();
MuonScatter &mu = muon.GetContent();
this->SetMuon(mu,poca);
void vtkVoxRaytracerRepresentation::SetRayColor(Vector4f rgba) {
this->SetColor(m_RayLineActor, rgba);
}
VoxRaytracer::RayData vtkVoxRaytracerRepresentation::GetRay()
{
return m_Ray;
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::SetRay(HPoint3f in, HPoint3f out)
{
m_Ray = m_Content->TraceBetweenPoints(in,out);
this->SetRay(&m_Ray);
void vtkVoxRaytracerRepresentation::InstallPipe() {
vtkSmartPointer<vtkAppendPolyData> append =
vtkSmartPointer<vtkAppendPolyData>::New();
append->AddInputConnection(m_Sphere1->GetOutputPort());
append->AddInputConnection(m_Sphere2->GetOutputPort());
append->AddInputConnection(m_Line1->GetOutputPort());
append->AddInputConnection(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(m_RayLine->GetOutputPort());
mapper->Update();
m_RayLineActor->SetMapper(mapper);
m_RayLineActor->GetProperty()->SetColor(1, 0, 0);
this->SetProp(m_RayLineActor);
vtkSmartPointer<vtkTransformPolyDataFilter> polyfilter =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
polyfilter->SetInputConnection(m_RayRepresentation->GetOutputPort());
polyfilter->SetTransform(m_Transform);
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(polyfilter->GetOutputPort());
mapper->Update();
vtkActor *vra = 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);
}
void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f mid, HPoint3f out)
{
m_Ray = m_Content->TraceBetweenPoints(in,mid);
m_Ray.AppendRay( m_Content->TraceBetweenPoints(mid,out) );
this->SetRay(&m_Ray);
}
void vtkVoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray)
{
vtkAppendPolyData *appender = m_RayRepresentation;
appender->RemoveAllInputs();
for(int i=0; i<ray->Data().size(); ++i) {
int id = ray->Data().at(i).vox_id;
Vector3i idv = 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());
# endif
appender->Update();
}
}
void vtkVoxRaytracerRepresentation::SetVoxelsColor(Vector4f rgba)
{
this->SetColor(m_RayRepresentationActor,rgba);
}
void vtkVoxRaytracerRepresentation::SetRayColor(Vector4f rgba)
{
this->SetColor(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(m_Sphere1->GetOutputPort());
append->AddInputConnection(m_Sphere2->GetOutputPort());
append->AddInputConnection(m_Line1->GetOutputPort());
append->AddInputConnection(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(m_RayLine->GetOutputPort());
mapper->Update();
m_RayLineActor->SetMapper(mapper);
m_RayLineActor->GetProperty()->SetColor(1,0,0);
this->SetProp(m_RayLineActor);
vtkSmartPointer<vtkTransformPolyDataFilter> polyfilter =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
polyfilter->SetInputConnection(m_RayRepresentation->GetOutputPort());
polyfilter->SetTransform(m_Transform);
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(polyfilter->GetOutputPort());
mapper->Update();
vtkActor *vra = 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
} // namespace Vtk
} // namespace uLib