ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccPolyline.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include <pybind11/pybind11.h>
9 #include <pybind11/stl.h>
10 #include <pybind11/stl_bind.h>
11 
13 #include <ecvPointCloud.h>
14 #include <ecvPolyline.h>
15 
16 #include "../casters.h"
17 
18 namespace py = pybind11;
19 using namespace pybind11::literals;
20 
21 void define_ccPolyline(py::module &m)
22 {
23  py::class_<ccPolyline, cloudViewer::Polyline, ccShiftedObject>(m, "ccPolyline")
24  .def(py::init([](cloudViewer::GenericIndexedCloudPersist *cloud)
25  { return new ccPolyline(cloud); }),
26  "associatedCloud"_a,
27  py::keep_alive<1, 2>() // Keep cloud alive while polyline is
28  )
29 
30  .def("set2DMode", &ccPolyline::set2DMode, "state"_a)
31  .def("is2DMode", &ccPolyline::is2DMode)
32  .def("setForeground", &ccPolyline::setForeground, "state"_a)
33  .def("setColor", &ccPolyline::setColor, "col"_a)
34  .def("setWidth", &ccPolyline::setWidth, "width"_a)
35  .def("getWidth", &ccPolyline::getWidth)
36  .def("getColor", &ccPolyline::getColor)
37  .def(
38  "split",
39  [](ccPolyline &self, PointCoordinateType maxEdgeLength)
40  {
41  std::vector<ccPolyline *> parts;
42  self.split(maxEdgeLength, parts);
43  return parts;
44  },
45  "maxEdgeLength"_a)
46  .def("computeLength", &ccPolyline::computeLength)
47  .def("showVertices", &ccPolyline::showVertices, "state"_a)
48  .def("verticesShown", &ccPolyline::verticesShown)
49  .def("setVertexMarkerWidth", &ccPolyline::setVertexMarkerWidth, "width"_a)
50  .def("getVertexMarkerWidth", &ccPolyline::getVertexMarkerWidth)
51  // TODO .def("initWith", &ccPolyline::initWith, "vertices"_a, "poly"_a)
52  .def("importParametersFrom", &ccPolyline::importParametersFrom, "poly"_a)
53  .def("showArrow", &ccPolyline::showArrow, "state"_a, "vertIndex"_a, "length"_a)
54  .def("segmentCount", &ccPolyline::segmentCount)
55  .def("samplePoints",
57  "densityBased"_a,
58  "samplingParameter"_a,
59  "withRGB"_a)
60  .def("smoothChaikin", &ccPolyline::smoothChaikin, "ratio"_a, "iterationCount"_a);
61 }
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
void define_ccPolyline(py::module &m)
Definition: ccPolyline.cpp:21
Colored polyline.
Definition: ecvPolyline.h:24
PointCoordinateType computeLength() const
Computes the polyline length.
void setForeground(bool state)
Defines if the polyline is drawn in background or foreground.
bool verticesShown() const
Whether the polyline vertices should be displayed or not.
Definition: ecvPolyline.h:131
void set2DMode(bool state)
Defines if the polyline is considered as 2D or 3D.
ccPointCloud * samplePoints(bool densityBased, double samplingParameter, bool withRGB)
Samples points on the polyline.
bool is2DMode() const
Returns whether the polyline is considered as 2D or 3D.
Definition: ecvPolyline.h:63
ccPolyline * smoothChaikin(PointCoordinateType ratio, unsigned iterationCount) const
Smoothes the polyline (Chaikin algorithm)
void showArrow(bool state, unsigned vertIndex, PointCoordinateType length)
Shows an arrow in place of a given vertex.
const ecvColor::Rgb & getColor() const
Returns the polyline color.
Definition: ecvPolyline.h:99
void setVertexMarkerWidth(int width)
Sets the width of vertex markers.
Definition: ecvPolyline.h:137
void importParametersFrom(const ccPolyline &poly)
Copy the parameters from another polyline.
void showVertices(bool state)
Sets whether to display or hide the polyline vertices.
Definition: ecvPolyline.h:129
unsigned segmentCount() const
Returns the number of segments.
PointCoordinateType getWidth() const
Returns the width of the line.
Definition: ecvPolyline.h:94
int getVertexMarkerWidth() const
Returns the width of vertex markers.
Definition: ecvPolyline.h:139
void setColor(const ecvColor::Rgb &col)
Sets the polyline color.
Definition: ecvPolyline.h:81
void setWidth(PointCoordinateType width)
Sets the width of the line.
A generic 3D point cloud with index-based and presistent access to points.