Picking in the vtkScene

25 views
Skip to first unread message

Guillaume Stuber

unread,
May 26, 2011, 12:45:29 PM5/26/11
to fw4spl-discuss
Hello,

I have created an adaptor to manipulate the scene. What is the easiest
way to select an actor (pick it) at the coordinates I specify ?

Thank you,

GS.

Nicolasph

unread,
May 27, 2011, 10:29:57 AM5/27/11
to fw4spl-discuss

Guillaume Stuber

unread,
Jun 1, 2011, 5:29:20 AM6/1/11
to fw4spl-discuss
Hello,

Thank you for this answer, I now have a good picking.
Nevertheless I cannot use the IVtkAdaptorService::getAssociatedObject
method, because it search the object associated to the adaptator that
created the vtkActor/vtkProp among the m_subServices of the current
adaptator. However my adaptor don't have any m_subServices. This
method would work if I was in the adaptor Acquisition for example, but
not in mine (I may be mistaken).
In that case how can I still get this object (from my vtkActor)?

Thank you,

Guillaume.

On 27 mai, 16:29, Nicolasph <nicola...@gmail.com> wrote:
> Hello,
>
> There are actually several examples of how to manage picking within
> adaptors :
>
> http://code.google.com/p/fw4spl/source/browse/Bundles/LeafVisu/visuVT...http://code.google.com/p/fw4spl/source/browse/Bundles/LeafVisu/visuVT...http://code.google.com/p/fw4spl/source/browse/Bundles/LeafVisu/visuVT...http://code.google.com/p/fw4spl/source/browse/Bundles/LeafVisu/visuVT...http://code.google.com/p/fw4spl/source/browse/Bundles/LeafVisu/visuVT...

Nicolas P

unread,
Jun 1, 2011, 6:30:04 AM6/1/11
to fw4spl-...@googlegroups.com
Hello,

In your own adaptor, you need to register the actors you created. This is automatically done if you use the IVtkAdaptor::addToRenderer method, otherwise you need to call this method : IVtkAdaptor::registerProp(yourActor)

Cheers,
Nicolas

2011/6/1 Guillaume Stuber <guillaum...@gmail.com>

Guillaume Stuber

unread,
Jun 1, 2011, 9:13:41 AM6/1/11
to fw4spl-discuss
In my adaptor, I do not create any actors. I get an actor with the
picking, using the picker whose id is specified in the plugin.xml(and
that picked actor has been created by the TriangularMesh adaptor I
suppose).
And this is maybe the best solution: I may pass the id of the
acquisition adaptor service to my own adaptor directly in the
plugin.xml that defines my application.
Is this the only solution ?

Guillaume.



On 1 juin, 12:30, Nicolas P <nicola...@gmail.com> wrote:
> Hello,
>
> In your own adaptor, you need to register the actors you created. This is
> automatically done if you use the IVtkAdaptor::addToRenderer method,
> otherwise you need to call this method
> : IVtkAdaptor::registerProp(yourActor)
>
> Cheers,
> Nicolas
>
> 2011/6/1 Guillaume Stuber <guillaume.stu...@gmail.com>
>
>
>
>
>
>
>
> > Hello,
>
> > Thank you for this answer, I now have a good picking.
> > Nevertheless I cannot use the IVtkAdaptorService::getAssociatedObject
> > method, because it search the object associated to the adaptator that
> > created the vtkActor/vtkProp among the m_subServices of the current
> > adaptator. However my adaptor don't have any m_subServices. This
> > method would work if I was in the adaptor Acquisition for example, but
> > not in mine (I may be mistaken).
> > In that case how can I still get this object (from my vtkActor)?
>
> > Thank you,
>
> > Guillaume.
>
> > On 27 mai, 16:29, Nicolasph <nicola...@gmail.com> wrote:
> > > Hello,
>
> > > There are actually several examples of how to manage picking within
> > > adaptors :
>
> >http://code.google.com/p/fw4spl/source/browse/Bundles/LeafVisu/visuVT....
> > ..

Nicolas P

