diff --git a/city_model_structure/attributes/polyhedron.py b/city_model_structure/attributes/polyhedron.py index 886e8d27..0c23875f 100644 --- a/city_model_structure/attributes/polyhedron.py +++ b/city_model_structure/attributes/polyhedron.py @@ -5,7 +5,6 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc """ import numpy as np from trimesh import Trimesh - from helpers.geometry_helper import GeometryHelper @@ -107,13 +106,21 @@ class Polyhedron: """ return self._polyhedron_mesh.centroid - def export(self, full_path): + def stl_export(self, full_path): """ Export the polyhedron to stl given file :param full_path: str :return: None """ - self._polyhedron_mesh.export(full_path) + self._polyhedron_mesh.export(full_path, 'stl_ascii') + + def obj_export(self, full_path): + """ + Export the polyhedron to obj given file + :param full_path: str + :return: None + """ + self._polyhedron_mesh.export(full_path, 'obj') def show(self): - self._polyhedron_mesh.show() \ No newline at end of file + self._polyhedron_mesh.show() diff --git a/city_model_structure/city_object.py b/city_model_structure/city_object.py index 489242b6..bf252a62 100644 --- a/city_model_structure/city_object.py +++ b/city_model_structure/city_object.py @@ -78,13 +78,21 @@ class CityObject: if self._polyhedron is None: self._polyhedron = Polyhedron(self.surfaces) full_path = (Path(path) / (self._name + '.stl')).resolve() - self._polyhedron.export(full_path) + self._polyhedron.stl_export(full_path) + + def obj_export(self, path): + if self._polyhedron is None: + self._polyhedron = Polyhedron(self.surfaces) + full_path = (Path(path) / (self._name + '.obj')).resolve() + self._polyhedron.obj_export(full_path) def show(self): if self._polyhedron is None: self._polyhedron = Polyhedron(self.surfaces) self._polyhedron.show() + + @property def max_height(self): """ diff --git a/tests/test_idf.py b/tests/test_idf.py index 0a4eba77..93b7df5f 100644 --- a/tests/test_idf.py +++ b/tests/test_idf.py @@ -8,6 +8,7 @@ from unittest import TestCase from factories.geometry_factory import GeometryFactory from factories.physics_factory import PhysicsFactory from factories.usage_factory import UsageFactory +from factories.occupancy_factory import OccupancyFactory from helpers.idf_helper import IdfHelper import os import glob @@ -33,6 +34,8 @@ class TestIdf(TestCase): self._city_gml = GeometryFactory('citygml', file_path).city PhysicsFactory('us_new_york', self._city_gml) UsageFactory('us_new_york', self._city_gml) + UsageFactory('us_new_york', self._city_gml) + OccupancyFactory('demo', self._city_gml) return self._city_gml def test_idf_blocks(self):