463 } |
463 } |
464 else |
464 else |
465 return Vertex(); |
465 return Vertex(); |
466 } |
466 } |
467 |
467 |
468 void LDBezierCurve::rasterize(Model& model, int segments) |
468 void LDBezierCurve::rasterize(DocumentManager* context, Winding winding, Model& model, bool, bool) |
469 { |
469 { |
470 QVector<LDPolygon> polygons = rasterizePolygons(segments); |
470 QVector<LDPolygon> polygons = rasterizePolygons(context, winding); |
471 |
471 |
472 for (LDPolygon& poly : polygons) |
472 for (LDPolygon& poly : polygons) |
473 { |
473 { |
474 LDEdgeLine* line = model.emplace<LDEdgeLine>(poly.vertices[0], poly.vertices[1]); |
474 LDEdgeLine* line = model.emplace<LDEdgeLine>(poly.vertices[0], poly.vertices[1]); |
475 line->setColor(LDColor {poly.color}); |
475 line->setColor(LDColor {poly.color}); |
476 } |
476 } |
477 } |
477 } |
478 |
478 |
479 QVector<LDPolygon> LDBezierCurve::rasterizePolygons(int segments) |
479 QVector<LDPolygon> LDBezierCurve::rasterizePolygons(DocumentManager*, Winding) |
480 { |
480 { |
481 QVector<LDPolygon> result; |
481 QVector<LDPolygon> result; |
482 QVector<Vertex> parms; |
482 QVector<Vertex> parms; |
483 parms.append (pointAt (0.0)); |
483 parms.append (pointAt (0.0)); |
484 |
484 |
485 for (int i = 1; i < segments; ++i) |
485 for (int i = 1; i < m_segments; ++i) |
486 parms.append (pointAt (double (i) / segments)); |
486 parms.append (pointAt (double (i) / m_segments)); |
487 |
487 |
488 parms.append (pointAt (1.0)); |
488 parms.append (pointAt (1.0)); |
489 LDPolygon poly; |
489 LDPolygon poly; |
490 poly.color = color().index(); |
490 poly.color = color().index(); |
491 poly.type = LDPolygon::Type::EdgeLine; |
491 poly.type = LDPolygon::Type::EdgeLine; |
492 |
492 |
493 for (int i = 0; i < segments; ++i) |
493 for (int i = 0; i < m_segments; ++i) |
494 { |
494 { |
495 poly.vertices[0] = parms[i]; |
495 poly.vertices[0] = parms[i]; |
496 poly.vertices[1] = parms[i + 1]; |
496 poly.vertices[1] = parms[i + 1]; |
497 result << poly; |
497 result << poly; |
498 } |
498 } |
499 |
499 |
500 return result; |
500 return result; |
|
501 } |
|
502 |
|
503 void LDBezierCurve::serialize(Serializer& serializer) |
|
504 { |
|
505 LDObject::serialize(serializer); |
|
506 serializer << m_segments; |
|
507 } |
|
508 |
|
509 int LDBezierCurve::segments() const |
|
510 { |
|
511 return m_segments; |
|
512 } |
|
513 |
|
514 void LDBezierCurve::setSegments(int newSegments) |
|
515 { |
|
516 changeProperty(&m_segments, newSegments); |
501 } |
517 } |
502 |
518 |
503 LDSubfileReference::LDSubfileReference( |
519 LDSubfileReference::LDSubfileReference( |
504 QString referenceName, |
520 QString referenceName, |
505 const QMatrix4x4& matrix |
521 const QMatrix4x4& matrix |