1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkPointSetToPointSetFilter.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 "vtkPointSetToPointSetFilter.h"
#include "vtkPolyData.h"
#include "vtkStructuredGrid.h"
#include "vtkUnstructuredGrid.h"
vtkCxxRevisionMacro(vtkPointSetToPointSetFilter, "$Revision: 1.61 $");
//----------------------------------------------------------------------------
// Construct object.
vtkPointSetToPointSetFilter::vtkPointSetToPointSetFilter()
{
this->NumberOfRequiredInputs = 1;
this->SetNumberOfInputPorts(1);
}
//----------------------------------------------------------------------------
vtkPointSetToPointSetFilter::~vtkPointSetToPointSetFilter()
{
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
void vtkPointSetToPointSetFilter::SetInput(vtkPointSet *input)
{
vtkPointSet *oldInput = this->GetInput();
if (oldInput != NULL)
{
if (input == NULL ||
oldInput->GetDataObjectType() != input->GetDataObjectType())
{
vtkWarningMacro("Changing input type. Deleting output");
this->SetOutput(NULL);
}
}
if (input != NULL && this->vtkSource::GetOutput(0) == NULL)
{
this->vtkSource::SetNthOutput(0, input->NewInstance());
this->Outputs[0]->ReleaseData();
this->Outputs[0]->Delete();
}
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkPointSet *vtkPointSetToPointSetFilter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkPointSet *)(this->Inputs[0]);
}
//----------------------------------------------------------------------------
// Get the output of this filter. If output is NULL then input hasn't been set
// which is necessary for abstract objects.
vtkPointSet *vtkPointSetToPointSetFilter::GetOutput()
{
if (this->GetInput() == NULL )
{
vtkErrorMacro(<<"Abstract filters require input to be set before output can be retrieved");
return NULL;
}
return this->vtkPointSetSource::GetOutput();
}
//----------------------------------------------------------------------------
// Get the output as vtkPolyData.
vtkPolyData *vtkPointSetToPointSetFilter::GetPolyDataOutput()
{
vtkDataSet *ds = this->GetOutput();
if (!ds)
{
return NULL;
}
if (ds->GetDataObjectType() == VTK_POLY_DATA)
{
return (vtkPolyData *)ds;
}
return NULL;
}
//----------------------------------------------------------------------------
// Get the output as vtkStructuredGrid. Performs run-time checking.
vtkStructuredGrid *vtkPointSetToPointSetFilter::GetStructuredGridOutput()
{
vtkDataSet *ds = this->GetOutput();
if (!ds)
{
return NULL;
}
if (ds->GetDataObjectType() == VTK_STRUCTURED_GRID)
{
return (vtkStructuredGrid *)ds;
}
return NULL;
}
//----------------------------------------------------------------------------
// Get the output as vtkUnstructuredGrid. Performs run-time checking.
vtkUnstructuredGrid *vtkPointSetToPointSetFilter::GetUnstructuredGridOutput()
{
vtkDataSet *ds = this->GetOutput();
if (!ds)
{
return NULL;
}
if (ds->GetDataObjectType() == VTK_UNSTRUCTURED_GRID)
{
return (vtkUnstructuredGrid *)ds;
}
return NULL;
}
//----------------------------------------------------------------------------
// Copy the update information across
void vtkPointSetToPointSetFilter::ComputeInputUpdateExtents(vtkDataObject *output)
{
vtkDataObject *input = this->GetInput();
input->SetUpdatePiece( output->GetUpdatePiece() );
input->SetUpdateNumberOfPieces( output->GetUpdateNumberOfPieces() );
input->SetUpdateGhostLevel( output->GetUpdateGhostLevel() );
input->SetUpdateExtent( output->GetUpdateExtent() );
input->RequestExactExtentOn();
}
//----------------------------------------------------------------------------
void vtkPointSetToPointSetFilter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
}
|