1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkLocator.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 "vtkLocator.h"
16 
17 #include "vtkDataSet.h"
18 #include "vtkGarbageCollector.h"
19 
20 vtkCxxSetObjectMacro(vtkLocator, DataSet, vtkDataSet);
21 
vtkLocator()22 vtkLocator::vtkLocator()
23 {
24   this->DataSet = nullptr;
25   this->Tolerance = 0.001;
26   this->Automatic = 1;
27   this->MaxLevel = 8;
28   this->Level = 8;
29 }
30 
~vtkLocator()31 vtkLocator::~vtkLocator()
32 {
33   // commented out because of compiler problems in g++
34   //  this->FreeSearchStructure();
35   this->SetDataSet(nullptr);
36 }
37 
Initialize()38 void vtkLocator::Initialize()
39 {
40   // free up hash table
41   this->FreeSearchStructure();
42 }
43 
Update()44 void vtkLocator::Update()
45 {
46   if (!this->DataSet)
47   {
48     vtkErrorMacro(<< "Input not set!");
49     return;
50   }
51   if ((this->MTime > this->BuildTime) || (this->DataSet->GetMTime() > this->BuildTime))
52   {
53     this->BuildLocator();
54   }
55 }
56 
PrintSelf(ostream & os,vtkIndent indent)57 void vtkLocator::PrintSelf(ostream& os, vtkIndent indent)
58 {
59   this->Superclass::PrintSelf(os, indent);
60 
61   if (this->DataSet)
62   {
63     os << indent << "DataSet: " << this->DataSet << "\n";
64   }
65   else
66   {
67     os << indent << "DataSet: (none)\n";
68   }
69 
70   os << indent << "Automatic: " << (this->Automatic ? "On\n" : "Off\n");
71   os << indent << "Tolerance: " << this->Tolerance << "\n";
72   os << indent << "Build Time: " << this->BuildTime.GetMTime() << "\n";
73   os << indent << "MaxLevel: " << this->MaxLevel << "\n";
74   os << indent << "Level: " << this->Level << "\n";
75 }
76 
77 //------------------------------------------------------------------------------
Register(vtkObjectBase * o)78 void vtkLocator::Register(vtkObjectBase* o)
79 {
80   this->RegisterInternal(o, 1);
81 }
82 
83 //------------------------------------------------------------------------------
UnRegister(vtkObjectBase * o)84 void vtkLocator::UnRegister(vtkObjectBase* o)
85 {
86   this->UnRegisterInternal(o, 1);
87 }
88 
89 //------------------------------------------------------------------------------
ReportReferences(vtkGarbageCollector * collector)90 void vtkLocator::ReportReferences(vtkGarbageCollector* collector)
91 {
92   this->Superclass::ReportReferences(collector);
93   vtkGarbageCollectorReport(collector, this->DataSet, "DataSet");
94 }
95