You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
134 lines
3.5 KiB
134 lines
3.5 KiB
15 years ago
|
#include <iostream>
|
||
|
using namespace std;
|
||
|
|
||
|
#include "Attractor.hpp"
|
||
|
#include "Canvas.hpp"
|
||
|
#include "Projector.hpp"
|
||
|
|
||
|
#include "AttractorKernel.hpp"
|
||
|
#include "kernels/Lorenz.hpp"
|
||
|
|
||
|
// TODO : Allemaal files inlezen, voor makkelijker gebruik
|
||
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
|
||
|
|
||
|
AttractorKernel * mijnAttractortje;
|
||
|
mijnAttractortje = new Lorenz();
|
||
|
AttractorKernel &attractor = *mijnAttractortje;
|
||
|
|
||
|
attractor.parameter(0) = 1.0;
|
||
|
attractor.parameter(2) = 2.0;
|
||
|
|
||
|
double * & vector = attractor.vector();
|
||
|
|
||
|
unsigned int * _dimension = (unsigned int*)mijnAttractortje->getProperty("dimension");
|
||
|
unsigned int dimension = *_dimension;
|
||
|
delete _dimension;
|
||
|
|
||
|
cout << "Dimension = " << dimension << endl;
|
||
|
|
||
|
for ( unsigned int i = 0; i < 20; i++ ) {
|
||
|
mijnAttractortje->iterate();
|
||
|
cout << "vector = ";
|
||
|
for ( unsigned int i = 0; i < dimension; i++ ) {
|
||
|
cout << " " << vector[i];
|
||
|
}
|
||
|
cout << endl;
|
||
|
}
|
||
|
|
||
|
|
||
|
/*if ( argc <= 2 ) {
|
||
|
cout << endl << "nothing to do..." << endl;
|
||
|
cout << "usage:" << endl;
|
||
|
cout << " rendering to canvas: -a my_attractor.attr 500000000 my_attractor.canv 800 600 3" << endl;
|
||
|
cout << " canvas to png: -c my_attractor.canv 800 600 3 my_atttractor.png" << endl << endl;
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
int mode;
|
||
|
string argv1 = argv[1];
|
||
|
if ( argv1 == "-a" ) {
|
||
|
cout << "rendermode" << endl;
|
||
|
mode = 1;
|
||
|
} else if ( argv1 == "-c" ) {
|
||
|
cout << "canvasmode" << endl;
|
||
|
mode = 2;
|
||
|
} else {
|
||
|
cout << "i do.. i do... i do not understand... \"" << argv1 << "\""<< endl;
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
switch ( mode ) {
|
||
|
case 1: {
|
||
|
if ( argc != 8 ) {
|
||
|
cout << "all parameters must be set..." << endl;
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
string attractorFile = argv[2];
|
||
|
unsigned int iterations = atoi(argv[3]);
|
||
|
string canvasFile = argv[4];
|
||
|
unsigned int width = atoi(argv[5]);
|
||
|
unsigned int height = atoi(argv[6]);
|
||
|
unsigned int numColors = atoi(argv[7]);
|
||
|
|
||
|
Attractor attract(attractorFile.c_str());
|
||
|
cout << attractorFile << " is read" << endl;
|
||
|
|
||
|
Projector projection;
|
||
|
Canvas canvas(width, height, numColors);
|
||
|
projection.canvas = &canvas;
|
||
|
|
||
|
attract.projectors.push_back(&projection);
|
||
|
attract.init_range();
|
||
|
|
||
|
projection.output();
|
||
|
|
||
|
for ( unsigned int j = 1; j <= 100; j++ ) {
|
||
|
for ( unsigned int i = 0; 100*i <= iterations; i++ ) {
|
||
|
attract.iterate();
|
||
|
attract.plot();
|
||
|
}
|
||
|
cout << j << "% done" << endl;
|
||
|
}
|
||
|
|
||
|
canvas.output_raw(canvasFile.c_str());
|
||
|
cout << canvasFile << " is outputted" << endl;
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
case 2: {
|
||
|
if ( argc != 7 ) {
|
||
|
cout << "all parameters must be set..." << endl;
|
||
|
exit(0);
|
||
|
}
|
||
|
|
||
|
string canvasFile = argv[2];
|
||
|
unsigned int width = atoi(argv[3]);
|
||
|
unsigned int height = atoi(argv[4]);
|
||
|
unsigned int numColors = atoi(argv[5]);
|
||
|
string pngFile = argv[6];
|
||
|
|
||
|
Canvas canvas(width, height, numColors);
|
||
|
canvas.input_raw(canvasFile.c_str());
|
||
|
cout << canvasFile << " is read" << endl;
|
||
|
for ( double v = -1.5; v < 1.6; v += 1.5 ) {
|
||
|
canvas.v = v;
|
||
|
canvas.output_file();
|
||
|
}
|
||
|
cout << pngFile << " was exported" << endl;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
default: {
|
||
|
cout << "WTF" << endl;
|
||
|
break;
|
||
|
}
|
||
|
}*/
|
||
|
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|