summer_course_2024/imports/geometry_feeders/obj.py

35 lines
1.1 KiB
Python
Raw Normal View History

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
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
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
@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