git-svn-id: svn://db.shs.com.ru/pip@764 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-02-27 11:28:54 +00:00
parent b6ee08194c
commit 0435c2b332
8 changed files with 83 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Variant type Variant type
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -146,6 +146,8 @@ PIVariant::Type PIVariant::typeFromName(const PIString & tname) {
if (s == "color") return PIVariant::pivColor; if (s == "color") return PIVariant::pivColor;
if (s == "point") return PIVariant::pivPoint; if (s == "point") return PIVariant::pivPoint;
if (s == "rect") return PIVariant::pivRect; if (s == "rect") return PIVariant::pivRect;
if (s == "vector") return PIVariant::pivMathVector;
if (s == "matrix") return PIVariant::pivMathMatrix;
return PIVariant::pivInvalid; return PIVariant::pivInvalid;
} }
@@ -189,6 +191,8 @@ PIString PIVariant::typeName(PIVariant::Type type) {
case PIVariant::pivColor: return "Color"; case PIVariant::pivColor: return "Color";
case PIVariant::pivPoint: return "Point"; case PIVariant::pivPoint: return "Point";
case PIVariant::pivRect: return "Rect"; case PIVariant::pivRect: return "Rect";
case PIVariant::pivMathVector: return "Vector";
case PIVariant::pivMathMatrix: return "Matrix";
case PIVariant::pivCustom: return "Custom"; case PIVariant::pivCustom: return "Custom";
default: break; default: break;
} }
@@ -593,3 +597,24 @@ PIRectd PIVariant::toRect() const {
if (_type == PIVariant::pivRect) {PIRectd r; ba >> r; return r;} if (_type == PIVariant::pivRect) {PIRectd r; ba >> r; return r;}
return PIRectd(); return PIRectd();
} }
/** \brief Returns variant content as math vector
* \details In case of PIMathVectord type returns rect value. \n
* In case of other types returns empty PIMathVectord. */
PIMathVectord PIVariant::toMathVector() const {
PIByteArray ba(_content);
if (_type == PIVariant::pivMathVector) {PIMathVectord r; ba >> r; return r;}
return PIMathVectord();
}
/** \brief Returns variant content as math matrix
* \details In case of PIMathMatrixd type returns rect value. \n
* In case of other types returns empty PIMathMatrixd. */
PIMathMatrixd PIVariant::toMathMatrix() const {
PIByteArray ba(_content);
if (_type == PIVariant::pivMathMatrix) {PIMathMatrixd r; ba >> r; return r;}
return PIMathMatrixd();
}

View File

