Rhino implementation for dompark project.
This commit is contained in:
parent
49bfc6eec9
commit
becc8f6068
|
@ -67,19 +67,22 @@ class Rhino:
|
||||||
for obj in self._model.Objects:
|
for obj in self._model.Objects:
|
||||||
name = obj.Attributes.Id
|
name = obj.Attributes.Id
|
||||||
surfaces = []
|
surfaces = []
|
||||||
for face in obj.Geometry.Faces:
|
try:
|
||||||
if face is None:
|
for face in obj.Geometry.Faces:
|
||||||
break
|
if face is None:
|
||||||
_mesh = face.GetMesh(MeshType.Default)
|
break
|
||||||
polygon_points = None
|
_mesh = face.GetMesh(MeshType.Default)
|
||||||
for i in range(0, len(_mesh.Faces)):
|
polygon_points = None
|
||||||
faces = _mesh.Faces[i]
|
for i in range(0, len(_mesh.Faces)):
|
||||||
_points = ''
|
faces = _mesh.Faces[i]
|
||||||
for index in faces:
|
_points = ''
|
||||||
self._lower_corner(_mesh.Vertices[index].X, _mesh.Vertices[index].Y, _mesh.Vertices[index].Z)
|
for index in faces:
|
||||||
_points = _points + f'{_mesh.Vertices[index].X} {_mesh.Vertices[index].Y} {_mesh.Vertices[index].Z} '
|
self._lower_corner(_mesh.Vertices[index].X, _mesh.Vertices[index].Y, _mesh.Vertices[index].Z)
|
||||||
polygon_points = Rhino._solid_points(_points.strip())
|
_points = _points + f'{_mesh.Vertices[index].X} {_mesh.Vertices[index].Y} {_mesh.Vertices[index].Z} '
|
||||||
surfaces.append(LibsSurface(Polygon(polygon_points), Polygon(polygon_points)))
|
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), []))
|
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)
|
lower_corner = (self._min_x, self._min_y, self._min_z)
|
||||||
upper_corner = (self._max_x, self._max_y, self._max_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!
|
# is not a building but a window!
|
||||||
for surface in rhino_object.surfaces:
|
for surface in rhino_object.surfaces:
|
||||||
# add to windows the "hole" with the normal inverted
|
# add to windows the "hole" with the normal inverted
|
||||||
print('window')
|
|
||||||
windows.append(Polygon(surface.perimeter_polygon.inverse))
|
windows.append(Polygon(surface.perimeter_polygon.inverse))
|
||||||
else:
|
else:
|
||||||
buildings.append(rhino_object)
|
buildings.append(rhino_object)
|
||||||
|
print(f'windows: {len(windows)}')
|
||||||
# todo: this method will be pretty inefficient
|
# todo: this method will be pretty inefficient
|
||||||
for hole in windows:
|
for hole in windows:
|
||||||
corner = hole.coordinates[0]
|
corner = hole.coordinates[0]
|
||||||
for building in buildings:
|
for building in buildings:
|
||||||
for surface in building.surfaces:
|
for surface in building.surfaces:
|
||||||
plane = surface.perimeter_polygon.plane
|
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 windows should be correctly modeled
|
||||||
# todo: this is a hack for dompark project it should not be done this way
|
# 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.
|
# check if the window is in the right high.
|
||||||
if surface.upper_corner[2] >= corner[2] >= surface.lower_corner[2]:
|
if surface.upper_corner[2] >= corner[2] >= surface.lower_corner[2]:
|
||||||
if surface.holes_polygons is None:
|
if surface.holes_polygons is None:
|
||||||
surface.holes_polygons = []
|
surface.holes_polygons = []
|
||||||
surface.holes_polygons.append(hole)
|
surface.holes_polygons.append(hole)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for building in buildings:
|
for building in buildings:
|
||||||
city.add_city_object(building)
|
city.add_city_object(building)
|
||||||
return city
|
return city
|
||||||
|
|
Loading…
Reference in New Issue
Block a user