Skip to content
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

drawing of colorbar in vcs too slow #849

Closed
doutriaux1 opened this issue Oct 27, 2014 · 14 comments
Closed

drawing of colorbar in vcs too slow #849

doutriaux1 opened this issue Oct 27, 2014 · 14 comments
Assignees
Milestone

Comments

@doutriaux1
Copy link
Contributor

@doutriaux1 doutriaux1 commented Oct 27, 2014

the following code, takes around .5sec just to draw the colorbar.

import cdms2,sys,vcs
x=vcs.init()
f=cdms2.open(sys.prefix+"/sample_data/clt.nc")
s=f("clt")
x.plot(s)

The code to draw the colorbar should be rewritten in pure VTK.
current code:
https://github.com/UV-CDAT/uvcdat/blob/master/Packages/vcs/Lib/template.py#L1369

in the vtkbackend we call it at:
https://github.com/UV-CDAT/uvcdat/blob/master/Packages/vcs/Lib/VTKPlots.py#L1127

I think we should update
vtkScalarBarActor

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Oct 27, 2014

@dlonie let me know if that's not clear

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Oct 27, 2014

@dlonie also let's use the same branch for this, I'm using: https://github.com/UV-CDAT/uvcdat/tree/optimize_vtk

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Oct 28, 2014

I'll take a look soon.

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Oct 30, 2014

You're on the right track. Adding a vtkScalarBarActor that uses the same vtkLookupTable as the data mapper should be sufficient. Let me know how I can help.

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Oct 31, 2014

@dlonie no the vtkscalarbaractor won't work. I tried it. If I remember correctly you can't control very well the viewport (i.e dims) and you can't control the text on it. You can't add extension arrows. Also we need to be able to control the text fonts color height etc... that is why I assigned it to kit ware because it will need a serious overall of the scalarbaractor.

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Oct 31, 2014

Ah, you want a different style. It's probably best to write a new one from scratch if you need that level of control over the elements. If we go this route, can you provide a list of the specific features/customizations you need?

Alternatively, have you profiled the current scalar bar drawing code? If we can figure out what's making it take so long, we might be able to optimize it and keep the existing look and feel without too much effort.

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Oct 31, 2014

yes there's many places where the current code can be optimized. python loops over the 255 colors is bad while creating the fillarea object, then while processing the fillarea object we go thru that loop again. We already have the lookupup table in VTKPlot.py so I think using ScalarBarActor (a new one) is the way to go. There's not so much more that needs to be added, I almost think the current one is close form functional for us. A short sumary of what our colorbar actor would need
1- ability to add extensions arrows
2- ability to control the thickness/stretch
3- ability to control which values are effectively written as text (can't write 255 vals obviously)
4- ability to map these vlue to specific strings
5- ability to control the textactor (colro/font/size/orientation etc...) of the actual text rendered.

allisonvacanti pushed a commit that referenced this issue Nov 6, 2014
Rather than allocating (and rendering!) a unique polydata + mapper + actor
combo for each vertical slice of the color bar, create a single, multicell
polydata that gets rendered at once in a single actor/mapper.

This speeds up the execution of prepFillArea using the test script in #849
from 0.25s to 0.09s on my machine.
@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Nov 6, 2014

See the branch I just pushed. I profiled the existing implementation and found some quick optimizations. Allocating and rendering separate polydata, mappers, and actors for each vertical slice of the colorbar eats up a lot of time (you really want to try to minimize the number of actors in VTK for best performance), and the data fits quite well into a single multicell polydata.

This is roughly 3x faster on my machine and produces the same results. Would this improve performance enough for you folks? IMO, if we can avoid spending a week or two developing a new C++ scalar bar, we should ;-)

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Nov 6, 2014

will test. If works much better for me will merge then into master. If @williams13 still wants more performance improvement later we can revisit. Does that sounds right?

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Nov 7, 2014

Sounds good to me, let's see what Dean thinks.

@williams13
Copy link
Contributor

@williams13 williams13 commented Nov 10, 2014

I am rebuilding it now… Back in a few.

Best regards,
Dean

From: David Lonie <notifications@github.commailto:notifications@github.com>
Reply-To: UV-CDAT/uvcdat <reply@reply.github.commailto:reply@reply.github.com>
Date: Friday, November 7, 2014 5:43 AM
To: UV-CDAT/uvcdat <uvcdat@noreply.github.commailto:uvcdat@noreply.github.com>
Cc: Dean Williams <williams13@llnl.govmailto:williams13@llnl.gov>
Subject: Re: [uvcdat] drawing of colorbar in vcs too slow (#849)

Sounds good to me, let's see what Dean thinks.


Reply to this email directly or view it on GitHubhttps://github.com//issues/849#issuecomment-62145287.

@allisonvacanti
Copy link
Contributor

@allisonvacanti allisonvacanti commented Dec 12, 2014

Can we close this, or is more work needed?

@williams13
Copy link
Contributor

@williams13 williams13 commented Dec 12, 2014

Charles was looking at this. I believe the drawing of the color bar on the plot has been correct and sped up.

-Dean

From: David Lonie <notifications@github.commailto:notifications@github.com>
Reply-To: UV-CDAT/uvcdat <reply@reply.github.commailto:reply@reply.github.com>
Date: Friday, December 12, 2014 6:04 AM
To: UV-CDAT/uvcdat <uvcdat@noreply.github.commailto:uvcdat@noreply.github.com>
Cc: Dean Williams <williams13@llnl.govmailto:williams13@llnl.gov>
Subject: Re: [uvcdat] drawing of colorbar in vcs too slow (#849)

Can we close this, or is more work needed?


Reply to this email directly or view it on GitHubhttps://github.com//issues/849#issuecomment-66775914.

@doutriaux1
Copy link
Contributor Author

@doutriaux1 doutriaux1 commented Dec 24, 2014

Yes @dlonie code is in. Closing

@doutriaux1 doutriaux1 closed this Dec 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants