ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
BoundingBox.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/operators.h>
9 #include <pybind11/pybind11.h>
10 
11 #include <BoundingBox.h>
12 
13 namespace py = pybind11;
14 using namespace pybind11::literals;
15 
16 void define_BoundingBox(py::module &cccorelib)
17 {
18  py::class_<cloudViewer::BoundingBox>(cccorelib, "BoundingBox")
19  .def(py::init<>())
20  .def(py::init(
21  [](const CCVector3 &minCorner, const CCVector3 &maxCorner, bool valid = true)
22  {
23  auto bbox = new cloudViewer::BoundingBox(minCorner, maxCorner);
24  if (bbox)
25  {
26  bbox->setValidity(valid);
27  }
28  return bbox;
29  }),
30  "minCorner"_a,
31  "maxCorner"_a,
32  "valid"_a = true)
33  .def("clear", &cloudViewer::BoundingBox::clear)
34  .def("add", &cloudViewer::BoundingBox::add, "aPoint"_a)
35  .def("minCorner", [](const cloudViewer::BoundingBox &self) { return self.minCorner(); })
36  .def("maxCorner", [](const cloudViewer::BoundingBox &self) { return self.maxCorner(); })
37  .def("getCenter", &cloudViewer::BoundingBox::getCenter)
38  .def("getDiagVec", &cloudViewer::BoundingBox::getDiagVec)
39  .def("getDiagNorm", &cloudViewer::BoundingBox::getDiagNorm)
40  .def("getDiagNormd", &cloudViewer::BoundingBox::getDiagNormd)
41  .def("getMinBoxDim", &cloudViewer::BoundingBox::getMinBoxDim)
42  .def("getMaxBoxDim", &cloudViewer::BoundingBox::getMaxBoxDim)
43  .def("computeVolume", &cloudViewer::BoundingBox::computeVolume)
44  .def("setValidity", &cloudViewer::BoundingBox::setValidity, "state"_a)
45  .def("isValid", &cloudViewer::BoundingBox::isValid)
46  .def("minDistTo", &cloudViewer::BoundingBox::minDistTo, "box"_a)
47  .def("contains", &cloudViewer::BoundingBox::contains, "P"_a)
48  .def(py::self + py::self)
49  .def(py::self += py::self)
50  .def(py::self += CCVector3())
51  .def(py::self -= CCVector3())
52  .def(py::self *= double());
53  // TODO operator *= square matrix
54 }
void define_BoundingBox(py::module &cccorelib)
Definition: BoundingBox.cpp:16
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
Vector3Tpl< PointCoordinateType > getDiagVec() const
Returns diagonal vector.
Definition: BoundingBox.h:169
double getDiagNormd() const
Returns diagonal length (double precision)
Definition: BoundingBox.h:175
Vector3Tpl< PointCoordinateType > getCenter() const
Returns center.
Definition: BoundingBox.h:164
bool contains(const Vector3Tpl< PointCoordinateType > &P) const
Returns whether a points is inside the box or not.
Definition: BoundingBox.h:231
PointCoordinateType minDistTo(const BoundingBoxTpl< PointCoordinateType > &bbox) const
Definition: BoundingBox.h:209
PointCoordinateType getDiagNorm() const
Returns diagonal length.
Definition: BoundingBox.h:172
PointCoordinateType getMinBoxDim() const
Returns minimal box dimension.
Definition: BoundingBox.h:178
void setValidity(bool state)
Sets bonding box validity.
Definition: BoundingBox.h:200
double computeVolume() const
Returns the bounding-box volume.
Definition: BoundingBox.h:192
PointCoordinateType getMaxBoxDim() const
Returns maximal box dimension.
Definition: BoundingBox.h:185
bool isValid() const
Returns whether bounding box is valid or not.
Definition: BoundingBox.h:203
void add(const Vector3Tpl< PointCoordinateType > &P)
'Enlarges' the bounding box with a point
Definition: BoundingBox.h:131
BoundingBoxTpl< PointCoordinateType > BoundingBox
Default bounding-box type.
Definition: BoundingBox.h:304