7template < prototype_number NUMBER >
9public ::array_base < ::rectangle_type < NUMBER > >
13 using BASE_ARRAY = ::array_base < ::rectangle_type < NUMBER > >;
16 using UNIT_TYPE = NUMBER;
21 using BASE_ARRAY::BASE_ARRAY;
22 using BASE_ARRAY::operator =;
29 using array_base < ::rectangle_type < NUMBER > >::add;
30 void add(const ::rectangle_type < NUMBER > & rectangle);
31 void add(UNIT_TYPE left, UNIT_TYPE top, UNIT_TYPE right, UNIT_TYPE bottom);
32 void add(const ::point_type < NUMBER > & point, const ::size_type < NUMBER > & size);
33 void add(const ::size_type < NUMBER > & size);
34 void add_if_none_contains(const ::rectangle_type < NUMBER > & rectangle)
36 if (!this->any_contains(rectangle)) add(rectangle);
38 template < prototype_container CONTAINER >
39 void append_if_none_contains(
const CONTAINER & container)
41 for (
auto & r : container) add_if_none_contains(r);
43 void intersect(const ::rectangle_type < NUMBER > & rectangle);
44 bool any_contains(const ::rectangle_type < NUMBER > & rectangle)
const
46 for (
auto & r : *
this)
if (r.contains(rectangle))
return true;
50 void add_dim(UNIT_TYPE x, UNIT_TYPE y, UNIT_TYPE cx, UNIT_TYPE cy);
52 ::collection::index max_normal_intersect_area(const ::rectangle_type < NUMBER > & rectangle, const ::rectangle_type < NUMBER > & rectangleModel);
55 void get_box(::rectangle_type < NUMBER > * prectangle);
58 ::rectangle_type < NUMBER > union_rect();
60 void offset(UNIT_TYPE cx, UNIT_TYPE cy);
61 void offset(::point_type < NUMBER > point);
63 UNIT_TYPE total_area(::collection::index iStart = 0, ::collection::count c = -1)
const
68 this->predicate_each([&i](
auto& r)
86template < prototype_number NUMBER >
87inline void rectangle_array_base < NUMBER >::offset(::point_type < NUMBER > point)
89 offset(point.x, point.y);
101template < prototype_number NUMBER >
102void rectangle_array_base < NUMBER >::offset(UNIT_TYPE cx, UNIT_TYPE cy)
105 for (::i32 i = 0; i < this->get_size(); i++)
108 ::rectangle_type < NUMBER > & rectangle = this->element_at(i);
110 rectangle.left += cx;
112 rectangle.right += cx;
113 rectangle.bottom += cy;
120template < prototype_number NUMBER >
121::rectangle_type < NUMBER > rectangle_array_base < NUMBER >::union_rect()
131 ::rectangle_type < NUMBER > rectangleUnion(0, 0, 0, 0);
133 rectangleUnion = this->first();
135 for (::i32 i = 1; i < this->get_size(); i++)
138 rectangleUnion.unite(rectangleUnion, this->element_at(i));
142 return rectangleUnion;
147template < prototype_number NUMBER >
148void rectangle_array_base < NUMBER >::get_box(::rectangle_type < NUMBER > * prectangle)
152 *prectangle = union_rect();
158template < prototype_number NUMBER >
159void rectangle_array_base < NUMBER >::intersect(const ::rectangle_type < NUMBER > & rectangle)
162 for (::collection::index i = 0; i < this->get_size();)
165 this->element_at(i).intersect(this->element_at(i), rectangle);
167 if (this->element_at(i).is_null())
185template < prototype_number NUMBER >
186void rectangle_array_base < NUMBER >::add(const ::rectangle_type < NUMBER > & rectangle)
188 array_base < ::rectangle_type < NUMBER > >::add(rectangle);
192template < prototype_number NUMBER >
193void rectangle_array_base < NUMBER >::add(UNIT_TYPE left, UNIT_TYPE top, UNIT_TYPE right, UNIT_TYPE bottom)
195 add(::rectangle_type < NUMBER >(left, top, right, bottom));
199template < prototype_number NUMBER >
200void rectangle_array_base < NUMBER >::add_dim(UNIT_TYPE x, UNIT_TYPE y, UNIT_TYPE cx, UNIT_TYPE cy)
202 add(i32_rectangle_dimension(x, y, cx, cy));
206template < prototype_number NUMBER >
207void rectangle_array_base < NUMBER >::add(const ::point_type < NUMBER > & point, const ::size_type < NUMBER > & size)
209 add(::rectangle_type < NUMBER >(point, size));
213template < prototype_number NUMBER >
214void rectangle_array_base < NUMBER >::add(const ::size_type < NUMBER > & size)
216 this->add(::rectangle_type < NUMBER >(size));
220template < prototype_number NUMBER >
221::collection::index rectangle_array_base < NUMBER >::max_normal_intersect_area(const ::rectangle_type < NUMBER > & rectangleParam, const ::rectangle_type < NUMBER > & rectangleModel)
224 ::collection::index iFound = -1;
225 ::rectangle_type < NUMBER > rectangle;
226 auto iModelArea = rectangleModel.width() * rectangleModel.height();
227 decltype(iModelArea) iArea;
228 decltype(iModelArea) iAreaMax = 0;
233 for (::collection::index i = 0; i < this->get_count(); i++)
236 if (rectangle.intersect(&rectangleParam, this->element_at(i)))
239 iArea = rectangle.area() * iModelArea / this->element_at(i).area();
241 if (iArea > iAreaMax)
260CLASS_DECL_ACME i32_rectangle_array_base get_top_left_oriented_damaged_areas_by_resizing(const ::i32_rectangle & rectangleNew, const ::i32_rectangle & rectangleOld,
bool bOnlyGrowing =
true);
Definition rectangle_array.h:10