2014-07-08 03:11:14 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "FractoriumPch.h"
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// EmberFile class.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Class for representing an ember Xml file in memory.
|
|
|
|
/// It contains a filename and a vector of embers.
|
|
|
|
/// It also provides static helper functions for creating
|
|
|
|
/// default names for the file and the embers in it.
|
|
|
|
/// </summary>
|
|
|
|
template <typename T>
|
|
|
|
class EmberFile
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// <summary>
|
|
|
|
/// Empty constructor that does nothing.
|
|
|
|
/// </summary>
|
|
|
|
EmberFile()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Default copy constructor.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="emberFile">The EmberFile object to copy</param>
|
|
|
|
EmberFile(const EmberFile<T>& emberFile)
|
|
|
|
{
|
|
|
|
EmberFile<T>::operator=<T>(emberFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Copy constructor to copy an EmberFile object of type U.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="emberFile">The EmberFile object to copy</param>
|
|
|
|
template <typename U>
|
|
|
|
EmberFile(const EmberFile<U>& emberFile)
|
|
|
|
{
|
|
|
|
EmberFile<T>::operator=<U>(emberFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Default assignment operator.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="emberFile">The EmberFile object to copy</param>
|
|
|
|
EmberFile<T>& operator = (const EmberFile<T>& emberFile)
|
|
|
|
{
|
|
|
|
if (this != &emberFile)
|
|
|
|
EmberFile<T>::operator=<T>(emberFile);
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Assignment operator to assign a EmberFile object of type U.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="emberFile">The EmberFile object to copy.</param>
|
|
|
|
/// <returns>Reference to updated self</returns>
|
|
|
|
template <typename U>
|
|
|
|
EmberFile<T>& operator = (const EmberFile<U>& emberFile)
|
|
|
|
{
|
|
|
|
m_Filename = emberFile.m_Filename;
|
|
|
|
CopyVec(m_Embers, emberFile.m_Embers);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Clear the file name and the vector of embers.
|
|
|
|
/// </summary>
|
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
m_Filename.clear();
|
|
|
|
m_Embers.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Ensure all ember names are unique.
|
|
|
|
/// </summary>
|
|
|
|
void MakeNamesUnique()
|
|
|
|
{
|
|
|
|
int x = 0;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < m_Embers.size(); i++)
|
|
|
|
{
|
|
|
|
for (size_t j = 0; j < m_Embers.size(); j++)
|
|
|
|
{
|
|
|
|
if (i != j && m_Embers[i].m_Name == m_Embers[j].m_Name)
|
|
|
|
{
|
|
|
|
m_Embers[j].m_Name = m_Embers[j].m_Name + "_" + QString::number(++x).toStdString();
|
|
|
|
j = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Return the default filename based on the current date/time.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The default filename</returns>
|
|
|
|
static QString DefaultFilename()
|
|
|
|
{
|
|
|
|
return "Flame_" + QDateTime(QDateTime::currentDateTime()).toString("yyyy-MM-dd-hhmmss");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Ensures a given input filename is unique by appending a count to the end.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>The passed in name if it was unique, else a uniquely made name.</returns>
|
|
|
|
static QString UniqueFilename(QString& filename)
|
|
|
|
{
|
|
|
|
if (!QFile::exists(filename))
|
|
|
|
return filename;
|
|
|
|
|
|
|
|
int counter = 2;
|
|
|
|
QString newPath;
|
|
|
|
QFileInfo original(filename);
|
Numerous fixes
0.4.0.5 Beta 07/18/2014
--User Changes
Allow for vibrancy values > 1.
Add flatten and unflatten menu items.
Automatically flatten like Apophysis does.
Add plugin and new_linear tags to Xml to be compatible with Apophysis.
--Bug Fixes
Fix blur, blur3d, bubble, cropn, cross, curl, curl3d, epispiral, ho,
julia3d, julia3dz, loonie, mirror_x, mirror_y, mirror_z, rotate_x,
sinusoidal, spherical, spherical3d, stripes.
Unique filename on final render was completely broken.
Two severe OpenCL bugs. Random seeds were biased and fusing was being
reset too often leading to results that differ from the CPU.
Subtle, but sometimes severe bug in the setup of the xaos weights.
Use properly defined epsilon by getting the value from
std::numeric_limits, rather than hard coding 1e-6 or 1e-10.
Omit incorrect usage of epsilon everywhere. It should not be
automatically added to denominators. Rather, it should only be used if
the denominator is zero.
Force final render progress bars to 100 on completion. Sometimes they
didn't seem to make it there.
Make variation name and params comparisons be case insensitive.
--Code Changes
Make ForEach and FindIf wrappers around std::for_each and std::find_if.
2014-07-19 02:33:18 -04:00
|
|
|
QString path = original.absolutePath() + QDir::separator();
|
2014-07-08 03:11:14 -04:00
|
|
|
QString base = original.completeBaseName();
|
|
|
|
QString extension = original.suffix();
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
Numerous fixes
0.4.0.5 Beta 07/18/2014
--User Changes
Allow for vibrancy values > 1.
Add flatten and unflatten menu items.
Automatically flatten like Apophysis does.
Add plugin and new_linear tags to Xml to be compatible with Apophysis.
--Bug Fixes
Fix blur, blur3d, bubble, cropn, cross, curl, curl3d, epispiral, ho,
julia3d, julia3dz, loonie, mirror_x, mirror_y, mirror_z, rotate_x,
sinusoidal, spherical, spherical3d, stripes.
Unique filename on final render was completely broken.
Two severe OpenCL bugs. Random seeds were biased and fusing was being
reset too often leading to results that differ from the CPU.
Subtle, but sometimes severe bug in the setup of the xaos weights.
Use properly defined epsilon by getting the value from
std::numeric_limits, rather than hard coding 1e-6 or 1e-10.
Omit incorrect usage of epsilon everywhere. It should not be
automatically added to denominators. Rather, it should only be used if
the denominator is zero.
Force final render progress bars to 100 on completion. Sometimes they
didn't seem to make it there.
Make variation name and params comparisons be case insensitive.
--Code Changes
Make ForEach and FindIf wrappers around std::for_each and std::find_if.
2014-07-19 02:33:18 -04:00
|
|
|
newPath = path + base + "_" + QString::number(counter++) + "." + extension;
|
2014-07-08 03:11:14 -04:00
|
|
|
}
|
|
|
|
while (QFile::exists(newPath));
|
|
|
|
|
|
|
|
return newPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Return the default ember name based on the current date/time and
|
|
|
|
/// the ember's index in the file.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="i">The index in the file of the ember</param>
|
|
|
|
/// <returns>The default ember name</returns>
|
|
|
|
static QString DefaultEmberName(unsigned int i)
|
|
|
|
{
|
|
|
|
return DefaultFilename() + "-" + QString::number(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString m_Filename;
|
|
|
|
vector<Ember<T>> m_Embers;
|
|
|
|
};
|