File: vtkCGMWriter.h

package info (click to toggle)
paraview 5.13.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 544,220 kB
  • sloc: cpp: 3,374,605; ansic: 1,332,409; python: 150,381; xml: 122,166; sql: 65,887; sh: 7,317; javascript: 5,262; yacc: 4,417; java: 3,977; perl: 2,363; lex: 1,929; f90: 1,397; makefile: 170; objc: 153; tcl: 59; pascal: 50; fortran: 29
file content (129 lines) | stat: -rw-r--r-- 4,339 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
/**
 * @class   vtkCGMWriter
 * @brief   write polygonal data as a CGM file
 *
 * vtkCGMWriter writes CGM (Computer Graphics Metafile) output. CGM is a 2D
 * graphics vector format typically used by large plotters. This writer can
 * handle vertices, lines, polygons, and triangle strips in any combination.
 * Colors are specified either 1) from cell scalars (assumed to be RGB or
 * RGBA color specification), 2) from a specified color; or 3) randomly
 * assigned colors.
 *
 * Note: During output of the polygonal data, triangle strips are converted
 * to triangles, and polylines to lines. Also, due to limitations in the CGM
 * color model, only 256 colors are available to the color palette.
 *
 * @warning
 * The class vtkImageToPolyDataFilter is convenient for converting a raster
 * image into polygons (and color map) suitable for plotting with CGM.
 *
 * @sa
 * vtkPolyDataWriter vtkPointDataToCellData
 */

#ifndef vtkCGMWriter_h
#define vtkCGMWriter_h

#include "vtkIOGeometryModule.h" // For export macro
#include "vtkPolyDataWriter.h"

VTK_ABI_NAMESPACE_BEGIN
class vtkViewport;

#define VTK_COLOR_MODE_DEFAULT 0
#define VTK_COLOR_MODE_SPECIFIED_COLOR 1
#define VTK_COLOR_MODE_RANDOM_COLORS 2

class VTKIOGEOMETRY_EXPORT vtkCGMWriter : public vtkPolyDataWriter
{
public:
  /**
   * Instantiate with no viewport defined and sorting on. The default
   * resolution is 10,000, and the color mode is set to default.
   */
  static vtkCGMWriter* New();

  vtkTypeMacro(vtkCGMWriter, vtkPolyDataWriter);
  void PrintSelf(ostream& os, vtkIndent indent);

  ///@{
  /**
   * Specify a vtkViewport object to be used to transform the vtkPolyData
   * points into 2D coordinates. By default (no vtkViewport specified), the
   * point coordinates are generated by ignoring the z values. If a viewport
   * is defined, then the points are transformed into viewport coordinates.
   */
  virtual void SetViewport(vtkViewport*);
  vtkGetObjectMacro(Viewport, vtkViewport);
  ///@}

  ///@{
  /**
   * Turn on/off the sorting of the cells via depth. If enabled, polygonal
   * cells will be sorted from back to front, i.e., a Painter's algorithm
   * sort.
   */
  vtkSetMacro(Sort, int);
  vtkGetMacro(Sort, int);
  ///@}

  ///@{
  /**
   * Specify the resolution of the CGM file. This number is used to integerize
   * the maximum coordinate range of the plot file.
   */
  vtkSetClampMacro(Resolution, int, 100, VTK_INT_MAX);
  vtkGetMacro(Resolution, int);
  ///@}

  ///@{
  /**
   * Control how output polydata is colored. By default (ColorModeToDefault),
   * if per cell colors are defined (unsigned chars of 1-4 components), then
   * the cells are colored with these values. (If point colors are defined
   * and cell colors are not, you can use vtkPointDataToCellData to convert
   * the point colors to cell colors.) Otherwise, by default, the cells are
   * set to the specified color. If ColorModeToSpecifiedColor is set, then
   * the primitives will all be set to this color. If ColorModeToRandomColors
   * is set, each cell will be randomly assigned a color.
   */
  vtkSetMacro(ColorMode, int);
  vtkGetMacro(ColorMode, int);
  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
  void SetColorModeToSpecifiedColor() { this->SetColorMode(VTK_COLOR_MODE_SPECIFIED_COLOR); }
  void SetColorModeToRandomColors() { this->SetColorMode(VTK_COLOR_MODE_RANDOM_COLORS); }
  ///@}

  ///@{
  /**
   * Set/Get the specified color to color the polydata cells. This
   * color is only used when the color mode is set to
   * ColorModeToSpecifiedColor, or ColorModeToDefault is set and no
   * cell colors are specified. The specified color is specified as RGB
   * values ranging from (0,1). (Note: CGM will map this color to the
   * closest color it supports.)
   */
  vtkSetVector3Macro(SpecifiedColor, float);
  vtkGetVectorMacro(SpecifiedColor, float, 3);
  ///@}

protected:
  vtkCGMWriter();
  ~vtkCGMWriter() override;
  void WriteData();

  vtkViewport* Viewport;
  int ColorMode;
  float SpecifiedColor[3];
  int Resolution;
  int Sort;

private:
  vtkCGMWriter(const vtkCGMWriter&) = delete;
  void operator=(const vtkCGMWriter&) = delete;
};

VTK_ABI_NAMESPACE_END
#endif