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

Method DrawPoly

IO/ExportPDF/vtkPDFContextDevice2D.cxx:661–703  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

659
660//------------------------------------------------------------------------------
661void vtkPDFContextDevice2D::DrawPoly(float* points, int n, unsigned char* colors, int nc_comps)
662{
663 assert(nc_comps == 0 || colors != nullptr);
664 assert(n > 0);
665 assert(points != nullptr);
666
667 if (this->Pen->GetLineType() == vtkPen::NO_PEN)
668 {
669 return;
670 }
671
672 if (!colors && this->Pen->GetColorObject().GetAlpha() == 0)
673 {
674 return;
675 }
676
677 this->PushGraphicsState();
678 this->ApplyPenState();
679
680 if (colors == nullptr)
681 {
682 HPDF_Page_MoveTo(this->Impl->Page, points[0], points[1]);
683 for (int i = 1; i < n; ++i)
684 {
685 HPDF_Page_LineTo(this->Impl->Page, points[i * 2], points[i * 2 + 1]);
686 }
687 this->Stroke();
688 }
689 else
690 {
691 vtkVector2f width = this->GetUnscaledPenWidth() * 0.5f;
692 const float radius = std::max(width[0], width[1]) * 0.5f;
693 HPDF_REAL bbox[4];
694 GetPointBounds(points, n, bbox, radius);
695
696 HPDF_Shading shading = HPDF_Shading_New(this->Impl->Document,
697 HPDF_SHADING_FREE_FORM_TRIANGLE_MESH, HPDF_CS_DEVICE_RGB, bbox[0], bbox[1], bbox[2], bbox[3]);
698 PolyLineToShading(points, n, colors, nc_comps, radius, shading);
699 HPDF_Page_SetShading(this->Impl->Page, shading);
700 }
701
702 this->PopGraphicsState();
703}
704
705//------------------------------------------------------------------------------
706void vtkPDFContextDevice2D::DrawLines(float* f, int n, unsigned char* colors, int nc_comps)

Callers 2

PaintMethod · 0.45
PaintMethod · 0.45

Calls 15

PushGraphicsStateMethod · 0.95
ApplyPenStateMethod · 0.95
StrokeMethod · 0.95
GetUnscaledPenWidthMethod · 0.95
PopGraphicsStateMethod · 0.95
HPDF_Page_MoveToFunction · 0.85
HPDF_Page_LineToFunction · 0.85
GetPointBoundsFunction · 0.85
HPDF_Shading_NewFunction · 0.85
PolyLineToShadingFunction · 0.85
HPDF_Page_SetShadingFunction · 0.85
GetLineTypeMethod · 0.80

Tested by 2

PaintMethod · 0.36
PaintMethod · 0.36