1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkVRMLImporter.h,v $
6 Date: $Date: 2002/08/08 13:29:58 $
7 Version: $Revision: 1.17 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkVRMLImporter - imports VRML 2.0 files.
19 // .SECTION Description
21 // vtkVRMLImporter imports VRML 2.0 files into vtk.
24 // These nodes are currently supported:
25 // Appearance IndexedFaceSet
33 // As you can see this implementation focuses on getting the geometry
34 // translated. The routes and scripting nodes are ignored since they deal
35 // with directly accessing a nodes internal structure based on the VRML
36 // spec. Since this is a translation the internal data structures differ
37 // greatly from the VRML spec and the External Authoring Interface (see the
38 // VRML spec). The DEF/USE mechanism does allow the Vtk user to extract
39 // objects from the scene and directly manipulate them using the native
40 // language (Tcl, Python, Java, or whatever language Vtk is wrapped
41 // in). This, in a way, removes the need for the route and script mechanism
42 // (not completely though).
47 /* ======================================================================
49 Importer based on BNF Yacc and Lex parser definition from:
51 **************************************************
53 * Copyright (C) 1996 Silicon Graphics, Inc.
55 * Author(s) : Gavin Bell
56 * Daniel Woods (first port)
57 **************************************************
59 Ported to VTK By: Thomas D. Citriniti
60 Rensselaer Polytechnic Institute
63 =======================================================================*/
65 #ifndef __vtkVRMLImporter_h
66 #define __vtkVRMLImporter_h
68 // Includes for the yacc/lex parser
69 #include "vtkImporter.h"
79 class vtkPolyDataMapper;
82 class vtkVRMLImporterInternal;
84 class VTK_HYBRID_EXPORT vtkVRMLImporter : public vtkImporter
87 static vtkVRMLImporter *New();
89 vtkTypeRevisionMacro(vtkVRMLImporter,vtkImporter);
90 void PrintSelf(ostream& os, vtkIndent indent);
93 // In the VRML spec you can DEF and USE nodes (name them),
94 // This routine will return the associated VTK object which
95 // was created as a result of the DEF mechanism
96 // Send in the name from the VRML file, get the VTK object.
97 // You will have to check and correctly cast the object since
98 // this only returns vtkObjects.
99 vtkObject *GetVRMLDEFObject(const char *name);
102 // Needed by the yacc/lex grammar used
103 void enterNode(const char *);
105 void enterField(const char *);
107 void useNode(const char *);
110 // Specify the name of the file to read.
111 vtkSetStringMacro(FileName);
112 vtkGetStringMacro(FileName);
115 // Return the file pointer to the open file.
116 FILE *GetFileFD() {return this->FileFD;};
120 friend int yylex ( vtkVRMLImporter* );
128 virtual int ImportBegin ();
129 virtual void ImportEnd ();
130 virtual void ImportActors (vtkRenderer *) {};
131 virtual void ImportCameras (vtkRenderer *) {};
132 virtual void ImportLights (vtkRenderer *) {};
133 virtual void ImportProperties (vtkRenderer *) {};
135 int OpenImportFile();
140 vtkActor *CurrentActor;
141 vtkProperty *CurrentProperty;
142 vtkCamera *CurrentCamera;
143 vtkLight *CurrentLight;
144 vtkTransform *CurrentTransform;
145 vtkSource *CurrentSource;
146 vtkPoints *CurrentPoints;
147 vtkFloatArray *CurrentNormals;
148 vtkLookupTable *CurrentLut;
149 vtkFloatArray *CurrentScalars;
150 vtkPolyDataMapper *CurrentMapper;
152 vtkPoints* PointsNew();
153 vtkIdTypeArray* IdTypeArrayNew();
155 void DeleteObject(vtkObject*);
157 vtkVRMLImporterInternal* Internal;
160 vtkVRMLImporter(const vtkVRMLImporter&); // Not implemented.
161 void operator=(const vtkVRMLImporter&); // Not implemented.