23 #ifndef STEPCORE_TYPES_H
24 #define STEPCORE_TYPES_H
28 #define EIGEN_USE_NEW_STDVECTOR
29 #include <Eigen/StdVector>
31 #include <Eigen/Sparse>
46 operator unsigned int()
const {
return value; }
52 return QString(
"#%1").arg(v, 8, 16, QLatin1Char(
'0'));
58 QString s1 = s.trimmed();
59 if(!s1.startsWith(
'#'))
return Color(0);
61 return Color(s1.toUInt(ok, 16));
67 return QString::fromAscii(v.toBase64());
70 template<>
inline QByteArray
stringToType(
const QString& s,
bool *ok)
73 return QByteArray::fromBase64(s.toAscii());
79 return QString(
"(%1,%2)").arg(v[0]).arg(v[1]);
86 QString s1 = s.trimmed();
87 if(!s1.startsWith(
'(') || !s1.endsWith(
')'))
return Vector2d();
88 s1 = s1.mid(1, s1.size()-2);
90 StepCore::Vector2d v(s1.section(
',',0,0).toDouble(&ok1), s1.section(
',',1,1).toDouble(&ok2));
91 if(!ok1 || !ok2)
return v;
99 return QString(
"(%1,%2)").arg(v[0]).arg(v[1]);
106 QString s1 = s.trimmed();
107 if(!s1.startsWith(
'(') || !s1.endsWith(
')'))
return Vector2i();
108 s1 = s1.mid(1, s1.size()-2);
110 StepCore::Vector2i v(s1.section(
',',0,0).toInt(&ok1), s1.section(
',',1,1).toInt(&ok2));
111 if(!ok1 || !ok2)
return v;
117 typedef std::vector<Vector2d, Eigen::aligned_allocator<Vector2d> >
Vector2dList;
122 for(Vector2dList::const_iterator it = v.begin(); it != v.end(); ++it) {
123 if(!ret.isEmpty()) ret +=
",";
124 ret += QString(
"(%1,%2)").arg((*it)[0]).arg((*it)[1]);
134 QString s1 = s.trimmed();
137 while(s1[0] ==
'(' && s1.contains(
')')) {
138 bool ok;
double d1, d2;
140 d1 = s1.section(
',',0,0).toDouble(&ok);
142 s1 = s1.section(
',',1);
143 d2 = s1.section(
')',0,0).toDouble(&ok);
145 s1 = s1.section(
')',1).trimmed();
147 if(s1.isEmpty())
break;
149 s1 = s1.mid(1).trimmed();
158 #ifdef STEPCORE_WITH_QT
160 Q_DECLARE_METATYPE(StepCore::Object*)
161 Q_DECLARE_METATYPE(StepCore::Color)
Eigen::Vector2d Vector2d
Two-dimensional vector with double components.
Eigen::SparseMatrix< double, Eigen::RowMajor > SparseRowMatrix
Eigen::Map< Eigen::VectorXd > MappedVector
QString typeToString(const T &v)
Eigen::SparseMatrix< double > SparseColMatrix
Object, MetaObject and MetaProperty classes.
T stringToType(const QString &s, bool *ok)
Eigen::DynamicSparseMatrix< double, Eigen::RowMajor > DynSparseRowMatrix
Eigen::Vector2i Vector2i
Two-dimensional vector with integer components.
std::vector< Vector2d, Eigen::aligned_allocator< Vector2d > > Vector2dList