Last active
August 29, 2015 14:05
-
-
Save sytsereitsma/73cb7afc1ddcdb374641 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
virtual void OnKeyPress() { | |
vtkRenderWindowInteractor *rwi = this->Interactor; | |
const char* ch = rwi->GetKeySym (); | |
if (strcmp (ch, "Delete") == 0) { | |
vtkPlanes* frustum = static_cast<vtkAreaPicker*>(this->GetInteractor()->GetPicker())->GetFrustum(); | |
vtkSmartPointer<vtkExtractGeometry> extractGeometry = | |
vtkSmartPointer<vtkExtractGeometry>::New(); | |
extractGeometry->SetImplicitFunction(frustum); | |
extractGeometry->SetInputData(this->Points); | |
extractGeometry->SetExtractInside(0); //We want all points outside the geometry | |
extractGeometry->Update(); | |
vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter = | |
vtkSmartPointer<vtkVertexGlyphFilter>::New(); | |
glyphFilter->SetInputConnection(extractGeometry->GetOutputPort()); | |
glyphFilter->Update(); | |
vtkPolyData* selected = glyphFilter->GetOutput (); | |
vtkIdTypeArray* ids = vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetArray("OriginalIds")); | |
vtkSmartPointer<vtkPoints> newPoints = vtkSmartPointer<vtkPoints>::New(); | |
for(vtkIdType i = 0; i < ids->GetNumberOfTuples(); i++) { | |
newPoints->InsertPoint(ids->GetValue(i), this->Points->GetPoint (ids->GetValue(i))); | |
} | |
this->Points->SetPoints (newPoints); | |
this->GetInteractor()->GetRenderWindow()->Render(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment