vtkContourTopogramProjectionFilter is clean
This commit is contained in:
@ -41,6 +41,7 @@ gfattori 08.11.2021
|
||||
|
||||
#include "vtkImageData.h"
|
||||
#include "vtkTransform.h"
|
||||
#include "vtkSmartPointer.h"
|
||||
|
||||
namespace itk
|
||||
{
|
||||
@ -139,6 +140,8 @@ public:
|
||||
vtkMatrix4x4 * GetProjection1VTKTransform();
|
||||
vtkMatrix4x4 * GetProjection2VTKTransform();
|
||||
|
||||
vtkTransform * GetProjection1vtkTransform();
|
||||
|
||||
/** Debug writers */
|
||||
void WriteProjectionImages();
|
||||
void Write2DImages();
|
||||
@ -334,6 +337,7 @@ ImageType3D::PointType ImportOffset;
|
||||
* m_Projection2VTKTransform;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -34,15 +34,18 @@ vtkObjectFactoryNewMacro(vtkContourTopogramProjectionFilter);
|
||||
vtkContourTopogramProjectionFilter::vtkContourTopogramProjectionFilter()
|
||||
{
|
||||
|
||||
dProjectionLPSOffset[0]=0.;
|
||||
dProjectionLPSOffset[1]=0.;
|
||||
dProjectionLPSOffset[2]=0.;
|
||||
this->dProjectionLPSOffset[0]=0.;
|
||||
this->dProjectionLPSOffset[1]=0.;
|
||||
this->dProjectionLPSOffset[2]=0.;
|
||||
|
||||
dImportOffsetLPS[0] = 0.;
|
||||
dImportOffsetLPS[1] = 0.;
|
||||
dImportOffsetLPS[2] = 0.;
|
||||
this->dImportOffsetLPS[0] = 0.;
|
||||
this->dImportOffsetLPS[1] = 0.;
|
||||
this->dImportOffsetLPS[2] = 0.;
|
||||
|
||||
dSCD = -1.;
|
||||
this->dSCD = -1.;
|
||||
|
||||
this->m_RefTransform = nullptr;
|
||||
this->m_Transform = nullptr;
|
||||
|
||||
// by default process active point scalars
|
||||
this->SetInputArrayToProcess(
|
||||
@ -52,7 +55,15 @@ vtkContourTopogramProjectionFilter::vtkContourTopogramProjectionFilter()
|
||||
|
||||
vtkContourTopogramProjectionFilter::~vtkContourTopogramProjectionFilter()
|
||||
{
|
||||
if (this->m_Transform)
|
||||
{
|
||||
this->m_Transform->UnRegister(this);
|
||||
}
|
||||
|
||||
if (this->m_RefTransform)
|
||||
{
|
||||
this->m_RefTransform->UnRegister(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -79,20 +90,36 @@ int vtkContourTopogramProjectionFilter::RequestData(
|
||||
points = graphInput->GetPoints();
|
||||
}
|
||||
|
||||
// check input
|
||||
// If no points, then nothing to do.
|
||||
if (points == nullptr)
|
||||
{
|
||||
vtkDebugMacro("Cannot Project; no input points");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// If reference transform, then nothing to do.
|
||||
if (m_RefTransform == nullptr)
|
||||
{
|
||||
vtkDebugMacro("Cannot Project; no input reference projection transform");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// If transform, then nothing to do.
|
||||
if (m_Transform == nullptr)
|
||||
{
|
||||
vtkDebugMacro("Cannot Project; no input projection transform");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
vtkSmartPointer<vtkPoints> PrjPoints = vtkSmartPointer<vtkPoints>::New();
|
||||
vtkPoints* PrjPoints = vtkPoints::New();
|
||||
PrjPoints->SetNumberOfPoints( points->GetNumberOfPoints() );
|
||||
|
||||
|
||||
double pp0[3], pp1[3], pp2[3];
|
||||
|
||||
for(unsigned long int ii = 0; ii < points->GetNumberOfPoints() ; ii++){
|
||||
for(vtkIdType ii = 0; ii < points->GetNumberOfPoints() ; ii++){
|
||||
|
||||
|
||||
/** input points are in LPS, should be corrected for import offset and mapped onto
|
||||
@ -105,10 +132,13 @@ int vtkContourTopogramProjectionFilter::RequestData(
|
||||
* projection geometry using the inverse of the transform */
|
||||
m_Transform->GetInverse()->TransformPoint(pp0, pp1);
|
||||
|
||||
/** coorrect x coordinate by the ratio of distance from source
|
||||
/** correct x coordinate by the ratio of distance from source
|
||||
* Basic intercept theorem */
|
||||
pp1[0] = pp1[0] * dSCD / abs(pp1[2]);
|
||||
|
||||
if(pp1[2] != 0.){
|
||||
pp1[0] = pp1[0] * dSCD / abs(pp1[2]);
|
||||
} else {
|
||||
vtkDebugMacro("point at SCD distance from panel. Skipping lateral correction for this point.");
|
||||
}
|
||||
/** Go on the virtual detector */
|
||||
pp1[2] = -dSCD;
|
||||
|
||||
@ -121,27 +151,22 @@ int vtkContourTopogramProjectionFilter::RequestData(
|
||||
pp2[2] -= dProjectionLPSOffset [2];
|
||||
|
||||
PrjPoints->InsertPoint(ii,pp2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
output->SetPoints( PrjPoints );
|
||||
output->BuildCells();
|
||||
|
||||
// if (psInput)
|
||||
// {
|
||||
// output->GetPointData()->PassData(psInput->GetPointData());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// output->GetPointData()->PassData(graphInput->GetVertexData());
|
||||
// }
|
||||
|
||||
vtkIdType numPoints = points->GetNumberOfPoints();
|
||||
|
||||
if (psInput)
|
||||
{
|
||||
output->GetPointData()->PassData(psInput->GetPointData());
|
||||
}
|
||||
else
|
||||
{
|
||||
output->GetPointData()->PassData(graphInput->GetVertexData());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VTK_CREATE(vtkCellArray, cells);
|
||||
cells->AllocateEstimate(numPoints, 1);
|
||||
|
||||
@ -151,6 +176,11 @@ int vtkContourTopogramProjectionFilter::RequestData(
|
||||
}
|
||||
output->SetVerts(cells);
|
||||
|
||||
|
||||
PrjPoints->Delete();
|
||||
|
||||
output->Squeeze();
|
||||
|
||||
return 1;
|
||||
|
||||
|
||||
@ -172,7 +202,9 @@ void vtkContourTopogramProjectionFilter::SetLPStoProjectionLPSGeometryOffset(con
|
||||
|
||||
void vtkContourTopogramProjectionFilter::SetTransformMatrix( vtkMatrix4x4 *userMatrix)
|
||||
{
|
||||
m_Transform = vtkSmartPointer<vtkTransform>::New();
|
||||
if(this->m_Transform == nullptr){
|
||||
m_Transform = vtkTransform::New();
|
||||
}
|
||||
m_Transform->SetMatrix(userMatrix);
|
||||
this->Modified();
|
||||
}
|
||||
@ -180,7 +212,9 @@ void vtkContourTopogramProjectionFilter::SetTransformMatrix( vtkMatrix4x4 *userM
|
||||
|
||||
void vtkContourTopogramProjectionFilter::SetReferenceTransformMatrix( vtkMatrix4x4 *userMatrix)
|
||||
{
|
||||
m_RefTransform = vtkSmartPointer<vtkTransform>::New();
|
||||
if(this->m_RefTransform == nullptr){
|
||||
m_RefTransform = vtkTransform::New();
|
||||
}
|
||||
m_RefTransform ->SetMatrix(userMatrix);
|
||||
this->Modified();
|
||||
}
|
||||
@ -189,7 +223,6 @@ void vtkContourTopogramProjectionFilter::SetReferenceTransformMatrix( vtkMatrix4
|
||||
void vtkContourTopogramProjectionFilter ::PrintSelf(ostream& os, vtkIndent indent)
|
||||
{
|
||||
this->Superclass::PrintSelf(os, indent);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -199,7 +232,4 @@ int vtkContourTopogramProjectionFilter::FillInputPortInformation(int, vtkInforma
|
||||
info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkGraph");
|
||||
info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPointSet");
|
||||
return 1;
|
||||
|
||||
// info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
|
||||
// return 1;
|
||||
}
|
||||
|
@ -18,9 +18,12 @@ public:
|
||||
|
||||
static vtkContourTopogramProjectionFilter * New();
|
||||
|
||||
|
||||
void SetReferenceTransformMatrix( vtkMatrix4x4 *);
|
||||
void SetTransformMatrix( vtkMatrix4x4 *);
|
||||
|
||||
vtkGetObjectMacro(m_Transform, vtkTransform);
|
||||
vtkGetObjectMacro(m_RefTransform, vtkTransform);
|
||||
|
||||
void SetLPStoProjectionLPSGeometryOffset (const double * );
|
||||
void SetSCD(const double dVal);
|
||||
void SetImportOffsetLPS(const double *);
|
||||
@ -44,8 +47,8 @@ private:
|
||||
dImportOffsetLPS[3],
|
||||
dSCD;
|
||||
|
||||
vtkSmartPointer<vtkTransform> m_RefTransform;
|
||||
vtkSmartPointer<vtkTransform> m_Transform;
|
||||
vtkTransform *m_RefTransform;
|
||||
vtkTransform *m_Transform;
|
||||
vtkSmartPointer<vtkPolyData> m_PrjPoly;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user