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>
<br>
public void open(String fileName)<br>
{<br>
renderer = renWin.GetRenderer();<br>
renderer.RemoveActor(actor);<br>
renderer.SetBackground(0.1, 0.2, 0.4);<br>
<span style="color: rgb(51, 102, 255);"> renderer.ResetCameraClippingRange();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> renderer.ResetCamera();</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);"> renderer.InteractiveOff();</span><br>
<br>
this.validate(); <span style="color: rgb(51, 204, 0);">//extends JPanel</span><br>
this.repaint();<br>
renWin.validate();<br>
renWin.repaint();<br>
<br>
vtkSTLReader reader = new vtkSTLReader();<br>
reader.SetFileName(fileName);<br>
<br>
vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>
mapper.SetInput(reader.GetOutput());<br>
<br>
actor = new vtkActor();<br>
actor.SetMapper(mapper);<br>
<br>
renderer.AddActor(actor);<br>
}<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> <<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>> 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>"renWin.GetRenderer().RemoveActor(actor);" 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>><br>> hi all,<br>><br>> i'm newbie in VTK. now i'm using java.1.5 and vtk4.2 for my application.<br>> i have problem when rendering the STL file.<br>> first, i using GUI to select the STL file,<br>
> private void openActionPerformed(java.awt.event.ActionEvent evt) {<br>> // TODO add your handling code here:<br>> JFileChooser chooser = new JFileChooser();<br>> chooser.showOpenDialog(this);
<br>><br>> File file = chooser.getSelectedFile();<br>> if(file != null)<br>> {<br>> String fileName = file.getPath();<br>><br>> mainPanel.open(fileName);
<br>> //System.out.println(fileName);<br>> }<br>> }<br>><br>> and then mainPanel, which is using vtkPanel to render the STL,<br>> public void open(String fileName)<br>> {<br>
> //this.setLayout(new BorderLayout());<br>> vtkSTLReader reader = new vtkSTLReader();<br>> reader.SetFileName(fileName);<br>> //System.out.println("dalam fungsi" + fileName);
<br>><br>> vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>> mapper.SetInput(reader.GetOutput());<br>><br>> vtkActor actor = new vtkActor();<br>> actor.SetMapper(mapper);
<br>><br>> //renWin.GetRenderer().AddActor(actor);<br>> renWin.GetRenderer().AddActor(actor);<br>><br>> renWin.validate();<br>> renWin.repaint();<br>> }<br>><br>> when i try to open the STL file, it's fine.
<br>> but the problem comes when i try to open other STL file.<br>> the first STL image don't changed with the second STL image, but they<br>> together in one window.<br>> how to make the second STL image replacing the first STL image?
<br>><br>> thank's for your responese..<br>><br>> --<br>> --Y!M: ekaditya<br>><br>>------------------------------------------------------------------------<br>><br>>_______________________________________________
<br>>This is the private VTK discussion list.<br>>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>>Follow this link to subscribe/unsubscribe:
<br>><a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>><br>><br><br></blockquote></div><br><br clear="all"><br>-- <br>--Y!M: ekaditya