Files
qt5-legatus-legacy/Lts/Services/AreaEffectSimulation/Utils/polygons.h
T
2026-08-13 18:33:10 +02:00

177 lines
10 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @RDE_HEADER@
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <AreaEffectSimulation/aes_db_structs.h>
#include <ProjectDataManagement/pdm_enums.hpp>
#include <QColor>
#include <QPolygonF>
#include <QRectF>
class QPointF;
namespace LtsCoordTrans
{
struct UtmCoordinate;
}
namespace SituationMap
{
class ElevationMap;
}
namespace ParticipantManagement
{
namespace Interface
{
class Dtc;
}
} // namespace ParticipantManagement
namespace NGL
{
class INGLLogger;
}
namespace AreaEffectSimulation
{
// N. Thoden, 18. jan 2024:
// I can´t find a file like aes_types.h, aes_constants.h.
// So i use polygons.h to provide following for service as well as gui:
static const int s_maxTrajectoriesPerExplosionCluster = 900;
namespace Polygons
{
using Trajectory = QPair<QPolygonF, QVector<double>>;
struct AES_COMMON_EXPORT AreaBottomLeft
{
explicit AreaBottomLeft(const QPointF &cornerBottomLeftMeter, double widthMeter, double heightMeter, double rotation_deg);
explicit AreaBottomLeft(const LtsCoordTrans::UtmCoordinate &cornerBottomLeftMeter, double widthMeter, double heightMeter, double rotation_deg);
bool isValid() const;
QPointF m_cornerBottomLeft; // meter
double m_width{0}; // x; meter,
double m_height{0}; // y; meter, aka length
double m_rotation_deg{0};
};
AES_COMMON_EXPORT QPixmap pixmapFromPolygon(const QPolygonF &poly,
const QColor &color,
const int &width,
const Qt::BrushStyle &fillPattern = Qt::BrushStyle::NoBrush,
bool isLine = false,
const QColor &bgcolor = Qt::transparent);
AES_COMMON_EXPORT QPolygonF circle(const QPointF &center, qreal radius, int steps = 72);
AES_COMMON_EXPORT QVector<double> trajectory(const double &distance, const double &height, double angle, int steps = 72);
AES_COMMON_EXPORT QPolygonF nContamination(const Database::AesNContamination &awf);
AES_COMMON_EXPORT void bcCurrentCenterPoint(const Database::AesBCContamination &cwf,
ProjectDataManagement::VolatilityType volatilityType,
const QDateTime &currentTime,
QPointF &newCenterPointGeographic,
double &distance);
AES_COMMON_EXPORT QPolygonF bcContamination(const Database::AesBCContamination &cwf,
ProjectDataManagement::VolatilityType volatilityType,
double expansionFactor,
const QDateTime &currentTime);
AES_COMMON_EXPORT QPolygonF airSupportImpact(const Database::AesAirSupportImpact &as, double chargeRadius);
AES_COMMON_EXPORT QPolygonF explosionSingle(const Database::AesExplosionSingle &ef, double chargeRadius);
AES_COMMON_EXPORT QPolygonF explosionArea(const Database::AesExplosionArea &ea);
AES_COMMON_EXPORT QVector<QPointF> explosionAreaSingleExplosions(const Database::AesExplosionArea &explosionArea);
// ExplosionCluster (3D-Wirksim)
AES_COMMON_EXPORT AreaBottomLeft explosionClusterAddTla(const AreaBottomLeft &areaBottomLeftIn, int tla);
AES_COMMON_EXPORT QPolygonF explosionClusterArea(const Database::AesExplosionCluster &explosionCluster); // geometryType-aware
AES_COMMON_EXPORT QVector<QPointF> explosionClusterSingleExplosionsGAUSS(const Database::AesExplosionCluster &explosionCluster);
AES_COMMON_EXPORT QVector<QPointF> explosionClusterSingleExplosionsGAUSS_Mtp(const Database::AesExplosionCluster &explosionCluster, double mtpRotationNorthDegree);
AES_COMMON_EXPORT LtsUtils::QPoint3D calculateFiringUnitCenterNonRecursive(const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
int unitParticipantId,
std::vector<Core::GeoPosition> &singlePositionsOut,
NGL::INGLLogger &logger);
// MTP = Mittlerer TrefferPunkt
AES_COMMON_EXPORT QVector<QPointF> explosionClusterAreaToMtps(const AreaBottomLeft &boundary,
int numberOfMTPs,
double *singleWidthOut = nullptr,
double *singleHeightOut = nullptr);
AES_COMMON_EXPORT QVector<QPointF> explosionClusterRadialToMtps(const AreaBottomLeft &boundary,
int numberOfMTPs,
const LtsCoordTrans::UtmCoordinate &firingPos,
const LtsCoordTrans::UtmCoordinate &circleCenter,
double *singleWidthOut = nullptr,
double *singleHeightOut = nullptr);
AES_COMMON_EXPORT QVector<QPointF> explosionClusterAreaToMtpsRelativeToBottomLeft(const AreaBottomLeft &boundary,
int numberOfMTPs,
double *singleWidthOut = nullptr,
double *singleHeightOut = nullptr);
AES_COMMON_EXPORT QVector<QPointF> explosionClusterRadialToMtpsRelativeToBottomLeft(const AreaBottomLeft &boundary,
int numberOfMTPs,
const LtsCoordTrans::UtmCoordinate &firingPos,
const LtsCoordTrans::UtmCoordinate &circleCenter,
double *singleWidthOut = nullptr,
double *singleHeightOut = nullptr);
AES_COMMON_EXPORT qint64 explosionClusterCalculatedFlightDuration2DMSec(const Database::AesExplosionCluster &explosionCluster, int timeOffsetMSec = 2000);
AES_COMMON_EXPORT qint64 explosionClusterEstimatedMaxFlightDuration2DMSec(qint64 calculatedFlightDuration, int calculationOffsetMSec = 10000);
// EffectCluster (3D-Wirksim/Adler)
AES_COMMON_EXPORT QPolygonF effectClusterArea(const Database::AesEffectCluster &effectCluster); // geometryType-aware
AES_COMMON_EXPORT QVector<QPointF> effectClusterSingleExplosionsGAUSS(const Database::AesEffectCluster &effectCluster);
AES_COMMON_EXPORT QVector<QPointF> effectClusterSingleExplosionsGAUSS_Mtp(const Database::AesEffectCluster &effectCluster,
const QHash<int, Database::AesEffectorData> &effectorData);
// offRouteMine
AES_COMMON_EXPORT QPolygonF offRouteMineArea(const Database::AesOffRouteMine &ea);
AES_COMMON_EXPORT QPolygonF offRouteMineAreaImpact(const Database::AesOffRouteMine &ea, int steps = 72);
AES_COMMON_EXPORT QPolygonF boobyTrapCake(const Database::AesBoobyTrap &boobyTrap, qreal radius);
AES_COMMON_EXPORT QPointF bottomLeft2CenterPoint(QPointF bottomLeft, double width, double height, double rotation);
AES_COMMON_EXPORT QPointF centerPoint2BottomLeft(QPointF centerPoint, double width, double height, double rotation);
AES_COMMON_EXPORT QPolygonF functionalArea(const Database::AesFunctionalArea &fa);
AES_COMMON_EXPORT QPolygonF technicalArea(const Database::AesTechnicalArea &ta);
AES_COMMON_EXPORT QPolygonF reconArea(const Database::AesReconArea &ra);
AES_COMMON_EXPORT QPolygonF dangerArea(const QVector<QPointF> &segments);
AES_COMMON_EXPORT std::vector<Core::GeoPosition2D> dangerAreaDefaultSegments(const QPointF &centerPos, const int &radius);
// AES_COMMON_EXPORT QPolygonF dangerArea(const shm_gefahrenbereich_rt& gb);
AES_COMMON_EXPORT QPolygonF borderline(const QVector<QPointF> &segments);
AES_COMMON_EXPORT QPolygonF gasPipe(const QVector<Database::AesGasPipeSegment> &segments, double width);
AES_COMMON_EXPORT QPolygonF gasPipeSegment(const Database::AesGasPipeSegment &start, const Database::AesGasPipeSegment &end, double width);
AES_COMMON_EXPORT QPolygonF mineArea(const QVector<Database::AesMineAreaSegment> &segments, double width, double density, bool bIsCenterLine);
AES_COMMON_EXPORT QVector<QPolygonF> mineAreaSingleSegments(const QVector<Database::AesMineAreaSegment> &segments, double width, bool bIsCenterLine);
AES_COMMON_EXPORT QPolygonF mineAreaSegment(const Database::AesMineAreaSegment &segment, double width, bool bIsCenterLine);
AES_COMMON_EXPORT QPolygonF mineCorridor(const QVector<Database::AesMineCorridorSegment> &segments, double width);
AES_COMMON_EXPORT QVector<QPolygonF> mineCorridorSingleSegments(const QVector<Database::AesMineCorridorSegment> &segments, double width);
AES_COMMON_EXPORT QPolygonF mineCorridorSegment(const Database::AesMineCorridorSegment &start, const Database::AesMineCorridorSegment &end, double width);
// keep area (instead of width/density) as also random number is needed!
AES_COMMON_EXPORT QVector<QPointF> minePositions(const Database::AesMineArea &area, const QVector<Database::AesMineAreaSegment> &segments);
AES_COMMON_EXPORT int getSequelNumber(const Database::AesExplosionArea &explosionArea);
AES_COMMON_EXPORT int getSequelNumber(int startSequelNumber, int impactCount, qint64 originalEffectDurationMs, qint64 effectDurationMs);
// calculates the minimum Area Enclosing Rectangle, bottom left is OUR Bottom Left, outangleDregrees is already counter clockwise
AES_COMMON_EXPORT QRectF getMinAreaRect(const QVector<QPointF> &points, double &outAngleDegrees);
// Hilfsfunktion für die konvexe Hülle (Monotone Chain Algorithmus)
QVector<QPointF> calculateConvexHull(const QVector<QPointF> &points);
AES_COMMON_EXPORT QVector<LtsCoordTrans::UtmCoordinate> geoVecToUtm(const std::vector<Core::GeoPosition2D> &vecPos, int utmZone = -1);
AES_COMMON_EXPORT QVector<QPointF> geoVecToUtmPointF(const std::vector<Core::GeoPosition2D> &vecPos, int utmZone = -1);
} // namespace Polygons
} // namespace AreaEffectSimulation