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 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCGMWriter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @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"
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();
void WriteData();
vtkViewport *Viewport;
int ColorMode;
float SpecifiedColor[3];
int Resolution;
int Sort;
private:
vtkCGMWriter(const vtkCGMWriter&) VTK_DELETE_FUNCTION;
void operator=(const vtkCGMWriter&) VTK_DELETE_FUNCTION;
};
#endif
|