Menu

#2820 fillcolor setting ignored in "splot with circles" when using "set hidden3d"

open
nobody
None
4 days ago
5 days ago
No

When using "splot with circles" to draw filled circles, I find it very helpful that enabling "set hidden3d" allows the circles to properly occlude elements behind them.

However, when "set hidden3d" is enabled, the color specified by the fillcolor setting for "with circles" appears to be ignored. Without "set hidden3d", the circles are correctly filled with the specified color.

Is there something I might be missing here?

The following script reproduces the issue:

set xrange [-2:2]
set yrange [-2:2]
set zrange [-2:2]
set xyplane 0
set isotropic

$data <<EOD
0 0 0 1
0 0.5 0 1
EOD

#####################################################
#
# The circles are filled in "green"  (OK)
#

splot $data using 1:2:3:4 with circles \
            fc rgb "green" \
            fs solid border lc black, \
      -2 with lines lc "blue"

pause -1

#####################################################
#
# The circles are filled in "white"  (???)
#

set hidden3d offset 0 front 

splot $data using 1:2:3:4 with circles \
            fc rgb "green" \
            fs solid border lc black, \
      -2 with lines lc "blue"

pause -1

#####################################################
#
# The circles are filled in "black"  (???)
#

set style fill solid 1

splot $data using 1:2:3:4 with circles \
            fc rgb "green", \
      -2 with lines lc "blue"

pause -1

Discussion

  • Ethan Merritt

    Ethan Merritt - 5 days ago

    I am kind of surprised the circles are drawn at all in hidden3d mode. It was only designed for "splot with lines". Here's what the documentation says:

    hidden3d also affects 3D plotting styles points, labels, vectors, and
    impulses even if no surface is present in the graph.
    Unobscured portions of each vector are drawn as line segments (no arrowheads).
    Individual plots within the graph may be explicitly excluded from this
    processing by appending the extra option nohidden3d to the with specifier.

    I guess the individual line segments that make up the circumference of the circle are being treated as if they were part of a hidden surface. That wasn't intentional. The circle interiors are not drawn because hidden3d mode only deals with line segments.

    If you add the keyword "nohidden3d" after the circles part of the splot command, does that produce what you wanted? This will cause the circles to be drawn in a separate pass from the hidden3d parts of the plot. There is no way that I know of to include them in the calculation of what is occluded by the hidden3d surface.

     
    • Hiroki Motoyoshi

      Thank you for reply.

      I wasn't interested in the behavior when adding nohidden3d; the real issue was that the fillcolor setting wasn’t working as expected. So I found the following workaround:

      set hidden3d offset 0 front
      set style fill solid 1
      splot $data using 1:2:3:4:(rgbcolor("green")) with circles, \
            -2 with lines lc "blue"
      

      This produced the expected result. I would be satisfied if this behavior could be achieved using the inline option with circles fc "green" fs solid 1.

      That said, like you, I was also surprised that with circles is affected by hidden3d, just like surface plots are. Please, try the following.

      splot $data using 1:2:3:4 with circles \
                  fc rgb "green" \
                  fs solid border lc black, \
            0 with lines lc "blue"
      
       
  • Hiroki Motoyoshi

    To provide some background, what I wanted to achieve with this feature was to hide the rendering of the far side of a sphere, as in the following script. At the same time, I wanted to indicate the extent of the sphere using a color instead of white.

    set angles degrees
    set parametric
    set mapping spherical
    set isotropic
    set xyplane relative 0
    set title "3D version using spherical coordinate system" 
    set dummy u, v
    set urange [ -90.0000 : 90.0000 ] noreverse
    set vrange [ 0.00000 : 360.000 ] noreverse
    unset key
    set hidden3d
    set style fill solid 1 border lc "black"
    unset border
    unset tics
    set view ,,1.5
    array dummy[1]
    splot dummy using (0):(0):(0):(1):(rgbcolor("gray90")) with circles lw 1,\
          'world.dat' with lines lc rgb "black",\
          'world.cor' with points lt 1 pt 6
    pause -1
    

    This is a modified version of "world.2" in "world.dem".

     
  • Ethan Merritt

    Ethan Merritt - 5 days ago

    I am not sure where fill color fits into this.

    In the first two examples you gave, my interpretation was the reason the circles are green without hidden3d and not green with hidden3d is not because of the fillcolor. I think the fillcolor is still green. But in hidden3d mode the interior of the circle is not drawn at all, so the fill color is never looked at. At least that's how I interpret the difference. You can tell it's not white fill by setting a background color for the plot; the background color will show through, not white.

    I do see something odd, which may or may not explain the rest of your examples. The global property from set style fill seems to be taking precedence over a fillstyle given in the plot command for with circles. That is not supposed to happen. And when it does happen, I'm not sure where it is taking the fillcolor from. But more than that I am still confused about why it is drawing an interior for the circle at all, since as I said I before thought the hidden3d code never drew anything but line segments. Evidently I am wrong about that. I will hunt through the hidden3d code to see what is going on.

    Your work-around gives an impressive result. I did not think the program could do that! And it may give me a clue where to look, since apparently there must be some place in the code where it branches based on whether variable color is present. One side of the choice works while the other side does not.

     
  • Ethan Merritt

    Ethan Merritt - 4 days ago

    Please try this patch:

    diff --git a/src/plot3d.c b/src/plot3d.c
    index d0a023575..880037bc6 100644
    --- a/src/plot3d.c
    +++ b/src/plot3d.c
    @@ -1169,7 +1169,11 @@ get_3ddata(struct surface_points *this_plot)
                        color = z;
                    else
                        color = v[varcol];
    -               color_from_column(TRUE);
    +               if (this_plot->lp_properties.pm3d_color.type == TC_RGB
    +               &&  this_plot->lp_properties.pm3d_color.value >= 0.0)
    +                   color_from_column(FALSE);
    +               else
    +                   color_from_column(TRUE);
    
                } else if (this_plot->plot_style == VECTOR) {
                    /* We already enforced that j >= 6 */
    

    I still do not quite understand how the hidden3d code is managing to occlude circles, but I think this is the reason it fails to recognize that a specific color was requested.

    The fact that hidden3d always uses the global fill style rather than a plot-specific fill style is a limitation of the data structures it uses. All of the plots in the splot command are broken down into "edges" and "vertices". Line segments consist of two vertices with a connecting edge. Points consist of a single vertex with no connecting edges. The vertex structure (util3d.h) contains a pointer back to the coordinates of the point it came from, but it does not have a point back to the plot it came from. So it does not have access to a plot-specific fill style.

     
    • Hiroki Motoyoshi

      Thank you for the explanation.

      After applying the patch, I was able to set the border color for circles. By combining it with "set style fill", the interior of the circles can also be filled in the specified color. Looking at hidden3d.c, it seems that only the "circles" style is treated specially to allow set style fill to apply a fill style.

      I'm fully satisfied with this fix.

       

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.