MCPcopy Create free account
hub / github.com/Kitware/VTK / BuildTree

Method BuildTree

Common/ExecutionModel/vtkSimpleScalarTree.cxx:84–193  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Construct the scalar tree from the dataset provided. Checks build times and modified time from input and reconstructs the tree if necessary.

Source from the content-addressed store, hash-verified

82// Construct the scalar tree from the dataset provided. Checks build times
83// and modified time from input and reconstructs the tree if necessary.
84void vtkSimpleScalarTree::BuildTree()
85{
86 vtkIdType cellId, i, j, numScalars;
87 int level, offset, parentOffset, prod;
88 vtkIdType numNodes, node, numLeafs, leaf, numParentLeafs;
89 vtkCell* cell;
90 vtkIdList* cellPts;
91 vtkScalarRange<double>*tree, *parent;
92 double* s;
93 vtkDoubleArray* cellScalars;
94
95 // Check input...see whether we have to rebuild
96 //
97 if (!this->DataSet || (this->NumCells = this->DataSet->GetNumberOfCells()) < 1)
98 {
99 vtkErrorMacro(<< "No data to build tree with");
100 return;
101 }
102
103 if (this->Tree != nullptr && this->BuildTime > this->MTime &&
104 this->BuildTime > this->DataSet->GetMTime())
105 {
106 return;
107 }
108
109 vtkDebugMacro(<< "Building scalar tree...");
110
111 // If no scalars set then try and grab them from dataset
112 if (!this->Scalars)
113 {
114 this->SetScalars(this->DataSet->GetPointData()->GetScalars());
115 }
116 if (!this->Scalars)
117 {
118 vtkErrorMacro(<< "No scalar data to build trees with");
119 return;
120 }
121
122 this->Initialize();
123 cellScalars = vtkDoubleArray::New();
124 cellScalars->Allocate(100);
125
126 // Compute the number of levels in the tree
127 //
128 numLeafs = static_cast<int>(ceil(static_cast<double>(this->NumCells) / this->BranchingFactor));
129 for (prod = 1, numNodes = 1, this->Level = 0; prod < numLeafs && this->Level <= this->MaxLevel;
130 this->Level++)
131 {
132 prod *= this->BranchingFactor;
133 numNodes += prod;
134 }
135
136 this->LeafOffset = offset = numNodes - prod;
137 vtkScalarRange<double>* TTree;
138 this->TreeSize = numNodes - (prod - numLeafs);
139 this->Tree = TTree = new vtkScalarRange<double>[this->TreeSize];
140 for (i = 0; i < this->TreeSize; i++)
141 {

Callers 2

InitTraversalMethod · 0.95

Calls 15

InitializeMethod · 0.95
SetScalarsMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
ceilFunction · 0.50
minFunction · 0.50
maxFunction · 0.50
GetNumberOfCellsMethod · 0.45
GetMTimeMethod · 0.45
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
AllocateMethod · 0.45

Tested by

no test coverage detected