Skip to content

Commit 9ced881

Browse files
committed
Fix glb converter
1 parent 09b0b2e commit 9ced881

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
### Added
66
- Subset more than one CityObject type (#9)
77
- `models.Geometry.reproject()` for reprojecting dereferenced geometry boundaries
8+
- Read from `stdin` and save to `stdout`
9+
- `--suppress_msg` to suppress all messages. Required when saving to `stdout`
810

911
### Fixed
1012
- Subset with BBOX does not modify the input model anymore (#10)
@@ -13,15 +15,17 @@
1315
- `texture` and `material` are correctly removed from the geometries of the CityObjects with `textures/materials_remove`
1416
- `vertex-texture` is removed from the CityJSON with `textures_remove`
1517
- Docker image build (#77, #132)
18+
- Other minor fixes
1619

1720
### Changed
1821
- Export format is an argument, not an option (#35), e.g. `cjio ... export obj out.obj`
1922
- NumPy is a hard requirement
2023
- Require pyproj >= 3.0.0 (#142)
24+
- Refactor warnings and alert printing (#143)
2125

2226
## [0.7.4] - 2022-06-20
2327
### Fixed
24-
- crash wiht new version of Click (>=8.1) (#140)
28+
- crash with new version of Click (>=8.1) (#140)
2529
### Added
2630
- templates for bug reporting
2731

cjio/convert.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,17 +174,25 @@ def to_glb(cm):
174174
triList = []
175175
for shell in geom['boundaries']:
176176
for face in shell:
177-
tri = geom_help.triangulate_face(face, vertexlist)
178-
for t in tri:
179-
triList.append(list(t))
177+
tri, success = geom_help.triangulate_face(face, vertexlist)
178+
if success:
179+
for t in tri:
180+
triList.append(list(t))
181+
else:
182+
# TODO: logging
183+
print(f"Failed to triangulate face in CityObject {theid}")
180184
trigeom = (flatten(triList))
181185

182186
elif (geom['type'] == 'MultiSurface') or (geom['type'] == 'CompositeSurface'):
183187
triList = []
184188
for face in geom['boundaries']:
185-
tri = geom_help.triangulate_face(face, vertexlist)
186-
for t in tri:
187-
triList.append(t)
189+
tri, success = geom_help.triangulate_face(face, vertexlist)
190+
if success:
191+
for t in tri:
192+
triList.append(t)
193+
else:
194+
# TODO: logging
195+
print(f"Failed to triangulate face in CityObject {theid}")
188196
trigeom = (flatten(triList))
189197
flatgeom = trigeom
190198
forimax.append(flatgeom)
@@ -199,7 +207,10 @@ def to_glb(cm):
199207
# Need to swap the axis, because gltf uses a right-handed coordinate
200208
# system. glTF defines +Y as up, +Z as forward, and -X as right;
201209
# the front of a glTF asset faces +Z.
202-
vtx_np[i] = np.array((vertexlist[v][1], vertexlist[v][2], vertexlist[v][0]))
210+
try:
211+
vtx_np[i] = np.array((vertexlist[v][1], vertexlist[v][2], vertexlist[v][0]))
212+
except IndexError as e:
213+
print(i, v)
203214
vtx_idx_np[i] = i
204215
bin_vtx = vtx_np.astype(np.float32).tostring()
205216
# convert geometry indices to binary

0 commit comments

Comments
 (0)