Dear All,
Has VTK, support to load and display an OBJ file (color vectorial image, extension .obj with .mtl and .png files)?
Can you please provide a link for an example code?
Thanks,
Luís Gonçalves
Dear All,
Has VTK, support to load and display an OBJ file (color vectorial image, extension .obj with .mtl and .png files)?
Can you please provide a link for an example code?
Thanks,
Luís Gonçalves
https://kitware.github.io/vtk-examples/site/Cxx/IO/OBJImporter/
Alternativaly, you can use F3D directly: F3D
Dear All,
I translated the following example to Python:
https://kitware.github.io/vtk-examples/site/Cxx/IO/OBJImporter/
And gives the following error:
( 166.199s) [paraview ] vtkOBJImporter.cxx:843 ERR| vtkOBJPolyDataProcessor (0x28763c0): material ‘material_0’ appears in OBJ but not MTL file?
( 167.862s) [paraview ] vtkOBJImporter.cxx:843 ERR| vtkOBJPolyDataProcessor (0x28763c0): material ‘“material_1”’ appears in OBJ but not MTL file?
#file .mtl
newmtl material_0
Ka 1 1 1
Kd 1 1 1
Ks 1 1 1
Ns 1000
map_Kd output1_1.png
newmtl material_1
Ka 1 1 1
Kd 1 1 1
Ks 1 1 1
Ns 1000
#File .Obj
mtllib output1.mtl
o Copy of Sharp fusion 1
v -157.45563 -18.5831 220.40683
usemtl material_0
vt 0.087013 0.803479
f 6256/1 6257/2 6253/3
usemtl “material_1”
Result (appears without the textures) I suppose in error:
This within example “web-project-templates-master” with Paraview Python.
Thanks,
Luís Gonçalves
please share your data.
importer=vtk.vtkOBJImporter()
importer.SetFileName(path1+file8+'.obj');
#importer.SetFileNameMTL(path1+file4+'.mtl');
#importer.SetTexturePath(path1+file9+'.png');
colors=vtk.vtkNamedColors()
#vtkNew<vtkRenderer> renderer;
#vtkNew<vtkRenderWindow> renWin;
#vtkNew<vtkRenderWindowInteractor> iren;
renderer.SetBackground2(colors.GetColor3d("Silver"))
renderer.SetBackground(colors.GetColor3d("Gold"))
renderer.GradientBackgroundOn()
renderWindow.Modified()
#renWin->AddRenderer(renderer);
renderer.UseHiddenLineRemovalOn()
renderWindow.Modified()
#renWin->AddRenderer(renderer);
renderWindow.SetSize(640, 480);
#renWin->SetWindowName("OBJImporter");
#iren->SetRenderWindow(renWin);
importer.SetRenderWindow(renderWindow);
importer.Update()
actors = renderer.GetActors()
actors.InitTraversal()
#std::cout << "There are " << actors->GetNumberOfItems() << " actors"
# << std::endl;
for a in range(actors.GetNumberOfItems()):
actor =vtk.vtkActor()
actor=actors.GetNextActor()
if (actor.GetTexture()):
actor.GetTexture().InterpolateOn()
pd =vtk.vtkPolyData(actor.GetMapper().GetInput())
mapper =vtk.vtkPolyDataMapper(actor.GetMapper())
mapper.SetInputData(pd)
renderWindow.SetSize(640, 480); has no effect.
please share your data.
I reproduce the issue, but more investigation is needed to understand where this is coming from.
Solved:
Changed:
importer.SetFileName(path1+file8+'.obj')
importer.SetFileNameMTL(path1+file4+'.mtl')
importer.SetTexturePath(path1)
The code works like this (I removed the redundant code).
self.importer=vtk.vtkOBJImporter()
self.importer.SetFileName(path1+file8+'.obj')
self.importer.SetFileNameMTL(path1+file4+'.mtl')
self.importer.SetTexturePath(path1)#+file9+'.png')
colors=vtk.vtkNamedColors()
renderer.SetBackground2(colors.GetColor3d("Silver"))
renderer.SetBackground(colors.GetColor3d("Gold"))
renderer.GradientBackgroundOn()
renderWindow.Modified()
renderer.UseHiddenLineRemovalOn()
self.importer.SetRenderWindow(renderWindow);
self.importer.Update()
How I remove the picture from the screen?
I tried
self.importer.RemoveRenderWindow(renderWindow);
but do not works.
This thread is still open.
I only want to remove this “volume” from the screen. But it is not a volume, I suppose.
Can anyone help?
Thanks.
What do you mean by removing the picture? Clearing the render window to the background?
Yes, clearing the render window. Of that image in particular.
you can try to learn the c++ demo, which is easy to translate it to python. it shows how to get the actor and mapper of the import.
https://examples.vtk.org/site/Cxx/IO/OBJImporter/