------------------------------------------------------------------------------
| 125 | |
| 126 | //------------------------------------------------------------------------------ |
| 127 | void vtkOctreePointLocatorNode::ComputeOctreeNodeInformation( |
| 128 | vtkOctreePointLocatorNode* Parent, int& NextLeafId, int& NextMinId, float* coordinates) |
| 129 | { |
| 130 | this->MinID = NextMinId; |
| 131 | if (this->Children) |
| 132 | { |
| 133 | int i; |
| 134 | for (i = 0; i < 8; i++) |
| 135 | { |
| 136 | this->Children[i]->ComputeOctreeNodeInformation(this, NextLeafId, NextMinId, coordinates); |
| 137 | } |
| 138 | // a non-leaf region can get its data bounds from its children... |
| 139 | this->SetMinDataBounds(this->Children[0]->GetMinDataBounds()); |
| 140 | this->SetMaxDataBounds(this->Children[0]->GetMaxDataBounds()); |
| 141 | |
| 142 | for (i = 1; i < 8; i++) |
| 143 | { |
| 144 | const double* min = this->Children[i]->GetMinDataBounds(); |
| 145 | const double* max = this->Children[i]->GetMaxDataBounds(); |
| 146 | for (int j = 0; j < 3; j++) |
| 147 | { |
| 148 | this->MinDataBounds[j] = std::min(min[j], this->MinDataBounds[j]); |
| 149 | this->MaxDataBounds[j] = std::max(max[j], this->MaxDataBounds[j]); |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | else |
| 154 | { |
| 155 | this->ID = NextLeafId; |
| 156 | NextLeafId++; |
| 157 | NextMinId = this->MinID + this->NumberOfPoints; |
| 158 | if (this->NumberOfPoints == 0) |
| 159 | { |
| 160 | // since there are no points in this, set the data bounds |
| 161 | // such that they won't affect anything else |
| 162 | this->SetMinDataBounds(Parent->GetMaxBounds()); |
| 163 | this->SetMaxDataBounds(Parent->GetMinBounds()); |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | int i; |
| 168 | float* coordptr = coordinates + 3 * this->MinID; |
| 169 | for (i = 0; i < 3; i++) |
| 170 | { |
| 171 | this->MinDataBounds[i] = this->MaxDataBounds[i] = coordptr[i]; |
| 172 | } |
| 173 | for (i = 1; i < this->NumberOfPoints; i++) |
| 174 | { |
| 175 | coordptr += 3; |
| 176 | for (int j = 0; j < 3; j++) |
| 177 | { |
| 178 | if (coordptr[j] < this->MinDataBounds[j]) |
| 179 | { |
| 180 | this->MinDataBounds[j] = coordptr[j]; |
| 181 | } |
| 182 | else if (coordptr[j] > this->MaxDataBounds[j]) |
| 183 | { |
| 184 | this->MaxDataBounds[j] = coordptr[j]; |
no test coverage detected