From 6a73b6b9ecb5302e006be90cc689b0e1ac35dfc1 Mon Sep 17 00:00:00 2001 From: Neil Toronto Date: Sat, 5 Apr 2014 11:40:23 -0600 Subject: [PATCH] Fix wrongly raised exception when 3D rectangles are entirely clipped out --- pkgs/plot-pkgs/plot-lib/plot/private/plot3d/plot-area.rkt | 4 ++-- pkgs/plot-pkgs/plot-test/plot/tests/plot2d-tests.rkt | 4 ++++ pkgs/plot-pkgs/plot-test/plot/tests/plot3d-tests.rkt | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/plot-area.rkt b/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/plot-area.rkt index ed5339ddc8..8b1440996e 100644 --- a/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/plot-area.rkt +++ b/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/plot-area.rkt @@ -1033,8 +1033,8 @@ norm-vs ls normal))))))) (define/public (put-rect r) - (when (rect-rational? r) - (let ([r (rect-meet r bounds-rect)]) + (let ([r (if (rect-rational? r) (rect-meet r bounds-rect) r)]) + (when (rect-rational? r) (match-define (vector (ivl x-min x-max) (ivl y-min y-max) (ivl z-min z-max)) r) (define v-min (plot->norm (vector (inexact->exact x-min) (inexact->exact y-min) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/plot2d-tests.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/plot2d-tests.rkt index 5c535bb5c6..e7b9b4c2d4 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/plot2d-tests.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/plot2d-tests.rkt @@ -18,6 +18,10 @@ (time (plot (points empty) #:x-min -1 #:x-max 1 #:y-min -1 #:y-max 1)) +(printf "Plot should be empty:~n") +(plot (rectangles (list (list (ivl 0 1) (ivl 0 1)))) + #:x-min 2 #:x-max 3) + (plot (list (function values -4 4) (axes 1 2))) (time (plot (function values 0 1000))) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-tests.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-tests.rkt index 7b86246746..971e461801 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-tests.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-tests.rkt @@ -11,6 +11,10 @@ (time (plot3d (points3d empty) #:x-min -1 #:x-max 1 #:y-min -1 #:y-max 1 #:z-min -1 #:z-max 1)) +(printf "This plot should be empty:~n") +(plot3d (rectangles3d (list (list (ivl 0 1) (ivl 0 1) (ivl 0 1)))) + #:x-min 2 #:x-max 3) + (parameterize ([plot-background "black"] [plot-foreground "white"] [plot-background-alpha 1/2]