VTK  9.3.1
vtkGeoJSONWriter.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
14 #ifndef vtkGeoJSONWriter_h
15 #define vtkGeoJSONWriter_h
16 
17 #include "vtkIOGeoJSONModule.h" // For export macro
18 #include "vtkWriter.h"
19 
20 VTK_ABI_NAMESPACE_BEGIN
21 class vtkLookupTable;
22 
23 class VTKIOGEOJSON_EXPORT vtkGeoJSONWriter : public vtkWriter
24 {
25 public:
26  static vtkGeoJSONWriter* New();
27  void PrintSelf(ostream& os, vtkIndent indent) override;
28  vtkTypeMacro(vtkGeoJSONWriter, vtkWriter);
29 
31 
34  vtkSetFilePathMacro(FileName);
35  vtkGetFilePathMacro(FileName);
37 
39 
42  vtkSetMacro(WriteToOutputString, bool);
43  vtkGetMacro(WriteToOutputString, bool);
44  vtkBooleanMacro(WriteToOutputString, bool);
46 
48 
53  vtkGetMacro(OutputStringLength, int);
54  vtkGetStringMacro(OutputString);
55  unsigned char* GetBinaryOutputString()
56  {
57  return reinterpret_cast<unsigned char*>(this->OutputString);
58  }
60 
62 
68  vtkSetMacro(ScalarFormat, int);
69  vtkGetMacro(ScalarFormat, int);
71 
73 
76  void SetLookupTable(vtkLookupTable* lut);
77  vtkGetObjectMacro(LookupTable, vtkLookupTable);
79 
84  vtkStdString GetOutputStdString();
85 
91  char* RegisterAndGetOutputString();
92 
93 protected:
95  ~vtkGeoJSONWriter() override;
96 
97  // Only accepts vtkPolyData
99 
100  // Implementation of Write()
101  void WriteData() override;
102 
103  // Helper for Write that writes attributes out
104  void WriteScalar(vtkDataArray* da, vtkIdType ptId);
106 
110 
112 
113  // Internal helpers
114  ostream* OpenFile();
115  void ConditionalComma(vtkIdType, vtkIdType);
116  void CloseFile(ostream*);
117  class Internals;
118  Internals* WriterHelper;
119  char* FileName;
120 
121 private:
122  vtkGeoJSONWriter(const vtkGeoJSONWriter&) = delete;
123  void operator=(const vtkGeoJSONWriter&) = delete;
124 };
125 
126 VTK_ABI_NAMESPACE_END
127 #endif // vtkGeoJSONWriter_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:28
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
int vtkIdType
Definition: vtkType.h:315
abstract class to write data to file(s)
Definition: vtkWriter.h:34
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
Internals * WriterHelper
static vtkAlgorithm * New()
virtual void WriteData()=0
Convert vtkPolyData to Geo JSON format.
vtkLookupTable * LookupTable
unsigned char * GetBinaryOutputString()
When WriteToOutputString in on, then a string is allocated, written to, and can be retrieved with the...