[vtkusers] Crashing on GetGlobalIds

meakcey meakcey at gmail.com
Sat Nov 24 09:47:44 EST 2018


Cleaner comparison to problem

*Code below is working*

vtkPlanes* frustum =
static_cast<vtkAreaPicker*>(this->GetInteractor()->GetPicker())->GetFrustum();
vtkSmartPointer<vtkExtractGeometry> extractGeometry =
vtkSmartPointer<vtkExtractGeometry>::New();
extractGeometry->SetImplicitFunction(frustum);
extractGeometry->SetInputData(this->Points);
extractGeometry->Update();
extractGeometry->GetOutput()->GetPointData()->CopyGlobalIdsOn();

vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
glyphFilter->SetInputConnection(extractGeometry->GetOutputPort());
glyphFilter->Update();
glyphFilter->GetOutput()->GetPointData()->CopyGlobalIdsOn();
vtkPolyData* selected = glyphFilter->GetOutput();

vtkSmartPointer<vtkIdTypeArray> globalIds =
vtkSmartPointer<vtkIdTypeArray>::New();
globalIds =
vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetGlobalIds());
assert(globalIds);
std::cout << "Nof globalIds " << globalIds->GetNumberOfComponents() << " "
<< globalIds->GetNumberOfTuples() << std::endl;

*Code below is crashing at the line of cout
*
vtkPlanes* frustum =
static_cast<vtkAreaPicker*>(this->GetInteractor()->GetPicker())->GetFrustum();
vtkSmartPointer<vtkExtractGeometry> extractGeometry =
vtkSmartPointer<vtkExtractGeometry>::New();
extractGeometry->SetImplicitFunction(frustum);
extractGeometry->SetInputData(this->Points);
extractGeometry->Update();
extractGeometry->GetOutput()->GetPointData()->CopyGlobalIdsOn();

vtkSmartPointer<vtkSelectVisiblePoints> visiblePoints =
vtkSmartPointer<vtkSelectVisiblePoints>::New();
visiblePoints->SetInputConnection(extractGeometry->GetOutputPort());
visiblePoints->SetRenderer(this->GetInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
visiblePoints->Update();
visiblePoints->GetOutput()->GetPointData()->CopyGlobalIdsOn();

vtkSmartPointer<vtkVertexGlyphFilter> visibleFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();
visibleFilter->SetInputConnection(visiblePoints->GetOutputPort());
visibleFilter->Update();
visibleFilter->GetOutput()->GetPointData()->CopyGlobalIdsOn();
vtkPolyData* visibles = visibleFilter->GetOutput();

vtkSmartPointer<vtkIdTypeArray> globalIds =
vtkSmartPointer<vtkIdTypeArray>::New();
globalIds =
vtkIdTypeArray::SafeDownCast(visibles->GetPointData()->GetGlobalIds());
assert(globalIds);
std::cout << "Nof globalIds " << globalIds->GetNumberOfComponents() << " "
<< globalIds->GetNumberOfTuples() << std::endl;






--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list