Selecting/Extracting cells using points

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

Selecting/Extracting cells using points

David Doria-2
When using vtkSelectionNode and vtkExtractSelection to extract a piece
of a vtkPolyData by selectin point ids, is there anyway to get the
cells that exist completely on the remaining points to come along for
the ride? This code:

http://www.vtk.org/Wiki/VTK/Examples/Broken/ExtractCellsUsingPoints

currently seems to generate a vertex for each point but lose all of
the polygonal cells. Anyone know how to do this?

Thanks,

David
_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Selecting/Extracting cells using points

David E DeMarle
That is what that vtkInformationIntegerKey
*vtkSelectionNode::CONTAINING_CELLS() flag is for.

David E DeMarle
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x109



On Sun, May 30, 2010 at 11:18 AM, David Doria <[hidden email]> wrote:

> When using vtkSelectionNode and vtkExtractSelection to extract a piece
> of a vtkPolyData by selectin point ids, is there anyway to get the
> cells that exist completely on the remaining points to come along for
> the ride? This code:
>
> http://www.vtk.org/Wiki/VTK/Examples/Broken/ExtractCellsUsingPoints
>
> currently seems to generate a vertex for each point but lose all of
> the polygonal cells. Anyone know how to do this?
>
> Thanks,
>
> David
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Selecting/Extracting cells using points

David Doria-2
On Sun, May 30, 2010 at 11:52 AM, David E DeMarle
<[hidden email]> wrote:
> That is what that vtkInformationIntegerKey
> *vtkSelectionNode::CONTAINING_CELLS() flag is for.
>
> David E DeMarle

Perfect, thanks.

For anyone else interested, you use this by doing:

selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(), 1);

David
_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Selecting/Extracting cells using points

David Doria-2
> For anyone else interested, you use this by doing:
>
> selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(), 1);
>
> David
>

Hm, so that seems to work when the selection is inverted, but not when
it is not inverted:

If I do this:

  vtkSmartPointer<vtkSelectionNode> selectionNode =
      vtkSmartPointer<vtkSelectionNode>::New();
  selectionNode->SetFieldType(vtkSelectionNode::POINT);
  selectionNode->SetContentType(vtkSelectionNode::INDICES);
  selectionNode->SetSelectionList(this->pointIds);
  selectionNode->GetProperties()->Set(vtkSelectionNode::INVERSE(), 1);
//invert the selection
  selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(),
1); //keep cells that use remaining points

it works as expected, it removes the points that were in pointIds and
keeps the cells that are defined on the remaining points.

However, with out the inverse line:

  vtkSmartPointer<vtkSelectionNode> selectionNode =
      vtkSmartPointer<vtkSelectionNode>::New();
  selectionNode->SetFieldType(vtkSelectionNode::POINT);
  selectionNode->SetContentType(vtkSelectionNode::INDICES);
  selectionNode->SetSelectionList(this->pointIds);
  selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(),
1); //keep cells that use remaining points

It seems to keep ALL of the points no matter how many are listed in
pointIds. If I remove the CONTAINING_CELLS line:

  vtkSmartPointer<vtkSelectionNode> selectionNode =
      vtkSmartPointer<vtkSelectionNode>::New();
  selectionNode->SetFieldType(vtkSelectionNode::POINT);
  selectionNode->SetContentType(vtkSelectionNode::INDICES);
  selectionNode->SetSelectionList(this->pointIds);

It keeps only the points listed in pointIds, but of course there are
no non-vertex cells in the output.

Can anyone explain this behavior?

Thanks,

David
_______________________________________________
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

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Selecting/Extracting cells using points

andyjk
Resurrecting this - I cannot even get it to work in inverse mode, it only
keeps the points, not the cells. I have tried using vtkExtractSelection and
vtkExtractSelectedIds, but neither will extract the cells. Any idea what I
am missing here?

                        std::cout << "Removing " <<
ids_for_removal->GetNumberOfTuples() << " points on boundary" << std::endl;
                        // Run the extraction filter (inverted)
                        vtkSmartPointer<vtkSelectionNode> selectionNode =
vtkSmartPointer<vtkSelectionNode>::New();
                        selectionNode->SetFieldType(vtkSelectionNode::POINT);
                        selectionNode->SetContentType(vtkSelectionNode::INDICES);
                        selectionNode->SetSelectionList(ids_for_removal);
                        selectionNode->GetProperties()->Set(vtkSelectionNode::INVERSE(), 1);
//invert the selection so we extract everything NOT labelled
                        selectionNode->GetProperties()->Set(vtkSelectionNode::CONTAINING_CELLS(),
1);
                       
                        vtkSmartPointer<vtkSelection> selection =
vtkSmartPointer<vtkSelection>::New();
                        selection->AddNode(selectionNode);

                        vtkSmartPointer<vtkExtractSelectedIds> extractSelectedIds =
vtkSmartPointer<vtkExtractSelectedIds>::New();
                        extractSelectedIds->SetInputData(0, mesh_in_out);
                        extractSelectedIds->SetInputData(1, selection);
                        extractSelectedIds->Update();

                        // Back up the data
                        vtkSmartPointer<vtkPolyData> temp2 = vtkSmartPointer<vtkPolyData>::New();
                        temp2->DeepCopy(extractSelectedIds->GetOutput());
                        std::cout << "Before mesh has : " << mesh_in_out->GetNumberOfCells() << "
cells and " << mesh_in_out->GetNumberOfPoints() << " points" << std::endl;

                        std::cout << "Extracted mesh has : " << temp2->GetNumberOfCells() << "
cells and " << temp2->GetNumberOfPoints() << " points" << std::endl;


My output is :

Removing 216 points on boundary
Before mesh has : 125688 cells and 62941 points
Extracted mesh has : 0 cells and 62725 points






--
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