From c1550b673b9de9bce73358ad9f6984c03d931812 Mon Sep 17 00:00:00 2001 From: Neil Toronto Date: Wed, 2 Apr 2014 22:06:42 -0600 Subject: [PATCH] Remove unnecessary use of `remove-duplicates' --- .../plot-lib/plot/private/plot3d/bsp.rkt | 11 +-- .../plot-test/plot/tests/plot3d-bsp-tests.rkt | 91 ++++++++----------- 2 files changed, 41 insertions(+), 61 deletions(-) diff --git a/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/bsp.rkt b/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/bsp.rkt index 4ad472f21f..9c29b76f67 100644 --- a/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/bsp.rkt +++ b/pkgs/plot-pkgs/plot-lib/plot/private/plot3d/bsp.rkt @@ -499,8 +499,7 @@ (cond [(empty? ps) #f] [else - (define vs (remove-duplicates (bsp-polys->vertices ps))) - (define axes (vertices->axes vs)) + (define axes (vertices->axes (bsp-polys->vertices ps))) (define center (list->flvector (map axis-mid axes))) ;; Planes defined by neighboring polygon vertices @@ -530,8 +529,7 @@ (cond [(empty? ls) #f] [else - (define vs (remove-duplicates (bsp-lines->vertices ls))) - (define axes (vertices->axes vs)) + (define axes (vertices->axes (bsp-lines->vertices ls))) (define center (list->flvector (map axis-mid axes))) ;; Planes defined by line segments and basis vectors (i.e. one basis in normal is zero) @@ -560,9 +558,8 @@ (cond [(and (empty? ls) (empty? ps)) #f] [else - (define vs (remove-duplicates (append (append* (map lines-vertices ls)) - (append* (map points-vertices ps))))) - (define axes (vertices->axes vs)) + (define axes (vertices->axes (append (append* (map lines-vertices ls)) + (append* (map points-vertices ps))))) (define center (list->flvector (map axis-mid axes))) (: try-nondisjoint-split (-> (U #f BSP-Tree))) diff --git a/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-bsp-tests.rkt b/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-bsp-tests.rkt index 00ff5ced78..be8ed2a60c 100644 --- a/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-bsp-tests.rkt +++ b/pkgs/plot-pkgs/plot-test/plot/tests/plot3d-bsp-tests.rkt @@ -1,23 +1,5 @@ #lang racket -#| -TODO - -BSP - - deal better with polygon + many non-polygon shapes - - avoid more recomputation in build-bsp3d (i.e. precompute bounding and central planes) - - make middle shapes in bsp-node a BSP-Tree - - speed up disjoint splitting - -insert line segments into BSP as polygonal clipping regions? - -slow parts - - 22.3: build-bsp-tree - - 15.6: contour renderer proc - - 12.7: clip-polygon - - 6.0: bin-shapes -|# - (require plot (except-in plot/utils sum flsum sample) math @@ -95,41 +77,42 @@ slow parts (points3d xyzs #:sym 'dot))))) (time - (plot3d - (list (contour-intervals3d - (λ (x y) - (* x (+ 0.1 y))) - -1 1 -1 1 - #:samples 41 - #:alphas '(0.85) - ;#:alpha 0.75 - ;#:line-width 2 - ;#:line-widths '(2) - ;#:line-styles '(transparent) - #:contour-widths '(2) - ;#:color 1 - ;#:label "" - ) - - (surface3d - (λ (x y) - (* (- (* (flnormal-pdf 0.0 0.2 (fl x) #f) - (flnormal-pdf 0.0 0.2 (fl y) #f)) - 0.7) - 0.4)) - -1 1 -1 1 - #:samples 40 - ;#:alphas '(0.75) - #:alpha 0.95 - #:color "plum" - #:line-color 6 - ;#:line-style 'transparent - ;#:line-width 2 - )) - #:x-min -1 #:x-max 1 - #:y-min -1 #:y-max 1 - ;#:out-file "test.pdf" - )) + (for/last ([_ (in-range 1)]) + (plot3d + (list (contour-intervals3d + (λ (x y) + (* x (+ 0.1 y))) + -1 1 -1 1 + #:samples 41 + #:alphas '(0.85) + ;#:alpha 0.75 + ;#:line-width 2 + ;#:line-widths '(2) + ;#:line-styles '(transparent) + #:contour-widths '(2) + ;#:color 1 + ;#:label "" + ) + + (surface3d + (λ (x y) + (* (- (* (flnormal-pdf 0.0 0.2 (fl x) #f) + (flnormal-pdf 0.0 0.2 (fl y) #f)) + 0.7) + 0.4)) + -1 1 -1 1 + #:samples 40 + ;#:alphas '(0.75) + #:alpha 0.95 + #:color "plum" + #:line-color 6 + ;#:line-style 'transparent + ;#:line-width 2 + )) + #:x-min -1 #:x-max 1 + #:y-min -1 #:y-max 1 + ;#:out-file "test.pdf" + ))) (plot3d (list (surface3d * -1 1 -1 1 #:samples 6 #:alpha 0.75 #:color 1) (surface3d (λ (x y) (+ 0.1 (* x y))) -1 1 -1 1 #:samples 6 #:alpha 0.75 #:color 2) @@ -140,7 +123,7 @@ slow parts (plot3d (list (isosurface3d (λ (x y z) (+ (- 1 x) (- 1 y) (- z 1.5))) 0 #:alpha 0.85 #:color 2 #:line-color 2 - #:samples 2) + #:samples 4) (discrete-histogram3d (list (vector 'a 'a 1) (vector 'a 'b 2) (vector 'b 'b 3))