vtkX3DExporter.h 3.87 KB
Newer Older
Christian Charles's avatar
Christian Charles committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkX3DExporter.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
15
// .NAME vtkX3DExporter - create an x3d file
16
// .SECTION Description
17 18 19 20 21 22
// vtkX3DExporter is a render window exporter which writes out the renderered
// scene into an X3D file. X3D is an XML-based format for representation 
// 3D scenes (similar to VRML). Check out http://www.web3d.org/x3d/ for more
// details.
// .SECTION Thanks
// X3DExporter is contributed by Christophe Mouton at EDF.
23

Christian Charles's avatar
Christian Charles committed
24 25 26
#ifndef __vtkX3DExporter_h
#define __vtkX3DExporter_h

27
#include "vtkIOExportModule.h" // For export macro
Christian Charles's avatar
Christian Charles committed
28 29
#include "vtkExporter.h"

30
class vtkLight;
Christian Charles's avatar
Christian Charles committed
31 32
class vtkActor;
class vtkActor2D;
33
class vtkPoints;
34
class vtkDataArray;
Christian Charles's avatar
Christian Charles committed
35
class vtkUnsignedCharArray;
36
class vtkX3DExporterWriter;
37
class vtkRenderer;
Christian Charles's avatar
Christian Charles committed
38

39
class VTKIOEXPORT_EXPORT vtkX3DExporter : public vtkExporter
Christian Charles's avatar
Christian Charles committed
40 41 42
{
public:
  static vtkX3DExporter *New();
43
  vtkTypeMacro(vtkX3DExporter,vtkExporter);
Christian Charles's avatar
Christian Charles committed
44 45 46 47 48 49 50 51 52 53 54
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Set/Get the output file name.
  vtkSetStringMacro(FileName);
  vtkGetStringMacro(FileName);

  // Description:
  // Specify the Speed of navigation. Default is 4.
  vtkSetMacro(Speed,double);
  vtkGetMacro(Speed,double);
55 56 57 58 59 60 61

  // Description:
  // Turn on binary mode
  vtkSetClampMacro(Binary, int, 0, 1);
  vtkBooleanMacro(Binary, int);
  vtkGetMacro(Binary, int);

62 63 64 65 66 67
  // Description:
  // In binary mode use fastest instead of best compression
  vtkSetClampMacro(Fastest, int, 0, 1);
  vtkBooleanMacro(Fastest, int);
  vtkGetMacro(Fastest, int);

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
  // Description:
  // Enable writing to an OutputString instead of the default, a file.
  vtkSetMacro(WriteToOutputString,int);
  vtkGetMacro(WriteToOutputString,int);
  vtkBooleanMacro(WriteToOutputString,int);

  // Description:
  // When WriteToOutputString in on, then a string is allocated, written to,
  // and can be retrieved with these methods.  The string is deleted during
  // the next call to write ...
  vtkGetMacro(OutputStringLength, int);
  vtkGetStringMacro(OutputString);
  unsigned char *GetBinaryOutputString()
    {
      return reinterpret_cast<unsigned char *>(this->OutputString);
    }

  // Description:
  // This convenience method returns the string, sets the IVAR to NULL,
  // so that the user is responsible for deleting the string.
  // I am not sure what the name should be, so it may change in the future.
  char *RegisterAndGetOutputString();

Christian Charles's avatar
Christian Charles committed
91 92
protected:
  vtkX3DExporter();
93 94
  ~vtkX3DExporter();

95 96 97 98 99
  // Stream management
  int WriteToOutputString;
  char *OutputString;
  int OutputStringLength;

100
  // Description:
Christian Charles's avatar
Christian Charles committed
101 102 103
  // Write data to output.
  void WriteData();

104 105 106
  void WriteALight(vtkLight *aLight, vtkX3DExporterWriter* writer);
  void WriteAnActor(vtkActor *anActor, vtkX3DExporterWriter* writer,
    int index);
107 108 109 110
  void WritePointData(vtkPoints *points, vtkDataArray *normals,
    vtkDataArray *tcoords, vtkUnsignedCharArray *colors,
    vtkX3DExporterWriter* writer, int index);
  void WriteATextActor2D(vtkActor2D *anTextActor2D,
111
    vtkX3DExporterWriter* writer);
112 113 114
  void WriteATexture(vtkActor *anActor, vtkX3DExporterWriter* writer);
  void WriteAnAppearance(vtkActor *anActor, bool writeEmissiveColor, vtkX3DExporterWriter* writer);
  int HasHeadLight(vtkRenderer* ren);
Christian Charles's avatar
Christian Charles committed
115 116
  char *FileName;
  double Speed;
117
  int Binary;
118
  int Fastest;
119

120
private:
121

122 123
  vtkX3DExporter(const vtkX3DExporter&); // Not implemented.
  void operator=(const vtkX3DExporter&); // Not implemented.
Christian Charles's avatar
Christian Charles committed
124 125 126 127
};


#endif