Project: s41467-023-44554-8 | Function: Buffer2DepthMap (cpp)

system: You are an expert C++ programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow C++ best practices and maintain consistent code style.
Return **only** the complete C++ function code.

user: Complete this C++ function:

**DESCRIPTION:** Converts buffered LiDAR points into depth maps for temporal analysis, implementing the depth image library update mechanism

**KEY TERMS:** {
  "buffer": "point buffer",
  "depth_map_list": "depth image library",
  "buffer_delay": "accumulation time period",
  "depth_map_dur": "depth map duration",
  "SphericalProjection": "spherical coordinate transformation"
}

**CONTEXT CODE:**             if (dyn_tag_origin[i] == 1 || dyn_tag_origin[i] == 2)
            {
                if(is_rec) 
                {
                    int tmp = 251;
                    out.write((char*)&tmp, sizeof(int));
                }
            } 
            else
            {
                if(is_rec)
                {
                    int tmp = 9;
                    out.write((char*)&tmp, sizeof(int));
                }
            } 
        }
    }
    double total_test1 = 0, total_test2 = 0, total_test3 = 0, total_proj = 0, total_occ = 0, total_map = 0;
    for (int i = 0; i < size; i++)
    {
        total_test1 += time_test1[i];
        total_test2 += time_test2[i];
        total_test3 += time_test3[i];
        total_proj += time_proj[i];
        total_occ += time_occ_check[i];
        total_map += time_map_cons[i];
    }
    if(time_breakdown_file != "") 
    {
        time_breakdown_out << total_test1 << " " << total_test2 << " "<< total_test3 << " " << total_proj << " " << total_occ << " " << total_map << endl;
    }
    frame_num_for_rec ++;
    cur_point_soph_pointers = (cur_point_soph_pointers + 1)%max_pointers_num;
    if(is_rec) out.close();
    time_total = omp_get_wtime() - t00;
    time_ind ++;
    time_total_avr = time_total_avr * (time_ind - 1) / time_ind + time_total / time_ind;
}

void  DynObjFilter::Points2Buffer(vector<point_soph*> &points, std::vector<int> &index_vector)
{
    int cur_tail = buffer.tail;
    buffer.push_parallel_prepare(points.size());
    std::for_each(std::execution::par, index_vector.begin(), index_vector.end(), [&](const int &i)
    {   
        buffer.push_parallel(points[i], cur_tail+i);
    });
}

void  DynObjFilter::Buffer2DepthMap(double cur_time)
{
  std::cerr << "Function Buffer2DepthMap has been masked" << std::endl;
  throw std::runtime_error("Function implementation has been masked");
}

void  DynObjFilter::SphericalProjection(point_soph &p, int depth_index, const M3D &rot, const V3D &transl, point_soph &p_spherical)
{
    if(fabs(p.last_vecs.at(depth_index%HASH_PRIM)[2]) > 10E-5)
    {       
        p_spherical.vec = p.last_vecs.at(depth_index%HASH_PRIM);
        p_spherical.hor_ind = p.last_positions.at(depth_index%HASH_PRIM)[0];
        p_spherical.ver_ind = p.last_positions.at(depth_index%HASH_PRIM)[1];
        p_spherical.position = p.last_positions.at(depth_index%HASH_PRIM)[2];     
    }
    else
    {
        V3D p_proj(rot*(p.glob - transl));
        p_spherical.GetVec(p_proj, hor_resolution_max, ver_resolution_max);
        p.last_vecs.at(depth_index%HASH_PRIM) = p_spherical.vec;
        p.last_positions.at(depth_index%HASH_PRIM)[0] = p_spherical.hor_ind;
        p.last_positions.at(depth_index%HASH_PRIM)[1] = p_spherical.ver_ind;
        p.last_positions.at(depth_index%HASH_PRIM)[2] = p_spherical.position;
    }
}

bool  DynObjFilter::InvalidPointCheck(const V3D &body, const int intensity)
{
    if ((pow(body(0), 2) + pow(body(1), 2) + pow(body(2), 2)) < blind_dis*blind_dis || (dataset == 1 && fabs(body(0)) < 0.1 && fabs(body(1)) < 1.0) && fabs(body(2)) < 0.1)
    {
        return true;
    } 
    else
    {
        return false;
    }
}

bool  DynObjFilter::SelfPointCheck(const V3D &body, const dyn_obj_flg dyn)
{
    if (dataset == 0)
    {      
        if( (body(0) > -1.2 && body(0) < -0.4 && body(1) > -1.7 && body(1) < -1.0 && body(2) > -0.65 && body(2) < -0.4) || \
            (body(0) > -1.75 && body(0) < -0.85 && body(1) > 1.0 && body(1) < 1.6 && body(2) > -0.75 && body(2) < -0.40) || \
            (body(0) > 1.4 && body(0) < 1.7 && body(1) > -1.3 && body(1) < -0.9 && body(2) > -0.8 && body(2) < -0.6) || \
            (body(0) > 2.45 && body(0) < 2.6 && body(1) > -0.6 && body(1) < -0.45 && body(2) > -1.0 && body(2) < -0.9) || \
            (body(0) > 2.45 && body(0) < 2.6 && body(1) > 0.45 && body(1) < 0.6 && body(2) > -1.0 && body(2) < -0.9) )
        {
            return true;
        }
        else
        {
            return false;
        }
    } 
    return false;
}

bool  DynObjFilter::CheckVerFoV(const point_soph & p, const DepthMap &map_info)
{
    bool ver_up = false, ver_down = false;
    for(int i = p.ver_ind; i >= pixel_fov_down; i--)
    {   
        int cur_pos = p.hor_ind * MAX_1D_HALF + i;
        if(map_info.depth_map[cur_pos].size() > 0)
        {
            ver_down = true;
            break;
        }
    } 
    for(int i = p.ver_ind; i <= pixel_fov_up; i++)
    {   
        int cur_pos = p.hor_ind * MAX_1D_HALF + i;
        if(map_info.depth_map[cur_pos].size() > 0)
        {
            ver_up = true;
            break;
        }
    }   
    if(ver_up && ver_down)
    {
        return false;
    }
    else
    {
        return true;
    }
}

void DynObjFilter::CheckNeighbor(const point_soph & p, const DepthMap &map_info, float &max_depth, float &min_depth)
{   
    int n = checkneighbor_range;
    for (int i = -n; i <= n; i++)
    {
        for (int j = -n; j <= n; j++)
        {
            int cur_pos = (p.hor_ind + i) * MAX_1D_HALF + p.ver_ind + j;
            if(cur_pos < MAX_2D_N && cur_pos >= 0 && map_info.depth_map[cur_pos].size() > 0)
            {
                float cur_max_depth = map_info.max_depth_static[cur_pos];


Complete the function implementation replacing "throw std::runtime_error("Not implemented");".