Skip to content

Commit b7e93e0

Browse files
Merge pull request #1127 from MClemot/DelRips
[DelaunayRipsPersistence]
2 parents 98e6984 + 7b8b310 commit b7e93e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+3686
-254
lines changed

.github/workflows/package.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939
libeigen3-dev \
4040
libgraphviz-dev \
4141
libsqlite3-dev \
42+
libtbb-dev \
4243
libgl1-mesa-dev \
4344
libwebsocketpp-dev \
4445
graphviz \
@@ -202,7 +203,7 @@ jobs:
202203
brew install --cask xquartz
203204
brew install mesa glew qt@5 ninja libomp
204205
# TTK dependencies
205-
brew install boost cgal eigen graphviz spectra sqlite zlib numpy qhull
206+
brew install boost cgal eigen graphviz spectra sqlite tbb zlib numpy qhull
206207
207208
- name: Install and setup sccache
208209
uses: f3d-app/sccache-setup-action@v1
@@ -290,7 +291,7 @@ jobs:
290291
brew install --cask xquartz
291292
brew install mesa glew qt@5 ninja libomp
292293
# TTK dependencies
293-
brew install boost cgal eigen graphviz spectra sqlite zlib numpy qhull
294+
brew install boost cgal eigen graphviz spectra sqlite tbb zlib numpy qhull
294295
295296
- name: Install and setup sccache
296297
uses: f3d-app/sccache-setup-action@v1

.github/workflows/test-macos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
brew install --cask xquartz
4343
brew install ninja open-mpi libomp
4444
# TTK dependencies
45-
brew install boost cgal eigen graphviz spectra sqlite numpy qhull
45+
brew install boost cgal eigen graphviz spectra sqlite tbb numpy qhull
4646
4747
- name: Run sccache-cache
4848
uses: mozilla-actions/[email protected]
@@ -87,6 +87,7 @@ jobs:
8787
-DTTK_ENABLE_MPI=FALSE \
8888
-DTTK_ENABLE_CPU_OPTIMIZATION=FALSE \
8989
-DTTK_ENABLE_SHARED_BASE_LIBRARIES=TRUE \
90+
-DTTK_ENABLE_TBB=FALSE \
9091
-DTTK_IMPLICIT_PRECONDITIONS_THRESHOLD=64*64*64 \
9192
$GITHUB_WORKSPACE
9293

.github/workflows/test-ubuntu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
libosmesa-dev \
4343
libopenmpi-dev \
4444
libsqlite3-dev \
45+
libtbb-dev \
4546
libwebsocketpp-dev \
4647
graphviz \
4748
python3-sklearn \

CMake/Print.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function(ttk_print_summary)
1616
message(STATUS "TTK_ENABLE_SHARED_BASE_LIBRARIES: ${TTK_ENABLE_SHARED_BASE_LIBRARIES}")
1717
message(STATUS "TTK_ENABLE_SPECTRA: ${TTK_ENABLE_SPECTRA}")
1818
message(STATUS "TTK_ENABLE_SQLITE3: ${TTK_ENABLE_SQLITE3}")
19+
message(STATUS "TTK_ENABLE_TBB: ${TTK_ENABLE_TBB}")
1920
message(STATUS "TTK_ENABLE_TORCH: ${TTK_ENABLE_TORCH}")
2021
message(STATUS "TTK_ENABLE_WEBSOCKETPP: ${TTK_ENABLE_WEBSOCKETPP}")
2122
message(STATUS "TTK_ENABLE_ZFP: ${TTK_ENABLE_ZFP}")

CMake/config.cmake

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mark_as_advanced(TTK_IMPLICIT_PRECONDITIONS_THRESHOLD)
116116
option(TTK_ENABLE_DOUBLE_TEMPLATING "Use double templating for bivariate data" OFF)
117117
mark_as_advanced(TTK_ENABLE_DOUBLE_TEMPLATING)
118118

119-
option(TTK_REDUCE_TEMPLATE_INSTANTIATIONS "Use a reduced list of template instatiations to fasten build times" OFF)
119+
option(TTK_REDUCE_TEMPLATE_INSTANTIATIONS "Use a reduced list of template instantiations to fasten build times" OFF)
120120
mark_as_advanced(TTK_REDUCE_TEMPLATE_INSTANTIATIONS)
121121

122122
option(TTK_TIME_TARGETS "Print targets build time" OFF)
@@ -207,6 +207,15 @@ else()
207207
message(STATUS "SQLite3 not found, disabling SQLite3 support in TTK.")
208208
endif()
209209

210+
find_package(TBB QUIET)
211+
if (TBB_FOUND)
212+
option(TTK_ENABLE_TBB "Enable TBB support" ON)
213+
message(STATUS "Found TBB ${TBB_VERSION} (${TBB_DIR})")
214+
else()
215+
option(TTK_ENABLE_TBB "Enable TBB support" OFF)
216+
message(STATUS "TBB not found, disabling TBB support in TTK.")
217+
endif()
218+
210219
find_package(ZFP QUIET)
211220
if(ZFP_INCLUDE_DIRS)
212221
option(TTK_ENABLE_ZFP "Enable ZFP support" ON)
@@ -223,8 +232,8 @@ if(NOT TTK_ENABLE_ZFP)
223232
find_package(ZFP QUIET)
224233
endif()
225234

