VTK
vtkMNIObjectWriter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMNIObjectWriter.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 /*=========================================================================
16 
17 Copyright (c) 2006 Atamai, Inc.
18 
19 Use, modification and redistribution of the software, in source or
20 binary forms, are permitted provided that the following terms and
21 conditions are met:
22 
23 1) Redistribution of the source code, in verbatim or modified
24  form, must retain the above copyright notice, this license,
25  the following disclaimer, and any notices that refer to this
26  license and/or the following disclaimer.
27 
28 2) Redistribution in binary form must include the above copyright
29  notice, a copy of this license and the following disclaimer
30  in the documentation or with other materials provided with the
31  distribution.
32 
33 3) Modified copies of the source code must be clearly marked as such,
34  and must not be misrepresented as verbatim copies of the source code.
35 
36 THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
37 WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
38 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
40 MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
41 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
42 (INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
43 OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
44 THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
45 POSSIBILITY OF SUCH DAMAGES.
46 
47 =========================================================================*/
65 #ifndef vtkMNIObjectWriter_h
66 #define vtkMNIObjectWriter_h
67 
68 #include "vtkIOMINCModule.h" // For export macro
69 #include "vtkWriter.h"
70 
71 class vtkMapper;
72 class vtkProperty;
73 class vtkLookupTable;
74 class vtkPolyData;
75 class vtkFloatArray;
76 class vtkIntArray;
77 class vtkPoints;
78 
79 class VTKIOMINC_EXPORT vtkMNIObjectWriter : public vtkWriter
80 {
81 public:
83 
84  static vtkMNIObjectWriter *New();
85  void PrintSelf(ostream& os, vtkIndent indent) override;
86 
90  virtual const char* GetFileExtensions() {
91  return ".obj"; }
92 
96  virtual const char* GetDescriptiveName() {
97  return "MNI object"; }
98 
100 
104  virtual void SetProperty(vtkProperty *property);
105  virtual vtkProperty *GetProperty() { return this->Property; };
107 
109 
114  virtual void SetMapper(vtkMapper *mapper);
115  virtual vtkMapper *GetMapper() { return this->Mapper; };
117 
119 
123  virtual void SetLookupTable(vtkLookupTable *table);
124  virtual vtkLookupTable *GetLookupTable() { return this->LookupTable; };
126 
128 
132  vtkPolyData* GetInput(int port);
134 
136 
139  vtkSetStringMacro(FileName);
140  vtkGetStringMacro(FileName);
142 
144 
147  vtkSetClampMacro(FileType,int,VTK_ASCII,VTK_BINARY);
148  vtkGetMacro(FileType,int);
149  void SetFileTypeToASCII() {this->SetFileType(VTK_ASCII);};
150  void SetFileTypeToBinary() {this->SetFileType(VTK_BINARY);};
152 
153 protected:
155  ~vtkMNIObjectWriter() override;
156 
160 
161  ostream *OutputStream;
162 
163  int WriteObjectType(int objType);
164  int WriteValues(vtkDataArray *array);
165  int WriteIdValue(vtkIdType value);
166  int WriteNewline();
167 
168  int WriteProperty(vtkProperty *property);
169  int WriteLineThickness(vtkProperty *property);
170  int WritePoints(vtkPolyData *polyData);
171  int WriteNormals(vtkPolyData *polyData);
172  int WriteColors(vtkProperty *property, vtkMapper *mapper, vtkPolyData *data);
173  int WriteCells(vtkPolyData *data, int cellType);
174 
175  int WritePolygonObject(vtkPolyData *output);
176  int WriteLineObject(vtkPolyData *output);
177 
178  void WriteData() override;
179 
180  char* FileName;
181 
182  int FileType;
183 
184  int FillInputPortInformation(int port, vtkInformation *info) override;
185 
186  ostream *OpenFile();
187  void CloseFile(ostream *fp);
188 
189 private:
190  vtkMNIObjectWriter(const vtkMNIObjectWriter&) = delete;
191  void operator=(const vtkMNIObjectWriter&) = delete;
192 
193 };
194 
195 #endif
Store vtkAlgorithm input/output information.
represent surface properties of a geometric object
Definition: vtkProperty.h:60
virtual vtkLookupTable * GetLookupTable()
Set the lookup table associated with the object.
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:35
map scalar values into colors via a lookup table
virtual const char * GetFileExtensions()
Get the entension for this file format.
int vtkIdType
Definition: vtkType.h:347
virtual vtkProperty * GetProperty()
Set the property associated with the object.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
#define VTK_ASCII
Definition: vtkWriter.h:39
virtual const char * GetDescriptiveName()
Get the name of this file format.
A writer for MNI surface mesh files.
abstract class to write data to file(s)
Definition: vtkWriter.h:42
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
dynamic, self-adjusting array of int
Definition: vtkIntArray.h:39
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkDataObject * GetInput()
vtkLookupTable * LookupTable
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
#define VTK_BINARY
Definition: vtkWriter.h:40
virtual int FillInputPortInformation(int port, vtkInformation *info)
Fill the input port information objects for this algorithm.
abstract class specifies interface to map data to graphics primitives
Definition: vtkMapper.h:80
void SetFileTypeToBinary()
Specify file type (ASCII or BINARY) for vtk data file.
virtual vtkMapper * GetMapper()
Set the mapper associated with the object.
static vtkAlgorithm * New()
virtual void WriteData()=0
void SetFileTypeToASCII()
Specify file type (ASCII or BINARY) for vtk data file.
represent and manipulate 3D points
Definition: vtkPoints.h:33