How to add a public method to 3d-plot-area%?

Hi, I am trying to build a new 3d renderer for the plot package. The renderer is a 3d matrix viewer, where each index in the matrix matches a voxel in the plot. The current implementation is inspired by the existing rectangles3d renderer

It seems one of the initial steps is to make a put-voxels method in the public API of 3d-plot-area%. This code compiles and typechecks, and can be seen at https://github.com/Rscho314/plot/blob/raoul_voxel/plot-lib/plot/private/plot3d/plot-area.rkt.

But the method is not seen when I try to use the API, such as in https://github.com/Rscho314/plot/blob/raoul_voxel/plot-lib/plot/private/plot3d/voxel.rkt.

How can I make my new method visible ? Thanks !

I had a look at the code, and I don't see what the problem could be - it should work. Can you post the error message you get when you try to run it?


On a separate note, and if I understood your code correctly, I think you can easily use the existing rectangles3d renderer to plot voxels. You just need to write a function which converts the 3d boolean matrix into 3D rectangles:

(define (voxel-model->plot-rectangles vm)
  (for/list ([(zs z) (in-indexed vm)] #:when zs
             [(ys y) (in-indexed zs)] #:when ys
             [(xs x) (in-indexed ys)] #:when xs)
    (vector (ivl x (add1 x))
            (ivl y (add1 y))
            (ivl z (add1 z)))))

Here is an example, rendering a voxel matrix:

... and the source code is here:

Alex.

Sorry if this is obvious, but did you set up your plot clone up as the installed package? Because otherwise (require plot/utils) is still referring to the standard install that does not have your updates.
(... having been bitten myself by this when working on the plot library...)

Indeed, I forgot to raco setup plot, thanks for reminding me!

EDIT:

I solved the problem with raco setup plot. Apparently, plot/compat had to be installed separately.

EDIT 2:

For new methods to be visible, the symbols have to be reprovided in plot/no-gui.rkt. I then had to raco setup -c --pkgs plot and again raco setup plot for the symbols to finally become accessible.

@alexh when I try to raco setup plot on a clean local copy of racket/plot, build fails with the following (racket 8.13, Linux install as non-root user):

raco setup: --- summary of errors --- [15:27:32]
raco setup: error: during making for /plot-doc/plot
raco setup: plot-doc/plot/scribblings/compat.scrbl:5:21: cannot open module file
raco setup: module path: plot/compat
raco setup: path: /home/raoul/Desktop/racket_plot/plot/plot-gui-lib/plot/compat.rkt
raco setup: system error: no such file or directory; rkt_err=3
raco setup: compiling: /plot-doc/plot/scribblings/compat.scrbl
raco setup: error: during building docs for /plot-doc/plot/scribblings/plot.scrbl
raco setup: plot-doc/plot/scribblings/compat.scrbl:5:21: cannot open module file
raco setup: module path: plot/compat
raco setup: path: /home/raoul/Desktop/racket_plot/plot/plot-gui-lib/plot/compat.rkt
raco setup: system error: no such file or directory; rkt_err=3

Would you know where I'm doing it wrong ? Thx !

I am aware rectangles3d can be used for cube voxels. My goal is to use other space-filling polygons, such as the truncated octahedron and friends. It could certainly be done by using the existing plotting facilities, but I thought it might be interesting to others and was perhaps worth a PR.

1 Like