Skip to content

Commit c2d34db

Browse files
committed
Update to latest CC
The main change is the fact that the ScalarField now has an offset system baked into it, meaning APIs work with double but internally floats are stored This has the consequence of making the asArray to convert to a numpy array view of the scalar field impossible. As a replacement a custom class has been made, its very incomplete as it supports only assignments and read bot no operations like +,-,==, etc. So now users will be forced to use toArray to copy the values into a numpy array, work with them then copy back into the scalar field when needed
1 parent b4bb2a9 commit c2d34db

17 files changed

Lines changed: 286 additions & 63 deletions

.github/workflows/Build.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
uses: actions/checkout@v4
1818
with:
1919
repository: 'CloudCompare/CloudCompare'
20-
ref: dde99864332e10d6bb0da8acb3c16d36d054c2aa
20+
ref: 84a7b4916f1cdcd98f3b8f07dcdaf5bfb7b5e542
2121
submodules: recursive
2222

2323
- name: Clone PythonRuntime
@@ -80,7 +80,7 @@ jobs:
8080
uses: actions/checkout@v4
8181
with:
8282
repository: 'CloudCompare/CloudCompare'
83-
ref: dde99864332e10d6bb0da8acb3c16d36d054c2aa
83+
ref: 84a7b4916f1cdcd98f3b8f07dcdaf5bfb7b5e542
8484
submodules: recursive
8585

8686
- name: Clone PythonRuntime
@@ -148,7 +148,7 @@ jobs:
148148
uses: actions/checkout@v4
149149
with:
150150
repository: 'CloudCompare/CloudCompare'
151-
ref: dde99864332e10d6bb0da8acb3c16d36d054c2aa
151+
ref: 84a7b4916f1cdcd98f3b8f07dcdaf5bfb7b5e542
152152
submodules: recursive
153153

154154
- name: Clone PythonRuntime
@@ -200,6 +200,9 @@ jobs:
200200
runs-on: windows-latest
201201

202202
steps:
203+
- name: Support longpaths on Windows
204+
run: git config --global core.longpaths true
205+
203206
- uses: actions/checkout@v4
204207

205208
- name: Install Miniconda

.github/workflows/Lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v4
11-
- uses: DoozyX/clang-format-lint-action@v0.14
11+
- uses: DoozyX/clang-format-lint-action@v0.18.1
1212
with:
1313
source: '.'
1414
extensions: 'h,cpp'
15-
clangFormatVersion: 14
15+
clangFormatVersion: 18

src/PythonInterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static py::dict CreateGlobals()
5050
return globals;
5151
}
5252

53-
PythonInterpreter::State::State() : globals(CreateGlobals()), locals(){};
53+
PythonInterpreter::State::State() : globals(CreateGlobals()), locals() {};
5454

5555
//================================================================================
5656

tests/scripts/auto_segmentation_tools.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_tribox_overlap():
3939
cccorelib.CCVector3(0.75, 1.25, 1.0)
4040
]
4141

42-
assert cccorelib.CCMiscTools.TriBoxOverlap(boxCenter, boxHalfSize, triangle)
42+
assert cccorelib.CCMiscTools.TriBoxOverlap(boxCenter, boxHalfSize, triangle), "TriBoxOverlap failed"
4343

4444
# TODO: needs CCVector3D to be defined in cccorelib to be uncommented
4545
# boxCenter = cccorelib.CCVector3d(0, 0, 0)
@@ -59,7 +59,7 @@ def test_connected_components(cloud):
5959

6060
reference_clouds = cccorelib.ReferenceCloudContainer()
6161
success = cccorelib.AutoSegmentationTools.extractConnectedComponents(cloud, reference_clouds)
62-
assert success
62+
assert success, "extractConnectedComponents failed"
6363

6464

6565
def main():

tests/scripts/cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def main():
5151

5252
cloud.setPointScalarValue(17, 42.1337)
5353
print(cloud.getPointScalarValue(17))
54-
assert cloud.getPointScalarValue(17) == float(np.float32(42.1337))
54+
assert np.isclose(cloud.getPointScalarValue(17), 42.1337)
5555

5656
p = cloud.getNextPoint()
5757
assert p.x == point1.x

tests/scripts/normal_distribution.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@
2020
d.computeParameters(cloud)
2121

2222
d.setParameters(1.1, 0.6)
23-
assert d.getMu() == float(np.float32(1.1))
24-
assert d.getSigma2() == float(np.float32(0.6))
23+
assert d.getMu() == 1.1
24+
assert d.getSigma2() == 0.6

tests/scripts/scalarfield.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import cccorelib
22
import pycc
3+
import numpy as np
34

45
cc = pycc.GetInstance()
56
cloud = cc.clouds()[0].pc
67

7-
assert cccorelib.ScalarFieldTools.computeMeanScalarValue(cloud) == 8204.2490234375
8-
assert cccorelib.ScalarFieldTools.computeMeanSquareScalarValue(cloud) == 93043936.0
9-
assert cccorelib.ScalarFieldTools.computeScalarFieldGradient(cloud, 0, False) == 0
8+
assert np.isclose(cccorelib.ScalarFieldTools.computeMeanScalarValue(cloud), 8204.2490234375)
9+
assert np.isclose(cccorelib.ScalarFieldTools.computeMeanSquareScalarValue(cloud), 93043936.0)
10+
assert np.isclose(cccorelib.ScalarFieldTools.computeScalarFieldGradient(cloud, 0, False), 0)
1011

1112
assert cccorelib.ScalarFieldTools.computeScalarFieldExtremas(cloud) == (0, 37522.00)
1213
assert cccorelib.ScalarFieldTools.countScalarFieldValidValues(cloud) == 10_683

wrapper/cccorelib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if(CCCORELIB_PYTHON_IS_MASTER_PROJECT)
2525
GIT_REPOSITORY https://github.com/CloudCompare/CCCoreLib
2626
GIT_PROGRESS ON
2727
GIT_SHALLOW OFF
28-
GIT_TAG ee426c368280aef8dc3e2c418e6a007064280e58
28+
GIT_TAG 83732e77561da45b857a8a2ffcd2949e6057a393
2929
)
3030

3131
FetchContent_GetProperties(CCCoreLib)
@@ -44,7 +44,7 @@ if(CCCORELIB_PYTHON_IS_MASTER_PROJECT OR NOT PLUGIN_PYTHON_USE_EMBEDDED_MODULES)
4444
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
4545
ensure_pybind11_cmake_module_is_in_path()
4646
find_package(pybind11 CONFIG REQUIRED)
47-
47+
4848
pybind11_add_module(cccorelib ${cccorelib_sources})
4949
target_link_libraries(cccorelib PRIVATE CCCoreLib)
5050

wrapper/cccorelib/src/GenericDistribution.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,4 @@ void define_GenericDistribution(py::module &cccorelib)
5151
"Yk"_a,
5252
"numberOfClasses"_a,
5353
"histo"_a = nullptr);
54-
55-
py::bind_vector<CCCoreLib::GenericDistribution::ScalarContainer>(GenericDistribution, "ScalarContainer");
5654
}

0 commit comments

Comments
 (0)