VMTK
Loading...
Searching...
No Matches
vtkvmtkSurfaceProjection Class Reference

Project point data from a reference surface onto an input surface. More...

#include <vtkvmtkSurfaceProjection.h>

Inheritance diagram for vtkvmtkSurfaceProjection:
[legend]
Collaboration diagram for vtkvmtkSurfaceProjection:
[legend]

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkSurfaceProjection * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetReferenceSurface (vtkPolyData *)
virtual vtkPolyData * GetReferenceSurface ()

Static Public Member Functions

static int IsTypeOf (const char *type)
static vtkvmtkSurfaceProjection * SafeDownCast (vtkObjectBase *o)
static vtkvmtkSurfaceProjection * New ()

Protected Member Functions

virtual vtkObjectBase * NewInstanceInternal () const
 vtkvmtkSurfaceProjection ()
 ~vtkvmtkSurfaceProjection ()
virtual int RequestData (vtkInformation *, vtkInformationVector **, vtkInformationVector *) override

Protected Attributes

vtkPolyData * ReferenceSurface

Detailed Description

Project point data from a reference surface onto an input surface.

Definition at line 34 of file vtkvmtkSurfaceProjection.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkSurfaceProjection::Superclass

Definition at line 37 of file vtkvmtkSurfaceProjection.h.

Constructor & Destructor Documentation

◆ vtkvmtkSurfaceProjection()

vtkvmtkSurfaceProjection::vtkvmtkSurfaceProjection ( )
protected

Definition at line 37 of file vtkvmtkSurfaceProjection.cxx.

38{
39 this->ReferenceSurface = NULL;
40}

◆ ~vtkvmtkSurfaceProjection()

vtkvmtkSurfaceProjection::~vtkvmtkSurfaceProjection ( )
protected

Definition at line 42 of file vtkvmtkSurfaceProjection.cxx.

43{
44 if (this->ReferenceSurface)
45 {
46 this->ReferenceSurface->Delete();
47 this->ReferenceSurface = NULL;
48 }
49}

Member Function Documentation

◆ IsTypeOf()

int vtkvmtkSurfaceProjection::IsTypeOf ( const char * type)
static

◆ IsA()

virtual int vtkvmtkSurfaceProjection::IsA ( const char * type)
virtual

◆ SafeDownCast()

vtkvmtkSurfaceProjection * vtkvmtkSurfaceProjection::SafeDownCast ( vtkObjectBase * o)
static

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkSurfaceProjection::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkSurfaceProjection * vtkvmtkSurfaceProjection::NewInstance ( ) const

◆ PrintSelf()

void vtkvmtkSurfaceProjection::PrintSelf ( std::ostream & os,
vtkIndent indent )
override

Definition at line 127 of file vtkvmtkSurfaceProjection.cxx.

128{
129 this->Superclass::PrintSelf(os,indent);
130}

◆ New()

vtkvmtkSurfaceProjection * vtkvmtkSurfaceProjection::New ( )
static

◆ SetReferenceSurface()

virtual void vtkvmtkSurfaceProjection::SetReferenceSurface ( vtkPolyData * )
virtual

Set/Get the reference surface to compute distance from.

◆ GetReferenceSurface()

virtual vtkPolyData * vtkvmtkSurfaceProjection::GetReferenceSurface ( )
virtual

Set/Get the reference surface to compute distance from.

◆ RequestData()

int vtkvmtkSurfaceProjection::RequestData ( vtkInformation * ,
vtkInformationVector ** ,
vtkInformationVector *  )
overrideprotectedvirtual

Definition at line 51 of file vtkvmtkSurfaceProjection.cxx.

55{
56 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
57 vtkInformation *outInfo = outputVector->GetInformationObject(0);
58
59 vtkPolyData *input = vtkPolyData::SafeDownCast(
60 inInfo->Get(vtkDataObject::DATA_OBJECT()));
61 vtkPolyData *output = vtkPolyData::SafeDownCast(
62 outInfo->Get(vtkDataObject::DATA_OBJECT()));
63
64 vtkIdType i;
65 vtkIdType cellId;
66 int subId;
67 double point[3], closestPoint[3];
68 double pcoords[3];
69 double distance2;
70 vtkCellLocator *locator;
71 vtkGenericCell *genericCell;
72
73 if (!this->ReferenceSurface)
74 {
75 vtkErrorMacro(<<"No reference surface!");
76 return 1;
77 }
78
79 int numberOfPoints = input->GetNumberOfPoints();
80
81 output->DeepCopy(input);
82
83 vtkPointData* outputPointData = output->GetPointData();
84 vtkPointData* referencePointData = this->ReferenceSurface->GetPointData();
85
86 outputPointData->InterpolateAllocate(referencePointData,numberOfPoints);
87
88 this->ReferenceSurface->BuildCells();
89
90 locator = vtkCellLocator::New();
91 genericCell = vtkGenericCell::New();
92
93 locator->SetDataSet(this->ReferenceSurface);
94 locator->BuildLocator();
95
96 for (i=0; i<numberOfPoints; i++)
97 {
98 input->GetPoint(i,point);
99 locator->FindClosestPoint(point,closestPoint,genericCell,cellId,subId,distance2);
100 if (this->ReferenceSurface->GetCellType(cellId) != VTK_POLY_LINE)
101 {
102 double* weights = new double[genericCell->GetNumberOfPoints()];
103 genericCell->EvaluatePosition(closestPoint,NULL,subId,pcoords,distance2,weights);
104 outputPointData->InterpolatePoint(referencePointData,i,genericCell->GetPointIds(),weights);
105 delete[] weights;
106 }
107 else
108 {
109 double testPoint0[3], testPoint1[3];
110 vtkIdType pointId = genericCell->GetPointId(subId);
111 input->GetPoint(genericCell->GetPointId(subId),testPoint0);
112 input->GetPoint(genericCell->GetPointId(subId+1),testPoint1);
113 if (vtkMath::Distance2BetweenPoints(closestPoint,testPoint1) < vtkMath::Distance2BetweenPoints(closestPoint,testPoint0))
114 {
115 pointId = genericCell->GetPointId(subId+1);
116 }
117 outputPointData->CopyData(referencePointData,pointId,i);
118 }
119 }
120
121 locator->Delete();
122 genericCell->Delete();
123
124 return 1;
125}

Member Data Documentation

◆ ReferenceSurface

vtkPolyData* vtkvmtkSurfaceProjection::ReferenceSurface
protected

Definition at line 56 of file vtkvmtkSurfaceProjection.h.


The documentation for this class was generated from the following files: