diff --git a/imports/geometry/rhino.py b/imports/geometry/rhino.py index f9f41338..3b2c283a 100644 --- a/imports/geometry/rhino.py +++ b/imports/geometry/rhino.py @@ -67,19 +67,22 @@ class Rhino: for obj in self._model.Objects: name = obj.Attributes.Id surfaces = [] - for face in obj.Geometry.Faces: - if face is None: - break - _mesh = face.GetMesh(MeshType.Default) - polygon_points = None - for i in range(0, len(_mesh.Faces)): - faces = _mesh.Faces[i] - _points = '' - for index in faces: - self._lower_corner(_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()) - surfaces.append(LibsSurface(Polygon(polygon_points), Polygon(polygon_points))) + try: + for face in obj.Geometry.Faces: + if face is None: + break + _mesh = face.GetMesh(MeshType.Default) + polygon_points = None + for i in range(0, len(_mesh.Faces)): + faces = _mesh.Faces[i] + _points = '' + for index in faces: + self._lower_corner(_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()) + surfaces.append(LibsSurface(Polygon(polygon_points), Polygon(polygon_points))) + except AttributeError: + continue rhino_objects.append(Building(name, 3, surfaces, 'unknown', 'unknown', (self._min_x, self._min_y, self._min_z), [])) lower_corner = (self._min_x, self._min_y, self._min_z) upper_corner = (self._max_x, self._max_y, self._max_z) @@ -89,27 +92,27 @@ class Rhino: # is not a building but a window! for surface in rhino_object.surfaces: # add to windows the "hole" with the normal inverted - print('window') + windows.append(Polygon(surface.perimeter_polygon.inverse)) else: buildings.append(rhino_object) - + print(f'windows: {len(windows)}') # todo: this method will be pretty inefficient for hole in windows: corner = hole.coordinates[0] for building in buildings: for surface in building.surfaces: plane = surface.perimeter_polygon.plane - if plane.distance(corner) <= EPSILON: - # todo: this is a hack for dompark project it should not be done this way + # todo: this is a hack for dompark project it should not be done this way windows should be correctly modeled + # if the distance between the wall plane and the window is less than 2m + # and the window Z coordinate it's between the wall Z, it's a window of that wall + if plane.distance(corner) <= 2: # check if the window is in the right high. if surface.upper_corner[2] >= corner[2] >= surface.lower_corner[2]: if surface.holes_polygons is None: surface.holes_polygons = [] surface.holes_polygons.append(hole) - - for building in buildings: city.add_city_object(building) return city