Select Git revision
vtkOFFReader.cxx
vtkOFFReader.cxx 5.41 KiB
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkOFFReader.cxx,v $
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.
=========================================================================*/
#include "vtkOFFReader.h"
#include "vtkCellArray.h"
#include "vtkFloatArray.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkTriangle.h"
#include <sstream>
#include <fstream>
vtkStandardNewMacro(vtkOFFReader);
// Description:
// Instantiate object with NULL filename.
vtkOFFReader::vtkOFFReader()
{
this->FileName = NULL;
this->SetNumberOfInputPorts(0);
}
vtkOFFReader::~vtkOFFReader()
{
if (this->FileName)
{
delete[] this->FileName;
this->FileName = NULL;
}
}
/*--------------------------------------------------------
This is only partial support for the OFF format, which is
quite complicated. To find a full specification,
search the net for "OFF format", eg.:
http://people.sc.fsu.edu/~burkardt/data/off/off.html
We support only vertices and faces composed of 3 vertices.
---------------------------------------------------------*/
// a replacement for isspace()
int is_whitespace(char c)
{
if (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\v' || c == '\f')
return 1;
else
return 0;
}
int vtkOFFReader::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the ouptut