bugGNU Octave - Bugs: bug #47677, non-planar patches are not...

 
 

bug #47677: non-planar patches are not supported in Octave

Submitter:  Markus Mützel <mmuetzel>
Submitted:  Tue 12 Apr 2016 01:14:40 PM UTC
   
 
Category:  Plotting with OpenGL Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 02 Jun 2018 12:57:18 PM UTC, comment #7: 

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Thu 31 May 2018 11:23:55 AM UTC, comment #6: 

I refreshed this patch to apply on the current tip and pushed it here:
http://hg.savannah.gnu.org/hgweb/octave/rev/762eb2e33a7f

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Mon 18 Jul 2016 04:39:37 PM UTC, comment #5: 

The attached changeset adds a demo with a non-planar patch. other than that it is the same as file #37672 from comment #4.

(file #37933)

Markus Mützel <mmuetzel>
Group administrator
Sat 02 Jul 2016 07:53:47 PM UTC, comment #4: 

Attached is a patch that finds planar subsets for non-planar faces.
When using OpenGL, these subsets are drawn separately.

There are different approaches for separating non-planar polygons into planar subsets. The approach taken in this patch is the following:
1- Find the largest sequence starting from edge(1) that gives a planar polygon.
2- Including edge(1), find the largest sequence starting from the last edge of the prior polygon that gives a planar polygon.
3- Repeat from 2 until the face is complete.

I also attached a script for testing with some exemplary non-planar polygons.

(file #37672, file #37673)

Markus Mützel <mmuetzel>
Group administrator
Tue 19 Apr 2016 01:58:42 PM UTC, comment #3: 

After some debugging, I am under the impression that OpenGL does not support non-coplanar polygons at all.
For the missing vertex, patch_tesselator::combine is called and the point is collapsed onto [0 1 0].

From the OpenGL docs [1]:
GLU_TESS_COMBINE
The combine callback is called to create a new vertex when the tessellation detects an intersection or wishes to merge features.

If I understand correctly, this is something OpenGL does automatically.
The only thing that occurs to me that would enable non-coplanar polygons would be to divide the polygons into coplanar subsets and draw them seperately...

With the attaches patch that adds a bunch of debugging messages, I get the following:

>> hp = patch ('Vertices', [0, 1, 0; 1, 1, 0; 0, 0, 0; 0, 0, 1], 'Faces', [1 2 3 4]);
opengl_renderer::draw_patch vdata[0] (0, 1, 0)
opengl_renderer::draw_patch vdata[1] (1, 1, 0)
opengl_renderer::draw_patch vdata[2] (0, 0, 0)
opengl_renderer::draw_patch vdata[3] (0, 0, 1)
opengl_renderer::draw_patch drawing faces
opengl_renderer::draw_patch (0, 0, 1)
opengl_tesselator::add_vertex (0, 0, 1)
opengl_renderer::draw_patch (0, 0, 0)
opengl_tesselator::add_vertex (0, 0, 0)
opengl_renderer::draw_patch (1, 1, 0)
opengl_tesselator::add_vertex (1, 1, 0)
opengl_renderer::draw_patch (0, 1, 0)
opengl_tesselator::add_vertex (0, 1, 0)
opengl_renderer::draw_patch ending face
patch_tesselator::combine vertices to combine (1, 1, 0)
patch_tesselator::combine vertices to combine (0, 1, 0)
patch_tesselator::combine (1, 1, 0)
patch_tesselator::vertex (1, 1, 0)
patch_tesselator::vertex (0, 0, 1)
patch_tesselator::vertex (0, 0, 0)
opengl_renderer::draw_patch drawing contours
opengl_tesselator::add_vertex (0, 0, 1)
opengl_tesselator::add_vertex (0, 0, 0)
opengl_tesselator::add_vertex (1, 1, 0)
opengl_tesselator::add_vertex (0, 1, 0)
opengl_renderer::draw_patch ending contour
patch_tesselator::combine vertices to combine (1, 1, 0)
patch_tesselator::combine vertices to combine (0, 1, 0)
patch_tesselator::combine (1, 1, 0)
patch_tesselator::vertex (1, 1, 0)
patch_tesselator::vertex (0, 0, 1)
patch_tesselator::vertex (0, 0, 0)




(file #36963)

Markus Mützel <mmuetzel>
Group administrator
Fri 15 Apr 2016 07:23:06 AM UTC, comment #2: 

Rik:
Please, find the resulting figure from the example in comment #0 in "non-plane_patch.pdf". To better visualize the "elbow" in the patch surface, "non-plane_patch+line.pdf" was saved after executing this additional line (from vertices(1,:) to vertices(3,:) ):

line ([0 0], [1 0], [0 0], 'Color', 'w', 'LineStyle', ':')


The triangle that is produced by Octave 4.0.1 with the same example from comment #0 is none of the two parts of that surface but lies on the "space diagonal" surface given by [1, 1, 0; 0, 0, 0; 0, 0, 1] ( = vertices(2:4,:) ), see "non-plane_patch_Octave.pdf" for Octave's result from a similar perspective.

I do not know where the thin, white, dashed and dotted lines come from in the latter pdf. I cannot see them in the original figure on the screen before and after saving to pdf. Maybe that is a different bug or they might even give a hint on what is going wrong...

(file #36932, file #36933, file #36934)

Markus Mützel <mmuetzel>
Group administrator
Thu 14 Apr 2016 08:18:52 PM UTC, comment #1: 

Could you attach a png or pdf of what the output should look like?

The problematic code is going to be in libinterp/corefcn/gl-render.cc.  Either the draw_patch routine or the callback that handles the tesselation.  My guess is that the callback is filtering out one of the resulting triangles because it is seeing the shared edge and somehow calculating them to be the same triangle.

Rik <rik5>
Group administrator
Tue 12 Apr 2016 01:14:40 PM UTC, original submission:  

In Matlab, the following example gives a patch with a bent surface (similar to two triangles sharing one edge):

vertices = [0, 1, 0; 1, 1, 0; 0, 0, 0; 0, 0, 1];
faces = [1 2 3 4];
hp = patch ('Vertices', vertices, 'Faces', faces);


While the same code sample does not error for "fltk" or "qt" in Octave, the resulting patch is incorrect. The first edge (at [0, 1, 0]) seems to be ignored.

For "gnuplot", this error is thrown:

error: __go_draw_axes__: gnuplot (as of v4.2) only supports 3-D filled triangular patches
error: called from
    __go_draw_axes__ at line 671 column 18
    __go_draw_figure__ at line 172 column 17
    __gnuplot_drawnow__ at line 86 column 5


Markus Mützel <mmuetzel>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #37673:  test_nonplanar_patches.m added by mmuetzel (2KiB - text/x-objcsrc)
file #36932:  non-plane_patch.pdf added by mmuetzel (3KiB - application/pdf)
file #36933:  non-plane_patch+line.pdf added by mmuetzel (3KiB - application/pdf)
file #36934:  non-plane_patch_Octave.pdf added by mmuetzel (4KiB - application/pdf)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 14 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-06-02 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-05-31 mmuetzel StatusConfirmed Ready For Test
    2016-11-15 rik5 StatusNone Confirmed
        Release4.0.1 dev
    2016-09-23 rik5 Dependencies- bugs #38779 is dependent
    2016-07-18 mmuetzel Attached File- Added patch_with_nonplanar_faces_v2.patch, #37933
        Carbon-Copy- Added pantxo
    2016-07-02 mmuetzel Attached File- Added patch_with_nonplanar_faces.patch, #37672
        Attached File- Added test_nonplanar_patches.m, #37673
    2016-04-19 mmuetzel Attached File- Added patch_tesselator_debug.patch, #36963
    2016-04-15 mmuetzel Attached File- Added non-plane_patch.pdf, #36932
        Attached File- Added non-plane_patch+line.pdf, #36933
        Attached File- Added non-plane_patch_Octave.pdf, #36934

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code