-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
63 lines (57 loc) · 1.44 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from os.path import join
from constants import mesh_dir, query_dir
from numpy import loadtxt
from cupy import asarray
def load_cuda_array_from_txt(
file_name,
**kwargs
):
return asarray(
loadtxt(
file_name,
**kwargs
)
)
def load_query_points(query_name):
return load_cuda_array_from_txt(
join(query_dir, query_name+"_points.csv"),
delimiter=','
)
def load_mesh(mesh_name):
vertex_normals = None
try:
vertex_normals = load_cuda_array_from_txt(
join(mesh_dir, mesh_name+"_vert_normals.csv"),
delimiter=','
)
except:
print("Unable to load vertex normals. Using inferred face normals.")
return (
load_cuda_array_from_txt(
join(mesh_dir, mesh_name+"_triangles.csv"),
dtype=int,
delimiter=','
),
load_cuda_array_from_txt(
join(mesh_dir, mesh_name+"_verts.csv"),
delimiter=','
),
vertex_normals
)
def load_mesh_np(mesh_name):
return (
loadtxt(
join(mesh_dir, mesh_name+"_triangles.csv"),
dtype=int,
delimiter=','
),
loadtxt(
join(mesh_dir, mesh_name+"_verts.csv"),
delimiter=','
),
)
def load_query_points_np(query_name):
return loadtxt(
join(query_dir, query_name+"_points.csv"),
delimiter=','
)