------------------------------------------------------------------------------
| 126 | |
| 127 | //------------------------------------------------------------------------------ |
| 128 | bool vtkDistributedPointCloudFilter::OptimizeBoundingBox( |
| 129 | std::vector<vtkMPIController*>& kdTreeRounds, vtkPointSet* pointCloud, double regionBounds[6]) |
| 130 | { |
| 131 | if (kdTreeRounds.empty()) |
| 132 | { |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | // **************************************** |
| 137 | // Compute the domains bounds |
| 138 | |
| 139 | // Separate lower and upper because Allreduce should minimize lower and maximize upper |
| 140 | double localLowerBound[3]; |
| 141 | double localUpperBound[3]; |
| 142 | double currentGroupLowerBound[3]; |
| 143 | double currentGroupUpperBound[3]; |
| 144 | |
| 145 | vtkIdType numPts = pointCloud->GetNumberOfPoints(); |
| 146 | if (numPts > 0) |
| 147 | { |
| 148 | double* bounds = pointCloud->GetBounds(); |
| 149 | for (int i = 0; i < 3; ++i) |
| 150 | { |
| 151 | localLowerBound[i] = bounds[2 * i + 0]; |
| 152 | localUpperBound[i] = bounds[2 * i + 1]; |
| 153 | } |
| 154 | } |
| 155 | else |
| 156 | { |
| 157 | for (int i = 0; i < 3; ++i) |
| 158 | { |
| 159 | localLowerBound[i] = +std::numeric_limits<double>::max(); |
| 160 | localUpperBound[i] = -std::numeric_limits<double>::max(); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | // **************************************** |
| 165 | // Main Loop: transfer points between process. |
| 166 | // Point cloud is recursively split in two, among MPI groups. |
| 167 | // Algorithm: |
| 168 | // - 1. choose an axis (the longest) |
| 169 | // - 2. build the local histogram of number of points along the given axis |
| 170 | // - 3. compute the global histogram |
| 171 | // - 4. process 0 only: find the median and the corresponding cut position and share it to others |
| 172 | // - 5. split points in two groups : to keep on this node or to send |
| 173 | // - 6. exchange points: each MPI process find a partner in the other MPI group. |
| 174 | // - 7. update current MPI group bounds |
| 175 | // Each round concerns a MPI subgroup of previous round group |
| 176 | |
| 177 | const int histSize = HISTOGRAM_SIZE; |
| 178 | std::vector<int> histogram(histSize, 0); |
| 179 | std::vector<int> histsum(histSize, 0); |
| 180 | std::vector<vtkIdType> pointExchangeCount(kdTreeRounds[0]->GetNumberOfProcesses(), 0); |
| 181 | std::vector<double> pts; |
| 182 | |
| 183 | if (numPts > 0) |
| 184 | { |
| 185 | pts.resize(3 * numPts); |
no test coverage detected