 #include <iostream>
 #include <stdexcept>
 
+#include <thrust/remove.h>
 #include <thrust/sort.h>
 #include <thrust/transform.h>
 

                              thrust::device_vector<MortonBound>::iterator boundsBegin,
                              thrust::device_vector<MortonBound>::iterator boundsEnd);

void MortonDacrtNodes::Create(RayContainer& rayContainer, SpheresGeometry& spheres) {
    
    // TestMortonEncoding();

    ReduceMinMaxMortonByAxis(rayMortonCodes.begin(), rayMortonCodes.end(),
                             bounds.begin(), bounds.end());

    // Cull inactive partitions.
    thrust::device_vector<MortonBound>::iterator boundsEnd = thrust::remove_if(bounds.begin(), bounds.end(), InvalidAxis());
    bounds.resize(boundsEnd - bounds.begin());
    std::cout << "Bounds:\n" << bounds << std::endl;
    
    MortonBound firstBound = bounds[0];
    std::cout << "HyperCube: " << rayMortonCoder.HyperCubeFromBound(firstBound) << std::endl;

    exit(0);

    /*    
    // Geometry partition
