Browse Source

mac osx is not supported (due to libpng++), removed a lot of warnings

master
Joshua Moerman 13 years ago
parent
commit
4859798b11
  1. 6
      Attractor.cpp
  2. 10
      Attractor.hpp
  3. 3
      AttractorKernel.hpp
  4. 6
      AwesomeAttract0r.xcodeproj/project.pbxproj
  5. 3
      Projector.hpp
  6. 36
      canvae/PNG.hpp
  7. 10
      canvae/Raw.cpp
  8. 4
      canvae/Raw.hpp
  9. 35
      canvae/libpng.hpp
  10. 2
      projectors/Normalizer.cpp
  11. 4
      projectors/Normalizer.hpp

6
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:

10
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

3
AttractorKernel.hpp

@ -140,6 +140,9 @@ private:
delete[] parameters;
parameters = NULL;
}
AttractorKernel(AttractorKernel const &);
AttractorKernel & operator=(AttractorKernel const &);
};

6
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 = "<group>"; };
01C5703013B63B78009D151B /* stf.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = stf.hpp; path = stfu/stf.hpp; sourceTree = "<group>"; };
01C5703113B63B78009D151B /* stf.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = stf.cpp; path = stfu/stf.cpp; sourceTree = "<group>"; };
01C5703713B63B90009D151B /* pngwriter.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pngwriter.cc; path = pngwriter/pngwriter.cc; sourceTree = "<group>"; };
01C5703913B63BA3009D151B /* Unravel3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Unravel3D.hpp; path = kernels/Unravel3D.hpp; sourceTree = "<group>"; };
01C5703A13B63BA3009D151B /* PolynomialA3D.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PolynomialA3D.hpp; path = kernels/PolynomialA3D.hpp; sourceTree = "<group>"; };
01C5703B13B63BA3009D151B /* Polynomial.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Polynomial.hpp; path = kernels/Polynomial.hpp; sourceTree = "<group>"; };
@ -65,6 +63,7 @@
01C5704213B63BBE009D151B /* Normalizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Normalizer.cpp; path = projectors/Normalizer.cpp; sourceTree = "<group>"; };
01C5707D13B63CF9009D151B /* libpng.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpng.a; path = /usr/local/lib/libpng.a; sourceTree = "<absolute>"; };
08FB7796FE84155DC02AAC07 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
420486591455B11C0025CC53 /* libpng.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = libpng.hpp; path = canvae/libpng.hpp; sourceTree = "<group>"; };
/* 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 */,
);

3
Projector.hpp

@ -71,6 +71,9 @@ private:
delete[] projectedColor;
projectedColor = NULL;
}
Projector(Projector const &);
Projector & operator=(Projector const &);
};
#endif // PROJECTOR_HPP

36
canvae/PNG.hpp

@ -4,9 +4,18 @@
#include <memory>
#include <vector>
#include <cassert>
#include <array>
#include <cmath>
#ifndef __APPLE__
#include <array>
#else
#include <tr1/array>
namespace std {
using tr1::array;
}
#endif
#include <png++/png.hpp>
#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<vstd::vector<unsigned int>>(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

10
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];
}

4
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 &);
};

35
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 <png++/png.hpp>
#else
#warning PNG++ is not yet supported
namespace png {
template <typename T>
struct image{
image(unsigned int, unsigned int){}
image& operator[](unsigned int){return *this;}
template <typename S>
image& operator=(S const &){return *this;}
void write(std::string const &){}
};
struct rgb_pixel{
rgb_pixel(unsigned int, unsigned int, unsigned int){}
};
}
#endif
#endif

2
projectors/Normalizer.cpp

@ -1,3 +1,5 @@
#include <cmath>
#include "../Logger.hpp"
#include "Normalizer.hpp"

4
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