vedo
vedo copied to clipboard
Vedo can not display point
from vedo import show,Points
import numpy as np
pts = np.random.randn(200, 3)
vpts = Points(pts).ps(10)
p = vpts.points()
p[0] = [5,5,4] # make this point stick out
vpts.points(p)
vpts.cmap('viridis', pts[:,2], name="mydata")
vpts.print()
show(vpts, axes=1).close()
cols = np.random.rand(200, 3)*255
cols[0] = [255,0,0]
show(vpts, axes=1).close()
I try to run this code from someone in the example project. However, it turn out NO POINTS appear. I am so confused and would like to let someone check for me.
@OhmPuchiss thanks for reporting! I have seen this problem once but I could not reproduce it... Can you try these tests, type in your terminal:
vedo
this should show your system specs, in my case:
then
import numpy as np
from vedo import show, Points
pts = np.random.randn(200, 3)
vpts = Points(pts).ps(10)
vpts.coordinates[0] = [5, 5, 4] # make this point stick out
vpts.cmap("viridis", pts[:, 2], name="mydata")
# vpts.print()
# show(vpts, axes=1).close()
import vtk
# FIRST TEST ################################
poly = vpts.dataset
# SECOND TEST ################################
# poly = vtk.vtkPolyData()
# points = vtk.vtkPoints()
# for i in range(100):
# points.InsertNextPoint(np.random.rand(3))
# poly.SetPoints(points)
# verts = vtk.vtkCellArray()
# for i in range(100):
# verts.InsertNextCell(1)
# verts.InsertCellPoint(i)
# poly.SetVerts(verts)
############################################
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
ren.SetBackground(0.1, 0.2, 0.4)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
actor = vtk.vtkActor()
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(poly)
mapper.SetScalarRange(poly.GetScalarRange())
actor.SetMapper(mapper)
actor.GetProperty().SetPointSize(10)
actor.GetProperty().RenderPointsAsSpheresOn() # try comment out this line
ren.AddActor(actor)
renWin.Render()
iren.Start()
the first test would show something like:
the second test (by uncommenting) would show this:
Sorry for the late reply, the problem is due to actor.GetProperty().RenderPointsAsSpheresOn()
.
Try:
vpts = Points(pts).ps(10).render_points_as_spheres(False)