Hello everyone.
I’m encountering an issue with vtkTextureMapToPlane. When I map the texture image onto my STL model, some of the dots in the texture get resized. Since the next step is to obtain the corresponding color values of the points, I would like to ensure that these dots retain their shape, even on the curved surfaces of the model. Is this a difficult problem to address? Below are my texture image, test code, and the result.
reader = vtk.vtkSTLReader()
reader.SetFileName("model.stl")
reader.Update()
texturemap = vtk.vtkTextureMapToPlane()
texturemap.SetInputData(reader.GetOutput())
texturemap.Update()
texture = vtk.vtkTexture()
image_reader = vtk.vtkJPEGReader()
image_reader.SetFileName("texture.jpg")
image_reader.Update()
texture.SetInputConnection(image_reader.GetOutputPort())
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(texturemap.GetOutput())
mapper.Update()
actor = vtk.vtkActor()
actor.SetMapper(mapper)
actor.SetTexture(texture)
renderer = vtk.vtkRenderer()
renderer.SetBackground(*[128,128,128])
renderer.SetBackground2(*[128,128,128])
renderer.GradientBackgroundOn()
renderer.AddActor(actor)
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
render_window_interactor = vtk.vtkRenderWindowInteractor()
render_window_interactor.SetRenderWindow(render_window)
render_window.Render()
render_window_interactor.Start()
best regards