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

Method DrawPolyData

IO/ExportPDF/vtkPDFContextDevice2D.cxx:1373–1470  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1371
1372//------------------------------------------------------------------------------
1373void vtkPDFContextDevice2D::DrawPolyData(
1374 float p[2], float scale, vtkPolyData* polyData, vtkUnsignedCharArray* colors, int scalarMode)
1375{
1376 // Do nothing if the supported cell types do not exist in the dataset:
1377 vtkNew<vtkCellTypes> types;
1378 polyData->GetDistinctCellTypes(types);
1379 if (!types->IsType(VTK_LINE) && !types->IsType(VTK_POLY_LINE) && !types->IsType(VTK_TRIANGLE) &&
1380 !types->IsType(VTK_QUAD) && !types->IsType(VTK_POLYGON))
1381 {
1382 return;
1383 }
1384
1385 double bounds[6];
1386 polyData->GetBounds(bounds);
1387
1388 float radius = this->Impl->computeWorldRadius(
1389 bounds[0], bounds[2], bounds[1], bounds[3], this->Matrix->GetMatrix(), this->Pen->GetWidth());
1390
1391 // Adjust bounds for transform, account for pen width:
1392 bounds[0] = (bounds[0] + p[0]) * scale - radius;
1393 bounds[1] = (bounds[1] + p[0]) * scale + radius;
1394 bounds[2] = (bounds[2] + p[1]) * scale - radius;
1395 bounds[3] = (bounds[3] + p[1]) * scale + radius;
1396
1397 // Accumulate all triangles in a shading object:
1398 HPDF_Shading shading =
1399 HPDF_Shading_New(this->Impl->Document, HPDF_SHADING_FREE_FORM_TRIANGLE_MESH, HPDF_CS_DEVICE_RGB,
1400 bounds[0], bounds[1], bounds[2], bounds[3]);
1401
1402 // Temporary buffers:
1403 std::vector<float> verts;
1404 std::vector<unsigned char> vertColors;
1405
1406 vtkCellIterator* cell = polyData->NewCellIterator();
1407 cell->InitTraversal();
1408 for (; !cell->IsDoneWithTraversal(); cell->GoToNextCell())
1409 {
1410 // To match the original implementation on the OpenGL2 backend, we only
1411 // handle polygons and lines:
1412 int cellType = cell->GetCellType();
1413 switch (cellType)
1414 {
1415 case VTK_LINE:
1416 case VTK_POLY_LINE:
1417 case VTK_TRIANGLE:
1418 case VTK_QUAD:
1419 case VTK_POLYGON:
1420 break;
1421
1422 default:
1423 continue;
1424 }
1425
1426 // Allocate temporary arrays:
1427 vtkIdType numPoints = cell->GetNumberOfPoints();
1428 if (numPoints == 0)
1429 {
1430 continue;

Callers 1

drawPolyLinePolyDataFunction · 0.45

Calls 15

HPDF_Shading_NewFunction · 0.85
PolyLineToShadingFunction · 0.85
PolygonToShadingFunction · 0.85
HPDF_Page_SetShadingFunction · 0.85
computeWorldRadiusMethod · 0.80
GoToNextCellMethod · 0.80
DeleteMethod · 0.65
GetDistinctCellTypesMethod · 0.45
IsTypeMethod · 0.45
GetBoundsMethod · 0.45
GetMatrixMethod · 0.45
GetWidthMethod · 0.45

Tested by 1

drawPolyLinePolyDataFunction · 0.36