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

WIP Implement use of PS command shfill into grdview (and maybe elsewhere) #7681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remkos
Copy link
Contributor

@remkos remkos commented Jul 26, 2023

Description of proposed changes

As discussed in Oslo, the PostScript shfill command (first introduced in PostScript 3 in 1999) would be quite useful for draping surfaces as in grdview. The biggest advantages would be:

  • Shorter code
  • Automatic colour interpolation between the colours defined on the vertices (we can now only use a constant colour for each defined triangle).

There may be some other opportunities as well, like plotting 3D spheres or ellipses.

Regarding shfill implementation in grdview, I have come to the following observations based on reading the PostScript Language Reference Manual, third edition, pp. 261-287

  • One way to implement it is by "type 5 shading", i.e. using a pseudorectangular lattice. This would be relatively straightforward, since we are anyway mapping a rectangular grid of vertices, but it would not work when that grid includes holes (NaNs). Afaik grdview now moves around those, since a NaN for the z-coordinate cannot be mapped onto the plot. A NaN value for the draped grid would simply lead to it being assigned the appropriate NaN colour, so that would still work, although the automatic colour interpolation would become a mess.
  • The second way of implementation is by "type 4 shading", i.e. using a freeform series of triangles. This implementation is closer to the current one in grdview, but will be a bit more complex to implement.
  • Either way, the input can be encoded as binary (we would probably then run it through compression and ascii-encoding as we do images), which can also provide quite some savings in size. I would still first implement it through ascii arrays though to see how well it works.
  • One thing that we cannot port from the current implementation, is the opportunity to plot both a surface (draped grid) and a mesh (outline of the grid rectangles). So there would be no equivalent to -Qsm. That means we would probably need to remain supporting the original implementation with option -Qs while introducing a new option e.g. -Qf to use shfill. There would be no way to combine a surface plotted and filled using shfill with a mesh.

Reminders

  • Make sure that your code follows our style. Use the other functions/files as a basis.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Describe changes to function behavior and arguments in a comment below the function declaration.
  • If adding new functionality, add a detailed description to the documentation and/or an example.

@remkos remkos added discussion Topics for longer discussion enhancement Improving an existing feature new module PR that implements a new module new feature PR that implements a new feature or capability in GMT and removed new module PR that implements a new module labels Jul 26, 2023
@remkos remkos self-assigned this Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topics for longer discussion enhancement Improving an existing feature new feature PR that implements a new feature or capability in GMT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant