VTK
dox/IO/MINC/vtkMNIObjectReader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMNIObjectReader.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00015 /*=========================================================================
00016 
00017 Copyright (c) 2006 Atamai, Inc.
00018 
00019 Use, modification and redistribution of the software, in source or
00020 binary forms, are permitted provided that the following terms and
00021 conditions are met:
00022 
00023 1) Redistribution of the source code, in verbatim or modified
00024    form, must retain the above copyright notice, this license,
00025    the following disclaimer, and any notices that refer to this
00026    license and/or the following disclaimer.
00027 
00028 2) Redistribution in binary form must include the above copyright
00029    notice, a copy of this license and the following disclaimer
00030    in the documentation or with other materials provided with the
00031    distribution.
00032 
00033 3) Modified copies of the source code must be clearly marked as such,
00034    and must not be misrepresented as verbatim copies of the source code.
00035 
00036 THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
00037 WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
00038 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00039 PURPOSE.  IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
00040 MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
00041 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
00042 (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
00043 OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
00044 THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
00045 POSSIBILITY OF SUCH DAMAGES.
00046 
00047 =========================================================================*/
00067 #ifndef __vtkMNIObjectReader_h
00068 #define __vtkMNIObjectReader_h
00069 
00070 #include "vtkIOMINCModule.h" // For export macro
00071 #include "vtkPolyDataAlgorithm.h"
00072 
00073 class vtkProperty;
00074 class vtkPolyData;
00075 class vtkFloatArray;
00076 class vtkIntArray;
00077 class vtkPoints;
00078 class vtkCellArray;
00079 
00080 class VTKIOMINC_EXPORT vtkMNIObjectReader : public vtkPolyDataAlgorithm
00081 {
00082 public:
00083   vtkTypeMacro(vtkMNIObjectReader,vtkPolyDataAlgorithm);
00084 
00085   static vtkMNIObjectReader *New();
00086   virtual void PrintSelf(ostream& os, vtkIndent indent);
00087 
00089 
00090   vtkSetStringMacro(FileName);
00091   vtkGetStringMacro(FileName);
00093 
00095 
00096   virtual const char* GetFileExtensions() {
00097     return ".obj"; }
00099 
00101 
00102   virtual const char* GetDescriptiveName() {
00103     return "MNI object"; }
00105 
00107   virtual int CanReadFile(const char* name);
00108 
00110   virtual vtkProperty *GetProperty() { return this->Property; };
00111 
00112 protected:
00113   vtkMNIObjectReader();
00114   ~vtkMNIObjectReader();
00115 
00116   char *FileName;
00117   vtkProperty *Property;
00118   int FileType;
00119 
00120   istream *InputStream;
00121   int LineNumber;
00122   char *LineText;
00123   char *CharPointer;
00124 
00125   int ReadLine(char *text, unsigned int length);
00126   int SkipWhitespace();
00127   int ParseValues(vtkDataArray *array, vtkIdType n);
00128   int ParseIdValue(vtkIdType *value);
00129 
00130   int ReadNumberOfPoints(vtkIdType *numCells);
00131   int ReadNumberOfCells(vtkIdType *numCells);
00132   int ReadProperty(vtkProperty *property);
00133   int ReadLineThickness(vtkProperty *property);
00134   int ReadPoints(vtkPolyData *polyData, vtkIdType numPoints);
00135   int ReadNormals(vtkPolyData *polyData, vtkIdType numPoints);
00136   int ReadColors(vtkProperty *property, vtkPolyData *data,
00137                  vtkIdType numPoints, vtkIdType numCells);
00138   int ReadCells(vtkPolyData *data, vtkIdType numCells, int cellType);
00139 
00140   int ReadPolygonObject(vtkPolyData *output);
00141   int ReadLineObject(vtkPolyData *output);
00142 
00143   virtual int ReadFile(vtkPolyData *output);
00144 
00145   virtual int RequestData(vtkInformation* request,
00146                           vtkInformationVector** inInfo,
00147                           vtkInformationVector* outInfo);
00148 
00149 private:
00150   vtkMNIObjectReader(const vtkMNIObjectReader&); // Not implemented
00151   void operator=(const vtkMNIObjectReader&);  // Not implemented
00152 
00153 };
00154 
00155 #endif