1 #ifndef RAM_PATH_PLANNING_VTK_RENDER_UPDATER_TIMER_HPP 2 #define RAM_PATH_PLANNING_VTK_RENDER_UPDATER_TIMER_HPP 4 #include <vtkCommand.h> 5 #include <vtkInteractorStyleTrackballCamera.h> 6 #include <vtkPolyDataMapper.h> 7 #include <vtkProperty.h> 8 #include <vtkRenderWindow.h> 9 #include <vtkRenderWindowInteractor.h> 10 #include <vtkRenderer.h> 11 #include <vtkRendererCollection.h> 12 #include <vtkTransform.h> 13 #include <vtkTransformFilter.h> 18 typedef vtkSmartPointer<vtkPolyData>
Polygon;
20 typedef std::vector<PolygonVector>
Layer;
31 vtkSmartPointer<vtkPolyData>
mesh_ = vtkSmartPointer<vtkPolyData>::New();
37 void * vtkNotUsed(callData))
39 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::SafeDownCast(caller);
40 vtkRenderer * renderer = iren->GetRenderWindow()->GetRenderers()->GetFirstRenderer();
42 int representation(1);
43 vtkActor* last_actor(renderer->GetActors()->GetLastActor());
46 representation = last_actor->GetProperty()->GetRepresentation();
48 renderer->RemoveAllViewProps();
53 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
54 mapper->SetInputData(mesh_);
56 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
57 actor->SetMapper(mapper);
59 actor->GetProperty()->SetColor(0.5, 0.5, 0.5);
60 actor->GetProperty()->SetOpacity(0.5);
61 actor->GetProperty()->SetRepresentation(representation);
62 renderer->AddActor(actor);
67 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
68 mapper->SetInputConnection(stripper_->GetOutputPort());
69 mapper->ScalarVisibilityOff();
71 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
72 actor->SetMapper(mapper);
74 actor->GetProperty()->SetColor(1, 0, 0);
75 actor->GetProperty()->SetLineWidth(2.0);
76 actor->GetProperty()->SetRepresentation(representation);
77 renderer->AddActor(actor);
81 for (
unsigned i = 0; i < current_layer_.size(); ++i)
83 unsigned color_index(0);
84 for (
auto polygon : current_layer_[i])
86 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
87 mapper->SetInputData(polygon);
89 vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
90 actor->SetMapper(mapper);
94 actor->GetProperty()->SetColor(rgb);
95 actor->GetProperty()->SetRepresentation(representation);
96 renderer->AddActor(actor);
99 iren->GetRenderWindow()->Render();
std::vector< Polygon > PolygonVector
std::vector< PolygonVector > Layer
virtual void Execute(vtkObject *caller, unsigned long, void *vtkNotUsed(callData))
static vtkRendererUpdaterTimer * New()
void getColorFromIndex(const unsigned i, double rgb[3])
vtkSmartPointer< vtkPolyData > Polygon
vtkSmartPointer< vtkRendererUpdaterTimer > cb
vtkSmartPointer< vtkStripper > stripper_
vtkSmartPointer< vtkPolyData > mesh_