Browse Source

3d raw output working (other stuff not any more ;D)

master
unknown 14 years ago
parent
commit
972ccfd30a
  1. 2
      Attractor.cpp
  2. 63
      AwesomeAttractor.cbp
  3. 33
      Projector.cpp
  4. 15
      canvae/Raw.cpp
  5. 2
      canvae/Raw.hpp
  6. 22
      main.cpp

2
Attractor.cpp

@ -38,7 +38,7 @@ void Attractor::init_range() {
const double * point = myAttractor->vector();
for ( std::vector<Projector*>::iterator it = projectors.begin(); it != projectors.end(); it++ ) {
(*it)->extern_dim = dimension;
(*it)->intern_dim = 2;
(*it)->intern_dim = 3;
(*it)->init(point);
}

63
AwesomeAttractor.cbp

@ -7,8 +7,8 @@
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option output="bin\Debug\AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
@ -20,8 +20,8 @@
</Linker>
</Target>
<Target title="Release">
<Option output="bin/Release/AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option output="bin\Release\AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
@ -33,8 +33,8 @@
</Linker>
</Target>
<Target title="UniRelease">
<Option output="bin/UniRelease/AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/UniRelease/" />
<Option output="bin\UniRelease\AwesomeAttractor" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\UniRelease\" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
@ -52,9 +52,6 @@
<Add option="-Wall" />
<Add option="-Wno-unknown-pragmas" />
</Compiler>
<Linker>
<Add library="libpng" />
</Linker>
<Unit filename="Attractor.cpp" />
<Unit filename="Attractor.hpp" />
<Unit filename="AttractorKernel.cpp" />
@ -65,27 +62,39 @@
<Unit filename="Projector.hpp">
<Option compilerVar="CC" />
</Unit>
<Unit filename="attractors/testAttractor.stf" />
<Unit filename="attractors/testLorenz.stf" />
<Unit filename="attractors/testPolynomial.stf" />
<Unit filename="attractors/testUnravel.stf" />
<Unit filename="attractors\testAttractor.stf" />
<Unit filename="attractors\testLorenz.stf" />
<Unit filename="attractors\testPolynomial.stf" />
<Unit filename="attractors\testUnravel.stf" />
<Unit filename="canvae\PNG.cpp">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="canvae\PNG.hpp">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="canvae\Raw.cpp" />
<Unit filename="canvae\Raw.hpp" />
<Unit filename="defines.hpp" />
<Unit filename="kernels/Logistic.cpp" />
<Unit filename="kernels/Logistic.hpp" />
<Unit filename="kernels/Lorenz3D.cpp" />
<Unit filename="kernels/Lorenz3D.hpp" />
<Unit filename="kernels/Polynomial.cpp" />
<Unit filename="kernels/Polynomial.hpp" />
<Unit filename="kernels/PolynomialA3D.cpp" />
<Unit filename="kernels/PolynomialA3D.hpp" />
<Unit filename="kernels/Unravel3D.cpp" />
<Unit filename="kernels/Unravel3D.hpp" />
<Unit filename="kernels\Logistic.cpp" />
<Unit filename="kernels\Logistic.hpp" />
<Unit filename="kernels\Lorenz3D.cpp" />
<Unit filename="kernels\Lorenz3D.hpp" />
<Unit filename="kernels\Polynomial.cpp" />
<Unit filename="kernels\Polynomial.hpp" />
<Unit filename="kernels\PolynomialA3D.cpp" />
<Unit filename="kernels\PolynomialA3D.hpp" />
<Unit filename="kernels\Unravel3D.cpp" />
<Unit filename="kernels\Unravel3D.hpp" />
<Unit filename="main.cpp" />
<Unit filename="myMath.hpp" />
<Unit filename="pngwriter/pngwriter.cc" />
<Unit filename="pngwriter/pngwriter.h" />
<Unit filename="stfu/stf.cpp" />
<Unit filename="stfu/stf.hpp" />
<Unit filename="pngwriter\pngwriter.cc">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="pngwriter\pngwriter.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="stfu\stf.cpp" />
<Unit filename="stfu\stf.hpp" />
<Extensions>
<code_completion />
<envvars />

33
Projector.cpp

@ -45,31 +45,16 @@ void Projector::update_range(const double * point) {
}
void Projector::finish_range() {
// double max_dist = 0.0;
// for ( unsigned int i = 0; i < intern_dim; i++ ) {
// const double dist = range_max[i] - range_min[i];
// if ( dist > max_dist )
// max_dist = dist;
// }
//
// factor = 0.9/max_dist;
// for ( unsigned int i = 0; i < intern_dim; i++ ) {
// offset[i] = -0.5*factor*(range_min[i] + range_max[i]);
// }
factor = canvas->size[0] / (range_max[0] - range_min[0]);
unsigned int teh_size = canvas->size[0];
factor = 2.0 / (range_max[0] - range_min[0]);
for ( unsigned int i = 1; i < intern_dim; i++ ) {
double dist = range_max[i] - range_min[i];
if ( factor * dist > (double)canvas->size[i] ) {
factor = (double)canvas->size[i] / dist;
if ( factor * dist > 2.0 ) {
factor = 2.0 / dist;
//teh_size = canvas->size[i];
LogDebug("Crap for dimension %d\n", i);
}
}
factor /= (double)teh_size;
for ( unsigned int i = 0; i < intern_dim; i++ ) {
offset[i] = -0.5*factor*(range_min[i] + range_max[i]);
}
@ -77,9 +62,10 @@ void Projector::finish_range() {
void Projector::project(const double * point) {
assert(extern_dim >= 2);
//assert(extern_dim >= 2);
project_point[0] = point[0];
project_point[1] = point[1];
project_point[2] = point[2];
}
@ -88,12 +74,11 @@ void Projector::plot(const double * point) {
const double x = project_point[0]*factor + offset[0];
const double y = project_point[1]*factor + offset[1];
const double z = project_point[2]*factor + offset[2];
double position[] = {x,y,z};
canvas->plot(x, y);
if ( even(point[2]*17) )
canvas->plot(x, y, 1);
if ( even(point[2]*17+0.6) )
canvas->plot(x, y, 2);
canvas->plot(position);
}

15
canvae/Raw.cpp

@ -24,7 +24,10 @@ Raw::Raw (const unsigned int dimension, const unsigned int* sizes_):
sizesMultiplied[i] = sizesMultiplied[i-1]*sizes[i-1];
}
arraySize = std::accumulate(sizes, sizes + dimension, multiplies<unsigned int>);
arraySize = 1;
for ( unsigned int i = 0; i < dimension; ++i ) {
arraySize *= sizes[i];
}
pixelArray = new unsigned int[arraySize];
assert(pixelArray != NULL);
@ -37,14 +40,14 @@ void Raw::clear() {
std::fill_n(pixelArray, arraySize, 0);
}
void Raw::plot(double * position) {
void Raw::plot(const double * position) {
unsigned int index = 0;
for ( unsigned int i = 0; i < dimension; ++i ) {
index += (position[i]*sizes[i] + 0.5*sizes[i])*sizesMultiplied[i];
index += (unsigned int)(position[i]*sizes[i] + 0.5*sizes[i])*sizesMultiplied[i];
}
if(index < arraySize) {
int_array[index]++;
pixelArray[index]++;
}
}
@ -52,7 +55,7 @@ void Raw::plot(double * position) {
I/O functions
*/
void Raw::output_file(const char * filename){
void Raw::output_file(const char * filename) const{
std::ofstream outfile (filename, std::ofstream::binary);
outfile.write(reinterpret_cast<char*>(int_array), sizeof(unsigned int)*width*height*num_colors);
outfile.write(reinterpret_cast<char*>(pixelArray), sizeof(unsigned int)*arraySize);
}

2
canvae/Raw.hpp

@ -5,7 +5,7 @@
class Raw : public Canvas {
unsigned int * sizes;
unsigned int sizesMultiplied;
unsigned int * sizesMultiplied;
unsigned int * pixelArray;
unsigned int arraySize;

22
main.cpp

@ -8,21 +8,13 @@
#include "Canvas.hpp"
#include "Projector.hpp"
#include "canvae\Raw.hpp"
#include "defines.hpp"
int verbose;
/*
char filename[50];
time_t t = time(0);
struct tm* lt = localtime(&t);
int r = rand() % 10;
sprintf(filename, "render/attractor_%04d-%02d-%02d_%02d-%02d-%02d-%01d.png", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, r);
*/
void showHelpText(){
std::cout << "Awesome Attractor, version " << __DATE__ << std::endl;
std::cout << "Usage: AwesomeAttractor [OPTION]... FILE" << std::endl << std::endl;
@ -76,7 +68,7 @@ int main(int argc, char *argv[]) {
Projector projection;
unsigned int sizes[] = {128, 128, 128};
Canvas* canvas = new Raw(3, sizes);
projection.canvas = &canvas;
projection.canvas = canvas;
myAttractor.projectors.push_back(&projection);
myAttractor.init_range();
@ -104,8 +96,14 @@ int main(int argc, char *argv[]) {
LogMoreInfo("Average iterations per second: %f\n\n", totalIterations/totalTime);
// saving output
char filename[50];
time_t t = time(0);
struct tm* lt = localtime(&t);
int r = rand() % 10;
sprintf(filename, "render/attractor_%04d-%02d-%02d_%02d-%02d-%02d-%01d.raw", lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, r);
start = clock();
canvas.output_file();
canvas->output_file(filename);
end = clock();
totalTime = ((double)(end-start)/(double)(CLOCKS_PER_SEC));