VTK  9.3.20240418
vtkPLYWriter.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
58 #ifndef vtkPLYWriter_h
59 #define vtkPLYWriter_h
60 
61 #include "vtkIOPLYModule.h" // For export macro
62 #include "vtkSmartPointer.h" // For protected ivars
63 #include "vtkWriter.h"
64 
65 #include <string> // For string parameter
66 
67 VTK_ABI_NAMESPACE_BEGIN
69 class vtkPolyData;
70 class vtkScalarsToColors;
71 class vtkStringArray;
73 
74 #define VTK_LITTLE_ENDIAN 0
75 #define VTK_BIG_ENDIAN 1
76 
77 #define VTK_COLOR_MODE_DEFAULT 0
78 #define VTK_COLOR_MODE_UNIFORM_CELL_COLOR 1
79 #define VTK_COLOR_MODE_UNIFORM_POINT_COLOR 2
80 #define VTK_COLOR_MODE_UNIFORM_COLOR 3
81 #define VTK_COLOR_MODE_OFF 4
82 
83 #define VTK_TEXTURECOORDS_UV 0
84 #define VTK_TEXTURECOORDS_TEXTUREUV 1
85 
86 class VTKIOPLY_EXPORT vtkPLYWriter : public vtkWriter
87 {
88 public:
89  static vtkPLYWriter* New();
90  vtkTypeMacro(vtkPLYWriter, vtkWriter);
91  void PrintSelf(ostream& os, vtkIndent indent) override;
92 
94 
98  vtkSetClampMacro(DataByteOrder, int, VTK_LITTLE_ENDIAN, VTK_BIG_ENDIAN);
99  vtkGetMacro(DataByteOrder, int);
100  void SetDataByteOrderToBigEndian() { this->SetDataByteOrder(VTK_BIG_ENDIAN); }
101  void SetDataByteOrderToLittleEndian() { this->SetDataByteOrder(VTK_LITTLE_ENDIAN); }
103 
105 
113  vtkSetMacro(WriteToOutputString, bool);
114  vtkGetMacro(WriteToOutputString, bool);
115  vtkBooleanMacro(WriteToOutputString, bool);
116  const std::string& GetOutputString() const { return this->OutputString; }
118 
120 
124  vtkSetMacro(WriteObjectInformation, bool);
125  vtkGetMacro(WriteObjectInformation, bool);
126  vtkBooleanMacro(WriteObjectInformation, bool);
128 
130 
147  vtkSetMacro(ColorMode, int);
148  vtkGetMacro(ColorMode, int);
149  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
152  void SetColorModeToUniformColor() // both cells and points are colored
153  {
154  this->SetColorMode(VTK_COLOR_MODE_UNIFORM_COLOR);
155  }
156  void SetColorModeToOff() // No color information is written
157  {
158  this->SetColorMode(VTK_COLOR_MODE_OFF);
159  }
161 
163 
167  vtkSetMacro(EnableAlpha, bool);
168  vtkGetMacro(EnableAlpha, bool);
169  vtkBooleanMacro(EnableAlpha, bool);
171 
173 
176  vtkSetStringMacro(ArrayName);
177  vtkGetStringMacro(ArrayName);
179 
181 
184  vtkSetClampMacro(Component, int, 0, VTK_INT_MAX);
185  vtkGetMacro(Component, int);
187 
189 
194  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
196 
198 
204  vtkSetVector3Macro(Color, unsigned char);
205  vtkGetVector3Macro(Color, unsigned char);
207 
209 
212  vtkSetMacro(Alpha, unsigned char);
213  vtkGetMacro(Alpha, unsigned char);
215 
217 
223 
225 
231 
233 
236  vtkSetClampMacro(FileType, int, VTK_ASCII, VTK_BINARY);
237  vtkGetMacro(FileType, int);
238  void SetFileTypeToASCII() { this->SetFileType(VTK_ASCII); }
239  void SetFileTypeToBinary() { this->SetFileType(VTK_BINARY); }
241 
243 
247  vtkSetClampMacro(TextureCoordinatesName, int, VTK_TEXTURECOORDS_UV, VTK_TEXTURECOORDS_TEXTUREUV);
248  vtkGetMacro(TextureCoordinatesName, int);
249  void SetTextureCoordinatesNameToUV() { this->SetTextureCoordinatesName(VTK_TEXTURECOORDS_UV); }
251  {
252  this->SetTextureCoordinatesName(VTK_TEXTURECOORDS_TEXTUREUV);
253  }
255 
259  void AddComment(const std::string& comment);
260 
261 protected:
263  ~vtkPLYWriter() override;
264 
265  void WriteData() override;
268  const float* GetNormals(vtkIdType num, vtkDataSetAttributes* dsa);
269 
271  char* ArrayName;
275  unsigned char Color[3];
276 
278  unsigned char Alpha;
279 
280  char* FileName;
281 
282  int FileType;
284 
286 
287  // Whether this object is writing to a string or a file.
288  // Default is 0: write to file.
290 
292 
293  // The output string.
295 
297 
298 private:
299  vtkPLYWriter(const vtkPLYWriter&) = delete;
300  void operator=(const vtkPLYWriter&) = delete;
301 };
302 
303 VTK_ABI_NAMESPACE_END
304 #endif
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:108
Store vtkAlgorithm input/output information.
write Stanford PLY file format
Definition: vtkPLYWriter.h:87
char * FileName
Definition: vtkPLYWriter.h:280
void SetDataByteOrderToLittleEndian()
If the file type is binary, then the user can specify which byte order to use (little versus big endi...
Definition: vtkPLYWriter.h:101
vtkSetFilePathMacro(FileName)
Specify file name of vtk polygon data file to write.
const std::string & GetOutputString() const
Enable writing to an OutputString instead of the default, a file.
Definition: vtkPLYWriter.h:116
void SetColorModeToUniformCellColor()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:150
void SetFileTypeToASCII()
Specify file type (ASCII or BINARY) for vtk data file.
Definition: vtkPLYWriter.h:238
void SetColorModeToUniformColor()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:152
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void SetFileTypeToBinary()
Specify file type (ASCII or BINARY) for vtk data file.
Definition: vtkPLYWriter.h:239
void SetDataByteOrderToBigEndian()
If the file type is binary, then the user can specify which byte order to use (little versus big endi...
Definition: vtkPLYWriter.h:100
vtkGetFilePathMacro(FileName)
Specify file name of vtk polygon data file to write.
void AddComment(const std::string &comment)
Add a comment in the header part.
char * ArrayName
Definition: vtkPLYWriter.h:271
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkScalarsToColors * LookupTable
Definition: vtkPLYWriter.h:274
unsigned char Alpha
Definition: vtkPLYWriter.h:278
std::string OutputString
Definition: vtkPLYWriter.h:294
vtkSmartPointer< vtkUnsignedCharArray > GetColors(vtkIdType num, vtkDataSetAttributes *dsa)
~vtkPLYWriter() override
void SetTextureCoordinatesNameToUV()
Choose the name used for the texture coordinates.
Definition: vtkPLYWriter.h:249
void SetColorModeToDefault()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:149
void SetColorModeToUniformPointColor()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:151
static vtkPLYWriter * New()
bool WriteToOutputString
Definition: vtkPLYWriter.h:289
void WriteData() override
vtkPolyData * GetInput(int port)
Get the input to this writer.
const float * GetNormals(vtkIdType num, vtkDataSetAttributes *dsa)
int TextureCoordinatesName
Definition: vtkPLYWriter.h:283
virtual void SetLookupTable(vtkScalarsToColors *)
A lookup table can be specified in order to convert data arrays to RGBA colors.
bool WriteObjectInformation
Definition: vtkPLYWriter.h:291
void SetTextureCoordinatesNameToTextureUV()
Choose the name used for the texture coordinates.
Definition: vtkPLYWriter.h:250
vtkSmartPointer< vtkStringArray > HeaderComments
Definition: vtkPLYWriter.h:285
vtkPolyData * GetInput()
Get the input to this writer.
void SetColorModeToOff()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:156
const float * GetTextureCoordinates(vtkIdType num, vtkDataSetAttributes *dsa)
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:181
Superclass for mapping scalar values to colors.
a vtkAbstractArray subclass for strings
dynamic, self-adjusting array of unsigned char
abstract class to write data to file(s)
Definition: vtkWriter.h:35
@ Color
Definition: vtkX3D.h:46
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
@ string
Definition: vtkX3D.h:490
#define VTK_LITTLE_ENDIAN
Definition: vtkPLYWriter.h:74
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkPLYWriter.h:77
#define VTK_COLOR_MODE_OFF
Definition: vtkPLYWriter.h:81
#define VTK_COLOR_MODE_UNIFORM_POINT_COLOR
Definition: vtkPLYWriter.h:79
#define VTK_TEXTURECOORDS_UV
Definition: vtkPLYWriter.h:83
#define VTK_COLOR_MODE_UNIFORM_COLOR
Definition: vtkPLYWriter.h:80
#define VTK_BIG_ENDIAN
Definition: vtkPLYWriter.h:75
#define VTK_COLOR_MODE_UNIFORM_CELL_COLOR
Definition: vtkPLYWriter.h:78
#define VTK_TEXTURECOORDS_TEXTUREUV
Definition: vtkPLYWriter.h:84
int vtkIdType
Definition: vtkType.h:315
#define VTK_INT_MAX
Definition: vtkType.h:144
#define VTK_BINARY
Definition: vtkWriter.h:32
#define VTK_ASCII
Definition: vtkWriter.h:31