Skip to content

Commit

Permalink
Output a fixed number of digits (based on "transform") for OBJ export
Browse files Browse the repository at this point in the history
and fixed the bug where the model wasn't compressed after OBJ export

fixes #134
  • Loading branch information
hugoledoux committed Mar 15, 2022
1 parent 138a25f commit 88689e5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cjio/cityjson.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,11 +1476,14 @@ def export2jsonl(self):
return out

def export2obj(self):
imp_digits = math.ceil(abs(math.log(self.j["transform"]["scale"][0], 10)))
ids = "." + str(imp_digits) + "f"
self.decompress()
out = StringIO()
#-- write vertices
for v in self.j['vertices']:
out.write('v ' + str(v[0]) + ' ' + str(v[1]) + ' ' + str(v[2]) + '\n')
s = format("v {} {} {}\n".format(format(v[0], ids), format(v[1], ids), format(v[2], ids)))
out.write(s)
vnp = np.array(self.j["vertices"])
#-- translate to minx,miny
minx = 9e9
Expand Down Expand Up @@ -1514,6 +1517,7 @@ def export2obj(self):
if b == True:
for t in re:
out.write("f %d %d %d\n" % (t[0] + 1, t[1] + 1, t[2] + 1))
self.compress(imp_digits)
return out

def export2stl(self):
Expand Down

0 comments on commit 88689e5

Please sign in to comment.