Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
331 commits
Select commit Hold shift + click to select a range
60d040a
added tests for 2D. hessian is not perfect, try to remove AD
fsichetti Jan 26, 2026
d92efc3
tidy up 2d code, removed some old code
fsichetti Jan 27, 2026
40bc413
removed autodiff for 2D, cleaned up code, added some tests. hessian s…
fsichetti Jan 28, 2026
36f5954
some changes to tests
fsichetti Jan 30, 2026
7162932
watertight check
Huangzizhou Feb 1, 2026
70b625d
pass erleben test
Huangzizhou Feb 1, 2026
a692eae
Merge branch 'main' of github.com:fsichetti/ipc-toolkit
Huangzizhou Feb 1, 2026
0d228ff
removed unused function
fsichetti Feb 2, 2026
29dbee5
Remove const shared_ptr<T>& parameters
fsichetti Feb 3, 2026
6cd9c2d
refactoring of shared pointers according to main branch
fsichetti Feb 3, 2026
ccebb49
refactoring vector classes
fsichetti Feb 3, 2026
e70297e
Merge remote-tracking branch 'origin/main' into ogc-merge-branch
fsichetti Feb 3, 2026
b002de2
merge
fsichetti Feb 3, 2026
f5ccccd
temporarily removed some defective tests
fsichetti Feb 4, 2026
5fddf61
changed thresholds
fsichetti Feb 9, 2026
c016b96
removed old offset tests and new codim offset tests
fsichetti Feb 9, 2026
cdefe04
exact distance type computation with geogram
fsichetti Feb 12, 2026
302439a
fix
fsichetti Feb 13, 2026
3d9bf50
cleaner point_triangle_distance_type, and tighter checks for zero pot…
fsichetti Feb 13, 2026
05f0175
added custom filters for point-primitive distances; still need to do …
fsichetti Feb 16, 2026
d2d56b7
added all filters and tests
fsichetti Feb 17, 2026
af18c0b
added back the parallel threshold to fix stability issues, and fix co…
fsichetti Feb 17, 2026
08781bc
added filter for thresholded parallel check
fsichetti Feb 17, 2026
ddf6e93
removed special case for parallel edges, but test is failing
fsichetti Feb 19, 2026
e300a77
fix
fsichetti Feb 19, 2026
7664359
tiny change
fsichetti Feb 19, 2026
44a65dc
remove unnecessary header
fsichetti Feb 19, 2026
c80bdac
truncate uv
Huangzizhou Feb 20, 2026
860d8c6
buggy scene
Huangzizhou Feb 20, 2026
8f9372f
remove problematic test
Huangzizhou Feb 22, 2026
b9f7fab
change log level
Huangzizhou Feb 22, 2026
59299d1
fix assertion false
Huangzizhou Feb 22, 2026
72708d8
HighOrderCollisionDict wrapper
Huangzizhou Feb 26, 2026
03b1dfe
get rid of pointers
Huangzizhou Feb 26, 2026
f44a543
std array instead of vector
Huangzizhou Feb 26, 2026
ed75734
use .data() to get array address
Huangzizhou Feb 26, 2026
d0f48a4
refactor to use dense vectors for local derivatives
Huangzizhou Feb 27, 2026
d50a246
benchmark for pointers
Huangzizhou Feb 27, 2026
e190b3a
Merge branch 'predicates_only'
fsichetti Mar 2, 2026
8632fb3
missing braces on linux
fsichetti Mar 2, 2026
245ef8d
parallel quadrature build
fsichetti Mar 2, 2026
1acb1a1
remove unused test
Huangzizhou Mar 3, 2026
fe5fcfd
local hessian matrix
Huangzizhou Mar 3, 2026
8f4e288
Revert "local hessian matrix"
Huangzizhou Mar 3, 2026
f44cf16
psd projection
Huangzizhou Mar 3, 2026
7532439
clean gradient
Huangzizhou Mar 3, 2026
86fa801
parallelize evaluation on faces
fsichetti Mar 3, 2026
87b0b35
Merge remote-tracking branch 'origin/main'
Huangzizhou Mar 4, 2026
f2aca91
merge commit
Huangzizhou Mar 4, 2026
9413d72
follow ipc code
Huangzizhou Mar 4, 2026
d27cae9
refactor to reduce per-collision memory
Huangzizhou Mar 4, 2026
8330bb6
avoid duplicated distance check
Huangzizhou Mar 4, 2026
b85aed9
use vector for local storage instead of unordered maps
fsichetti Mar 4, 2026
f3ff995
Merge remote-tracking branch 'origin/main'
Huangzizhou Mar 4, 2026
a0121d2
rename and clean code
Huangzizhou Mar 4, 2026
5d9b906
revert accidental commit
Huangzizhou Mar 4, 2026
d6957cf
unique_ptr
Huangzizhou Mar 5, 2026
9fe48c4
avoid unnecessary matrices
Huangzizhou Mar 5, 2026
813cf11
unit test for collision pair count
Huangzizhou Mar 5, 2026
fd7877d
skip obstacles and removed unused parts of the code
fsichetti Mar 7, 2026
bdb326e
fix for linux
fsichetti Mar 9, 2026
92ad854
fix failed test
Huangzizhou Mar 9, 2026
3ee2042
Merge remote-tracking branch 'origin/main'
Huangzizhou Mar 9, 2026
5ca173a
respect skip_obstacles setting
fsichetti Mar 9, 2026
121fca1
Merge branch 'skip-obstacles'
fsichetti Mar 9, 2026
32ecdf5
fixed a bug and reverted exact parallel check to thresholded check; w…
fsichetti Mar 10, 2026
ce0f5b6
count collision pairs before cancellation
Huangzizhou Mar 13, 2026
3036d83
test "Number of Pairs" on armadillo-rollers/327.ply
Huangzizhou Mar 14, 2026
e3e32f7
print edge quadrature point distribution
Huangzizhou Mar 14, 2026
91aba99
explicitly check eigen vectorization
Huangzizhou Mar 14, 2026
a266c62
option to skip building face collisions
Huangzizhou Mar 14, 2026
75b3e0f
normalization of weights
Huangzizhou Mar 15, 2026
b7a7181
use fixed-size Eigen types for mol_grad in hessian()
Huangzizhou Mar 16, 2026
3e7753c
make weight normalization optional, default on
Huangzizhou Mar 16, 2026
ace4eaf
unit test skip_face_collisions for both true and false
Huangzizhou Mar 16, 2026
ff455e9
avoid big matrix copy in build_collisions_at_face_center()
Huangzizhou Mar 16, 2026
0ffa9b2
avoid duplicated distance_type compute
Huangzizhou Mar 17, 2026
d7b08c9
separate dhat for EE points
fsichetti Mar 17, 2026
53ca141
changes to parameters class
fsichetti Mar 20, 2026
5a3e783
export ee eval count
fsichetti Mar 20, 2026
ad9423f
avoid logging strange distance number
Huangzizhou Mar 20, 2026
963bdf8
Add edge_collision_counts() to HighOrderCollisions
Huangzizhou Mar 21, 2026
6c689d5
refactor tests, codim 2d test
Huangzizhou Mar 21, 2026
46876e2
Merge origin/safety-mode: new parameter API + edge eval count export
Huangzizhou Mar 21, 2026
1eaa00c
high order face quadrature test
fsichetti Mar 22, 2026
8b07f86
friction for new contact
Huangzizhou Mar 23, 2026
5a7d0c7
higher order quadrature, hardcoded weight factor for testing, removed…
fsichetti Mar 23, 2026
958bfab
temporary hardcoded flag to skip obstacles on OGC
fsichetti Mar 23, 2026
ec53447
Merge branch 'face-quadrature'
fsichetti Mar 23, 2026
f3c9a71
high order face quadrature with vertices
fsichetti Mar 24, 2026
5a25bd4
tests updated
fsichetti Mar 24, 2026
1b3805d
skipping obstacle-obstacle collisions
fsichetti Mar 25, 2026
d17bcee
high order collisions friction
Huangzizhou Mar 27, 2026
6ea0242
more test
Huangzizhou Mar 28, 2026
b2d49cb
friction unit test
Huangzizhou Mar 29, 2026
c812718
fix friction
Huangzizhou Mar 29, 2026
0bf2a3e
fix gradient jump for parallel edges
Huangzizhou Apr 2, 2026
172178c
Remove debug logging from high_order_contact_potential
Huangzizhou Apr 2, 2026
f2e054a
expose skip_obstacles flag for OGC and fix a test
fsichetti Apr 2, 2026
f5cdf7b
externally sourcing triangle quadrature
fsichetti Apr 6, 2026
aba129d
skip quadrature on vertices when face quadrature (which includes vert…
fsichetti Apr 7, 2026
994488c
high order contact friction
Huangzizhou Apr 10, 2026
28cee52
deprecate compute_active_minimum_distance
Huangzizhou Apr 10, 2026
bcdb739
more extensive unit tests
Huangzizhou Apr 10, 2026
512f457
profiling utils
Huangzizhou Apr 11, 2026
e259302
skip empty dict
Huangzizhou Apr 11, 2026
2524bca
warnings / errors for some quadrature orders
fsichetti Apr 13, 2026
c02cc43
generic barrier for the new potential
fsichetti Apr 15, 2026
0e0f900
profiling
Huangzizhou Apr 16, 2026
e331de5
2D high order potential refactor
fsichetti Apr 18, 2026
512de6b
fix
fsichetti Apr 18, 2026
cc6b726
added inv power barrier to barriers
fsichetti Apr 18, 2026
8413a00
Merge branch '2d-refactor'
fsichetti Apr 18, 2026
787667a
high mollifier order for high barrier order
Huangzizhou Apr 18, 2026
ea42fc3
remove r and alpha from HighOrderContactParameters
Huangzizhou Apr 19, 2026
73e296e
removed ad-hoc 2D offset contact implementation
fsichetti Apr 19, 2026
f8d737e
2D offset potential update and HO fix. Note: 2D OGC and HO potentials…
fsichetti Apr 19, 2026
844490f
psd projection when normalize_weight=true
Huangzizhou Apr 20, 2026
62b1594
1D quadrature fix
fsichetti Apr 21, 2026
b31f38c
OGC fix (from e67f802 on main branch)
fsichetti Apr 21, 2026
7abd6f0
ogc reimplementation
fsichetti Apr 22, 2026
1db44f3
fix and add param
fsichetti Apr 22, 2026
117d12d
2D fix and add area weighting param
fsichetti Apr 22, 2026
3cb3d34
Merge branch 'ogc-impl'
fsichetti Apr 22, 2026
a23ca46
init_pck
fsichetti Apr 23, 2026
75c64cd
Merge remote-tracking branch 'myfork/main'
fsichetti Apr 23, 2026
8e70462
option to switch to legacy edge_edge_distance_type()
Huangzizhou Apr 23, 2026
9453f6d
full legacy version distance type
Huangzizhou Apr 23, 2026
c4b0a03
OGC coefficient fix
fsichetti Apr 26, 2026
e6cdf1a
Merge branch 'main' of github.com:fsichetti/ipc-toolkit
fsichetti Apr 26, 2026
ab11799
adaptive dhat WIP
fsichetti May 4, 2026
3852e48
test: bump Face Quadrature Hessian FD step from 1e-12 to 1e-6
Huangzizhou May 4, 2026
8d940f9
fix(adaptive-dhat): smooth eps across closest-point dtype boundaries
Huangzizhou May 4, 2026
817d4d0
test: loosen Convergent Quadrature gradient tolerance to 1e-5
Huangzizhou May 4, 2026
01897ea
adaptive-dhat: restore clamping in eps for closest-point dtype
Huangzizhou May 4, 2026
5b5e491
adaptive-dhat: C1 smooth saturation for closest-point parameter
Huangzizhou May 4, 2026
1d0d858
test
fsichetti May 4, 2026
ab722a2
add mesh
fsichetti May 4, 2026
c46cfb3
adaptive-dhat: 3D smoothing, dtype invariant, and AD-helper cleanup
Huangzizhou May 4, 2026
59b1c8b
added near/far barrier
fsichetti May 4, 2026
2c06b0e
barrier split (buggy)
fsichetti May 4, 2026
c28f1dd
fix unit test for use_near_far
Huangzizhou May 4, 2026
812ec4e
adaptive dhat computation
fsichetti May 4, 2026
6e6f161
updated test that did not make sense
fsichetti May 4, 2026
60b6725
Merge remote-tracking branch 'origin/adaptive-dhat'
Huangzizhou May 5, 2026
b9c1acf
added tests and finished adding adaptive dhat to the new near/far spl…
fsichetti May 5, 2026
0a0dbc3
removed defective new test
fsichetti May 5, 2026
ea84cc7
minor improvements done while debugging
fsichetti May 6, 2026
5c52138
bugfix
fsichetti May 6, 2026
838b857
some ogc 3D fixes
fsichetti May 6, 2026
7707c3a
near far bugfix
fsichetti May 8, 2026
d673c9d
bugfix
fsichetti May 9, 2026
2393376
Merge remote-tracking branch 'origin/main' into main
fsichetti Jul 28, 2026
33a729e
Support building without geogram; unify parallel threshold; fix EE pa…
fsichetti Jul 29, 2026
e7f298a
Merge remote-tracking branch 'origin/main' into upstream-merge
fsichetti Aug 13, 2026
5f301a2
fix clang format
fsichetti Aug 13, 2026
67bb3d7
Make high_order_contact compile on MSVC
danielepanozzo Aug 16, 2026
1612533
arbitrary point evaluation machinery (ported from a local branch)
fsichetti Aug 19, 2026
42e32a7
added combined evaluation of value, gradient and hessian (2~3x speedup)
fsichetti Aug 19, 2026
8028b77
clang-format fixes
fsichetti Aug 19, 2026
feaf16f
Remove ogc_collisions OGC-replication mode from high_order_contact
fsichetti Sep 1, 2026
a16b48d
Fix clang-format include ordering in high_order_contact
fsichetti Sep 1, 2026
3a76d75
2D version
fsichetti Sep 2, 2026
dfbad2a
Merge remote-tracking branch 'upstream/main' into upstream-merge
fsichetti Sep 3, 2026
5501bd5
Merge remote-tracking branch 'wildmeshing/upstream-merge' into upstre…
fsichetti Sep 3, 2026
b730568
Fix stale non-templated Barrier usages and edge_edge_distance_type re…
fsichetti Sep 3, 2026
742f5f5
Rename high_order_contact -> esp and smooth_contact -> gcp
fsichetti Sep 3, 2026
d00d05b
Rename arbitrary_point_potential -> arbitrary_point_esp
fsichetti Sep 3, 2026
7754082
clang-format fixes
fsichetti Sep 4, 2026
caf393c
Merge remote-tracking branch 'origin/main' into upstream-merge
fsichetti Sep 9, 2026
7ae94a1
Fix CI failures: Windows macros, Abseil leak, and geogram on MSVC
fsichetti Sep 9, 2026
f7e4c29
clang-tidy: add braces around single-statement bodies
fsichetti Sep 9, 2026
38240f2
clang-tidy: follow the project's identifier naming conventions
fsichetti Sep 9, 2026
77b518a
Fix MSVC AVX2 build silently downgrading to AVX
fsichetti Sep 16, 2026
8c5a01c
Merge remote-tracking branch 'upstream/main' into upstream-merge
fsichetti Sep 21, 2026
50a2b8b
Inline the filtered predicates in the exact distance-type classifiers
fsichetti Sep 29, 2026
343e27c
ArbitraryPointESP: build the per-point collision set without heap all…
udaykusupati Sep 28, 2026
626e27e
Fix ArbitraryPointESP on non-closed inputs: inclusion-exclusion weights
udaykusupati Sep 29, 2026
91b19a6
Restore release notes and the Python rename guard after the GCP rename
fsichetti Sep 30, 2026
dba5f8c
Restore std::unordered_map in the collision mesh bindings
fsichetti Sep 30, 2026
b16b306
Keep Abseil private: move the ESP collision maps to an internal header
fsichetti Sep 30, 2026
db9f493
Update the ESP Python bindings to the current API
fsichetti Sep 30, 2026
0d247b5
Keep the pre-rename smooth-contact names as deprecated aliases
fsichetti Sep 30, 2026
be6ccc0
Trim the PR and fix issues found in review
fsichetti Oct 2, 2026
b1c1060
Add the remaining deprecated GCP aliases and fix warnings
fsichetti Oct 2, 2026
4959e9e
Keep the exact distance-type classifiers consistent without geogram
claude Oct 5, 2026
931b3d6
Stop ESP from forcing Eigen vectorization off and geogram on
claude Oct 5, 2026
3db02ab
Load the FV mollification test's cube from the tests data
claude Oct 5, 2026
225d77e
Fix the ESP 2D finite-difference test across distance-type switches
claude Oct 6, 2026
f4877a6
Extend ESP dbar_factor to [0, 2] and project every split Hessian
claude Oct 6, 2026
c6bec29
Validate the ESP face quadrature rule on assignment
claude Oct 7, 2026
731d58f
Check face quadrature coordinates; drop quad_order limits
claude Oct 7, 2026
cfd6735
Tighten face quadrature rule validation test
claude Oct 7, 2026
a2a79a9
Trim face quadrature rule validation test
claude Oct 7, 2026
a54158f
Fix the ESP CI failures on MSVC, clang-tidy and Debug
claude Oct 7, 2026
3d44890
Update the ESP documentation
claude Oct 7, 2026
34f7846
Fix the stiffness of BarrierPotential with unsquared distance
claude Oct 8, 2026
d27856b
Remove the unused all_types parameter from the CCD Candidates::build
claude Oct 8, 2026
72473f0
Fix ESP friction and two ESP bugs, remove dead code, raise coverage
claude Oct 8, 2026
40e251a
Fix the shadow and old-style cast warnings in ESP
claude Oct 8, 2026
9c1918c
Remove the unused face-center ESP functions
claude Oct 8, 2026
2c6f589
Rename the ESP face potential functions to face_interior_point
claude Oct 8, 2026
93bc983
Merge branch 'main' into upstream-merge
fsichetti Oct 9, 2026
d6373a5
Merge branch 'main' into upstream-merge
zfergus Oct 11, 2026
9b982f8
Move the 2D ESP Hessian PSD check into its own test
claude Oct 11, 2026
a66bc67
Merge branch 'main' into upstream-merge
zfergus Oct 12, 2026
493ff2f
Merge branch 'main' into upstream-merge
zfergus Oct 12, 2026
7a372cd
Check ESP 2D finite differences at quadrature orders 1 and 14 only
fsichetti Oct 13, 2026
586b0bf
Trim the slowest ESP and distance-type tests
fsichetti Oct 13, 2026
82ca34d
Follow the style guide in the ESP code and fix its new warnings
fsichetti Oct 14, 2026
7809ac1
Silence geogram's own build warnings
fsichetti Oct 14, 2026
03c39d2
Add C++ and Python API reference pages for ESP
fsichetti Oct 14, 2026
279ff11
Merge branch 'main' into upstream-merge
fsichetti Oct 15, 2026
6a059ee
Replace geogram with its MultiPrecision PSM
zfergus Oct 16, 2026
6f09bd3
Merge branch 'main' into upstream-merge
zfergus Oct 16, 2026
0ad52e6
Show geogram PSM as static in dependency graph
zfergus Oct 16, 2026
2f909b5
Remove unused <cstdio> include
zfergus Oct 16, 2026
577594e
Relicense vendored Gauss-Lobatto code under MIT
zfergus Oct 16, 2026
73be9c4
Load ESP sphere meshes from the test-data repo
zfergus Oct 16, 2026
762aaf0
Warn when deprecated smooth_contact names are used
zfergus Oct 16, 2026
eafc68d
Fix MSVC link errors against the geogram PSM
zfergus Oct 16, 2026
047ec60
Fix skip_obstacles weights in normal collisions
zfergus Oct 16, 2026
39cfa3e
Validate ESP parameters and quadrature consistency
zfergus Oct 16, 2026
f152576
Fix all_types candidates for ESP and IPC builds
zfergus Oct 16, 2026
3ecad1e
Read ESP vertex matrices without copies
zfergus Oct 18, 2026
d8ec238
Fix ESP signs and integration on non-closed meshes
zfergus Oct 18, 2026
b12b4b4
Fix ESP under ColMajor layout and without Abseil
zfergus Oct 19, 2026
1d0f853
Test both sides of the edge-edge parallel threshold
zfergus Oct 19, 2026
d5bdb83
Document the exact distance-type API
zfergus Oct 19, 2026
157645b
Move GENERATEs out of SECTIONs in ESP tests
zfergus Oct 19, 2026
d54ea91
Fix NaN barriers at zero distance
zfergus Oct 19, 2026
61d6156
Size ESP stencil buffers for their real stencils
zfergus Oct 19, 2026
180351a
Fix ESP closest point of nearly parallel edges
zfergus Oct 19, 2026
93b55ae
Log errors before throwing across src/
zfergus Oct 19, 2026
abc817b
Fix ESP obstacle handling of mixed and 2D edges
zfergus Oct 19, 2026
76b19b1
Use LBVH traversal for ESP point queries
zfergus Oct 19, 2026
f605aae
Pass blend_mu before normalize_weights for ESP
zfergus Oct 19, 2026
42cd38a
Print and count 2D ESP collision pairs
zfergus Oct 19, 2026
8baaafe
Fix vacuous ESPCollisionDict primitive id assert
zfergus Oct 19, 2026
2aaf029
Declare ESP explicit specializations in headers
zfergus Oct 19, 2026
da279fa
Define per-collision gcp_force_jacobian
zfergus Oct 19, 2026
6249a70
Template the inverse-power and near-far barriers
zfergus Oct 20, 2026
ee46d71
Store candidate adjacency lists in CSR arrays
zfergus Oct 20, 2026
cb2768f
Report the requested index in the range error
zfergus Oct 20, 2026
f3346b0
Rename AdjList to AdjacencyList
zfergus Oct 20, 2026
46574f6
Silence the unused capture warning in ESPCollisionDict
zfergus Oct 20, 2026
37ee48d
Use Catch2 BENCHMARK in the ESP adjacency benchmark
zfergus Oct 21, 2026
ab598fe
Add LBVH::query_point and drop ArbitraryPointBVH
zfergus Oct 21, 2026
3ad5585
Move pi_v into lobatto_compute
zfergus Oct 21, 2026
9a4c264
Use bracket includes in ESP sources
zfergus Oct 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ if(IPC_TOOLKIT_WITH_FILIB)
target_link_libraries(ipc_toolkit PUBLIC filib::filib)
endif()

# Exact arithmetic (geogram's MultiPrecision PSM)
include(geogram_multi_precision)
target_link_libraries(ipc_toolkit PRIVATE geogram::multi_precision)

# Block-accelerated Hessian assembly
if(IPC_TOOLKIT_WITH_MESHFEM_SPARSE)
include(meshfem_sparse)
Expand Down
4 changes: 2 additions & 2 deletions cmake/find/FindSIMD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ function(test_avx_availability)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(AVX_FLAGS "-xHost")
elseif(MSVC)
# /arch: is single-valued on MSVC: emitting both downgrades to AVX.
if(DETECTED_AVX_20)
SET(AVX_FLAGS "${AVX_FLAGS} /arch:AVX2")
endif()
if(DETECTED_AVX_10)
elseif(DETECTED_AVX_10)
SET(AVX_FLAGS "${AVX_FLAGS} /arch:AVX")
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/ipc_toolkit/ipc_toolkit_tests_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ else()
SOURCE_DIR ${IPC_TOOLKIT_TESTS_DATA_DIR}

GIT_REPOSITORY https://github.com/ipc-sim/ipc-toolkit-tests-data.git
GIT_TAG c7eba549d9a80d15569a013c473f0aff104ac44a
GIT_TAG 05696a21b8662f6cd12f8469eeb35ee9a5cc0493

CONFIGURE_COMMAND ""
BUILD_COMMAND ""
Expand Down
90 changes: 90 additions & 0 deletions cmake/recipes/geogram_multi_precision.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Geogram's MultiPrecision Pluggable Software Module
# (https://github.com/BrunoLevy/geogram)
# License: BSD 3-Clause License
if(TARGET geogram::multi_precision)
return()
endif()

message(STATUS "Third-party: creating target 'geogram::multi_precision'")

# The PSM is a standalone extract of geogram's exact arithmetic
# (expansion_nt), so we download its release archive instead of building all
# of geogram.
set(GEOGRAM_MULTI_PRECISION_VERSION "1.10.1")

include(CPM)
CPMAddPackage(
NAME geogram_multi_precision
URL "https://github.com/BrunoLevy/geogram/releases/download/v${GEOGRAM_MULTI_PRECISION_VERSION}/MultiPrecision_psm_${GEOGRAM_MULTI_PRECISION_VERSION}.zip"
URL_HASH SHA256=1c4fa0ef6422547f08b11891a0f934b90a2bc91359dcfaeb89a490b3878c0e18
DOWNLOAD_ONLY YES
)

# The archive also ships an optional CGAL example that carries an LGPL-3.0
# header. We never build it, so we delete it to keep the build tree free of
# non-permissive files.
file(REMOVE_RECURSE "${geogram_multi_precision_SOURCE_DIR}/CGAL")

# Downstream projects (e.g., PolyFEM) may link their own full copy of geogram,
# which defines the same GEO:: symbols as the PSM. Linking both would either
# fail with duplicate symbols (static) or silently mix two geogram versions
# (shared). Instead, we compile a copy of the PSM with its namespace renamed
# from GEO to ipc_geogram, so the two can never collide. We write the copy to
# the build tree so a shared CPM source cache is never modified.
set(GEOGRAM_MULTI_PRECISION_DIR
"${CMAKE_CURRENT_BINARY_DIR}/geogram_multi_precision")
foreach(file IN ITEMS MultiPrecision_psm.h MultiPrecision_psm.cpp)
file(READ "${geogram_multi_precision_SOURCE_DIR}/${file}" content)
# GEO only appears as the namespace name ("namespace GEO", "GEO::", and
# "using namespace GEO"). Matching it as a whole word leaves macros such
# as GEO_OS_WINDOWS untouched.
string(REGEX REPLACE "([^A-Za-z0-9_])GEO([^A-Za-z0-9_])"
"\\1ipc_geogram\\2" content "${content}")
# If a future PSM spells the namespace in a way the pattern above misses,
# the copy would silently keep GEO:: symbols and could clash again, so we
# fail loudly instead.
string(REGEX MATCH "(^|[^A-Za-z0-9_])GEO([^A-Za-z0-9_]|$)"
leftover "${content}")
if(leftover)
message(FATAL_ERROR
"Failed to rename namespace GEO to ipc_geogram in ${file}.")
endif()
file(WRITE "${GEOGRAM_MULTI_PRECISION_DIR}/tmp/${file}" "${content}")
# Copy only when the content changed, so we don't trigger rebuilds.
configure_file("${GEOGRAM_MULTI_PRECISION_DIR}/tmp/${file}"
"${GEOGRAM_MULTI_PRECISION_DIR}/${file}" COPYONLY)
endforeach()

add_library(geogram_multi_precision STATIC
"${GEOGRAM_MULTI_PRECISION_DIR}/MultiPrecision_psm.cpp"
)
add_library(geogram::multi_precision ALIAS geogram_multi_precision)

target_include_directories(geogram_multi_precision SYSTEM PUBLIC
"$<BUILD_INTERFACE:${GEOGRAM_MULTI_PRECISION_DIR}>"
)

# The PSM header assumes geogram is a shared library unless told otherwise. On
# MSVC that marks every symbol __declspec(dllimport), which breaks linking
# against our static build, so we define GEO_STATIC_LIBS for the library and
# everything that includes its header.
target_compile_definitions(geogram_multi_precision PUBLIC GEO_STATIC_LIBS)

target_compile_features(geogram_multi_precision PUBLIC cxx_std_17)
set_target_properties(geogram_multi_precision PROPERTIES
POSITION_INDEPENDENT_CODE ON
)

# The expansion arithmetic relies on error-free transforms, which break if the
# compiler fuses a*b+c into an FMA, so we turn off contraction. We also silence
# the third-party warnings.
if(MSVC)
target_compile_options(geogram_multi_precision PRIVATE "/fp:precise" "/w")
else()
target_compile_options(geogram_multi_precision PRIVATE
"-ffp-contract=off" "-w"
)
endif()

# Folder name for IDE
set_target_properties(geogram_multi_precision PROPERTIES FOLDER "ThirdParty")
2 changes: 2 additions & 0 deletions docs/source/_static/graphviz/dependencies.dot
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,6 @@ digraph "IPC Toolkit Dependencies" {
// MeshFEMSparse -> Eigen3_Eigen
"node17" -> "node9" [color = "#8FB976";];
// MeshFEMSparse -> tbb
"node18" [label = "geogram_multi_precision\n(geogram::multi_precision)";shape = box;style = "rounded,filled";fillcolor = "#D5E8D4";color = "#8FB976";];
"node5" -> "node18" [color = "#BE6562";];
}
Loading
Loading