1 /*=========================================================================
2 
3   Program: Visualization Toolkit
4   Module: vtkProStarReader.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 vtkProStarReader - Reads geometry in proSTAR (STARCD) file format.
16 // .SECTION Description
17 // vtkProStarReader creates an unstructured grid dataset.
18 // It reads .cel/.vrt files stored in proSTAR (STARCD) ASCII format.
19 //
20 // .SECTION Thanks
21 // Reader written by Mark Olesen
22 //
23 
24 #ifndef vtkProStarReader_h
25 #define vtkProStarReader_h
26 
27 #include "vtkIOGeometryModule.h" // For export macro
28 #include "vtkUnstructuredGridAlgorithm.h"
29 
30 class VTKIOGEOMETRY_EXPORT vtkProStarReader : public vtkUnstructuredGridAlgorithm
31 {
32 public:
33   static vtkProStarReader *New();
34   vtkTypeMacro(vtkProStarReader,vtkUnstructuredGridAlgorithm);
35   void PrintSelf(ostream& os, vtkIndent indent);
36 
37   // Description:
38   // Specify the file name prefix of the cel/vrt files to read.
39   // The reader will try to open FileName.cel and FileName.vrt files.
40   vtkSetStringMacro(FileName);
41   vtkGetStringMacro(FileName);
42 
43   // Description:
44   // The proSTAR files are often in millimeters.
45   // Specify an alternative scaling factor.
46   vtkSetClampMacro(ScaleFactor, double, 0, VTK_DOUBLE_MAX);
47   vtkGetMacro(ScaleFactor, double);
48 
49   // Description:
50   // The type of material represented by the cell
51   enum cellType
52   {
53     starcdFluidType = 1,
54     starcdSolidType = 2,
55     starcdBaffleType = 3,
56     starcdShellType = 4,
57     starcdLineType = 5,
58     starcdPointType = 6
59   };
60 
61   // Description:
62   // The primitive cell shape
63   enum shapeType
64   {
65     starcdPoint = 1,
66     starcdLine = 2,
67     starcdShell = 3,
68     starcdHex = 11,
69     starcdPrism = 12,
70     starcdTet = 13,
71     starcdPyr = 14,
72     starcdPoly = 255
73   };
74 
75 protected:
76   vtkProStarReader();
77   ~vtkProStarReader();
78 
79   int RequestInformation
80     (vtkInformation *, vtkInformationVector **, vtkInformationVector *);
81   int RequestData
82     (vtkInformation *, vtkInformationVector **, vtkInformationVector *);
83 
84   // Description:
85   // The name of the file to be read.  If it has a .cel, .vrt, or .inp
86   // extension it will be truncated and later appended when reading
87   // the appropriate files.  Otherwise those extensions will be appended
88   // to FileName when opening the files.
89   char *FileName;
90 
91   // Description:
92   // The coordinates are multiplied by ScaleFactor when setting them.
93   // The default value is 1.
94   double ScaleFactor;
95 
96 private:
97   //
98   // Internal Classes/Structures
99   //
100   struct idMapping;
101 
102   FILE* OpenFile(const char *ext);
103 
104   bool ReadVrtFile(vtkUnstructuredGrid *output, idMapping& pointMapping);
105   bool ReadCelFile(vtkUnstructuredGrid *output, const idMapping& pointMapping);
106 
107   vtkProStarReader(const vtkProStarReader&); // Not implemented.
108   void operator=(const vtkProStarReader&); // Not implemented.
109 };
110 #endif
111