Merge branch 'GDE' of https://github.com/gaeltp3/Harzard_Projekt into GDE
This commit is contained in:
commit
a7e4edb77e
5 changed files with 232 additions and 136 deletions
|
@ -9,6 +9,8 @@ extern uint dimension;
|
||||||
extern uint numElements;
|
extern uint numElements;
|
||||||
extern bool KNF;
|
extern bool KNF;
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
void KV::Clear()
|
void KV::Clear()
|
||||||
{
|
{
|
||||||
|
@ -167,7 +169,7 @@ void KV::PrintPrimImplikanten()
|
||||||
{
|
{
|
||||||
PrimImplikant* currentPI = this->globalPic->at(i);
|
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++)
|
for (uint j = 0; j < currentPI->implikanten.size(); j++)
|
||||||
{
|
{
|
||||||
uint currentI = currentPI->implikanten[j];
|
uint currentI = currentPI->implikanten[j];
|
||||||
|
@ -200,11 +202,69 @@ void KV::PrintPrimImplikanten()
|
||||||
case 0x03: // overflows from left to right
|
case 0x03: // overflows from left to right
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0; // find coordinates for Rechteck
|
|
||||||
for (uint j = 0; j < currentPI->implikanten.size(); j++)
|
*/
|
||||||
|
|
||||||
|
// 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->PI_groupCollection.size(); j++)
|
||||||
{
|
{
|
||||||
uint currentI = currentPI->implikanten[j];
|
|
||||||
uint w = (currentI & ((0x1 << (this->numVarX)) - 1)); // get all bits that make X (=w)
|
vector<Implikant_localisation*>* kullers = currentPI->PI_groupCollection[j];
|
||||||
|
uint X1 = -1, X2 = 0, Y1 = -1, Y2 = 0;
|
||||||
|
|
||||||
|
|
||||||
|
for (vector<Implikant_localisation*>::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 w = currentPI->PI_groupCollection // get all bits that make X (=w)
|
||||||
w ^= w / 2;
|
w ^= w / 2;
|
||||||
uint h = (currentI >> this->numVarX); // get all bits that make Y (=h)
|
uint h = (currentI >> this->numVarX); // get all bits that make Y (=h)
|
||||||
h ^= h / 2;
|
h ^= h / 2;
|
||||||
|
@ -212,7 +272,7 @@ void KV::PrintPrimImplikanten()
|
||||||
uint x1 = w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord
|
uint x1 = w * (this->edgeLength + 1) + this->VarY_Length; // Upper coord
|
||||||
uint x2 = x1 + this->edgeLength; // Lower coord
|
uint x2 = x1 + this->edgeLength; // Lower coord
|
||||||
uint y1 = h * (this->edgeLength + 1) + this->VarX_Length; // Left 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);
|
X1 = min(X1, x1);
|
||||||
X2 = max(X2, x2);
|
X2 = max(X2, x2);
|
||||||
|
@ -242,114 +302,9 @@ void KV::PrintPrimImplikanten()
|
||||||
|
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|
||||||
bool KV:: Anwesenheit(Implikant_localisation* &I, vector<Implikant_localisation*> &group)
|
|
||||||
{
|
|
||||||
|
|
||||||
for (vector<Implikant_localisation*>::iterator it = group.begin(); it < group.end(); it++)
|
*/
|
||||||
{
|
|
||||||
if ((*it)->i == (I->i))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
vector<Implikant_localisation*> KV::setgroupCollection(vector<Implikant_localisation*> &group)
|
|
||||||
{
|
|
||||||
|
|
||||||
vector<Implikant_localisation*> hilfVec1;
|
|
||||||
vector<Implikant_localisation*>::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<Implikant_localisation*>::iterator it1;
|
|
||||||
vector<Implikant_localisation*> groupA; // Jede I_vector wird in einem oder in Zwei vectoren
|
|
||||||
vector<Implikant_localisation*> 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ private:
|
||||||
PrimImplikantCollection* globalPic;
|
PrimImplikantCollection* globalPic;
|
||||||
CellCollection* allCells;
|
CellCollection* allCells;
|
||||||
vector<string>* variables;
|
vector<string>* variables;
|
||||||
vector<vector<Implikant_localisation*>*> PI_groupCollection;
|
|
||||||
|
|
||||||
uint offsetX; // Der freie Platz nach links in Pixeln
|
uint offsetX; // Der freie Platz nach links in Pixeln
|
||||||
uint offsetY; // Der freie Platz nach rechts 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 PrintCellValues(); // Erstellt die Werte der jeweiligen Zellen
|
||||||
void PrintPrimImplikanten(); // Erstellt die einzelnen Primimplikanten
|
void PrintPrimImplikanten(); // Erstellt die einzelnen Primimplikanten
|
||||||
void PrintString_Var(); // Erstellt den horizontalen TextVariable & vertikalen Textvariable
|
void PrintString_Var(); // Erstellt den horizontalen TextVariable & vertikalen Textvariable
|
||||||
vector<Implikant_localisation*> setgroupCollection(vector<Implikant_localisation*> &group);
|
|
||||||
bool Anwesenheit(Implikant_localisation* &I, vector<Implikant_localisation*> &group);
|
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
void Line(uint x1, uint y1, uint x2, uint y2, int color); // Zeichnet eine Linie mit Offset
|
void Line(uint x1, uint y1, uint x2, uint y2, int color); // Zeichnet eine Linie mit Offset
|
||||||
|
|
|
@ -45,7 +45,11 @@ public:
|
||||||
bool PrimImplikant::valueAt(uint position);
|
bool PrimImplikant::valueAt(uint position);
|
||||||
void PrimImplikant::parser(string input);
|
void PrimImplikant::parser(string input);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vector<uint> implikanten;
|
vector<uint> implikanten;
|
||||||
vector<Implikant_localisation*> I_Vector;
|
vector<Implikant_localisation*> I_Vector;
|
||||||
|
vector<vector<Implikant_localisation*>*> PI_groupCollection;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -15,18 +15,21 @@ void PrimImplikantCollection::add(string input)
|
||||||
PrimImplikant* PI = new PrimImplikant(input);
|
PrimImplikant* PI = new PrimImplikant(input);
|
||||||
|
|
||||||
PI->id = this->size();
|
PI->id = this->size();
|
||||||
|
this->setgroupCollection1(PI);
|
||||||
this->add(PI);
|
this->add(PI);
|
||||||
}
|
}
|
||||||
void PrimImplikantCollection::add(uint input)
|
void PrimImplikantCollection::add(uint input)
|
||||||
{
|
{
|
||||||
PrimImplikant* PI = new PrimImplikant(input);
|
PrimImplikant* PI = new PrimImplikant(input);
|
||||||
PI->id = this->size();
|
PI->id = this->size();
|
||||||
|
this->setgroupCollection1(PI);
|
||||||
this->add(PI);
|
this->add(PI);
|
||||||
}
|
}
|
||||||
void PrimImplikantCollection::add(uint input1, uint input2)
|
void PrimImplikantCollection::add(uint input1, uint input2)
|
||||||
{
|
{
|
||||||
PrimImplikant* PI = new PrimImplikant(input1, input2);
|
PrimImplikant* PI = new PrimImplikant(input1, input2);
|
||||||
PI->id = this->size();
|
PI->id = this->size();
|
||||||
|
this->setgroupCollection1(PI);
|
||||||
this->add(PI);
|
this->add(PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,6 +58,133 @@ bool PrimImplikantCollection::contains(PrimImplikant* foreign)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void PrimImplikantCollection::setgroupCollection1(PrimImplikant* ¤tPI)
|
||||||
|
{
|
||||||
|
|
||||||
|
vector<Implikant_localisation*> groupA; // Jede I_vector wird in einem oder in Zwei vectoren
|
||||||
|
vector<Implikant_localisation*> groupB; // zuerst gespaltet.
|
||||||
|
|
||||||
|
static int Linie_mitte;
|
||||||
|
uint numVarY = (uint)ceil(dimension / 2.0f);
|
||||||
|
|
||||||
|
//PrimImplikant* currentPI = currentPI; // Zuweisung diese Adresse an einem ZeigerObjekt denselben Namen.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (vector<Implikant_localisation*>::iterator 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(&(currentPI->I_Vector));
|
||||||
|
Linie_mitte = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (vector<Implikant_localisation*>::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
|
||||||
|
{ // gespeichert.
|
||||||
|
|
||||||
|
groupA.push_back(*it1);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else { groupB.push_back(*it1); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupA.size())
|
||||||
|
{
|
||||||
|
setgroupCollection2(currentPI, groupA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (groupB.size())
|
||||||
|
{
|
||||||
|
setgroupCollection2(currentPI, groupB);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PrimImplikantCollection::setgroupCollection2(PrimImplikant* ¤tPI, vector<Implikant_localisation*> &group)
|
||||||
|
{
|
||||||
|
|
||||||
|
vector<Implikant_localisation*> hilfVec1, hilfVec2;
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (vector<Implikant_localisation*>::iterator 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 w der KV diagramm erreicht ist.
|
||||||
|
// Test zu wissen , wieviele Implikanten in Mitte_tiefe sind
|
||||||
|
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Linie_mitte) // Wenn wahr ist.--> Linie_mitte_X
|
||||||
|
{
|
||||||
|
|
||||||
|
currentPI->PI_groupCollection.push_back(&group);
|
||||||
|
Linie_mitte = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (vector<Implikant_localisation*>::iterator it1 = group.begin(); it1 < group.end(); it1++)
|
||||||
|
{
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else { hilfVec2.push_back(*it1); }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hilfVec1.size())
|
||||||
|
{
|
||||||
|
currentPI->PI_groupCollection.push_back(&hilfVec1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hilfVec2.size())
|
||||||
|
{
|
||||||
|
currentPI->PI_groupCollection.push_back(&hilfVec2);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
uint PrimImplikantCollection::size()
|
uint PrimImplikantCollection::size()
|
||||||
{
|
{
|
||||||
return this->PIVector.size();
|
return this->PIVector.size();
|
||||||
|
|
|
@ -2,8 +2,12 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "PrimImplikant.h"
|
#include "PrimImplikant.h"
|
||||||
|
#include "Implikant_localisation.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
extern uint dimension;
|
||||||
|
extern uint numElements;
|
||||||
|
extern bool KNF;
|
||||||
|
|
||||||
#ifndef PRIMIMPLIKANTCOLLEC
|
#ifndef PRIMIMPLIKANTCOLLEC
|
||||||
#define PRIMIMPLIKANTCOLLEC
|
#define PRIMIMPLIKANTCOLLEC
|
||||||
|
@ -18,6 +22,9 @@ public:
|
||||||
bool valueAt(uint position);
|
bool valueAt(uint position);
|
||||||
PrimImplikantCollection primImplikantenAt(uint position);
|
PrimImplikantCollection primImplikantenAt(uint position);
|
||||||
bool contains(PrimImplikant* foreign);
|
bool contains(PrimImplikant* foreign);
|
||||||
|
void setgroupCollection1(PrimImplikant* ¤tPI);
|
||||||
|
void setgroupCollection2(PrimImplikant* ¤tPI,vector<Implikant_localisation*> &group);
|
||||||
|
|
||||||
|
|
||||||
void Dispose();
|
void Dispose();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue