Rectangles list is STL now.

This commit is contained in:
2025-08-07 23:54:51 -04:00
parent eaee41750d
commit 905fdbf0dd
3 changed files with 23 additions and 29 deletions

View File

@ -220,16 +220,6 @@ bool Polygon::isPointWithin (int x, int y)
}
}
Region::Region()
{
rectangleList = new container::typed::List <Rectangle> (true);
}
Region::~Region()
{
delete rectangleList;
}
/**
* \brief Add a rectangle to the region and combine it with
* existing rectangles if possible.
@ -238,13 +228,11 @@ Region::~Region()
*/
void Region::addRectangle (Rectangle *rPointer)
{
container::typed::Iterator <Rectangle> it;
Rectangle *r = new Rectangle (rPointer->x, rPointer->y,
rPointer->width, rPointer->height);
for (it = rectangleList->iterator (); it.hasNext (); ) {
Rectangle *ownRect = it.getNext ();
auto r= std::make_unique< Rectangle >( rPointer->x, rPointer->y,
rPointer->width, rPointer->height );
for( auto &ownRect: rectangleList )
{
int combinedHeight =
misc::max(r->y + r->height, ownRect->y + ownRect->height) -
misc::min(r->y, ownRect->y);
@ -252,7 +240,7 @@ void Region::addRectangle (Rectangle *rPointer)
misc::max(r->x + r->width, ownRect->x + ownRect->width) -
misc::min(r->x, ownRect->x);
if (rectangleList->size() >= 16 ||
if (rectangleList.size() >= 16 ||
combinedWidth * combinedHeight <=
ownRect->width * ownRect->height + r->width * r->height) {
@ -261,11 +249,11 @@ void Region::addRectangle (Rectangle *rPointer)
r->width = combinedWidth;
r->height = combinedHeight;
rectangleList->removeRef (ownRect);
rectangleList.remove( ownRect );
}
}
rectangleList->append (r);
rectangleList.push_back( std::move( r ) );
}
Content::Type Content::maskForSelection (bool followReferences)