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

Document default Delaunay Triangulation algorithm as Shewchuk #6438

Merged

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Mar 12, 2022

Description of proposed changes

Current default should be the Shewchuk [1996] algorithm, and not Watson [1982]. Modified documentation in contour.rst, triangulate.rst, gmt.conf.rst and TRIANGLE.HOWTO to be clear on this. Also mentioned using gmt get GMT_TRIANGULATE as the way to know which one is being used.

Fixes #6436

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.

weiji14 added 2 commits March 12, 2022 18:05
Current default should be the Shewchuk [1996] algorithm, and not Watson [1982]. Modified documentation in contour.rst, triangulate.rst and gmt.conf.rst to be clear on this. Also mentioned using `gmt get GMT_TRIANGULATE` as the way to know which one is being used.
@weiji14 weiji14 added the documentation Improve documentation label Mar 12, 2022
@weiji14 weiji14 added this to the 6.4.0 milestone Mar 12, 2022
@weiji14 weiji14 self-assigned this Mar 12, 2022
Comment on lines 17 to +23
In makegmt.macro there are two parameters that can be defined:
TRIANGLE_D and TRIANGLE_O. By default they are commented out.
TRIANGLE_D and TRIANGLE_O. By default these lines are commented out.
To use Shewchuk's [1996] routine, remove the # from the
beginning of the lines and then 'make clean' and 'make install'.
To revert to the default GMT usage of Watson's [1982] algorithm,
To revert to using Watson's [1982] algorithm,
simply place a # in the first column at these two lines.
Then, say 'make clean' and 'make install' again.
Then, run 'make clean' and 'make install' again.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need a bit of help rewording these lines. I don't see makegmt.macro anywhere (the git blame on this file dates back to Dec 2000!!). I do see a TRIANGLE_D here:

gmt/src/gmt_init.c

Lines 6580 to 6585 in 434ed18

/* GMT_TRIANGULATE */
#ifdef TRIANGLE_D
GMT->current.setting.triangulate = GMT_TRIANGLE_SHEWCHUK;
#else
GMT->current.setting.triangulate = GMT_TRIANGLE_WATSON;
#endif

but no mention of TRIANGLE_O.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My best guess is that these macros are in reference to the pre-CMake days. I think that this paragraph and the preceding to sentences should instead make these points:

  1. Use gmt set GMT_TRIANGULATE to control which algorithm is used on the fly.
  2. Use set (LICENSE_RESTRICTED GPL) in cmake/ConfigUserAdvanced.cmake to disable Shewchuk's routine entirely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, pre-CMake language.

weiji14 added a commit to GenericMappingTools/pygmt that referenced this pull request Mar 13, 2022
weiji14 added a commit to GenericMappingTools/pygmt that referenced this pull request Mar 14, 2022
Wrapping the triangulate function which does
"Delaunay triangulation or Voronoi partitioning
and gridding of Cartesian data".
Original GMT documentation can be found at
https://docs.generic-mapping-tools.org/6.3/triangulate.html.

Aliased outgrid (G), spacing (I), projection (J),
region (R), verbose (V), registration (r).

* Refactor triangulate to use virtualfile_from_data
* Refactor triangulate implementation to use pygmt.io.load_dataarray
* Alias binary(b), nodata(d), find(e), coltypes(f), header(h), incols(i)

* Rename the parameter 'table' to 'data'

As per #1479.

* Refactor test_triangulate to use Table_5_11_mean.xyz instead of tut_ship
* Refactor test_triangulate_with_outgrid to use xr.testing.assert_allclose
* Refactor test_triangulate_input_xyz to use pd.testing.assert_frame_equal

* Implement regular_grid and delaunay_triples staticmethod for triangulate
* Let list inputs to spacing (I) and incols (i) work

Use  I="sequence" and i="sequence_comma".

* Ensure triangulate.delaunay_triples output_type is valid

Must be either one of numpy, pandas or file

* Autocorrect output_type to 'file' if outfile parameter is set
* Allow only str or None inputs to outgrid parameter

Xref #1807

* Use gmt get GMT_TRIANGULATE to check whether Watson or Shewchuk is used
* State that Shewchuk is the default triangulation algorithm

As per GenericMappingTools/gmt#6438

* Actually document the output_type parameter for delaunay_triples

Co-authored-by: Will Schlitzer <schlitzer90@gmail.com>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@PaulWessel
Copy link
Member

Remind me if this is ready to be approved - it has been languishing for some time.

@weiji14
Copy link
Member Author

weiji14 commented Jun 8, 2022

Might need some more changes to the wording. Feel free to work directly on this branch, I'm a bit short on time right now.

@PaulWessel
Copy link
Member

OK, but not sure how to check out your branch...

@maxrjones
Copy link
Member

maxrjones commented Jun 8, 2022

Here are the instructions for checking out a PR - https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally.

That said, I am not sure whether you'd be able to push to Wei Ji's branch (I haven't ever tried to push to a fork from a local checkout).

This is an improvement, so IMO you could merge this as a part 1 and make any additional edits as a separate PR if it's easier.

@PaulWessel PaulWessel marked this pull request as ready for review June 8, 2022 18:31
@PaulWessel PaulWessel merged commit 06201c8 into GenericMappingTools:master Jun 8, 2022
@PaulWessel
Copy link
Member

Thanks, that is easier, now merged.

@weiji14 weiji14 deleted the triangulate/default-shewchuk branch June 8, 2022 19:39
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
Wrapping the triangulate function which does
"Delaunay triangulation or Voronoi partitioning
and gridding of Cartesian data".
Original GMT documentation can be found at
https://docs.generic-mapping-tools.org/6.3/triangulate.html.

Aliased outgrid (G), spacing (I), projection (J),
region (R), verbose (V), registration (r).

* Refactor triangulate to use virtualfile_from_data
* Refactor triangulate implementation to use pygmt.io.load_dataarray
* Alias binary(b), nodata(d), find(e), coltypes(f), header(h), incols(i)

* Rename the parameter 'table' to 'data'

As per GenericMappingTools#1479.

* Refactor test_triangulate to use Table_5_11_mean.xyz instead of tut_ship
* Refactor test_triangulate_with_outgrid to use xr.testing.assert_allclose
* Refactor test_triangulate_input_xyz to use pd.testing.assert_frame_equal

* Implement regular_grid and delaunay_triples staticmethod for triangulate
* Let list inputs to spacing (I) and incols (i) work

Use  I="sequence" and i="sequence_comma".

* Ensure triangulate.delaunay_triples output_type is valid

Must be either one of numpy, pandas or file

* Autocorrect output_type to 'file' if outfile parameter is set
* Allow only str or None inputs to outgrid parameter

Xref GenericMappingTools#1807

* Use gmt get GMT_TRIANGULATE to check whether Watson or Shewchuk is used
* State that Shewchuk is the default triangulation algorithm

As per GenericMappingTools/gmt#6438

* Actually document the output_type parameter for delaunay_triples

Co-authored-by: Will Schlitzer <schlitzer90@gmail.com>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improve documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clarifying default algorithm used for triangulate - Watson or Shewchuk?
3 participants