unread,
Jun 1, 2011, 9:45:22 AM6/1/11
to fw4spl-...@googlegroups.com
If i understand, you need to know which data is directly associated to the vtkActor you have picked. Currently, getAssociatedObject return the object responsible of the creation of the actor (i.e. for a vtkActor from a TriangularMeshAdaptor, it could be a TriangularMesh, as well as a Reconstruction or an Acquisition.). To have the two behaviour, you will have to update the getAssociatedObject method. If you're interested into writing a patch about that, i will gladly apply it on fw4spl.

Your second solution (ID in the configuration) : it is possible if you know before runtime the service you are interested in. But your problem doesn't seems to match this case.

Cheers,
Nicolas

 

2011/6/1 Guillaume Stuber <guillaum...@gmail.com>

Guillaume Stuber

unread,
Jun 8, 2011, 4:25:17 AM6/8/11
to fw4spl-discuss
Hello,

I don't think I have understood the modifications I have to do in the
getAssociatedObject function.
I try the second one. Here is the generic scene in my plugin.xml:

plugin.xml-------------------------------------------------------------------------------------

<service uid="genericScene"
implementation="::fwRenderVTK::VtkRenderService"
type="::fwRender::IRender" autoComChannel="yes">
<scene>

<picker id="myPicker" vtkclass="fwVtkCellPicker" />

<renderer id="default" background="0.0" />

<adaptor id="myRenderAdaptor" class="::visuVTKAdaptor::Render"
objectId="self">
<config renderer="default" picker="" />
</adaptor>

<adaptor id="myAcquisitionAdaptor"
class="::visuVTKAdaptor::Acquisition" objectId="myAcquisition">
<config renderer="default" picker="myPicker" />
</adaptor>

...

<adaptor id="kinectAdaptator" class="::opKinect::KinectInteractor"
objectId="myAcquisition" >
<config renderer="default" picker="myPicker"
acquisition="myAcquisitionAdaptor" />
</adaptor>

</scene>
-----------------------------------------------------------------------------------------------

I try here to get the AcquisitionAdaptorID in my own adaptor,
KinectInteractor. In its configuring method, I get this ID well. But
in my update method, when I want to have the true service with this
ID, It doesn't exists. That is how I verify this :

-----------------------------------------------------------------------------------------------
bool srv_exists = ::fwTools::fwID::exist(this->m_acquisitionId);
if(srv_exists){
::fwServices::IService::sptr service = ::fwServices::get(this-
>m_acquisitionId);
::visuVTKAdaptor::Acquisition::sptr acq
= ::boost::dynamic_pointer_cast< visuVTKAdaptor::Acquisition
>(service);
}
-----------------------------------------------------------------------------------------------

Why this service doesn't exist ?

Thank you :),

Guillaume.

On 1 juin, 15:45, Nicolas P <nicola...@gmail.com> wrote:
> If i understand, you need to know which data is directly associated to the
> vtkActor you have picked. Currently, getAssociatedObject return the object
> responsible of the creation of the actor (i.e. for a vtkActor from a
> TriangularMeshAdaptor, it could be a TriangularMesh, as well as a
> Reconstruction or an Acquisition.). To have the two behaviour, you will have
> to update the getAssociatedObject method. If you're interested into writing
> a patch about that, i will gladly apply it on fw4spl.
>
> Your second solution (ID in the configuration) : it is possible if you know
> before runtime the service you are interested in. But your problem doesn't
> seems to match this case.
>
> Cheers,
> Nicolas
>
> 2011/6/1 Guillaume Stuber <guillaume.stu...@gmail.com>

Guillaume Stuber

unread,
Jun 8, 2011, 4:38:32 AM6/8/11
to fw4spl-discuss
I saw that when I run the application, the acquisition Id is
"::visuVTKAdaptor::Acquisition-0". Why is this ID not the one I
specified in the plugin.xml ?

Again, thanks for your help,

Guillaume.

Nicolas P

unread,
Jun 8, 2011, 6:04:13 AM6/8/11
to fw4spl-...@googlegroups.com
Hello,

The "id" attribute is a scene internal identifier. That mean that you can use the same id in several scenes. If you want to define a fwID, you will have to use the 'uid' attribute.

Cheers,
Nicolas

2011/6/8 Guillaume Stuber <guillaum...@gmail.com>
Reply all
Reply to author
Forward
0 new messages