~ubuntu-branches/ubuntu/utopic/vtk6/utopic

« back to all changes in this revision

Viewing changes to Filters/ReebGraph/vtkUnstructuredGridToReebGraphFilter.cxx

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2014-01-07 21:26:32 UTC
  • Revision ID: package-import@ubuntu.com-20140107212632-vzwzmu3oyc3obmsg
Tags: upstream-6.0.0
ImportĀ upstreamĀ versionĀ 6.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*=========================================================================
 
2
 
 
3
  Program:   Visualization Toolkit
 
4
  Module:    $RCSfile$
 
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
#include "vtkUnstructuredGridToReebGraphFilter.h"
 
16
 
 
17
#include "vtkElevationFilter.h"
 
18
#include "vtkInformation.h"
 
19
#include "vtkInformationVector.h"
 
20
#include "vtkObjectFactory.h"
 
21
#include "vtkPointData.h"
 
22
#include "vtkReebGraph.h"
 
23
#include "vtkUnstructuredGrid.h"
 
24
 
 
25
vtkStandardNewMacro(vtkUnstructuredGridToReebGraphFilter);
 
26
 
 
27
//----------------------------------------------------------------------------
 
28
vtkUnstructuredGridToReebGraphFilter::vtkUnstructuredGridToReebGraphFilter()
 
29
{
 
30
  FieldId = 0;
 
31
  this->SetNumberOfInputPorts(1);
 
32
}
 
33
 
 
34
//----------------------------------------------------------------------------
 
35
vtkUnstructuredGridToReebGraphFilter::~vtkUnstructuredGridToReebGraphFilter()
 
36
{
 
37
}
 
38
 
 
39
//----------------------------------------------------------------------------
 
40
int vtkUnstructuredGridToReebGraphFilter::FillInputPortInformation( int vtkNotUsed(portNumber), vtkInformation *info)
 
41
{
 
42
  info->Remove(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE());
 
43
  info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkUnstructuredGrid");
 
44
  return 1;
 
45
}
 
46
 
 
47
//----------------------------------------------------------------------------
 
48
int vtkUnstructuredGridToReebGraphFilter::FillOutputPortInformation(
 
49
  int, vtkInformation *info)
 
50
{
 
51
  info->Set(vtkDirectedGraph::DATA_TYPE_NAME(), "vtkReebGraph");
 
52
  return 1;
 
53
}
 
54
 
 
55
//----------------------------------------------------------------------------
 
56
void vtkUnstructuredGridToReebGraphFilter::PrintSelf(ostream& os, vtkIndent indent)
 
57
{
 
58
  this->Superclass::PrintSelf(os,indent);
 
59
  os << indent << "Field Id: " << this->FieldId << "\n";
 
60
}
 
61
 
 
62
//----------------------------------------------------------------------------
 
63
vtkReebGraph* vtkUnstructuredGridToReebGraphFilter::GetOutput()
 
64
{
 
65
  return vtkReebGraph::SafeDownCast(this->GetOutputDataObject(0));
 
66
}
 
67
 
 
68
//----------------------------------------------------------------------------
 
69
int vtkUnstructuredGridToReebGraphFilter::RequestData(vtkInformation*,
 
70
                                    vtkInformationVector** inputVector,
 
71
                                    vtkInformationVector* outputVector)
 
72
{
 
73
 
 
74
  vtkInformation  *inInfo = inputVector[0]->GetInformationObject(0);
 
75
 
 
76
  vtkUnstructuredGrid *input = vtkUnstructuredGrid::SafeDownCast(
 
77
    inInfo->Get(vtkUnstructuredGrid::DATA_OBJECT()));
 
78
 
 
79
  vtkInformation  *outInfo = outputVector->GetInformationObject(0);
 
80
  vtkReebGraph    *output = vtkReebGraph::SafeDownCast(
 
81
    outInfo->Get(vtkReebGraph::DATA_OBJECT()));
 
82
 
 
83
  // check for the presence of a scalar field
 
84
  vtkDataArray    *scalarField = input->GetPointData()->GetArray(FieldId);
 
85
  if(!scalarField)
 
86
    {
 
87
    vtkElevationFilter* eFilter = vtkElevationFilter::New();
 
88
    eFilter->SetInputData(input);
 
89
    eFilter->Update();
 
90
    output->Build(vtkUnstructuredGrid::SafeDownCast(eFilter->GetOutput()),
 
91
                  "Elevation");
 
92
    eFilter->Delete();
 
93
    }
 
94
  else
 
95
    {
 
96
    output->Build(input, FieldId);
 
97
    }
 
98
 
 
99
  return 1;
 
100
}