07 roof access
import os
import topogenesis as tg
import pyvista as pv
import trimesh as tm
import numpy as np
import pickle
import csv
#This script calculates roof acces based on voxel_z
########################################################################################
#Load the complete lattice for reference and shape
lattice_path = os.path.relpath("data\lattice_complete_3_6.csv")
shape = envelope_lattice.shape
roof_access_base = np.ones(shape)
########################################################################################
########################################################################################
#intialize lists
z_coords_step = []
z_coords_list = []
#Creating a base list filled with 0.0 and a list of [x, y,[all_z]]
for i in range(len(envelope_lattice)):
for j in range(len(envelope_lattice[0])):
for k in range(len(envelope_lattice[0][0])):
roof_access_base[i][j][k] = 0.0
if envelope_lattice[i][j][k] == True:
z_coords_step.append(k)
z_coords_list.append([i, j, z_coords_step])
z_coords_step = []
#Scale list by len of all_z so z_min = 0.0 and z_max = 1.0
z_coords_scaled = z_coords_list[:]
for i in range(len(z_coords_list)):
s = 1 / (len(z_coords_list[i][2])-1)
for j in range(len(z_coords_list[i][2])):
z_coords_scaled[i][2][j] = z_coords_list[i][2][j]*s
#Place scaled values into a proper lattice
final_list = []
for i in range(len(z_coords_scaled)):
x = z_coords_scaled[i][0]
y = z_coords_scaled[i][1]
for j in range(len(z_coords_scaled[i][2])):
z = j
val = z_coords_scaled[i][2][j]
roof_access_base[x][y][z] = val
#Export roof_access lattice
roof_access_lattice = tg.to_lattice(roof_access_base, envelope_lattice)
csv_path_lattice = os.path.relpath("data\roof_access_3_6.csv")
roof_access_lattice.to_csv(csv_path_lattice)
########################################################################################
print("done")
Last update: January 25, 2021