226-
find_package(Eigen3 3.3 QUIET NO_MODULE)
227-
if(EIGEN3_FOUND)
235+
find_package(Eigen3 QUIET NO_MODULE)
236+
if(Eigen3_FOUND)
228237
option(TTK_ENABLE_EIGEN "Enable Eigen3 support" ON)
229238
message(STATUS "Found Eigen ${Eigen3_VERSION} (${EIGEN3_INCLUDE_DIR})")
230239

CMake/cpack_config.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ else()
1919
set(CPACK_RESOURCE_FILE_README ${PROJECT_BINARY_DIR}/Readme.txt)
2020
endif()
2121
set(CPACK_DEBIAN_PACKAGE_DEPENDS
22-
"ttk-paraview (= 6.0.1), libboost-system-dev, libeigen3-dev, libgraphviz-dev, libsqlite3-dev, graphviz, python3-sklearn, zlib1g-dev, libqhull-dev, python3-dev, libgl1-mesa-dev")
22+
"ttk-paraview (= 6.0.1), libboost-system-dev, libcgal-dev, libeigen3-dev, libgraphviz-dev, libsqlite3-dev, libtbb-dev, libwebsocketpp-dev, graphviz, python3-sklearn, zlib1g-dev, libqhull-dev, python3-dev, libgl1-mesa-dev")
2323
# autogenerate dependency information
2424
set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
2525
# package will be installed under %ProgramFiles%\${CPACK_PACKAGE_INSTALL_DIRECTORY} on Windows

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Cycle-aware dimensionality reduction (TopoAE++, IEEE TVCG 2026)
55
- Distributed computation of persistent homology! (IEEE TPDS 2025)
66
- Discrete vector field topology! (IEEE VIS 2024)
7+
- Fast DelaunayRips persistence computation for point cloud data
78
- New backend for TrackingFromFields (critical point based)
89
- Stochastic discrete gradient (IEEE VIS 2012)
910
- Fast planar Rips filtration persistence computation

core/base/TTKBaseConfig.cmake.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ if (@TTK_ENABLE_QHULL@ AND @Qhull_FOUND@)
1717
find_dependency(Qhull REQUIRED)
1818
endif()
1919

20+
if (@TTK_ENABLE_TBB@)
21+
find_dependency(TBB REQUIRED)
22+
endif()
23+
2024
if (@TTK_ENABLE_TORCH@)
2125
set(Torch_DIR "@Torch_DIR@" CACHE PATH "Use TTK Torch dir" FORCE)
2226
find_dependency(Torch REQUIRED @Torch_DIR@)
@@ -35,9 +39,13 @@ if (@TTK_ENABLE_SCIKIT_LEARN@ AND NOT @TTK_ENABLE_SHARED_BASE_LIBRARIES@)
3539
find_package(Python3 COMPONENTS Development NumPy)
3640
endif()
3741

38-
if (@TTK_ENABLE_CGAL@ AND @CGAL_FOUND@)
42+
if (@TTK_ENABLE_CGAL@)
3943
find_dependency(CGAL REQUIRED)
4044
endif()
4145

46+
if (@TTK_ENABLE_EIGEN@)
47+
find_dependency(Eigen3 CONFIG REQUIRED)
48+
endif()
49+
4250
# Include the actual targets for TTK Base
4351
include("${CMAKE_CURRENT_LIST_DIR}/TTKBaseTargets.cmake")
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
ttk_add_base_library(delaunayRipsPersistenceDiagram
2+
SOURCES
3+
DelaunayRipsPersistenceDiagram.cpp
4+
HEADERS
5+
DelaunayRipsPersistenceDiagram.h
6+
dset.h
7+
geoPH3.h
8+
geoPHd.h
9+
geoPHUtils.h
10+
DEPENDS
11+
ripsPersistenceDiagram
12+
)
13+
14+
set(TTK_DELAUNAY_MAX_COMPILED_DIMENSION "8" CACHE STRING "Maximum compiled dimension for arbitrary dimension Delaunay-related code")
15+
mark_as_advanced(TTK_DELAUNAY_MAX_COMPILED_DIMENSION)
16+
target_compile_definitions(delaunayRipsPersistenceDiagram PUBLIC TTK_DELAUNAY_MAX_COMPILED_DIMENSION=${TTK_DELAUNAY_MAX_COMPILED_DIMENSION})
17+
18+
target_link_libraries(delaunayRipsPersistenceDiagram PUBLIC Boost::boost)
19+
20+
if(TTK_ENABLE_EIGEN)
21+
target_compile_definitions(delaunayRipsPersistenceDiagram PUBLIC TTK_ENABLE_EIGEN)
22+
target_link_libraries(delaunayRipsPersistenceDiagram PUBLIC Eigen3::Eigen)
23+
endif()
24+
25+
if(TTK_ENABLE_CGAL)
26+
target_compile_definitions(delaunayRipsPersistenceDiagram PUBLIC TTK_ENABLE_CGAL)
27+
if(CGAL_VERSION VERSION_LESS "6.0")
28+
target_link_libraries(delaunayRipsPersistenceDiagram PUBLIC ${CGAL_LIBRARIES})
29+
else()
30+
target_link_libraries(delaunayRipsPersistenceDiagram PUBLIC CGAL::CGAL)
31+
endif()
32+
endif()
33+
34+
if(TTK_ENABLE_TBB)
35+
target_compile_definitions(delaunayRipsPersistenceDiagram PUBLIC TTK_ENABLE_TBB)
36+
target_compile_definitions(delaunayRipsPersistenceDiagram PUBLIC CGAL_LINKED_WITH_TBB)
37+
target_link_libraries(delaunayRipsPersistenceDiagram PUBLIC TBB::tbb TBB::tbbmalloc)
38+
endif()
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#include <DelaunayRipsPersistenceDiagram.h>
2+
3+
using namespace ttk::rpd;
4+
5+
ttk::DelaunayRipsPersistenceDiagram::DelaunayRipsPersistenceDiagram() {
6+
// inherited from Debug: prefix will be printed at the beginning of every msg
7+
this->setDebugMsgPrefix("DelaunayRipsPD");
8+
}
9+
10+
int ttk::DelaunayRipsPersistenceDiagram::execute(
11+
const PointCloud &points, MultidimensionalDiagram &ph) const {
12+
13+
#ifdef TTK_ENABLE_CGAL
14+
const unsigned dim = points[0].size();
15+
if(points.size() <= dim) {
16+
printErr("Not enough points");
17+
return 1;
18+
}
19+
if(dim == 2) {
20+
FastRipsPersistenceDiagram2 FRPD(points);
21+
FRPD.setDebugLevel(debugLevel_);
22+
FRPD.computeDelaunayRips0And1Persistence(ph);
23+
} else if(dim == 3) {
24+
#ifndef CGAL_LINKED_WITH_TBB
25+
if(getThreadNumber() > 1) {
26+
printWrn("TTK was not compiled with TBB:");
27+
printWrn("sequential Delaunay triangulation only");
28+
}
29+
#endif
30+
gph::runDelaunayRipsPersistenceDiagram3(points, ph, getThreadNumber());
31+
ph[0].emplace_back(
32+
FiltratedSimplex{{-1}, 0.}, FiltratedSimplex{{-1}, inf}); // infinite pair
33+
} else {
34+
if(dim > TTK_DELAUNAY_MAX_COMPILED_DIMENSION)
35+
printWrn("High dimension: " + std::to_string(dim) + ">"
36+
+ std::to_string(TTK_DELAUNAY_MAX_COMPILED_DIMENSION));
37+
gph::tryDimensions(points, ph, getThreadNumber());
38+
ph[0].emplace_back(
39+
FiltratedSimplex{{-1}, 0.}, FiltratedSimplex{{-1}, inf}); // infinite pair
40+
}
41+
return 0;
42+
#else
43+
TTK_FORCE_USE(points);
44+
TTK_FORCE_USE(ph);
45+
printErr("TTK was not compiled with CGAL:");
46+
printErr("this filter is not available.");
47+
return 1;
48+
#endif
49+
}
50+
51+
int ttk::DelaunayRipsPersistenceDiagram::execute(
52+
const PointCloud &points,
53+
MultidimensionalDiagram &ph,
54+
std::vector<Generator1> &generators1,
55+
std::vector<Generator2> &generators2) const {
56+
57+
#ifdef TTK_ENABLE_CGAL
58+
const unsigned dim = points[0].size();
59+
if(dim > 3) {
60+
printErr("Input dimension too large: " + std::to_string(dim) + ">3");
61+
return 1;
62+
}
63+
if(points.size() <= dim) {
64+
printErr("Not enough points");
65+
return 1;
66+
}
67+
if(dim == 2) {
68+
FastRipsPersistenceDiagram2 FRPD(points);
69+
FRPD.setDebugLevel(debugLevel_);
70+
FRPD.computeDelaunayRips0And1Persistence(ph);
71+
FRPD.exportRips1Generators(generators1);
72+
} else if(dim == 3) {
73+
#ifndef CGAL_LINKED_WITH_TBB
74+
if(getThreadNumber() > 1) {
75+
printWrn("TTK was not compiled with TBB:");
76+
printWrn("sequential Delaunay triangulation only");
77+
}
78+
#endif
79+
gph::runDelaunayRipsPersistenceDiagram3(
80+
points, ph, generators1, generators2, getThreadNumber());
81+
ph[0].emplace_back(
82+
FiltratedSimplex{{-1}, 0.}, FiltratedSimplex{{-1}, inf}); // infinite pair
83+
}
84+
return 0;
85+
#else
86+
TTK_FORCE_USE(points);
87+
TTK_FORCE_USE(ph);
88+
TTK_FORCE_USE(generators1);
89+
TTK_FORCE_USE(generators2);
90+
printErr("TTK was not compiled with CGAL:");
91+
printErr("this filter is not available.");
92+
return 1;
93+
#endif
94+
}

0 commit comments

Comments
 (0)