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

Method WritePolyData

IO/Geometry/vtkIVWriter.cxx:52–209  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

50
51//------------------------------------------------------------------------------
52void vtkIVWriter::WritePolyData(vtkPolyData* pd, FILE* fp)
53{
54 vtkPoints* points;
55 vtkIdType i;
56 vtkCellArray* cells;
57 vtkIdType npts = 0;
58 const vtkIdType* indx = nullptr;
59 vtkUnsignedCharArray* colors = nullptr;
60
61 points = pd->GetPoints();
62
63 // create colors for vertices
64 vtkDataArray* scalars = pd->GetPointData()->GetScalars();
65
66 if (scalars)
67 {
68 vtkLookupTable* lut;
69 if ((lut = scalars->GetLookupTable()) == nullptr)
70 {
71 lut = vtkLookupTable::New();
72 lut->Build();
73 }
74 colors = lut->MapScalars(scalars, VTK_COLOR_MODE_DEFAULT, 0);
75 if (!scalars->GetLookupTable())
76 {
77 lut->Delete();
78 }
79 }
80
81 vtk::print(fp, "Separator {{\n");
82
83 // Point data (coordinates)
84 vtk::print(fp, "\tCoordinate3 {{\n");
85 vtk::print(fp, "\t\tpoint [\n");
86 vtk::print(fp, "\t\t\t");
87 for (i = 0; i < points->GetNumberOfPoints(); i++)
88 {
89 double xyz[3];
90 points->GetPoint(i, xyz);
91 vtk::print(fp, "{:g} {:g} {:g}, ", xyz[0], xyz[1], xyz[2]);
92 if (!((i + 1) % 2))
93 {
94 vtk::print(fp, "\n\t\t\t");
95 }
96 }
97 vtk::print(fp, "\n\t\t]");
98 vtk::print(fp, "\t}}\n");
99
100 // Per vertex coloring
101 vtk::print(fp, "\tMaterialBinding {{\n");
102 vtk::print(fp, "\t\tvalue PER_VERTEX_INDEXED\n");
103 vtk::print(fp, "\t}}\n");
104
105 // Colors, if any
106 if (colors)
107 {
108 vtk::print(fp, "\tMaterial {{\n");
109 vtk::print(fp, "\t\tdiffuseColor [\n");

Callers 1

WriteDataMethod · 0.95

Calls 15

GetNumberOfPolysMethod · 0.80
GetPolysMethod · 0.80
GetVertsMethod · 0.80
GetNumberOfStripsMethod · 0.80
GetStripsMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
printFunction · 0.50
GetPointsMethod · 0.45
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
GetLookupTableMethod · 0.45

Tested by

no test coverage detected