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

colors format in mesh functions #51

Closed
nilsbecker opened this issue Dec 18, 2017 · 2 comments
Closed

colors format in mesh functions #51

nilsbecker opened this issue Dec 18, 2017 · 2 comments

Comments

@nilsbecker
Copy link

this is about the python wrapper - should i file in sciapp/ somewhere instead?

@nilsbecker
Copy link
Author

in gr3.drawXXXmesh, the colors must be given as a flattened array of 3-tuples for each mesh component drawn iiuc. why not allow an (N, 3) array? it could be transformed into a flat view trivially?

@FlorianRhiem
Copy link
Member

I am not certain that I understand your question correctly. Let's take gr3.drawconemesh for an example:

colors = floatarray(colors)
...
_gr3.gr3_drawconemesh(c_uint(n), positions.data, directions.data, colors.data, radii.data, lengths.data)

The colors, like the other array-like parameters, are converted using the floatarray helper class. For CPython, the following happens:

self.array = numpy.array(a, c_float)
self.data = self.array.ctypes.data_as(POINTER(c_float))

So anything can be used that can also be used to construct a numpy.array of datatype ctypes.c_float. The array shape is ignored, as GR3 only works with a pointer to the array's contiguous memory.

Could you provide an example which causes problems (N, 3) shaped arrays?


And yes, sciapp/python-gr would be the fitting repository as it contains the current code for the GR and GR3 Python wrappers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants