<div class="gmail_quote"><div>Hi Jochen,</div><div>  Why don&#39;t you add this to the wikiexamples (<a href="http://www.vtk.org/Wiki/VTK/Examples">http://www.vtk.org/Wiki/VTK/Examples</a>)?</div><div>One small suggestion I would make is to use vtkSmartPointer throughout your code.</div>
<div>e,g vtkSmartPointer&lt;<span style="font-family:Consolas">vtkSphereSource</span>&gt; <span style="font-family:Consolas">sphere</span><span style="font-family:Consolas"> </span>vtkSmartPointer&lt;<span style="font-family:Consolas">vtkSphereSource</span>&gt;::New();</div>

<div>but not for </div><div>  vtkSphereSource *src = vtkSphereSource::SafeDownCast(algo);</div><div><br></div><div>In this way clean-up is automatically performed when the objects go out of scope, so -&gt;Delete();; is not needed.</div>

<div><br></div><div>I could then make a Python equivalent for the wikiexamples.</div><div><br></div><div>Regards</div><div>  ANdrew</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

---------- Forwarded message ----------<br>From: &quot;Jochen K.&quot; &lt;<a href="mailto:jochen.kling@email.de" target="_blank">jochen.kling@email.de</a>&gt;<br>To: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>
Cc: <br>Date: Wed, 6 Jun 2012 10:23:45 -0700 (PDT)<br>
Subject: Re: [vtkusers] what&#39;s the difference between actor &#39;s position and sphere &#39;s center ?<br>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" 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>
</p></font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkSphereSource.h&gt;<br>
</font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkPolyDataMapper.h&gt;<br>
</font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkRenderWindow.h&gt;<br>
</font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkCamera.h&gt;<br>
</font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkActor.h&gt;<br>
</font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkRenderer.h&gt;
</font><font face="Consolas"></font>
<font face="Consolas" color="#008000">
<p>// additional needed vtk header for this example<br>
</p></font><font face="Consolas" color="#0000ff">#include</font><font face="Consolas">
</font><font face="Consolas" color="#a31515">&lt;vtkAlgorithmOutput.h&gt;
</font><font face="Consolas"></font>
<font face="Consolas" color="#0000ff">
<p>#define</p></font><font face="Consolas"> PI 3.14159265
</font><font face="Consolas" color="#0000ff">
<p>int</p></font><font face="Consolas"> main() {<br>
</font><font face="Consolas" color="#008000">  // source<br>
</font><font face="Consolas">  vtkSphereSource *sphere = 
vtkSphereSource::New();<br>
  sphere-&gt;SetRadius( 1.0 );<br>
</font><font face="Consolas" color="#008000">  // mapper<br>
  </font><font face="Consolas">vtkPolyDataMapper *sphereMapper = 
vtkPolyDataMapper::New();<br>
  sphereMapper-&gt;SetInputConnection( sphere-&gt;GetOutputPort() );<br>
  </font><font face="Consolas" color="#008000">// actor<br>
  </font><font face="Consolas">vtkActor *sphereActor = 
vtkActor::New();<br>
  sphereActor-&gt;SetMapper( sphereMapper );<br>
  </font><font face="Consolas" color="#008000">//renderer<br>
  </font><font face="Consolas">vtkRenderer *ren1 = 
vtkRenderer::New();<br>
  ren1-&gt;SetBackground( 0.1, 0.2, 0.4 );<br>
  vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
  renWin-&gt;AddRenderer( ren1 );<br>
  renWin-&gt;SetSize( 300, 300 );<br>
  </font><font face="Consolas" color="#008000">// add actor to the 
renderer<br>
  </font><font face="Consolas">ren1-&gt;AddActor( sphereActor );<br>
  </font><font face="Consolas" 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">vtkAlgorithm *algo = 
sphereActor-&gt;GetMapper()-&gt;GetInputConnection(0, 0)-&gt;GetProducer();<br>
  vtkSphereSource *src = vtkSphereSource::SafeDownCast(algo);</font></b><br><br>
<font face="Consolas" color="#0000ff">  float</font><font face="Consolas"> 
origRadius = src-&gt;GetRadius();<br>
</font><font face="Consolas" color="#0000ff">  int</font><font face="Consolas"> 
i;<br>
</font><font face="Consolas" color="#0000ff">  for</font><font face="Consolas"> 
(i = 0; i &lt; 360; ++i) {<br>
    src-&gt;SetRadius(origRadius * (1 + sin((</font><font face="Consolas" color="#0000ff">float</font><font face="Consolas">)i/180.0 
* PI)));<br>
    renWin-&gt;Render();&#39;<br>
  }<br>
  </font><font face="Consolas" 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">sphere-&gt;Delete();<br>
  sphereMapper-&gt;Delete();<br>
  sphereActor-&gt;Delete();<br>
  ren1-&gt;Delete();<br>
  renWin-&gt;Delete();<br>
</font><font face="Consolas" color="#008000">  // dont&#39;t do that, 
cause src is just a reference<br>
  // src-&gt;Delete();<br>
</font><font face="Consolas" color="#0000ff">  return</font><font face="Consolas"> 
0;<br>
}
</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" target="_blank">Re: what&#39;s the difference between actor &#39;s position and sphere &#39;s center ?</a><br>


Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" target="_blank">VTK - Users mailing list archive</a> at Nabble.com.<br><br><br></blockquote></div><div><br></div>-- <br>___________________________________________<br>

Andrew J. P. Maclean<br><br>___________________________________________<br>