2021-03-16 16:58:52 -04:00
|
|
|
"""
|
|
|
|
Obj module parses obj files and import the geometry into the city model structure
|
|
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
2021-04-07 11:47:39 -04:00
|
|
|
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
|
2021-03-16 16:58:52 -04:00
|
|
|
"""
|
|
|
|
import trimesh.exchange.obj
|
2021-04-07 11:47:39 -04:00
|
|
|
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
|
2021-03-16 16:58:52 -04:00
|
|
|
|
|
|
|
|
|
|
|
class Obj:
|
|
|
|
"""
|
|
|
|
Obj class
|
|
|
|
"""
|
|
|
|
def __init__(self, path):
|
|
|
|
self._city = None
|
|
|
|
with open(path, 'r') as file:
|
|
|
|
self._scene = trimesh.exchange.obj.load_obj(file)
|
|
|
|
# todo: review class trimesh.exchange.load that returns Trimesh or Trimesh.scene
|
|
|
|
|
|
|
|
@property
|
|
|
|
def scene(self) -> dict:
|
|
|
|
return self._scene
|
2021-04-07 11:47:39 -04:00
|
|
|
|
|
|
|
@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
|