Skip to content

Commit fbaba7d

Browse files
p-leroytmontaigu
authored andcommitted
Add ccDisc primitive
1 parent a0acb1e commit fbaba7d

File tree

9 files changed

+111
-11
lines changed

9 files changed

+111
-11
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ include(cmake/CloudCompareVariables.cmake)
77

88
option(PLUGIN_PYTHON "Install Python Plugin" OFF)
99

10+
set(CMAKE_CXX_STANDARD 17)
11+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12+
1013
if(PLUGIN_PYTHON)
1114
project(PythonRuntime)
1215

cmake/Helpers.cmake

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,24 @@ function(copy_python_dll)
4040
DEBUG
4141
"Python DLL: = ${Python_RUNTIME_LIBRARY_DIRS}/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.dll"
4242
)
43-
install(
44-
FILES "${Python_RUNTIME_LIBRARY_DIRS}/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.dll"
43+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
44+
message(STATUS "Debug build")
45+
install(
46+
FILES "${Python_RUNTIME_LIBRARY_DIRS}/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}_d.dll"
47+
# install the python3 base dll as well because some libs will try to
48+
# find it (PySide and PyQT for example)
49+
"${Python_RUNTIME_LIBRARY_DIRS}/python${Python_VERSION_MAJOR}_d.dll"
50+
DESTINATION ${CLOUDCOMPARE_DEST_FOLDER}
51+
)
52+
else()
53+
install(
54+
FILES "${Python_RUNTIME_LIBRARY_DIRS}/python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.dll"
4555
# install the python3 base dll as well because some libs will try to
4656
# find it (PySide and PyQT for example)
4757
"${Python_RUNTIME_LIBRARY_DIRS}/python${Python_VERSION_MAJOR}.dll"
48-
DESTINATION ${CLOUDCOMPARE_DEST_FOLDER}
49-
)
58+
DESTINATION ${CLOUDCOMPARE_DEST_FOLDER}
59+
)
60+
endif()
5061
endfunction()
5162

5263
function(manage_windows_install)

docs/python/pycc/primitives.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ __________________
99
:undoc-members:
1010
:show-inheritance:
1111

12+
ccDisc
13+
________
14+
15+
.. autoclass:: pycc.ccDisc
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:
19+
1220
ccSphere
1321
________
1422

docs/stubfiles/pycc.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ class ccShiftedObject(ccHObject):
427427
@overload
428428
def setGlobalShift(*args, **kwargs) -> Any: ...
429429

430+
class ccDisc(ccGenericPrimitive):
431+
def __init__(self, radius: float, transMat: ccGLMatrix = ..., name: QString = ..., precision: int = ..., uniqueId: int = ...) -> None: ...
432+
def getRadius(self) -> float: ...
433+
def setRadius(self, radius: float) -> None: ...
434+
430435
class ccSphere(ccGenericPrimitive):
431436
def __init__(self, radius: float, transMat: ccGLMatrix = ..., name: QString = ..., precision: int = ..., uniqueId: int = ...) -> None: ...
432437
def getRadius(self) -> float: ...

tests/test_cmdline.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ def test_normal_kdtree(cloudcompare_exe):
4545
cloudcompare_exe, "-SILENT", "-O", f"{abspath}/data/a_cloud.bin", "-PYTHON_SCRIPT",
4646
os.path.join(abspath, "scripts", "kdtree.py"))
4747

