From 4859798b1129b43172e2ee100221ecbd9e15143f Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Mon, 24 Oct 2011 16:48:39 +0200 Subject: [PATCH] mac osx is not supported (due to libpng++), removed a lot of warnings --- Attractor.cpp | 6 ++-- Attractor.hpp | 10 ++++-- AttractorKernel.hpp | 3 ++ AwesomeAttract0r.xcodeproj/project.pbxproj | 6 ++-- Projector.hpp | 3 ++ canvae/PNG.hpp | 36 ++++++++++++++++------ canvae/Raw.cpp | 10 ++++-- canvae/Raw.hpp | 4 +++ canvae/libpng.hpp | 35 +++++++++++++++++++++ projectors/Normalizer.cpp | 2 ++ projectors/Normalizer.hpp | 4 +++ 11 files changed, 99 insertions(+), 20 deletions(-) create mode 100644 canvae/libpng.hpp diff --git a/Attractor.cpp b/Attractor.cpp index 8cf2b80..2d44807 100644 --- a/Attractor.cpp +++ b/Attractor.cpp @@ -7,8 +7,10 @@ #include "AttractorKernel.hpp" #include "Projector.hpp" -Attractor::Attractor() : - kernel(0), projector(0) { +Attractor::Attractor() + : projector(0) + , kernel(0) + { stfu::node kernel_node; switch(rand()%2+1){ case 0: diff --git a/Attractor.hpp b/Attractor.hpp index afb4530..9ba5a4a 100644 --- a/Attractor.hpp +++ b/Attractor.hpp @@ -14,12 +14,15 @@ public: // should be private really Projector* projector; - Attractor(const std::string& filename) { + Attractor(const std::string& filename) + : projector(0) + , kernel(0) + { LogInfo("Reading file '%s'...\n", filename.c_str()); stfu::node system; if(!system.read(filename.c_str())){ - std::cerr << "Couldn't open file(" << filename << ") for reading\n"; + std::cerr << "Couldn't open file (" << filename << ") for reading\n"; exit(-1); } @@ -75,6 +78,9 @@ public: private: AttractorKernel* kernel; + + Attractor(Attractor const &); + Attractor& operator=(Attractor const &); }; #endif // ATTRACTOR_HPP diff --git a/AttractorKernel.hpp b/AttractorKernel.hpp index 228d3a0..fea06e8 100644 --- a/AttractorKernel.hpp +++ b/AttractorKernel.hpp @@ -140,6 +140,9 @@ private: delete[] parameters; parameters = NULL; } + + AttractorKernel(AttractorKernel const &); + AttractorKernel & operator=(AttractorKernel const &); }; diff --git a/AwesomeAttract0r.xcodeproj/project.pbxproj b/AwesomeAttract0r.xcodeproj/project.pbxproj index 3f89e97..48e6894 100644 --- a/AwesomeAttract0r.xcodeproj/project.pbxproj +++ b/AwesomeAttract0r.xcodeproj/project.pbxproj @@ -13,7 +13,6 @@ 01C5701513B63AF0009D151B /* Attractor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5701113B63AF0009D151B /* Attractor.cpp */; }; 01C5702913B63B56009D151B /* Raw.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5702813B63B56009D151B /* Raw.cpp */; }; 01C5703213B63B78009D151B /* stf.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5703113B63B78009D151B /* stf.cpp */; }; - 01C5703813B63B90009D151B /* pngwriter.cc in Sources */ = {isa = PBXBuildFile; fileRef = 01C5703713B63B90009D151B /* pngwriter.cc */; }; 01C5704313B63BBE009D151B /* Projection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5704013B63BBE009D151B /* Projection.cpp */; }; 01C5704413B63BBE009D151B /* Normalizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 01C5704213B63BBE009D151B /* Normalizer.cpp */; }; 01C5707E13B63CF9009D151B /* libpng.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 01C5707D13B63CF9009D151B /* libpng.a */; }; @@ -52,7 +51,6 @@ 01C5702813B63B56009D151B /* Raw.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Raw.cpp; path = canvae/Raw.cpp; sourceTree = ""; }; 01C5703013B63B78009D151B /* stf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = stf.hpp; path = stfu/stf.hpp; sourceTree = ""; }; 01C5703113B63B78009D151B /* stf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stf.cpp; path = stfu/stf.cpp; sourceTree = ""; }; - 01C5703713B63B90009D151B /* pngwriter.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pngwriter.cc; path = pngwriter/pngwriter.cc; sourceTree = ""; }; 01C5703913B63BA3009D151B /* Unravel3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Unravel3D.hpp; path = kernels/Unravel3D.hpp; sourceTree = ""; }; 01C5703A13B63BA3009D151B /* PolynomialA3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PolynomialA3D.hpp; path = kernels/PolynomialA3D.hpp; sourceTree = ""; }; 01C5703B13B63BA3009D151B /* Polynomial.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Polynomial.hpp; path = kernels/Polynomial.hpp; sourceTree = ""; }; @@ -65,6 +63,7 @@ 01C5704213B63BBE009D151B /* Normalizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Normalizer.cpp; path = projectors/Normalizer.cpp; sourceTree = ""; }; 01C5707D13B63CF9009D151B /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = /usr/local/lib/libpng.a; sourceTree = ""; }; 08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; + 420486591455B11C0025CC53 /* libpng.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = libpng.hpp; path = canvae/libpng.hpp; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -106,6 +105,7 @@ 08FB7794FE84155DC02AAC07 /* AwesomeAttract0r */ = { isa = PBXGroup; children = ( + 420486591455B11C0025CC53 /* libpng.hpp */, 01C5703F13B63BBE009D151B /* Projection.hpp */, 01C5704013B63BBE009D151B /* Projection.cpp */, 01C5704113B63BBE009D151B /* Normalizer.hpp */, @@ -137,7 +137,6 @@ 01C5700E13B63AF0009D151B /* AwesomeAttractorConfig.h */, 01C5701013B63AF0009D151B /* Attractor.hpp */, 01C5701113B63AF0009D151B /* Attractor.cpp */, - 01C5703713B63B90009D151B /* pngwriter.cc */, 08FB7796FE84155DC02AAC07 /* main.cpp */, ); name = Source; @@ -215,7 +214,6 @@ 01C5701513B63AF0009D151B /* Attractor.cpp in Sources */, 01C5702913B63B56009D151B /* Raw.cpp in Sources */, 01C5703213B63B78009D151B /* stf.cpp in Sources */, - 01C5703813B63B90009D151B /* pngwriter.cc in Sources */, 01C5704313B63BBE009D151B /* Projection.cpp in Sources */, 01C5704413B63BBE009D151B /* Normalizer.cpp in Sources */, ); diff --git a/Projector.hpp b/Projector.hpp index 6a0bf01..4af3693 100644 --- a/Projector.hpp +++ b/Projector.hpp @@ -71,6 +71,9 @@ private: delete[] projectedColor; projectedColor = NULL; } + + Projector(Projector const &); + Projector & operator=(Projector const &); }; #endif // PROJECTOR_HPP diff --git a/canvae/PNG.hpp b/canvae/PNG.hpp index 4500ce5..052b797 100644 --- a/canvae/PNG.hpp +++ b/canvae/PNG.hpp @@ -4,9 +4,18 @@ #include #include #include -#include +#include + +#ifndef __APPLE__ + #include +#else + #include + namespace std { + using tr1::array; + } +#endif -#include +#include "libpng.hpp" #include "../Canvas.hpp" @@ -22,8 +31,13 @@ public: double v; - PNG(unsigned int width, unsigned int height, unsigned int num_colors = 1): - Canvas(2), width(width), height(height), num_colors(num_colors), v(0) { + PNG(unsigned int width, unsigned int height, unsigned int num_colors = 1) + : Canvas(2) + , width(width) + , height(height) + , num_colors(num_colors) + , int_array(0) + , v(2.0) { //int_array = std::make_shared>(width*height*num_colors); int_array = new unsigned int[width*height*num_colors]; @@ -80,7 +94,7 @@ public: const double average = cumulative / (double)(width*height); - power[i] = -2.5/log(average/(double)max_int[i]); + power[i] = -2.5/std::log(average/(double)max_int[i]); if(power[i] < 0) { power[i] = 1; LogInfo("negative power\n"); @@ -92,7 +106,7 @@ public: } } - const double vibrancy = 2.0; + const double vibrancy = v; double averagePower = 0; for(unsigned int i = 0; i < num_colors; i++) { averagePower += power[i]; @@ -125,9 +139,9 @@ public: double b = 0.0; for(unsigned int c = 0; c < num_colors; c++) { const double norm_value = (double)int_array[x + y*width + c*width*height]/max_int[c]; - r += (pow(norm_value, power[c]*power_matrix[c+0]))*output_matrix[c+0]; - g += (pow(norm_value, power[c]*power_matrix[c+2]))*output_matrix[c+2]; - b += (pow(norm_value, power[c]*power_matrix[c+4]))*output_matrix[c+4]; + r += (std::pow(norm_value, power[c]*power_matrix[c+0]))*output_matrix[c+0]; + g += (std::pow(norm_value, power[c]*power_matrix[c+2]))*output_matrix[c+2]; + b += (std::pow(norm_value, power[c]*power_matrix[c+4]))*output_matrix[c+4]; } // TODO: also clamp is below 0 ? r = std::min(1.0, r); @@ -145,6 +159,10 @@ public: LogMoreInfo("File written"); } + +private: + PNG(PNG const &); + PNG & operator=(PNG const &); }; #endif // PNG_HPP diff --git a/canvae/Raw.cpp b/canvae/Raw.cpp index a3998ef..999ac5d 100644 --- a/canvae/Raw.cpp +++ b/canvae/Raw.cpp @@ -10,8 +10,13 @@ #include "Raw.hpp" -Raw::Raw(const unsigned int dimension, const unsigned int* sizes_): - Canvas(dimension) { +Raw::Raw(const unsigned int dimension, const unsigned int* sizes_) + : Canvas(dimension) + , sizes(0) + , sizesMultiplied(0) + , pixelArray(0) + , arraySize(1) + { sizes = new unsigned int[dimension]; assert(sizes != NULL); @@ -24,7 +29,6 @@ Raw::Raw(const unsigned int dimension, const unsigned int* sizes_): sizesMultiplied[i] = sizesMultiplied[i-1]*sizes[i-1]; } - arraySize = 1; for(unsigned int i = 0; i < dimension; ++i) { arraySize *= sizes[i]; } diff --git a/canvae/Raw.hpp b/canvae/Raw.hpp index 88de53b..ed2b4bf 100644 --- a/canvae/Raw.hpp +++ b/canvae/Raw.hpp @@ -16,6 +16,10 @@ public: virtual void clear(); virtual void plot(const double* normalizedPosition); virtual void output_file(const char* filename) const; + +private: + Raw(Raw const &); + Raw & operator=(Raw const &); }; diff --git a/canvae/libpng.hpp b/canvae/libpng.hpp new file mode 100644 index 0000000..b4685b9 --- /dev/null +++ b/canvae/libpng.hpp @@ -0,0 +1,35 @@ +// +// libpng.hpp +// AwesomeAttract0r +// +// Created by Joshua Moerman on 10/24/11. +// Copyright 2011 Vadovas. All rights reserved. +// + +#ifndef AwesomeAttract0r_libpng_hpp +#define AwesomeAttract0r_libpng_hpp + +#ifndef __APPLE__ +#include +#else +#warning PNG++ is not yet supported +namespace png { + template + struct image{ + image(unsigned int, unsigned int){} + + image& operator[](unsigned int){return *this;} + + template + image& operator=(S const &){return *this;} + + void write(std::string const &){} + }; + + struct rgb_pixel{ + rgb_pixel(unsigned int, unsigned int, unsigned int){} + }; +} +#endif + +#endif diff --git a/projectors/Normalizer.cpp b/projectors/Normalizer.cpp index 6805af0..ceb7aa0 100644 --- a/projectors/Normalizer.cpp +++ b/projectors/Normalizer.cpp @@ -1,3 +1,5 @@ +#include + #include "../Logger.hpp" #include "Normalizer.hpp" diff --git a/projectors/Normalizer.hpp b/projectors/Normalizer.hpp index b943c91..3ff6c33 100644 --- a/projectors/Normalizer.hpp +++ b/projectors/Normalizer.hpp @@ -24,6 +24,10 @@ protected: public: Normalizer(unsigned int dimension); virtual ~Normalizer(); + +private: + Normalizer(Normalizer const &); + Normalizer & operator=(Normalizer const &); }; #endif // NORMALIZER_HPP