File: TestPolyDataPointSampler.cxx

package info (click to toggle)
vtk9 9.5.2%2Bdfsg3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 205,984 kB
  • sloc: cpp: 2,336,570; ansic: 327,116; python: 111,200; yacc: 4,104; java: 3,977; sh: 3,032; xml: 2,771; perl: 2,189; lex: 1,787; makefile: 181; javascript: 165; objc: 153; tcl: 59
file content (102 lines) | stat: -rw-r--r-- 3,016 bytes parent folder | download | duplicates (2)
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
// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
// SPDX-License-Identifier: BSD-3-Clause
// The command line arguments are:
// -I        => run in interactive mode; unless this is used, the program will
//              not allow interaction and exit
// -D <path> => path to the data; the data should be in <path>/Data/

// If WRITE_RESULT is defined, the result of the surface filter is saved.
// #define WRITE_RESULT

#include "vtkActor.h"
#include "vtkCamera.h"
#include "vtkMath.h"
#include "vtkPolyData.h"
#include "vtkPolyDataMapper.h"
#include "vtkPolyDataPointSampler.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkSphereSource.h"
#include "vtkStripper.h"
#include "vtkTestUtilities.h"

int TestPolyDataPointSampler(int argc, char* argv[])
{
  // Standard rendering classes
  vtkRenderer* renderer = vtkRenderer::New();
  vtkRenderWindow* renWin = vtkRenderWindow::New();
  renWin->SetMultiSamples(0);
  renWin->AddRenderer(renderer);
  vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  // Create a generating polydata
  vtkSphereSource* ss = vtkSphereSource::New();
  ss->SetPhiResolution(25);
  ss->SetThetaResolution(38);
  ss->SetCenter(4.5, 5.5, 5.0);
  ss->SetRadius(2.5);

  // Create multiple samplers to test different parts of the algorithm
  vtkPolyDataPointSampler* sampler = vtkPolyDataPointSampler::New();
  sampler->SetInputConnection(ss->GetOutputPort());
  sampler->SetDistance(0.05);
  sampler->GenerateInteriorPointsOn();

  vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
  mapper->SetInputConnection(sampler->GetOutputPort());

  vtkActor* actor = vtkActor::New();
  actor->SetMapper(mapper);

  vtkStripper* stripper = vtkStripper::New();
  stripper->SetInputConnection(ss->GetOutputPort());

  vtkPolyDataPointSampler* sampler2 = vtkPolyDataPointSampler::New();
  sampler2->SetInputConnection(stripper->GetOutputPort());
  sampler2->SetDistance(0.05);
  sampler2->GenerateInteriorPointsOn();

  vtkPolyDataMapper* mapper2 = vtkPolyDataMapper::New();
  mapper2->SetInputConnection(sampler2->GetOutputPort());

  vtkActor* actor2 = vtkActor::New();
  actor2->SetMapper(mapper2);
  actor2->AddPosition(5.5, 0, 0);
  actor2->GetProperty()->SetColor(0, 1, 0);

  // Add actors
  renderer->AddActor(actor);
  renderer->AddActor(actor2);

  // Standard testing code.
  renWin->SetSize(500, 250);
  renWin->Render();
  renderer->GetActiveCamera()->Zoom(2);
  renWin->Render();

  int retVal = vtkRegressionTestImageThreshold(renWin, 0.05);
  if (retVal == vtkRegressionTester::DO_INTERACTOR)
  {
    iren->Start();
  }

  // Cleanup
  renderer->Delete();
  renWin->Delete();
  iren->Delete();

  ss->Delete();
  sampler->Delete();
  stripper->Delete();
  sampler2->Delete();
  mapper->Delete();
  mapper2->Delete();
  actor->Delete();
  actor2->Delete();

  return !retVal;
}