system_assignation/exports/formats/triangular.py

23 lines
723 B
Python
Raw Normal View History

from pathlib import Path
from trimesh import Trimesh
2021-03-16 16:58:52 -04:00
class Triangular:
def __init__(self, city, path, triangular_format):
self._city = city
self._path = path
self._triangular_format = triangular_format
self._files()
def _files(self):
if self._city.name is None:
self._city.name = 'unknown_city'
file_name = self._city.name + '.' + self._triangular_format
file_path = (Path(self._path).resolve() / file_name).resolve()
print(file_path)
trimesh = Trimesh()
for building in self._city.buildings:
trimesh = trimesh.union(building.simplified_polyhedron.trimesh)
with open(file_path, 'w') as file:
file.write(trimesh.export(file_type=self._triangular_format))