blob: 576f9188598f4e96cfef07546853e072e96076cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright 2006 Google Inc.
// All Rights Reserved.
// Author: <renn@google.com> (Marius Renn)
#include "cluster.h"
#include "shape.h"
using namespace helium;
Cluster::Cluster(Shape* shape) : first_(shape) {
ASSERT(!shape->left_neighbor());
while (shape) {
shape->set_needs_clustering(false);
shape = shape->right_neighbor();
}
}
Box Cluster::CalculateBounds() const {
ASSERT(first_);
// Unify all bounding boxes of contained shapes
Box total_bounds = first_->bounds();
Shape* current = first_->right_neighbor();
while (current) {
total_bounds = MinEnclosingBox(total_bounds, current->bounds());
current = current->right_neighbor();
}
return total_bounds;
}
|