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

Projects a cell array from a reference surface. More...

#include <vtkvmtkSurfaceProjectCellArray.h>

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

Public Types

typedef vtkPolyDataAlgorithm Superclass

Public Member Functions

virtual int IsA (const char *type)
vtkvmtkSurfaceProjectCellArray * NewInstance () const
void PrintSelf (std::ostream &os, vtkIndent indent) override
virtual void SetReferenceSurface (vtkPolyData *)
virtual vtkPolyData * GetReferenceSurface ()
virtual void SetProjectedArrayName (const char *)
virtual char * GetProjectedArrayName ()
virtual void SetDistanceTolerance (double)
virtual double GetDistanceTolerance ()
virtual void SetDefaultValue (double)
virtual double GetDefaultValue ()

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

vtkPolyData * ReferenceSurface
char * ProjectedArrayName
double DistanceTolerance
double DefaultValue

Detailed Description

Projects a cell array from a reference surface.

For each cell, the cell value chosen is the one of the cell on the reference surface which has the smallest minimum distance to the cell vertices. If the distance of any vertices in the cell to the reference surface is higher than DistanceTolerance, the cell array values are set to DefaultValue for each component.

Definition at line 38 of file vtkvmtkSurfaceProjectCellArray.h.

Member Typedef Documentation

◆ Superclass

typedef vtkPolyDataAlgorithm vtkvmtkSurfaceProjectCellArray::Superclass

Definition at line 41 of file vtkvmtkSurfaceProjectCellArray.h.

Constructor & Destructor Documentation

◆ vtkvmtkSurfaceProjectCellArray()

vtkvmtkSurfaceProjectCellArray::vtkvmtkSurfaceProjectCellArray ( )
protected

◆ ~vtkvmtkSurfaceProjectCellArray()

vtkvmtkSurfaceProjectCellArray::~vtkvmtkSurfaceProjectCellArray ( )
protected

Definition at line 52 of file vtkvmtkSurfaceProjectCellArray.cxx.

53{
54 if (this->ReferenceSurface)
55 {
56 this->ReferenceSurface->Delete();
57 this->ReferenceSurface = NULL;
58 }
59
60 if (this->ProjectedArrayName)
61 {
62 delete[] this->ProjectedArrayName;
63 this->ProjectedArrayName = NULL;
64 }
65}

Member Function Documentation

◆ IsTypeOf()

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

◆ IsA()

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

◆ SafeDownCast()

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

◆ NewInstanceInternal()

virtual vtkObjectBase * vtkvmtkSurfaceProjectCellArray::NewInstanceInternal ( ) const
protectedvirtual

◆ NewInstance()

vtkvmtkSurfaceProjectCellArray * vtkvmtkSurfaceProjectCellArray::NewInstance ( ) const

◆ PrintSelf()

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

Definition at line 176 of file vtkvmtkSurfaceProjectCellArray.cxx.

177{
178 this->Superclass::PrintSelf(os,indent);
179}

◆ New()

vtkvmtkSurfaceProjectCellArray * vtkvmtkSurfaceProjectCellArray::New ( )
static

◆ SetReferenceSurface()

virtual void vtkvmtkSurfaceProjectCellArray::SetReferenceSurface ( vtkPolyData * )
virtual

Set/Get the reference surface to compute distance from.

◆ GetReferenceSurface()

virtual vtkPolyData * vtkvmtkSurfaceProjectCellArray::GetReferenceSurface ( )
virtual

Set/Get the reference surface to compute distance from.

◆ SetProjectedArrayName()

virtual void vtkvmtkSurfaceProjectCellArray::SetProjectedArrayName ( const char * )
virtual

Set/Get the name of the output cell array holding the projected values. Commonly named "CellEntityIds".

◆ GetProjectedArrayName()

virtual char * vtkvmtkSurfaceProjectCellArray::GetProjectedArrayName ( )
virtual

Set/Get the name of the output cell array holding the projected values. Commonly named "CellEntityIds".

◆ SetDistanceTolerance()

virtual void vtkvmtkSurfaceProjectCellArray::SetDistanceTolerance ( double )
virtual

Set/Get the maximum admissible distance between a cell of the input surface and the closest cell of the reference surface. Cells farther than this tolerance from the reference surface are assigned DefaultValue.

◆ GetDistanceTolerance()

virtual double vtkvmtkSurfaceProjectCellArray::GetDistanceTolerance ( )
virtual

Set/Get the maximum admissible distance between a cell of the input surface and the closest cell of the reference surface. Cells farther than this tolerance from the reference surface are assigned DefaultValue.

◆ SetDefaultValue()

virtual void vtkvmtkSurfaceProjectCellArray::SetDefaultValue ( double )
virtual

