Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Camera object with vtki.texture_map_to_plane #121

Closed
ljc19800331 opened this issue Mar 9, 2019 · 3 comments
Closed

Camera object with vtki.texture_map_to_plane #121

ljc19800331 opened this issue Mar 9, 2019 · 3 comments
Labels
question How do I....?

Comments

@ljc19800331
Copy link

ljc19800331 commented Mar 9, 2019

Hello, I am using the vtki for texture mapping and I also want to use the vtk.camera object with vtki. I have some questions:

  1. Is it possible to use vtki as regular vtk.polydata for texture mapping? I tried but it is showing a white board. My final goal is to capture the textured image from different camera position and focal length.
  2. Is there a more convenient way to build relation between the vtk and vtki package? I try extract the data from vtki object but it seems difficult.

Here is my code for texture mapping and the change of the camera position:

texture = vtki.load_texture(img_path)
obj = vtki.read(stl_path)
obj.texture_map_to_plane(inplace=True)
Mapper = vtk.vtkPolyDataMapper()
Mapper.SetInputData(obj)
Actor = vtk.vtkActor()
Actor.SetMapper(Mapper)

renderer = vtk.vtkRenderer()
renderer.AddActor(Actor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(renderer)

// The camera position code

iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

renWin.Render()
iren.Start()

@akaszynski
Copy link
Member

Can you upload the stl and texture? This would help me in debugging why the texture isn't plotting.

As for the camera and plotting code, you can use vtki to streamline the plotting:

import vtki
texture = vtki.load_texture(img_path)
obj = vtki.read(stl_path)
obj.texture_map_to_plane(inplace=True)

# create a plotter object to handle visualization
plotter = vtki.Plotter()
plotter.add_mesh(obj)

# grab the camera object
camera = plotter.camera  # vtkRenderingOpenGL2Python.vtkOpenGLCamera object
# your camera code follows

plotter.show()

@banesullivan
Copy link
Member

@banesullivan banesullivan added the question How do I....? label Mar 12, 2019
@ljc19800331
Copy link
Author

My problem is solved. Thanks.

@pyvista pyvista locked and limited conversation to collaborators Jun 22, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question How do I....?
Projects
None yet
Development

No branches or pull requests

3 participants