Re: Crashing on GetGlobalIds
David E DeMarle via vtkusers <[email protected]>
| Newsgroups | gmane.comp.lib.vtk.user |
|---|---|
| Message-ID | <CANjZAi8T3Za4Cx-CrkSkYYWh6LeKoXHP3aqzQEo=j3iKRSFv6w@mail.gmail.com> |
vtkSmartPointer<vtkIdTypeArray> globalIds = vtkSmartPointer<vtkIdTypeArray>::New(); globalIds = vtkIdTypeArray::SafeDownCast(selected->GetPointData()->GetGlobalIds()); assert(globalIds); I think the assert tells you that the smartpointer itself exists, but it doesn't say anything about the vtkIdTypeArray pointed to by the smartpointer. I suspect if you assert(globalIds.GetPointer()) it will fail. If that is the case, since it is null, gloablids->* crashes on the next line. Why it is null will take some more tracking down. One thing to note about globalids is that VTK is conservative about preserving their meaning and throws them away when it can't do that. For example they won't be interpolated like most arrays are because averaging ids or (i.e. names) is undefined. Likewise filters that don't simply copy cells/points across won't attempt to preserve globalids. So what you should do is trace through the filters you are using to see where specifically the globalids are lost. hth David E DeMarle Kitware, Inc. Principal Engineer 21 Corporate Drive Clifton Park, NY 12065-8662 Phone: 518-881-4909 On Sat, Nov 24, 2018 at 9:47 AM meakcey <[email protected]> wrote: > 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 > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the VTK FAQ at: > http://www.vtk.org/Wiki/VTK_FAQ > > Search the list archives at: http://markmail.org/search/?q=vtkusers > > Follow this link to subscribe/unsubscribe: > https://public.kitware.com/mailman/listinfo/vtkusers > _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ Search the list archives at: http://markmail.org/search/?q=vtkusers Follow this link to subscribe/unsubscribe: https://public.kitware.com/mailman/listinfo/vtkusers