VTK  9.3.0
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
38#ifndef vtkPLYWriter_h
39#define vtkPLYWriter_h
40
41#include "vtkIOPLYModule.h" // For export macro
42#include "vtkSmartPointer.h" // For protected ivars
43#include "vtkWriter.h"
44
45#include <string> // For string parameter
46
47VTK_ABI_NAMESPACE_BEGIN
49class vtkPolyData;
51class vtkStringArray;
53
54#define VTK_LITTLE_ENDIAN 0
55#define VTK_BIG_ENDIAN 1
56
57#define VTK_COLOR_MODE_DEFAULT 0
58#define VTK_COLOR_MODE_UNIFORM_CELL_COLOR 1
59#define VTK_COLOR_MODE_UNIFORM_POINT_COLOR 2
60#define VTK_COLOR_MODE_UNIFORM_COLOR 3
61#define VTK_COLOR_MODE_OFF 4
62
63#define VTK_TEXTURECOORDS_UV 0
64#define VTK_TEXTURECOORDS_TEXTUREUV 1
65
66class VTKIOPLY_EXPORT vtkPLYWriter : public vtkWriter
67{
68public:
69 static vtkPLYWriter* New();
70 vtkTypeMacro(vtkPLYWriter, vtkWriter);
71 void PrintSelf(ostream& os, vtkIndent indent) override;
72
74
78 vtkSetClampMacro(DataByteOrder, int, VTK_LITTLE_ENDIAN, VTK_BIG_ENDIAN);
79 vtkGetMacro(DataByteOrder, int);
80 void SetDataByteOrderToBigEndian() { this->SetDataByteOrder(VTK_BIG_ENDIAN); }
81 void SetDataByteOrderToLittleEndian() { this->SetDataByteOrder(VTK_LITTLE_ENDIAN); }
83
85
93 vtkSetMacro(WriteToOutputString, bool);
94 vtkGetMacro(WriteToOutputString, bool);
95 vtkBooleanMacro(WriteToOutputString, bool);
96 const std::string& GetOutputString() const { return this->OutputString; }
98
100
104 vtkSetMacro(WriteObjectInformation, bool);
105 vtkGetMacro(WriteObjectInformation, bool);
106 vtkBooleanMacro(WriteObjectInformation, bool);
108
110
127 vtkSetMacro(ColorMode, int);
128 vtkGetMacro(ColorMode, int);
129 void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
132 void SetColorModeToUniformColor() // both cells and points are colored
133 {
134 this->SetColorMode(VTK_COLOR_MODE_UNIFORM_COLOR);
135 }
136 void SetColorModeToOff() // No color information is written
137 {
138 this->SetColorMode(VTK_COLOR_MODE_OFF);
139 }
141
143
147 vtkSetMacro(EnableAlpha, bool);
148 vtkGetMacro(EnableAlpha, bool);
149 vtkBooleanMacro(EnableAlpha, bool);
151
153
156 vtkSetStringMacro(ArrayName);
157 vtkGetStringMacro(ArrayName);
159
161
164 vtkSetClampMacro(Component, int, 0, VTK_INT_MAX);
165 vtkGetMacro(Component, int);
167
169
174 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
176
178
184 vtkSetVector3Macro(Color, unsigned char);
185 vtkGetVector3Macro(Color, unsigned char);
187
189
192 vtkSetMacro(Alpha, unsigned char);
193 vtkGetMacro(Alpha, unsigned char);
195
197
203
205
211
213
216 vtkSetClampMacro(FileType, int, VTK_ASCII, VTK_BINARY);
217 vtkGetMacro(FileType, int);
218 void SetFileTypeToASCII() { this->SetFileType(VTK_ASCII); }
219 void SetFileTypeToBinary() { this->SetFileType(VTK_BINARY); }
221
223
227 vtkSetClampMacro(TextureCoordinatesName, int, VTK_TEXTURECOORDS_UV, VTK_TEXTURECOORDS_TEXTUREUV);
228 vtkGetMacro(TextureCoordinatesName, int);
229 void SetTextureCoordinatesNameToUV() { this->SetTextureCoordinatesName(VTK_TEXTURECOORDS_UV); }
231 {
232 this->SetTextureCoordinatesName(VTK_TEXTURECOORDS_TEXTUREUV);
233 }
235
239 void AddComment(const std::string& comment);
240
241protected:
243 ~vtkPLYWriter() override;
244
245 void WriteData() override;
249
255 unsigned char Color[3];
256
258 unsigned char Alpha;
259
260 char* FileName;
261
264
266
267 // Whether this object is writing to a string or a file.
268 // Default is 0: write to file.
270
272
273 // The output string.
274 std::string OutputString;
275
276 int FillInputPortInformation(int port, vtkInformation* info) override;
277
278private:
279 vtkPLYWriter(const vtkPLYWriter&) = delete;
280 void operator=(const vtkPLYWriter&) = delete;
281};
282
283VTK_ABI_NAMESPACE_END
284#endif
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition vtkIndent.h:38
Store vtkAlgorithm input/output information.
write Stanford PLY file format
void SetDataByteOrderToLittleEndian()
If the file type is binary, then the user can specify which byte order to use (little versus big endi...
vtkSetFilePathMacro(FileName)
Specify file name of vtk polygon data file to write.
void SetColorModeToUniformCellColor()
These methods enable the user to control how to add color into the PLY output file.
void SetFileTypeToASCII()
Specify file type (ASCII or BINARY) for vtk data file.
void SetColorModeToUniformColor()
These methods enable the user to control how to add color into the PLY output file.
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.
void SetDataByteOrderToBigEndian()
If the file type is binary, then the user can specify which byte order to use (little versus big endi...
const std::string & GetOutputString() const
Enable writing to an OutputString instead of the default, a file.
vtkGetFilePathMacro(FileName)
Specify file name of vtk polygon data file to write.
vtkPolyData * GetInput(int port)
Get the input to this writer.
void AddComment(const std::string &comment)
Add a comment in the header part.
const float * GetTextureCoordinates(vtkIdType num, vtkDataSetAttributes *dsa)
vtkPolyData * GetInput()
Get the input to this writer.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkScalarsToColors * LookupTable
unsigned char Alpha
std::string OutputString
~vtkPLYWriter() override
void SetTextureCoordinatesNameToUV()
Choose the name used for the texture coordinates.
void SetColorModeToDefault()
These methods enable the user to control how to add color into the PLY output file.
void SetColorModeToUniformPointColor()
These methods enable the user to control how to add color into the PLY output file.
const float * GetNormals(vtkIdType num, vtkDataSetAttributes *dsa)
bool WriteToOutputString
void WriteData() override
int TextureCoordinatesName
static vtkPLYWriter * New()
virtual void SetLookupTable(vtkScalarsToColors *)
A lookup table can be specified in order to convert data arrays to RGBA colors.
bool WriteObjectInformation
void SetTextureCoordinatesNameToTextureUV()
Choose the name used for the texture coordinates.
vtkSmartPointer< vtkStringArray > HeaderComments
void SetColorModeToOff()
These methods enable the user to control how to add color into the PLY output file.
vtkSmartPointer< vtkUnsignedCharArray > GetColors(vtkIdType num, vtkDataSetAttributes *dsa)
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:89
Superclass for mapping scalar values to colors.
Hold a reference to a vtkObjectBase instance.
a vtkAbstractArray subclass for strings
dynamic, self-adjusting array of unsigned char
abstract class to write data to file(s)
Definition vtkWriter.h:32
#define VTK_LITTLE_ENDIAN
#define VTK_COLOR_MODE_OFF
#define VTK_COLOR_MODE_UNIFORM_POINT_COLOR
#define VTK_TEXTURECOORDS_UV
#define VTK_COLOR_MODE_UNIFORM_COLOR
#define VTK_BIG_ENDIAN
#define VTK_COLOR_MODE_UNIFORM_CELL_COLOR
#define VTK_TEXTURECOORDS_TEXTUREUV
#define VTK_COLOR_MODE_DEFAULT
int vtkIdType
Definition vtkType.h:315
#define VTK_INT_MAX
Definition vtkType.h:144
#define VTK_BINARY
Definition vtkWriter.h:29
#define VTK_ASCII
Definition vtkWriter.h:28