示例#1
0
void PolygonClip::sutherlandHodgmanPolygonClip(glm::vec2* inVertexArray, glm::vec2* outVertexArray, 
                                               int inLength, int& outLength,  const LineSegment2& clipBoundary) {
    glm::vec2 start, end; // Start, end point of current polygon edge
    glm::vec2 intersection;   // Intersection point with a clip boundary

    outLength = 0;
    start = inVertexArray[inLength - 1]; // Start with the last vertex in inVertexArray
    for (int j = 0; j < inLength; j++) {
        end = inVertexArray[j]; // Now start and end correspond to the vertices
        
        // Cases 1 and 4 - the endpoint is inside the boundary 
        if (pointInsideBoundary(end,clipBoundary)) {
            // Case 1 - Both inside
            if (pointInsideBoundary(start, clipBoundary)) {
                appendPoint(end, outLength, outVertexArray);
            } else { // Case 4 - end is inside, but start is outside
                segmentIntersectsBoundary(start, end, clipBoundary, intersection);
                appendPoint(intersection, outLength, outVertexArray);
                appendPoint(end, outLength, outVertexArray);
            }
        } else { // Cases 2 and 3 - end is outside
            if (pointInsideBoundary(start, clipBoundary))  { 
                // Cases 2 - start is inside, end is outside
                segmentIntersectsBoundary(start, end, clipBoundary, intersection);
                appendPoint(intersection, outLength, outVertexArray);
            } else {
                // Case 3 - both are outside, No action
            }
       } 
       start = end;  // Advance to next pair of vertices
    }
}
void SVGPathStringBuilder::emitSegment(const PathSegmentData& segment)
{
    ASSERT(segment.command > PathSegUnknown && segment.command <= PathSegCurveToQuadraticSmoothRel);
    m_stringBuilder.append(pathSegmentCharacter[segment.command]);

    switch (segment.command) {
    case PathSegMoveToRel:
    case PathSegMoveToAbs:
    case PathSegLineToRel:
    case PathSegLineToAbs:
    case PathSegCurveToQuadraticSmoothRel:
    case PathSegCurveToQuadraticSmoothAbs:
        appendPoint(m_stringBuilder, segment.targetPoint);
        break;
    case PathSegLineToHorizontalRel:
    case PathSegLineToHorizontalAbs:
        appendFloat(m_stringBuilder, segment.targetPoint.x());
        break;
    case PathSegLineToVerticalRel:
    case PathSegLineToVerticalAbs:
        appendFloat(m_stringBuilder, segment.targetPoint.y());
        break;
    case PathSegClosePath:
        break;
    case PathSegCurveToCubicRel:
    case PathSegCurveToCubicAbs:
        appendPoint(m_stringBuilder, segment.point1);
        appendPoint(m_stringBuilder, segment.point2);
        appendPoint(m_stringBuilder, segment.targetPoint);
        break;
    case PathSegCurveToCubicSmoothRel:
    case PathSegCurveToCubicSmoothAbs:
        appendPoint(m_stringBuilder, segment.point2);
        appendPoint(m_stringBuilder, segment.targetPoint);
        break;
    case PathSegCurveToQuadraticRel:
    case PathSegCurveToQuadraticAbs:
        appendPoint(m_stringBuilder, segment.point1);
        appendPoint(m_stringBuilder, segment.targetPoint);
        break;
    case PathSegArcRel:
    case PathSegArcAbs:
        appendPoint(m_stringBuilder, segment.point1);
        appendFloat(m_stringBuilder, segment.point2.x());
        appendBool(m_stringBuilder, segment.arcLarge);
        appendBool(m_stringBuilder, segment.arcSweep);
        appendPoint(m_stringBuilder, segment.targetPoint);
        break;
    default:
        ASSERT_NOT_REACHED();
    }
    m_stringBuilder.append(' ');
}
示例#3
0
void StructureMap::registerObjectDetected(double distance, double angle, double opacity, int size) {
	if (finish) return;
	Trafo2D objectLocation = create->tracker->getTransformation() * Trafo2D::rot(Rad(angle)) * Trafo2D::trans(0, distance);

	Vector2D p = Vector2D(objectLocation.trans().x(),objectLocation.trans().y());

	appendPoint(p);

}
示例#4
0
void RandomPlot::append(int timeout, int count)
{
    if ( !d_timer )
    {
        d_timer = new QTimer(this);
        connect(d_timer, SIGNAL(timeout()), SLOT(appendPoint()));
    }

    d_timerCount = count;

    Q_EMIT running(true);
    d_timeStamp.start();

    canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, false);
    d_timer->start(timeout);
}
示例#5
0
int RandomPlot::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = IncrementalPlot::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: running((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 1: clear(); break;
        case 2: stop(); break;
        case 3: append((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 4: appendPoint(); break;
        }
        _id -= 5;
    }
    return _id;
}
示例#6
0
void BrainPlot::timeStep(std::vector<float> data) {
    /*Curves*/
    for(int c = 0; c < nChannels; c++)
        appendPoint(QPointF(sample%plotLength, data[c]), c);

    /*Sweep line*/
    CurveData *sweep = static_cast<CurveData *>( d_sweep->data() );
    sweep->replace(0, QPointF((sample)%plotLength, plotLength));
    sweep->replace(1, QPointF((sample)%plotLength, 2*nChannels*minusExpectedAmplitude));
    setClipRegion(d_sweep, QPointF(0,0));
    d_directPainter->drawSeries( d_sweep, 0, 1);

    /*Time step*/
    sample++;

    /*Refreshes plot*/
    replot();
}
示例#7
0
Ref<BasicShape> BasicShapePolygon::blend(const BasicShape& other, double progress) const
{
    ASSERT(type() == other.type());

    auto& otherPolygon = downcast<BasicShapePolygon>(other);
    ASSERT(m_values.size() == otherPolygon.values().size());
    ASSERT(!(m_values.size() % 2));

    size_t length = m_values.size();
    auto result = BasicShapePolygon::create();
    if (!length)
        return WTFMove(result);

    result->setWindRule(otherPolygon.windRule());

    for (size_t i = 0; i < length; i = i + 2) {
        result->appendPoint(m_values.at(i).blend(otherPolygon.values().at(i), progress),
            m_values.at(i + 1).blend(otherPolygon.values().at(i + 1), progress));
    }

    return WTFMove(result);
}
示例#8
0
void StructureMap::addStructureMapPoint(Vector2D p){
	appendPoint(p);
}
void Plotter::appendPoint(qreal y)
{
    appendPoint(y, "default");
}
示例#10
0
void DebugDraw::appendPoint(float x, float y, float r, float g, float b)
{
	appendPoint(ccp(x, y), r, g, b);
}
void CurveData::appendPoint(double x, double y) {
  appendPoint(QPointF(x, y));
}