
/**************************************************************************
THIS IS A MODIFIED VERSION OF THE original vtkVRMLExporter class.
This version is implemented using C++ streams rather than that C FILE pointer
and should be more 'script-friendly'. For instance, when serving VRML files
over the web with one of the scripted languages, you don't have to write out a 
temporary file and then read it back in with some kind of file writer and then write
it back to the web server output stream. (What a mess!)

Now you can simply call vtkVRMLExporterY::SetWriteTargetToString to switch the 
output stream to an internal stream buffer and you can get the VRML from the VRMLString
property. No more file mess!

vtkVRMLExporterY export
export SetInput someInput
export SetWriteTargetToString
export Write
set output [export GetVRMLString]


-Maik
***************************************************************************/
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: vtkVRMLExporterY.h,v $

  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.

=========================================================================*/
// .NAME vtkVRMLExporterY - export a scene into VRML 2.0 format.
// .SECTION Description
// vtkVRMLExporterY is a concrete subclass of vtkExporter that writes VRML 2.0
// files. This is based on the VRML 2.0 draft #3 but it should be pretty
// stable since we aren't using any of the newer features.
//
// .SECTION See Also
// vtkExporter


#ifndef __vtkVRMLExporterY_h
#define __vtkVRMLExporterY_h

#include "vtkExporter.h"

class vtkLight;
class vtkActor;
class vtkPoints;
class vtkDataArray;
class vtkUnsignedCharArray;

class VTK_RENDERING_EXPORT vtkVRMLExporterY : public vtkExporter
{
public:
  static vtkVRMLExporterY *New();
  vtkTypeRevisionMacro(vtkVRMLExporterY,vtkExporter);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Specify the name of the VRML file to write.
  vtkSetStringMacro(FileName);
  vtkGetStringMacro(FileName);

  // Description:
  // Specify the Speed of navigation. Default is 4.
  vtkSetMacro(Speed,double);
  vtkGetMacro(Speed,double);

  // Description:
  // Set the file pointer to write to. This will override
  // a FileName if specified.
  void SetStreamPointer(ostream *fp);
  
	void SetWriteTargetToFile() {
		this->WriteMode = 0;
	}

	void SetWriteTargetToString() {
		this->WriteMode = 1;
	}

	void SetWriteTargetToStream() {
		this->WriteMode = 2;
	}

	//const char *GetVRMLString();
	vtkGetStringMacro(VRMLString);
	
protected:
  vtkVRMLExporterY();
  ~vtkVRMLExporterY();

  void WriteData();
  void WriteALight(vtkLight *aLight, ostream& fp);
  void WriteAnActor(vtkActor *anActor, ostream& fp);
  void WritePointData(vtkPoints *points, vtkDataArray *normals, 
                      vtkDataArray *tcoords, vtkUnsignedCharArray *colors, 
                      ostream& fp);
  char *FileName;
	int WriteMode;
	//BTX
	ostream* StreamPointer;
	vtkstd::ostringstream* StringPointer;
	//ETX
  double Speed;

	vtkSetStringMacro(VRMLString);
	

	char *VRMLString;
private:
  vtkVRMLExporterY(const vtkVRMLExporterY&);  // Not implemented.
  void operator=(const vtkVRMLExporterY&);  // Not implemented.
	void WriteDataInternal(ostream& fp);
};

#endif

