[vtkusers] Delete object from vtkPolyDataConnectivityFilter(C++)
hao chen
harry1994128 at gmail.com
Tue Jul 17 06:01:15 EDT 2018
Hi kenichiro yoshimi,
Very thank you for your method and reply patiently.
I can get the origin CellId now.
This is my part of code:
vtkSmartPointer<vtkDICOMImageReader> DicomImageReader =
vtkSmartPointer<vtkDICOMImageReader>::New();
DicomImageReader->SetDirectoryName("E:\\offline_3Ddata\\2017042402");
DicomImageReader->Update();
vtkSmartPointer<vtkContourFilter> filter =
vtkSmartPointer<vtkContourFilter>::New();
filter->SetInputConnection(DicomImageReader->GetOutputPort());
filter->SetValue(0, 9000);
filter->Update();
vtkSmartPointer<vtkTriangleFilter> triangleFilter =
vtkSmartPointer<vtkTriangleFilter>::New();
triangleFilter->SetInputConnection(filter->GetOutputPort());
triangleFilter->Update();
*vtkSmartPointer<vtkIdFilter> idFilter =
vtkSmartPointer<vtkIdFilter>::New();
idFilter->SetInputConnection(triangleFilter->GetOutputPort());
idFilter->SetIdsArrayName("ids");
idFilter->Update();*
vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
connectivityFilter->SetInput(*idFilter*->GetOutput());
connectivityFilter->SetExtractionModeToCellSeededRegions();
connectivityFilter->AddSeed(1000);
connectivityFilter->Update();
*vtkSmartPointer<vtkIdTypeArray> cellIdArray =
vtkIdTypeArray::SafeDownCast(connectivityFilter->GetOutput()->GetCellData()->GetArray("ids"));*
*std::vector<double> OriginCellId;
for(int i = 0; i < cellIdArray->GetSize(); i++)
{
OriginCellId.push_back(cellIdArray->GetTuple1(i));
}*
----------------------------------------------------------------------------------------------------------------------
Use 'cellIdArray->GetTuple1(i)' can get is entire connectivityFilter's
origin cellid in triangleFilter.
In addition, I had a question about vtkIdFilter, did I need to use for sure?
If I don't use, it will error in 'vtkSmartPointer<vtkIdTypeArray>
cellIdArray =
vtkIdTypeArray::SafeDownCast(connectivityFilter->GetOutput()->GetCellData()->GetArray("ids"));'
I think is 'GetArray("ids")' problem.
Sorry my poor english.
Thank you~
Hao
--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
More information about the vtkusers
mailing list