title: How to calculate total volume of multiple overlapping cuboids
body: <p>I have a list of Cuboids, defined by their coordinates of their lower-left-back and upper-right-front corners, with edges parallel to the axis. Coordinates are double values. These cuboids are densely packed, will overlap with one or more others, or even fully contain others. </p>
  
  <p>I need to calculate the total volume encompassed by all the given cuboids. Areas which overlap (even multiple times) should be counted exactly once.</p>
  
  <p>For example, the volumes: </p>
  
  <ol>
  <li>((0,0,0) (3,3,3))</li>
  <li>((0,1,0) (2,2,4))</li>
  <li>((1,0,1) (2,5,2))</li>
  <li>((6,6,6) (8,8,8))</li>
  </ol>
  
  <p>The total volume is 27 + 1 + 2 + 8 = 38.
  Is there an easy way to do this ( in O(n^3) time or better?) ?</p>