A structure for vtkContourTopogramProjectionFilter

This commit is contained in:
2022-02-15 00:53:50 +01:00
parent c94dc43b17
commit 867d2949a3
4 changed files with 244 additions and 0 deletions

View File

@ -21,6 +21,8 @@ SET(HDR
itkImageProcessor.h
itkgSiddonJacobsRayCastInterpolateImageFunction.h
itkgSiddonJacobsRayCastInterpolateImageFunction.hxx
vtkContourTopogramProjectionFilter.cxx
vtkContourTopogramProjectionFilter.h
)
ADD_LIBRARY(${LIB_NAME} ${SRCS} ${HDR})

View File

@ -440,6 +440,7 @@ void itkImageProcessor::ApplyVolumeImportTransform(){
LPStoIEC_Directions,
rtIsocenterLPS,
IEC2DCMMapT);
std::cout<<"ImportOffset> "<<ImportOffset<<std::endl;
} else {
ImportOffset.Fill(0.);
}

View File

@ -0,0 +1,196 @@
#include "vtkContourTopogramProjectionFilter.h"
#include "vtkCallbackCommand.h"
#include "vtkCell.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkContourHelper.h"
#include "vtkContourValues.h"
#include "vtkGarbageCollector.h"
#include "vtkGenericCell.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkPolyDataNormals.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTimerLog.h"
#include "vtkUniformGrid.h"
#include "vtkGraph.h"
#include "vtkTransformPolyDataFilter.h"
#include <cmath>
#include "vtkSmartPointer.h"
#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
vtkObjectFactoryNewMacro(vtkContourTopogramProjectionFilter);
vtkContourTopogramProjectionFilter::vtkContourTopogramProjectionFilter()
{
// by default process active point scalars
this->SetInputArrayToProcess(
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataSetAttributes::SCALARS);
}
vtkContourTopogramProjectionFilter::~vtkContourTopogramProjectionFilter()
{
}
int vtkContourTopogramProjectionFilter::RequestData(
vtkInformation* request, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
// Get the info objects.
vtkInformation* inInfo = inputVector[0]->GetInformationObject(0);
vtkInformation* outInfo = outputVector->GetInformationObject(0);
// Get the input and output.
vtkPointSet* psInput = vtkPointSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkGraph* graphInput = vtkGraph::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkPoints* points = nullptr;
if (psInput)
{
points = psInput->GetPoints();
}
else
{
points = graphInput->GetPoints();
}
// If no points, then nothing to do.
if (points == nullptr)
{
return 1;
}
vtkSmartPointer<vtkPoints> PrjPoints = vtkSmartPointer<vtkPoints>::New();
PrjPoints->SetNumberOfPoints( points->GetNumberOfPoints() );
double pp0[3], pp[3], pp2[3];
for(unsigned long int ii = 0; ii < points->GetNumberOfPoints() ; ii++){
//std::cout<< "-----" << std::endl;
pp0[0] = points->GetPoint(ii)[0] - dIso[0];
pp0[1] = points->GetPoint(ii)[1] - dIso[1];
pp0[2] = points->GetPoint(ii)[2] - dIso[2];
m_Transform->GetInverse()->TransformPoint(pp0,
pp);
/** coorrect x coordinate by the ratio of distance from panel */
if(pp[2] > 0) {
//pp[0] = pp[0] * 570/ pp[2];
} else if(pp[2] < 0){
//pp[0] = pp[0] / 570/ pp[2];
} else {
}
/** Go on the virtual detector */
pp[2] = -570.;
m_Transform->TransformPoint(pp,
pp2);
pp2[0] += dIso[0];
pp2[1] += dIso[1];
pp2[2] += dIso[2];
PrjPoints->InsertPoint(ii,pp2);
// std::cout<< ": "<<ii <<std::endl;
// std::cout<< points->GetPoint(ii)[0] << " "
// << points->GetPoint(ii)[1] << " "
// << points->GetPoint(ii)[2]
// <<std::endl;
// std::cout<< PrjPoints ->GetPoint(ii)[0] << " "
// << PrjPoints ->GetPoint(ii)[1] << " "
// << PrjPoints ->GetPoint(ii)[2]
// <<std::endl;
// std::cout<< "-----" << std::endl;
}
// m_Transform->Print(std::cout);
//m_PrjPoly = vtkSmartPointer<vtkPolyData>::New();
output->SetPoints( PrjPoints );
//output->SetPoints(points);
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);
for (vtkIdType i = 0; i < numPoints; i++)
{
cells->InsertNextCell(1, &i);
}
output->SetVerts(cells);
return 1;
}
void vtkContourTopogramProjectionFilter::SetProjectionCenter(const double * dP)
{
memcpy(dIso,dP,3*sizeof(double));
}
void vtkContourTopogramProjectionFilter::SetTransformMatrix( vtkMatrix4x4 *userMatrix)
{
m_Transform = vtkSmartPointer<vtkTransform>::New();
m_Transform->SetMatrix(userMatrix);
this->Modified();
}
void vtkContourTopogramProjectionFilter ::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
int vtkContourTopogramProjectionFilter::FillInputPortInformation(int, vtkInformation* info)
{
info->Remove(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE());
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;
}

View File

@ -0,0 +1,45 @@
#ifndef VTKCONTOURTOPOGRAMPROJECTIONFILTER_H
#define VTKCONTOURTOPOGRAMPROJECTIONFILTER_H
#include "vtkFiltersCoreModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"
#include "vtkMatrix4x4.h"
#include "vtkTransform.h"
class VTKFILTERSCORE_EXPORT vtkContourTopogramProjectionFilter :
public vtkPolyDataAlgorithm
{
public:
vtkTypeMacro(vtkContourTopogramProjectionFilter, vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) override;
static vtkContourTopogramProjectionFilter * New();
void SetTransformMatrix( vtkMatrix4x4 *);
void SetProjectionCenter(const double * );
protected:
vtkContourTopogramProjectionFilter();
~vtkContourTopogramProjectionFilter() override;
int RequestData(vtkInformation* request, vtkInformationVector** inputVector,
vtkInformationVector* outputVector) override;
int FillInputPortInformation(int port, vtkInformation* info) override;
private:
vtkContourTopogramProjectionFilter (const vtkContourTopogramProjectionFilter &) = delete;
void operator=(const vtkContourTopogramProjectionFilter&) = delete;
double dIso[3];
vtkSmartPointer<vtkTransform> m_Transform;
vtkSmartPointer<vtkPolyData> m_PrjPoly;
};
#endif