added destructionPower as abstractionLayer
This commit is contained in:
		@@ -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
 | 
					     * @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
 | 
					     * @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
 | 
					     * @brief   pure virtual method which sets the constraint on the given Coordinate in the m_constraintMatrix
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,44 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by mpapa on 05.12.2017.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "DestructionPower.h"
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void DestructionPower::PreProcessing(const vector<Part*>* 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;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -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 <vector>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <bitset>
 | 
				
			||||||
 | 
					#include <random>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class DestructionPower : public AbstraktionLayer_Base<DestructionPower_Properties>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    void PreProcessing(const vector<Part*>* 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
 | 
				
			||||||
@@ -0,0 +1,35 @@
 | 
				
			|||||||
 | 
					//
 | 
				
			||||||
 | 
					// Created by mpapa on 05.12.2017.
 | 
				
			||||||
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H
 | 
				
			||||||
 | 
					#define SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdint.h>
 | 
				
			||||||
 | 
					#include "DestructionPower.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class DestructionPower_Properties
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					    DestructionPower_Properties()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        for(int i=0;i<DestructionArray.size();i++)
 | 
				
			||||||
 | 
					            DestructionArray[i]=(map[i]*DESTRUCTION_INIT);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					    float DestructionArray[DESTRUCTION_COUNT];
 | 
				
			||||||
 | 
					    static map<int,float> SpeedTable = create_SpeedTable;
 | 
				
			||||||
 | 
					    friend class DestructionPower;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    static map<int,float> create_SpeedTable(){
 | 
				
			||||||
 | 
					        map<int, float> m;
 | 
				
			||||||
 | 
					        m[1] = 0.001;
 | 
				
			||||||
 | 
					        return m;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif //SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H
 | 
				
			||||||
@@ -12,7 +12,7 @@ void AbstractionLayer_1::PreProcessing(const vector<Part*>* partArray)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//it through qualityVector and removes all that do not trigger PlaceOfPartGood
 | 
					//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++)
 | 
					    for(auto it = qualityVector.begin();it!=qualityVector.end();it++)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ class AbstractionLayer_1 : public AbstraktionLayer_Base<AbstractionLayer_1_Prope
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    void PreProcessing(const vector<Part*>* partArray);//override
 | 
					    void PreProcessing(const vector<Part*>* 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 SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint);
 | 
				
			||||||
    bool RemoveConstraintOnPosition(const coor constraintCoordinate);
 | 
					    bool RemoveConstraintOnPosition(const coor constraintCoordinate);
 | 
				
			||||||
    bool PlaceOfPartGood(coor myCoor, uint8_t& myPart);
 | 
					    bool PlaceOfPartGood(coor myCoor, uint8_t& myPart);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include <stdint.h>
 | 
					#include <stdint.h>
 | 
				
			||||||
#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h"
 | 
					#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h"
 | 
				
			||||||
 | 
					#include "../functions/AbstractionLayers/DestructionPower/DestructionPower_Properties.h"
 | 
				
			||||||
class Part
 | 
					class Part
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@@ -31,6 +31,7 @@ public:
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    AbstractionLayer_1_Properties m_test1;
 | 
					    AbstractionLayer_1_Properties m_test1;
 | 
				
			||||||
 | 
					    DestructionPower_Properties m_destruction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
    int32_t m_partID;
 | 
					    int32_t m_partID;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user