@@ -6,7 +6,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Variant type Variant type
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -237,6 +237,8 @@ public:
pivPoint /** PIPoint */ , pivPoint /** PIPoint */ ,
pivRect /** PIRect */ , pivRect /** PIRect */ ,
pivIODevice /** PIVariantTypes::IODevice */ , pivIODevice /** PIVariantTypes::IODevice */ ,
pivMathVector /** PIMathVectord */ ,
pivMathMatrix /** PIMathMatrixd */ ,
pivCustom /** Custom */ = 0xFF pivCustom /** Custom */ = 0xFF
}; };
@@ -329,6 +331,12 @@ public:
//! Constructs variant from rect //! Constructs variant from rect
PIVariant(const PIRectd & v) {initType(v);} PIVariant(const PIRectd & v) {initType(v);}
//! Constructs variant from MathVector
PIVariant(const PIMathVectord & v) {initType(v);}
//! Constructs variant from MathMatrix
PIVariant(const PIMathMatrixd & v) {initType(v);}
//! Set variant content and type to string //! Set variant content and type to string
void setValue(const char * v) {setValue(PIString(v));} void setValue(const char * v) {setValue(PIString(v));}
@@ -414,6 +422,13 @@ public:
//! Set variant content and type to rect //! Set variant content and type to rect
void setValue(const PIRectd & v) {initType(v);} void setValue(const PIRectd & v) {initType(v);}
//! Set variant content and type to math vector
void setValue(const PIMathVectord & v) {initType(v);}
//! Set variant content and type to math matrix
void setValue(const PIMathMatrixd & v) {initType(v);}
//! Set current value from string without change type //! Set current value from string without change type
void setValueFromString(const PIString & v); void setValueFromString(const PIString & v);
@@ -439,6 +454,8 @@ public:
PIVariantTypes::IODevice toIODevice() const; PIVariantTypes::IODevice toIODevice() const;
PIPointd toPoint() const; PIPointd toPoint() const;
PIRectd toRect() const; PIRectd toRect() const;
PIMathVectord toMathVector() const;
PIMathMatrixd toMathMatrix() const;
/** \brief Returns variant content as custom type /** \brief Returns variant content as custom type
@@ -530,6 +547,10 @@ public:
PIVariant & operator =(const PIPointd & v) {setValue(v); return *this;} PIVariant & operator =(const PIPointd & v) {setValue(v); return *this;}
//! Assign operator //! Assign operator
PIVariant & operator =(const PIRectd & v) {setValue(v); return *this;} PIVariant & operator =(const PIRectd & v) {setValue(v); return *this;}
//! Assign operator
PIVariant & operator =(const PIMathVectord & v) {setValue(v); return *this;}
//! Assign operator
PIVariant & operator =(const PIMathMatrixd & v) {setValue(v); return *this;}
//! Compare operator //! Compare operator
@@ -688,6 +709,8 @@ template<> inline PIVariant PIVariant::fromValue(const PIVariantTypes::Color & v
template<> inline PIVariant PIVariant::fromValue(const PIVariantTypes::IODevice & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const PIVariantTypes::IODevice & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const PIPointd & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const PIPointd & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const PIRectd & v) {return PIVariant(v);} template<> inline PIVariant PIVariant::fromValue(const PIRectd & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const PIMathVectord & v) {return PIVariant(v);}
template<> inline PIVariant PIVariant::fromValue(const PIMathMatrixd & v) {return PIVariant(v);}
template<> inline PIVariant::Type PIVariant::getType<bool>() {return PIVariant::pivBool;} template<> inline PIVariant::Type PIVariant::getType<bool>() {return PIVariant::pivBool;}
template<> inline PIVariant::Type PIVariant::getType<char>() {return PIVariant::pivChar;} template<> inline PIVariant::Type PIVariant::getType<char>() {return PIVariant::pivChar;}
@@ -716,6 +739,8 @@ template<> inline PIVariant::Type PIVariant::getType<PIVariantTypes::Color>() {r
template<> inline PIVariant::Type PIVariant::getType<PIVariantTypes::IODevice>() {return PIVariant::pivIODevice;} template<> inline PIVariant::Type PIVariant::getType<PIVariantTypes::IODevice>() {return PIVariant::pivIODevice;}
template<> inline PIVariant::Type PIVariant::getType<PIPointd>() {return PIVariant::pivPoint;} template<> inline PIVariant::Type PIVariant::getType<PIPointd>() {return PIVariant::pivPoint;}
template<> inline PIVariant::Type PIVariant::getType<PIRectd>() {return PIVariant::pivRect;} template<> inline PIVariant::Type PIVariant::getType<PIRectd>() {return PIVariant::pivRect;}
template<> inline PIVariant::Type PIVariant::getType<PIMathVectord>() {return PIVariant::pivMathVector;}
template<> inline PIVariant::Type PIVariant::getType<PIMathMatrixd>() {return PIVariant::pivMathMatrix;}
REGISTER_VARIANT(bool) REGISTER_VARIANT(bool)
REGISTER_VARIANT(char) REGISTER_VARIANT(char)
@@ -744,6 +769,9 @@ REGISTER_NS_VARIANT(PIVariantTypes, Color)
REGISTER_NS_VARIANT(PIVariantTypes, IODevice) REGISTER_NS_VARIANT(PIVariantTypes, IODevice)
REGISTER_VARIANT(PIPointd) REGISTER_VARIANT(PIPointd)
REGISTER_VARIANT(PIRectd) REGISTER_VARIANT(PIRectd)
REGISTER_VARIANT(PIMathVectord)
REGISTER_VARIANT(PIMathMatrixd)
inline PIByteArray & operator <<(PIByteArray & s, const PIVariant & v) { inline PIByteArray & operator <<(PIByteArray & s, const PIVariant & v) {
s << v._content << int(v._type); s << v._content << int(v._type);

View File

@@ -1,7 +1,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Variant types Variant types
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View File

@@ -6,7 +6,7 @@
/* /*
PIP - Platform Independent Primitives PIP - Platform Independent Primitives
Variant types Variant types
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@@ -26,6 +26,8 @@
#define PIVARIANTYPES_H #define PIVARIANTYPES_H
#include "pistring.h" #include "pistring.h"
#include "pimathmatrix.h"
class PIPropertyStorage; class PIPropertyStorage;
@@ -114,5 +116,4 @@ inline PIByteArray & operator <<(PIByteArray & s, const PIVariantTypes::IODevice
inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;} inline PIByteArray & operator >>(PIByteArray & s, PIVariantTypes::IODevice & v) {s >> v.prefix >> v.mode >> v.options >> v.props; return s;}
inline PICout operator <<(PICout s, const PIVariantTypes::IODevice & v) {s << v.toPICout(); return s;} inline PICout operator <<(PICout s, const PIVariantTypes::IODevice & v) {s << v.toPICout(); return s;}
#endif // PIVARIANTYPES_H #endif // PIVARIANTYPES_H

View File

@@ -56,7 +56,7 @@ public:
}; };
template<typename Type> template<typename Type>
PICout operator <<(PICout & s, const PIPoint<Type> & v) {s.setControl(0, true); s << '{' << v.x << ", " << v.y << '}'; s.restoreControl(); return s;} PICout operator <<(PICout & s, const PIPoint<Type> & v) {s.setControl(0, true); s << "Point{" << v.x << ", " << v.y << "}"; s.restoreControl(); return s;}
template<typename Type> template<typename Type>
inline PIByteArray & operator <<(PIByteArray & s, PIPoint<Type> v) {s << v.x << v.y; return s;} inline PIByteArray & operator <<(PIByteArray & s, PIPoint<Type> v) {s << v.x << v.y; return s;}
@@ -141,7 +141,7 @@ public:
}; };
template<typename Type> template<typename Type>
PICout operator <<(PICout & s, const PIRect<Type> & v) {s.setControl(0, true); s << '{' << v.x0 << ", " << v.y0 << "; " << v.x1 - v.x0 << ", " << v.y1 - v.y0 << '}'; s.restoreControl(); return s;} PICout operator <<(PICout & s, const PIRect<Type> & v) {s.setControl(0, true); s << "Rect{" << v.x0 << ", " << v.y0 << "; " << v.x1 - v.x0 << ", " << v.y1 - v.y0 << "}"; s.restoreControl(); return s;}
template<typename Type> template<typename Type>
inline PIByteArray & operator <<(PIByteArray & s, PIRect<Type> v) {s << v.x0 << v.x1 << v.y0 << v.y1; return s;} inline PIByteArray & operator <<(PIByteArray & s, PIRect<Type> v) {s << v.x0 << v.x1 << v.y0 << v.y1; return s;}

View File

@@ -232,11 +232,11 @@ template<> inline PIMathMatrixT<3u, 3u> PIMathMatrixT<3u, 3u>::scaleZ(double fac
#ifdef PIP_STD_IOSTREAM #ifdef PIP_STD_IOSTREAM
template<uint Rows, uint Cols, typename Type> template<uint Rows, uint Cols, typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << '{'; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << std::endl << ' ';} s << '}'; return s;} inline std::ostream & operator <<(std::ostream & s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << "{"; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << std::endl << " ";} s << "}"; return s;}
#endif #endif
template<uint Rows, uint Cols, typename Type> template<uint Rows, uint Cols, typename Type>
inline PICout operator <<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << '{'; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << PICoutManipulators::NewLine << ' ';} s << '}'; return s;} inline PICout operator <<(PICout s, const PIMathMatrixT<Rows, Cols, Type> & m) {s << "{"; PIMM_FOR_I(r, c) s << m[r][c]; if (c < Cols - 1 || r < Rows - 1) s << ", ";} if (r < Rows - 1) s << PICoutManipulators::NewLine << " ";} s << "}"; return s;}
/// Multiply matrices {Rows0 x CR} on {CR x Cols1}, result is {Rows0 x Cols1} /// Multiply matrices {Rows0 x CR} on {CR x Cols1}, result is {Rows0 x Cols1}
template<uint CR, uint Rows0, uint Cols1, typename Type> template<uint CR, uint Rows0, uint Cols1, typename Type>
@@ -328,7 +328,7 @@ class PIP_EXPORT PIMathMatrix : public PIVector2D<Type> {
typedef PIMathMatrix<Type> _CMatrix; typedef PIMathMatrix<Type> _CMatrix;
typedef PIMathVector<Type> _CMCol; typedef PIMathVector<Type> _CMCol;
public: public:
PIMathMatrix(const uint cols = 3, const uint rows = 3) {resize(cols, rows);} PIMathMatrix(const uint cols = 0, const uint rows = 0) {resize(cols, rows);}
PIMathMatrix(const uint cols, const uint rows, const PIVector<Type> & val) {resize(cols, rows); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];} PIMathMatrix(const uint cols, const uint rows, const PIVector<Type> & val) {resize(cols, rows); int i=0; PIMM_FOR_I(c, r) _V2D::element(r, c) = val[i++];}
PIMathMatrix(const PIVector<PIVector<Type> > & val) {if(!val.isEmpty()) {resize(val[0].size(), val.size()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val[r][c];}} PIMathMatrix(const PIVector<PIVector<Type> > & val) {if(!val.isEmpty()) {resize(val[0].size(), val.size()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val[r][c];}}
PIMathMatrix(const PIVector2D<Type> & val) {if(!val.isEmpty()) {resize(val.cols(), val.rows()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val.element(r, c);}} PIMathMatrix(const PIVector2D<Type> & val) {if(!val.isEmpty()) {resize(val.cols(), val.rows()); PIMM_FOR_I(c, r) _V2D::element(r, c) = val.element(r, c);}}
@@ -346,6 +346,7 @@ public:
bool isSquare() const {return _V2D::cols_ == _V2D::rows_;} bool isSquare() const {return _V2D::cols_ == _V2D::rows_;}
bool isIdentity() const {PIMM_FOR(c, r) if ((c == r) ? _V2D::element(r, c) != Type(1) : _V2D::element(r, c) != Type(0)) return false; return true;} bool isIdentity() const {PIMM_FOR(c, r) if ((c == r) ? _V2D::element(r, c) != Type(1) : _V2D::element(r, c) != Type(0)) return false; return true;}
bool isNull() const {PIMM_FOR_A(i) if (_V2D::mat[i] != Type(0)) return false; return true;} bool isNull() const {PIMM_FOR_A(i) if (_V2D::mat[i] != Type(0)) return false; return true;}
bool isValid() const {return !PIVector2D<Type>::isEmpty();}
_CMatrix & operator =(const PIVector<PIVector<Type> > & v) {*this = _CMatrix(v); return *this;} _CMatrix & operator =(const PIVector<PIVector<Type> > & v) {*this = _CMatrix(v); return *this;}
bool operator ==(const _CMatrix & sm) const {PIMM_FOR_A(i) if (_V2D::mat[i] != sm.mat[i]) return false; return true;} bool operator ==(const _CMatrix & sm) const {PIMM_FOR_A(i) if (_V2D::mat[i] != sm.mat[i]) return false; return true;}
@@ -482,20 +483,16 @@ public:
} }
_CMatrix inverted(bool * ok = 0) const {_CMatrix tm(*this); tm.invert(ok); return tm;} _CMatrix inverted(bool * ok = 0) const {_CMatrix tm(*this); tm.invert(ok); return tm;}
_CMatrix transposed() const {_CMatrix tm(_V2D::rows_, _V2D::cols_); PIMM_FOR(c, r) tm.element(c, r) = _V2D::element(r, c); return tm;} _CMatrix transposed() const {_CMatrix tm(_V2D::rows_, _V2D::cols_); PIMM_FOR(c, r) tm.element(c, r) = _V2D::element(r, c); return tm;}
private:
// size_t rows_, cols_;
// PIVector<Type> mat;
}; };
#ifdef PIP_STD_IOSTREAM #ifdef PIP_STD_IOSTREAM
template<typename Type> template<typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMathMatrix<Type> & m) {s << '{'; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << std::endl << ' ';} s << '}'; return s;} inline std::ostream & operator <<(std::ostream & s, const PIMathMatrix<Type> & m) {s << "{"; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << std::endl << " ";} s << "}"; return s;}
#endif #endif
template<typename Type> template<typename Type>
inline PICout operator <<(PICout s, const PIMathMatrix<Type> & m) {s << '{'; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << PICoutManipulators::NewLine << ' ';} s << '}'; return s;} inline PICout operator <<(PICout s, const PIMathMatrix<Type> & m) {s << "Matrix{"; for (uint r = 0; r < m.rows(); ++r) { for (uint c = 0; c < m.cols(); ++c) { s << m.element(r, c); if (c < m.cols() - 1 || r < m.rows() - 1) s << ", ";} if (r < m.rows() - 1) s << PICoutManipulators::NewLine << " ";} s << "}"; return s;}
/// Multiply matrices {CR x Rows0} on {Cols1 x CR}, result is {Cols1 x Rows0} /// Multiply matrices {CR x Rows0} on {Cols1 x CR}, result is {Cols1 x Rows0}
template<typename Type> template<typename Type>

View File

@@ -129,7 +129,7 @@ inline PIMathVectorT<Size, Type> operator *(const Type & x, const PIMathVectorT<
} }
template<uint Size, typename Type> template<uint Size, typename Type>
inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << '{'; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << '}'; return s;} inline PICout operator <<(PICout s, const PIMathVectorT<Size, Type> & v) {s << "{"; PIMV_FOR(i, 0) {s << v[i]; if (i < Size - 1) s << ", ";} s << "}"; return s;}
template<uint Size, typename Type> template<uint Size, typename Type>
inline bool operator ||(const PIMathVectorT<Size, Type> & f, const PIMathVectorT<Size, Type> & s) {return (f * s).isNull();} inline bool operator ||(const PIMathVectorT<Size, Type> & f, const PIMathVectorT<Size, Type> & s) {return (f * s).isNull();}
template<uint Size, typename Type> template<uint Size, typename Type>
@@ -179,7 +179,7 @@ template<typename Type>
class PIP_EXPORT PIMathVector { class PIP_EXPORT PIMathVector {
typedef PIMathVector<Type> _CVector; typedef PIMathVector<Type> _CVector;
public: public:
PIMathVector(const uint size = 3) {c.resize(size);} PIMathVector(const uint size = 0) {c.resize(size);}
PIMathVector(const PIVector<Type> & val) {c.resize(val.size()); PIMV_FOR(i, 0) c[i] = val[i];} PIMathVector(const PIVector<Type> & val) {c.resize(val.size()); PIMV_FOR(i, 0) c[i] = val[i];}
PIMathVector(const _CVector & st, const _CVector & fn) {c.resize(st.size()); PIMV_FOR(i, 0) c[i] = fn[i] - st[i];} PIMathVector(const _CVector & st, const _CVector & fn) {c.resize(st.size()); PIMV_FOR(i, 0) c[i] = fn[i] - st[i];}
@@ -201,6 +201,8 @@ public:
_CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;} _CVector & normalize() {Type tv = length(); if (tv == Type(1)) return *this; if (piAbs<Type>(tv) <= Type(1E-100)) {fill(Type(0)); return *this;} PIMV_FOR(i, 0) c[i] /= tv; return *this;}
_CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;} _CVector normalized() {_CVector tv(*this); tv.normalize(); return tv;}
bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;} bool isNull() const {PIMV_FOR(i, 0) if (c[i] != Type(0)) return false; return true;}
bool isValid() const {return !c.isEmpty();}
bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);} bool isOrtho(const _CVector & v) const {return ((*this) ^ v) == Type(0);}
Type & at(uint index) {return c[index];} Type & at(uint index) {return c[index];}
@@ -237,6 +239,9 @@ public:
PIMathVector turnTo(uint size) const {PIMathVector<Type1> tv; uint sz = piMin<uint>(c.size(), size); for (uint i = 0; i < sz; ++i) tv[i] = c[i]; return tv;} PIMathVector turnTo(uint size) const {PIMathVector<Type1> tv; uint sz = piMin<uint>(c.size(), size); for (uint i = 0; i < sz; ++i) tv[i] = c[i]; return tv;}
PIVector<Type> toVector() const {return c;} PIVector<Type> toVector() const {return c;}
inline Type * data() {return c.data();}
inline const Type * data() const {return c.data();}
private: private:
// uint size_; // uint size_;
PIVector<Type> c; PIVector<Type> c;
@@ -247,11 +252,17 @@ private:
#ifdef PIP_STD_IOSTREAM #ifdef PIP_STD_IOSTREAM
template<typename Type> template<typename Type>
inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v) {s << '{'; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << '}'; return s;} inline std::ostream & operator <<(std::ostream & s, const PIMathVector<Type> & v) {s << "{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
#endif #endif
template<typename Type> template<typename Type>
inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << '{'; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << '}'; return s;} inline PICout operator <<(PICout s, const PIMathVector<Type> & v) {s << "Vector{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
template<uint Size, typename Type>
inline PIByteArray & operator <<(PIByteArray & s, const PIMathVector<Type> & v) {s << v.c; return s;}
template<uint Size, typename Type>
inline PIByteArray & operator >>(PIByteArray & s, PIMathVector<Type> & v) {s >> v.c; return s;}
typedef PIMathVector<int> PIMathVectori; typedef PIMathVector<int> PIMathVectori;
typedef PIMathVector<double> PIMathVectord; typedef PIMathVector<double> PIMathVectord;

View File

@@ -1,4 +1,5 @@
#include "piopencl.h" #include "piopencl.h"
#define CL_USE_DEPRECATED_OPENCL_1_2_APIS
#ifdef MAC_OS #ifdef MAC_OS
# include "cl.h" # include "cl.h"
#else #else