48-
49-
def test_normal_kdtree(cloudcompare_exe):
50-
assert_command_runs(
51-
cloudcompare_exe, "-SILENT", "-O", f"{abspath}/data/a_cloud.bin", "-PYTHON_SCRIPT",
52-
os.path.join(abspath, "scripts", "true_kdtree.py"))
53-
54-
5548
def test_cloud_for_each(cloudcompare_exe):
5649
assert_command_runs(
5750
cloudcompare_exe, "-SILENT", "-O", f"{abspath}/data/a_cloud.bin", "-PYTHON_SCRIPT",

wrapper/pycc/src/qcc_db/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(pycc_db_sources
88
${CMAKE_CURRENT_LIST_DIR}/ccColorScalesManager.cpp
99
${CMAKE_CURRENT_LIST_DIR}/ccCone.cpp
1010
${CMAKE_CURRENT_LIST_DIR}/ccCylinder.cpp
11+
${CMAKE_CURRENT_LIST_DIR}/ccDisc.cpp
1112
${CMAKE_CURRENT_LIST_DIR}/ccDish.cpp
1213
${CMAKE_CURRENT_LIST_DIR}/ccDrawableObject.cpp
1314
${CMAKE_CURRENT_LIST_DIR}/ccGBLSensor.cpp

wrapper/pycc/src/qcc_db/ccDisc.cpp

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// ##########################################################################
2+
// # #
3+
// # CLOUDCOMPARE PLUGIN: PythonRuntime #
4+
// # #
5+
// # This program is free software; you can redistribute it and/or modify #
6+
// # it under the terms of the GNU General Public License as published by #
7+
// # the Free Software Foundation; version 2 of the License. #
8+
// # #
9+
// # This program is distributed in the hope that it will be useful, #
10+
// # but WITHOUT ANY WARRANTY; without even the implied warranty of #
11+
// # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12+
// # GNU General Public License for more details. #
13+
// # #
14+
// # COPYRIGHT: Thomas Montaigu #
15+
// # #
16+
// ##########################################################################
17+
18+
#include <pybind11/pybind11.h>
19+
#include <pybind11/stl.h>
20+
#include <pybind11/stl_bind.h>
21+
22+
#include <ccDisc.h>
23+
24+
#include "../casters.h"
25+
26+
namespace py = pybind11;
27+
using namespace pybind11::literals;
28+
29+
void define_ccDisc(py::module &m)
30+
{
31+
py::class_<ccDisc, ccGenericPrimitive>(m, "ccDisc", R"doc(
32+
ccDisc
33+
34+
Parameters
35+
----------
36+
radius : PointCoordinateType
37+
radius of the disc
38+
transMat : , optional
39+
optional 3D transformation (can be set afterwards with ccDrawableObject::setGLTransformation)
40+
name : str, default: Disc
41+
name of the disc object
42+
precision : int, default: 24
43+
drawing precision (angular step = 360/precision)
44+
uniqueID : int, optional
45+
unique ID (handle with care)
46+
47+
Example
48+
-------
49+
50+
.. code:: Python
51+
52+
disc = pycc.ccDisc(3.0)
53+
disc2 = pycc.ccDisc(5.0, name="Disc2")
54+
)doc")
55+
.def(
56+
py::init<PointCoordinateType, const ccGLMatrix *, QString, unsigned, unsigned>(),
57+
"radius"_a,
58+
"transMat"_a = nullptr,
59+
"name"_a = QString("Disc"),
60+
"precision"_a = 24,
61+
"uniqueId"_a = []() { return ccUniqueIDGenerator::InvalidUniqueID; }())
62+
.def("getRadius", &ccDisc::getRadius)
63+
.def("setRadius", &ccDisc::setRadius, "radius"_a);
64+
}

wrapper/pycc/src/qcc_db/qcc_db.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ void define_ccIndexedTransformation(py::module &m);
4444
void define_ccPlane(py::module &);
4545
void define_ccTorus(py::module &);
4646
void define_ccBox(py::module &);
47+
void define_ccDisc(py::module &);
4748
void define_ccDish(py::module &);
4849
void define_ccCone(py::module &);
4950
void define_ccCylinder(py::module &);
@@ -155,6 +156,7 @@ void define_qcc_db(py::module &m)
155156
define_ccPlane(m);
156157
define_ccTorus(m);
157158
define_ccBox(m);
159+
define_ccDisc(m);
158160
define_ccDish(m);
159161
define_ccCone(m);
160162
define_ccCylinder(m);

wrapper/pycc/tests/test_primitives.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22
import cccorelib
33

44

5+
def test_cc_disc():
6+
disc = pycc.ccDisc(3.0)
7+
assert disc.getTypeName() == "Disc"
8+
assert disc.getName() == "Disc"
9+
assert disc.getRadius() == 3.0
10+
disc.setRadius(10.0)
11+
assert disc.getRadius() == 10.0
12+
13+
disc2 = pycc.ccDisc(5.0, name="Disc2")
14+
assert disc2.getTypeName() == "Disc"
15+
assert disc2.getName() == "Disc2"
16+
17+
518
def test_cc_sphere():
619
sphere = pycc.ccSphere(3.0)
720
assert sphere.getTypeName() == "Sphere"

0 commit comments

Comments
 (0)