以下代碼展示了如何利用C++與Techlego庫(kù)執(zhí)行平面擬合并刪除指定平面上的點(diǎn)云:
```cpp
#include "pch.h"
int main()
{
// 創(chuàng)建協(xié)議通過(guò)IP端口
auto protocol = techlego::create_binary_protocol(L"localhost", 5252);
// 使用協(xié)議創(chuàng)建客戶(hù)端
auto client = techlego::h_scan3d_client::make_shared(protocol);
// 獲取底面點(diǎn)云
std::vector<techlego::point3d> points;
auto returns = techlego::read_file(L"D:\\plane.asc", points);
if (returns == nullptr)
{
std::cout << "讀取文件成功\n";
}
else
{
std::cout << "讀取文件錯(cuò)誤\n";
return -1;
}
// 擬合平面并獲取平面上的點(diǎn)和法線(xiàn)
techlego::pos6d plane{};
double a = plane.fit_plane(points);
// 執(zhí)行一次掃描并獲取點(diǎn)云
if (!client->scan_and_get_data(points))
{
std::cout << "掃描錯(cuò)誤\n";
}
// 將當(dāng)前點(diǎn)作為平面上的點(diǎn),點(diǎn)的法線(xiàn)作為平面的法線(xiàn),刪除點(diǎn)云(刪除底面)
plane.filter_points_by_plane(points, -50, 5);
// 將刪除后的點(diǎn)云替換到指定掃描組
client->replace_scan_data_by_index(0, points, 0);
return 0;
}
```