From 9863c8b9e8c89a5af5b7f65b1ebc92ec56c110d4 Mon Sep 17 00:00:00 2001 From: Raphael Maenle <17550607+g-spacewhale@users.noreply.github.com> Date: Sat, 20 Jan 2018 11:58:32 +0100 Subject: [PATCH] created Preprocessing check if true deactivate in header.h --- .../Layer1/AbstractionLayer_1.cpp | 41 +++++++++++++++---- .../Layer1/AbstractionLayer_1.h | 1 + Source/functions/solve/puzzleExtension.cpp | 3 -- Source/header.h | 1 + Source/header/solve.h | 5 ++- 5 files changed, 39 insertions(+), 12 deletions(-) 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; }