diff src/gl-render.cc @ 11175:c0a95a5c6d25

Address the speed of plotting large hggroup groups and in particular contours (bug #31305). Changes to address this include - Use __go_patch__ in __contour__ rather than patch so that the cost of setting up the callback functions is avoided. The contourgroup callback handles the updating of properties. - Add children_property class to store children in a list so that adding and deleting children is a low cost operation. - Create a new version of update_axis_limits code that doesn't force the recalculation of all of the objects children. Patch also allows unclosed patch contours with the FLTK backend.
author David Bateman <dbateman@free.fr>
date Tue, 02 Nov 2010 00:47:31 +0100
parents 36442102c340
children f72e17e70378
line wrap: on
line diff
--- a/src/gl-render.cc	Mon Nov 01 06:54:43 2010 -0400
+++ b/src/gl-render.cc	Tue Nov 02 00:47:31 2010 +0100
@@ -2659,6 +2659,7 @@
           set_linestyle (props.get_linestyle (), false);
           set_linewidth (props.get_linewidth ());
 
+
           // FIXME: use __index__ property from patch object; should we
           // offset patch contour as well?
           patch_tesselator tess (this, ec_mode, el_mode);
@@ -2666,20 +2667,47 @@
           for (int i = 0; i < nf; i++)
             {
               if (clip_f(i))
-                continue;
-
-              tess.begin_polygon (false);
-              tess.begin_contour ();
-
-              for (int j = 0; j < count_f(i); j++)
                 {
-                  vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
-        
-                  tess.add_vertex (vv->coords.fortran_vec (), vv);
+                  // This is an unclosed contour. Draw it as a line
+                  bool flag = false;
+
+                  for (int j = 0; j < count_f(i); j++)
+                    {
+                      if (! clip(int (f(i,j) - 1)))
+                        {
+                          vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
+                          const Matrix m = vv->coords;
+                          if (! flag)
+                            {
+                              flag = true;
+                              glBegin (GL_LINE_STRIP);
+                            }
+                          glVertex3d (m(0), m(1), m(2));
+                        }
+                      else if (flag)
+                        {
+                          flag = false;
+                          glEnd ();
+                        }
+                    }
+
+                  if (flag)
+                    glEnd ();
                 }
-
-              tess.end_contour ();
-              tess.end_polygon ();
+              else
+                {
+                  tess.begin_polygon (false);
+                  tess.begin_contour ();
+
+                  for (int j = 0; j < count_f(i); j++)
+                    {
+                      vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
+                      tess.add_vertex (vv->coords.fortran_vec (), vv);
+                    }
+
+                  tess.end_contour ();
+                  tess.end_polygon ();
+                }
             }
 
           set_linestyle ("-");