Menu

#497 Patch triangul3d (drawing triangulated 3D surfaces)

closed-rejected
nobody
None
1
2011-10-15
2010-08-27
Khanh-Dang
No

With this patch, gnuplot can plot a 3D surface of non-gridded data, without using interpolation. The set of (x,y) points are triangulated using a Delaunay triangulation. The triangulated surface can be drawn with hidden3d or used as a pm3d surface. This patch is not relevant for 2D plotting or functions plotting.

This patch is useful when you don't want to use dgrid3d (interpolation), either because interpolation fails (discontinuous surface, or a surface with a very small number of points), or because you just like to draw your actual data and just not an approximation.

See http://www.pmmh.espci.fr/~knguyen/gnuplot/ for a demo.

Discussion

  • Khanh-Dang

    Khanh-Dang - 2010-08-27

    triangul3d patch

     
  • Ethan Merritt

    Ethan Merritt - 2010-08-29

    Comments:

    [Summarizing for others who haven't looked at the patch] The patch adds 2 big chunks of code and also adds some bits to existing plot structures to support them. The biggest chunk is a 3rd-party routine triangle.c by Jonathan Richard Shewchuk that does the Delaunay tessellation (creates a set of triangles whose vertices are the input points). The other big chunk is an alternative version of hidden3d that handles the triangles.

    As you pointed out in the newsgroup, the license on triangle.c makes it pretty much impossible to include it as part of a larger package or distribution, as it restricts what can be done with it further down the chain: "Distribution of this code as part of a commercial system is permissible ONLY BY DIRECT ARRANGEMENT WITH THE AUTHOR. (If you are not directly supplying this code to a customer, and you are instead telling them how they can obtain it for free, then you are not required to make any arrangement with me.)". This is the same problem that prevented distribution of gnuplot when linked with PDFLib, although it doesn't prevent providing instructions to end-users for how to link gnuplot with the 3rd-party code if the license does not apply to them.

    Adding triangles to the hidden3d code is potentially useful in its own right. However, if I'm reading the code correctly, it's implemented as an either/or thing. You can use hidden3d to plot a triangulated surface, or you can use it in its current form, but you can't mix triangles with other objects in the same plot. That seems like an serious limitation, with no obvious justification. Why not just mix the triangles in with the other objects and handle the whole lot jointly?

    So I'm going to suggest some options.

    First, how about splitting the patch into two parts. One part to implement triangles as hidden3d objects and define a format for reading them in. I can imagine several ways to do this, starting with the obvious but possibly non-optimal one of having the file contain an indexed list of vertices followed by a list of index triples. That's the way it's going to be stored internally anyhow, right? This would not involve any licensing issues, and would add a capability to the program that is not tied to any particular tessellation algorithm or code.

    Since we can't incorporate Jonathan Shewchuk's triangle.c code into gnuplot proper, it would have to either be replaced by a license-compatible alternative subroutine, or run as a separate stand-alone program that produces an input file for gnuplot to plot. Both of these seem possible. The latter is maybe a more flexible option, as there are many other programs out there in the world that know how to generate tessellated surfaces.

    The code quality looks good to me at first run through, but I hate the [mis]spelling "triangul".
    triangle.c itself seems pretty heavy-weight for the purpose, which is maybe another reason to look for an alternative tessellation code. Given that turning on the triangulation mode breaks hidden3d for all other objects, I veto making it the default state. But that's irrelevant if the triangle-handling code is merged in with the existing hidden3d code rather than being an separate path.

    Note that I'm not 100% convinced that it's worth adding this capability to gnuplot. On the one hand it's a very large chunk of code that only does one thing in its current form. On the other hand it doesn't handle some of what you'd normally expect from Delaunay tessellation, like providing surface normals at each vertex so that one can generate smooth coloring. I think I'd be happier adding only the triangle support itself to the core gnuplot code, particular if integrating it with the current hidden3d.c makes it a smaller addition (not really sure it will, though).

    Note: gcc issues warnings about the code in triangle.c
    triangle.c:489: warning: assignment makes integer from pointer without a cast
    triangle.c:491: warning: assignment makes pointer from integer without a cast
    triangle.c:573: warning: cast to pointer from integer of different size
    so it may not be 64-bit safe. Not relevant if it is replaced with another tessellation code.

     
  • Ethan Merritt

    Ethan Merritt - 2011-03-21
    • priority: 5 --> 1
    • status: open --> open-rejected
     
  • Nobody/Anonymous

    M2a0Mp <a href="http://akuetptsjmyx.com/">akuetptsjmyx</a>, [url=http://tkjgekijyeku.com/]tkjgekijyeku[/url], [link=http://dehbszgjuikv.com/]dehbszgjuikv[/link], http://pgfnavjnyfru.com/

     
  • Ethan Merritt

    Ethan Merritt - 2011-10-15
    • status: open-rejected --> closed-rejected
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.