File: TestTransformCoordinateUseDouble.cxx

package info (click to toggle)
vtk6 6.3.0%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,880 kB
  • sloc: cpp: 1,442,792; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,119; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 154; makefile: 103; objc: 17
file content (120 lines) | stat: -rw-r--r-- 3,545 bytes parent folder | download | duplicates (9)
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
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    TestOpenGLPolyDataMapper.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.

=========================================================================*/

// .NAME Test of vtkLabelPlacementMapper
// .SECTION Description
// this program tests vtkLabelPlacementMapper which uses a sophisticated algorithm to
// prune labels/icons preventing them from overlapping.

#include <vtkCellArray.h>
#include <vtkProperty2D.h>
#include <vtkPolyData.h>
#include <vtkNew.h>
#include <vtkPolyDataMapper2D.h>
#include <vtkActor2D.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkTestUtilities.h>
#include <vtkRegressionTestImage.h>

int TestTransformCoordinateUseDouble(int argc, char *argv[])
{
  vtkNew<vtkRenderWindow> renderWindow;
  renderWindow->SetSize(400, 400);

  // Create a box around the renderers
  vtkNew<vtkPolyData> poly;
  vtkNew<vtkPoints> points;

  // Shift the points so they don't fall right between 2 pixels but on the on
  // located on the top right.
  double shift = 0.0002;
  points->InsertNextPoint(0. + shift, 0. + shift, 0); // bottom-left
  points->InsertNextPoint(1. + shift, 0. + shift, 0); // bottom-right
  points->InsertNextPoint(1. + shift, 1. + shift, 0); // top-right
  points->InsertNextPoint(0. + shift, 1. + shift, 0); // top-left

  vtkNew<vtkCellArray> cells;
  cells->InsertNextCell(5);
  cells->InsertCellPoint(0);
  cells->InsertCellPoint(1);
  cells->InsertCellPoint(2);
  cells->InsertCellPoint(3);
  cells->InsertCellPoint(0);

  poly->SetPoints(points.GetPointer());
  poly->SetLines(cells.GetPointer());

  int i = 6;
  double x = 0.;
  double y = 1. / 8.;
  double width = 1. / 4.;
  double height = 1. / 8.;

  vtkNew<vtkRenderer> emptyRenderer;
  emptyRenderer->SetViewport(0 , 0 , width, height);
  renderWindow->AddRenderer(emptyRenderer.GetPointer());

  while (--i)
    {
    vtkNew<vtkRenderer> renderer;
    renderer->SetViewport(x , y , x + width, y + height);

    vtkNew<vtkCoordinate> boxCoordinate;
    boxCoordinate->SetCoordinateSystemToNormalizedViewport();
    boxCoordinate->SetViewport(renderer.GetPointer());

    vtkNew<vtkPolyDataMapper2D> polyDataMapper;
    polyDataMapper->SetInputData(poly.GetPointer());
    polyDataMapper->SetTransformCoordinate(boxCoordinate.GetPointer());
    polyDataMapper->SetTransformCoordinateUseDouble(true);

    vtkNew<vtkActor2D> boxActor;
    boxActor->SetMapper(polyDataMapper.GetPointer());

    renderer->AddActor2D(boxActor.GetPointer());

    renderWindow->AddRenderer(renderer.GetPointer());

    if ( i % 2 )
      {
      x += width;
      y -= height;
      height *= 2.;
      }
    else
      {
      x -= width;
      y += height;
      width *= 2.;
      }
    }

  //Render and interact
  vtkNew<vtkRenderWindowInteractor> interactor;
  interactor->SetRenderWindow(renderWindow.GetPointer());

  renderWindow->SetMultiSamples(0);
  renderWindow->Render();

  int retVal = vtkRegressionTestImage(renderWindow.GetPointer());
  if(retVal == vtkRegressionTester::DO_INTERACTOR)
    {
    interactor->Start();
    }

  return !retVal;
}