From aeb5cbfe34e90844392ceb4025ba250129ffe2a2 Mon Sep 17 00:00:00 2001 From: gaeltp3 Date: Fri, 20 Dec 2013 21:35:45 +0100 Subject: [PATCH 1/5] Erstellung einen neuen Vector. --- Hazard/Hazard/KV.cpp | 136 +++++----------------- Hazard/Hazard/KV.h | 6 +- Hazard/Hazard/PrimImplikant.h | 3 + Hazard/Hazard/PrimImplikantCollection.cpp | 125 ++++++++++++++++++++ Hazard/Hazard/PrimImplikantCollection.h | 7 ++ 5 files changed, 164 insertions(+), 113 deletions(-) diff --git a/Hazard/Hazard/KV.cpp b/Hazard/Hazard/KV.cpp index 709f2cd..6a044d9 100644 --- a/Hazard/Hazard/KV.cpp +++ b/Hazard/Hazard/KV.cpp @@ -167,7 +167,7 @@ void KV::PrintPrimImplikanten() { PrimImplikant* currentPI = this->globalPic->at(i); - uint overflow = 0; // at which sides the PrimImplikant overlaps + /*uint overflow = 0; // at which sides the PrimImplikant overlaps for (uint j = 0; j < currentPI->implikanten.size(); j++) { uint currentI = currentPI->implikanten[j]; @@ -200,11 +200,32 @@ void KV::PrintPrimImplikanten() case 0x03: // overflows from left to right break; default: + + */ + + // ab hier mache ich später weiter. Ich habe wieder Kopfschmerzen!!! + + + uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; // find coordinates for Rechteck - for (uint j = 0; j < currentPI->implikanten.size(); j++) + for (uint j = 0; j < currentPI->PI_groupCollection.size(); j++) { - uint currentI = currentPI->implikanten[j]; - uint w = (currentI & ((0x1 << (this->numVarX)) - 1)); // get all bits that make X (=w) + vector* kuller = currentPI->PI_groupCollection[j]; + for (uint j = 0; j < kuller->size(); j++) + { + uint x1 = (*kuller)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord + uint x2 = x1 + this->edgeLength; // Lower coord + uint y1 = h * (this->edgeLength + 1) + this->VarX_Length; // Left coord + uint y2 = y1 + this->edgeLength; // Right coo + + X1 = min(X1, x1); + X2 = max(X2, x2); + Y1 = min(Y1, y1); + Y2 = max(Y2, y2); + } + + + uint w = currentPI->PI_groupCollection // get all bits that make X (=w) w ^= w / 2; uint h = (currentI >> this->numVarX); // get all bits that make Y (=h) h ^= h / 2; @@ -212,7 +233,7 @@ void KV::PrintPrimImplikanten() uint x1 = w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord uint x2 = x1 + this->edgeLength; // Lower coord uint y1 = h * (this->edgeLength + 1) + this->VarX_Length; // Left coord - uint y2 = y1 + this->edgeLength; // Right coord + uint y2 = y1 + this->edgeLength; // Right coo X1 = min(X1, x1); X2 = max(X2, x2); @@ -242,114 +263,9 @@ void KV::PrintPrimImplikanten() //------------------------------------------------------------------ -bool KV:: Anwesenheit(Implikant_localisation* &I, vector &group) -{ - - for (vector::iterator it = group.begin(); it < group.end(); it++) - { - if ((*it)->i == (I->i)) - { - return true; - } - - } - return false; -} - -vector KV::setgroupCollection(vector &group) -{ - - vector hilfVec1; - vector::iterator it1, it2; - int schalter = 1; - - // Muss noch eine Ãœberprufung der mitteLinie w der KV diagramm gemacht werden - - for (it1 = group.begin(); it1 < group.end() - 1; it1++) - { - if (schalter) - { - - hilfVec1.push_back(*it1); - schalter = 0; - } - - for (it2 = it1 + 1; it2 < group.end(); it2++) - { - - if ((((*it1)->w) == ((*it2)->w) && abs((int)((*it1)->h - (*it2)->h)) == 1) || ((*it1)->h) == ((*it2)->h) && abs((int)((*it1)->w - (*it2)->w)) == 1) - { - - if (Anwesenheit((*it2), hilfVec1) == 0){ - - hilfVec1.push_back(*it2); - break; - } - - break; - } - else - { - // Muss hier weiter programmiert. - } - - } - - this->PI_groupCollection.push_back(&hilfVec1); - } -} -void KV::PrintPrimImplikanten() -{ - srand(time(NULL) + rand()); - - for (uint i = 0; i < this->globalPic->size(); i++) - { - PrimImplikant* currentPI = this->globalPic->at(i); - vector::iterator it1; - vector groupA; // Jede I_vector wird in einem oder in Zwei vectoren - vector groupB; // zuerst gespaltet. - int Linie_mitte = 0; - - for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end() - 1; it1++) - { - if ((((*it1)->h) = (this->numVarY / 2) - 1) || (((*it1)->h) = (this->numVarY / 2))) - { - Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist. - } - } - for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end() - 1; it1++) - { - - if (((*it1)->h < (this->numVarY / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA - { // gespeichert. - - groupA.push_back(*it1); - - - } - else if (Linie_mitte) - { - groupA.push_back(*it1); - - } - else { groupB.push_back(*it1); } - - } - - if (groupA.size() != 0) - { - setgroupCollection(groupA); - } - if (groupB.size() != 0) - { - setgroupCollection(groupB); - } - - } -} diff --git a/Hazard/Hazard/KV.h b/Hazard/Hazard/KV.h index 17c3de4..f217dcf 100644 --- a/Hazard/Hazard/KV.h +++ b/Hazard/Hazard/KV.h @@ -42,7 +42,7 @@ private: PrimImplikantCollection* globalPic; CellCollection* allCells; vector* variables; - vector*> PI_groupCollection; + uint offsetX; // Der freie Platz nach links in Pixeln uint offsetY; // Der freie Platz nach rechts in Pixeln @@ -66,8 +66,8 @@ private: void PrintCellValues(); // Erstellt die Werte der jeweiligen Zellen void PrintPrimImplikanten(); // Erstellt die einzelnen Primimplikanten void PrintString_Var(); // Erstellt den horizontalen TextVariable & vertikalen Textvariable - vector setgroupCollection(vector &group); - bool Anwesenheit(Implikant_localisation* &I, vector &group); + + void Clear(); void Line(uint x1, uint y1, uint x2, uint y2, int color); // Zeichnet eine Linie mit Offset diff --git a/Hazard/Hazard/PrimImplikant.h b/Hazard/Hazard/PrimImplikant.h index 079adb1..868c811 100644 --- a/Hazard/Hazard/PrimImplikant.h +++ b/Hazard/Hazard/PrimImplikant.h @@ -45,7 +45,10 @@ public: bool PrimImplikant::valueAt(uint position); void PrimImplikant::parser(string input); + + vector implikanten; vector I_Vector; + vector*> PI_groupCollection; }; #endif \ No newline at end of file diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index f591bde..ec2c2a8 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -15,18 +15,21 @@ void PrimImplikantCollection::add(string input) PrimImplikant* PI = new PrimImplikant(input); PI->id = this->size(); + setgroupCollection1(PI); this->add(PI); } void PrimImplikantCollection::add(uint input) { PrimImplikant* PI = new PrimImplikant(input); PI->id = this->size(); + setgroupCollection1(PI); this->add(PI); } void PrimImplikantCollection::add(uint input1, uint input2) { PrimImplikant* PI = new PrimImplikant(input1, input2); PI->id = this->size(); + setgroupCollection1(PI); this->add(PI); } @@ -55,6 +58,128 @@ bool PrimImplikantCollection::contains(PrimImplikant* foreign) return false; } +bool PrimImplikantCollection::Anwesenheit(Implikant_localisation* &I, vector &group) +{ + + for (vector::iterator it = group.begin(); it < group.end(); it++) + { + if ((*it)->i == (I->i)) + { + return true; + } + + } + return false; +} + +void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) +{ + vector::iterator it1; + vector groupA; // Jede I_vector wird in einem oder in Zwei vectoren + vector groupB; // zuerst gespaltet. + + static int Linie_mitte; + uint numVarY = (uint)ceil(dimension / 2.0f); + + + + for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) + { + if ((((*it1)->h) = (numVarY / 2) - 1) || (((*it1)->h) = (numVarY / 2))) + { + Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist. + // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind + //schalter = 1; + } + continue; + } + + if (Linie_mitte) // Wenn wahr ist. ES geht um Linie_mitte_Y + { + for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) + { + groupA.push_back(*it1); + } + + currentPI->PI_groupCollection.push_back(&groupA); + Linie_mitte = 0; + } + else + { + for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) + { + + if (((*it1)->h < (numVarY / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA + { // gespeichert. + + groupA.push_back(*it1); + + + } + + else { groupB.push_back(*it1); } + + } + + setgroupCollection2(currentPI,groupA); + setgroupCollection2(currentPI,groupB); + } + +} + + +void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vector&group) +{ + + vector hilfVec1, hilfVec2; + vector::iterator it1; + uint numVarX = (uint)floor(dimension / 2.0f); + static int Linie_mitte; // Zustand 0--> wird h überprüft im Vector + // Zustand 1-->wird w überprüft im Vector. + // Ohne Zuweisung hat schalter am Anfang den Wert 0 + + + + for (it1 = group.begin(); it1 < group.end(); it1++) + { + if ((((*it1)->h) = (numVarX / 2) - 1) || (((*it1)->h) = (numVarX / 2))) + { + Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist. + // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind + //schalter = 1; + } + continue; + } + + if (Linie_mitte) // Wenn wahr ist.--> Linie_mitte_X + { + + currentPI->PI_groupCollection.push_back(&group); + Linie_mitte = 0; + } + else + { + for (it1 = group.begin(); it1 < group.end(); it1++) + { + + if (((*it1)->w < (numVarX / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA + { // gespeichert. + + hilfVec1.push_back(*it1); + + + } + + else { hilfVec2.push_back(*it1); } + + } + + currentPI->PI_groupCollection.push_back(&hilfVec1); + currentPI->PI_groupCollection.push_back(&hilfVec2); + } +} + + uint PrimImplikantCollection::size() { return this->PIVector.size(); diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index 63c8ca7..da71120 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -2,8 +2,12 @@ #include #include #include "PrimImplikant.h" +#include "Implikant_localisation.h" using namespace std; +extern uint dimension; +extern uint numElements; +extern bool KNF; #ifndef PRIMIMPLIKANTCOLLEC #define PRIMIMPLIKANTCOLLEC @@ -18,6 +22,9 @@ public: bool valueAt(uint position); PrimImplikantCollection primImplikantenAt(uint position); bool contains(PrimImplikant* foreign); + void setgroupCollection1(PrimImplikant* ¤tPI); + void setgroupCollection2(PrimImplikant* ¤tPI,vector&group); + bool Anwesenheit(Implikant_localisation* &I, vector &group); void Dispose(); From 10269bcd658f96c8cb4ff43c381b2be4db6e30c3 Mon Sep 17 00:00:00 2001 From: gaeltp3 Date: Mon, 23 Dec 2013 02:51:37 +0100 Subject: [PATCH 2/5] Print Implikant algoritmus geschrieben aber. funktionniert. Keine Fehler bei der Compilierung aber die Kuller auftreten nicht --- Hazard/Hazard/KV.cpp | 104 ++++++++++++++++------ Hazard/Hazard/PrimImplikant.h | 1 + Hazard/Hazard/PrimImplikantCollection.cpp | 54 +++++++---- Hazard/Hazard/PrimImplikantCollection.h | 2 +- 4 files changed, 114 insertions(+), 47 deletions(-) diff --git a/Hazard/Hazard/KV.cpp b/Hazard/Hazard/KV.cpp index 6a044d9..44e785d 100644 --- a/Hazard/Hazard/KV.cpp +++ b/Hazard/Hazard/KV.cpp @@ -9,6 +9,8 @@ extern uint dimension; extern uint numElements; extern bool KNF; +using namespace std; + void KV::Clear() { @@ -162,7 +164,7 @@ void KV::PrintCellValues() // Erstellt die Werte der jeweiligen Zellen: ▯▯ void KV::PrintPrimImplikanten() { - srand(time(NULL)+rand()); + srand(time(NULL) + rand()); for (uint i = 0; i < this->globalPic->size(); i++) { PrimImplikant* currentPI = this->globalPic->at(i); @@ -170,35 +172,35 @@ void KV::PrintPrimImplikanten() /*uint overflow = 0; // at which sides the PrimImplikant overlaps for (uint j = 0; j < currentPI->implikanten.size(); j++) { - uint currentI = currentPI->implikanten[j]; - uint w = (currentI & ((0x1 << (this->numVarX)) - 1)); // get all bits that make X (=w) - w ^= w / 2; - uint h = (currentI >> this->numVarX); // get all bits that make Y (=h) - h ^= h / 2; + uint currentI = currentPI->implikanten[j]; + uint w = (currentI & ((0x1 << (this->numVarX)) - 1)); // get all bits that make X (=w) + w ^= w / 2; + uint h = (currentI >> this->numVarX); // get all bits that make Y (=h) + h ^= h / 2; - if (w == 0) - overflow |= 0x1; // left side - else if (w == this->numFieldX - 1) - overflow |= 0x2; // right side - else - overflow |= 0x4; + if (w == 0) + overflow |= 0x1; // left side + else if (w == this->numFieldX - 1) + overflow |= 0x2; // right side + else + overflow |= 0x4; - if (h == 0) - overflow |= 0x10; // upper side - else if (h == this->numFieldY - 1) - overflow |= 0x20; // lower side - else - overflow |= 0x40; + if (h == 0) + overflow |= 0x10; // upper side + else if (h == this->numFieldY - 1) + overflow |= 0x20; // lower side + else + overflow |= 0x40; } switch (overflow) { case 0x33: // all 4 edges - break; + break; case 0x30: // overflows from top to bottom - break; + break; case 0x03: // overflows from left to right - break; + break; default: */ @@ -207,24 +209,70 @@ void KV::PrintPrimImplikanten() - uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; // find coordinates for Rechteck - for (uint j = 0; j < currentPI->PI_groupCollection.size(); j++) + // uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; // find coordinates for Rechteck + + + for (uint j = 0; j < currentPI->PI_groupCollection.size(); j++) + { + + + vector* kullers = currentPI->PI_groupCollection[j]; + + + for (uint k = 0; k < kullers->size(); k++) { - vector* kuller = currentPI->PI_groupCollection[j]; - for (uint j = 0; j < kuller->size(); j++) + + for (vector::iterator it = kullers->begin(); it < kullers->end(); it++) { - uint x1 = (*kuller)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord + uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; + + uint x1 = (*it)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord uint x2 = x1 + this->edgeLength; // Lower coord - uint y1 = h * (this->edgeLength + 1) + this->VarX_Length; // Left coord + uint y1 = (*it)->h * (this->edgeLength + 1) + this->VarX_Length; // Left coord uint y2 = y1 + this->edgeLength; // Right coo X1 = min(X1, x1); X2 = max(X2, x2); Y1 = min(Y1, y1); Y2 = max(Y2, y2); + + if (currentPI->name.find("|") != string::npos) + { + this->Rechteck(X1 + 12, Y1 + 9, X2 - 12, Y2 - 9, RED, TRANS); + } + else + { + uint random = rand() % 10; + X1 += random; + X2 -= random; + Y1 += random; + Y2 -= random; + if (currentPI->implikanten.size() == 1) + this->Rechteck(X1, Y1, X2, Y2, GREEN, TRANS); + else + this->Rechteck(X1, Y1, X2, Y2, BLUE, TRANS); + } + + + + } + + + + + } + + } + } +} + + +/* + + uint w = currentPI->PI_groupCollection // get all bits that make X (=w) w ^= w / 2; uint h = (currentI >> this->numVarX); // get all bits that make Y (=h) @@ -264,7 +312,7 @@ void KV::PrintPrimImplikanten() //------------------------------------------------------------------ - +*/ diff --git a/Hazard/Hazard/PrimImplikant.h b/Hazard/Hazard/PrimImplikant.h index 868c811..50563e8 100644 --- a/Hazard/Hazard/PrimImplikant.h +++ b/Hazard/Hazard/PrimImplikant.h @@ -44,6 +44,7 @@ public: bool PrimImplikant::valueAt(uint position); void PrimImplikant::parser(string input); + diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index ec2c2a8..ec35546 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -15,21 +15,21 @@ void PrimImplikantCollection::add(string input) PrimImplikant* PI = new PrimImplikant(input); PI->id = this->size(); - setgroupCollection1(PI); + this->setgroupCollection1(PI); this->add(PI); } void PrimImplikantCollection::add(uint input) { PrimImplikant* PI = new PrimImplikant(input); PI->id = this->size(); - setgroupCollection1(PI); + this->setgroupCollection1(PI); this->add(PI); } void PrimImplikantCollection::add(uint input1, uint input2) { PrimImplikant* PI = new PrimImplikant(input1, input2); PI->id = this->size(); - setgroupCollection1(PI); + this->setgroupCollection1(PI); this->add(PI); } @@ -80,12 +80,14 @@ void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) static int Linie_mitte; uint numVarY = (uint)ceil(dimension / 2.0f); + + //PrimImplikant* currentPI = currentPI; // Zuweisung diese Adresse an einem ZeigerObjekt denselben Namen. for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) { - if ((((*it1)->h) = (numVarY / 2) - 1) || (((*it1)->h) = (numVarY / 2))) + if ((((*it1)->h) == (numVarY / 2) - 1) || (((*it1)->h) == (numVarY / 2))) { Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist. // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind @@ -121,32 +123,40 @@ void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) } - setgroupCollection2(currentPI,groupA); - setgroupCollection2(currentPI,groupB); + if (groupA.size()) + { + setgroupCollection2(currentPI, groupA); + } + + if (groupB.size()) + { + setgroupCollection2(currentPI, groupB); + } + } } -void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vector&group) +void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vector &group) { vector hilfVec1, hilfVec2; vector::iterator it1; uint numVarX = (uint)floor(dimension / 2.0f); - static int Linie_mitte; // Zustand 0--> wird h überprüft im Vector - // Zustand 1-->wird w überprüft im Vector. - // Ohne Zuweisung hat schalter am Anfang den Wert 0 + static int Linie_mitte; // Zustand 0--> wird w überprüft im Vector + // Zustand 1 oder >1 -->wird w überprüft im Vector. + for (it1 = group.begin(); it1 < group.end(); it1++) { - if ((((*it1)->h) = (numVarX / 2) - 1) || (((*it1)->h) = (numVarX / 2))) + if ((((*it1)->h) == (numVarX / 2) - 1) || (((*it1)->h) == (numVarX / 2))) { - Linie_mitte++; // test zu wissen ob die MitteLinie h der KV diagramm erreicht ist. - // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind - //schalter = 1; + Linie_mitte++; // test zu wissen ob die MitteLinie w der KV diagramm erreicht ist. + // Test zu wissen , wieviele Implikanten in Mitte_tiefe sind + } continue; } @@ -162,8 +172,8 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vec for (it1 = group.begin(); it1 < group.end(); it1++) { - if (((*it1)->w < (numVarX / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA - { // gespeichert. + if (((*it1)->w < (numVarX / 2) - 1)) // die Implikanten, deren w <= numVarX/2 -1 sind im groupA + { // gespeichert. wenn w größer, dann wird im hilfVec2 gespeichert hilfVec1.push_back(*it1); @@ -173,9 +183,17 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vec else { hilfVec2.push_back(*it1); } } + + if (hilfVec1.size()) + { + currentPI->PI_groupCollection.push_back(&hilfVec1); + } + + if (hilfVec2.size()) + { + currentPI->PI_groupCollection.push_back(&hilfVec2); + } - currentPI->PI_groupCollection.push_back(&hilfVec1); - currentPI->PI_groupCollection.push_back(&hilfVec2); } } diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index da71120..749f0c2 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -23,7 +23,7 @@ public: PrimImplikantCollection primImplikantenAt(uint position); bool contains(PrimImplikant* foreign); void setgroupCollection1(PrimImplikant* ¤tPI); - void setgroupCollection2(PrimImplikant* ¤tPI,vector&group); + void setgroupCollection2(PrimImplikant* ¤tPI,vector &group); bool Anwesenheit(Implikant_localisation* &I, vector &group); void Dispose(); From 299af0a622dd58f0f520c6f3467235fa951591f2 Mon Sep 17 00:00:00 2001 From: gaeltp3 Date: Mon, 23 Dec 2013 11:40:27 +0100 Subject: [PATCH 3/5] hoehste & niedrige Koordinanten --- Hazard/Hazard/KV.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Hazard/Hazard/KV.cpp b/Hazard/Hazard/KV.cpp index 44e785d..5f3b0c6 100644 --- a/Hazard/Hazard/KV.cpp +++ b/Hazard/Hazard/KV.cpp @@ -217,14 +217,15 @@ void KV::PrintPrimImplikanten() vector* kullers = currentPI->PI_groupCollection[j]; - + uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; for (uint k = 0; k < kullers->size(); k++) { + for (vector::iterator it = kullers->begin(); it < kullers->end(); it++) { - uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; + uint x1 = (*it)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord uint x2 = x1 + this->edgeLength; // Lower coord From 06a33deceb20bb8454c2d426c1945e5008981522 Mon Sep 17 00:00:00 2001 From: gaeltp3 Date: Mon, 23 Dec 2013 14:03:44 +0100 Subject: [PATCH 4/5] direkte Zugriff zu kullers --- Hazard/Hazard/KV.cpp | 60 +++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 34 deletions(-) diff --git a/Hazard/Hazard/KV.cpp b/Hazard/Hazard/KV.cpp index 5f3b0c6..26158e8 100644 --- a/Hazard/Hazard/KV.cpp +++ b/Hazard/Hazard/KV.cpp @@ -215,54 +215,46 @@ void KV::PrintPrimImplikanten() for (uint j = 0; j < currentPI->PI_groupCollection.size(); j++) { - vector* kullers = currentPI->PI_groupCollection[j]; uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; - for (uint k = 0; k < kullers->size(); k++) - { - for (vector::iterator it = kullers->begin(); it < kullers->end(); it++) - { + for (vector::iterator it = kullers->begin(); it < kullers->end(); it++) + { - uint x1 = (*it)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord - uint x2 = x1 + this->edgeLength; // Lower coord - uint y1 = (*it)->h * (this->edgeLength + 1) + this->VarX_Length; // Left coord - uint y2 = y1 + this->edgeLength; // Right coo - - X1 = min(X1, x1); - X2 = max(X2, x2); - Y1 = min(Y1, y1); - Y2 = max(Y2, y2); - - if (currentPI->name.find("|") != string::npos) - { - this->Rechteck(X1 + 12, Y1 + 9, X2 - 12, Y2 - 9, RED, TRANS); - } - else - { - uint random = rand() % 10; - X1 += random; - X2 -= random; - Y1 += random; - Y2 -= random; - if (currentPI->implikanten.size() == 1) - this->Rechteck(X1, Y1, X2, Y2, GREEN, TRANS); - else - this->Rechteck(X1, Y1, X2, Y2, BLUE, TRANS); - } - - + uint x1 = (*it)->w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord + uint x2 = x1 + this->edgeLength; // Lower coord + uint y1 = (*it)->h * (this->edgeLength + 1) + this->VarX_Length; // Left coord + uint y2 = y1 + this->edgeLength; // Right coo + X1 = min(X1, x1); + X2 = max(X2, x2); + Y1 = min(Y1, y1); + Y2 = max(Y2, y2); + if (currentPI->name.find("|") != string::npos) + { + this->Rechteck(X1 + 12, Y1 + 9, X2 - 12, Y2 - 9, RED, TRANS); + } + else + { + uint random = rand() % 10; + X1 += random; + X2 -= random; + Y1 += random; + Y2 -= random; + if (currentPI->implikanten.size() == 1) + this->Rechteck(X1, Y1, X2, Y2, GREEN, TRANS); + else + this->Rechteck(X1, Y1, X2, Y2, BLUE, TRANS); } - } + } } From 172b262e2bc48e6fe1d55599e4e59fcdb9ed05e4 Mon Sep 17 00:00:00 2001 From: gaeltp3 Date: Mon, 23 Dec 2013 19:33:41 +0100 Subject: [PATCH 5/5] Entfernung der Funktion Anwesendheit. --- Hazard/Hazard/KV.cpp | 36 +++++++++++------------ Hazard/Hazard/PrimImplikantCollection.cpp | 33 +++++++-------------- Hazard/Hazard/PrimImplikantCollection.h | 2 +- 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/Hazard/Hazard/KV.cpp b/Hazard/Hazard/KV.cpp index 26158e8..4e2066d 100644 --- a/Hazard/Hazard/KV.cpp +++ b/Hazard/Hazard/KV.cpp @@ -218,7 +218,6 @@ void KV::PrintPrimImplikanten() vector* kullers = currentPI->PI_groupCollection[j]; uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; - for (vector::iterator it = kullers->begin(); it < kullers->end(); it++) { @@ -234,25 +233,24 @@ void KV::PrintPrimImplikanten() Y1 = min(Y1, y1); Y2 = max(Y2, y2); - if (currentPI->name.find("|") != string::npos) - { - this->Rechteck(X1 + 12, Y1 + 9, X2 - 12, Y2 - 9, RED, TRANS); - } + + + } + if (currentPI->name.find("|") != string::npos) + { + this->Rechteck(X1 + 12, Y1 + 9, X2 - 12, Y2 - 9, RED, TRANS); + } + else + { + uint random = rand() % 10; + X1 += random; + X2 -= random; + Y1 += random; + Y2 -= random; + if (currentPI->implikanten.size() == 1) + this->Rechteck(X1, Y1, X2, Y2, GREEN, TRANS); else - { - uint random = rand() % 10; - X1 += random; - X2 -= random; - Y1 += random; - Y2 -= random; - if (currentPI->implikanten.size() == 1) - this->Rechteck(X1, Y1, X2, Y2, GREEN, TRANS); - else - this->Rechteck(X1, Y1, X2, Y2, BLUE, TRANS); - } - - - + this->Rechteck(X1, Y1, X2, Y2, BLUE, TRANS); } diff --git a/Hazard/Hazard/PrimImplikantCollection.cpp b/Hazard/Hazard/PrimImplikantCollection.cpp index ec35546..07c94f5 100644 --- a/Hazard/Hazard/PrimImplikantCollection.cpp +++ b/Hazard/Hazard/PrimImplikantCollection.cpp @@ -58,23 +58,11 @@ bool PrimImplikantCollection::contains(PrimImplikant* foreign) return false; } -bool PrimImplikantCollection::Anwesenheit(Implikant_localisation* &I, vector &group) -{ - for (vector::iterator it = group.begin(); it < group.end(); it++) - { - if ((*it)->i == (I->i)) - { - return true; - } - - } - return false; -} void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) { - vector::iterator it1; + vector groupA; // Jede I_vector wird in einem oder in Zwei vectoren vector groupB; // zuerst gespaltet. @@ -85,7 +73,7 @@ void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) - for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) + for (vector::iterator it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) { if ((((*it1)->h) == (numVarY / 2) - 1) || (((*it1)->h) == (numVarY / 2))) { @@ -98,20 +86,20 @@ void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI) if (Linie_mitte) // Wenn wahr ist. ES geht um Linie_mitte_Y { - for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) + /*for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) { groupA.push_back(*it1); } - - currentPI->PI_groupCollection.push_back(&groupA); + */ + currentPI->PI_groupCollection.push_back(&(currentPI->I_Vector)); Linie_mitte = 0; } else { - for (it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) + for (vector::iterator it1 = currentPI->I_Vector.begin(); it1 < currentPI->I_Vector.end(); it1++) { - if (((*it1)->h < (numVarY / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA + if ((*it1)->h < ((numVarY / 2) - 1)) // die Implikanten, deren h <= numVary/2 -1 sind im groupA { // gespeichert. groupA.push_back(*it1); @@ -142,7 +130,6 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vec { vector hilfVec1, hilfVec2; - vector::iterator it1; uint numVarX = (uint)floor(dimension / 2.0f); static int Linie_mitte; // Zustand 0--> wird w überprüft im Vector // Zustand 1 oder >1 -->wird w überprüft im Vector. @@ -150,7 +137,7 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vec - for (it1 = group.begin(); it1 < group.end(); it1++) + for (vector::iterator it1 = group.begin(); it1 < group.end(); it1++) { if ((((*it1)->h) == (numVarX / 2) - 1) || (((*it1)->h) == (numVarX / 2))) { @@ -169,10 +156,10 @@ void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vec } else { - for (it1 = group.begin(); it1 < group.end(); it1++) + for (vector::iterator it1 = group.begin(); it1 < group.end(); it1++) { - if (((*it1)->w < (numVarX / 2) - 1)) // die Implikanten, deren w <= numVarX/2 -1 sind im groupA + if ((*it1)->w < ((numVarX / 2) - 1)) // die Implikanten, deren w <= numVarX/2 -1 sind im groupA { // gespeichert. wenn w größer, dann wird im hilfVec2 gespeichert hilfVec1.push_back(*it1); diff --git a/Hazard/Hazard/PrimImplikantCollection.h b/Hazard/Hazard/PrimImplikantCollection.h index 749f0c2..ec88bfe 100644 --- a/Hazard/Hazard/PrimImplikantCollection.h +++ b/Hazard/Hazard/PrimImplikantCollection.h @@ -24,7 +24,7 @@ public: bool contains(PrimImplikant* foreign); void setgroupCollection1(PrimImplikant* ¤tPI); void setgroupCollection2(PrimImplikant* ¤tPI,vector &group); - bool Anwesenheit(Implikant_localisation* &I, vector &group); + void Dispose();