(define (make-bounding-box lower-extent upper-extent)
  (lambda (selector)
    (case selector
      ((get-lower-extent)
       (lambda () lower-extent))
      ((get-upper-extent)
       (lambda () upper-extent))
      ((update-max)
       (lambda (bounding-box)
         (if (null? lower-extent)
           (set! lower-extent
             (make-point
               ((((bounding-box 'get-lower-extent)) 'get-x))
               ((((bounding-box 'get-lower-extent)) 'get-y))
               ((((bounding-box 'get-lower-extent)) 'get-z))))
           (let
             ((bb-lower ((bounding-box 'get-lower-extent))))
             (let
               ((bb-x ((bb-lower 'get-x)))
                (bb-y ((bb-lower 'get-y)))
                (bb-z ((bb-lower 'get-z)))
                (x ((lower-extent 'get-x)))
                (y ((lower-extent 'get-y)))
                (z ((lower-extent 'get-z))))
               (if (< bb-x x)
                 ((lower-extent 'set-x) bb-x))
               (if (< bb-y y)
                 ((lower-extent 'set-y) bb-y))
               (if (< bb-z z)
                 ((lower-extent 'set-z) bb-z)))))
         (if (null? upper-extent)
           (set! upper-extent
             (make-point
               ((((bounding-box 'get-upper-extent)) 'get-x))
               ((((bounding-box 'get-upper-extent)) 'get-y))
               ((((bounding-box 'get-upper-extent)) 'get-z))))
           (let
             ((bb-upper ((bounding-box 'get-upper-extent))))
             (let
               ((bb-x ((bb-upper 'get-x)))
                (bb-y ((bb-upper 'get-y)))
                (bb-z ((bb-upper 'get-z)))
                (x ((upper-extent 'get-x)))
                (y ((upper-extent 'get-y)))
                (z ((upper-extent 'get-z))))
               (if (> bb-x x)
                 ((upper-extent 'set-x) bb-x))
               (if (> bb-y y)
                 ((upper-extent 'set-y) bb-y))
               (if (> bb-z z)
                 ((upper-extent 'set-z) bb-z)))))))
      ((display)
       (lambda ()
         (display "bounding box ")
         ((lower-extent 'display))
         (display " ")
         ((upper-extent 'display))))
      (else
       (render-error "make-bounding-box" "Invalid selector: " selector)))))
