VTK
vtkGeoJSONWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGeoJSONWriter.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef vtkGeoJSONWriter_h
27 #define vtkGeoJSONWriter_h
28 
29 #include "vtkIOGeoJSONModule.h" // For export macro
30 #include "vtkWriter.h"
31 
32 class vtkLookupTable;
33 
34 class VTKIOGEOJSON_EXPORT vtkGeoJSONWriter : public vtkWriter
35 {
36 public:
37  static vtkGeoJSONWriter* New();
38  virtual void PrintSelf( ostream& os, vtkIndent indent ) override;
39  vtkTypeMacro(vtkGeoJSONWriter,vtkWriter);
40 
42 
45  vtkSetStringMacro(FileName);
46  vtkGetStringMacro(FileName);
48 
50 
53  vtkSetMacro(WriteToOutputString,bool);
54  vtkGetMacro(WriteToOutputString,bool);
55  vtkBooleanMacro(WriteToOutputString,bool);
57 
59 
64  vtkGetMacro(OutputStringLength, int);
65  vtkGetStringMacro(OutputString);
66  unsigned char *GetBinaryOutputString()
67  {
68  return reinterpret_cast<unsigned char *>(this->OutputString);
69  }
71 
73 
79  vtkSetMacro(ScalarFormat,int);
80  vtkGetMacro(ScalarFormat,int);
82 
84 
87  void SetLookupTable(vtkLookupTable *lut);
88  vtkGetObjectMacro(LookupTable, vtkLookupTable);
90 
95  vtkStdString GetOutputStdString();
96 
102  char *RegisterAndGetOutputString();
103 
104 protected:
106  virtual ~vtkGeoJSONWriter();
107 
108  // Only accepts vtkPolyData
109  virtual int FillInputPortInformation(int port, vtkInformation *info) override;
110 
111  // Implementation of Write()
112  void WriteData() override;
113 
114  // Helper for Write that writes attributes out
115  void WriteScalar(vtkDataArray *da, vtkIdType ptId);
117 
121 
123 
124  // Internal helpers
125  ostream *OpenFile();
126  void ConditionalComma(vtkIdType, vtkIdType);
127  void CloseFile(ostream *);
128  class Internals;
129  Internals *WriterHelper;
130  char* FileName;
131 
132 private:
133  vtkGeoJSONWriter(const vtkGeoJSONWriter&) = delete;
134  void operator=(const vtkGeoJSONWriter&) = delete;
135 };
136 
137 #endif // vtkGeoJSONWriter_h
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:40
Store vtkAlgorithm input/output information.
map scalar values into colors via a lookup table
int vtkIdType
Definition: vtkType.h:347
abstract class to write data to file(s)
Definition: vtkWriter.h:42
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:39
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
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...