An update will be applied December 9th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit e0f018c1 authored by Cory Quammen's avatar Cory Quammen
Browse files

Added vtkPolyLineSource

Change-Id: I2793cb7382f43fd2fb4a1f15df9f45399f41bd93
parent e75ecd9a
......@@ -19,6 +19,7 @@ set(Module_SRCS
vtkPlaneSource.cxx
vtkPlatonicSolidSource.cxx
vtkPointSource.cxx
vtkPolyLineSource.cxx
vtkProgrammableDataObjectSource.cxx
vtkProgrammableSource.cxx
vtkRectangularButtonSource.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPolyLineSource.cxx
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 "vtkPolyLineSource.h"
#include "vtkCellArray.h"
#include "vtkIdList.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkSmartPointer.h"
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkPolyLineSource);
//----------------------------------------------------------------------------
vtkPolyLineSource::vtkPolyLineSource()
{
this->Points = vtkPoints::New();
this->Closed = 0;
this->SetNumberOfInputPorts(0);
}
//----------------------------------------------------------------------------
vtkPolyLineSource::~vtkPolyLineSource()
{
this->Points->Delete();
}
//----------------------------------------------------------------------------
void vtkPolyLineSource::SetNumberOfPoints(vtkIdType numPoints)
{
if (numPoints != this->GetNumberOfPoints())
{
this->Points->SetNumberOfPoints(numPoints);
this->Modified();
}
}
//----------------------------------------------------------------------------
vtkIdType vtkPolyLineSource::GetNumberOfPoints()
{
return this->Points->GetNumberOfPoints();
}
//----------------------------------------------------------------------------
void vtkPolyLineSource::SetPoint(vtkIdType id, double x, double y, double z)
{
if (id >= this->Points->GetNumberOfPoints())
{
vtkErrorMacro(<< "point id " << id << " is larger than the number of points");
return;
}
this->Points->SetPoint(id, x, y, z);
this->Modified();
}
//----------------------------------------------------------------------------
int vtkPolyLineSource::RequestData(
vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the ouptut
vtkPolyData *output = vtkPolyData::SafeDownCast(
outInfo->Get(vtkDataObject::DATA_OBJECT()));
vtkIdType numPoints = this->GetNumberOfPoints();
vtkSmartPointer<vtkIdList> pointIds = vtkSmartPointer<vtkIdList>::New();
pointIds->SetNumberOfIds(this->Closed ? numPoints + 1 : numPoints);
for (vtkIdType i = 0; i < numPoints; ++i)
{
pointIds->SetId(i, i);
}
if (this->Closed)
{
pointIds->SetId(numPoints, 0);
}
vtkSmartPointer<vtkCellArray> polyLine = vtkSmartPointer<vtkCellArray>::New();
polyLine->InsertNextCell(pointIds.GetPointer());
output->SetPoints(this->Points);
output->SetLines(polyLine);
return 1;
}
//----------------------------------------------------------------------------
void vtkPolyLineSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Points: " << this->Points << "\n";
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPolyLineSource.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.
=========================================================================*/
// .NAME vtkPolyLineSource - create a poly line from a list of input points
// .SECTION Description
// vtkPolyLineSource is a source object that creates a poly line from
// user-specified points. The output is a vtkPolyLine.
#ifndef vtkPolyLineSource_h
#define vtkPolyLineSource_h
#include "vtkFiltersSourcesModule.h" // For export macro
#include "vtkPolyDataAlgorithm.h"
class vtkPoints;
class VTKFILTERSSOURCES_EXPORT vtkPolyLineSource : public vtkPolyDataAlgorithm
{
public:
static vtkPolyLineSource* New();
vtkTypeMacro(vtkPolyLineSource, vtkPolyDataAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set the number of points in the poly line.
void SetNumberOfPoints(vtkIdType numPoints);
vtkIdType GetNumberOfPoints();
// Description:
// Set a point location.
void SetPoint(vtkIdType id, double x, double y, double z);
// Description:
// Get the points.
void SetPoints(vtkPoints* points);
vtkGetObjectMacro(Points, vtkPoints);
// Description:
// Set whether to close the poly line by connecting the last and first points.
vtkSetMacro(Closed, int);
vtkGetMacro(Closed, int);
protected:
vtkPolyLineSource();
~vtkPolyLineSource();
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector *);
vtkPoints* Points;
int Closed;
private:
vtkPolyLineSource(const vtkPolyLineSource&); // Not implemented.
void operator=(const vtkPolyLineSource&); // 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