Skip to content
Snippets Groups Projects
Commit 4bc026c7 authored by Lab Computer's avatar Lab Computer
Browse files

generate bounding boxes of partitions and record max layers to collision check

parent b2942baa
No related merge requests found
......@@ -216,6 +216,7 @@ class ReebPartition:
self.GP = data['GP']
if 'bboxes' in data:
self.bboxes = data['bboxes']
self.partition_max_layer = data['partition_max_layer']
if 'surf_points' in data:
self.surf_points = data['surf_points']
self.col_theta = col_theta
......@@ -374,6 +375,7 @@ class ReebPartition:
if 'dependson' in self.G.nodes[n] and \
not self.GP.has_edge(self.G.nodes[self.G.nodes[n]['dependson']]['partition'], self.G.nodes[n]['partition']):
self.GP.add_edge(self.G.nodes[self.G.nodes[n]['dependson']]['partition'], self.G.nodes[n]['partition'])
self.gen_boundingboxes()
def assign_contours(self, new_contours, node_n):
self.contours += new_contours
......@@ -449,7 +451,7 @@ class ReebPartition:
pl.add_mesh(mesh, color=np.random.randint(0, 255, size=3).tolist(), show_edges=True,
opacity=1, line_width=0.1, edge_color=np.random.randint(0, 255, size=3).tolist())
pl.show()
def show_contours(self):
pl = pv.Plotter()
pl.add_mesh(self.mesh, opacity=0.2)
......@@ -459,11 +461,23 @@ class ReebPartition:
opacity=1, line_width=0.1, edge_color=colors[self.contour_partition[i]])
pl.show()
def boundingboxes_DEPRECATED(self):
def gen_boundingboxes(self):
"""
Get bounding boxes for each partition
"""
s = time.time()
print("Generating bounding boxes...")
self.bboxes = []
self.partition_max_layer = []
for i in range(len(self.partitions)):
mesh = pv.PolyData()
max_layer = 0
for n in self.partitions[i]:
mesh += self.G.nodes[n]['sl']
max_layer = self.G.nodes[n]['layer']
self.partition_max_layer.append(max_layer)
self.bboxes.append(mesh.bounds)
print("Bounding boxes Generated in {} seconds.".format(time.time()-s))
def save(self, filename, surfs=None):
"""
......@@ -488,6 +502,8 @@ class ReebPartition:
'zs': self.zs,
'GP': self.GP,
'surf_points': surf_points,
'bboxes': self.bboxes,
'partition_max_layer': self.partition_max_layer,
}
with open(filename, 'wb') as f:
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment