Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+170
View File
@@ -0,0 +1,170 @@
/**
* @RDE_HEADER@
* Interface of AbstractMapObject
* $Id$
* $HeadURL$
* $Author$
*/
// Own
#include "bounding_box.h"
#include "situation_map_utils.h"
#include <situation_map_export.h>
//----------------------------------------------------------------------------
namespace SituationMap
{
BoundingBox::BoundingBox(ExtentType extentType)
{
reset();
m_extentType = extentType;
}
BoundingBox::BoundingBox(ExtentType extentType, const Point3D &center, double width, double height)
: m_extentType(extentType),
m_center(center),
m_width(width),
m_height(height)
{
}
void BoundingBox::reset()
{
m_extentType = ExtentType::Undefined;
m_center = Point3D();
m_width = m_height = std::numeric_limits<double>::lowest();
}
BoundingBox::ExtentType BoundingBox::extentType() const
{
return m_extentType;
}
void BoundingBox::setExtentType(BoundingBox::ExtentType extentType)
{
m_extentType = extentType;
}
bool BoundingBox::isValid() const
{
return
m_extentType != ExtentType::Undefined &&
!m_center.isNull() &&
m_width != std::numeric_limits<double>::lowest() &&
m_height != std::numeric_limits<double>::lowest();
}
Point3D BoundingBox::center() const
{
return m_center;
}
double BoundingBox::width() const
{
return m_width;
}
double BoundingBox::height() const
{
return m_height;
}
Point3D BoundingBox::topLeft() const
{
return Point3D(m_center.x() - width() / 2.0,
m_center.y() + height() / 2.0,
m_center.z());
}
Point3D BoundingBox::topRight() const
{
return Point3D(m_center.x() + width() / 2.0,
m_center.y() + height() / 2.0,
m_center.z());
}
Point3D BoundingBox::bottomLeft() const
{
return Point3D(m_center.x() - width() / 2.0,
m_center.y() - height() / 2.0,
m_center.z());
}
Point3D BoundingBox::bottomRight() const
{
return Point3D(m_center.x() + width() / 2.0,
m_center.y() - height() / 2.0,
m_center.z());
}
Point3D BoundingBox::centerRight() const
{
return Point3D(m_center.x() + width() / 2.0,
m_center.y(),
m_center.z());
}
PositionCont BoundingBox::positions() const
{
PositionCont posCont;
posCont.reserve(4);
posCont.append(topLeft());
posCont.append(topRight());
posCont.append(bottomRight());
posCont.append(bottomLeft());
return posCont;
}
QString BoundingBox::toString() const
{
QString asString = toString(m_extentType);
asString += QStringLiteral(" center=(%1;%2;%3), width=%4, height=%5")
.arg(m_center.x()).arg(m_center.y()).arg(m_center.z()).arg(m_width).arg(m_height);
return asString;
}
QString BoundingBox::toString(BoundingBox::ExtentType value)
{
switch (value)
{
case BoundingBox::ExtentType::Undefined:
return QLatin1String("Undefined");
case BoundingBox::ExtentType::Sim:
return QLatin1String("Sim");
case BoundingBox::ExtentType::Pixel:
return QLatin1String("Pixel");
} // switch
return QLatin1String("BoundingBox::ExtentTypeERROR");
}
//-----------------------------------------------------------------------------
// output operator:
//-----------------------------------------------------------------------------
std::ostream &operator<< (std::ostream &stream,
const BoundingBox &value)
{
stream << value.toString();
return stream;
}
std::ostream &operator<< (std::ostream &stream,
const BoundingBox::ExtentType &value)
{
stream << BoundingBox::toString(value);
return stream;
}
} // namespace SituationMap