1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkBYUReader.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 // .NAME vtkBYUReader - read MOVIE.BYU polygon files
16 // .SECTION Description
17 // vtkBYUReader is a source object that reads MOVIE.BYU polygon files.
18 // These files consist of a geometry file (.g), a scalar file (.s), a
19 // displacement or vector file (.d), and a 2D texture coordinate file
20 // (.t).
21 
22 #ifndef vtkBYUReader_h
23 #define vtkBYUReader_h
24 
25 #include "vtkIOGeometryModule.h" // For export macro
26 #include "vtkPolyDataAlgorithm.h"
27 
28 class VTKIOGEOMETRY_EXPORT vtkBYUReader : public vtkPolyDataAlgorithm
29 {
30 public:
31   static vtkBYUReader *New();
32 
33   vtkTypeMacro(vtkBYUReader,vtkPolyDataAlgorithm);
34   void PrintSelf(ostream& os, vtkIndent indent);
35 
36   // Description:
37   // Specify name of geometry FileName.
38   vtkSetStringMacro(GeometryFileName);
39   vtkGetStringMacro(GeometryFileName);
40 
41   // Description:
42   // Specify name of geometry FileName (alias).
SetFileName(const char * f)43   virtual void SetFileName(const char* f) { this->SetGeometryFileName(f); }
GetFileName()44   virtual char* GetFileName() { return this->GetGeometryFileName(); }
45 
46   // Description:
47   // Specify name of displacement FileName.
48   vtkSetStringMacro(DisplacementFileName);
49   vtkGetStringMacro(DisplacementFileName);
50 
51   // Description:
52   // Specify name of scalar FileName.
53   vtkSetStringMacro(ScalarFileName);
54   vtkGetStringMacro(ScalarFileName);
55 
56   // Description:
57   // Specify name of texture coordinates FileName.
58   vtkSetStringMacro(TextureFileName);
59   vtkGetStringMacro(TextureFileName);
60 
61   // Description:
62   // Turn on/off the reading of the displacement file.
63   vtkSetMacro(ReadDisplacement,int);
64   vtkGetMacro(ReadDisplacement,int);
65   vtkBooleanMacro(ReadDisplacement,int);
66 
67   // Description:
68   // Turn on/off the reading of the scalar file.
69   vtkSetMacro(ReadScalar,int);
70   vtkGetMacro(ReadScalar,int);
71   vtkBooleanMacro(ReadScalar,int);
72 
73   // Description:
74   // Turn on/off the reading of the texture coordinate file.
75   // Specify name of geometry FileName.
76   vtkSetMacro(ReadTexture,int);
77   vtkGetMacro(ReadTexture,int);
78   vtkBooleanMacro(ReadTexture,int);
79 
80   // Description:
81   // Set/Get the part number to be read.
82   vtkSetClampMacro(PartNumber,int,1,VTK_INT_MAX);
83   vtkGetMacro(PartNumber,int);
84 
85   // Description:
86   // Returns 1 if this file can be read and 0 if the file cannot be read.
87   // Because BYU files do not have anything in the header specifying the file
88   // type, the result is not definitive.  Invalid files may still return 1
89   // although a valid file will never return 0.
90   static int CanReadFile(const char *filename);
91 
92 protected:
93   vtkBYUReader();
94   ~vtkBYUReader();
95 
96   int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
97   // This source does not know how to generate pieces yet.
98   int ComputeDivisionExtents(vtkDataObject *output,
99                              int idx, int numDivisions);
100 
101   char *GeometryFileName;
102   char *DisplacementFileName;
103   char *ScalarFileName;
104   char *TextureFileName;
105   int ReadDisplacement;
106   int ReadScalar;
107   int ReadTexture;
108   int PartNumber;
109 
110   void ReadGeometryFile(FILE *fp, int &numPts, vtkInformation *outInfo);
111   void ReadDisplacementFile(int numPts, vtkInformation *outInfo);
112   void ReadScalarFile(int numPts, vtkInformation *outInfo);
113   void ReadTextureFile(int numPts, vtkInformation *outInfo);
114 private:
115   vtkBYUReader(const vtkBYUReader&);  // Not implemented.
116   void operator=(const vtkBYUReader&);  // Not implemented.
117 };
118 
119 #endif
120