Delete object from vtkPolyDataConnectivityFilter(C++)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Delete object from vtkPolyDataConnectivityFilter(C++)

hao chen
This post was updated on .
Like this pic, I want to delete that object.

Hello, I want to delete one object in vtkTriangleFilter, have some question
about origin CellId after I do vtkPolyDataConnectivityFilter.

Part of my code:

vtkSmartPointer<vtkDICOMImageReader> DicomImageReader =
vtkSmartPointer<vtkDICOMImageReader>::New();
DicomImageReader->SetDirectoryName("E:\\offline_3Ddata\\2017042402");
DicomImageReader->Update();
In my part of code:
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<vtkPolyDataConnectivityFilter> connectivityFilter =
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();  
connectivityFilter->SetInput(triangleFilter->GetOutput());  
connectivityFilter->SetExtractionModeToCellSeededRegions();
connectivityFilter->AddSeed(1000);
connectivityFilter->Update();

----------------------------------------------------------------------------------------------------------------------
This case in triangleFilter have many objects and use connectivityFilter it
will find CellId = 1000 in triangleFilter others cell connected with CellId
= 1000.

After that connectivityFilter will have one object, and the
connectivityFilter's CellId will start with zero, but I want the original
CellId.

How can I get the original CellId in connectivityFilter? I want to delete
object in the triangleFilter.
Or have any other solution.

Sorry my poor english. Thx~

Hao



--
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
Reply | Threaded
Open this post in threaded view
|

Re: Delete object from vtkPolyDataConnectivityFilter(C++)

kenichiro yoshimi
Hi Hao,

Beforehand you can make a numbering of cell ids using vtkIdFilter
before applying connectivityFilter.
See: https://lorensen.github.io/VTKExamples/site/Cxx/PolyData/PointCellIds/

Regards
2018年7月12日(木) 22:26 hao chen <[hidden email]>:

>
> Hello, I want to delete one object in vtkTriangleFilter, have some question
> about origin CellId after I do vtkPolyDataConnectivityFilter.
>
> Part of my code:
>
> vtkSmartPointer<vtkDICOMImageReader> DicomImageReader =
> vtkSmartPointer<vtkDICOMImageReader>::New();
> DicomImageReader->SetDirectoryName("E:\\offline_3Ddata\\2017042402");
> DicomImageReader->Update();
> In my part of code:
> 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<vtkPolyDataConnectivityFilter> connectivityFilter =
> vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
> connectivityFilter->SetInput(triangleFilter->GetOutput());
> connectivityFilter->SetExtractionModeToCellSeededRegions();
> connectivityFilter->AddSeed(1000);
> connectivityFilter->Update();
>
> ----------------------------------------------------------------------------------------------------------------------
> This case in triangleFilter have many objects and use connectivityFilter it
> will find CellId = 1000 in triangleFilter others cell connected with CellId
> = 1000.
>
> After that connectivityFilter will have one object, and the
> connectivityFilter's CellId will start with zero, but I want the original
> CellId.
>
> How can I get the original CellId in connectivityFilter? I want to delete
> object in the triangleFilter.
> Or have any other solution.
>
> Sorry my poor english. Thx~
>
> Hao
>
>
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Delete object from vtkPolyDataConnectivityFilter(C++)

hao chen
This post was updated on .
Hi, kenichiro yoshimi

Thank you for your reply.
But I don't know the specific method.

Do you mean like this:

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(sphereSource->GetOutputPort());
  idFilter->SetIdsArrayName("ids");
  idFilter->Update();*


vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();  
connectivityFilter->SetInput(*idFilter*->GetOutput());  
connectivityFilter->SetExtractionModeToCellSeededRegions();
connectivityFilter->AddSeed(1000);
connectivityFilter->Update();

----------------------------------------------------------------------------------------------------------------------
By the way, I didn't realize that I don't know how to get the CellID from
vtkPolyDataConnectivityFilter.
I use 'GetCellNeighbors' to get CellId, but if I use in circled object(too
large), it will work very slowly.
So I found vtkPolyDataConnectivityFilter method, want to find out the CellId
directly.
Can you show me the specific method?

Sorry my poor english.
Thank you~

Hao



--
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
Reply | Threaded
Open this post in threaded view
|

Re: Delete object from vtkPolyDataConnectivityFilter(C++)

kenichiro yoshimi
Hi Hao,

I am sorry that I don't quite understand what you are trying to do. If
you want to get the original CellID from
vtkPolyDataConnectivityFilter, I think you first need to make a map
that stores combinations {original id:current id}:
-----
  std::map<vtkIdType, vtkIdType> idMap;
  vtkIdTypeArray *cellIdArray = vtkIdTypeArray::SafeDownCast(
    connectivityFilter->GetOutput()->GetCellData()->GetArray("ids"));
  for (vtkIdType i = 0; i < cellIdArray->GetNumberOfTuples(); ++i)
  {
    vtkIdType orgId = cellIdArray->GetTuple1(i);
    idMap[orgId] = i;
  }
-----
After that  you can also get a cell according to the original Id:
  vtkCell *cell = connectivityFilter->GetOutput()->GetCell(idMap[1000]);

Thanks
2018年7月16日(月) 15:49 hao chen <[hidden email]>:

>
> Hi, kenichiro yoshimi
>
> Thank you for your reply.
> But I don't know the specific method.
>
> Do you mean like this:
>
> 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(sphereSource->GetOutputPort());
>   idFilter->SetIdsArrayName("ids");
>   idFilter->Update();*
>
> vtkSmartPointer<vtkPolyDataConnectivityFilter> connectivityFilter =
> vtkSmartPointer<vtkPolyDataConnectivityFilter>::New();
> connectivityFilter->SetInput(*idFilter*->GetOutput());
> connectivityFilter->SetExtractionModeToCellSeededRegions();
> connectivityFilter->AddSeed(1000);
> connectivityFilter->Update();
>
> ----------------------------------------------------------------------------------------------------------------------
> By the way, I didn't realize that I don't know how to get the CellID from
> vtkPolyDataConnectivityFilter.
> I use 'GetCellNeighbors' to get CellId, but if I use in circled object(too
> large), it will work very slowly.
> So I found vtkPolyDataConnectivityFilter method, want to find out the CellId
> directly.
> Can you show me the specific method?
>
> Sorry my poor english.
> Thank you~
>
> Hao
>
>
>
> --
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Delete object from vtkPolyDataConnectivityFilter(C++)

hao chen
This post was updated on .
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
_______________________________________________
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