4 #include <vtkPolyData.h> 5 #include <vtkPolyDataMapper.h> 7 #include <vtkProperty.h> 9 #include <vtkCellArray.h> 10 #include <vtkCellData.h> 11 #include <vtkUnsignedCharArray.h> 12 #include <vtkTransform.h> 19 vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
20 vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
28 pt[0] = min.
x, pt[1] = min.
y, pt[2] = min.
z;
29 points->InsertNextPoint(pt);
31 pt[0] = max.
x, pt[1] = min.
y, pt[2] = min.
z;
32 points->InsertNextPoint(pt);
34 pt[0] = min.
x, pt[1] = max.
y, pt[2] = min.
z;
35 points->InsertNextPoint(pt);
37 pt[0] = max.
x, pt[1] = max.
y, pt[2] = min.
z;
38 points->InsertNextPoint(pt);
42 pt[0] = min.
x, pt[1] = min.
y, pt[2] = max.
z;
43 points->InsertNextPoint(pt);
45 pt[0] = max.
x, pt[1] = min.
y, pt[2] = max.
z;
46 points->InsertNextPoint(pt);
48 pt[0] = min.
x, pt[1] = max.
y, pt[2] = max.
z;
49 points->InsertNextPoint(pt);
51 pt[0] = max.
x, pt[1] = max.
y, pt[2] = max.
z;
52 points->InsertNextPoint(pt);
54 polyData->SetPoints(points);
56 vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
60 vtkSmartPointer<vtkLine> line0 = vtkSmartPointer<vtkLine>::New();
61 line0->GetPointIds()->SetId(0, 0);
62 line0->GetPointIds()->SetId(1, 1);
63 lines->InsertNextCell(line0);
65 vtkSmartPointer<vtkLine> line1 = vtkSmartPointer<vtkLine>::New();
66 line1->GetPointIds()->SetId(0, 0);
67 line1->GetPointIds()->SetId(1, 2);
68 lines->InsertNextCell(line1);
70 vtkSmartPointer<vtkLine> line2 = vtkSmartPointer<vtkLine>::New();
71 line2->GetPointIds()->SetId(0, 3);
72 line2->GetPointIds()->SetId(1, 1);
73 lines->InsertNextCell(line2);
75 vtkSmartPointer<vtkLine> line3 = vtkSmartPointer<vtkLine>::New();
76 line3->GetPointIds()->SetId(0, 3);
77 line3->GetPointIds()->SetId(1, 2);
78 lines->InsertNextCell(line3);
82 vtkSmartPointer<vtkLine> line4 = vtkSmartPointer<vtkLine>::New();
83 line4->GetPointIds()->SetId(0, 4);
84 line4->GetPointIds()->SetId(1, 5);
85 lines->InsertNextCell(line4);
87 vtkSmartPointer<vtkLine> line5 = vtkSmartPointer<vtkLine>::New();
88 line5->GetPointIds()->SetId(0, 4);
89 line5->GetPointIds()->SetId(1, 6);
90 lines->InsertNextCell(line5);
92 vtkSmartPointer<vtkLine> line6 = vtkSmartPointer<vtkLine>::New();
93 line6->GetPointIds()->SetId(0, 7);
94 line6->GetPointIds()->SetId(1, 5);
95 lines->InsertNextCell(line6);
97 vtkSmartPointer<vtkLine> line7 = vtkSmartPointer<vtkLine>::New();
98 line7->GetPointIds()->SetId(0, 7);
99 line7->GetPointIds()->SetId(1, 6);
100 lines->InsertNextCell(line7);
104 vtkSmartPointer<vtkLine> line8 = vtkSmartPointer<vtkLine>::New();
105 line8->GetPointIds()->SetId(0, 0);
106 line8->GetPointIds()->SetId(1, 4);
107 lines->InsertNextCell(line8);
109 vtkSmartPointer<vtkLine> line9 = vtkSmartPointer<vtkLine>::New();
110 line9->GetPointIds()->SetId(0, 1);
111 line9->GetPointIds()->SetId(1, 5);
112 lines->InsertNextCell(line9);
114 vtkSmartPointer<vtkLine> line10 = vtkSmartPointer<vtkLine>::New();
115 line10->GetPointIds()->SetId(0, 2);
116 line10->GetPointIds()->SetId(1, 6);
117 lines->InsertNextCell(line10);
119 vtkSmartPointer<vtkLine> line11 = vtkSmartPointer<vtkLine>::New();
120 line11->GetPointIds()->SetId(0, 3);
121 line11->GetPointIds()->SetId(1, 7);
122 lines->InsertNextCell(line11);
124 polyData->SetLines(lines);
126 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
127 mapper->SetInputData(polyData);
129 m_actor = vtkSmartPointer<vtkActor>::New();
137 double color[] = {r, g, b};
138 m_actor->GetProperty()->SetColor(color);
143 vtkSmartPointer<vtkTransform>
transform = vtkSmartPointer<vtkTransform>::New();
144 transform->PostMultiply();
145 transform->RotateX(pose.
r);
146 transform->RotateY(pose.
t);
147 transform->RotateZ(pose.
p);
148 transform->Translate(pose.
x, pose.
y, pose.
z);
150 m_actor->SetUserTransform(transform);
void setPose(const Pose &pose)
vtkSmartPointer< vtkActor > m_actor
void setVisibility(bool visible)
A dynamic bounding box class.
LVRBoundingBoxBridge(BoundingBox< Vec > bb)
void setColor(double r, double g, double b)
BoundingBox< Vec > m_boundingBox