Set/Get the value assigned to cells whose distance to the reference surface exceeds DistanceTolerance.

◆ GetDefaultValue()

virtual double vtkvmtkSurfaceProjectCellArray::GetDefaultValue ( )
virtual

Set/Get the value assigned to cells whose distance to the reference surface exceeds DistanceTolerance.

◆ RequestData()

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

Definition at line 67 of file vtkvmtkSurfaceProjectCellArray.cxx.

71{
72 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
73 vtkInformation *outInfo = outputVector->GetInformationObject(0);
74
75 vtkPolyData *input = vtkPolyData::SafeDownCast(
76 inInfo->Get(vtkDataObject::DATA_OBJECT()));
77 vtkPolyData *output = vtkPolyData::SafeDownCast(
78 outInfo->Get(vtkDataObject::DATA_OBJECT()));
79
80
81 vtkCellLocator *locator;
82 vtkGenericCell *genericCell;
83
84 if (!this->ReferenceSurface)
85 {
86 vtkErrorMacro(<<"No reference surface!");
87 return 1;
88 }
89
90 vtkDataArray *referenceArray = this->ReferenceSurface->GetCellData()->GetArray(this->ProjectedArrayName);
91 if (!referenceArray)
92 {
93 vtkErrorMacro(<<"No reference array!");
94 return 1;
95 }
96
97 int numberOfCells = input->GetNumberOfCells();
98
99 output->DeepCopy(input);
100
101 vtkDataArray *projectedArray = output->GetCellData()->GetArray(this->ProjectedArrayName);
102
103 if (!projectedArray)
104 {
105 projectedArray = vtkDoubleArray::New();
106 projectedArray->SetName(this->ProjectedArrayName);
107 projectedArray->SetNumberOfTuples(numberOfCells);
108 projectedArray->SetNumberOfComponents(referenceArray->GetNumberOfComponents());
109 output->GetCellData()->AddArray(projectedArray);
110 }
111
112 int numberOfComponents = std::min(referenceArray->GetNumberOfComponents(), projectedArray->GetNumberOfComponents());
113
114 for (int i=0; i<numberOfComponents; i++)
115 {
116 projectedArray->FillComponent(i, DefaultValue);
117 }
118
119
120 this->ReferenceSurface->BuildCells();
121
122 locator = vtkCellLocator::New();
123 genericCell = vtkGenericCell::New();
124
125 locator->SetDataSet(this->ReferenceSurface);
126 locator->BuildLocator();
127
128 vtkIdList *cellPtsIds = vtkIdList::New();
129
130 double point[3], closestPoint[3];
131 double distance2;
132 double distanceTolerance2 = this->DistanceTolerance*this->DistanceTolerance;
133 vtkIdType cellId;
134 int subId;
135
136 for (int i=0; i<numberOfCells; i++)
137 {
138 input->GetCellPoints(i,cellPtsIds);
139 bool skipCell = false;
140 double minDistance = VTK_VMTK_LARGE_DOUBLE;
141 vtkIdType minId = 0;
142
143 //Find the cell with the smallest minimum distance to the vertices
144 for (int j=0; j<cellPtsIds->GetNumberOfIds(); j++)
145 {
146 input->GetPoint(cellPtsIds->GetId(j), point);
147 locator->FindClosestPoint(point,closestPoint,genericCell,cellId,subId,distance2);
148 if (distance2>distanceTolerance2)
149 {
150 skipCell = true;
151 break;
152 }
153 if ((j==0) || (distance2 < minDistance))
154 {
155 minDistance = distance2;
156 minId = cellId;
157 }
158 }
159
160 if (!skipCell)
161 {
162 for (int j=0; j<numberOfComponents; j++)
163 {
164 projectedArray->SetComponent(i,j,referenceArray->GetComponent(minId,j));
165 }
166 }
167 }
168
169 locator->Delete();
170 genericCell->Delete();
171 cellPtsIds->Delete();
172
173 return 1;
174}

Member Data Documentation

◆ ReferenceSurface

vtkPolyData* vtkvmtkSurfaceProjectCellArray::ReferenceSurface
protected

Definition at line 88 of file vtkvmtkSurfaceProjectCellArray.h.

◆ ProjectedArrayName

char* vtkvmtkSurfaceProjectCellArray::ProjectedArrayName
protected

Definition at line 90 of file vtkvmtkSurfaceProjectCellArray.h.

◆ DistanceTolerance

double vtkvmtkSurfaceProjectCellArray::DistanceTolerance
protected

Definition at line 92 of file vtkvmtkSurfaceProjectCellArray.h.

◆ DefaultValue

double vtkvmtkSurfaceProjectCellArray::DefaultValue
protected

Definition at line 93 of file vtkvmtkSurfaceProjectCellArray.h.


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