[vtkusers] vtkOBBTree and vtkActor

Sergio Aguirre sergio.aguirre at gmail.com
Mon Mar 21 18:18:51 EDT 2011


Hi everyone ...

Just seems simpler to test for a point based on a boundingbox...

Sergio

vtkBoundingBox tBox;
iter = vtkCollectionIterator::New();
iter->SetCollection(actrList);
iter->InitTraversal();

int c = 0; // counter to change state
int poked = -1; // actor poked
double bounds[6];

while ( !iter->IsDoneWithTraversal() )
{
vtkActor* tmp_actr = (vtkActor*) iter->GetCurrentObject();
tmp_actr->GetBounds(bounds);
tBox.SetBounds(bounds);

if ( tBox.ContainsPoint(lasserP2) == 1 )
{
poked = c;
break;
}

iter->GoToNextItem();
c++;
}

iter->Delete();

return poked;

On Mon, Mar 21, 2011 at 1:11 PM, Sergio Aguirre <sergio.aguirre at gmail.com>wrote:

> Hi everyone
>
> I am trying to have some interaction between a tracked pointer and
> vtkActors in a scene.
>
> My actors are simple objects I call like vtkConeSource, vtkPolyDataMapper
> and vtkActor.
>
> Basically I am building a line using vtkLineSource and testing if the line
> intersects any actors in my scene with vtkOBBTree using the code below.
>
> tBox = vtkOBBTree::New();
>  iter = vtkCollectionIterator::New();
> iter->SetCollection(actrList);
> iter->InitTraversal();
>
> int c = 0; // counter to change state
> int poked = -1; // actor poked
>
> while ( !iter->IsDoneWithTraversal() )
> {
> vtkActor* tmp_actr = (vtkActor*) iter->GetCurrentObject();
>  tmp_actr->GetMapper()->GetInput()->Update(); // update the object
> tBox->SetDataSet( tmp_actr->GetMapper()->GetInput() );
>  tBox->BuildLocator();
>
> if( tBox->IntersectWithLine(lasserP1, lasserP2, NULL, NULL) != 0 )
>  {
> poked = c;
> break;
>  }
>
> iter->GoToNextItem();
> c++;
>  }
>
> However, because the vtkOBBTree tests against vtkDataSet (ie vtkConeSource)
> the new (translated or rotated) coordinates are not updated when I test the
> intersection again.
>
> As far as I can tell I would need to update the 'center' of the vtkDataSet
> downstream from the vtkActor...
>
> I hope anyone can share any suggestions.
>
> Sergio
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110321/d5eecd36/attachment.htm>


More information about the vtkusers mailing list