ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ccPlane.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 
12 #include "../casters.h"
13 
15 #include <ecvPlane.h>
16 
17 namespace py = pybind11;
18 using namespace pybind11::literals;
19 
20 void define_ccPlane(py::module &m)
21 {
22 
23  py::class_<ccPlanarEntityInterface>(m, "ccPlanarEntityInterface")
24  .def("showNormalVector", &ccPlanarEntityInterface::showNormalVector, "state"_a)
25  .def("normalVectorIsShown", &ccPlanarEntityInterface::normalVectorIsShown)
26  .def("getNormal", &ccPlanarEntityInterface::getNormal);
27 
28  py::class_<ccPlane, ccGenericPrimitive, ccPlanarEntityInterface>(m,
29  "ccPlane",
30  R"doc(
31  ccPlane
32 
33  Parameters
34  ----------
35  xWidth : PointCoordinateType
36  yWidth : PointCoordinateType
37  transMat : , optional
38  optional 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)
39  name : str, default: Sphere
40  name of the sphere object
41  uniqueID : int, optional
42  unique ID (handle with care)
43 
44  Example
45  -------
46  >>> import pycc
47  >>> plane = pycc.ccPlane(10.0, 5.0)
48  >>> plane.getXWidth()
49  10.0
50  >>> plane.getYWidth()
51  5.0
52  >>> plane.setXWidth(15.0)
53  >>> plane.setYWidth(12.5)
54  >>> plane.getXWidth()
55  15.0
56  >>> plane.getYWidth()
57  12.5
58  )doc")
59  .def(py::init<PointCoordinateType, PointCoordinateType, const ccGLMatrix *, QString>(),
60  "xWidth"_a,
61  "yWidth"_a,
62  "transMat"_a = nullptr,
63  "name"_a = QString("Plane"))
64  .def("getXWidth", &ccPlane::getXWidth)
65  .def("getYWidth", &ccPlane::getYWidth)
66  .def("getCenter", &ccPlane::getCenter)
67  .def("setXWidth", &ccPlane::setXWidth, "w"_a, "autoUpdate"_a = true)
68  .def("setYWidth", &ccPlane::setYWidth, "h"_a, "autoUpdate"_a = true)
69  // TODO setAsTexture, will need QImage
70  // TODO setQuadTexture, also needs QImage
71  .def_static("Fit", &ccPlane::Fit, "cloud"_a, "rms"_a)
72  .def("getEquation",
73  [](const ccPlane &self)
74  {
75  CCVector3 N;
76  PointCoordinateType constVal;
77 
78  self.getEquation(N, constVal);
79  return py::make_tuple(N, constVal);
80  })
81  .def("flip", &ccPlane::flip);
82 }
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
void define_ccPlane(py::module &m)
Definition: ccPlane.cpp:20
void showNormalVector(bool state)
Show normal vector.
bool normalVectorIsShown() const
Whether normal vector is shown or not.
virtual CCVector3 getNormal() const =0
Returns the entity normal.
Plane (primitive)
Definition: ecvPlane.h:18
static ccPlane * Fit(cloudViewer::GenericIndexedCloudPersist *cloud, double *rms=0)
Fits a plane primitive on a cloud.
CCVector3 getCenter() const
Returns the center.
Definition: ecvPlane.h:56
void flip()
Flips the plane.
void setXWidth(PointCoordinateType w, bool autoUpdate=true)
Sets 'X' width.
Definition: ecvPlane.h:61
PointCoordinateType getXWidth() const
Returns 'X' width.
Definition: ecvPlane.h:50
PointCoordinateType getYWidth() const
Returns 'Y' width.
Definition: ecvPlane.h:53
void setYWidth(PointCoordinateType h, bool autoUpdate=true)
Sets 'Y' width.
Definition: ecvPlane.h:67