[vtkusers] Read 1 STL file containing multiple STL objects.
Mark Hervagault
mark.hervagault at gmail.com
Fri Jun 6 04:37:44 EDT 2014
Hi,
I search how to read a STL file that contains 2 STL files. Let me explain
...
I created a STL file of 2 STL file (porsche.stl + peace.stl) with Meshlab.
*Problem:*
With my code, I can read my stl file. But I view only my first stl file:
porsche.stl.
Can you help me visualize my two STL components?
After, I would separate them from each other to change their colors, etc...
but that's for later.
*My STL file:*
fichier.7z <http://vtk.1045678.n5.nabble.com/file/n5727364/fichier.7z>
*My code:*
package testvtk;
import vtk.vtkActor;
import vtk.vtkNativeLibrary;
import vtk.vtkSTLReader;
import vtk.vtkPolyDataMapper;
import vtk.vtkRenderWindow;
import vtk.vtkRenderWindowInteractor;
import vtk.vtkRenderer;
public class NewMain1 {
// Chargement des librairies
static {
if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {
if (!lib.IsLoaded()) {
System.out.println(lib.GetLibraryName() + " not
loaded");
}
}
}
vtkNativeLibrary.DisableOutputWindow(null);
}
public static void main(String[] args) {
// import du fichier stl
vtkSTLReader reader = new vtkSTLReader();
reader.SetFileName("fichier.stl");
reader.Update();
//Visualisation
vtkPolyDataMapper mapper = new vtkPolyDataMapper();
mapper.SetInputConnection(reader.GetOutputPort(0));
vtkActor actor = new vtkActor();
actor.SetMapper(mapper);
vtkRenderer renderer = new vtkRenderer();
vtkRenderWindow renderWindow = new vtkRenderWindow();
renderWindow.AddRenderer(renderer);
vtkRenderWindowInteractor renderWindowInteractor = new
vtkRenderWindowInteractor();
renderWindowInteractor.SetRenderWindow(renderWindow);
renderer.AddActor(actor);
renderer.SetBackground(.3, .6, .3);
renderer.ResetCamera();
renderWindow.Render();
renderWindowInteractor.Start();
}
}
--
View this message in context: http://vtk.1045678.n5.nabble.com/Read-1-STL-file-containing-multiple-STL-objects-tp5727364.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list