Commit ac75d7a7 authored by David Gobbi's avatar David Gobbi

ENH: Add file IO classes for BIC-MNI file formats.

parent 9015f9bd
......@@ -53,6 +53,10 @@ vtkLandmarkTransform.cxx
vtkLegendBoxActor.cxx
vtkLegendScaleActor.cxx
vtkLSDynaReader.cxx
vtkMNIObjectReader.cxx
vtkMNIObjectWriter.cxx
vtkMNITransformReader.cxx
vtkMNITransformWriter.cxx
vtkPCAAnalysisFilter.cxx
vtkPieChartActor.cxx
vtkPolyDataSilhouette.cxx
......
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMNIObjectReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*=========================================================================
Copyright (c) 2006 Atamai, Inc.
Use, modification and redistribution of the software, in source or
binary forms, are permitted provided that the following terms and
conditions are met:
1) Redistribution of the source code, in verbatim or modified
form, must retain the above copyright notice, this license,
the following disclaimer, and any notices that refer to this
license and/or the following disclaimer.
2) Redistribution in binary form must include the above copyright
notice, a copy of this license and the following disclaimer
in the documentation or with other materials provided with the
distribution.
3) Modified copies of the source code must be clearly marked as such,
and must not be misrepresented as verbatim copies of the source code.
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
=========================================================================*/
// .NAME vtkMNIObjectReader - A reader for MNI surface mesh files.
// .SECTION Description
// The MNI .obj file format is used to store geometrical data. This
// file format was developed at the McConnell Brain Imaging Centre at
// the Montreal Neurological Institute and is used by their software.
// .SECTION See Also
// vtkMINCImageReader vtkMNIObjectWriter vtkMNITransformReader
// .SECTION Thanks
// Thanks to David Gobbi for writing this class and Atamai Inc. for
// contributing it to VTK.
#ifndef __vtkMNIObjectReader_h
#define __vtkMNIObjectReader_h
#include "vtkPolyDataAlgorithm.h"
class vtkProperty;
class vtkPolyData;
class vtkFloatArray;
class vtkIntArray;
class vtkPoints;
class vtkCellArray;
class VTK_HYBRID_EXPORT vtkMNIObjectReader : public vtkPolyDataAlgorithm
{
public:
vtkTypeMacro(vtkMNIObjectReader,vtkPolyDataAlgorithm);
static vtkMNIObjectReader *New();
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set the file name.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Get the entension for this file format.
virtual const char* GetFileExtensions() {
return ".obj"; }
// Description:
// Get the name of this file format.
virtual const char* GetDescriptiveName() {
return "MNI object"; }
// Description:
// Test whether the specified file can be read.
virtual int CanReadFile(const char* name);
// Description:
// Get the property associated with the object.
virtual vtkProperty *GetProperty() { return this->Property; };
protected:
vtkMNIObjectReader();
~vtkMNIObjectReader();
char *FileName;
vtkProperty *Property;
int FileType;
istream *InputStream;
int LineNumber;
char *LineText;
char *CharPointer;
int ReadLine(char *text, unsigned int length);
int SkipWhitespace();
int ParseValues(vtkDataArray *array, vtkIdType n);
int ParseIdValue(vtkIdType *value);
int IsPolygonReversed(vtkIntArray *polyIndices, vtkPoints *points,
vtkDataArray *normals,
vtkIdType lastEndIndex, vtkIdType numIndices);
int ReadNumberOfPoints(vtkIdType *numCells);
int ReadNumberOfCells(vtkIdType *numCells);
int ReadProperty(vtkProperty *property);
int ReadLineThickness(vtkProperty *property);
int ReadPoints(vtkPolyData *polyData, vtkIdType numPoints);
int ReadNormals(vtkPolyData *polyData, vtkIdType numPoints);
int ReadColors(vtkProperty *property, vtkPolyData *data,
vtkIdType numPoints, vtkIdType numCells);
int ReadCells(vtkPolyData *data, vtkIdType numCells, int cellType);
int ReadPolygonObject(vtkPolyData *output);
int ReadLineObject(vtkPolyData *output);
virtual int ReadFile(vtkPolyData *output);
virtual int RequestData(vtkInformation* request,
vtkInformationVector** inInfo,
vtkInformationVector* outInfo);
private:
vtkMNIObjectReader(const vtkMNIObjectReader&); // Not implemented
void operator=(const vtkMNIObjectReader&); // Not implemented
};
#endif
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMNIObjectWriter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*=========================================================================
Copyright (c) 2006 Atamai, Inc.
Use, modification and redistribution of the software, in source or
binary forms, are permitted provided that the following terms and
conditions are met:
1) Redistribution of the source code, in verbatim or modified
form, must retain the above copyright notice, this license,
the following disclaimer, and any notices that refer to this
license and/or the following disclaimer.
2) Redistribution in binary form must include the above copyright
notice, a copy of this license and the following disclaimer
in the documentation or with other materials provided with the
distribution.
3) Modified copies of the source code must be clearly marked as such,
and must not be misrepresented as verbatim copies of the source code.
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
=========================================================================*/
// .NAME vtkMNIObjectWriter - A writer for MNI surface mesh files.
// .SECTION Description
// The MNI .obj file format is used to store geometrical data. This
// file format was developed at the McConnell Brain Imaging Centre at
// the Montreal Neurological Institute and is used by their software.
// .SECTION See Also
// vtkMINCImageReader vtkMNIObjectReader vtkMNITransformReader
// .SECTION Thanks
// Thanks to David Gobbi for writing this class and Atamai Inc. for
// contributing it to VTK.
#ifndef __vtkMNIObjectWriter_h
#define __vtkMNIObjectWriter_h
#include "vtkPolyDataWriter.h"
class vtkProperty;
class vtkLookupTable;
class vtkPolyData;
class vtkFloatArray;
class vtkIntArray;
class vtkPoints;
class VTK_HYBRID_EXPORT vtkMNIObjectWriter : public vtkPolyDataWriter
{
public:
vtkTypeMacro(vtkMNIObjectWriter,vtkPolyDataWriter);
static vtkMNIObjectWriter *New();
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Get the entension for this file format.
virtual const char* GetFileExtensions() {
return ".obj"; }
// Description:
// Get the name of this file format.
virtual const char* GetDescriptiveName() {
return "MNI object"; }
// Description:
// Set the property associated with the object.
virtual void SetProperty(vtkProperty *property);
virtual vtkProperty *GetProperty() { return this->Property; };
// Description:
// Set the lookup table associated with the object. This will be
// used to convert scalar values to colors, if present.
virtual void SetLookupTable(vtkLookupTable *table);
virtual vtkLookupTable *GetLookupTable() { return this->LookupTable; };
protected:
vtkMNIObjectWriter();
~vtkMNIObjectWriter();
vtkProperty *Property;
vtkLookupTable *LookupTable;
ostream *OutputStream;
int WriteObjectType(int objType);
int WriteValues(vtkDataArray *array);
int WriteIdValue(vtkIdType value);
int WriteNewline();
int WriteProperty(vtkProperty *property);
int WriteLineThickness(vtkProperty *property);
int WritePoints(vtkPolyData *polyData);
int WriteNormals(vtkPolyData *polyData);
int WriteColors(vtkProperty *property, vtkPolyData *data);
int WriteCells(vtkPolyData *data, int cellType);
int WritePolygonObject(vtkPolyData *output);
int WriteLineObject(vtkPolyData *output);
void WriteData();
private:
vtkMNIObjectWriter(const vtkMNIObjectWriter&); // Not implemented
void operator=(const vtkMNIObjectWriter&); // Not implemented
};
#endif
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMNITransformReader.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*=========================================================================
Copyright (c) 2006 Atamai, Inc.
Use, modification and redistribution of the software, in source or
binary forms, are permitted provided that the following terms and
conditions are met:
1) Redistribution of the source code, in verbatim or modified
form, must retain the above copyright notice, this license,
the following disclaimer, and any notices that refer to this
license and/or the following disclaimer.
2) Redistribution in binary form must include the above copyright
notice, a copy of this license and the following disclaimer
in the documentation or with other materials provided with the
distribution.
3) Modified copies of the source code must be clearly marked as such,
and must not be misrepresented as verbatim copies of the source code.
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
=========================================================================*/
// .NAME vtkMNITransformReader - A reader for MNI transformation files.
// .SECTION Description
// The MNI .xfm file format is used to store geometrical
// transformations. Three kinds of transformations are supported by
// the file format: affine, thin-plate spline, and grid transformations.
// This file format was developed at the McConnell Brain Imaging Centre
// at the Montreal Neurological Institute and is used by their software.
// .SECTION See Also
// vtkMINCImageReader vtkMNITransformWriter
// .SECTION Thanks
// Thanks to David Gobbi for writing this class and Atamai Inc. for
// contributing it to VTK.
#ifndef __vtkMNITransformReader_h
#define __vtkMNITransformReader_h
#include "vtkAlgorithm.h"
class vtkAbstractTransform;
class vtkDoubleArray;
class vtkCollection;
class VTK_HYBRID_EXPORT vtkMNITransformReader : public vtkAlgorithm
{
public:
vtkTypeMacro(vtkMNITransformReader,vtkAlgorithm);
static vtkMNITransformReader *New();
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set the file name.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Get the entension for this file format.
virtual const char* GetFileExtensions() {
return ".xfm"; }
// Description:
// Get the name of this file format.
virtual const char* GetDescriptiveName() {
return "MNI Transform"; }
// Description:
// Test whether the specified file can be read.
virtual int CanReadFile(const char* name);
// Description:
// Get the number of transforms in the file.
virtual int GetNumberOfTransforms();
// Description:
// Get one of the transforms listed in the file.
virtual vtkAbstractTransform *GetNthTransform(int i);
// Description:
// Get the transform that results from concatenating all
// of the transforms in the file. This will return null
// if you have not specified a file name.
virtual vtkAbstractTransform *GetTransform();
// Description:
// Get any comments that are included in the file.
virtual const char *GetComments();
protected:
vtkMNITransformReader();
~vtkMNITransformReader();
char *FileName;
vtkAbstractTransform *Transform;
vtkCollection *Transforms;
int LineNumber;
char *Comments;
void SetTransform(vtkAbstractTransform *transform);
int ReadLine(istream &infile, char result[256]);
int ReadLineAfterComments(istream &infile, char result[256]);
int SkipWhitespace(istream &infile, char linetext[256], char **cpp);
int ParseLeftHandSide(istream &infile, char linetext[256], char **cpp,
char identifier[256]);
int ParseStringValue(istream &infile, char linetext[256], char **cpp,
char data[256]);
int ParseFloatValues(istream &infile, char linetext[256], char **cpp,
vtkDoubleArray *array);
int ParseInvertFlagValue(istream &infile, char linetext[256], char **cpp,
int *invertFlag);
int ReadLinearTransform(istream &infile, char linetext[256], char **cp);
int ReadThinPlateSplineTransform(istream &infile, char linetext[256],
char **cp);
int ReadGridTransform(istream &infile, char linetext[256], char **cp);
virtual int ReadNextTransform(istream &infile, char linetext[256]);
virtual int ReadFile();
virtual int ProcessRequest(vtkInformation* request,
vtkInformationVector** inInfo,
vtkInformationVector* outInfo);
private:
vtkMNITransformReader(const vtkMNITransformReader&); // Not implemented
void operator=(const vtkMNITransformReader&); // Not implemented
};
#endif
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMNITransformWriter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*=========================================================================
Copyright (c) 2006 Atamai, Inc.
Use, modification and redistribution of the software, in source or
binary forms, are permitted provided that the following terms and
conditions are met:
1) Redistribution of the source code, in verbatim or modified
form, must retain the above copyright notice, this license,
the following disclaimer, and any notices that refer to this
license and/or the following disclaimer.
2) Redistribution in binary form must include the above copyright
notice, a copy of this license and the following disclaimer
in the documentation or with other materials provided with the
distribution.
3) Modified copies of the source code must be clearly marked as such,
and must not be misrepresented as verbatim copies of the source code.
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
=========================================================================*/
// .NAME vtkMNITransformWriter - A writer for MNI transformation files.
// .SECTION Description
// The MNI .xfm file format is used to store geometrical
// transformations. Three kinds of transformations are supported by
// the file format: affine, thin-plate spline, and grid transformations.
// This file format was developed at the McConnell Brain Imaging Centre
// at the Montreal Neurological Institute and is used by their software.
// .SECTION See Also
// vtkMINCImageWriter vtkMNITransformReader
// .SECTION Thanks
// Thanks to David Gobbi for writing this class and Atamai Inc. for
// contributing it to VTK.
#ifndef __vtkMNITransformWriter_h
#define __vtkMNITransformWriter_h
#include "vtkAlgorithm.h"
class vtkAbstractTransform;
class vtkHomogeneousTransform;
class vtkThinPlateSplineTransform;
class vtkGridTransform;
class vtkCollection;
class VTK_HYBRID_EXPORT vtkMNITransformWriter : public vtkAlgorithm
{
public:
vtkTypeMacro(vtkMNITransformWriter,vtkAlgorithm);
static vtkMNITransformWriter *New();
virtual void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set the file name.
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Get the entension for this file format.
virtual const char* GetFileExtensions() {
return ".xfm"; }
// Description:
// Get the name of this file format.
virtual const char* GetDescriptiveName() {
return "MNI Transform"; }
// Description:
// Set the transform.
virtual void SetTransform(vtkAbstractTransform *transform);
virtual vtkAbstractTransform *GetTransform() {
return this->Transform; };
// Description:
// Add another transform to the file. The next time that
// SetTransform is called, all added transforms will be
// removed.
virtual void AddTransform(vtkAbstractTransform *transform);
// Description:
// Get the number of transforms that will be written.
virtual int GetNumberOfTransforms();
// Description:
// Set comments to be added to the file.
vtkSetStringMacro(Comments);
vtkGetStringMacro(Comments);
// Description:
// Write the file.
virtual void Write();
protected:
vtkMNITransformWriter();
~vtkMNITransformWriter();
char *FileName;
vtkAbstractTransform *Transform;
vtkCollection *Transforms;
char *Comments;
int WriteLinearTransform(ostream &outfile,
vtkHomogeneousTransform *transform);
int WriteThinPlateSplineTransform(ostream &outfile,
vtkThinPlateSplineTransform *transform);
int WriteGridTransform(ostream &outfile,
vtkGridTransform *transform);
virtual int WriteTransform(ostream &outfile,
vtkAbstractTransform *transform);
virtual int WriteFile();
virtual int ProcessRequest(vtkInformation* request,
vtkInformationVector** inInfo,
vtkInformationVector* outInfo);
private:
vtkMNITransformWriter(const vtkMNITransformWriter&); // Not implemented
void operator=(const vtkMNITransformWriter&); // Not implemented
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment