OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / include / vtk / vtkVRMLImporter.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    $RCSfile: vtkVRMLImporter.h,v $
5   Language:  C++
6   Date:      $Date: 2002/08/08 13:29:58 $
7   Version:   $Revision: 1.17 $
8
9   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
10   All rights reserved.
11   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
12
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.
16
17 =========================================================================*/
18 // .NAME vtkVRMLImporter - imports VRML 2.0 files.
19 // .SECTION Description
20 //
21 // vtkVRMLImporter imports VRML 2.0 files into vtk.
22 // .SECTION Caveats
23 //
24 // These nodes are currently supported:
25 //      Appearance                              IndexedFaceSet
26 //      Box                                     IndexedLineSet
27 //      Color                                   Material
28 //      Cone                                    Shape
29 //      Coordinate                              Sphere
30 //      Cylinder                                Transform
31 //      DirectionalLight
32 //
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).
43 //
44 // .SECTION See Also
45 // vtkImporter
46
47 /* ======================================================================
48  
49    Importer based on BNF Yacc and Lex parser definition from:
50
51     **************************************************
52         * VRML 2.0 Parser
53         * Copyright (C) 1996 Silicon Graphics, Inc.
54         *
55         * Author(s) :    Gavin Bell
56         *                Daniel Woods (first port)
57         **************************************************
58
59   Ported to VTK By:     Thomas D. Citriniti
60                         Rensselaer Polytechnic Institute
61                         citrit@rpi.edu
62
63 =======================================================================*/
64
65 #ifndef __vtkVRMLImporter_h
66 #define __vtkVRMLImporter_h
67
68 // Includes for the yacc/lex parser
69 #include "vtkImporter.h"
70
71 class vtkActor;
72 class vtkProperty;
73 class vtkCamera;
74 class vtkLight;
75 class vtkTransform;
76 class vtkSource;
77 class vtkLookupTable;
78 class vtkFloatArray;
79 class vtkPolyDataMapper;
80 class vtkPoints;
81 class vtkIdTypeArray;
82 class vtkVRMLImporterInternal;
83
84 class VTK_HYBRID_EXPORT vtkVRMLImporter : public vtkImporter
85 {
86 public:
87   static vtkVRMLImporter *New();
88
89   vtkTypeRevisionMacro(vtkVRMLImporter,vtkImporter);
90   void PrintSelf(ostream& os, vtkIndent indent);
91
92   // Description:
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);
100
101   // Description:
102   // Needed by the yacc/lex grammar used
103   void enterNode(const char *);
104   void exitNode();
105   void enterField(const char *);
106   void exitField();
107   void useNode(const char *);
108
109   // Description:
110   // Specify the name of the file to read.
111   vtkSetStringMacro(FileName);
112   vtkGetStringMacro(FileName);
113
114   // Description:
115   // Return the file pointer to the open file.
116   FILE *GetFileFD() {return this->FileFD;};
117
118 //BTX
119
120   friend int yylex ( vtkVRMLImporter* );
121
122 //ETX
123
124 protected:
125   vtkVRMLImporter();
126   ~vtkVRMLImporter();
127
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 *) {};
134
135   int OpenImportFile();
136   char *FileName;
137   FILE *FileFD;
138
139 private:
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;
151
152   vtkPoints* PointsNew();
153   vtkIdTypeArray* IdTypeArrayNew();
154
155   void DeleteObject(vtkObject*);
156
157   vtkVRMLImporterInternal* Internal;
158
159 private:
160   vtkVRMLImporter(const vtkVRMLImporter&);  // Not implemented.
161   void operator=(const vtkVRMLImporter&);  // Not implemented.
162 };
163
164 #endif
165