Skip to content

Commit 3f12d9e

Browse files
authored
Download test data from external repo (#113)
* Download test data from external repo * Add option to use existing tests data * Convert OBJs to PLYs * Python download data at test time
1 parent f55090b commit 3f12d9e

File tree

497 files changed

+159
-122071
lines changed

Some content is hidden

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

497 files changed

+159
-122071
lines changed

.gitignore

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,19 +243,12 @@ core*
243243
docs/source/doxyoutput
244244
docs/source/api
245245
!docs/Makefile
246-
# Private data
247-
tests/data/private
248-
# Git repo of sample CCD queries
249-
tests/data/ccd-queries
250-
# Too large to store in git
251-
tests/data/friction/chain
252246
logo
253247
ipctk
254248

255249
# Python bindings
256250
!python/src/bindings*
257251
!python/src/**/bindings*
258-
python/bunny.obj
259252

260253
IPCToolkitOptions.cmake
261254

@@ -265,5 +258,7 @@ tests/src/tests/config.hpp
265258
docs/_doxygen
266259

267260
notebooks/*.[ch]pp
268-
tests/data/cloth_ball_bf_ccd_candidates.json
269261
python/update_bindings.py
262+
263+
# External test data
264+
tests/data
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ipc-toolkit-tests-data (https://github.com/ipc-sim/ipc-toolkit-tests-data)
2+
# License: MIT
3+
4+
if(TARGET ipc_toolkit_test_data_download)
5+
return()
6+
endif()
7+
8+
include(ExternalProject)
9+
include(FetchContent)
10+
11+
set(IPC_TOOLKIT_TESTS_DATA_DIR "${PROJECT_SOURCE_DIR}/tests/data/" CACHE PATH "Where should we download the tests data?")
12+
option(IPC_TOOLKIT_USE_EXISTING_TESTS_DATA_DIR "Use an existing test data directory instead of downloading it" OFF)
13+
14+
if(IPC_TOOLKIT_USE_EXISTING_TESTS_DATA_DIR)
15+
ExternalProject_Add(
16+
ipc_toolkit_test_data_download
17+
PREFIX "${FETCHCONTENT_BASE_DIR}/tests/data"
18+
SOURCE_DIR ${IPC_TOOLKIT_TESTS_DATA_DIR}
19+
20+
# NOTE: No download step
21+
CONFIGURE_COMMAND ""
22+
BUILD_COMMAND ""
23+
INSTALL_COMMAND ""
24+
LOG_DOWNLOAD ON
25+
)
26+
else()
27+
ExternalProject_Add(
28+
ipc_toolkit_test_data_download
29+
PREFIX "${FETCHCONTENT_BASE_DIR}/tests/data"
30+
SOURCE_DIR ${IPC_TOOLKIT_TESTS_DATA_DIR}
31+
32+
GIT_REPOSITORY https://github.com/ipc-sim/ipc-toolkit-tests-data.git
33+
GIT_TAG 333aed25f87c5820bec8a7f82d7959ff87a9a502
34+
35+
CONFIGURE_COMMAND ""
36+
BUILD_COMMAND ""
37+
INSTALL_COMMAND ""
38+
LOG_DOWNLOAD ON
39+
)
40+
endif()

cmake/recipes/ccd_query_io.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ endif()
66

77
message(STATUS "Third-party: creating target 'ccd_io::ccd_io'")
88

9+
include(ipc_toolkit_tests_data)
10+
911
set(CCD_IO_DOWNLOAD_SAMPLE_QUERIES ON CACHE BOOL "Download sample CCD queries" FORCE)
10-
set(CCD_IO_SAMPLE_QUERIES_DIR "${PROJECT_SOURCE_DIR}/tests/data/ccd-queries/" CACHE PATH "Where should we download sample queries?")
12+
set(CCD_IO_SAMPLE_QUERIES_DIR "${IPC_TOOLKIT_TESTS_DATA_DIR}/ccd-queries/" CACHE PATH "Where should we download sample queries?")
1113

1214
include(CPM)
1315
CPMAddPackage("gh:Continuous-Collision-Detection/CCD-Query-IO#36f6093af81a65acc27d9f05ad32d6b5729e8d15")

docs/source/tutorial/getting_started.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Collision Mesh
88

99
First, we need to create a collision mesh. The ``CollisionMesh`` data structure represents the surface geometry used for collision processing.
1010

11-
We will start by creating a collision mesh from a ``bunny.obj`` mesh file (you can find the mesh `here <https://github.com/ipc-sim/ipc-toolkit/blob/main/tests/data/bunny.obj>`_):
11+
We will start by creating a collision mesh from a ``bunny.ply`` mesh file (you can find the mesh `here <https://github.com/ipc-sim/ipc-toolkit-tests-data/blob/main/bunny.ply>`_):
1212

1313
.. md-tab-set::
1414

@@ -20,14 +20,14 @@ We will start by creating a collision mesh from a ``bunny.obj`` mesh file (you c
2020

2121
#include <Eigen/Core>
2222
#include <Eigen/Sparse>
23-
#include <igl/readOBJ.h>
23+
#include <igl/read_triangle_mesh.h>
2424
#include <igl/edges.h>
2525

2626
// ...
2727

2828
Eigen::MatrixXd rest_positions;
2929
Eigen::MatrixXi edges, faces;
30-
igl::readOBJ("bunny.obj", rest_positions, faces);
30+
igl::read_triangle_mesh("bunny.ply", rest_positions, faces);
3131
igl::edges(faces, edges);
3232

3333
ipc::CollisionMesh collision_mesh(rest_positions, edges, faces);
@@ -40,7 +40,7 @@ We will start by creating a collision mesh from a ``bunny.obj`` mesh file (you c
4040
4141
import meshio
4242
43-
mesh = meshio.read("bunny.obj")
43+
mesh = meshio.read("bunny.ply")
4444
rest_positions = mesh.points
4545
faces = mesh.cells_dict["triangle"]
4646
edges = ipctk.edges(faces)

docs/source/tutorial/simulation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ While IPC cannot directly handle nonlinear finite element bases and/or curved me
194194
Eigen::MatrixXd proxy_rest_positions;
195195
Eigen::MatrixXi proxy_edges, proxy_faces;
196196
// Load the proxy mesh from a file
197-
igl::readOBJ("proxy.obj", rest_positions, faces);
197+
igl::read_triangle_mesh("proxy.ply", rest_positions, faces);
198198
igl::edges(faces, edges);
199199
// Or build it from the volumetric mesh
200200

@@ -215,7 +215,7 @@ While IPC cannot directly handle nonlinear finite element bases and/or curved me
215215
216216
# Collision proxy mesh
217217
# Load the proxy mesh from a file
218-
proxy_mesh = meshio.read("proxy.obj")
218+
proxy_mesh = meshio.read("proxy.ply")
219219
proxy_rest_positions = proxy_mesh.points
220220
proxy_faces = proxy_mesh.cells_dict["triangle"]
221221
proxy_edges = igl.edges(proxy_faces)

python/example.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91183,7 +91183,7 @@
9118391183
"metadata": {},
9118491184
"outputs": [],
9118591185
"source": [
91186-
"in_mesh = meshio.read(\"../tests/data/bunny.obj\")\n",
91186+
"in_mesh = meshio.read(\"../tests/data/bunny.ply\")\n",
9118791187
"V = in_mesh.points\n",
9118891188
"F = in_mesh.cells[0].data\n",
9118991189
"E = edges(F)"
@@ -91316,7 +91316,7 @@
9131691316
"name": "python",
9131791317
"nbconvert_exporter": "python",
9131891318
"pygments_lexer": "ipython3",
91319-
"version": "3.11.6"
91319+
"version": "3.11.9"
9132091320
},
9132191321
"varInspector": {
9132291322
"cols": {

python/tests/test_ccd.py

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

99

1010
def test_ccd():
11-
V0, E, F = load_mesh("two-cubes-close.obj")
12-
V1, E, F = load_mesh("two-cubes-intersecting.obj")
11+
V0, E, F = load_mesh("two-cubes-close.ply")
12+
V1, E, F = load_mesh("two-cubes-intersecting.ply")
1313

1414
mesh = ipctk.CollisionMesh(V0, E, F)
1515

python/tests/test_ipc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def check_ipc_derivatives(broad_phase_method, use_convergent_formulation, mesh_n
4141
def test_ipc():
4242
for method in utils.broad_phase_methods():
4343
for use_convergent_formulation in (True, False):
44-
yield check_ipc_derivatives, method, use_convergent_formulation, "cube.obj", np.sqrt(2.0), True
45-
yield check_ipc_derivatives, method, use_convergent_formulation, "two-cubes-far.obj", 1e-1, False
46-
yield check_ipc_derivatives, method, use_convergent_formulation, "two-cubes-close.obj", 1e-1, False
47-
yield check_ipc_derivatives, method, use_convergent_formulation, "bunny.obj", 5e-3, True
44+
yield check_ipc_derivatives, method, use_convergent_formulation, "cube.ply", np.sqrt(2.0), True
45+
yield check_ipc_derivatives, method, use_convergent_formulation, "two-cubes-far.ply", 1e-1, False
46+
yield check_ipc_derivatives, method, use_convergent_formulation, "two-cubes-close.ply", 1e-1, False
47+
yield check_ipc_derivatives, method, use_convergent_formulation, "bunny.ply", 5e-3, True

python/tests/utils.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,28 @@
55
import find_ipctk
66
import ipctk
77

8-
TEST_DATA_DIR = pathlib.Path(__file__).parents[2] / 'tests' / 'data'
8+
9+
def download_test_data_if_needed(directory):
10+
if directory.exists():
11+
return
12+
13+
# Clone the test data repository
14+
print(f"Downloading test data to {directory}")
15+
import subprocess
16+
subprocess.run([
17+
'git', 'clone', 'https://github.com/ipc-sim/ipc-toolkit-tests-data',
18+
str(directory)
19+
])
20+
21+
22+
def test_data_dir():
23+
_test_data_dir = pathlib.Path(__file__).parents[2] / 'tests' / 'data'
24+
download_test_data_if_needed(_test_data_dir)
25+
return _test_data_dir
926

1027

1128
def load_mesh(mesh_name):
12-
mesh = meshio.read(TEST_DATA_DIR / mesh_name)
29+
mesh = meshio.read(test_data_dir() / mesh_name)
1330
return mesh.points, ipctk.edges(mesh.cells_dict['triangle']), mesh.cells_dict['triangle']
1431

1532

tests/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ endif()
1818
set(IPC_TOOLKIT_TESTS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/tests")
1919
set(IPC_TOOLKIT_TESTS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
2020

21-
### Data directory
22-
cmake_path(APPEND IPC_TOOLKIT_TESTS_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}" "data")
23-
2421
################################################################################
2522
# IPC Toolkit Tests Executable
2623
################################################################################
@@ -29,6 +26,7 @@ cmake_path(APPEND IPC_TOOLKIT_TESTS_DATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}" "data
2926
add_executable(ipc_toolkit_tests)
3027

3128
# Fill in configuration options
29+
include(ipc_toolkit_tests_data)
3230
configure_file(
3331
"${IPC_TOOLKIT_TESTS_SOURCE_DIR}/config.hpp.in"
3432
"${IPC_TOOLKIT_TESTS_SOURCE_DIR}/config.hpp")

0 commit comments

Comments
 (0)