MCPcopy Create free account
hub / github.com/Kitware/VTK / DrawPolygon

Method DrawPolygon

Interaction/Style/vtkInteractorStyleDrawPolygon.cxx:166–193  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

164
165//------------------------------------------------------------------------------
166void 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//------------------------------------------------------------------------------
196void vtkInteractorStyleDrawPolygon::PrintSelf(ostream& os, vtkIndent indent)

Callers 1

OnMouseMoveMethod · 0.95

Calls 9

DeepCopyMethod · 0.45
GetPointerMethod · 0.45
GetSizeMethod · 0.45
GetRenderWindowMethod · 0.45
GetNumberOfPointsMethod · 0.45
GetPointMethod · 0.45
DrawPixelsMethod · 0.45
SetPixelDataMethod · 0.45
FrameMethod · 0.45

Tested by

no test coverage detected