------------------------------------------------------------------------------ For streaming and threads. Splits output update extent into num pieces. This method needs to be called num times. Results must not overlap for consistent starting extent. Subclass can override this method. This method returns the number of pieces resulting from a successful split. This can be from 1 to "total". If 1
| 118 | // This can be from 1 to "total". |
| 119 | // If 1 is returned, the extent cannot be split. |
| 120 | int vtkThreadedImageAlgorithm::SplitExtent(int splitExt[6], int startExt[6], int num, int total) |
| 121 | { |
| 122 | // split path (the order in which to split the axes) |
| 123 | int pathlen = this->SplitPathLength; |
| 124 | int mode = this->SplitMode; |
| 125 | int axis0 = this->SplitPath[0]; |
| 126 | int axis1 = this->SplitPath[1]; |
| 127 | int axis2 = this->SplitPath[2]; |
| 128 | int path[3] = { axis0, axis1, axis2 }; |
| 129 | |
| 130 | // divisions |
| 131 | int divs[3] = { 1, 1, 1 }; |
| 132 | |
| 133 | // this needs 64 bits to avoid overflow in the math below |
| 134 | const vtkTypeInt64 size[3] = { startExt[1] - startExt[0] + 1, startExt[3] - startExt[2] + 1, |
| 135 | startExt[5] - startExt[4] + 1 }; |
| 136 | |
| 137 | // check for valid extent |
| 138 | if (size[0] <= 0 || size[1] <= 0 || size[2] <= 0) |
| 139 | { |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | // divide out the minimum block size |
| 144 | int maxdivs[3] = { 1, 1, 1 }; |
| 145 | for (int i = 0; i < 3; i++) |
| 146 | { |
| 147 | if (size[i] > this->MinimumPieceSize[i] && this->MinimumPieceSize[i] > 0) |
| 148 | { |
| 149 | maxdivs[i] = size[i] / this->MinimumPieceSize[i]; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // make sure total is not greater than max number of pieces |
| 154 | vtkTypeInt64 maxPieces = maxdivs[axis0]; |
| 155 | vtkTypeInt64 maxPieces2D = maxPieces; |
| 156 | if (pathlen > 1) |
| 157 | { |
| 158 | maxPieces *= maxdivs[axis1]; |
| 159 | maxPieces2D = maxPieces; |
| 160 | if (pathlen > 2) |
| 161 | { |
| 162 | maxPieces *= maxdivs[axis2]; |
| 163 | } |
| 164 | } |
| 165 | total = std::min<vtkTypeInt64>(total, maxPieces); |
| 166 | |
| 167 | if (mode == SLAB || pathlen < 2) |
| 168 | { |
| 169 | // split the axes in the given order |
| 170 | divs[axis0] = maxdivs[axis0]; |
| 171 | if (total < maxdivs[axis0]) |
| 172 | { |
| 173 | divs[axis0] = total; |
| 174 | } |
| 175 | else if (pathlen > 1) |
| 176 | { |
| 177 | divs[axis1] = maxdivs[axis1]; |
no test coverage detected