Hi Yeonchool,<br /><br />
here is a complete example of how ro retrieve the source object from vtkActor reversely (relevant code lines are in bold):<br />
<font FACE="Consolas" SIZE="2" COLOR="#008000">
<p>//<br>
// This example demonstates how to access the source object reversely from the
actor.<br>
//<br>
// all the standard vtk headers<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkSphereSource.h><br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkPolyDataMapper.h><br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkRenderWindow.h><br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkCamera.h><br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkActor.h><br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkRenderer.h></p>
</font><font FACE="Consolas" SIZE="2"></font>
<font FACE="Consolas" SIZE="2" COLOR="#008000">
<p>// additional needed vtk header for this example<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">#include</font><font FACE="Consolas" SIZE="2">
</font><font FACE="Consolas" SIZE="2" COLOR="#a31515"><vtkAlgorithmOutput.h></p>
</font><font FACE="Consolas" SIZE="2"></font>
<font FACE="Consolas" SIZE="2" COLOR="#0000ff">
<p>#define</font><font FACE="Consolas" SIZE="2"> PI 3.14159265</p>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">
<p>int</font><font FACE="Consolas" SIZE="2"> main() {<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000"> // source<br>
</font><font FACE="Consolas" SIZE="2"> vtkSphereSource *sphere =
vtkSphereSource::New();<br>
sphere->SetRadius( 1.0 );<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000"> // mapper<br>
</font><font FACE="Consolas" SIZE="2">vtkPolyDataMapper *sphereMapper =
vtkPolyDataMapper::New();<br>
sphereMapper->SetInputConnection( sphere->GetOutputPort() );<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000">// actor<br>
</font><font FACE="Consolas" SIZE="2">vtkActor *sphereActor =
vtkActor::New();<br>
sphereActor->SetMapper( sphereMapper );<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000">//renderer<br>
</font><font FACE="Consolas" SIZE="2">vtkRenderer *ren1 =
vtkRenderer::New();<br>
ren1->SetBackground( 0.1, 0.2, 0.4 );<br>
vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
renWin->AddRenderer( ren1 );<br>
renWin->SetSize( 300, 300 );<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000">// add actor to the
renderer<br>
</font><font FACE="Consolas" SIZE="2">ren1->AddActor( sphereActor );<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000">//<br>
// Now we retrieve the source object from vtkActor reversely, loop over
360 degrees, <br>
// changes the radius of the spheresource and render the sphere each
time.<br>
//<br>
</font><b><font FACE="Consolas" SIZE="2">vtkAlgorithm *algo =
sphereActor->GetMapper()->GetInputConnection(0, 0)->GetProducer();<br>
vtkSphereSource *src = vtkSphereSource::SafeDownCast(algo);</b><br><br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff"> float</font><font FACE="Consolas" SIZE="2">
origRadius = src->GetRadius();<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff"> int</font><font FACE="Consolas" SIZE="2">
i;<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff"> for</font><font FACE="Consolas" SIZE="2">
(i = 0; i < 360; ++i) {<br>
src->SetRadius(origRadius * (1 + sin((</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff">float</font><font FACE="Consolas" SIZE="2">)i/180.0
* PI)));<br>
renWin->Render();'<br>
}<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000">//<br>
// Free up any objects we created. All instances in VTK are deleted by<br>
// using the Delete() method.<br>
//<br>
</font><font FACE="Consolas" SIZE="2">sphere->Delete();<br>
sphereMapper->Delete();<br>
sphereActor->Delete();<br>
ren1->Delete();<br>
renWin->Delete();<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#008000"> // dont't do that,
cause src is just a reference<br>
// src->Delete();<br>
</font><font FACE="Consolas" SIZE="2" COLOR="#0000ff"> return</font><font FACE="Consolas" SIZE="2">
0;<br>
}</p>
</font>
<br /><br />
with best regards<br />
Jochen
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/what-s-the-difference-between-actor-s-position-and-sphere-s-center-tp5713553p5713622.html">Re: what's the difference between actor 's position and sphere 's center ?</a><br/>
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br/>