From 7329e36bc8ea780d19a89c20a1f3bc0af31b1aff Mon Sep 17 00:00:00 2001 From: pilar Date: Thu, 11 Jun 2020 17:30:50 -0400 Subject: [PATCH] changed stl to trimesh --- city_model_structure/polyhedron.py | 19 +++++++++++-------- config/configuration.ini | 6 ++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/city_model_structure/polyhedron.py b/city_model_structure/polyhedron.py index d1665029..901dab2c 100644 --- a/city_model_structure/polyhedron.py +++ b/city_model_structure/polyhedron.py @@ -4,8 +4,8 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca """ import numpy as np -import stl from helpers.geometry_helper import GeometryHelper +from trimesh import Trimesh class Polyhedron: @@ -24,7 +24,7 @@ class Polyhedron: def _position_of(self, point): vertices = self.vertices - for i in enumerate(vertices): + for i in range(len(vertices)): if self._geometry.almost_equal(vertices[i], point): return i return -1 @@ -70,10 +70,10 @@ class Polyhedron: @property def _polyhedron_mesh(self): if self._mesh is None: - self._mesh = stl.mesh.Mesh(np.zeros(self.faces.shape[0], dtype=stl.mesh.Mesh.dtype)) - for i, faces in enumerate(self.faces): - for j in range(3): - self._mesh.vectors[i][j] = self.vertices[faces[j], :] + self._mesh = Trimesh(vertices=np.asarray(self.vertices), faces=np.asarray(self.faces)) + if not self._mesh.is_volume: + print('error') + return None return self._mesh @property @@ -83,7 +83,7 @@ class Polyhedron: :return: float """ if self._volume is None: - self._volume, _, _ = self._polyhedron_mesh.get_mass_properties() + self._volume = self._polyhedron_mesh.volume return self._volume @property @@ -92,7 +92,10 @@ class Polyhedron: Polyhedron maximal z value :return: float """ - return self._polyhedron_mesh.z.max() + bounds = self._polyhedron_mesh.bounds + z_max = max(bounds[:, 2]) + print(z_max) + return z_max def save(self, full_path): """ diff --git a/config/configuration.ini b/config/configuration.ini index 81cdb84f..295bab3c 100644 --- a/config/configuration.ini +++ b/config/configuration.ini @@ -1,7 +1,9 @@ # These values are intended as configurable assumptions [convective_fluxes] -h_i = 10 # W/m2K -h_e = 25 # W/m2K +# interior convective coefficient in W/m2K +h_i = 10 +# exterior convective coefficient in W/m2K +h_e = 25 [windows] frame_ratio = 0