Hello David and Prabhath,<br>
thank you so much for your response. :))<br>
<br>
the problem with image STL file done, which is the second STL image replacing the first STL image.<br>
so there is olny one object in window, but there's antoher problem raising, the camera is still following the first STL image.<br>
i mean, when i interact with the second STL image, the first STL image is still there.<br>
the fisrt STL image only cleared to the background color.. :(<br>
<br>
i already try to use following code, hopefully it will reset the camera, and turn it to the second STL image..<br>
&nbsp;<br>
public void open(String fileName)<br>
&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer = renWin.GetRenderer();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.RemoveActor(actor);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.SetBackground(0.1, 0.2, 0.4);<br>
<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.ResetCameraClippingRange();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.ResetCamera();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.InteractiveOff();</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.validate(); <span style="color: rgb(51, 204, 0);">//extends JPanel</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.repaint();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.validate();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renWin.repaint();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSTLReader reader = new vtkSTLReader();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader.SetFileName(fileName);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mapper.SetInput(reader.GetOutput());<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; actor = new vtkActor();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; actor.SetMapper(mapper);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; renderer.AddActor(actor);<br>
&nbsp;&nbsp; }<br>
<br>
is there any way, so that the second STL file replacing first STL image, and the camara also?<br>
<br>
thanks for your response..<br>
<br>On 7/26/05, <b class="gmail_sendername">David Cole</b> &lt;<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Save a reference to the actor and then call<br>&quot;renWin.GetRenderer().RemoveActor(actor);&quot; to get rid of it prior to<br>adding the actor for the second file. RemoveActor is the inverse of<br>AddActor.<br><br>ekaditya wrote:
<br><br>&gt;<br>&gt; hi all,<br>&gt;<br>&gt; i'm newbie in VTK. now i'm using java.1.5 and vtk4.2 for my application.<br>&gt; i have problem when rendering the STL file.<br>&gt; first, i using GUI to select the STL file,<br>
&gt;&nbsp;&nbsp;private void openActionPerformed(java.awt.event.ActionEvent evt) {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; // TODO add your handling code here:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JFileChooser chooser = new JFileChooser();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chooser.showOpenDialog(this);
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; File file = chooser.getSelectedFile();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(file != null)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String fileName = file.getPath();<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mainPanel.open(fileName);
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //System.out.println(fileName);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&gt;<br>&gt; and then mainPanel, which is using vtkPanel to render the STL,<br>&gt;&nbsp;&nbsp;public void open(String fileName)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;{<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//this.setLayout(new BorderLayout());<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vtkSTLReader reader = new vtkSTLReader();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader.SetFileName(fileName);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//System.out.println(&quot;dalam fungsi&quot; + fileName);
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mapper.SetInput(reader.GetOutput());<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vtkActor actor = new vtkActor();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;actor.SetMapper(mapper);
<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//renWin.GetRenderer().AddActor(actor);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;renWin.GetRenderer().AddActor(actor);<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;renWin.validate();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;renWin.repaint();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&gt;<br>&gt; when i try to open the STL file, it's fine.
<br>&gt; but the problem comes when i try to open other STL file.<br>&gt; the first STL image don't changed with the second STL image, but they<br>&gt; together in one window.<br>&gt; how to make the second STL image replacing the first STL image?
<br>&gt;<br>&gt; thank's for your responese..<br>&gt;<br>&gt; --<br>&gt; --Y!M: ekaditya<br>&gt;<br>&gt;------------------------------------------------------------------------<br>&gt;<br>&gt;_______________________________________________
<br>&gt;This is the private VTK discussion list.<br>&gt;Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;Follow this link to subscribe/unsubscribe:
<br>&gt;<a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;<br>&gt;<br><br></blockquote></div><br><br clear="all"><br>-- <br>--Y!M: ekaditya