| 1110 | //------------------------------------------------------------------------------ |
| 1111 | template <class T> |
| 1112 | void vtkImageCanvasSource2DFill(vtkImageData* image, double* color, T* ptr, int x, int y) |
| 1113 | { |
| 1114 | vtkImageCanvasSource2DPixel* pixel; |
| 1115 | vtkImageCanvasSource2DPixel *first, *last; |
| 1116 | vtkImageCanvasSource2DPixel* heap = nullptr; |
| 1117 | int min0, max0, min1, max1, min2, max2, maxV; |
| 1118 | int idxV; |
| 1119 | vtkIdType inc0, inc1, inc2; |
| 1120 | T fillColor[10]; |
| 1121 | T drawColor[10]; |
| 1122 | T *ptrV, *ptrC; |
| 1123 | int temp; |
| 1124 | |
| 1125 | image->GetExtent(min0, max0, min1, max1, min2, max2); |
| 1126 | maxV = image->GetNumberOfScalarComponents() - 1; |
| 1127 | image->GetIncrements(inc0, inc1, inc2); |
| 1128 | |
| 1129 | // Copy the fill color and make sure it differs from drawColor. |
| 1130 | ptrV = ptr; |
| 1131 | temp = 1; |
| 1132 | for (idxV = 0; idxV <= maxV; ++idxV) |
| 1133 | { |
| 1134 | // Save the fill color |
| 1135 | fillColor[idxV] = *ptrV; |
| 1136 | drawColor[idxV] = static_cast<T>(color[idxV]); |
| 1137 | if (*ptrV != drawColor[idxV]) |
| 1138 | { |
| 1139 | temp = 0; |
| 1140 | } |
| 1141 | ptrV++; |
| 1142 | } |
| 1143 | if (temp) |
| 1144 | { // fill the same as draw |
| 1145 | vtkGenericWarningMacro("Fill: Cannot handle draw color same as fill color"); |
| 1146 | return; |
| 1147 | } |
| 1148 | |
| 1149 | // Create the seed |
| 1150 | pixel = vtkImageCanvasSource2DPixel::New(); |
| 1151 | pixel->X = x; |
| 1152 | pixel->Y = y; |
| 1153 | pixel->Pointer = static_cast<void*>(ptr); |
| 1154 | pixel->Next = nullptr; |
| 1155 | first = last = pixel; |
| 1156 | // change the seeds color |
| 1157 | ptrV = static_cast<T*>(last->Pointer); |
| 1158 | ptrC = drawColor; |
| 1159 | for (idxV = 0; idxV <= maxV; ++idxV) |
| 1160 | { |
| 1161 | *ptrV = *ptrC++; |
| 1162 | ptrV++; |
| 1163 | } |
| 1164 | |
| 1165 | while (first) |
| 1166 | { |
| 1167 | ptr = static_cast<T*>(first->Pointer); |
| 1168 | |
| 1169 | // check bounds for -x neighbor |
no test coverage detected