From cb7bcec454cf3059479b8f6c02a39f68a89702d7 Mon Sep 17 00:00:00 2001 From: gaeltp3 Date: Fri, 20 Dec 2013 00:56:48 +0100 Subject: [PATCH] Spaltung der I_vector der PI in eventuell zwei Vectoren. --- Hazard/Hazard/KV.cpp | 115 ++++++++++++++++++++++++++++++++++ Hazard/Hazard/KV.h | 4 ++ Hazard/Hazard/PrimImplikant.h | 1 + 3 files changed, 120 insertions(+) diff --git a/Hazard/Hazard/KV.cpp b/Hazard/Hazard/KV.cpp index d583ebe..709f2cd 100644 --- a/Hazard/Hazard/KV.cpp +++ b/Hazard/Hazard/KV.cpp @@ -240,7 +240,122 @@ 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); + } + + } +} + + + + + + void KV::Line(uint x1, uint y1, uint x2, uint y2, int color) { line(x1 + this->offsetX, y1 + this->offsetY, x2 + this->offsetX, y2 + this->offsetY, color); diff --git a/Hazard/Hazard/KV.h b/Hazard/Hazard/KV.h index b735b50..17c3de4 100644 --- a/Hazard/Hazard/KV.h +++ b/Hazard/Hazard/KV.h @@ -4,6 +4,7 @@ #include "Cell.h" #include "CellCollection.h" #include "PrimImplikantCollection.h" +#include "Implikant_localisation.h" extern uint dimension; extern uint numElements; @@ -41,6 +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 @@ -64,6 +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 f1ff709..079adb1 100644 --- a/Hazard/Hazard/PrimImplikant.h +++ b/Hazard/Hazard/PrimImplikant.h @@ -3,6 +3,7 @@ #include #include +#include "Implikant_localisation.h" using namespace std;