From d02a0950282d7b2ec348b89dc85e74668c7a86b5 Mon Sep 17 00:00:00 2001 From: Paolo Andreetto Date: Fri, 10 May 2019 13:22:00 +0000 Subject: [PATCH] Removed macros.h and pimpl --- src/Detectors/HitMC.h | 11 +- src/Detectors/LinearFit.h | 38 ++-- src/Detectors/MuonError.h | 12 +- src/Detectors/MuonEvent.h | 16 +- src/Detectors/MuonScatter.h | 26 +-- src/Math/StructuredData.h | 9 +- src/Math/Transform.h | 16 +- src/Vtk/vtkMuonContainerScattering.h | 3 - src/Vtk/vtkMuonEvent.cxx | 110 +++------- src/Vtk/vtkMuonEvent.h | 26 ++- src/Vtk/vtkMuonScatter.cxx | 121 ++++------- src/Vtk/vtkMuonScatter.h | 24 ++- src/Vtk/vtkStructuredGrid.cpp | 118 +++------- src/Vtk/vtkStructuredGrid.h | 38 +++- src/Vtk/vtkVoxRaytracerRepresentation.cpp | 248 ++++++++-------------- src/Vtk/vtkVoxRaytracerRepresentation.h | 37 +++- 16 files changed, 363 insertions(+), 490 deletions(-) diff --git a/src/Detectors/HitMC.h b/src/Detectors/HitMC.h index 95404b2..53f3f3a 100644 --- a/src/Detectors/HitMC.h +++ b/src/Detectors/HitMC.h @@ -28,7 +28,6 @@ #ifndef U_HITMC_H #define U_HITMC_H -#include "Core/Macros.h" #include "Math/Dense.h" #include "Hit.h" @@ -43,10 +42,10 @@ public: DeltaRay }; - uLibConstRefMacro(Position,HPoint3f) - uLibGetMacro(Type, enum Type) + inline const HPoint3f & Position() const { return this->m_Position; } + inline enum Type GetType() const { return this->m_Type; } -private: +protected: HPoint3f m_Position; enum Type m_Type; }; @@ -54,8 +53,8 @@ private: class HitMC : public HitMCData { public: - uLibRefMacro(Position,HPoint3f) - uLibSetMacro(Type, enum Type) + inline HPoint3f & Position() { return this->m_Position; } + inline void SetType(enum Type name) { this->m_Type = name; } }; diff --git a/src/Detectors/LinearFit.h b/src/Detectors/LinearFit.h index 9419e69..a09841d 100644 --- a/src/Detectors/LinearFit.h +++ b/src/Detectors/LinearFit.h @@ -28,7 +28,6 @@ #ifndef U_LINEARFIT_H #define U_LINEARFIT_H -#include "Core/Macros.h" #include "Math/Dense.h" #include "ChamberDetector.h" @@ -37,32 +36,31 @@ namespace uLib { class LinearFitData { public: - uLibConstRefMacro(Position,Vector2f) - uLibConstRefMacro(Slope,Vector2f) - uLibConstRefMacro(PositionError,Vector2f) - uLibConstRefMacro(SlopeError,Vector2f) - uLibGetMacro(HitsNumber,int) - uLibGetMacro(Idv,ChamberDetector::ID) + inline const Vector2f & Position() const { return this->m_Position; } + inline const Vector2f & Slope() const { return this->m_Slope; } + inline const Vector2f & PositionError() const { return this->m_PositionError; } + inline const Vector2f & SlopeError() const { return this->m_SlopeError; } + inline int GetHitsNumber() const { return this->m_HitsNumber; } + inline ChamberDetector::ID GetIdv() const { return this->m_Idv; } -private: - friend class LinearFit; - Vector2f m_Position; - Vector2f m_Slope; - Vector2f m_PositionError; - Vector2f m_SlopeError; - int m_HitsNumber; +protected: + Vector2f m_Position; + Vector2f m_Slope; + Vector2f m_PositionError; + Vector2f m_SlopeError; + int m_HitsNumber; DetectorChamber::ID m_Idv; }; class LinearFit : public LinearFitData { public: - uLibRefMacro(Position,Vector2f) - uLibRefMacro(Slope,Vector2f) - uLibRefMacro(PositionError,Vector2f) - uLibRefMacro(SlopeError,Vector2f) - uLibSetMacro(HitsNumber,int) - uLibSetMacro(Idv,ChamberDetector::ID) + inline Vector2f & Position() { return this->m_Position; } + inline Vector2f & Slope() { return this->m_Slope; } + inline Vector2f & PositionError() { return this->m_PositionError; } + inline Vector2f & SlopeError() { return this->m_SlopeError; } + inline void SetHitsNumber(int name) { this->m_HitsNumber = name; } + inline void SetIdv(ChamberDetector::ID name) { this->m_Idv = name; } }; diff --git a/src/Detectors/MuonError.h b/src/Detectors/MuonError.h index 47aa570..3bbf5fd 100644 --- a/src/Detectors/MuonError.h +++ b/src/Detectors/MuonError.h @@ -28,18 +28,16 @@ #ifndef U_MUONERROR_H #define U_MUONERROR_H -#include "Core/Macros.h" #include "Math/Dense.h" namespace uLib { class MuonErrorData { - friend class MuonError; public: - uLibConstRefMacro(Theta,Scalarf) - uLibConstRefMacro(Phi,Scalarf) -private: + inline const Scalarf & Theta() const { return this->m_Theta; } + inline const Scalarf & Phi() const { return this->m_Phi; } +protected: Scalarf m_Theta; Scalarf m_Phi; }; @@ -47,8 +45,8 @@ private: class MuonError : public MuonErrorData { public: - uLibRefMacro(Theta,Scalarf) - uLibRefMacro(Phi,Scalarf) + inline Scalarf & Theta() { return this->m_Theta; } + inline Scalarf & Phi() { return this->m_Phi; } }; diff --git a/src/Detectors/MuonEvent.h b/src/Detectors/MuonEvent.h index 72e5c9b..f779681 100644 --- a/src/Detectors/MuonEvent.h +++ b/src/Detectors/MuonEvent.h @@ -28,20 +28,18 @@ #ifndef U_MUONEVENT_H #define U_MUONEVENT_H -#include "Core/Macros.h" #include "Math/Dense.h" namespace uLib { class MuonEventData { - friend class MuonEvent; public: - uLibConstRefMacro(LineIn,HLine3f) - uLibConstRefMacro(LineOut,HLine3f) - uLibGetMacro(Momentum,Scalarf) + inline const HLine3f & LineIn() const { return this->m_LineIn; } + inline const HLine3f & LineOut() const { return this->m_LineOut; } + inline Scalarf GetMomentum() const { return this->m_Momentum; } -private: +protected: HLine3f m_LineIn; HLine3f m_LineOut; Scalarf m_Momentum; @@ -50,9 +48,9 @@ private: class MuonEvent : public MuonEventData { public: - uLibRefMacro(LineIn,HLine3f) - uLibRefMacro(LineOut,HLine3f) - uLibRefMacro(Momentum,Scalarf) + inline HLine3f & LineIn() { return this->m_LineIn; } + inline HLine3f & LineOut() { return this->m_LineOut; } + inline Scalarf & Momentum() { return this->m_Momentum; } }; diff --git a/src/Detectors/MuonScatter.h b/src/Detectors/MuonScatter.h index 48552d9..cb930f7 100644 --- a/src/Detectors/MuonScatter.h +++ b/src/Detectors/MuonScatter.h @@ -29,7 +29,6 @@ #ifndef U_MUONSCATTER_H #define U_MUONSCATTER_H -#include "Core/Macros.h" #include "Math/Dense.h" namespace uLib { @@ -37,20 +36,21 @@ namespace uLib { class MuonScatter { public: - uLibConstRefMacro(LineIn,HLine3f) - uLibConstRefMacro(ErrorIn,HError3f) - uLibConstRefMacro(LineOut,HLine3f) - uLibConstRefMacro(ErrorOut,HError3f) + inline const HLine3f & LineIn() const { return this->m_LineIn; } + inline const HError3f & ErrorIn() const { return this->m_ErrorIn; } + inline const HLine3f & LineOut() const { return this->m_LineOut; } + inline const HError3f & ErrorOut() const { return this->m_ErrorOut; } - uLibRefMacro(LineIn,HLine3f) - uLibRefMacro(ErrorIn,HError3f) - uLibRefMacro(LineOut,HLine3f) - uLibRefMacro(ErrorOut,HError3f) - uLibSetMacro(Momentum,Scalarf) - uLibSetMacro(MomentumPrime,Scalarf) + inline HLine3f & LineIn() { return this->m_LineIn; } + inline HError3f & ErrorIn() { return this->m_ErrorIn; } + inline HLine3f & LineOut() { return this->m_LineOut; } + inline HError3f & ErrorOut() { return this->m_ErrorOut; } - uLibGetMacro(Momentum,Scalarf) - uLibGetMacro(MomentumPrime,Scalarf) + inline void SetMomentum(Scalarf name) { this->m_Momentum = name; } + inline void SetMomentumPrime(Scalarf name) { this->m_MomentumPrime = name; } + + inline Scalarf GetMomentum() const { return this->m_Momentum; } + inline Scalarf GetMomentumPrime() const { return this->m_MomentumPrime; } protected: HLine3f m_LineIn; diff --git a/src/Math/StructuredData.h b/src/Math/StructuredData.h index f92b6d0..56a8f38 100644 --- a/src/Math/StructuredData.h +++ b/src/Math/StructuredData.h @@ -28,7 +28,6 @@ #ifndef STRUCTUREDDATA_H #define STRUCTUREDDATA_H -#include "Core/Macros.h" #include "Core/Object.h" #include "Math/Dense.h" @@ -60,15 +59,17 @@ public: {} - uLibGetMacro(Dims,Vector3i) + inline Vector3i GetDims() const { return this->m_Dims; } void SetDims(const Vector3i &size); - uLibGetSetMacro(Increments,Vector3i) + inline Vector3i GetIncrements() const { return this->m_Increments; } + + inline void SetIncrements(Vector3i name) { this->m_Increments = name; } void SetDataOrder(Order order = YXZ); - uLibGetMacro(DataOrder,Order) + inline Order GetDataOrder() const { return this->m_DataOrder; } bool IsInsideGrid(const Vector3i &v) const; diff --git a/src/Math/Transform.h b/src/Math/Transform.h index 9982a89..f3a5b9b 100644 --- a/src/Math/Transform.h +++ b/src/Math/Transform.h @@ -25,31 +25,30 @@ -/* +/* * Copyright (C) 2012 Andrea Rigoni Garola - * + * * 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 2.1 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 not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA - * + * */ #ifndef U_TRANSFORM_H #define U_TRANSFORM_H -#include #include @@ -80,7 +79,10 @@ public: {} Eigen::Affine3f& GetTransform() { return m_T; } - uLibGetSetMacro(Parent,AffineTransform *) + + inline AffineTransform *GetParent() const { return this->m_Parent; } + + inline void SetParent(AffineTransform *name) { this->m_Parent = name; } inline void SetMatrix (Matrix4f &mat) { m_T.matrix() = mat; } inline Matrix4f& GetMatrix () { return m_T.matrix(); } diff --git a/src/Vtk/vtkMuonContainerScattering.h b/src/Vtk/vtkMuonContainerScattering.h index b1ef9be..d7f12d9 100644 --- a/src/Vtk/vtkMuonContainerScattering.h +++ b/src/Vtk/vtkMuonContainerScattering.h @@ -30,7 +30,6 @@ -#include "Core/Macros.h" #include "Math/Dense.h" #include "uLibVtkInterface.h" @@ -66,8 +65,6 @@ protected: private: void InstallPipe(); - friend class vtkMuonContainerScatteringPimpl; - class vtkMuonContainerScatteringPimpl *d; }; diff --git a/src/Vtk/vtkMuonEvent.cxx b/src/Vtk/vtkMuonEvent.cxx index db34b24..e81368c 100644 --- a/src/Vtk/vtkMuonEvent.cxx +++ b/src/Vtk/vtkMuonEvent.cxx @@ -29,22 +29,6 @@ #include "config.h" #endif - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - #include "vtkMuonEvent.h" #include "Math/Dense.h" @@ -72,105 +56,77 @@ private: }; -//// 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) + m_Prop(vtkActor::New()), + m_PolyData(NULL), + m_Appender(vtkAppendPolyData::New()), + content(&content) { - d->content = &content; - InstallPipe(); + InstallPipe(); } vtkMuonEvent::vtkMuonEvent(const MuonEventData &content) : - d(new vtkMuonEventPimpl) + m_Prop(vtkActor::New()), + m_PolyData(NULL), + m_Appender(vtkAppendPolyData::New()), + content(const_cast(&content)) { - d->content = const_cast(&content); - InstallPipe(); + InstallPipe(); } vtkMuonEvent::~vtkMuonEvent() { - if (d->m_Prop) d->m_Prop->Delete(); + if (m_Prop) m_Prop->Delete(); } vtkMuonEvent::Content &vtkMuonEvent::GetContent() { - return *d->content; + return *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" << + "\t[in] Origin > " << content->LineIn().origin.transpose() << "\n" << + "\t[in] Direction > " << content->LineIn().direction.transpose() << "\n" << + "\t[out] Origin > " << content->LineOut().origin.transpose() << "\n" << + "\t[out] Direction > " << content->LineOut().direction.transpose()<< "\n" << + "\tMomentum > " << content->GetMomentum() << "\n" << "...................\n"; } vtkProp *vtkMuonEvent::GetProp() { - return d->m_Prop; + return m_Prop; } void vtkMuonEvent::InstallPipe() { - vtkAppendPolyData *appender = d->m_Appender; + vtkAppendPolyData *appender = m_Appender; vtkSmartPointer mapper = vtkSmartPointer::New(); - if(d->content) { + if(content) { vtkSmartPointer line_in = vtkSmartPointer::New(); vtkSmartPointer line_out = vtkSmartPointer::New(); - float distance = (d->content->LineIn().origin - d->content->LineOut().origin).norm() / 10; + float distance = (content->LineIn().origin - content->LineOut().origin).norm() / 10; - HPoint3f pt; - pt = d->content->LineIn().origin; + HPoint3f pt; + pt = content->LineIn().origin; line_in->SetPoint1(pt(0),pt(1),pt(2)); - pt= d->content->LineIn().origin + d->content->LineIn().direction * distance; + pt= content->LineIn().origin + content->LineIn().direction * distance; line_in->SetPoint2(pt(0),pt(1),pt(2)); - pt = d->content->LineOut().origin; + pt = content->LineOut().origin; line_out->SetPoint1(pt(0),pt(1),pt(2)); - pt = d->content->LineOut().origin + d->content->LineOut().direction * distance; + pt = content->LineOut().origin + content->LineOut().direction * distance; line_out->SetPoint2(pt(0),pt(1),pt(2)); appender->AddInputConnection(line_in->GetOutputPort()); @@ -180,31 +136,31 @@ void vtkMuonEvent::InstallPipe() appender->Update(); mapper->SetInputConnection(appender->GetOutputPort()); mapper->Update(); - d->m_Prop->SetMapper(mapper); + m_Prop->SetMapper(mapper); } vtkPolyData *vtkMuonEvent::GetPolyData() const { - return d->m_Appender->GetOutput(); + return m_Appender->GetOutput(); } void vtkMuonEvent::AddPocaPoint(HPoint3f poca) { - d->m_Poca = poca; + m_Poca = poca; vtkSmartPointer sphere = vtkSmartPointer::New(); - float size = (d->content->LineIn().origin - d->content->LineOut().origin).head(3).norm(); + float size = (content->LineIn().origin - 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(); + m_Appender->AddInputConnection(sphere->GetOutputPort()); + m_Appender->Update(); } HPoint3f vtkMuonEvent::GetPocaPoint() { - return d->m_Poca; + return m_Poca; } diff --git a/src/Vtk/vtkMuonEvent.h b/src/Vtk/vtkMuonEvent.h index 310fc08..58a996c 100644 --- a/src/Vtk/vtkMuonEvent.h +++ b/src/Vtk/vtkMuonEvent.h @@ -28,7 +28,21 @@ #ifndef VTKMUONEVENT_H #define VTKMUONEVENT_H -#include "Core/Macros.h" +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + #include "Math/Dense.h" #include "uLibVtkInterface.h" @@ -64,8 +78,14 @@ public: private: void InstallPipe(); - friend class vtkMuonEventPimpl; - class vtkMuonEventPimpl *d; + vtkMuonEvent::Content *content; + vtkPolyData *m_PolyData; + vtkActor *m_Prop; + + vtkAppendPolyData *m_Appender; + vtkBoxWidget *m_WidgetIN; + vtkBoxWidget *m_WidgetOUT; + HPoint3f m_Poca; }; diff --git a/src/Vtk/vtkMuonScatter.cxx b/src/Vtk/vtkMuonScatter.cxx index b3c11d7..5832c7f 100644 --- a/src/Vtk/vtkMuonScatter.cxx +++ b/src/Vtk/vtkMuonScatter.cxx @@ -30,23 +30,6 @@ #include "config.h" #endif - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include -#include - #include "vtkMuonScatter.h" #include "Math/Dense.h" @@ -78,36 +61,6 @@ namespace Vtk { //} -//// 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 ///////////////////////////////////////////////////////// @@ -115,63 +68,69 @@ public: vtkMuonScatter::vtkMuonScatter(MuonScatter &content) : - d(new vtkMuonScatterPimpl) + m_Content(&content), + m_LineIn(vtkLineSource::New()), + m_LineOut(vtkLineSource::New()), + m_PolyData(vtkPolyData::New()), + m_SpherePoca(NULL) { - d->m_Content = &content; - InstallPipe(); + InstallPipe(); } vtkMuonScatter::vtkMuonScatter(const MuonScatter &content) : - d(new vtkMuonScatterPimpl) + m_Content(const_cast(&content)), + m_LineIn(vtkLineSource::New()), + m_LineOut(vtkLineSource::New()), + m_PolyData(vtkPolyData::New()), + m_SpherePoca(NULL) { - d->m_Content = const_cast(&content); - InstallPipe(); + InstallPipe(); } vtkMuonScatter::~vtkMuonScatter() { - delete d; + m_LineIn->Delete(); + m_LineOut->Delete(); + if(m_SpherePoca) m_SpherePoca->Delete(); } vtkMuonScatter::Content &vtkMuonScatter::GetContent() { - return *d->m_Content; + return *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; + if(m_Content) { + vtkLineSource *line_in = m_LineIn; + vtkLineSource *line_out = m_LineOut; - float distance = (d->m_Content->LineIn().origin - d->m_Content->LineOut().origin).norm() / 10; + float distance = (m_Content->LineIn().origin - m_Content->LineOut().origin).norm() / 10; HPoint3f pt; - pt = d->m_Content->LineIn().origin; + pt = 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; + pt= m_Content->LineIn().origin + m_Content->LineIn().direction * distance; line_in->SetPoint2(pt(0),pt(1),pt(2)); - pt = d->m_Content->LineOut().origin; + pt = 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; + pt = m_Content->LineOut().origin + m_Content->LineOut().direction * distance; line_out->SetPoint2(pt(0),pt(1),pt(2)); } vtkSmartPointer mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(d->m_LineIn->GetOutputPort()); + mapper->SetInputConnection(m_LineIn->GetOutputPort()); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); this->SetProp(actor); mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(d->m_LineOut->GetOutputPort()); + mapper->SetInputConnection(m_LineOut->GetOutputPort()); actor = vtkSmartPointer::New(); actor->SetMapper(mapper); this->SetProp(actor); @@ -180,32 +139,26 @@ void vtkMuonScatter::InstallPipe() vtkPolyData *vtkMuonScatter::GetPolyData() const { vtkSmartPointer append = vtkSmartPointer::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->AddInputConnection(m_LineIn->GetOutputPort()); + append->AddInputConnection(m_LineOut->GetOutputPort()); + if(m_SpherePoca) append->AddInputConnection(m_SpherePoca->GetOutputPort()); append->Update(); - d->m_PolyData->DeepCopy(append->GetOutput()); - return d->m_PolyData; + m_PolyData->DeepCopy(append->GetOutput()); + return 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(); + float size = (m_Content->LineIn().origin - 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; + m_SpherePoca = sphere; vtkSmartPointer mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(d->m_SpherePoca->GetOutputPort()); + mapper->SetInputConnection(m_SpherePoca->GetOutputPort()); vtkSmartPointer actor = vtkSmartPointer::New(); actor->SetMapper(mapper); this->SetProp(actor); @@ -214,8 +167,8 @@ void vtkMuonScatter::AddPocaPoint(HPoint3f poca) HPoint3f vtkMuonScatter::GetPocaPoint() { double center[3]; - if(d->m_SpherePoca) { - d->m_SpherePoca->GetCenter(center); + if(m_SpherePoca) { + m_SpherePoca->GetCenter(center); return HPoint3f(center[0],center[1],center[2]); } else { diff --git a/src/Vtk/vtkMuonScatter.h b/src/Vtk/vtkMuonScatter.h index 7237f98..77a3a94 100644 --- a/src/Vtk/vtkMuonScatter.h +++ b/src/Vtk/vtkMuonScatter.h @@ -28,7 +28,22 @@ #ifndef VTKMUONSCATTER_H #define VTKMUONSCATTER_H -#include "Core/Macros.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include +#include + #include "Math/Dense.h" #include "uLibVtkInterface.h" @@ -66,8 +81,11 @@ protected: private: void InstallPipe(); - friend class vtkMuonScatterPimpl; - class vtkMuonScatterPimpl *d; + vtkMuonScatter::Content *m_Content; + vtkLineSource *m_LineIn; + vtkLineSource *m_LineOut; + vtkSphereSource *m_SpherePoca; + vtkPolyData *m_PolyData; }; } // vtk diff --git a/src/Vtk/vtkStructuredGrid.cpp b/src/Vtk/vtkStructuredGrid.cpp index e2225ae..a122c43 100644 --- a/src/Vtk/vtkStructuredGrid.cpp +++ b/src/Vtk/vtkStructuredGrid.cpp @@ -29,82 +29,12 @@ #include "config.h" #endif -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - #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 t = - vtkSmartPointer::New(); - vtkBoxWidget *widget = reinterpret_cast(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 callback = - vtkSmartPointer::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 ///////////////////////////////////////////////////// @@ -113,14 +43,24 @@ private: vtkStructuredGrid::vtkStructuredGrid(Content &content) : - d(new vtkStructuredGridPimpl(this,content)) + m_Content(&content), + m_Actor(vtkActor::New()), + m_Widget(vtkBoxWidget::New()), + m_Transform(vtkTransform::New()) { + vtkSmartPointer callback = + vtkSmartPointer::New(); + callback->SetGrid(this); + m_Widget->AddObserver(vtkCommand::InteractionEvent, callback); + this->InstallPipe(); } vtkStructuredGrid::~vtkStructuredGrid() { - delete d; + m_Actor->Delete(); + m_Widget->Delete(); + m_Transform->Delete(); } @@ -131,26 +71,26 @@ void vtkStructuredGrid::SetTransform(vtkTransform *t) 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); + m_Content->SetMatrix(mat); vtkSmartPointer vmat2 = vtkSmartPointer::New(); - mat = d->m_Content->GetWorldMatrix(); + 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)); - d->m_Transform->SetMatrix(vmat2); - d->m_Transform->Update(); + m_Transform->SetMatrix(vmat2); + m_Transform->Update(); this->Update(); } vtkBoxWidget *vtkStructuredGrid::GetWidget() { - return d->m_Widget; + return m_Widget; } void vtkStructuredGrid::Update() { - d->m_Actor->GetMapper()->Update(); + m_Actor->GetMapper()->Update(); } void vtkStructuredGrid::InstallPipe() @@ -161,15 +101,15 @@ void vtkStructuredGrid::InstallPipe() vtkSmartPointer::New(); vtkSmartPointer vmat = vtkSmartPointer::New(); - Matrix4f mat = d->m_Content->GetWorldMatrix(); + 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)); - d->m_Transform->SetMatrix(vmat); - filter->SetTransform(d->m_Transform); + m_Transform->SetMatrix(vmat); + filter->SetTransform(m_Transform); filter->SetInputConnection(cube->GetOutputPort()); - Vector3i dims = d->m_Content->GetDims(); + Vector3i dims = m_Content->GetDims(); cube->SetBounds(0,dims(0),0,dims(1),0,dims(2)); cube->Update(); filter->Update(); @@ -178,16 +118,16 @@ void vtkStructuredGrid::InstallPipe() vtkSmartPointer::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); + 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); // set content transform to actor // this->Update(); - d->m_Widget->SetProp3D(d->m_Actor); + m_Widget->SetProp3D(m_Actor); - this->SetProp(d->m_Actor); + this->SetProp(m_Actor); } diff --git a/src/Vtk/vtkStructuredGrid.h b/src/Vtk/vtkStructuredGrid.h index 93a8df3..faa936a 100644 --- a/src/Vtk/vtkStructuredGrid.h +++ b/src/Vtk/vtkStructuredGrid.h @@ -28,7 +28,19 @@ #ifndef U_VTKSTRUCTUREDGRID_H #define U_VTKSTRUCTUREDGRID_H -#include "Core/Macros.h" +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + #include "Math/Dense.h" #include "uLibVtkInterface.h" @@ -55,8 +67,28 @@ public: private: void InstallPipe(); - friend class vtkStructuredGridPimpl; - class vtkStructuredGridPimpl *d; + 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 t = vtkSmartPointer::New(); + vtkBoxWidget *widget = reinterpret_cast(caller); + widget->GetTransform(t); + grid->SetTransform(t); + } + private: + uLib::Vtk::vtkStructuredGrid *grid; + }; + + vtkActor *m_Actor; + vtkBoxWidget *m_Widget; + StructuredGrid *m_Content; + vtkTransform *m_Transform; }; diff --git a/src/Vtk/vtkVoxRaytracerRepresentation.cpp b/src/Vtk/vtkVoxRaytracerRepresentation.cpp index f0e9852..214b250 100644 --- a/src/Vtk/vtkVoxRaytracerRepresentation.cpp +++ b/src/Vtk/vtkVoxRaytracerRepresentation.cpp @@ -29,25 +29,6 @@ #include "config.h" #endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - #include "vtkVoxRaytracerRepresentation.h" @@ -60,59 +41,6 @@ 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 m_Transform; - VoxRaytracer::RayData m_Ray; - vtkSmartPointer m_Sphere1,m_Sphere2; - vtkSmartPointer m_Line1, m_Line2, m_Line3; - vtkSmartPointer m_RayRepresentation; - - vtkAppendPolyData *m_SelectedElement; -}; - - - - //////////////////////////////////////////////////////////////////////////////// ////// VOX RAYTRACER REPRESENTATION /////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// @@ -120,44 +48,64 @@ public: vtkVoxRaytracerRepresentation::vtkVoxRaytracerRepresentation(Content &content) : - d(new vtkVoxRaytracerRepresentationPimpl(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() { - delete d; + m_Assembly->Delete(); + m_RayLine->Delete(); + m_RayLineActor->Delete(); + m_RayRepresentationActor->Delete(); + m_Transform->Delete(); } VoxRaytracer *vtkVoxRaytracerRepresentation::GetRaytracerAlgorithm() { - return d->m_Content; + return m_Content; } vtkProp *vtkVoxRaytracerRepresentation::GetProp() { - return d->m_Assembly; + return m_Assembly; } vtkPolyData *vtkVoxRaytracerRepresentation::GetPolyData() const { std::cout << "get Raytracer polydata\n"; - d->m_SelectedElement->Update(); - return d->m_SelectedElement->GetOutput(); + m_SelectedElement->Update(); + return m_SelectedElement->GetOutput(); } void vtkVoxRaytracerRepresentation::SetRepresentationElements(vtkVoxRaytracerRepresentation::RepresentationElements el) { switch(el) { case Vtk::vtkVoxRaytracerRepresentation::RayElements: - d->m_SelectedElement = d->m_RayLine; + m_SelectedElement = m_RayLine; break; case Vtk::vtkVoxRaytracerRepresentation::VoxelsElements: - d->m_SelectedElement = d->m_RayRepresentation; + m_SelectedElement = m_RayRepresentation; break; default: - d->m_SelectedElement = d->m_RayLine; + m_SelectedElement = m_RayLine; break; } } @@ -167,22 +115,22 @@ 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)); + 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; - 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)); + 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)); - d->m_Line3->SetPoint1(pt1(0),pt1(1),pt1(2)); - d->m_Line3->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 points = @@ -210,25 +158,22 @@ void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon) // Add the lines to the dataset linesPolyData->SetLines(lines); - d->m_RayLine->RemoveAllInputs(); + m_RayLine->RemoveAllInputs(); # if VTK_MAJOR_VERSION <= 5 - d->m_RayLine->AddInputConnection(linesPolyData->GetProducerPort()); -# else - d->m_RayLine->AddInputData(linesPolyData); + m_RayLine->AddInputConnection(linesPolyData->GetProducerPort()); # 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()); + 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 vmat = vtkSmartPointer::New(); - Matrix4f mat = d->m_Content->GetImage()->GetWorldMatrix(); + 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)); - d->m_Transform->SetMatrix(vmat); + m_Transform->SetMatrix(vmat); this->SetRay(pt1,pt2); } @@ -237,22 +182,22 @@ 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)); + 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; - 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)); + 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)); - d->m_Line3->SetPoint1(pt1(0),pt1(1),pt1(2)); - d->m_Line3->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 points = @@ -284,34 +229,31 @@ void vtkVoxRaytracerRepresentation::SetMuon(MuonScatter &muon, HPoint3f poca) // Add the lines to the dataset linesPolyData->SetLines(lines); - d->m_RayLine->RemoveAllInputs(); + m_RayLine->RemoveAllInputs(); # if VTK_MAJOR_VERSION <= 5 - d->m_RayLine->AddInputConnection(linesPolyData->GetProducerPort()); -# else - d->m_RayLine->AddInputData(linesPolyData); + m_RayLine->AddInputConnection(linesPolyData->GetProducerPort()); # 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()); + 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 poca_sphere = vtkSmartPointer::New(); - poca_sphere->SetRadius(d->default_radius); + poca_sphere->SetRadius(default_radius); poca_sphere->SetCenter(poca(0),poca(1),poca(2)); - d->m_RayLine->AddInputConnection(poca_sphere->GetOutputPort()); + m_RayLine->AddInputConnection(poca_sphere->GetOutputPort()); vtkSmartPointer vmat = vtkSmartPointer::New(); - Matrix4f mat = d->m_Content->GetImage()->GetWorldMatrix(); + 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)); - d->m_Transform->SetMatrix(vmat); + m_Transform->SetMatrix(vmat); - if(d->m_Content->GetImage()->IsInsideBounds(poca)) + if(m_Content->GetImage()->IsInsideBounds(poca)) this->SetRay(pt1,poca,pt2); else this->SetRay(pt1,pt2); @@ -328,38 +270,36 @@ void vtkVoxRaytracerRepresentation::SetMuon(vtkMuonScatter &muon) VoxRaytracer::RayData vtkVoxRaytracerRepresentation::GetRay() { - return d->m_Ray; + return m_Ray; } void vtkVoxRaytracerRepresentation::SetRay(HPoint3f in, HPoint3f out) { - d->m_Ray = d->m_Content->TraceBetweenPoints(in,out); - this->SetRay(&d->m_Ray); + m_Ray = m_Content->TraceBetweenPoints(in,out); + this->SetRay(&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); + 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 = d->m_RayRepresentation; + vtkAppendPolyData *appender = m_RayRepresentation; appender->RemoveAllInputs(); for(int i=0; iData().size(); ++i) { int id = ray->Data().at(i).vox_id; - Vector3i idv = d->m_Content->GetImage()->UnMap(id); + Vector3i idv = m_Content->GetImage()->UnMap(id); vtkSmartPointer cube = vtkSmartPointer::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(); } @@ -368,12 +308,12 @@ void vtkVoxRaytracerRepresentation::SetRay(VoxRaytracer::RayData *ray) void vtkVoxRaytracerRepresentation::SetVoxelsColor(Vector4f rgba) { - this->SetColor(d->m_RayRepresentationActor,rgba); + this->SetColor(m_RayRepresentationActor,rgba); } void vtkVoxRaytracerRepresentation::SetRayColor(Vector4f rgba) { - this->SetColor(d->m_RayLineActor,rgba); + this->SetColor(m_RayLineActor,rgba); } void vtkVoxRaytracerRepresentation::SetColor(vtkActor *actor, Vector4f rgba) @@ -395,10 +335,10 @@ void vtkVoxRaytracerRepresentation::InstallPipe() vtkSmartPointer append = vtkSmartPointer::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->AddInputConnection(m_Sphere1->GetOutputPort()); + append->AddInputConnection(m_Sphere2->GetOutputPort()); + append->AddInputConnection(m_Line1->GetOutputPort()); + append->AddInputConnection(m_Line2->GetOutputPort()); append->Update(); vtkSmartPointer mapper = @@ -413,34 +353,24 @@ void vtkVoxRaytracerRepresentation::InstallPipe() this->SetProp(actor); mapper = vtkSmartPointer::New(); - mapper->SetInputConnection(d->m_RayLine->GetOutputPort()); + mapper->SetInputConnection(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::New(); -// mapper->SetInputConnection(d->m_Line3->GetOutputPort()); -// mapper->Update(); - -// actor = vtkSmartPointer::New(); -// actor->SetMapper(mapper); -// actor->GetProperty()->SetColor(1,0,0); -// d->m_Assembly->AddPart(actor); - + m_RayLineActor->SetMapper(mapper); + m_RayLineActor->GetProperty()->SetColor(1,0,0); + this->SetProp(m_RayLineActor); vtkSmartPointer polyfilter = vtkSmartPointer::New(); - polyfilter->SetInputConnection(d->m_RayRepresentation->GetOutputPort()); - polyfilter->SetTransform(d->m_Transform); + polyfilter->SetInputConnection(m_RayRepresentation->GetOutputPort()); + polyfilter->SetTransform(m_Transform); mapper = vtkSmartPointer::New(); mapper->SetInputConnection(polyfilter->GetOutputPort()); mapper->Update(); - vtkActor *vra = d->m_RayRepresentationActor; + vtkActor *vra = m_RayRepresentationActor; vra->SetMapper(mapper); vra->GetProperty()->SetOpacity(0.2); vra->GetProperty()->SetEdgeVisibility(true); diff --git a/src/Vtk/vtkVoxRaytracerRepresentation.h b/src/Vtk/vtkVoxRaytracerRepresentation.h index 57ee264..d36246a 100644 --- a/src/Vtk/vtkVoxRaytracerRepresentation.h +++ b/src/Vtk/vtkVoxRaytracerRepresentation.h @@ -28,8 +28,24 @@ #ifndef U_VTKVOXRAYTRACERREPRESENTATION_H #define U_VTKVOXRAYTRACERREPRESENTATION_H +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#include "Core/Macros.h" #include "Math/Dense.h" #include "uLibVtkInterface.h" @@ -89,8 +105,23 @@ private: void SetColor(vtkActor *actor, Vector4f rgba); - friend class vtkVoxRaytracerRepresentationPimpl; - class vtkVoxRaytracerRepresentationPimpl *d; + VoxRaytracer *m_Content; + + Scalarf default_radius; + vtkAssembly *m_Assembly; + vtkAppendPolyData *m_RayLine; + vtkActor *m_RayLineActor; + vtkActor *m_RayRepresentationActor; + vtkSmartPointer m_Transform; + VoxRaytracer::RayData m_Ray; + vtkSmartPointer m_Sphere1; + vtkSmartPointer m_Sphere2; + vtkSmartPointer m_Line1; + vtkSmartPointer m_Line2; + vtkSmartPointer m_Line3; + vtkSmartPointer m_RayRepresentation; + + vtkAppendPolyData *m_SelectedElement; };