forked from s_ranjbar/city_retrofit
Correct rhino read
This commit is contained in:
parent
0ec80dacc0
commit
f53beb4a0a
|
@ -67,7 +67,7 @@ class Plane:
|
||||||
e = self.equation
|
e = self.equation
|
||||||
denominator = np.abs((p[0] * e[0]) + (p[1] * e[1]) + (p[2] * e[2]) + e[3])
|
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))
|
numerator = np.sqrt((e[0]**2) + (e[1]**2) + (e[2]**2))
|
||||||
return denominator/numerator
|
return float(denominator / numerator)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def opposite_normal(self):
|
def opposite_normal(self):
|
||||||
|
|
|
@ -4,20 +4,17 @@ SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Concordia CERC group
|
Copyright © 2022 Concordia CERC group
|
||||||
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.capip
|
Project Coder Guille Gutierrez guillermo.gutierrezmorote@concordia.capip
|
||||||
"""
|
"""
|
||||||
from numpy import inf
|
import numpy as np
|
||||||
from rhino3dm import *
|
from rhino3dm import *
|
||||||
from rhino3dm._rhino3dm import Extrusion
|
from rhino3dm._rhino3dm import Extrusion
|
||||||
from rhino3dm._rhino3dm import MeshType
|
from rhino3dm._rhino3dm import MeshType
|
||||||
|
|
||||||
|
|
||||||
from city_model_structure.attributes.point import Point
|
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.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.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
|
from imports.geometry.helpers.geometry_helper import GeometryHelper
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,49 +72,19 @@ class Rhino:
|
||||||
for i in range(0, len(_mesh.Faces)):
|
for i in range(0, len(_mesh.Faces)):
|
||||||
mesh_faces = _mesh.Faces[i]
|
mesh_faces = _mesh.Faces[i]
|
||||||
_points = ''
|
_points = ''
|
||||||
|
faces = []
|
||||||
for index in mesh_faces:
|
for index in mesh_faces:
|
||||||
|
if index in faces:
|
||||||
|
continue
|
||||||
|
faces.append(index)
|
||||||
self._corners(_mesh.Vertices[index])
|
self._corners(_mesh.Vertices[index])
|
||||||
_points = _points + f'{_mesh.Vertices[index].X} {_mesh.Vertices[index].Y} {_mesh.Vertices[index].Z} '
|
_points = _points + f'{_mesh.Vertices[index].X} {_mesh.Vertices[index].Y} {_mesh.Vertices[index].Z} '
|
||||||
polygon_points = Rhino._solid_points(_points.strip())
|
polygon_points = Rhino._solid_points(_points.strip())
|
||||||
hub_surfaces.append(HubSurface(Polygon(polygon_points), Polygon(polygon_points)))
|
hub_surfaces.append(HubSurface(Polygon(polygon_points), Polygon(polygon_points)))
|
||||||
return hub_surfaces
|
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
|
@property
|
||||||
def city(self) -> City:
|
def city(self) -> City:
|
||||||
i = 0
|
|
||||||
buildings = []
|
buildings = []
|
||||||
city_objects = [] # building and "windows"
|
city_objects = [] # building and "windows"
|
||||||
windows = []
|
windows = []
|
||||||
|
|
|
@ -6,6 +6,9 @@ Project Coder Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
||||||
"""
|
"""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from numpy import inf
|
||||||
|
|
||||||
from imports.geometry_factory import GeometryFactory
|
from imports.geometry_factory import GeometryFactory
|
||||||
from imports.construction_factory import ConstructionFactory
|
from imports.construction_factory import ConstructionFactory
|
||||||
|
|
||||||
|
@ -124,6 +127,10 @@ class TestGeometryFactory(TestCase):
|
||||||
city = self._get_rhino(file)
|
city = self._get_rhino(file)
|
||||||
self.assertIsNotNone(city, 'city is none')
|
self.assertIsNotNone(city, 'city is none')
|
||||||
self.assertTrue(len(city.buildings) == 36)
|
self.assertTrue(len(city.buildings) == 36)
|
||||||
|
i = 0
|
||||||
|
for building in city.buildings:
|
||||||
|
self.assertIsNot(building.volume, inf, 'open volume')
|
||||||
|
i += 1
|
||||||
|
|
||||||
# obj
|
# obj
|
||||||
def test_import_obj(self):
|
def test_import_obj(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user