vtkPVProbeLineFilter.cxx 4.17 KB
Newer Older
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
/*=========================================================================

  Program:   ParaView
  Module:    vtkPVProbeLineFilter.cxx

  Copyright (c) Kitware, Inc.
  All rights reserved.
  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html 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 "vtkPVProbeLineFilter.h"

#include "vtkDemandDrivenPipeline.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkLineSource.h"
#include "vtkObjectFactory.h"
#include "vtkProbeLineFilter.h"

vtkStandardNewMacro(vtkPVProbeLineFilter);

//----------------------------------------------------------------------------
vtkPVProbeLineFilter::vtkPVProbeLineFilter()
{
  this->LineSource->SetResolution(1);
  this->Prober->SetAggregateAsPolyData(true);
  this->Prober->SetSourceConnection(this->LineSource->GetOutputPort());
}

//----------------------------------------------------------------------------
int vtkPVProbeLineFilter::RequestData(
  vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
  // Check inputs / ouputs
  vtkInformation* inputInfo = inputVector[0]->GetInformationObject(0);
  vtkInformation* outInfo = outputVector->GetInformationObject(0);
  if (!outInfo || !inputInfo)
  {
    vtkErrorMacro("Missing input or output information");
    return 0;
  }

  vtkDataObject* input = inputInfo->Get(vtkDataObject::DATA_OBJECT());
  vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT()));
  if (!output || !input)
  {
    vtkErrorMacro("Missing input or output object");
    return 0;
  }

  this->LineSource->SetPoint1(this->Point1);
  this->LineSource->SetPoint2(this->Point2);
  this->Prober->SetLineResolution(this->LineResolution);
  this->Prober->SetPassCellArrays(this->PassCellArrays);
  this->Prober->SetPassPointArrays(this->PassPointArrays);
  this->Prober->SetPassFieldArrays(this->PassFieldArrays);
  this->Prober->SetPassPartialArrays(this->PassPartialArrays);
  this->Prober->SetTolerance(this->Tolerance);
  this->Prober->SetComputeTolerance(this->ComputeTolerance);
  this->Prober->SetSamplingPattern(this->SamplingPattern);

  this->Prober->SetInputData(input);
  this->Prober->Update();
  output->ShallowCopy(this->Prober->GetOutputDataObject(0));

  return 1;
}

//----------------------------------------------------------------------------
int vtkPVProbeLineFilter::FillInputPortInformation(int port, vtkInformation* info)
{
  switch (port)
  {
    case 0:
      info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
      info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkCompositeDataSet");
82
      info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkHyperTreeGrid");
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
      return 1;

    default:
      return 0;
  }
}

//----------------------------------------------------------------------------
void vtkPVProbeLineFilter::PrintSelf(ostream& os, vtkIndent indent)
{
  switch (this->SamplingPattern)
  {
    case vtkProbeLineFilter::SAMPLE_LINE_AT_CELL_BOUNDARIES:
      os << indent << "SamplingPattern: SAMPLE_LINE_AT_CELL_BOUNDARIES" << endl;
      break;
    case vtkProbeLineFilter::SAMPLE_LINE_AT_SEGMENT_CENTERS:
      os << indent << "SamplingPattern: SAMPLE_LINE_AT_SEGMENT_CENTERS" << endl;
      break;
    case vtkProbeLineFilter::SAMPLE_LINE_UNIFORMLY:
      os << indent << "SamplingPattern: SAMPLE_LINE_UNIFORMLY" << endl;
      break;
    default:
      os << indent << "SamplingPattern: UNDEFINED" << endl;
      break;
  }
  os << indent << "LineResolution: " << this->LineResolution << endl;
  os << indent << "PassPartialArrays: " << this->PassPartialArrays << endl;
  os << indent << "PassCellArrays: " << this->PassCellArrays << endl;
  os << indent << "PassPointArrays: " << this->PassPointArrays << endl;
  os << indent << "PassFieldArrays: " << this->PassFieldArrays << endl;
  os << indent << "ComputeTolerance: " << this->ComputeTolerance << endl;
  os << indent << "Tolerance: " << this->Tolerance << endl;
}