mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Removed macros.h and pimpl
This commit is contained in:
@@ -30,23 +30,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include <vtkConfigure.h>
|
||||
#include <vtkSmartPointer.h>
|
||||
#include <vtkSphereSource.h>
|
||||
#include <vtkAppendPolyData.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkLineSource.h>
|
||||
#include <vtkActor.h>
|
||||
|
||||
#include <vtk3DWidget.h>
|
||||
#include <vtkBoxWidget.h>
|
||||
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
|
||||
#include <vtkCommand.h>
|
||||
#include <vtkTransform.h>
|
||||
|
||||
#include "vtkMuonScatter.h"
|
||||
#include "Math/Dense.h"
|
||||
|
||||
@@ -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<MuonScatter *>(&content)),
|
||||
m_LineIn(vtkLineSource::New()),
|
||||
m_LineOut(vtkLineSource::New()),
|
||||
m_PolyData(vtkPolyData::New()),
|
||||
m_SpherePoca(NULL)
|
||||
{
|
||||
d->m_Content = const_cast<MuonScatter *>(&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<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(d->m_LineIn->GetOutputPort());
|
||||
mapper->SetInputConnection(m_LineIn->GetOutputPort());
|
||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
this->SetProp(actor);
|
||||
|
||||
mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(d->m_LineOut->GetOutputPort());
|
||||
mapper->SetInputConnection(m_LineOut->GetOutputPort());
|
||||
actor = vtkSmartPointer<vtkActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
this->SetProp(actor);
|
||||
@@ -180,32 +139,26 @@ void vtkMuonScatter::InstallPipe()
|
||||
vtkPolyData *vtkMuonScatter::GetPolyData() const
|
||||
{
|
||||
vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
|
||||
//# if VTK_MAJOR_VERSION <= 5
|
||||
append->AddInputConnection(d->m_LineIn->GetOutputPort());
|
||||
append->AddInputConnection(d->m_LineOut->GetOutputPort());
|
||||
if(d->m_SpherePoca) append->AddInputConnection(d->m_SpherePoca->GetOutputPort());
|
||||
//# else
|
||||
// append->AddInputData(d->m_LineIn->GetOutput());
|
||||
// append->AddInputData(d->m_LineOut->GetOutput());
|
||||
// if(d->m_SpherePoca) append->AddInputData(d->m_SpherePoca->GetOutput());
|
||||
//# endif
|
||||
append->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<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
mapper->SetInputConnection(d->m_SpherePoca->GetOutputPort());
|
||||
mapper->SetInputConnection(m_SpherePoca->GetOutputPort());
|
||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::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 {
|
||||
|
||||
Reference in New Issue
Block a user