58 #include <QLatin1Char>
59 #include <QMessageLogger>
60 #include <QPaintEngineState>
61 #include <QPainterPath>
64 #include <QTextStream>
68 #include "../vmisc/diagnostic.h"
69 #include "../vmisc/vmath.h"
86 QT_WARNING_DISABLE_CLANG(
"-Wsign-conversion")
87 QT_WARNING_DISABLE_INTEL(68)
88 QT_WARNING_DISABLE_INTEL(2022)
90 return QPaintEngine::PaintEngineFeatures(
91 QPaintEngine::AllFeatures
92 & ~QPaintEngine::PatternBrush
93 & ~QPaintEngine::PerspectiveTransform
94 & ~QPaintEngine::ConicalGradientFill
95 & ~QPaintEngine::PorterDuff);
104 , globalPointsCount(0)
118 #if defined(Q_CC_INTEL)
119 #pragma warning( pop )
133 qWarning(
"VObjEngine::begin(), no output device");
138 if (
outputDevice->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate) ==
false)
140 qWarning(
"VObjEngine::begin(), could not open output device: '%s'",
147 qWarning(
"VObjEngine::begin(), could not write to read-only output device: '%s'",
152 if (
size.isValid() ==
false)
154 qWarning()<<
"VObjEngine::begin(), size is not valid";
159 *
stream <<
"# Seamly2D OBJ File\n";
160 *
stream <<
"# www.seamly2d-project.org/\n";
175 QPaintEngine::DirtyFlags flags = state.state();
178 flags |= QPaintEngine::AllDirty;
181 if (flags & QPaintEngine::DirtyTransform)
190 QPolygonF polygon = path.toFillPolygon(
transform);
192 if (polygon.size() < 3)
197 qint64 sq =
Square(polygon);
200 *
stream <<
"o Plane." << QString(
"%1").arg(
planeCount, 3, 10, QLatin1Char(
'0')) <<
'\n';
202 quint32 num_points = 0;
204 for (
int i=0; i < polygon.count(); i++)
208 points[num_points].
x = polygon.at(i).x();
209 points[num_points].
y = polygon.at(i).y();
220 for (quint32 i = 0; i < res->
num_faces; i++ )
230 int num_verts =
static_cast<int>(res->
faces[offset]);
232 for (
int j = 0; j < num_verts; j++ )
234 int p0 =
static_cast<int>(res->
faces[offset + j]);
237 if (skipFace ==
false )
240 for (
int i = 0; i < num_verts; i++ )
242 face << QPointF(pf[i]);
244 QPolygonF united = polygon.united(face);
245 qint64 sqUnited =
Square(united);
248 drawPolygon(pf, num_verts, QPaintEngine::OddEvenMode);
266 for (
int i = 0; i < pointCount; ++i)
276 QPaintEngine::drawPolygon(
points, pointCount, mode);
282 return QPaintEngine::User;
288 for (
int i = 0; i < pointCount; ++i)
290 qreal x = ((
points[i].
x() - 0)/qFloor(
size.width()/2.0)) - 1.0;
291 qreal y = (((
points[i].
y() - 0)/qFloor(
size.width()/2.0)) - 1.0)*-1;
293 *
stream <<
"v" <<
" " << QString::number(x,
'f', 6 ) <<
" " << QString::number(y,
'f', 6 ) <<
" "
302 QPaintEngine::drawPoints(
points, pointCount);
323 Q_ASSERT(not isActive());
336 Q_ASSERT(not isActive());
349 Q_ASSERT(not isActive());
357 QPolygonF uniquePolygon;
358 for (
int i=0; i < polygon.count(); i++)
360 if (set.contains(polygon.at(i)) ==
false)
362 set.append(polygon.at(i));
363 uniquePolygon.append(polygon.at(i));
366 return uniquePolygon;
375 int n = poly.count();
379 for (
int i=0; i < n; i++)
381 x.append(poly.at(i).x());
382 y.append(poly.at(i).y());
386 for (
int i = 0; i < n; i++)
390 s = x.at(i)*(y.at(n-1) - y.at(i+1));
397 s = x.at(i)*(y.at(i-1) - y.at(0));
402 s = x.at(i)*(y.at(i-1) - y.at(i+1));
407 sq = qFloor(qAbs(res/2.0));
virtual void drawPath(const QPainterPath &path) Q_DECL_OVERRIDE
void setOutputDevice(QIODevice *value)
virtual void drawPoints(const QPointF *points, int pointCount) Q_DECL_OVERRIDE
int getResolution() const
virtual ~VObjEngine() Q_DECL_OVERRIDE
virtual bool end() Q_DECL_OVERRIDE
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) Q_DECL_OVERRIDE
qint64 Square(const QPolygonF &poly) const
virtual Type type() const Q_DECL_OVERRIDE
QPolygonF MakePointsUnique(const QPolygonF &polygon) const
virtual bool begin(QPaintDevice *pdev) Q_DECL_OVERRIDE
virtual void updateState(const QPaintEngineState &state) Q_DECL_OVERRIDE
QSharedPointer< QIODevice > outputDevice
void setSize(const QSize &value)
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) Q_DECL_OVERRIDE
quint32 globalPointsCount
QIODevice * getOutputDevice() const
del_point2d_t points[512]
QSharedPointer< QTextStream > stream
void setResolution(int value)
void delaunay2d_release(delaunay2d_t *del)
delaunay2d_t * delaunay2d_from(del_point2d_t *points, quint32 num_points)
static QPaintEngine::PaintEngineFeatures svgEngineFeatures()