1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkInterpolationKernel.cxx
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 #include "vtkInterpolationKernel.h"
16 #include "vtkAbstractPointLocator.h"
17 #include "vtkDataSet.h"
18 #include "vtkPointData.h"
19 
20 //----------------------------------------------------------------------------
vtkInterpolationKernel()21 vtkInterpolationKernel::vtkInterpolationKernel()
22 {
23   this->RequiresInitialization = true;
24 
25   this->Locator = nullptr;
26   this->DataSet = nullptr;
27   this->PointData = nullptr;
28 }
29 
30 //----------------------------------------------------------------------------
~vtkInterpolationKernel()31 vtkInterpolationKernel::~vtkInterpolationKernel()
32 {
33   this->FreeStructures();
34 }
35 
36 //----------------------------------------------------------------------------
37 void vtkInterpolationKernel::
FreeStructures()38 FreeStructures()
39 {
40   if ( this->Locator )
41   {
42     this->Locator->Delete();
43     this->Locator = nullptr;
44   }
45 
46   if ( this->DataSet )
47   {
48     this->DataSet->Delete();
49     this->DataSet = nullptr;
50   }
51 
52   if ( this->PointData )
53   {
54     this->PointData->Delete();
55     this->PointData = nullptr;
56   }
57 }
58 
59 //----------------------------------------------------------------------------
60 void vtkInterpolationKernel::
Initialize(vtkAbstractPointLocator * loc,vtkDataSet * ds,vtkPointData * attr)61 Initialize(vtkAbstractPointLocator *loc, vtkDataSet *ds, vtkPointData *attr)
62 {
63   this->FreeStructures();
64 
65   if ( loc )
66   {
67     this->Locator = loc;
68     this->Locator->Register(this);
69   }
70 
71   if ( ds )
72   {
73     this->DataSet = ds;
74     this->DataSet->Register(this);
75   }
76 
77   if ( attr )
78   {
79     this->PointData = attr;
80     this->PointData->Register(this);
81   }
82 }
83 
84 //----------------------------------------------------------------------------
PrintSelf(ostream & os,vtkIndent indent)85 void vtkInterpolationKernel::PrintSelf(ostream& os, vtkIndent indent)
86 {
87   this->Superclass::PrintSelf(os,indent);
88 
89   os << indent << "Requires Initialization: "
90      << (this->GetRequiresInitialization() ? "On\n" : "Off\n");
91 
92   if ( this->Locator )
93   {
94     os << indent << "Locator:\n";
95     this->Locator->PrintSelf(os,indent.GetNextIndent());
96   }
97   else
98   {
99     os << indent << "Locator: (None)\n";
100   }
101 
102   if ( this->DataSet )
103   {
104     os << indent << "DataSet:\n";
105     this->DataSet->PrintSelf(os,indent.GetNextIndent());
106   }
107   else
108   {
109     os << indent << "DataSet: (None)\n";
110   }
111 
112   if ( this->PointData )
113   {
114     os << indent << "PointData:\n";
115     this->PointData->PrintSelf(os,indent.GetNextIndent());
116   }
117   else
118   {
119     os << indent << "PointData: (None)\n";
120   }
121 }
122