octree_grid.cpp
Go to the documentation of this file.
1 #include "octree_grid.h"
2 
4 
5 namespace python
6 {
7  namespace datapointsfilters
8  {
9  void pybindOctreeGrid(py::module& p_module)
10  {
12  py::class_<OctreeGridDataPointsFilter, std::shared_ptr<OctreeGridDataPointsFilter>, DataPointsFilter> octreegridClass(p_module, "OctreeGridDataPointsFilter");
13 
14  octreegridClass.doc() = R"pbdoc(
15 Data Filter based on Octree representation
16 
17 Processings are applyed via a Visitor through Depth-first search in the Octree (DFS)
18 i.e. for each node, the Visitor/Callback is called
19 )pbdoc";
20 
21  using FirstPtsSampler = OctreeGridDataPointsFilter::FirstPtsSampler;
22  py::class_<FirstPtsSampler> firstptssamplerClass(octreegridClass, "FirstPtsSampler", "Visitors class to apply processing");
23 
24  firstptssamplerClass.def_readwrite("idx", &FirstPtsSampler::idx)
25 // .def_readwrite("pts", &FirstPtsSampler::pts, py::return_value_policy::reference) FIXME
26  .def_readwrite("mapidx", &FirstPtsSampler::mapidx, "Build map of (old index to new index), in case we sample pts at the begining of the pointcloud")
27 
28  .def(py::init<DataPoints&>(), py::arg("dp"))
29 
30 // .def("__call__", &FirstPtsSampler::operator()<2>, py::arg("oc")) FIXME
31 // .def("__call__", &FirstPtsSampler::operator()<3>, py::arg("oc")) FIXME
32  .def("finalize", &FirstPtsSampler::finalize);
33 
34  using RandomPtsSampler = OctreeGridDataPointsFilter::RandomPtsSampler;
35  py::class_<RandomPtsSampler, FirstPtsSampler>(firstptssamplerClass, "RandomPtsSampler")
36  .def_readonly("seed", &RandomPtsSampler::seed)
37 
38  .def(py::init<DataPoints&>(), py::arg("dp"))
39  .def(py::init<DataPoints&, const std::size_t>(), py::arg("dp"), py::arg("seed_"))
40 
41 // .def("__call__", &RandomPtsSampler::operator()<2>, py::arg("oc")) FIXME
42 // .def("__call__", &RandomPtsSampler::operator()<3>, py::arg("oc")) FIXME
43  .def("finalize", &RandomPtsSampler::finalize);
44 
45  using CentroidSampler = OctreeGridDataPointsFilter::CentroidSampler;
46  py::class_<CentroidSampler, FirstPtsSampler>(firstptssamplerClass, "CentroidSampler")
47  .def(py::init<DataPoints&>(), py::arg("dp"));
48 
49 // .def("__call__", &CentroidSampler::operator()<2>, py::arg("oc")) FIXME
50 // .def("__call__", &CentroidSampler::operator()<3>, py::arg("oc")); FIXME
51 
52  using MedoidSampler = OctreeGridDataPointsFilter::MedoidSampler;
53  py::class_<MedoidSampler, FirstPtsSampler>(firstptssamplerClass, "MedoidSampler", "Nearest point from the centroid (contained in the cloud)")
54  .def(py::init<DataPoints&>(), py::arg("dp"));
55 
56 // .def("__call__", &RandomPtsSampler::operator()<2>, py::arg("oc")) FIXME
57 // .def("__call__", &RandomPtsSampler::operator()<3>, py::arg("oc")); FIXME
58 
59  using SamplingMethod = OctreeGridDataPointsFilter::SamplingMethod;
60  py::enum_<SamplingMethod>(octreegridClass, "SamplingMethod").value("FIRST_PTS", SamplingMethod::FIRST_PTS)
61  .value("RAND_PTS", SamplingMethod::RAND_PTS).value("CENTROID", SamplingMethod::CENTROID)
62  .value("MEDOID", SamplingMethod::MEDOID).export_values();
63 
64  octreegridClass.def_static("description", &OctreeGridDataPointsFilter::description)
65  .def_static("availableParameters", &OctreeGridDataPointsFilter::availableParameters)
66 
67  .def_readwrite("centerX", &OctreeGridDataPointsFilter::buildParallel)
68  .def_readwrite("centerY", &OctreeGridDataPointsFilter::maxPointByNode)
69  .def_readwrite("centerY", &OctreeGridDataPointsFilter::maxSizeByNode)
70  .def_readonly("centerZ", &OctreeGridDataPointsFilter::samplingMethod)
71 
72  .def(py::init<const Parameters&>(), py::arg("params") = Parameters(), "Constructor, uses parameter interface")
73 
74  .def("filter", &OctreeGridDataPointsFilter::filter)
75  .def("inPlaceFilter", &OctreeGridDataPointsFilter::inPlaceFilter);
76  }
77  }
78 }
OctreeGridDataPointsFilter::buildParallel
bool buildParallel
Definition: OctreeGrid.h:156
OctreeGridDataPointsFilter::MedoidSampler
Definition: OctreeGrid.h:138
OctreeGridDataPointsFilter::CentroidSampler
Definition: OctreeGrid.h:124
OctreeGridDataPointsFilter::maxPointByNode
std::size_t maxPointByNode
Definition: OctreeGrid.h:158
DataPointsFilter
PM::DataPointsFilter DataPointsFilter
Definition: pypoint_matcher_helper.h:22
OctreeGridDataPointsFilter::samplingMethod
SamplingMethod samplingMethod
Definition: OctreeGrid.h:161
Parameters
PM::Parameters Parameters
Definition: filterProfiler.cpp:20
python::datapointsfilters::pybindOctreeGrid
void pybindOctreeGrid(py::module &p_module)
Definition: octree_grid.cpp:9
OctreeGridDataPointsFilter
Data Filter based on Octree representation.
Definition: OctreeGrid.h:54
python
Definition: add_descriptor.cpp:5
OctreeGridDataPointsFilter::SamplingMethod
SamplingMethod
Definition: OctreeGrid.h:153
OctreeGridDataPointsFilter::availableParameters
static const ParametersDoc availableParameters()
Definition: OctreeGrid.h:77
OctreeGrid.h
OctreeGridDataPointsFilter::FirstPtsSampler
Definition: OctreeGrid.h:90
octree_grid.h
OctreeGridDataPointsFilter::RandomPtsSampler
Definition: OctreeGrid.h:107
OctreeGridDataPointsFilter::maxSizeByNode
T maxSizeByNode
Definition: OctreeGrid.h:159
OctreeGridDataPointsFilter::inPlaceFilter
virtual void inPlaceFilter(DataPoints &cloud)
Apply these filters to a point cloud without copying.
Definition: OctreeGrid.cpp:318
OctreeGridDataPointsFilter::filter
virtual DataPoints filter(const DataPoints &input)
Apply filters to input point cloud. This is the non-destructive version and returns a copy.
Definition: OctreeGrid.cpp:310
OctreeGridDataPointsFilter::description
static const std::string description()
Definition: OctreeGrid.h:72


libpointmatcher
Author(s):
autogenerated on Mon Sep 16 2024 02:24:09