//
// Created by zx on 23-11-28.
//

#include "transitData.h"

TransitData::TransitData() {
    for (int i = 0; i < 4; i++) {
        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
        m_clouds_vct.emplace_back(cloud);
    }
}

#include <pcl/io/pcd_io.h>
void TransitData::setCloud(int id, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud) {
    m_mutex_clouds_vct[id].lock();
    m_clouds_vct[id]->clear();
    pcl::copyPointCloud(*cloud, *m_clouds_vct[id]);
    m_mutex_clouds_vct[id].unlock();
}

void TransitData::getCloud(int id, pcl::PointCloud<pcl::PointXYZ>::Ptr cloud) {
    m_mutex_clouds_vct[id].lock();
    cloud->clear();
    pcl::copyPointCloud(*m_clouds_vct[id], *cloud);
    m_mutex_clouds_vct[id].unlock();
}
