C1.Evaluate brick density
Compute the volume of material needed to cut & shape each Voussoir
a. oriented bounding box
# ==============================================================================
# get vertices of each block
# ==============================================================================
blanks = []
for block in blocks:
block_coordinates = []
for vkey in block.vertices():
coordinates = block.vertex_coordinates(vkey)
block_coordinates.append(coordinates)
bbox = oriented_bounding_box_numpy(block_coordinates)
array_to_list = np.array(bbox).tolist()
blanks.append(array_to_list)
b. load_check_data
#=================================================================
#Load Data
#=================================================================
HERE = os.path.dirname(__file__)
FILE_I = os.path.join(HERE, 'data', 'oriented_bbox_numpy.json')
with open(FILE_I, 'r') as f:
blocks = [Mesh.from_data(data) for data in json.load(f)]
blanks = [block.attributes['blank'] for block in blocks]
bbox = []
for blank in blanks:
box = Box.from_bounding_box(blank)
bbox.append(box)
c. Compute & visualize voussoirs by weight
#=================================================================
#Parameters units in kg per cubic meter
#=================================================================
stone_density = 2323
#=================================================================
#Compute Volume of bbox material
#=================================================================
bbox_weight = []
for box in bbox:
volume = box.volume
weight = int(volume * stone_density)
bbox_weight.append(weight)
#=================================================================
#Store weight as block attribute
#=================================================================
for block, weight in zip (blocks, bbox_weight):
block.attributes['weight'] = weight
#=================================================================
#Visualize weight by colour
#=================================================================
lowest_range = min(bbox_weight)
highest_range = max(bbox_weight)
low_range = int(((highest_range - lowest_range)/4) + lowest_range)
high_range = highest_range - ((highest_range - lowest_range)/4)
artist = MeshArtist(None, layer="WEIGHT")
artist.clear_layer()
for block in blocks:
weight = block.attributes['weight']
if weight <= low_range:
artist = MeshArtist(block, layer="WEIGHT::lowest_range")
artist.draw_faces(color=(250,128,114))
artist.redraw()
elif weight <= high_range and weight > low_range:
artist = MeshArtist(block, layer="WEIGHT::mid_range")
artist.draw_faces(color=(255,0,0))
artist.redraw()
elif weight <= highest_range and weight > high_range:
print('high_range' )
artist = MeshArtist(block, layer="WEIGHT::high_range")
artist.draw_faces(color=(128,0,0))
artist.redraw()
else:
print("not in any range", weight)
Last updated