Fixed bugs
This commit is contained in:
parent
9ca02c9100
commit
2d62e47f7e
4 changed files with 29 additions and 165 deletions
|
@ -2,17 +2,17 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Implikant_localisation.h"
|
||||
#include "KV_PiEleLoc.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PrimImplikant
|
||||
{
|
||||
private:
|
||||
bool compareGray(uint &a, uint &b);
|
||||
static bool compareGray(uint a, uint b);
|
||||
void makeLocations();
|
||||
|
||||
vector<KV_PiEleLoc*>* locations = NULL;
|
||||
vector<KV_PiEleLoc*>* _locations;
|
||||
|
||||
public:
|
||||
string name;
|
||||
|
@ -21,31 +21,31 @@ public:
|
|||
|
||||
PrimImplikant(string input)
|
||||
{
|
||||
name = input;
|
||||
parser(input);
|
||||
this->name = input;
|
||||
this->parser(input);
|
||||
this->_locations = NULL;
|
||||
}
|
||||
PrimImplikant(uint input)
|
||||
{
|
||||
char nameC[sizeof(uint)*8+1];
|
||||
_itoa_s(input, nameC, sizeof(uint)*8+1, 10);
|
||||
name = nameC;
|
||||
this->name = nameC;
|
||||
|
||||
implikanten.push_back(input);
|
||||
I_Vector.push_back(new Implikant_localisation(input));
|
||||
this->elements.push_back(input);
|
||||
this->_locations = NULL;
|
||||
}
|
||||
PrimImplikant(uint input1, uint input2)
|
||||
{
|
||||
char nameC[sizeof(uint)*8+1];
|
||||
_itoa_s(input1, nameC, sizeof(uint)*8+1, 10);
|
||||
name = nameC;
|
||||
this->name = nameC;
|
||||
_itoa_s(input2, nameC, sizeof(uint)*8+1, 10);
|
||||
name.append("|");
|
||||
name.append(nameC);
|
||||
this->name.append("|");
|
||||
this->name.append(nameC);
|
||||
|
||||
implikanten.push_back(input1);
|
||||
I_Vector.push_back(new Implikant_localisation(input1));
|
||||
implikanten.push_back(input2);
|
||||
I_Vector.push_back(new Implikant_localisation(input2));
|
||||
this->elements.push_back(input1);
|
||||
this->elements.push_back(input2);
|
||||
this->_locations = NULL;
|
||||
}
|
||||
|
||||
bool valueAt(uint position);
|
||||
|
@ -55,15 +55,13 @@ public:
|
|||
|
||||
~PrimImplikant()
|
||||
{
|
||||
if (this->locations)
|
||||
if (this->_locations)
|
||||
{
|
||||
for (uint i = 0; i < this->locations.size(); i++)
|
||||
{
|
||||
delete this->locations[i];
|
||||
this->locations[i] = NULL;
|
||||
}
|
||||
delete this->locations;
|
||||
this->locations = NULL;
|
||||
for (uint i = 0; i < this->_locations->size(); i++)
|
||||
delete this->_locations->at(i);
|
||||
|
||||
delete this->_locations;
|
||||
this->_locations = NULL;
|
||||
}
|
||||
}
|
||||
};
|
|
@ -1,4 +1,3 @@
|
|||
//#include <iostream>
|
||||
#include "stdafx.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -6,6 +5,8 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
uint PrimImplikantCollection::globalCount = 0;
|
||||
|
||||
void PrimImplikantCollection::add(PrimImplikant* &PI)
|
||||
{
|
||||
PIVector.push_back(PI);
|
||||
|
@ -15,21 +16,18 @@ void PrimImplikantCollection::add(string input)
|
|||
PrimImplikant* PI = new PrimImplikant(input);
|
||||
|
||||
PI->id = PrimImplikantCollection::globalCount++;
|
||||
this->setgroupCollection1(PI);
|
||||
this->add(PI);
|
||||
}
|
||||
void PrimImplikantCollection::add(uint input)
|
||||
{
|
||||
PrimImplikant* PI = new PrimImplikant(input);
|
||||
PI->id = PrimImplikantCollection::globalCount++;
|
||||
this->setgroupCollection1(PI);
|
||||
this->add(PI);
|
||||
}
|
||||
void PrimImplikantCollection::add(uint input1, uint input2)
|
||||
{
|
||||
PrimImplikant* PI = new PrimImplikant(input1, input2);
|
||||
PI->id = PrimImplikantCollection::globalCount++;
|
||||
this->setgroupCollection1(PI);
|
||||
this->add(PI);
|
||||
}
|
||||
|
||||
|
@ -58,133 +56,6 @@ bool PrimImplikantCollection::contains(PrimImplikant* foreign)
|
|||
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()
|
||||
{
|
||||
return this->PIVector.size();
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
//#include <iostream>
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "PrimImplikant.h"
|
||||
#include "Implikant_localisation.h"
|
||||
|
||||
using namespace std;
|
||||
extern uint dimension;
|
||||
extern uint numElements;
|
||||
extern bool KNF;
|
||||
|
||||
#ifndef PRIMIMPLIKANTCOLLEC
|
||||
#define PRIMIMPLIKANTCOLLEC
|
||||
|
||||
class PrimImplikantCollection{
|
||||
public:
|
||||
void add(PrimImplikant* &PI);
|
||||
|
@ -22,8 +19,6 @@ public:
|
|||
bool valueAt(uint position);
|
||||
PrimImplikantCollection primImplikantenAt(uint position);
|
||||
bool contains(PrimImplikant* foreign);
|
||||
void setgroupCollection1(PrimImplikant* ¤tPI);
|
||||
void setgroupCollection2(PrimImplikant* ¤tPI,vector<Implikant_localisation*> &group);
|
||||
|
||||
|
||||
void Dispose();
|
||||
|
@ -36,7 +31,5 @@ public:
|
|||
private:
|
||||
vector<PrimImplikant*> PIVector;
|
||||
|
||||
static uint globalCount = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
static uint globalCount;
|
||||
};
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
|
Loading…
Reference in a new issue