diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp index 65976ea..e4c0100 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.cpp @@ -1,7 +1,3 @@ -// -// Created by mpapa on 05.12.2017. -// - #include "AbstractionLayer_1.h" #include "../../../header.h" #include @@ -13,6 +9,7 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector* partAr const vector& ref_partArray = *partArray; analyseParts analyse(mySize.row*mySize.col); Part buf; + int PSum=0; int iterator=0; if(!analyse.getImages()) { @@ -23,7 +20,8 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector* partAr //TODO rows and cols for(int i = 0; i < mySize.row*mySize.col; i++) { - unsigned char poempel = analyse.getTabs(i);; + unsigned char poempel = analyse.getTabs(i); + PSum+=PoempelSum(poempel); //preprocess correct check for (int j=0;j<4;j++) { ref_partArray[iterator]->m_a1.m_connections=poempel; @@ -32,10 +30,12 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector* partAr } } + if(PREPRO_CHECK && PSum) + return false; + + //Zugriff auf den vector mit den einzelnen teilen: part[0].getConnenctions() entspricht pömpel von bild 0.jpg und liefert ein unsigned char, poempl Belegung wie ausgemacht - - InitialiseConstraintMatrixSize(mySize.col+2, mySize.row+2); //col row switched in this function setEdgeZero(); @@ -43,6 +43,33 @@ bool AbstractionLayer_1::PreProcessing(coor mySize, const vector* partAr return true; } +int AbstractionLayer_1::PoempelSum(uint8_t constraint) +{ + int PoempelSum=0; + if((constraint & 0b11000000)==0b01000000) + PoempelSum--; + else if((constraint & 0b11000000)==0b10000000) + PoempelSum++; + + if((constraint & 0b00110000)==0b00010000) + PoempelSum--; + else if((constraint & 0b00110000)==0b00100000) + PoempelSum++; + + if((constraint & 0b00001100)==0b00000100) + PoempelSum--; + else if((constraint & 0b00001100)==0b00001000) + PoempelSum++; + + if((constraint & 0b00000011)==0b00000001) + PoempelSum--; + else if((constraint & 0b00000011)==0b00000010) + PoempelSum++; + + return PoempelSum; + +} + //it through qualityVector and removes all that do not trigger PlaceOfPartGood bool AbstractionLayer_1::EvaluateQuality (const coor constraintCoordinate, qualityVector& qVector) { diff --git a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h index 15a49b8..42189c8 100644 --- a/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h +++ b/Source/functions/AbstractionLayers/Layer1/AbstractionLayer_1.h @@ -55,6 +55,7 @@ public: void shift(uint8_t& Part, int shifts); void setEdgeZero(); + int PoempelSum(uint8_t constraint); void CreateRandomPuzzle(); qualityVector returnInBox(vector& PuzzleBox); diff --git a/Source/functions/solve/puzzleExtension.cpp b/Source/functions/solve/puzzleExtension.cpp index 7037108..82a9c64 100644 --- a/Source/functions/solve/puzzleExtension.cpp +++ b/Source/functions/solve/puzzleExtension.cpp @@ -1,6 +1,3 @@ -// -// Created by Raphael Maenle on 21/12/2017. -// #include "../../header/solve.h" #include "../../header/input.h" diff --git a/Source/header.h b/Source/header.h index 533aff6..bcf9329 100755 --- a/Source/header.h +++ b/Source/header.h @@ -7,6 +7,7 @@ #include #include +#define PREPRO_CHECK false using namespace std; #include "header/input.h" diff --git a/Source/header/solve.h b/Source/header/solve.h index c0a48ca..08485f3 100755 --- a/Source/header/solve.h +++ b/Source/header/solve.h @@ -44,8 +44,9 @@ public: bool PreProcessing() { createBox(); createp_box(); - dp.PreProcessing({cols,rows}, nullptr); - a1.PreProcessing({cols,rows}, &p_myBox); + if(!dp.PreProcessing({cols,rows}, nullptr)) return false; + if(!a1.PreProcessing({cols,rows}, &p_myBox)) return false; + return true; }