Skip to content

Optimisation of point update in loop #501

Answered by marcomusy
jkissi asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, thanks for your nice words, the problem is that you recreate from scratch the whole Points object. I would it this way:

import vedo as ve
import numpy as np

ve.settings.defaultFont = "Theemim"

plt = ve.Plotter(interactive=False)

# Initialise the point could
points = np.random.rand(1000,3)
pcd = ve.pointcloud.Points(points, r=10)
pcd.pointdata["MY_RGB"] = np.zeros([1000,3], dtype=np.uint8)
pcd.pointdata.select("MY_RGB") # can add an alpha channel too

plt += [pcd, ve.Axes(pcd)]
plt.show()

pb = ve.ProgressBar(0, 500)
for n in range(500):
    colour_array = np.random.rand(pcd.NPoints(), 3)
    colour_array /= (np.max(colour_array) / 255) # normalize correctly
    colour_array = colou…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@jkissi
Comment options

@marcomusy
Comment options

@jkissi
Comment options

@jkissi
Comment options

@marcomusy
Comment options

Answer selected by jkissi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants