24 #include <vtkVersion.h>
25 #include <vtkSmartPointer.h>
26 #include <vtkPointData.h>
27 #include <vtkIdTypeArray.h>
28 #include <vtkDataSetSurfaceFilter.h>
29 #include <vtkRendererCollection.h>
30 #include <vtkProperty.h>
31 #include <vtkPlanes.h>
32 #include <vtkObjectFactory.h>
33 #include <vtkPolyDataMapper.h>
35 #include <vtkRenderWindow.h>
36 #include <vtkRenderer.h>
37 #include <vtkRenderWindowInteractor.h>
38 #include <vtkPolyData.h>
39 #include <vtkPointSource.h>
40 #include <vtkAreaPicker.h>
41 #include <vtkExtractGeometry.h>
42 #include <vtkDataSetMapper.h>
43 #include <vtkUnstructuredGrid.h>
44 #include <vtkVertexGlyphFilter.h>
45 #include <vtkIdFilter.h>
47 #include <vtkCellArray.h>
49 #include <vtkFeatureEdges.h>
57 #define VTKISRBP_ORIENT 0
58 #define VTKISRBP_SELECT 1
60 class axlInteractorStyleRubberBandPickPrivate
63 vtkSmartPointer<vtkPolyData> Points;
64 vtkSmartPointer<vtkActor> SelectedActor;
65 vtkSmartPointer<vtkDataSetMapper> SelectedMapper;
73 vtkInteractorStyleRubberBandPick::OnLeftButtonUp();
75 vtkPlanes* frustum =
static_cast<vtkAreaPicker*
>(this->GetInteractor()->GetPicker())->GetFrustum();
77 vtkSmartPointer<vtkExtractGeometry> extractGeometry =
78 vtkSmartPointer<vtkExtractGeometry>::New();
79 extractGeometry->SetImplicitFunction(frustum);
80 #if VTK_MAJOR_VERSION <= 5
81 extractGeometry->SetInput(d->Points);
83 extractGeometry->SetInputData(d->Points);
85 extractGeometry->Update();
88 vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
89 vtkSmartPointer<vtkVertexGlyphFilter>::New();
90 glyphFilter->SetInputConnection(extractGeometry->GetOutputPort());
91 glyphFilter->Update();
99 vtkPolyData* selected = glyphFilter->GetOutput();
100 std::cout <<
"Selected " << selected->GetNumberOfPoints() <<
" points." << std::endl;
101 std::cout <<
"Selected " << selected->GetNumberOfCells() <<
" cells." << std::endl;
102 #if VTK_MAJOR_VERSION <= 5
103 d->SelectedMapper->SetInput(selected);
105 d->SelectedMapper->SetInputData(selected);
107 d->SelectedMapper->ScalarVisibilityOff();
110 vtkIdTypeArray*
ids = vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetArray(
"OriginalIds"));
112 for(vtkIdType i = 0; i < ids->GetNumberOfTuples(); i++)
114 std::cout <<
"Id " << i <<
" : " << ids->GetValue(i) << std::endl;
115 d->ids.append(ids->GetValue(i));
119 d->SelectedActor->GetProperty()->SetColor(1.0, 0.0, 0.0);
120 d->SelectedActor->GetProperty()->SetPointSize(3);
122 this->CurrentRenderer->AddActor(d->SelectedActor);
124 this->GetInteractor()->GetRenderWindow()->Render();
125 this->HighlightProp(NULL);
132 vtkSmartPointer<vtkFeatureEdges> featureEdges =
133 vtkSmartPointer<vtkFeatureEdges>::New();
134 #if (VTK_MAJOR_VERSION <= 5)
135 featureEdges->SetInput(points);
137 featureEdges->SetInputData(points);
139 featureEdges->BoundaryEdgesOn();
140 featureEdges->FeatureEdgesOff();
141 featureEdges->ManifoldEdgesOff();
142 featureEdges->NonManifoldEdgesOff();
143 featureEdges->Update();
152 vtkSmartPointer<vtkPolyData> poly = featureEdges->GetOutput();
163 d->SelectedMapper = vtkSmartPointer<vtkDataSetMapper>::New();
164 d->SelectedActor = vtkSmartPointer<vtkActor>::New();
165 d->SelectedActor->SetMapper(d->SelectedMapper);
void IdsSelectedChanged(void)
void SetPolyData(vtkSmartPointer< vtkPolyData > points)
~axlInteractorStyleRubberBandPick(void)
vtkStandardNewMacro(axlInteractorStyleRubberBandPick)
axlInteractorStyleRubberBandPick(QObject *parent=0)
virtual void OnLeftButtonUp()