------------------------------------------------------------------------------
| 164 | |
| 165 | //------------------------------------------------------------------------------ |
| 166 | void vtkInteractorStyleDrawPolygon::DrawPolygon() |
| 167 | { |
| 168 | vtkNew<vtkUnsignedCharArray> tmpPixelArray; |
| 169 | tmpPixelArray->DeepCopy(this->PixelArray); |
| 170 | unsigned char* pixels = tmpPixelArray->GetPointer(0); |
| 171 | const int* size = this->Interactor->GetRenderWindow()->GetSize(); |
| 172 | |
| 173 | // draw each line segment |
| 174 | for (vtkIdType i = 0; i < this->Internal->GetNumberOfPoints() - 1; i++) |
| 175 | { |
| 176 | const vtkVector2i& a = this->Internal->GetPoint(i); |
| 177 | const vtkVector2i& b = this->Internal->GetPoint(i + 1); |
| 178 | |
| 179 | this->Internal->DrawPixels(a, b, pixels, size); |
| 180 | } |
| 181 | |
| 182 | // draw a line from the end to the start |
| 183 | if (this->Internal->GetNumberOfPoints() >= 3) |
| 184 | { |
| 185 | const vtkVector2i& start = this->Internal->GetPoint(0); |
| 186 | const vtkVector2i& end = this->Internal->GetPoint(this->Internal->GetNumberOfPoints() - 1); |
| 187 | |
| 188 | this->Internal->DrawPixels(start, end, pixels, size); |
| 189 | } |
| 190 | |
| 191 | this->Interactor->GetRenderWindow()->SetPixelData(0, 0, size[0] - 1, size[1] - 1, pixels, 0); |
| 192 | this->Interactor->GetRenderWindow()->Frame(); |
| 193 | } |
| 194 | |
| 195 | //------------------------------------------------------------------------------ |
| 196 | void vtkInteractorStyleDrawPolygon::PrintSelf(ostream& os, vtkIndent indent) |
no test coverage detected