Added CellCollection
Moved Hazard detection algorithm to this class to save lines in user_main
This commit is contained in:
		
							parent
							
								
									dda518f45a
								
							
						
					
					
						commit
						effa28cb2d
					
				
					 7 changed files with 198 additions and 99 deletions
				
			
		
							
								
								
									
										89
									
								
								Hazard/Hazard/CellCollection.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								Hazard/Hazard/CellCollection.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,89 @@
 | 
				
			||||||
 | 
					#include "stdafx.h"
 | 
				
			||||||
 | 
					#include <vector>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include "Cell.h"
 | 
				
			||||||
 | 
					#include "CellCollection.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					extern uint dimension;
 | 
				
			||||||
 | 
					extern uint numElements;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CellCollection::add(Cell* &cell)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						this->cells.push_back(cell);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CellCollection::init(PrimImplikantCollection* &globalPIC)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						this->globalPIC = globalPIC;
 | 
				
			||||||
 | 
						this->cells.resize(numElements);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (uint i = 0; i < numElements; i++)
 | 
				
			||||||
 | 
							this->cells[i] = new Cell(i, globalPIC);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CellCollection::findHazards()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						for (uint i = 0; i < numElements; i += 2)				// we only need to check every 2nd as long as it's gray
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							uint I = i ^ (i/2);									// transform to gray code --> Schachbrettmuster
 | 
				
			||||||
 | 
							Cell* currentCell = cells[I];						// this is the cell we are currently checking
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (currentCell->value == false)					// no hazard can occur
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cout << "   Checking cell " << I << endl;
 | 
				
			||||||
 | 
							vector<Cell*>* hazardousNeighbors = currentCell->getHazards(this->cells);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (hazardousNeighbors->size() == 0)				// no hazard found
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								delete hazardousNeighbors;
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (vector<Cell*>::iterator nc = hazardousNeighbors->begin(); nc < hazardousNeighbors->end(); nc++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								printf("Hazard found! Cell %d <--> Cell %d\n", I, (*nc)->index);
 | 
				
			||||||
 | 
								this->globalPIC->add(I, (*nc)->index);			// add PI that solves hazard. Not quite smart...
 | 
				
			||||||
 | 
								(*nc)->refresh(this->globalPIC);				// refresh the foreign PIC (a PI was added)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							currentCell->refresh(this->globalPIC);				// refresh the current PIC (a PI was added)
 | 
				
			||||||
 | 
							delete hazardousNeighbors;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void CellCollection::Dispose()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						for (uint i = 0; i < this->cells.size(); i++)
 | 
				
			||||||
 | 
							delete cells[i];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					uint CellCollection::size()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cells.size();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Cell* CellCollection::back()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cells.back();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Cell* CellCollection::front()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cells.front();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Cell* CellCollection::at(uint index)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cells.at(index);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Cell * CellCollection::operator[](uint &index)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return cells.at(index);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										37
									
								
								Hazard/Hazard/CellCollection.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Hazard/Hazard/CellCollection.h
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,37 @@
 | 
				
			||||||
 | 
					#pragma once
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "stdafx.h"
 | 
				
			||||||
 | 
					#include "Cell.h"
 | 
				
			||||||
 | 
					#include "CellCollection.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef _CELLCOLLEC_H
 | 
				
			||||||
 | 
					#define _CELLCOLLEC_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CellCollection {
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						void add(Cell* &cell);
 | 
				
			||||||
 | 
						void init(PrimImplikantCollection* &globalPIC);
 | 
				
			||||||
 | 
						void findHazards();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void Dispose();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						uint size();
 | 
				
			||||||
 | 
						Cell* back();
 | 
				
			||||||
 | 
						Cell* front();
 | 
				
			||||||
 | 
						Cell* at(uint index);
 | 
				
			||||||
 | 
						Cell* operator[](uint &index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						CellCollection(PrimImplikantCollection* &globalPIC)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this->init(globalPIC);
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						vector<Cell*> cells;
 | 
				
			||||||
 | 
						PrimImplikantCollection* globalPIC;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,3 @@
 | 
				
			||||||
// Hazard.cpp : Definiert den Einstiegspunkt für die Konsolenanwendung.
 | 
					 | 
				
			||||||
//
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "stdafx.h"
 | 
					#include "stdafx.h"
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
| 
						 | 
					@ -9,6 +6,7 @@
 | 
				
			||||||
#include "PrimImplikant.h"
 | 
					#include "PrimImplikant.h"
 | 
				
			||||||
#include "PrimImplikantCollection.h"
 | 
					#include "PrimImplikantCollection.h"
 | 
				
			||||||
#include "Cell.h"
 | 
					#include "Cell.h"
 | 
				
			||||||
 | 
					#include "CellCollection.h"
 | 
				
			||||||
#include "Wertetabelle.h"
 | 
					#include "Wertetabelle.h"
 | 
				
			||||||
#include "KV.h"
 | 
					#include "KV.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,124 +21,89 @@ void user_main(void)
 | 
				
			||||||
	FILE * input;
 | 
						FILE * input;
 | 
				
			||||||
	FILE * error;
 | 
						FILE * error;
 | 
				
			||||||
	FILE * list;
 | 
						FILE * list;
 | 
				
			||||||
	fopen_s(&input, "res\\input.txt", "r");
 | 
						if (open_files(input, error, list) != 0)
 | 
				
			||||||
	if (input == 0)
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		cout << "Fehler Inputdatei";
 | 
							pause();
 | 
				
			||||||
		system("pause");
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	fopen_s(&error, "res\\errorParser.txt", "a");
 | 
					 | 
				
			||||||
	if (error == 0)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		cout << "Fehler Fehlerdatei";
 | 
					 | 
				
			||||||
		system("pause");
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	fopen_s(&list, "res\\listParser.txt", "w");
 | 
					 | 
				
			||||||
	if (list == 0)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		cout << "Fehler Listdatei";
 | 
					 | 
				
			||||||
		system("pause");
 | 
					 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	PrimImplikantCollection* globalPIC = new PrimImplikantCollection();
 | 
						PrimImplikantCollection* globalPIC = new PrimImplikantCollection();
 | 
				
			||||||
	vector<string>* variables = new vector<string>();
 | 
						vector<string>* variables = new vector<string>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	CParser parser;
 | 
						CParser* parser = new CParser(input, error, list);
 | 
				
			||||||
	parser.IP_init_token_table();
 | 
						bool parseFailure = parser->yyparse(globalPIC, variables) != 0;
 | 
				
			||||||
	parser.InitParse(input, error, list);
 | 
					
 | 
				
			||||||
	if (parser.yyparse(globalPIC, variables) != 0)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		system("pause");
 | 
					 | 
				
			||||||
		return;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	fclose(input);
 | 
						fclose(input);
 | 
				
			||||||
	fclose(error);
 | 
						fclose(error);
 | 
				
			||||||
	fclose(list);
 | 
						fclose(list);
 | 
				
			||||||
	//system("pause");
 | 
						delete parser;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*pic.add(7);
 | 
						if (parseFailure)
 | 
				
			||||||
	pic.add("0x1");
 | 
					 | 
				
			||||||
	pic.add("100");
 | 
					 | 
				
			||||||
	pic.add("00x");
 | 
					 | 
				
			||||||
	pic.add(4);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	PrimImplikant prim7(7);
 | 
					 | 
				
			||||||
	PrimImplikant prim13("0x1");
 | 
					 | 
				
			||||||
	PrimImplikant prim4("100");
 | 
					 | 
				
			||||||
	PrimImplikant prim4567("1xx");
 | 
					 | 
				
			||||||
	pic.add(prim4567);*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/*for (int p = 0; p < numElements; p++)
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		//printf("Pos %d: prim7=%d, prim13=%d, prim4=%d, prim4567=%d, pic=%d\n", p, prim7.valueAt(p), prim13.valueAt(p), prim4.valueAt(p), prim4567.valueAt(p), pic.valueAt(p));
 | 
							pause();
 | 
				
			||||||
			printf("Pos %d: Matching collections: ", p);
 | 
							return;
 | 
				
			||||||
			PrimImplikantCollection matchingPIs = globalPIC->primImplikantenAt(p);
 | 
					 | 
				
			||||||
			for (int i = 0; i < matchingPIs.size(); i++)
 | 
					 | 
				
			||||||
				//cout << i->name < ", ";
 | 
					 | 
				
			||||||
				printf("%s, ", matchingPIs[i]->name.c_str());
 | 
					 | 
				
			||||||
			cout << endl;
 | 
					 | 
				
			||||||
	}*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// initialize Cells
 | 
					 | 
				
			||||||
	vector<Cell*> cells;
 | 
					 | 
				
			||||||
	cells.resize(numElements);
 | 
					 | 
				
			||||||
	uint numOnes = 0;
 | 
					 | 
				
			||||||
	for (uint i = 0; i < numElements; i++)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		cells[i] = new Cell(i, globalPIC);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						// initialize Cells
 | 
				
			||||||
 | 
						CellCollection* allCells = new CellCollection(globalPIC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Wertetabelle* wt = new Wertetabelle(&cells, variables);
 | 
						
 | 
				
			||||||
 | 
						// print Wertetabelle and KV of imported data
 | 
				
			||||||
 | 
						Wertetabelle* wt = new Wertetabelle(allCells, variables);
 | 
				
			||||||
	wt->Print();
 | 
						wt->Print();
 | 
				
			||||||
	delete wt;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	KV* kv = new KV(globalPIC, cells, 30);
 | 
						KV* kv = new KV(globalPIC, allCells, 30);
 | 
				
			||||||
	kv->Print(30);
 | 
						kv->Print(30);
 | 
				
			||||||
	//system("pause");
 | 
						//system("pause");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// find hazards
 | 
						// find and solve Hazards
 | 
				
			||||||
	for (uint i = 0; i < numElements; i += 2)
 | 
						allCells->findHazards();
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		uint grayI = i ^ (i/2);								// transform to gray code --> Schachbrettmuster
 | 
					 | 
				
			||||||
		Cell* currentCell = cells[grayI];					// this is the cell we are currently checking
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (currentCell->value == false)					// no hazard can occur
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		cout << "   Checking cell " << grayI << endl;
 | 
					 | 
				
			||||||
		vector<Cell*>* hazardousNeighbors = currentCell->getHazards(cells);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (hazardousNeighbors->size() == 0)				// no hazard found
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			delete hazardousNeighbors;
 | 
					 | 
				
			||||||
			continue;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		for (vector<Cell*>::iterator c = hazardousNeighbors->begin(); c < hazardousNeighbors->end(); c++)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			printf("Hazard found! Cell %d <--> Cell %d\n", grayI, (*c)->index);
 | 
					 | 
				
			||||||
			globalPIC->add(grayI, (*c)->index);				// add PI that solves hazard. Not quite smart...
 | 
					 | 
				
			||||||
			(*c)->refresh(globalPIC);						// refresh the local PIC (a PI was added)
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		currentCell->refresh(globalPIC);
 | 
					 | 
				
			||||||
		delete hazardousNeighbors;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	//system("pause");
 | 
						//system("pause");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	wt = new Wertetabelle(&cells, variables);
 | 
					
 | 
				
			||||||
 | 
						// print Wertetabelle and KV of corrected data
 | 
				
			||||||
	wt->Print();
 | 
						wt->Print();
 | 
				
			||||||
	delete wt;
 | 
						delete wt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kv->Print(30*2 + kv->width(), 30);
 | 
						kv->Print(30 + kv->width() + 30, 30);	// Diagramm neben dem vorherigen
 | 
				
			||||||
	delete kv;
 | 
						delete kv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	globalPIC->Dispose();
 | 
						globalPIC->Dispose();
 | 
				
			||||||
	//system("pause");
 | 
						allCells->Dispose();
 | 
				
			||||||
 | 
						delete globalPIC;
 | 
				
			||||||
 | 
						delete allCells;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						pause();
 | 
				
			||||||
	return;
 | 
						return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int open_files(FILE * &input, FILE * &error, FILE * &list)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						fopen_s(&input, "res\\input.txt", "r");
 | 
				
			||||||
 | 
						if (input == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							cout << "Fehler Inputdatei";
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fopen_s(&error, "res\\errorParser.txt", "a");
 | 
				
			||||||
 | 
						if (error == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							cout << "Fehler Fehlerdatei";
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						fopen_s(&list, "res\\listParser.txt", "w");
 | 
				
			||||||
 | 
						if (list == 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							cout << "Fehler Listdatei";
 | 
				
			||||||
 | 
							return 1;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void pause()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					#if DEBUG
 | 
				
			||||||
 | 
						system("pause");
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@
 | 
				
			||||||
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
 | 
					  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
 | 
				
			||||||
    <ConfigurationType>Application</ConfigurationType>
 | 
					    <ConfigurationType>Application</ConfigurationType>
 | 
				
			||||||
    <UseDebugLibraries>true</UseDebugLibraries>
 | 
					    <UseDebugLibraries>true</UseDebugLibraries>
 | 
				
			||||||
    <PlatformToolset>v100</PlatformToolset>
 | 
					    <PlatformToolset>v110</PlatformToolset>
 | 
				
			||||||
    <CharacterSet>Unicode</CharacterSet>
 | 
					    <CharacterSet>Unicode</CharacterSet>
 | 
				
			||||||
  </PropertyGroup>
 | 
					  </PropertyGroup>
 | 
				
			||||||
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
 | 
					  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
 | 
				
			||||||
| 
						 | 
					@ -81,6 +81,7 @@
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <ClInclude Include="Cell.h" />
 | 
					    <ClInclude Include="Cell.h" />
 | 
				
			||||||
 | 
					    <ClInclude Include="CellCollection.h" />
 | 
				
			||||||
    <ClInclude Include="CParser.h" />
 | 
					    <ClInclude Include="CParser.h" />
 | 
				
			||||||
    <ClInclude Include="PrimImplikant.h" />
 | 
					    <ClInclude Include="PrimImplikant.h" />
 | 
				
			||||||
    <ClInclude Include="PrimImplikantCollection.h" />
 | 
					    <ClInclude Include="PrimImplikantCollection.h" />
 | 
				
			||||||
| 
						 | 
					@ -90,6 +91,7 @@
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <ClCompile Include="Cell.cpp" />
 | 
					    <ClCompile Include="Cell.cpp" />
 | 
				
			||||||
 | 
					    <ClCompile Include="CellCollection.cpp" />
 | 
				
			||||||
    <ClCompile Include="CParser.cpp" />
 | 
					    <ClCompile Include="CParser.cpp" />
 | 
				
			||||||
    <ClCompile Include="Hazard.cpp" />
 | 
					    <ClCompile Include="Hazard.cpp" />
 | 
				
			||||||
    <ClCompile Include="PrimImplikant.cpp" />
 | 
					    <ClCompile Include="PrimImplikant.cpp" />
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,6 +39,9 @@
 | 
				
			||||||
    <ClInclude Include="Wertetabelle.h">
 | 
					    <ClInclude Include="Wertetabelle.h">
 | 
				
			||||||
      <Filter>Headerdateien</Filter>
 | 
					      <Filter>Headerdateien</Filter>
 | 
				
			||||||
    </ClInclude>
 | 
					    </ClInclude>
 | 
				
			||||||
 | 
					    <ClInclude Include="CellCollection.h">
 | 
				
			||||||
 | 
					      <Filter>Headerdateien</Filter>
 | 
				
			||||||
 | 
					    </ClInclude>
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <ClCompile Include="stdafx.cpp">
 | 
					    <ClCompile Include="stdafx.cpp">
 | 
				
			||||||
| 
						 | 
					@ -62,6 +65,9 @@
 | 
				
			||||||
    <ClCompile Include="Cell.cpp">
 | 
					    <ClCompile Include="Cell.cpp">
 | 
				
			||||||
      <Filter>Quelldateien</Filter>
 | 
					      <Filter>Quelldateien</Filter>
 | 
				
			||||||
    </ClCompile>
 | 
					    </ClCompile>
 | 
				
			||||||
 | 
					    <ClCompile Include="CellCollection.cpp">
 | 
				
			||||||
 | 
					      <Filter>Quelldateien</Filter>
 | 
				
			||||||
 | 
					    </ClCompile>
 | 
				
			||||||
  </ItemGroup>
 | 
					  </ItemGroup>
 | 
				
			||||||
  <ItemGroup>
 | 
					  <ItemGroup>
 | 
				
			||||||
    <None Include="..\res\input.txt">
 | 
					    <None Include="..\res\input.txt">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
#include <WinGDI.h>
 | 
					#include <WinGDI.h>
 | 
				
			||||||
#include "Cell.h"
 | 
					#include "Cell.h"
 | 
				
			||||||
 | 
					#include "CellCollection.h"
 | 
				
			||||||
#include "PrimImplikantCollection.h"
 | 
					#include "PrimImplikantCollection.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern uint dimension;
 | 
					extern uint dimension;
 | 
				
			||||||
| 
						 | 
					@ -18,7 +19,7 @@ public:
 | 
				
			||||||
	uint height();										// Gibt die Höhe   eines KV-Diagramms zurück (heightPx)
 | 
						uint height();										// Gibt die Höhe   eines KV-Diagramms zurück (heightPx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Konstruktor
 | 
						// Konstruktor
 | 
				
			||||||
	KV(PrimImplikantCollection * globalPic, vector<Cell*> allCells, uint size) 
 | 
						KV(PrimImplikantCollection * globalPic, CellCollection allCells, uint size) 
 | 
				
			||||||
	  :	edgeLength(size),
 | 
						  :	edgeLength(size),
 | 
				
			||||||
		numVarX(((uint)floor(dimension/2.0f))), numVarY(((uint)ceil(dimension/2.0f))),
 | 
							numVarX(((uint)floor(dimension/2.0f))), numVarY(((uint)ceil(dimension/2.0f))),
 | 
				
			||||||
		numFieldX((uint)pow(2,(float)numVarX)), numFieldY((uint)pow(2,(float)numVarY)),
 | 
							numFieldX((uint)pow(2,(float)numVarX)), numFieldY((uint)pow(2,(float)numVarY)),
 | 
				
			||||||
| 
						 | 
					@ -31,7 +32,7 @@ public:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	PrimImplikantCollection* globalPic;
 | 
						PrimImplikantCollection* globalPic;
 | 
				
			||||||
	vector<Cell*> allCells;
 | 
						CellCollection allCells;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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
 | 
				
			||||||
| 
						 | 
					@ -54,6 +55,7 @@ private:
 | 
				
			||||||
	void Text(uint x, uint y, uint size, int color, int bkcolor, int angle, int align, char* theText);									// Zeichnet einen Text mit Offset
 | 
						void Text(uint x, uint y, uint size, int color, int bkcolor, int angle, int align, char* theText);									// Zeichnet einen Text mit Offset
 | 
				
			||||||
	void KV::TextBox(uint x1, uint y1, uint x2, uint y2, uint size, int ctext, int cframe, int cfill, int flags, char* theText);		// Zeichnet eine TextBox mit Offset
 | 
						void KV::TextBox(uint x1, uint y1, uint x2, uint y2, uint size, int ctext, int cframe, int cfill, int flags, char* theText);		// Zeichnet eine TextBox mit Offset
 | 
				
			||||||
	void KV::TextBoxBold(uint x1, uint y1, uint x2, uint y2, uint size, int ctext, int cframe, int cfill, int flags, char* theText);		// Zeichnet eine TextBox mit Offset und fetter Schrift
 | 
						void KV::TextBoxBold(uint x1, uint y1, uint x2, uint y2, uint size, int ctext, int cframe, int cfill, int flags, char* theText);		// Zeichnet eine TextBox mit Offset und fetter Schrift
 | 
				
			||||||
 | 
						void KV::Rechteck(uint x1, uint y1, uint x2, uint y2, int cframe, int cfill);		// Zeichnet ein Rechteck mit Offset und fetter Schrift
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char* Binary(uint x, char length);	// Wie itoa(x, char[], 2), allerdings mit fester Breite
 | 
						char* Binary(uint x, char length);	// Wie itoa(x, char[], 2), allerdings mit fester Breite
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,9 +2,9 @@
 | 
				
			||||||
#include <vector>
 | 
					#include <vector>
 | 
				
			||||||
#include <string>
 | 
					#include <string>
 | 
				
			||||||
#include <iostream>
 | 
					#include <iostream>
 | 
				
			||||||
#include "Cell.h"
 | 
					 | 
				
			||||||
#include "PrimImplikant.h"
 | 
					#include "PrimImplikant.h"
 | 
				
			||||||
#include "Cell.h"
 | 
					#include "Cell.h"
 | 
				
			||||||
 | 
					#include "CellCollection.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
using namespace std;
 | 
					using namespace std;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,7 +16,7 @@ class Wertetabelle
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	void Print();
 | 
						void Print();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Wertetabelle(vector<Cell*>* cells, vector<string>* variables)
 | 
						Wertetabelle(CellCollection* cells, vector<string>* variables)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this->cells = cells;
 | 
							this->cells = cells;
 | 
				
			||||||
		this->variables = variables;
 | 
							this->variables = variables;
 | 
				
			||||||
| 
						 | 
					@ -28,7 +28,7 @@ private:
 | 
				
			||||||
	void printI(unsigned int i);
 | 
						void printI(unsigned int i);
 | 
				
			||||||
	void printPrimImplikanten(unsigned int i);
 | 
						void printPrimImplikanten(unsigned int i);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vector<Cell*>* cells;
 | 
						CellCollection* cells;
 | 
				
			||||||
	vector<string>* variables;
 | 
						vector<string>* variables;
 | 
				
			||||||
	vector<float> padding;
 | 
						vector<float> padding;
 | 
				
			||||||
	uint width;
 | 
						uint width;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue