#include "PointCollection.h"

PointCollection::PointCollection(const std::vector<Point> points)
    : mPoints(points)
{

}

void PointCollection::apply(const Transform& transform)
{
    for (auto& point : mPoints)
    {
        point.apply(transform);
    }
}

void PointCollection::addPoint(const Point& point)
{
    mPoints.push_back(point);
}

Bounds PointCollection::getBounds() const
{
	Bounds bounds{0.0, 0.0, 0.0, 0.0};

    if (mPoints.size() == 0)
    {
        return bounds;
    }

	bounds.intialize(mPoints[0].getX(), mPoints[0].getY(), mPoints[0].getZ());
	for(const auto& point : mPoints)
	{
        bounds.includePoint(point.getX(), point.getY(), point.getZ());
	}
	return bounds;
}

Point PointCollection::getEndPoint() const
{
    if (mPoints.empty())
    {
        return {};
    }
    else
    {
        return mPoints[mPoints.size() - 1];
    }
}

const std::vector<Point>& PointCollection::getPoints() const
{
    return mPoints;
}