ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccNormalVectors.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/native_enum.h>
9 #include <pybind11/pybind11.h>
10 #include <pybind11/stl.h>
11 #include <pybind11/stl_bind.h>
12 
13 #include <ecvNormalVectors.h>
14 #include <ecvProgressDialog.h>
15 
16 namespace py = pybind11;
17 using namespace pybind11::literals;
18 
19 void define_ccNormalVectors(py::module &m)
20 {
21  py::class_<ccNormalVectors> pyNormalVectors(m, "ccNormalVectors");
22 
23  pyNormalVectors.def_static("GetUniqueInstance", &ccNormalVectors::GetUniqueInstance)
24  .def_static("ReleaseUniqueInstance", &ccNormalVectors::ReleaseUniqueInstance)
25  .def_static("GetNumberOfVectors", &ccNormalVectors::GetNumberOfVectors)
26  .def_static("GetNormal", &ccNormalVectors::GetNormal, "normIndex"_a)
27  .def(
28  "getNormal",
29  [](const ccNormalVectors &self, unsigned normIndex) -> const CCVector3 &
30  { return self.getNormal(normIndex); },
31  "normIndex"_a)
32  .def_static(
33  "GetNormIndex",
34  static_cast<CompressedNormType (*)(const CCVector3 &N)>(&ccNormalVectors::GetNormIndex),
35  "N"_a);
36 
37  py::native_enum<ccNormalVectors::Orientation>(
38  pyNormalVectors, "Orientation", "enum.Enum", "ccNormalVectors::Orientation.")
39  .value("PLUS_X", ccNormalVectors::Orientation::PLUS_X)
40  .value("MINUS_X", ccNormalVectors::Orientation::MINUS_X)
41  .value("PLUS_Y", ccNormalVectors::Orientation::PLUS_Y)
42  .value("MINUS_Y", ccNormalVectors::Orientation::MINUS_Y)
43  .value("PLUS_Z", ccNormalVectors::Orientation::MINUS_Z)
44  .value("PLUS_BARYCENTER", ccNormalVectors::Orientation::PLUS_BARYCENTER)
45  .value("MINUS_BARYCENTER", ccNormalVectors::Orientation::MINUS_BARYCENTER)
46  .value("PLUS_ORIGIN", ccNormalVectors::Orientation::PLUS_ORIGIN)
47  .value("MINUS_ORIGIN", ccNormalVectors::Orientation::MINUS_ORIGIN)
48  .value("PREVIOUS", ccNormalVectors::Orientation::PREVIOUS)
49  .value("PLUS_SENSOR_ORIGIN", ccNormalVectors::Orientation::PLUS_SENSOR_ORIGIN)
50  .value("MINUS_SENSOR_ORIGIN", ccNormalVectors::Orientation::MINUS_SENSOR_ORIGIN)
51  .value("UNDEFINED", ccNormalVectors::Orientation::UNDEFINED)
52  .export_values()
53  .finalize();
54 
55  // TODO NormsIndexTable type cause symbols problems at runtime when the .so of the plugin is
56  // loaded pyNormalVectors
57  // .def_static("ComputeCloudNormals",
58  // &ccNormalVectors::ComputeCloudNormals,
59  // "cloud"_a,
60  // "theNormCodes"_a,
61  // "localModel"_a,
62  // "localRadius"_a,
63  // "preferredOrientation"_a = ccNormalVectors::Orientation::UNDEFINED,
64  // "progressCb"_a = nullptr,
65  // "inputOctree"_a = nullptr);
66  // .def_static("UpdateNormalOrientations",
67  // &ccNormalVectors::UpdateNormalOrientations,
68  // "cloud"_a,
69  // "theNormsCodes"_a,
70  // "preferredOrientation"_a)
71  // .def_static("ConvertNormalToStrikeAndDip",
72  // &ccNormalVectors::ConvertNormalToStrikeAndDip,
73  // "N"_a,
74  // "dip_deg"_a,
75  // "dipDir_deg"_a)
76  // .def_static("ConvertNormalToDipAndDipDir",
77  // &ccNormalVectors::ConvertNormalToDipAndDipDir,
78  // "N"_a,
79  // "dip_deg"_a,
80  // "dip_deg"_a)
81  // .def_static("ConvertDipAndDipDirToNormal",
82  // &ccNormalVectors::ConvertNormalToDipAndDipDir,
83  // "dip_deg"_a,
84  // "dipDir_deg"_a,
85  // "upward"_a = true)
86  // .def_static("ConvertStrikeAndDipToString",
87  // &ccNormalVectors::ConvertStrikeAndDipToString,
88  // "strike_deg"_a,
89  // "dip_deg"_a)
90  // .def_static("ConvertDipAndDipDirToString",
91  // &ccNormalVectors::ConvertDipAndDipDirToString,
92  // "strike_deg"_a,
93  // "dipDir_deg"_a)
94  // .def_static("ConvertNormalToHSV",
95  // [](const CCVector3 &N)
96  // {
97  // float H, S, V;
98  // ccNormalVectors::ConvertNormalToHSV(N, H, S, V);
99  // return py::make_tuple(H, S, V);
100  // })
101  // .def_static("ConvertNormalToRGB", &ccNormalVectors::ConvertNormalToRGB, "N"_a)
102  // .def("enableNormalHSVColorsArray", &ccNormalVectors::enableNormalHSVColorsArray)
103  // .def("getNormalHSVColor", &ccNormalVectors::getNormalHSVColor, "index"_a)
104  // .def("getNormalHSVColorArray", &ccNormalVectors::getNormalHSVColorArray);
105  // TODO 3 helpers
106 }
void define_ccNormalVectors(py::module &m)
Compressed normal vectors handler.
static ccNormalVectors * GetUniqueInstance()
Returns unique instance.
static const CCVector3 & GetNormal(unsigned normIndex)
Static access to ccNormalVectors::getNormal.
static unsigned GetNumberOfVectors()
Returns the number of compressed normal vectors.
static CompressedNormType GetNormIndex(const PointCoordinateType N[])
Returns the compressed index corresponding to a normal vector.
static void ReleaseUniqueInstance()
Releases unique instance.
unsigned int CompressedNormType
Compressed normals type.
Definition: ecvBasicTypes.h:16