Paper on arXiv: https://arxiv.org/abs/1803.05093
spt_cpp/ contains the source code for graph reconstruction, py_visualization/ contains the source code converting result to Paraview format. You need to compile spt_cpp first and call it from graphRecon.py. Please maintain the given directory structure. To use your own dataset, create directory dataset/your_dataset_name/, and put everything in this directory. The outputs can be found in result/. Once you complete one run on your dataset, persistence will be saved and you don't need to compute it again when you want to experiment with different threshold. density_estimation.cpp is for converting GPS trajectories to density fields.
To compile files in spt_cpp/, change directory to spt_cpp/, run the following command in the terminal:
Linux/macOS:
g++ DiMoSC.cpp -I./phat/include -std=c++11 -o spt_cpp
Windows(g++ need installed):
g++ -static DiMoSC.cpp -I./phat/include -std=c++11 -o spt_cpp
Usage:
python graphRecon.py dataset_name dataset_form dimension threshold
dataset_form -g input grid
dataset_form -t input triangulation
dimension 2 or 3
threshold [0,1] (the density function is normalized to [0,1])
2D triangulation as input:
python graphRecon.py Berlin -t 2 0.1
2D grid as input:
python graphRecon.py grid2D -g 2 0.6
3D triangulation as input:
python graphRecon.py test_3D -t 3 0.05
3D grid as input:
python graphRecon.py test_3D -g 3 0.05
All datasets can be downloaded here.
The input could be 2D/3D grids or trianglations from density functions.
the input text file should store the 2D grid as a matrixs. You can simply store your 2D array in python using np.savetxt().
the first line of the input text file is the dimension of the 3D grid m,n,l. And the 3D array is stored as 1D array after being flattened with np.reshape([m* n* l]).
The triangulation is stored in three files: tri_vert.txt, tri_edge.txt and tri_triangle.txt
tri_vert.txt:
x1 y1 (z1) f1
x2 y2 (z2) f2
x3 y3 (z3) f3
...
tri_edge.txt:
e1_adjacent_vertex_index1 e1_adjacent_vertex_index2
e2_adjacent_vertex_index1 e2_adjacent_vertex_index2
...
tri_triangle.txt:
t1_adjacent_vertex_index1 t1_adjacent_vertex_index2 t1_adjacent_vertex_index3
t2_adjacent_vertex_index1 t2_adjacent_vertex_index2 t2_adjacent_vertex_index3
...
The output graph is stored in two files: vert.txt and edge.txt
vert.txt:
x1 y1 (z1) f1
x2 y2 (z2) f2
x3 y3 (z3) f3
...
edge.txt:
e1_adjacent_vertex_index1 e1_adjacent_vertex_index2
e2_adjacent_vertex_index1 e2_adjacent_vertex_index2
...
visualization.png is the plot of the reconstructed graph. Paraview is recommended for 3D visualization.
Change directory to py_visualization/ (If not using the same directory structure, the directory location needs to be changed inside the code), run the following command in the terminal:
2D dataset:
python to_vtk_form_recon_2D.py <dataset_name>
3D dataset:
python to_vtk_form_recon_3D.py <dataset_name>
For example, 'python to_vtk_form_recon_3D.py test_3D' generates the vtp file for test_3D. Then you can open the vtp file in Paraview directly.
'python to_vtk_form_recon_2D.py Berlin' generates the vtp file for Berlin.
Instructions on volume rendering see here.
.raw files are used for volume rendering.
Open .raw file in Paraview,
test_3D:
Select Raw(binary) files when opening
Data scalar type: float
Data extent
0 49
0 49
0 49
ENZO:
Select Raw(binary) files when opening
Data scalar type: float
Data extent
0 63
0 63
0 63
Bone
Select Raw(binary) files when opening
Data scalar type: unsigned char
Data extent
0 245
0 147
0 146
All datasets can be downloaded here.
2D datasets: Athens, Berlin
3D datasets: ENZO, bone,test_3D
sur.vtp is the density terrain of 2D datasets, which can be opened directly in Paraview
[1] Wang, Suyi, Yusu Wang, and Yanjie Li. "Efficient map reconstruction and augmentation via topological methods." Proceedings of the 23rd SIGSPATIAL International Conference on Advances in Geographic Information Systems. ACM, 2015.
[2] Dey, Tamal K., Jiayuan Wang, and Yusu Wang. "Graph reconstruction by discrete Morse theory." arXiv preprint arXiv:1803.05093 (2018).