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

Method DrawPathPS

Rendering/GL2PSOpenGL2/vtkOpenGLGL2PSHelperImpl.cxx:796–936  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

794
795//------------------------------------------------------------------------------
796void vtkOpenGLGL2PSHelperImpl::DrawPathPS(vtkPath* path, double rasterPos[3], double windowPos[2],
797 unsigned char rgba[4], double scale[2], double rotateAngle, float strokeWidth,
798 const std::string& label)
799{
800 vtkFloatArray* points = vtkArrayDownCast<vtkFloatArray>(path->GetPoints()->GetData());
801 vtkIntArray* codes = path->GetCodes();
802
803 if (points->GetNumberOfTuples() != codes->GetNumberOfTuples())
804 {
805 return;
806 }
807
808 std::stringstream out;
809 out.setf(std::ios_base::left | std::ios_base::fixed);
810 constexpr int floatPrec = 2;
811 constexpr int floatWidth = 6;
812 out.precision(floatPrec);
813 out.width(floatWidth);
814
815 float curveto[3][2];
816 float curX = 0;
817 float curY = 0;
818
819 float* pt = points->GetPointer(0);
820 int* code = codes->GetPointer(0);
821
822 // These are only used in an assertion, ifdef silences warning on non-debug
823 // builds
824#ifndef NDEBUG
825 float* ptBegin = pt;
826 int* codeBegin = code;
827#endif
828 int* codeEnd = code + codes->GetNumberOfTuples();
829 if (!label.empty())
830 {
831 out << "% " << label << endl;
832 }
833 out << "gsave" << endl;
834 out << "initmatrix" << endl;
835 out << windowPos[0] << " " << windowPos[1] << " translate" << endl;
836 if (scale)
837 {
838 out << scale[0] << " " << scale[1] << " scale" << endl;
839 }
840 out << rotateAngle << " rotate" << endl;
841 out << "newpath" << endl;
842 while (code < codeEnd)
843 {
844 assert(pt - ptBegin == (code - codeBegin) * 3);
845
846 switch (static_cast<vtkPath::ControlPointType>(*code))
847 {
848 case vtkPath::MOVE_TO:
849 curX = *pt;
850 curY = *(++pt);
851 ++pt; // Flush z
852 out << curX << " " << curY << " moveto\n";
853 break;

Callers 1

DrawPathMethod · 0.95

Calls 13

gl2psForceRasterPosFunction · 0.85
gl2psSpecialFunction · 0.85
gl2psGetFileFormatFunction · 0.85
GetCodesMethod · 0.80
widthMethod · 0.80
assertFunction · 0.50
GetDataMethod · 0.45
GetPointsMethod · 0.45
GetNumberOfTuplesMethod · 0.45
GetPointerMethod · 0.45
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected