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
29 #ifndef vtkPLYWriter_h
30 #define vtkPLYWriter_h
31 
32 #include "vtkIOPLYModule.h" // For export macro
33 #include "vtkSmartPointer.h" // For protected ivars
34 #include "vtkWriter.h"
35 
36 #include <string> // For string parameter
37 
38 VTK_ABI_NAMESPACE_BEGIN
40 class vtkPolyData;
41 class vtkScalarsToColors;
42 class vtkStringArray;
44 
45 #define VTK_LITTLE_ENDIAN 0
46 #define VTK_BIG_ENDIAN 1
47 
48 #define VTK_COLOR_MODE_DEFAULT 0
49 #define VTK_COLOR_MODE_UNIFORM_CELL_COLOR 1
50 #define VTK_COLOR_MODE_UNIFORM_POINT_COLOR 2
51 #define VTK_COLOR_MODE_UNIFORM_COLOR 3
52 #define VTK_COLOR_MODE_OFF 4
53 
54 #define VTK_TEXTURECOORDS_UV 0
55 #define VTK_TEXTURECOORDS_TEXTUREUV 1
56 
57 class VTKIOPLY_EXPORT vtkPLYWriter : public vtkWriter
58 {
59 public:
60  static vtkPLYWriter* New();
61  vtkTypeMacro(vtkPLYWriter, vtkWriter);
62  void PrintSelf(ostream& os, vtkIndent indent) override;
63 
65 
69  vtkSetClampMacro(DataByteOrder, int, VTK_LITTLE_ENDIAN, VTK_BIG_ENDIAN);
70  vtkGetMacro(DataByteOrder, int);
71  void SetDataByteOrderToBigEndian() { this->SetDataByteOrder(VTK_BIG_ENDIAN); }
72  void SetDataByteOrderToLittleEndian() { this->SetDataByteOrder(VTK_LITTLE_ENDIAN); }
74 
76 
84  vtkSetMacro(WriteToOutputString, bool);
85  vtkGetMacro(WriteToOutputString, bool);
86  vtkBooleanMacro(WriteToOutputString, bool);
87  const std::string& GetOutputString() const { return this->OutputString; }
89 
91 
95  vtkSetMacro(WriteObjectInformation, bool);
96  vtkGetMacro(WriteObjectInformation, bool);
97  vtkBooleanMacro(WriteObjectInformation, bool);
99 
101 
118  vtkSetMacro(ColorMode, int);
119  vtkGetMacro(ColorMode, int);
120  void SetColorModeToDefault() { this->SetColorMode(VTK_COLOR_MODE_DEFAULT); }
123  void SetColorModeToUniformColor() // both cells and points are colored
124  {
125  this->SetColorMode(VTK_COLOR_MODE_UNIFORM_COLOR);
126  }
127  void SetColorModeToOff() // No color information is written
128  {
129  this->SetColorMode(VTK_COLOR_MODE_OFF);
130  }
132 
134 
138  vtkSetMacro(EnableAlpha, bool);
139  vtkGetMacro(EnableAlpha, bool);
140  vtkBooleanMacro(EnableAlpha, bool);
142 
144 
147  vtkSetStringMacro(ArrayName);
148  vtkGetStringMacro(ArrayName);
150 
152 
155  vtkSetClampMacro(Component, int, 0, VTK_INT_MAX);
156  vtkGetMacro(Component, int);
158 
160 
165  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
167 
169 
175  vtkSetVector3Macro(Color, unsigned char);
176  vtkGetVector3Macro(Color, unsigned char);
178 
180 
183  vtkSetMacro(Alpha, unsigned char);
184  vtkGetMacro(Alpha, unsigned char);
186 
188 
194 
196 
202 
204 
207  vtkSetClampMacro(FileType, int, VTK_ASCII, VTK_BINARY);
208  vtkGetMacro(FileType, int);
209  void SetFileTypeToASCII() { this->SetFileType(VTK_ASCII); }
210  void SetFileTypeToBinary() { this->SetFileType(VTK_BINARY); }
212 
214 
218  vtkSetClampMacro(TextureCoordinatesName, int, VTK_TEXTURECOORDS_UV, VTK_TEXTURECOORDS_TEXTUREUV);
219  vtkGetMacro(TextureCoordinatesName, int);
220  void SetTextureCoordinatesNameToUV() { this->SetTextureCoordinatesName(VTK_TEXTURECOORDS_UV); }
222  {
223  this->SetTextureCoordinatesName(VTK_TEXTURECOORDS_TEXTUREUV);
224  }
226 
230  void AddComment(const std::string& comment);
231 
232 protected:
234  ~vtkPLYWriter() override;
235 
236  void WriteData() override;
239  const float* GetNormals(vtkIdType num, vtkDataSetAttributes* dsa);
240 
242  char* ArrayName;
246  unsigned char Color[3];
247 
249  unsigned char Alpha;
250 
251  char* FileName;
252 
253  int FileType;
255 
257 
258  // Whether this object is writing to a string or a file.
259  // Default is 0: write to file.
261 
263 
264  // The output string.
266 
268 
269 private:
270  vtkPLYWriter(const vtkPLYWriter&) = delete;
271  void operator=(const vtkPLYWriter&) = delete;
272 };
273 
274 VTK_ABI_NAMESPACE_END
275 #endif
represent and manipulate attribute data in a dataset
a simple class to control print indentation
Definition: vtkIndent.h:29
Store vtkAlgorithm input/output information.
write Stanford PLY file format
Definition: vtkPLYWriter.h:58
char * FileName
Definition: vtkPLYWriter.h:251
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:72
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:87
void SetColorModeToUniformCellColor()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:121
void SetFileTypeToASCII()
Specify file type (ASCII or BINARY) for vtk data file.
Definition: vtkPLYWriter.h:209
void SetColorModeToUniformColor()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:123
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:210
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:71
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:242
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkScalarsToColors * LookupTable
Definition: vtkPLYWriter.h:245
unsigned char Alpha
Definition: vtkPLYWriter.h:249
std::string OutputString
Definition: vtkPLYWriter.h:265
vtkSmartPointer< vtkUnsignedCharArray > GetColors(vtkIdType num, vtkDataSetAttributes *dsa)
~vtkPLYWriter() override
void SetTextureCoordinatesNameToUV()
Choose the name used for the texture coordinates.
Definition: vtkPLYWriter.h:220
void SetColorModeToDefault()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:120
void SetColorModeToUniformPointColor()
These methods enable the user to control how to add color into the PLY output file.
Definition: vtkPLYWriter.h:122
static vtkPLYWriter * New()
bool WriteToOutputString
Definition: vtkPLYWriter.h:260
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:254
virtual void SetLookupTable(vtkScalarsToColors *)
A lookup table can be specified in order to convert data arrays to RGBA colors.
bool WriteObjectInformation
Definition: vtkPLYWriter.h:262
void SetTextureCoordinatesNameToTextureUV()
Choose the name used for the texture coordinates.
Definition: vtkPLYWriter.h:221
vtkSmartPointer< vtkStringArray > HeaderComments
Definition: vtkPLYWriter.h:256
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:127
const float * GetTextureCoordinates(vtkIdType num, vtkDataSetAttributes *dsa)
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:80
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:45
#define VTK_COLOR_MODE_DEFAULT
Definition: vtkPLYWriter.h:48
#define VTK_COLOR_MODE_OFF
Definition: vtkPLYWriter.h:52
#define VTK_COLOR_MODE_UNIFORM_POINT_COLOR
Definition: vtkPLYWriter.h:50
#define VTK_TEXTURECOORDS_UV
Definition: vtkPLYWriter.h:54
#define VTK_COLOR_MODE_UNIFORM_COLOR
Definition: vtkPLYWriter.h:51
#define VTK_BIG_ENDIAN
Definition: vtkPLYWriter.h:46
#define VTK_COLOR_MODE_UNIFORM_CELL_COLOR
Definition: vtkPLYWriter.h:49
#define VTK_TEXTURECOORDS_TEXTUREUV
Definition: vtkPLYWriter.h:55
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