code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231
values | license stringclasses 13
values | size int64 1 2.01M |
|---|---|---|---|---|---|
#pragma once
#include "Log.hpp"
#include "RecordFile.hpp"
namespace zzz{
// Auto select
class IOObj
{
public:
template<typename T>
static void WriteFileB(FILE *fp, const T *src, zsize size) {
IOObject<T>::WriteFileB(fp, src, size);
}
template<typename T>
static void ReadFileB(FILE *fp, T *d... | zzz-engine | zzzEngine/zCore/zCore/Utility/IOObject.hpp | C++ | gpl3 | 11,820 |
#pragma once
#include <zCoreConfig.hpp>
#include <string>
#include "Log.hpp"
#include "IOObject.hpp"
#include "../Math/Math.hpp"
namespace zzz {
#ifdef ZZZ_STLSTRING
class STLString : public std::string {
public:
typedef std::string::iterator iterator;
typedef std::string::reverse_iterator reverse_iter... | zzz-engine | zzzEngine/zCore/zCore/Utility/STLString.hpp | C++ | gpl3 | 10,389 |
#pragma once
#include <common.hpp>
namespace zzz {
class Timer
{
public:
Timer():pauseTime_(0),paused_(false) { startTime_ = clock(); }
void Restart() { startTime_ = clock(); pauseTime_=0; }
void Pause() { if (!paused_) {paused_=true; pauseTime_=clock() - startTime_;} }
void Resume() { if (paused... | zzz-engine | zzzEngine/zCore/zCore/Utility/Timer.hpp | C++ | gpl3 | 926 |
#pragma once
#include <zCoreConfig.hpp>
#include <common.hpp>
#include "Tools.hpp"
namespace zzz{
inline bool StrCaseCmp(const string &str1, const string &str2) {
int len1=str1.size();
int len2=str2.size();
int i1=0,i2=0;
while(i1<len1 && i2<len2) {
if (str1[i1]!=str2[i2])
return false;
... | zzz-engine | zzzEngine/zCore/zCore/Utility/StringTools.hpp | C++ | gpl3 | 5,015 |
#pragma once
#include "Tools.hpp"
#include "IOObject.hpp"
namespace zzz{
class HasFlags
{
public:
HasFlags():flags_(0){}
bool HasFlag(int bit) const {return CheckBit(flags_,bit);}
bool HasNoFlag(int bit) const {return !CheckBit(flags_,bit);}
void SetFlag(int bit){return SetBit(flags_,bit);}
void ... | zzz-engine | zzzEngine/zCore/zCore/Utility/HasFlag.hpp | C++ | gpl3 | 573 |
#define ZCORE_SOURCE
#include "StringTools.hpp"
namespace zzz{
string Replace(const string &ori, const string &from, const string &to) {
string ret;
zuint i=0;
while(i<ori.size()) {
int x=ori.find(from, i);
if (x==string::npos) {
ret.append(ori.begin()+i,ori.end());
break;
}
... | zzz-engine | zzzEngine/zCore/zCore/Utility/StringTools.cpp | C++ | gpl3 | 8,044 |
#pragma once
#include "IOObject.hpp"
namespace zzz {
class IOFile
{
public:
template<typename T>
static bool SaveFileA(const string &filename, const T &obj) {
ZLOGV << "Saving file " << filename << "...\n";
return IOFileA<T>::SaveFile(filename, obj);
}
template<typename T>
static bool Lo... | zzz-engine | zzzEngine/zCore/zCore/Utility/IOFile.hpp | C++ | gpl3 | 2,732 |
#pragma once
namespace zzz {
template<bool> struct StaticAssert;
template<> struct StaticAssert<true> {};
} // namespace zzz | zzz-engine | zzzEngine/zCore/zCore/Utility/StaticTools.hpp | C++ | gpl3 | 131 |
#pragma once
#include <common.hpp>
#ifdef ZZZ_OS_WIN
#include <conio.h>
#endif
namespace zzz{
// Bit Check
inline bool CheckBit(const int check, const int bit){return ((check & bit)!=0)?true:false;}
inline void SetBit(int &flag, const int bit){flag |= bit;}
inline void ClearBit(int &flag, const int bit){fl... | zzz-engine | zzzEngine/zCore/zCore/Utility/Tools.hpp | C++ | gpl3 | 2,453 |
//modified from boost::any
#pragma once
#include "../common.hpp"
#include "Uncopyable.hpp"
#ifdef __GNUC__
#include <typeinfo>
#endif
namespace zzz{
//Any is NOT a template class
class Any {
public:
// Empty construct
Any():content_(0){}
// Construct from T
template<typename T>
Any(const T & ... | zzz-engine | zzzEngine/zCore/zCore/Utility/Any.hpp | C++ | gpl3 | 3,681 |
#define ZCORE_SOURCE
#include "CmdParser.hpp"
#include "StringTools.hpp"
#include "Tools.hpp"
#include "FileTools.hpp"
#include "Log.hpp"
#include <yaml-cpp/yaml.h>
namespace zzz{
ZFLAGS_SWITCH2(help, "Show Help", 'h');
ZFLAGS_SWITCH(helplong, "Show All Help");
ZFLAGS_STRING(opt_file, "", "Option filename... | zzz-engine | zzzEngine/zCore/zCore/Utility/CmdParser.cpp | C++ | gpl3 | 10,708 |
#pragma once
namespace zzz{
class Uncopyable {
protected:
Uncopyable() {}
~Uncopyable() {}
private:
Uncopyable(const Uncopyable&);
const Uncopyable& operator=(const Uncopyable&);
};
}
| zzz-engine | zzzEngine/zCore/zCore/Utility/Uncopyable.hpp | C++ | gpl3 | 205 |
#pragma once
namespace zzz {
//for automatically destroy
template<typename T>
class SingletonDestroyer
{
public:
SingletonDestroyer():obj(0){}
~SingletonDestroyer(){delete obj;}
T *obj;
};
template<typename T>
class Singleton
{
public:
static T& Instance()
{
if (instance_ == 0)
... | zzz-engine | zzzEngine/zCore/zCore/Utility/Singleton.hpp | C++ | gpl3 | 706 |
#pragma once
#include "../common.hpp"
namespace zzz{
template <typename T>
struct ObjectCounter {
static size_t count_;
ObjectCounter() {++count_;}
ObjectCounter (const ObjectCounter<T> &) {++count_;}
~ObjectCounter() {--count_;}
static size_t NumOfLiving() {return count_;}
};
// initiali... | zzz-engine | zzzEngine/zCore/zCore/Utility/ObjectCounter.hpp | C++ | gpl3 | 406 |
#pragma once
#include "AutoloadCacheSet.hpp"
namespace zzz{
// It need a IndexSet<string, IDX> to provide filename, and load will call LoadFile(filename) to load object.
// The object need to implement IOData interface.
// Image is a good example.
template<typename T, typename IDX>
class ObjectCacheSet : publi... | zzz-engine | zzzEngine/zCore/zCore/Utility/ObjectCacheSet.hpp | C++ | gpl3 | 831 |
#pragma once
#include "../common.hpp"
namespace zzz{
#ifdef NO_ZCHECKPOINT
#define ZCHECKPOINT(msg) ;
#else
#define ZCHECKPOINT(msg) ZLOGI<<"*CP* "<<msg<<" at file: "<<__FILE__<<" line: "<<__LINE__<<endl;
#endif
} | zzz-engine | zzzEngine/zCore/zCore/Utility/CheckPoint.hpp | C++ | gpl3 | 227 |
#pragma once
#include <zCoreConfig.hpp>
#include <LibraryConfig.hpp>
#include "../common.hpp"
#ifdef ZZZ_LIB_BOOST
#define BOOST_FILESYSTEM_VERSION 2
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#endif
namespace zzz{
/////////////////////////////////... | zzz-engine | zzzEngine/zCore/zCore/Utility/FileTools.hpp | C++ | gpl3 | 2,660 |
#pragma once
#include <common.hpp>
namespace zzz {
template <typename T>
class zVar {
public:
zVar(const T &v):v_(v){}
friend inline ostream& operator<<(ostream& os, const zVar<T> &me) {
os<<me.v_;
return os;
}
private:
const T &v_;
};
//Use zout<<GetzVar(X) will output x only
//Use z... | zzz-engine | zzzEngine/zCore/zCore/Utility/zVar.hpp | C++ | gpl3 | 1,748 |
#define ZCORE_SOURCE
#include "Port.hpp"
#include "StringPrintf.hpp"
namespace zzz {
void StringAppendV(string &dst, const char *format, va_list ap)
{
char data[512];
va_list oldap;
va_copy(oldap, ap);
int result = vsnprintf(data, sizeof(data), format, oldap);
va_end(oldap);
if (result >= 0 &... | zzz-engine | zzzEngine/zCore/zCore/Utility/StringPrintf.cpp | C++ | gpl3 | 1,400 |
#pragma once
#include <zCoreConfig.hpp>
#include "../common.hpp"
namespace zzz {
ZCORE_FUNC string StringPrintf(const char *format, ...);
ZCORE_FUNC const string &SStringPrintf(string &dst, const char *format, ...);
ZCORE_FUNC void StringAppendF(string &dst, const char *format, ...);
} // namespace zzz
| zzz-engine | zzzEngine/zCore/zCore/Utility/StringPrintf.hpp | C++ | gpl3 | 315 |
#pragma once
#include <zCoreConfig.hpp>
#include <common.hpp>
#include "Singleton.hpp"
#include "zVar.hpp"
#include "StringTools.hpp"
namespace zzz{
/////////////////////////////////////////////////
// VerboseLevel Setter
class VerboseLevel
{
public:
static int Set(int x) {
old_=Get();
verbose... | zzz-engine | zzzEngine/zCore/zCore/Utility/Log.hpp | C++ | gpl3 | 11,332 |
#pragma once
#include "CacheSet.hpp"
#include "Log.hpp"
// It is a kind of cache set.
// The different from cache set is it will automatically load when get fails.
// Derived class should overload Load() to load correct object.
namespace zzz{
template<typename T, typename IDX=zuint>
class AutoloadCacheSet :... | zzz-engine | zzzEngine/zCore/zCore/Utility/AutoloadCacheSet.hpp | C++ | gpl3 | 826 |
#define ZCORE_SOURCE
#include "RecordFile.hpp"
#include "IOObject.hpp"
namespace zzz {
typedef pair<int, zint64> TableItem;
SIMPLE_IOOBJECT(TableItem);
RecordItem::RecordItem(FILE *fp, zint64 itebegin_pos_, RecordItem *parent)
:fp_(fp), itebegin_pos__(itebegin_pos_), child_(NULL), repeat_label_(-1), parent... | zzz-engine | zzzEngine/zCore/zCore/Utility/RecordFile.cpp | C++ | gpl3 | 8,578 |
#define ZCORE_SOURCE
#include "Thread.hpp"
#ifdef ZZZ_LIB_PTHREAD
namespace zzz{
void *__start_thread(void *p)
{
Thread *pt=(Thread*)p;
pt->running=true;
pt->Main();
pt->running=false;
// pthread_exit(NULL);
return NULL;
}
Thread::Thread()
{
running=false;
}
void Thread::Start()
{... | zzz-engine | zzzEngine/zCore/zCore/Utility/Thread.cpp | C++ | gpl3 | 1,555 |
#pragma once
#include <common.hpp>
#include "Singleton.hpp"
#include "AnyHolder.hpp"
namespace zzz{
typedef Singleton<AnyHolder> Global;
#define ZGLOBAL_ADD(v, name) zzz::Global::Instance().Add(v, name, false)
#define ZGLOBAL_GET(type, name) (zzz::Global::Instance().Get<type>(name))
#define ZGLOBAL_ISTYPE(t... | zzz-engine | zzzEngine/zCore/zCore/Utility/Global.hpp | C++ | gpl3 | 767 |
#pragma once
#include "Any.hpp"
#include "Log.hpp"
namespace zzz {
class AnyHolder
{
public:
virtual ~AnyHolder() {
Clear();
}
template<typename T>
bool Add(T v, const string &name, bool cover=false) {
if (holder_.find(name)!=holder_.end()) {
if (cover) {
Remove(name);
... | zzz-engine | zzzEngine/zCore/zCore/Utility/AnyHolder.hpp | C++ | gpl3 | 2,286 |
#pragma once
#include "IndexSet.hpp"
#include "../Math/Math.hpp"
#include "Log.hpp"
// It is a kind of indexed set.
// It will return an object based on an index.
// What's special is that it will cache some objects based on Least-Recent-Access.
// When an object is added, and cache is full, one object will de... | zzz-engine | zzzEngine/zCore/zCore/Utility/CacheSet.hpp | C++ | gpl3 | 3,249 |
#define ZCORE_SOURCE
#include "Log.hpp"
#include "CmdParser.hpp"
#include "Tools.hpp"
#ifdef ZZZ_LIB_BOOST
#include <boost/date_time/posix_time/posix_time.hpp>
#else
#include <ctime>
#endif
#include "FileTools.hpp"
#include "StringPrintf.hpp"
#include <EnvDetect.hpp>
#include <3rdParty/StackWalker.h>
#... | zzz-engine | zzzEngine/zCore/zCore/Utility/Log.cpp | C++ | gpl3 | 10,220 |
#include "Any.hpp"
#include <common.hpp>
#include "Singleton.hpp"
namespace zzz {
class AnyStack
{
public:
template<typename T>
void Push(const T &v)
{
stack_.push(Any(v));
}
template<typename T>
void Pop(T &v)
{
Top(v);
stack_.pop();
}
template<typename T>
T Po... | zzz-engine | zzzEngine/zCore/zCore/Utility/AnyStack.hpp | C++ | gpl3 | 907 |
#pragma once
#include <3rdParty/getopt.h>
#include "../common.hpp"
#include "Singleton.hpp"
#include "Global.hpp"
namespace YAML {
class Node;
}
namespace zzz{
typedef enum {CMDPARSER_NOARG=0,CMDPARSER_OPTARG=1,CMDPARSER_ONEARG=2} ArgRequirement;
class CmdParser
{
public:
~CmdParser();
void AddShort... | zzz-engine | zzzEngine/zCore/zCore/Utility/CmdParser.hpp | C++ | gpl3 | 5,761 |
#pragma once
#include "../common.hpp"
//wrap BraceItem
namespace zzz{
class BraceItem;
class BraceNode
{
public:
BraceNode(const BraceNode &node);
BraceNode(BraceItem *item,BraceItem *parent,int i);
bool IsValid() const;
BraceNode GetParent();
zuint NodeNumber() const;
BraceNode GetNode... | zzz-engine | zzzEngine/zCore/zCore/Utility/BraceNode.hpp | C++ | gpl3 | 1,409 |
#pragma once
#include "../Math/Array.hpp"
namespace zzz{
template<typename T>
class SumTable
{
public:
SumTable():ready_(false){}
SumTable(const Array<2, T> &value)
{
Prepare(value);
}
void Prepare(const Array<2, T> &value)
{
table_.SetSize(value.Size());
for (int r=0; r<table... | zzz-engine | zzzEngine/zCore/zCore/Algorithm/SumTable.hpp | C++ | gpl3 | 1,262 |
#pragma once
#include "../Math/Matrix.hpp"
#include "../Math/Vector.hpp"
//Gram-Schmidt process
//to normalize and orthogonalize a set of vectors
//based on http://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
//QR based on http://en.wikipedia.org/wiki/Qr_decomposition
namespace zzz{
template<typename ... | zzz-engine | zzzEngine/zCore/zCore/Algorithm/GramSchmidt.hpp | C++ | gpl3 | 1,263 |
#pragma once
#include "../common.hpp"
namespace zzz{
//Fibonacci Heap is a fast heap that you can insert data and extract the minimal data sequentially
//data in the heap can be decreased but never increased
//Simple Usage:
//heap.Insert(value)
//while(!heap.IsEmpty()) value=heap.ExtractMin();
///////////... | zzz-engine | zzzEngine/zCore/zCore/Algorithm/FibonacciHeap.hpp | C++ | gpl3 | 12,270 |
#pragma once
//WARNINGs
#pragma warning(disable:4244)//double to float
#pragma warning(disable:4305)//double to float
#pragma warning(disable:4267)//: 'initializing' : conversion from 'size_t' to 'uint', possible loss of data
#pragma warning(disable:4522)//multiple assignment operators specified
#pragma warning(d... | zzz-engine | zzzEngine/zCore/zCore/common.hpp | C++ | gpl3 | 1,120 |
#pragma once
#include <EnvDetect.hpp>
#include <stdint.h>
namespace zzz
{
//common
#undef min
#undef max
typedef uint8_t zuint8;
typedef uint16_t zuint16;
typedef uint32_t zuint32;
typedef uint64_t zuint64;
typedef int8_t zint8;
typedef int16_t zint16;
typedef int32_t zint32;
typedef int64_t zint64;
... | zzz-engine | zzzEngine/zCore/zCore/Define.hpp | C++ | gpl3 | 818 |
#include <zCoreConfig.hpp>
#ifdef ZZZ_DYNAMIC
#include <zCoreAutoLink3rdParty.hpp>
#endif | zzz-engine | zzzEngine/zCore/zCore/zCoreAutoLink.cpp | C++ | gpl3 | 94 |
#pragma once
// Separate link so when change a lib, only link needs redo.
#include "zCoreConfig.hpp"
#include "zCoreAutoLink3rdParty.hpp"
#ifndef ZZZ_NO_PRAGMA_LIB
#ifdef ZZZ_COMPILER_MSVC
#ifdef ZZZ_DYNAMIC
#ifdef ZZZ_DEBUG
#ifndef ZZZ_OS_WIN64
#pragma comment(lib, "zCoredllD.lib")
#e... | zzz-engine | zzzEngine/zCore/zCore/zCoreAutoLink.hpp | C++ | gpl3 | 996 |
#pragma once
#include "../common.hpp"
#include "Vector.hpp"
#undef min
#undef max
namespace zzz{
template <typename T>
class Vector<1, T> : public VectorBase<1, T>
{
protected:
using VectorBase<1, T>::v;
public:
//constructor
Vector(void){}
Vector(const Vector<1, T>& a):VectorBase<2, T>(a){}
... | zzz-engine | zzzEngine/zCore/zCore/Math/Vector1.hpp | C++ | gpl3 | 1,498 |
#pragma once
#include "Vector.hpp"
#include "Matrix.hpp"
#include "../common.hpp"
#include "Math.hpp"
#include "SymEigenSystem.hpp"
#include "SumCount.hpp"
namespace zzz{
template<typename T>
T Mean(const vector<T> &data)
{
SumCount<T> sc;
sc += data;
return sc.Mean();
}
template<typename T>
T... | zzz-engine | zzzEngine/zCore/zCore/Math/Statistics.hpp | C++ | gpl3 | 1,519 |
//modified from code by David Eberly[eberly@magic-software.com]
//original code comes from C Recipe
#pragma once
#include "Math.hpp"
#include "Vector.hpp"
#include "Utility/Log.hpp"
namespace zzz{
#define SIGN(a, b) ((b)<0 ? -fabs(a) : fabs(a))
template<typename T, int N>
class SymEigenSystem
{
private:
... | zzz-engine | zzzEngine/zCore/zCore/Math/SymEigenSystem.hpp | C++ | gpl3 | 5,707 |
#pragma once
#include "Matrix.hpp"
namespace zzz{
template <typename T>
class Matrix<2, 2, T> : public MatrixBase<2, 2, T>
{
public:
Matrix(){}
Matrix(const Matrix<2, 2, T> &mat):MatrixBase<2, 2, T>(mat){}
Matrix(const MatrixBase<2, 2, T> &mat):MatrixBase<2, 2, T>(mat){}
template<typename T1> explic... | zzz-engine | zzzEngine/zCore/zCore/Math/Matrix2x2.hpp | C++ | gpl3 | 2,593 |
#pragma once
#include <common.hpp>
namespace zzz{
template<typename T>
class SumCount
{
public:
SumCount():all_(0), count_(0){}
const T Sum() const {return all_;}
const zuint Count() const {return count_;}
const T Mean() const {return all_/count_;}
void AddData(const T &p) {
all_+=p;
... | zzz-engine | zzzEngine/zCore/zCore/Math/SumCount.hpp | C++ | gpl3 | 832 |
#pragma once
#include "Vector.hpp"
//3-variables polynomial function
namespace zzz{
typedef enum {
POLY3_UNIT,
POLY3_X, POLY3_Y, POLY3_Z,
POLY3_XY, POLY3_XZ, POLY3_YZ,
POLY3_X2, POLY3_Y2, POLY3_Z2,
POLY3_X2Y, POLY3_X2Z, POLY3_XY2, POLY3_Y2Z, POLY3_XZ2, POLY3_YZ2, POLY3_XYZ,
POLY3_X3, POLY3_Y3... | zzz-engine | zzzEngine/zCore/zCore/Math/Poly3.hpp | C++ | gpl3 | 8,251 |
#pragma once
#include <zCoreConfig.hpp>
#include "../common.hpp"
#include "Vector3.hpp"
#include "Matrix4x4.hpp"
namespace zzz{
#undef max
#undef min
inline zuint TimeSeed() {
return time(NULL);
}
inline void RandSeed() {
srand(TimeSeed());
}
template<typename T>
T UniformRand(const T &min, c... | zzz-engine | zzzEngine/zCore/zCore/Math/Random.hpp | C++ | gpl3 | 11,332 |
#pragma once
#include "../common.hpp"
namespace zzz{
// Donald Knuth's 32 bit Mix Function
// Discussed by Thomas Wang, HP
// http://www.concentric.net/~Ttwang/tech/inthash.htm
inline zuint HashKnuthUInt(zuint key)
{
// 2654435761 is the golden ratio of 2^32
return key*2654435761u;
}
// Robert Jenk... | zzz-engine | zzzEngine/zCore/zCore/Math/HashFunction.hpp | C++ | gpl3 | 1,124 |
#pragma once
//a tensor-like data structure to store data
#include "../common.hpp"
#include "../Utility/Log.hpp"
#include "../Utility/IOObject.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include "Vector4.hpp"
#include "Vector.hpp"
//low case function is STL competible, therefore at() takes int an... | zzz-engine | zzzEngine/zCore/zCore/Math/Array.hpp | C++ | gpl3 | 17,416 |
#pragma once
#include "Matrix.hpp"
namespace zzz{
template <typename T>
class Matrix<3, 3, T> : public MatrixBase<3, 3, T>
{
public:
Matrix(){}
Matrix(const Matrix<3, 3, T> &mat):MatrixBase<3, 3, T>(mat){}
Matrix(const MatrixBase<3, 3, T> &mat):MatrixBase<3, 3, T>(mat){}
template<typename T1> explic... | zzz-engine | zzzEngine/zCore/zCore/Math/Matrix3x3.hpp | C++ | gpl3 | 3,671 |
#pragma once
namespace zzz {
// Column majored sparse matrix
template<typename T>
class SparseMatrix
{
SparseMatrix():row_(0), col_(0), sorted_(false){}
SparseMatrix(zuint row, zuint col):row_(row), col_(col), sorted_(false){}
void Create(zuint row, zuint col) {
Clear();
if (row_==row && col_=... | zzz-engine | zzzEngine/zCore/zCore/Math/SparseMatrix.hpp | C++ | gpl3 | 2,128 |
#pragma once
#include <common.hpp>
#include "Vector.hpp"
#undef min
#undef max
namespace zzz{
template <typename T>
class Vector<3, T> : public VectorBase<3, T>
{
protected:
using VectorBase<3, T>::v;
public:
//constructor
Vector(void){}
Vector(const Vector<3, T>& a):VectorBase<3, T>(a){}
Vec... | zzz-engine | zzzEngine/zCore/zCore/Math/Vector3.hpp | C++ | gpl3 | 3,011 |
#pragma once
#include <common.hpp>
namespace zzz{
template<typename T>
class Average
{
public:
Average():ave_(0), count_(0){}
const T Sum() const {return ave_*count_;}
const zuint Count() const {return count_;}
const T Mean() const {return ave_;}
void AddData(const T &p)
{
ave_ = ave_... | zzz-engine | zzzEngine/zCore/zCore/Math/Average.hpp | C++ | gpl3 | 925 |
#pragma once
#include <common.hpp>
#include "Vector2.hpp"
namespace zzz{
template <typename T>
class MinMax {
public:
#undef max
#undef min
MinMax():min_(numeric_limits<T>::max()),max_(numeric_limits<T>::is_signed ? -numeric_limits<T>::max() : 0){}
MinMax(const T &min,const T &max):min_(min),max_(max){}... | zzz-engine | zzzEngine/zCore/zCore/Math/MinMax.hpp | C++ | gpl3 | 2,965 |
#pragma once
#include "DVector.hpp"
// dynamic matrix, size is changable, and can own the data or not(different from Array<2, T>)
namespace zzz{
template <typename T, bool OWN=true>
class DMatrixBase
{
public:
// type definitions
typedef T value_type;
typedef T* iterator;
ty... | zzz-engine | zzzEngine/zCore/zCore/Math/DMatrix.hpp | C++ | gpl3 | 8,251 |
#pragma once
// dynamic vector, size is changable. can own the data or not(different form Array<1, T>)
// when own, = set data, when not own = set reference
#include "../common.hpp"
namespace zzz{
template <typename T, bool OWN=true>
class DVectorBase
{
public:
// type definitions
typedef T ... | zzz-engine | zzzEngine/zCore/zCore/Math/DVector.hpp | C++ | gpl3 | 12,113 |
#pragma once
#include "../Utility/Tools.hpp"
#include "../Utility/Timer.hpp"
#include "../Utility/Log.hpp"
#include "Math.hpp"
//Iteration Exit Condition
//Condition can be combination of abs(residue), iteration times more, abs(residue difference), or running time
//If any condition satisfied, IsSatisfied will... | zzz-engine | zzzEngine/zCore/zCore/Math/IterExitCond.hpp | C++ | gpl3 | 4,604 |
#pragma once
#include <zMat.hpp>
namespace zzz{
class NonlinearSystem
{
public:
NonlinearSystem(int n_var, int n_cons):nVar_(n_var),nConstraints_(n_cons){}
int nVar_;
int nConstraints_;
virtual void Initialize(zVector<double> &init_x)=0;
virtual void WriteBack(const zVector<double> &result_x)=0;... | zzz-engine | zzzEngine/zCore/zCore/Math/NonlinearSystem/NonlinearSystem.hpp | C++ | gpl3 | 611 |
#define ZCORE_SOURCE
#include "MinpackSolver.hpp"
#ifdef ZZZ_LIB_MINPACK
#include <minpack.h>
#include <zMat.hpp>
#include "../../Utility/StringPrintf.hpp"
namespace zzz{
NonlinearSystem *mysys=NULL;
const string PrintResidue(const int *m, const double *fvec)
{
double v=0;
for (int i=0; i<*m; i++) ... | zzz-engine | zzzEngine/zCore/zCore/Math/NonlinearSystem/MinpackSolver.cpp | C++ | gpl3 | 2,628 |
#pragma once
#include <LibraryConfig.hpp>
#ifdef ZZZ_LIB_MINPACK
#include "NonlinearSystem.hpp"
namespace zzz{
class MinpackSolver : public NonlinearSystemSolver
{
public:
int Solve(NonlinearSystem &sys);
};
}
#endif // ZZZ_LIB_MINPACK | zzz-engine | zzzEngine/zCore/zCore/Math/NonlinearSystem/MinpackSolver.hpp | C++ | gpl3 | 254 |
#pragma once
#include "Vector2.hpp"
#include "Array.hpp"
namespace zzz {
template <typename T>
struct Array<2, T> : public ArrayBase<2, T>
{
using ArrayBase<2, T>::v;
using ArrayBase<2, T>::subsizes;
public:
//constructor
Array(void){}
Array(const zuint r, const zuint c):ArrayBase<2, T>(Vector2u... | zzz-engine | zzzEngine/zCore/zCore/Math/Array2.hpp | C++ | gpl3 | 2,721 |
#pragma once
#include "../common.hpp"
#include "../Utility/Log.hpp"
#include "../Utility/IOObject.hpp"
#include "../Utility/Tools.hpp"
#include "Math.hpp"
#undef min
#undef max
namespace zzz{
template <unsigned int N, typename T>
class VectorBase
{
protected:
T v[N];
public:
// STL support
/... | zzz-engine | zzzEngine/zCore/zCore/Math/Vector.hpp | C++ | gpl3 | 16,862 |
#pragma once
#include <zMat.hpp>
namespace zzz{
//AX=B
class LinearSystem
{
public:
LinearSystem(int n_var, int n_cons):nVar_(n_var),nConstraints_(n_cons){}
const int nVar_;
const int nConstraints_;
virtual void Initialize(zMatrix<double> &A, zVector<double> &B)=0;
virtual void WriteBack(zVecto... | zzz-engine | zzzEngine/zCore/zCore/Math/LinearSystem/LinearSystem.hpp | C++ | gpl3 | 430 |
#include "LinearSystem.hpp"
namespace zzz{
class DirectSolver : LinearSystemSolver
{
public:
int Solve(LinearSystem &sys);
};
} | zzz-engine | zzzEngine/zCore/zCore/Math/LinearSystem/DirectSolver.hpp | C++ | gpl3 | 138 |
#define ZCORE_SOURCE
#include "DirectSolver.hpp"
namespace zzz{
int DirectSolver::Solve(LinearSystem &sys)
{
zMatrix<double> A;
zVector<double> B;
sys.Initialize(A, B);
zMatrix<double> U, S,VT;
bool res=SVD(A, U, S,VT);
ZCHECK(res)<<"SVD Failed in DirectSolver";
for (zuint i=0; i<S.Size(0); i... | zzz-engine | zzzEngine/zCore/zCore/Math/LinearSystem/DirectSolver.cpp | C++ | gpl3 | 508 |
#pragma once
#include <common.hpp>
#include "Vector.hpp"
#undef min
#undef max
namespace zzz{
template <typename T>
class Vector<4, T> : public VectorBase<4, T>
{
protected:
using VectorBase<4, T>::v;
public:
//constructor
Vector(void){}
Vector(const Vector<4, T>& a):VectorBase<4, T>(a){}
Vec... | zzz-engine | zzzEngine/zCore/zCore/Math/Vector4.hpp | C++ | gpl3 | 2,374 |
#define ZCORE_SOURCE
#include "Random.hpp"
#include "Math.hpp"
namespace zzz{
//RandomLCG RandomLCG::rng;
const int RandomLCG::a = 16807;
const int RandomLCG::m = 2147483647;
const int RandomLCG::q = 127773;
const int RandomLCG::r = 2836;
RandomLCG::RandomLCG(const zuint seed)
: idum_(0)
{
RandomL... | zzz-engine | zzzEngine/zCore/zCore/Math/Random.cpp | C++ | gpl3 | 2,497 |
#pragma once
#include "Matrix.hpp"
namespace zzz{
template <typename T>
class Matrix<4, 4, T> : public MatrixBase<4, 4, T>
{
public:
Matrix(){}
Matrix(const Matrix<4, 4, T> &mat):MatrixBase<4, 4, T>(mat){}
Matrix(const MatrixBase<4, 4, T> &mat):MatrixBase<4, 4, T>(mat){}
template<typename T1> explic... | zzz-engine | zzzEngine/zCore/zCore/Math/Matrix4x4.hpp | C++ | gpl3 | 5,451 |
#pragma once
#include "../common.hpp"
#include "Vector.hpp"
#undef min
#undef max
namespace zzz{
template <typename T>
class Vector<2, T> : public VectorBase<2, T>
{
protected:
using VectorBase<2, T>::v;
public:
//constructor
Vector(void){}
Vector(const Vector<2, T>& a):VectorBase<2, T>(a){}
... | zzz-engine | zzzEngine/zCore/zCore/Math/Vector2.hpp | C++ | gpl3 | 1,939 |
#pragma once
#include "Vector3.hpp"
#include "Array.hpp"
namespace zzz {
template <typename T>
struct Array<3, T> : public ArrayBase<3, T>
{
using ArrayBase<3, T>::v;
using ArrayBase<3, T>::subsizes;
public:
//constructor
Array(void){}
Array(const zuint x, const zuint y, const zuint z):ArrayBase... | zzz-engine | zzzEngine/zCore/zCore/Math/Array3.hpp | C++ | gpl3 | 2,992 |
#pragma once
#include "../Utility/Log.hpp"
#include "Vector2.hpp"
#include "Vector.hpp"
#include "../common.hpp"
namespace zzz{
template <unsigned int ROW, unsigned int COL, typename T>
class MatrixBase
{
public:
// type definitions
typedef T value_type;
typedef T* iterato... | zzz-engine | zzzEngine/zCore/zCore/Math/Matrix.hpp | C++ | gpl3 | 22,218 |
#pragma once
#include "Vector1.hpp"
#include "Array.hpp"
namespace zzz {
template <typename T>
struct Array<1, T> : public ArrayBase<1, T>
{
protected:
using ArrayBase<1, T>::v;
public:
//constructor
Array(void){}
explicit Array(const zuint size):ArrayBase<1, T>(Vector1ui(size)){}
explicit Arra... | zzz-engine | zzzEngine/zCore/zCore/Math/Array1.hpp | C++ | gpl3 | 2,312 |
#pragma once
namespace zzz{
template<typename T>
class Complex : public Vector<2, T>
{
using Vector<2, T>::v;
public:
Complex():Vector<2, T>(0, 0){}
explicit Complex(const VectorBase<2, T> &v):Vector<2, T>(v){}
explicit Complex(T r, T i):Vector<2, T>(r, i){}
using Vector<2, T>::operator[];
T&... | zzz-engine | zzzEngine/zCore/zCore/Math/Complex.hpp | C++ | gpl3 | 955 |
#pragma once
#include "../zCoreConfig.hpp"
#include "Utility/Log.hpp"
namespace zzz{
const double EPS=1e-7;
const double EPSILON5=1e-5;
const double EPSILON6=1e-6;
const double EPSILON7=1e-7;
const double EPSILON8=1e-8;
const double EPSILON9=1e-9;
const double EPSILON=EPSILON7;
const double SMALL_EPSILON... | zzz-engine | zzzEngine/zCore/zCore/Math/Math.hpp | C++ | gpl3 | 12,370 |
#pragma once
#include "Function.hpp"
namespace zzz{
//f(x)=1/(sigma^2*2pi)*exp(-((x-meanx)^2+(y-meany)^2)/(2*sigma^2))
class Gaussian2DFunction : public Function<Vector2d,double>
{
public:
Gaussian2DFunction()
:Function<Vector2d,double>(Vector2d(MAX_DOUBLE,MAX_DOUBLE),
Vector2d(-MAX_DOUBLE, -... | zzz-engine | zzzEngine/zCore/zCore/Function/Gaussian2DFunction.hpp | C++ | gpl3 | 1,002 |
#pragma once
#include "Function.hpp"
namespace zzz{
//f(x)=1/(sigma*sqrt(2pi))*exp(-(x-mean)^2/(2*sigma^2))
class GaussianFunction : public Function<double,double>
{
public:
GaussianFunction()
:Function<double, double>(MAX_DOUBLE, -MAX_DOUBLE),
mean_(0),sigma_(0){}
GaussianFunction(double mean... | zzz-engine | zzzEngine/zCore/zCore/Function/GaussianFunction.hpp | C++ | gpl3 | 864 |
#pragma once
namespace zzz{
template<typename TI, typename TO> //TI for input type, TO for output type
class Function
{
public:
typedef TI InputType;
typedef TO OutputType;
const TI InputMin;
const TI InputMax;
Function(const TI imin, const TI imax)
:InputMin(imin),InputMax(imax) {}
... | zzz-engine | zzzEngine/zCore/zCore/Function/Function.hpp | C++ | gpl3 | 698 |
#pragma once
#include "EnvDetect.hpp"
//#define ZZZ_LIB_MINIMAL
#ifdef ZZZ_LIB_MINIMAL
#include "LibraryConfig.hpp.minimal"
#else
#ifdef ZZZ_OS_WIN32
#include "LibraryConfig.hpp.win32"
#endif
#ifdef ZZZ_OS_WIN64
#include "LibraryConfig.hpp.win64"
#endif
#endif // ZZZ_LIB_MINIMAL | zzz-engine | zzzEngine/zCore/zCore/LibraryConfig.hpp | C++ | gpl3 | 303 |
#pragma once
// Compiler
#ifdef _MSC_VER
#define ZZZ_COMPILER_MSVC
#endif
#ifdef __MINGW32__
#define ZZZ_COMPILER_MINGW
#endif
#ifdef __CYGWIN__
#define ZZZ_COMPILER_CYGWIN
#endif
#ifdef __GNUC__
#define ZZZ_COMPILER_GCC
#endif
#ifdef __INTEL_COMPILER
#define ZZZ_COMPILER_INTEL
#endif
// OS
#ifdef _WIN32
#define ... | zzz-engine | zzzEngine/zCore/zCore/EnvDetect.hpp | C++ | gpl3 | 1,116 |
#pragma once
#include <EnvDetect.hpp>
#include <LibraryConfig.hpp>
#ifdef ZZZ_OS_WIN32
#include "zCoreConfig.hpp.win32"
#endif
#ifdef ZZZ_OS_WIN64
#include "zCoreConfig.hpp.win64"
#endif
#ifdef ZZZ_DYNAMIC
#pragma warning(disable:4251) // needs to have dll-interface
#pragma warning(disable:4275)... | zzz-engine | zzzEngine/zCore/zCore/zCoreConfig.hpp | C++ | gpl3 | 709 |
#pragma once
#include "zCoreConfig.hpp"
//math part should be the last
#include "Math/Array1.hpp"
#include "Math/Array2.hpp"
#include "Math/Array3.hpp"
#include "Math/Array.hpp"
#include "Math/Average.hpp"
#include "Math/Complex.hpp"
#include "Math/DMatrix.hpp"
#include "Math/DVector.hpp"
#include "Math/... | zzz-engine | zzzEngine/zCore/zCore/zCore.hpp | C++ | gpl3 | 2,061 |
#define ZCORE_SOURCE
#include "XML.hpp"
#ifdef ZZZ_LIB_TINYXML
#define TIXML_USE_STL
#include <tinyxml/tinyxml.h>
#include <tinyxml/tinystr.h>
namespace zzz{
bool XML::LoadFile(const string &filename)
{
filename_=filename;
bool res=doc_->LoadFile(filename);
if (doc_->Error())
{
printf("Error ... | zzz-engine | zzzEngine/zCore/zCore/Xml/XML.cpp | C++ | gpl3 | 2,766 |
#define ZCORE_SOURCE
#include "RapidXMLNode.hpp"
#include "RapidXML.hpp"
using namespace rapidxml;
namespace zzz{
RapidXMLNode::RapidXMLNode(const RapidXMLNode &node):node_(node.node_),root_(node.root_)
{}
RapidXMLNode::RapidXMLNode(xml_node<> *node, const RapidXML *root):node_(node),root_(root)
{}
//sel... | zzz-engine | zzzEngine/zCore/zCore/Xml/RapidXMLNode.cpp | C++ | gpl3 | 4,641 |
#pragma once
#include <zCoreConfig.hpp>
#include "../common.hpp"
#include "../Utility/StringTools.hpp"
#include <3rdparty/rapidxml/rapidxml.hpp>
namespace zzz{
class RapidXML;
class ZCORE_CLASS RapidXMLNode {
public:
RapidXMLNode(const RapidXMLNode &node);
explicit RapidXMLNode(rapidxml::xml_node<> *nod... | zzz-engine | zzzEngine/zCore/zCore/Xml/RapidXMLNode.hpp | C++ | gpl3 | 3,481 |
#define ZCORE_SOURCE
#include "RapidXML.hpp"
#include <Utility\Log.hpp>
#include <Utility\FileTools.hpp>
#include <3rdparty/rapidxml/rapidxml_print.hpp>
using namespace rapidxml;
namespace zzz{
bool RapidXML::LoadFile(const string &filename)
{
filename_=filename;
string text;
ZCHECK(ReadFileToString(... | zzz-engine | zzzEngine/zCore/zCore/Xml/RapidXML.cpp | C++ | gpl3 | 2,900 |
#pragma once
#include "../Utility/IOInterface.hpp"
#include "../Utility/Uncopyable.hpp"
#include "XMLNode.hpp"
#ifdef ZZZ_LIB_TINYXML
class TiXmlDocument;
namespace zzz{
class XML : public IOData, public Uncopyable
{
public:
XML();
~XML();
bool LoadFile(const string &);
bool SaveFile(const string... | zzz-engine | zzzEngine/zCore/zCore/Xml/XML.hpp | C++ | gpl3 | 704 |
#define ZCORE_SOURCE
#include "XMLNode.hpp"
#ifdef ZZZ_LIB_TINYXML
#define TIXML_USE_STL
#include <tinyxml/tinyxml.h>
#include <tinyxml/tinystr.h>
namespace zzz{
XMLNode::XMLNode(const XMLNode &node):node_(node.node_),root_(node.root_)
{}
XMLNode::XMLNode(TiXmlElement *node, const XML *root):node_(node),... | zzz-engine | zzzEngine/zCore/zCore/Xml/XMLNode.cpp | C++ | gpl3 | 5,645 |
#pragma once
#include <LibraryConfig.hpp>
#ifdef ZZZ_LIB_TINYXML
#include "../common.hpp"
#include "../Utility/StringTools.hpp"
class TiXmlElement;
namespace zzz{
class XML;
class XMLNode
{
public:
XMLNode(const XMLNode &node);
explicit XMLNode(TiXmlElement *node, const XML *root);
bool IsValid()... | zzz-engine | zzzEngine/zCore/zCore/Xml/XMLNode.hpp | C++ | gpl3 | 2,730 |
#pragma once
#include "../Utility/IOInterface.hpp"
#include "../Utility/Uncopyable.hpp"
#include "RapidXMLNode.hpp"
#include <Math/Array.hpp>
namespace zzz{
class ZCORE_CLASS RapidXML : public IOData, public Uncopyable
{
public:
bool LoadFile(const string &);
bool SaveFile(const string &);
zuint Node... | zzz-engine | zzzEngine/zCore/zCore/Xml/RapidXML.hpp | C++ | gpl3 | 712 |
SET(THISLIB zVisualization)
FILE(GLOB_RECURSE LibSrc *.cpp)
#MESSAGE(STATUS "files ${LibSrc}")
IF( "${DEBUG_MODE}" EQUAL "1")
SET(THISLIB ${THISLIB}D)
ENDIF()
IF( "${BIT_MODE}" EQUAL "64" )
SET(THISLIB ${THISLIB}_X64)
ENDIF()
ADD_LIBRARY(${THISLIB} STATIC ${LibSrc})
| zzz-engine | zzzEngine/zVisualization/CMakeLists.txt | CMake | gpl3 | 279 |
#pragma once
#ifndef ZZZ_NO_PRAGMA_LIB
#ifdef _DEBUG
#ifndef ZZZ_OS_WIN64
#pragma comment(lib,"zVisualizationD.lib")
#else
#pragma comment(lib,"zVisualizationD_x64.lib")
#endif // ZZZ_OS_WIN64
#else
#ifndef ZZZ_OS_WIN64
#pragma comment(lib,"zVisualization.lib")
#else
#pragma comment(lib,"zVisualization_... | zzz-engine | zzzEngine/zVisualization/zVisualization/zVisualization.hpp | C++ | gpl3 | 605 |
#pragma once
#include "Visualizer2D.hpp"
#include "VisualizeNode2D.hpp"
namespace zzz{
class SequenceVisualizer2D:public Visualizer2D
{
public:
SequenceVisualizer2D(Vis2DRenderer *renderer,int num):Visualizer2D(renderer),maxnum_(num),autofocus_(true){}
~SequenceVisualizer2D(void)
{
for (list<Visua... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/SequenceVisualizer2D.hpp | C++ | gpl3 | 567 |
#pragma once
#include "Visualizer2D.hpp"
#include "VisualizeNode2D.hpp"
namespace zzz{
class CombineVisualizer2D:public Visualizer2D
{
public:
CombineVisualizer2D(Vis2DRenderer *renderer):Visualizer2D(renderer),autocenter_(true){}
~CombineVisualizer2D(void)
{
for (size_t i=0; i<visualizers_.size()... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/CombineVisualizer2D.hpp | C++ | gpl3 | 664 |
#include <common.hpp>
#include "TreeVisualizer2D.hpp"
namespace zzz{
void zzz::TreeVisualizer2D::Rerange(int gap)
{
if (direction==0)
{
int treeheight=1;
int centerx=tree_.GetHead()->v->posx_+(tree_.GetHead()->v->bbox_.Min(0)+tree_.GetHead()->v->bbox_.Max(0))/2;
int lastheight=tree_.GetHead()... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/TreeVisualizer2D.cpp | C++ | gpl3 | 2,552 |
#include "VisualizeNode2D.hpp"
#include <Renderer/Vis2DRenderer.hpp>
#include <Resource/Shader/Shader.hpp>
#include <Graphics/ColorDefine.hpp>
namespace zzz{
VisualizeNode2D::~VisualizeNode2D()
{
Clear();
}
void VisualizeNode2D::Clear()
{
for (size_t i=0; i<objs_.size(); i++)
delete objs_[i];
... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/VisualizeNode2D.cpp | C++ | gpl3 | 1,496 |
#pragma once
#include <common.hpp>
#include "VisualizeObj2D.hpp"
#include <Math\Vector2.hpp>
namespace zzz{
class Vis2DRenderer;
class VisualizeNode2D
{
public:
VisualizeNode2D():drawedge_(true), bbox_(Vector2i(0)){}
virtual ~VisualizeNode2D();
void AddObject(VisualizeObj2D* obj);
void DrawPixels(... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/VisualizeNode2D.hpp | C++ | gpl3 | 467 |
#pragma once
#include <Renderer/Vis2DRenderer.hpp>
//use Vis2DRenderer to visualize 2D information
namespace zzz{
class Visualizer2D
{
public:
Visualizer2D(Vis2DRenderer *renderer):renderer_(renderer){}
virtual void Draw()=0;
Vis2DRenderer *renderer_;
};
} | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/Visualizer2D.hpp | C++ | gpl3 | 277 |
#include "SequenceVisualizer2D.hpp"
namespace zzz{
void SequenceVisualizer2D::AddNode(VisualizeNode2D *node)
{
if ((int)nodes_.size()>=maxnum_) nodes_.pop_front();
double width=node->bbox_.Diff(0);
for (list<VisualizeNode2D*>::iterator lvi=nodes_.begin();lvi!=nodes_.end();lvi++)
{
VisualizeNode2D ... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/SequenceVisualizer2D.cpp | C++ | gpl3 | 874 |
#pragma once
#include "VisualizeNode2D.hpp"
#include "Visualizer2D.hpp"
#include <Utility/Tree.hpp>
namespace zzz{
class TreeVisualizer2D:public Visualizer2D
{
public:
TreeVisualizer2D(Vis2DRenderer *renderer):Visualizer2D(renderer),direction(1)
{}
void Draw();
void Rerange(int gap=10);
Tree<Visua... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/TreeVisualizer2D.hpp | C++ | gpl3 | 364 |
#pragma once
#include <Image/Image.hpp>
#include "VisualizeObj2D.hpp"
namespace zzz{
template<typename T>
class VImage2D : public VisualizeObj2D, public GraphicsHelper
{
public:
VImage2D(const Image<T> &img, int x=0, int y=0):image(img)
{
bbox_.Min()=Vector2i(x,y);
bbox_.Max()=Vector2i(x+image.Co... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/VImage2D.hpp | C++ | gpl3 | 599 |
#pragma once
#include "Visualizer2D.hpp"
#include "VisualizeNode2D.hpp"
//has only one node to show one image
namespace zzz{
class SingleVisualizer2D:public Visualizer2D
{
public:
SingleVisualizer2D(Vis2DRenderer *renderer):Visualizer2D(renderer),autocenter_(true),node_(NULL){}
~SingleVisualizer2D(void... | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/SingleVisualizer2D.hpp | C++ | gpl3 | 834 |
#pragma once
#include <Graphics\AABB.hpp>
namespace zzz{
class Vis2DRenderer;
class VisualizeObj2D
{
public:
AABB<2,int> bbox_;
virtual void DrawPixels(Vis2DRenderer *renderer,double basex, double basey)=0;
};
} | zzz-engine | zzzEngine/zVisualization/zVisualization/Visualizer/VisualizeObj2D.hpp | C++ | gpl3 | 225 |