summer_course_2024/imports/geometry_feeders/obj.py

35 lines
1.1 KiB
Python

"""
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
"""
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:
"""
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