VTK
dox/IO/MINC/vtkMNIObjectWriter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkMNIObjectWriter.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 __vtkMNIObjectWriter_h
00068 #define __vtkMNIObjectWriter_h
00069 
00070 #include "vtkIOMINCModule.h" // For export macro
00071 #include "vtkWriter.h"
00072 
00073 class vtkMapper;
00074 class vtkProperty;
00075 class vtkLookupTable;
00076 class vtkPolyData;
00077 class vtkFloatArray;
00078 class vtkIntArray;
00079 class vtkPoints;
00080 
00081 class VTKIOMINC_EXPORT vtkMNIObjectWriter : public vtkWriter
00082 {
00083 public:
00084   vtkTypeMacro(vtkMNIObjectWriter,vtkWriter);
00085 
00086   static vtkMNIObjectWriter *New();
00087   virtual void PrintSelf(ostream& os, vtkIndent indent);
00088 
00090 
00091   virtual const char* GetFileExtensions() {
00092     return ".obj"; }
00094 
00096 
00097   virtual const char* GetDescriptiveName() {
00098     return "MNI object"; }
00100 
00102 
00104   virtual void SetProperty(vtkProperty *property);
00105   virtual vtkProperty *GetProperty() { return this->Property; };
00107 
00109 
00112   virtual void SetMapper(vtkMapper *mapper);
00113   virtual vtkMapper *GetMapper() { return this->Mapper; };
00115 
00117 
00119   virtual void SetLookupTable(vtkLookupTable *table);
00120   virtual vtkLookupTable *GetLookupTable() { return this->LookupTable; };
00122 
00124 
00125   vtkPolyData* GetInput();
00126   vtkPolyData* GetInput(int port);
00128 
00130 
00131   vtkSetStringMacro(FileName);
00132   vtkGetStringMacro(FileName);
00134 
00136 
00137   vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
00138   vtkGetMacro(FileType,int);
00139   void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
00140   void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
00142 
00143 protected:
00144   vtkMNIObjectWriter();
00145   ~vtkMNIObjectWriter();
00146 
00147   vtkProperty *Property;
00148   vtkMapper *Mapper;
00149   vtkLookupTable *LookupTable;
00150 
00151   ostream *OutputStream;
00152 
00153   int WriteObjectType(int objType);
00154   int WriteValues(vtkDataArray *array);
00155   int WriteIdValue(vtkIdType value);
00156   int WriteNewline();
00157 
00158   int WriteProperty(vtkProperty *property);
00159   int WriteLineThickness(vtkProperty *property);
00160   int WritePoints(vtkPolyData *polyData);
00161   int WriteNormals(vtkPolyData *polyData);
00162   int WriteColors(vtkProperty *property, vtkMapper *mapper, vtkPolyData *data);
00163   int WriteCells(vtkPolyData *data, int cellType);
00164 
00165   int WritePolygonObject(vtkPolyData *output);
00166   int WriteLineObject(vtkPolyData *output);
00167 
00168   void WriteData();
00169 
00170   char* FileName;
00171 
00172   int FileType;
00173 
00174   virtual int FillInputPortInformation(int port, vtkInformation *info);
00175 
00176   ostream *OpenFile();
00177   void CloseFile(ostream *fp);
00178 
00179 private:
00180   vtkMNIObjectWriter(const vtkMNIObjectWriter&); // Not implemented
00181   void operator=(const vtkMNIObjectWriter&);  // Not implemented
00182 
00183 };
00184 
00185 #endif