MCPcopy Create free account
hub / github.com/JeremyBYU/polylidar / main

Function main

examples/cpp/simple.cpp:19–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 return os;
18}
19int main(int argc, char const* argv[])
20{
21 std::cout << "Very Simple C++ Example of Polylidar3D on 2D Point Set" << std::endl;
22 std::vector<double> points_data = {
23 0.0, 0.0, // Point index 0
24 0.0, 1.0, // Point index 1
25 1.0, 1.0, // Point index 2
26 1.0, 0.0, // Point index 3
27 5.0, 0.1, // Point index 4, outlier and should not be included in polygon
28 };
29
30 // 5 X 2 matrix as one contigious array
31 std::vector<std::size_t> shape = {points_data.size() / 2, 2};
32 Polylidar::Matrix<double> points(points_data.data(), shape[0], shape[1]);
33 // Set configuration parameters
34
35 // alpha, lmax, min triangles, min hole vertices,
36 Polylidar::Polylidar3D pl(0.0, 2.0, 1, 3);
37
38 Polylidar::MeshHelper::HalfEdgeTriangulation mesh;
39 Polylidar::Planes planes;
40 Polylidar::Polygons polygons;
41 auto before = std::chrono::high_resolution_clock::now();
42 std:tie(mesh, planes, polygons) = pl.ExtractPlanesAndPolygons(points);
43 auto after = std::chrono::high_resolution_clock::now();
44
45 auto elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(after - before);
46 std::cout << "Polylidar took " << elapsed.count() << " milliseconds processing a " << shape[0] << " point cloud"
47 << std::endl;
48 std::cout << "Point indices of Polygon Shell: ";
49 // Extract polygon
50 for (auto const& polygon : polygons)
51 {
52 std::cout << polygon.shell << std::endl;
53 }
54 // Point indices of Polygon Shell: [3,0,1,2]
55
56 std::cout << std::endl;
57
58 return 0;
59}

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected