ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
CCMiscTools.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 
10 #include <CVMiscTools.h>
11 
12 namespace py = pybind11;
13 using namespace pybind11::literals;
14 
15 void define_CCMiscTools(py::module &cccorelib)
16 {
17  py::class_<cloudViewer::CCMiscTools> CCMiscTools(cccorelib, "CCMiscTools");
18  CCMiscTools.def_static(
19  "EnlargeBox", &cloudViewer::CCMiscTools::EnlargeBox, "dimMin"_a, "dimMax"_a, "coef"_a);
20  CCMiscTools.def_static("MakeMinAndMaxCubical",
22  "dimMin"_a,
23  "dimMax"_a,
24  "enlargeFactor"_a = 0.01);
25 
26  CCMiscTools.def_static("ComputeBaseVectors",
27  (void (*)(const CCVector3 &, CCVector3 &, CCVector3 &))(
29  "N"_a,
30  "X"_a,
31  "Y"_a);
32 
33  CCMiscTools.def_static("ComputeBaseVectors",
34  (void (*)(const CCVector3d &, CCVector3d &, CCVector3d &))(
36  "N"_a,
37  "X"_a,
38  "Y"_a);
39 
40  CCMiscTools.def_static(
41  "TriBoxOverlap",
42  [](const CCVector3 &boxCenter, const CCVector3 boxhalfsize, py::list &triverts)
43  {
44  const CCVector3 *trueTrivers[3] = {
45  triverts[0].cast<CCVector3 *>(),
46  triverts[1].cast<CCVector3 *>(),
47  triverts[2].cast<CCVector3 *>(),
48  };
49 
50  return cloudViewer::CCMiscTools::TriBoxOverlap(boxCenter, boxhalfsize, trueTrivers);
51  },
52  "boxcenter"_a,
53  "boxhalfsize"_a,
54  "triverts"_a);
55 
56  CCMiscTools.def_static("TriBoxOverlapd",
58  "boxcenter"_a,
59  "boxhalfsize"_a,
60  "triverts"_a);
61 }
void define_CCMiscTools(py::module &cccorelib)
Definition: CCMiscTools.cpp:15
static void ComputeBaseVectors(const CCVector3 &N, CCVector3 &X, CCVector3 &Y)
Computes base vectors for a given 3D plane.
static bool TriBoxOverlap(const CCVector3 &boxcenter, const CCVector3 &boxhalfsize, const CCVector3 *triverts[3])
Ovelap test between a 3D box and a triangle.
static void EnlargeBox(CCVector3 &dimMin, CCVector3 &dimMax, double coef)
Proportionally enlarges a 3D box.
static bool TriBoxOverlapd(const CCVector3d &boxcenter, const CCVector3d &boxhalfsize, const CCVector3d triverts[3])
Ovelap test between a 3D box and a triangle (double version)
static void MakeMinAndMaxCubical(CCVector3 &dimMin, CCVector3 &dimMax, double enlargeFactor=0.01)
Transforms a 3D box into a 3D cube.
Definition: CVMiscTools.cpp:88