From 058a96ab08ccd60a1181108e542c60a784d656da Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Wed, 20 Dec 2017 22:05:04 +0100 Subject: [PATCH] added destructionPower as abstractionLayer --- .../AbstractionLayers/AbstraktionLayer_Base.h | 2 +- .../DestructionPower/DestructionPower.cpp | 44 +++++++++++++++++++ .../DestructionPower/DestructionPower.h | 31 +++++++++++++ .../DestructionPower_Properties.h | 35 +++++++++++++++ .../Layer1/AbstractionLayer_1.cpp | 2 +- .../Layer1/AbstractionLayer_1.h | 2 +- Source/header/input.h | 3 +- 7 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 Source/functions/AbstractionLayers/DestructionPower/DestructionPower.cpp create mode 100644 Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h create mode 100644 Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h diff --git a/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h b/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h index 774a6ba..07dab2a 100644 --- a/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h +++ b/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h @@ -35,7 +35,7 @@ public: * @param [in/out] qualityVector - References of all parts with the quality of their quality to fit in the given coordinate * @return Boolean if the quality was calculated right or not */ - virtual bool EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector) = 0; + virtual bool EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector) = 0; /** * @brief pure virtual method which sets the constraint on the given Coordinate in the m_constraintMatrix diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.cpp b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.cpp new file mode 100644 index 0000000..ffc9894 --- /dev/null +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.cpp @@ -0,0 +1,44 @@ +// +// Created by mpapa on 05.12.2017. +// + +#include "DestructionPower.h" +#include + +void DestructionPower::PreProcessing(const vector* partArray) +{ + InitialiseConstraintMatrixSize(32,28); +} + +//it through qualityVector and removes all that do not trigger PlaceOfPartGood +bool DestructionPower::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector) +{ +} + +bool DestructionPower::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint) +{ +} + +bool DestructionPower::RemoveConstraintOnPosition(const coor constraintCoordinate) +{ +} + +//gets destruction power from left and from top if possibe and normalizes +void DestructionPower::DestructionOfSurrounding(const coor constraintCoordinate) { + float newDestructionArray[DESTRUCTION_COUNT]; + for (int i = 0; i < DESTRUCTION_COUNT; ++i) { + int divisor=0; + if(constraintCoordinate.row > 0) + { + divisor++; + newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col][constraintCoordinate.row-1].m_destruction.DestructionArray[i]; + } + if(constraintCoordinate.col > 0) + { + divisor++; + newDestructionArray[i] += m_constraintMatrix[constraintCoordinate.col-1][constraintCoordinate.row].m_destruction.DestructionArray[i]; + } + if(divisor) + newDestructionArray[i] /=divisor; + } +} diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h new file mode 100644 index 0000000..16b2992 --- /dev/null +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower.h @@ -0,0 +1,31 @@ +// +// Created by mpapa on 05.12.2017. +// + +#ifndef SOURCE_ABSTRACTIONLAYER_1_H +#define SOURCE_ABSTRACTIONLAYER_1_H + +#define DESTRUCTION_INIT 0.5 +#define DESTRUCTION_COUNT 1 + +#include "../AbstraktionLayer_Base.h" +#include "DestructionPower_Properties.h" +#include +#include +#include +#include + +class DestructionPower : public AbstraktionLayer_Base +{ +public: + void PreProcessing(const vector* partArray);//override + bool EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector); + bool SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint); + bool RemoveConstraintOnPosition(const coor constraintCoordinate); + + void DestructionOfSurrounding(const coor constraintCoordinate); + +private: +}; + +#endif //SOURCE_ABSTRACTIONLAYER_1_H diff --git a/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h new file mode 100644 index 0000000..131f938 --- /dev/null +++ b/Source/functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h @@ -0,0 +1,35 @@ +// +// Created by mpapa on 05.12.2017. +// + +#ifndef SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H +#define SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H + + + +#include +#include "DestructionPower.h" + +class DestructionPower_Properties +{ +public: + DestructionPower_Properties() + { + for(int i=0;i SpeedTable = create_SpeedTable; + friend class DestructionPower; + + static map create_SpeedTable(){ + map m; + m[1] = 0.001; + return m; + } +}; + + +#endif //SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp index f7b766f..8f7495c 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp @@ -12,7 +12,7 @@ void AbstractionLayer_1::PreProcessing(const vector* partArray) } //it through qualityVector and removes all that do not trigger PlaceOfPartGood -bool AbstractionLayer_1::EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector) +bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector) { for(auto it = qualityVector.begin();it!=qualityVector.end();it++) { diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h index 20efe63..dc04ead 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h @@ -16,7 +16,7 @@ class AbstractionLayer_1 : public AbstraktionLayer_Base* partArray);//override - bool EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector); + bool EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector); bool SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint); bool RemoveConstraintOnPosition(const coor constraintCoordinate); bool PlaceOfPartGood(coor myCoor, uint8_t& myPart); diff --git a/Source/header/input.h b/Source/header/input.h index 87ca98a..3db8cc7 100755 --- a/Source/header/input.h +++ b/Source/header/input.h @@ -3,7 +3,7 @@ #include #include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h" - +#include "../functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h" class Part { public: @@ -31,6 +31,7 @@ public: } AbstractionLayer_1_Properties m_test1; + DestructionPower_Properties m_destruction; private: int32_t m_partID;