adding import obj (not yet working). Also erased accent from Alvarez

This commit is contained in:
Pilar 2021-04-07 11:47:39 -04:00
parent 39c6a3afd2
commit 5290cb6ba9
15 changed files with 149 additions and 13 deletions

View File

@ -2,7 +2,7 @@
Occupants module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Sanam Dabirian sanam.dabirian@mail.concordia.ca
Contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from typing import TypeVar

View File

@ -1,7 +1,7 @@
"""
Polygon module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import sys

View File

@ -2,7 +2,7 @@
Surface module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from __future__ import annotations

View File

@ -2,7 +2,7 @@
ThermalBoundary module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from typing import List, TypeVar
from city_model_structure.attributes.layer import Layer

View File

@ -2,7 +2,7 @@
ThermalOpening module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from typing import TypeVar

View File

@ -2,7 +2,7 @@
ThermalZone module
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import uuid
from typing import List, TypeVar

View File

@ -2,7 +2,7 @@
Geometry helper
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import math
import numpy as np

View File

@ -50,12 +50,22 @@ class GeometryFactory:
def scene(self):
"""
Load the city model structure from a geometry source
:return: Trimesh
:return: Trimesh scene
"""
return getattr(self, self._file_type, lambda: None)
@property
def _scene_debug(self):
"""
just for debug. More information is provided without the lambda parameter
"""
return getattr(self, self._file_type)
@property
def _city_debug(self):
"""
just for debug. More information is provided without the lambda parameter
"""
return CityGml(self._path).city
@property

View File

@ -5,7 +5,6 @@ Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@conc
"""
import numpy as np
import xmltodict
import time
from city_model_structure.city import City
from city_model_structure.building import Building
@ -70,7 +69,6 @@ class CityGml:
City model structure enriched with the geometry information
:return: City
"""
init = time.process_time_ns()
if self._city is None:
# todo: refactor this method to clearly choose the gml type
self._city = City(self._lower_corner, self._upper_corner, self._srs_name)

View File

@ -1,9 +1,14 @@
"""
Obj module parses obj files and import the geometry into the city model structure
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import trimesh.exchange.obj
from city_model_structure.city import City
from city_model_structure.building import Building
from city_model_structure.attributes.surface import Surface
from helpers.geometry_helper import GeometryHelper
from city_model_structure.attributes.polygon import Polygon
class Obj:
@ -19,3 +24,11 @@ class Obj:
@property
def scene(self) -> dict:
return self._scene
@property
def city(self) -> dict:
if self._city is None:
# todo: refactor this method to clearly choose the gml type
self._city = City(self._lower_corner, self._upper_corner, self._srs_name)
return self._city

View File

@ -1,7 +1,7 @@
"""
Building test
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path
from unittest import TestCase

View File

@ -2,6 +2,7 @@
TestExports test and validate the city export formats
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path

View File

@ -2,7 +2,7 @@
TestGeometryFactory test and validate the city model structure geometric parameters
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
Contributors Pilar Monsalvete Álvarez de Uribarri pilar.monsalvete@concordia.ca
Contributors Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
import os
from pathlib import Path

33
tests/test_imports.py Normal file
View File

@ -0,0 +1,33 @@
"""
TestImports test and validate the city export formats
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path
from unittest import TestCase
from imports.geometry_factory import GeometryFactory
class MyTestCase(TestCase):
def test_something(self):
self.assertEqual(True, False)
"""
TestImports
"""
def setUp(self) -> None:
"""
Test setup
:return: None
"""
self._city_gml = None
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
self._output_path = (Path(__file__).parent / 'tests_outputs').resolve()
def _get_city(self):
if self._city_gml is None:
file_path = (self._example_path / 'kelowna.obj').resolve()
scene = GeometryFactory('obj', file_path)._scene_debug
self._city_gml = scene.city
return self._city_gml

View File

@ -0,0 +1,81 @@
# https://github.com/mikedh/trimesh
v 329238.00000000 5528272.00000000 0.00000000
v 329238.00000000 5528272.00000000 3.79999995
v 329254.12500000 5528263.00000000 0.00000000
v 329254.12500000 5528263.00000000 3.79999995
v 329245.12500000 5528267.50000000 4.93084002
v 329246.15625000 5528272.50000000 0.00000000
v 329246.15625000 5528272.50000000 3.79999995
v 329229.15625000 5528271.00000000 0.00000000
v 329229.15625000 5528271.00000000 3.79999995
v 329242.18750000 5528267.00000000 5.29822016
v 329238.31250000 5528266.50000000 4.68875980
v 329229.31250000 5528269.50000000 0.00000000
v 329229.31250000 5528269.50000000 3.79999995
v 329244.34375000 5528267.00000000 4.99910021
v 329242.34375000 5528267.00000000 5.30000019
v 329233.34375000 5528276.00000000 0.00000000
v 329233.34375000 5528276.00000000 3.79999995
v 329247.34375000 5528262.50000000 0.00000000
v 329247.34375000 5528262.50000000 3.79999995
v 329242.40625000 5528257.50000000 0.00000000
v 329242.40625000 5528257.50000000 3.79999995
v 329231.50000000 5528270.50000000 4.31147003
v 329253.53125000 5528273.00000000 0.00000000
v 329253.53125000 5528273.00000000 3.79999995
v 329241.71875000 5528276.50000000 0.00000000
v 329241.71875000 5528276.50000000 3.79999995
v 329233.81250000 5528270.50000000 4.68364000
v 329248.81250000 5528267.50000000 4.92572021
f 22 9 13
f 28 4 24
f 23 6 7
f 7 24 23
f 6 25 26
f 26 7 6
f 25 1 2
f 2 26 25
f 1 16 17
f 17 2 1
f 16 8 9
f 9 17 16
f 8 12 13
f 13 9 8
f 12 20 21
f 21 13 12
f 20 18 19
f 19 21 20
f 18 3 4
f 4 19 18
f 3 23 24
f 24 4 3
f 6 23 3
f 6 3 18
f 6 18 20
f 6 20 12
f 6 12 8
f 8 16 1
f 6 8 1
f 1 25 6
f 24 7 14
f 24 14 5
f 5 28 24
f 7 26 15
f 15 14 7
f 26 2 11
f 26 11 10
f 10 15 26
f 2 17 27
f 27 11 2
f 17 9 22
f 22 27 17
f 21 10 11
f 13 21 11
f 13 11 27
f 27 22 13
f 21 19 5
f 21 5 14
f 21 14 15
f 15 10 21
f 19 4 28
f 28 5 19