------------------------------------------------------------------------------
| 50 | |
| 51 | //------------------------------------------------------------------------------ |
| 52 | void 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"); |
no test coverage detected