[vtkusers] vtkSelection with GLOBALIDS, vtkExtractSelection returns empty

da xu remywendy at gmail.com
Wed Jul 8 19:30:00 EDT 2009


I still haven't figured this out.

When I look at my original datasets, I notice that the GlobalID array does
not exist. I assmed that when I used vtkPointPIcker (with x,y,z=1)
coordinates, vtkPointPicker::GetPointID() returns the global ID? I'm
guessing it isnt; however trying with INDICES and PEDIGREEID yeilded empty
extractions as well!

On Wed, Jul 8, 2009 at 12:46 AM, John Platt <jcplatt at dsl.pipex.com> wrote:

>  Hi,
>
> Try changing your selection array from vtkIntArray to vtkIdTypeArray and
> check that the filters copy the GLOBALIDS (the default is not to copy or
> interpolate).
>
> John.
>
> ----- Original Message -----
> *From:* da xu <remywendy at gmail.com>
> *To:* vtkusers at vtk.org
> *Sent:* Wednesday, July 08, 2009 8:12 AM
> *Subject:* [vtkusers] vtkSelection with GLOBALIDS,vtkExtractSelection
> returns empty
>
> Hey all,
>
> I am trying to extract a section of my datasets using vtkSelection. I
> currently have a GUI that the user clicks on to select a start and end point
> using vtkPointPicker, returning the PointID. With a starting POINTID and
> ending POINTID, i then use a vtkSelection with field type POINT, ContentType
> GLOBALIDS to extract a dataset containing the points (with
> vtkSelectionNode's SetSelectionList correctly set I believe). However, I
> always end up extracting an empty grid.
>
> I can't figure out if:
>  My vtkSelectionNode is set up incorrectly
>  I'm using vtkExtractSelection incorrectly.
>  The vtkPointPicker doesnt actually get GLOBALIDS ?
>  Missing an update somewhere?
>
> Here is the code:
>
> // Set up vtkSelectionNode
>     vtkSelection* selection = vtkSelection::New();
>     vtkSelectionNode* selectionNode = vtkSelectionNode::New();
>     selectionNode->SetFieldType( vtkSelectionNode::POINT);
>     selectionNode->SetContentType(vtkSelectionNode::GLOBALIDS);
>
> // Populate the selection node with our GLOBALIDS (obtained from
> vtkPointPicker)
>     vtkIntArray* intarray = vtkIntArray::New();
>     for (int a = first; a < second; a++)
>     {
>         intarray->InsertNextValue(a);
>     }
>     selectionNode->SetSelectionList(intarray);
>     selection->AddNode(selectionNode);
>
> // Some setup stuff, Our source data is from a multiblock data set
>     vtkMultiBlockDataSet *extractFrom = vtkMultiBlockDataSet::SafeDownCast(
> m_v_modules.at(0)->getDataObject());
>     int nblocks = extractFrom->GetNumberOfBlocks();
>
>     vtkGeometryFilter *filter = vtkGeometryFilter::New();
>     vtkDataSetMapper *mapper = vtkDataSetMapper::New();
>     int counter=0;
>     vtkExtractSelection* extractSelection = vtkExtractSelection::New();
>
> // Iterate through our datasets (structured grids) and apply
> vtkExtractSelection to them. Always extracts empty!
>     vtkCompositeDataIterator *iter = extractFrom->NewIterator();
>     iter->InitTraversal();
>
>     int totalpoints = 0;
>     while (!iter->IsDoneWithTraversal())
>     {
>         vtkDataSet* ds =
> vtkDataSet::SafeDownCast(iter->GetCurrentDataObject());
>         if (ds)
>         {
>             const char* name = ds->GetClassName();    /// Temp debugger
>             extractSelection->RemoveAllInputs();
>             extractSelection->SetInput(0, ds);    /// Set the vtkDataSet
> for extraction
>             extractSelection->SetInput(1, selection);    /// Set the
> vtkSelection for extraction
>             vtkDataObject* extracted = extractSelection->GetOutput();
>             extractSelection->Update();
>             const char* name2 = extracted->GetClassName();    /// Temp
> debugger
>
>             vtkUnstructuredGrid* unstructGridTest =
> vtkUnstructuredGrid::SafeDownCast(extracted);
>             int ntemp1 = unstructGridTest->GetNumberOfPoints();
>             totalpoints += ntemp1;
>             counter++;
>         }
>         iter->GoToNextItem();
>     }
>
> ------------------------------
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090708/973e77bd/attachment.htm>


More information about the vtkusers mailing list