diff --git a/city_model_structure/attributes/plane.py b/city_model_structure/attributes/plane.py index 87edb2d5..25a4ec3f 100644 --- a/city_model_structure/attributes/plane.py +++ b/city_model_structure/attributes/plane.py @@ -67,7 +67,7 @@ class Plane: e = self.equation denominator = np.abs((p[0] * e[0]) + (p[1] * e[1]) + (p[2] * e[2]) + e[3]) numerator = np.sqrt((e[0]**2) + (e[1]**2) + (e[2]**2)) - return denominator/numerator + return float(denominator / numerator) @property def opposite_normal(self): diff --git a/imports/geometry/rhino.py b/imports/geometry/rhino.py index 3e394866..69150d6a 100644 --- a/imports/geometry/rhino.py +++ b/imports/geometry/rhino.py @@ -4,20 +4,17 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.capip """ -from numpy import inf +import numpy as np from rhino3dm import * from rhino3dm._rhino3dm import Extrusion from rhino3dm._rhino3dm import MeshType - from city_model_structure.attributes.point import Point -import numpy as np - -from city_model_structure.building import Building -from helpers.configuration_helper import ConfigurationHelper from city_model_structure.attributes.polygon import Polygon -from city_model_structure.city import City +from city_model_structure.building import Building from city_model_structure.building_demand.surface import Surface as HubSurface +from city_model_structure.city import City +from helpers.configuration_helper import ConfigurationHelper from imports.geometry.helpers.geometry_helper import GeometryHelper @@ -75,49 +72,19 @@ class Rhino: for i in range(0, len(_mesh.Faces)): mesh_faces = _mesh.Faces[i] _points = '' + faces = [] for index in mesh_faces: + if index in faces: + continue + faces.append(index) self._corners(_mesh.Vertices[index]) _points = _points + f'{_mesh.Vertices[index].X} {_mesh.Vertices[index].Y} {_mesh.Vertices[index].Z} ' polygon_points = Rhino._solid_points(_points.strip()) hub_surfaces.append(HubSurface(Polygon(polygon_points), Polygon(polygon_points))) return hub_surfaces - def _add_face2(self, face): - hub_surfaces = [] - _mesh = face.GetMesh(MeshType.Default) - for i in range(0, len(_mesh.Faces)): - mesh_faces = _mesh.Faces[i] - _points = '' - for index in mesh_faces: - self._corners(_mesh.Vertices[index]) - _points = _points + f'{_mesh.Vertices[index].X} {_mesh.Vertices[index].Y} {_mesh.Vertices[index].Z} ' - polygon_points = Rhino._solid_points(_points.strip()) - x = 'x = [' - y = 'y = [' - z = 'z = [' - for point in polygon_points: - if x == 'x = [': - x = f'{x}{point[0]}' - y = f'{y}{point[1]}' - z = f'{z}{point[2]}' - else: - x = f'{x}, {point[0]}' - y = f'{y}, {point[1]}' - z = f'{z}, {point[2]}' - x = f'{x}]' - y = f'{y}]' - z = f'{z}]' - print(x) - print(y) - print(z) - print('_add(ax, x, y, z)') - hub_surfaces.append(HubSurface(Polygon(polygon_points), Polygon(polygon_points))) - return hub_surfaces - - @property def city(self) -> City: - i = 0 buildings = [] city_objects = [] # building and "windows" windows = [] @@ -166,4 +133,4 @@ class Rhino: for building in buildings: city.add_city_object(building) - return city \ No newline at end of file + return city diff --git a/unittests/test_geometry_factory.py b/unittests/test_geometry_factory.py index cce867da..bcb19ab2 100644 --- a/unittests/test_geometry_factory.py +++ b/unittests/test_geometry_factory.py @@ -6,6 +6,9 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca """ from pathlib import Path from unittest import TestCase + +from numpy import inf + from imports.geometry_factory import GeometryFactory from imports.construction_factory import ConstructionFactory @@ -124,6 +127,10 @@ class TestGeometryFactory(TestCase): city = self._get_rhino(file) self.assertIsNotNone(city, 'city is none') self.assertTrue(len(city.buildings) == 36) + i = 0 + for building in city.buildings: + self.assertIsNot(building.volume, inf, 'open volume') + i += 1 # obj def test_import_obj(self):