diff --git a/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h b/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h new file mode 100644 index 0000000..774a6ba --- /dev/null +++ b/Source/functions/AbstractionLayers/AbstraktionLayer_Base.h @@ -0,0 +1,71 @@ +#ifndef SOURCE_ABSTRAKTIONLAYER_BASE_H +#define SOURCE_ABSTRAKTIONLAYER_BASE_H + +#include +#include +#include "../../header/solve.h" +#include "../../header/input.h" + +using namespace std; + +typedef map qualityVector; + +/* + * Die Logik mit der Template-Basisklasse und den abgeleiteten Layern kam mit der Idee, dass die Layer + * nicht auf die Layer-Eigenschaften der anderen Layer zugreifen können, da die mit friend geschützt sind. + * Ansonsten könnte man auch verschiedene Objekte der Template Basisklasse erstellen + */ +/** + * @brief template base class for all different layers + * @tparam T template parameter which should be the property class of the layer + */ +template +class AbstraktionLayer_Base +{ +public: + /** + * @brief pure virtual method for the pre processing of the layer + * @param [in] partArray - References of all Parts, in which the properties of the Layer will be written + */ + virtual void PreProcessing(const vector* partArray) = 0; + + /** + * @brief pure virtual method for the quality evaluation of the layer + * @param [in] constraintCoordinate - Coordinate where the quality should evaluate for each given part + * @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; + + /** + * @brief pure virtual method which sets the constraint on the given Coordinate in the m_constraintMatrix + * This function will be called from main for all layers + * @param [in] constraintCoordinate - Coordinate where the constraint should be placed + * @param [in] constraint - constraint which should be placed + * @return Boolean if the constraint was set or a failure happened + */ + virtual bool SetConstraintOnPosition(const coor constraintCoordinate, const T constraint) = 0; + + /** + * @brief pure virtual method which remove the constraint on the given Coordinate of the m_constraintMatrix + * This function will be called from main for all layers + * @param [in] constraintCoordinate - Coordinate where the constraint should be removed + * @return Boolean if the remove was successfull or failed + */ + virtual bool RemoveConstraintOnPosition(const coor constraintCoordinate) = 0; + + /** + * @brief virtual method to initialise the m_constraintMatrix to a given size + * @param [in] collumns - Wished collumns of the m_constraintMatrix + * @param [in] rows - Wished rows of the m_constraintMatrix + */ + virtual void InitialiseConstraintMatrixSize(const int32_t collumns, const int32_t rows) + { + m_constraintMatrix = vector>(collumns, vector(rows)); + } + + vector> m_constraintMatrix; //!<-- Matrix where the constraints of the layer will be saved +}; + + +#endif //SOURCE_ABSTRAKTIONLAYER_BASE_H diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp new file mode 100644 index 0000000..a1cf9a9 --- /dev/null +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp @@ -0,0 +1,91 @@ +// +// Created by mpapa on 05.12.2017. +// + +#include "AbstractionLayer_1.h" +#include + +void AbstractionLayer_1::PreProcessing(const vector* partArray) +{ + InitialiseConstraintMatrixSize(32+2, 28+2); + setEdgeZero(); +} + +bool AbstractionLayer_1::EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector) +{ + +} + +bool AbstractionLayer_1::SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint) +{ + +} + +bool AbstractionLayer_1::RemoveConstraintOnPosition(const coor constraintCoordinate) +{ + +} + +bool AbstractionLayer_1::CreateRandomPuzzle() +{ + for(int col=1;col +#include +#include + +class AbstractionLayer_1 : public AbstraktionLayer_Base +{ +public: + void PreProcessing(const vector* partArray); + bool EvalueteQuality (const coor constraintCoordinate, qualityVector& qVector); + bool SetConstraintOnPosition(const coor constraintCoordinate, const AbstractionLayer_1_Properties constraint); + bool RemoveConstraintOnPosition(const coor constraintCoordinate); + + void setEdgeZero(); + + + bool CreateRandomPuzzle(); + +private: +}; + +#endif //SOURCE_ABSTRACTIONLAYER_1_H diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h new file mode 100644 index 0000000..86c3b77 --- /dev/null +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h @@ -0,0 +1,21 @@ +// +// Created by mpapa on 05.12.2017. +// + +#ifndef SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H +#define SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H + +#include +#include "AbstractionLayer_1.h" + +class AbstractionLayer_1_Properties +{ +public: + AbstractionLayer_1_Properties() : m_connections(0b11111111) {} +private: + uint8_t m_connections; + friend class AbstractionLayer_1; +}; + + +#endif //SOURCE_ABSTRACTIONLAYER_1_PROPERTIES_H diff --git a/Source/functions/solve/structure.cpp b/Source/functions/solve/structure.cpp index bddc72f..dd10799 100755 --- a/Source/functions/solve/structure.cpp +++ b/Source/functions/solve/structure.cpp @@ -83,10 +83,10 @@ void solve(vector& log, vector& p_Box, Puzzle& puzzleMat break; } - capLogElements(log); - calculateWorth(log); - calculateTrueDestructionPower(log,puzzleMat); - calculateNewCombinedProbablility(log); + //capLogElements(log); + //calculateWorth(log); + //calculateTrueDestructionPower(log,puzzleMat); + //calculateNewCombinedProbablility(log); } diff --git a/Source/header/input.h b/Source/header/input.h index 7a16bd8..87ca98a 100755 --- a/Source/header/input.h +++ b/Source/header/input.h @@ -1,22 +1,40 @@ +#ifndef SOURCE_PART_H +#define SOURCE_PART_H + #include +#include "../functions/AbstractionLayers/Layer1/AbstractionLayer_1_Properties.h" class Part { public: - double r; - double g; - double b; - - Part(): connections(0){} + Part() : m_partID(0) {} ~Part() {} - uint8_t getConnections() const - {return connections;} - void setConnections(uint8_t newconnections) - {connections = newconnections;} + int32_t GetPartID () const + { + return m_partID; + } + + void SetPartID(const int32_t partID) + { + m_partID = partID; + } + + uint8_t GetNumOfRotations () const + { + return m_numOfRotations; + } + + void SetNumOfRotations(const uint8_t numOfRotations) + { + m_numOfRotations = numOfRotations; + } + + AbstractionLayer_1_Properties m_test1; private: - uint8_t connections; + int32_t m_partID; + uint8_t m_numOfRotations; +}; - -}; \ No newline at end of file +#endif //SOURCE_PART_H \ No newline at end of file