-
Notifications
You must be signed in to change notification settings - Fork 2
/
Test1.cpp
78 lines (63 loc) · 2.02 KB
/
Test1.cpp
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
#include <vtkSmartPointer.h>
#include <vtkMath.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkPolyData.h>
#include <vtkSphereSource.h>
#include <iostream>
#include <sstream>
#include "vtkFrameRateWidget.h"
using namespace std;
int main(int argc, char *argv[])
{
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
unsigned nPoints = 0;
// Check command line arguments
if (argc < 2)
{
nPoints = 100;
}
else
{
istringstream(argv[1]) >> nPoints;
}
for(unsigned int i = 0; i < nPoints; i++)
{
// Create a sphere
vtkSmartPointer<vtkSphereSource> sphereSource =
vtkSmartPointer<vtkSphereSource>::New();
sphereSource->SetRadius(nPoints*0.01);
sphereSource->SetCenter(vtkMath::Random(0,nPoints),
vtkMath::Random(0,nPoints),
vtkMath::Random(0,nPoints));
// Create a mapper and actor
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(sphereSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
renderer->AddActor(actor);
}
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> interactor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
vtkSmartPointer<vtkFrameRateWidget> frameRateWidget =
vtkSmartPointer<vtkFrameRateWidget>::New();
frameRateWidget->SetInteractor(interactor);
frameRateWidget->SetRenderer(renderer);
frameRateWidget->SelectableOff();
frameRateWidget->Init();
renderer->SetBackground(1,1,1); // Background color white
renderWindow->Render();
frameRateWidget->On();
interactor->Start();
return EXIT_SUCCESS;
}