-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.cpp
More file actions
68 lines (51 loc) · 1.58 KB
/
Point.cpp
File metadata and controls
68 lines (51 loc) · 1.58 KB
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
#include "Point.h"
Point::Point() {
build(new double[3]{ 0.0, 0.0, 0.0 }, 0.05);
}
Point::Point(double radius) {
build(new double[3]{ 0.0, 0.0, 0.0 }, radius);
}
Point::Point(double* _position, double _radius) {
build(_position, _radius);
}
void Point::build(double* _position, double _radius) {
actor = vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkRegularPolygonSource> point = vtkSmartPointer<vtkRegularPolygonSource>::New();
point->SetNumberOfSides(50);
point->SetRadius(_radius);
point->SetCenter(_position);
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkPolyDataMapper::New();
mapper->SetInputConnection(point->GetOutputPort());
actor->SetMapper(mapper);
actor->GetProperty()->SetColor(158 / 255.0, 77 / 255.0, 30 / 255.0);
actor->SetVisibility(1);
radius = _radius;
}
void Point::SetRadius(double _radius){
vtkSmartPointer<vtkRegularPolygonSource> point = vtkSmartPointer<vtkRegularPolygonSource>::New();
point->SetNumberOfSides(50);
point->SetRadius(_radius);
point->SetCenter(actor->GetPosition());
vtkPolyDataMapper::SafeDownCast(actor->GetMapper())->SetInputConnection(point->GetOutputPort());
}
void Point::SetPosition(double* position){
actor->SetPosition(position);
}
void Point::SetColor(int r, int g, int b){
actor->GetProperty()->SetColor(r / 255.0, g / 255.0, b / 255.0);
}
void Point::VisibilityOn(){
actor->SetVisibility(1);
}
void Point::VisibilityOff(){
actor->SetVisibility(0);
}
double Point::GetRadius(){
return radius;
}
double* Point::GetPosition(){
return actor->GetPosition();
}
vtkSmartPointer<vtkActor> Point::GetActor(){
return actor;
}