VTK  9.3.1
vtkX3DExporterXMLWriter.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
10 #ifndef vtkX3DExporterXMLWriter_h
11 #define vtkX3DExporterXMLWriter_h
12 
13 #include "vtkIOExportModule.h" // For export macro
14 #include "vtkX3DExporterWriter.h"
15 #include <string> // for std::string
16 
17 VTK_ABI_NAMESPACE_BEGIN
18 class vtkX3DExporterXMLNodeInfoStack;
19 
20 class VTKIOEXPORT_EXPORT vtkX3DExporterXMLWriter : public vtkX3DExporterWriter
21 {
22 
23 public:
24  static vtkX3DExporterXMLWriter* New();
26  void PrintSelf(ostream& os, vtkIndent indent) override;
27 
28  void CloseFile() override;
29  int OpenFile(const char* file) override;
30  void Flush() override;
31 
32  int OpenStream() override;
33 
34  void StartDocument() override;
35  void EndDocument() override;
36 
37  // Elements
38  void StartNode(int elementID) override;
39  void EndNode() override;
40 
41  // Attributes
42  // SFString / MFString
43  void SetField(int attributeID, const char*, bool mfstring = true) override;
44  // SFInt32
45  void SetField(int attributeID, int) override;
46  // SFFloat
47  void SetField(int attributeID, float) override;
48  // SFDouble
49  void SetField(int attributeID, double) override;
50  // SFBool
51  void SetField(int attributeID, bool) override;
52 
53  // For MFxxx attributes
54  void SetField(int attributeID, int type, const double* a) override;
55  void SetField(int attributeID, int type, vtkDataArray* a) override;
56  void SetField(int attributeID, const double* values, size_t size) override;
57  // MFInt32, SFIMAGE
58  void SetField(int attributeID, const int* values, size_t size, bool image = false) override;
59 
60 protected:
62  ~vtkX3DExporterXMLWriter() override;
63 
64 private:
65  const char* GetNewline() { return "\n"; }
66  void AddDepth();
67  void SubDepth();
68 
69  std::string ActTab;
70  int Depth;
71  ostream* OutputStream;
72  vtkX3DExporterXMLNodeInfoStack* InfoStack;
73 
75  void operator=(const vtkX3DExporterXMLWriter&) = delete;
76 };
77 
78 VTK_ABI_NAMESPACE_END
79 #endif
X3D Exporter Writer.
virtual void StartNode(int nodeID)=0
Starts/ends a new X3D node specified via nodeID.
virtual void EndNode()=0
Starts/ends a new X3D node specified via nodeID.
virtual void CloseFile()=0
virtual int OpenStream()=0
Init data support to be a stream instead of a file.
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
virtual void SetField(int attributeID, const char *value, bool mfstring=false)=0
Sets the field specified with attributeID of the active node to the given value.
X3D Exporter XML Writer.
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
virtual void StartDocument()=0
Starts a document and sets all necessary information, i.e.
virtual void EndDocument()=0
Ends a document and sets all necessary information or necessary bytes to finish the encoding correctl...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
virtual int OpenFile(const char *file)=0
Opens the file specified with file returns 1 if successful otherwise 0.