[vtk-developers] VtkLineWidget2 InteractionEvent distance
carlinhos
carlinhosmp87 at gmail.com
Wed Jul 16 11:14:32 EDT 2014
Hello,
I'm developing an app to measure the euclidean distance from a 3D point on
the surface of an object to another and show the distance with a line.
To accomplish that, i use *vtkLineWidget2 *with the representation
associated. First time i place it , it shows correctly fit on the surface of
the sphere (or any other object i place into the render window). But when
i'm moving the widget from one of the handler points of the
*vtkLineRepresentation *, it doesn't put the point on the surface of the
sphere. The method i use sometimes work, sometimes not.
I'm getting the pick every time the *vtkLineWidget2 *throws an Interaction
event, and getting the 3d point of the picked position to set it to the
selected handler of the *vtkLineRepresentation *. Sometimes it works, but
other times, it shows the border of the *vtkLineRepresentation *in a wrong
place (its correctly situated where i picked, but not on the surface of the
object). It seems random to me when it works or not.
I paste the code i call when the Interaction Event of the Widget is thrown.
*///If the selected point is the 1st
if ( state == vtkLineRepresentation::OnP1 ) {
this->m_rwi->GetPicker()->Pick(m_rwi->GetLastEventPosition()[0],
m_rwi->GetLastEventPosition()[1],
0, // always zero.
this->m_rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double picked[3];
this->m_rwi->GetPicker()->GetPickPosition(picked);
lineRepresentation->SetPoint1WorldPosition(picked);
}
//If the selected point is the 2nd
else if (state == vtkLineRepresentation::OnP2) {
this->m_rwi->GetPicker()->Pick(m_rwi->GetLastEventPosition()[0],
m_rwi->GetLastEventPosition()[1],
0,
this->m_rwi->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
double picked[3];
this->m_rwi->GetPicker()->GetPickPosition(picked);
lineRepresentation->SetPoint2WorldPosition(picked);
}/*
Does anyone know why is not working in all the cases?
Thanks in advance.
--
View this message in context: http://vtk.1045678.n5.nabble.com/VtkLineWidget2-InteractionEvent-distance-tp5727880.html
Sent from the VTK - Dev mailing list archive at Nabble.com.
More information about the vtk-developers
mailing list