feat: load shapes from ply files
This commit is contained in:
parent
016e5a2949
commit
4d3d2fb44d
3 changed files with 13 additions and 4 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
venv
|
||||
*.pyc
|
||||
__pycache__
|
11
map.py
11
map.py
|
@ -6,6 +6,7 @@ import os
|
|||
import sys
|
||||
|
||||
import numpy as np
|
||||
from plyfile import PlyData
|
||||
from tqdm import tqdm, trange
|
||||
|
||||
|
||||
|
@ -114,9 +115,11 @@ def map_poly(tri, poly, ref=None):
|
|||
|
||||
|
||||
def main(ns):
|
||||
with open(ns.faces, 'r') as f:
|
||||
j = json.load(f)
|
||||
faces = [Face([np.array(v)*ns.scale for v in vs]) for vs in j]
|
||||
with open(ns.faces, 'rb') as f:
|
||||
plydata = PlyData.read(f)
|
||||
vs = plydata['vertex']
|
||||
fs = plydata['face']['vertex_indices']
|
||||
faces = [Face([np.array(vs[vi].tolist())*ns.scale for vi in fvs]) for fvs in fs]
|
||||
with open(ns.geojson, 'r') as f:
|
||||
geojson = json.load(f)
|
||||
|
||||
|
@ -161,6 +164,6 @@ if __name__ == '__main__':
|
|||
ap.add_argument('--geojson', '-g', default='countries.geojson')
|
||||
ap.add_argument('--faces', '-f', default='shapes/cube.json')
|
||||
ap.add_argument('--out', '-o', default='faces/{faces}/face{face}.svg')
|
||||
ap.add_argument('--scale', '-s', type=int, default=1)
|
||||
ap.add_argument('--scale', '-s', type=float, default=1)
|
||||
ns = ap.parse_args()
|
||||
main(ns)
|
||||
|
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
numpy==2.2.0
|
||||
plyfile==1.1
|
||||
tqdm==4.67.1
|
Loading…
Reference in a new issue