Exemplo n.º 1
0
bool sameCorner(const EdgePoint* a, const EdgePoint* b) {
    COLA_UNUSED(a);
    COLA_UNUSED(b);
    COLA_ASSERT( !(a->node->id==b->node->id
                &&a->rectIntersect==b->rectIntersect));
    return false;
}
void ClusterContainmentConstraints::generateSeparationConstraints(
        const vpsc::Dim dim, vpsc::Variables& vs, vpsc::Constraints& cs,
        std::vector<vpsc::Rectangle*>& bbs) 
{
    COLA_UNUSED(bbs);
    for (SubConstraintInfoList::iterator o = _subConstraintInfo.begin();
            o != _subConstraintInfo.end(); ++o) 
    {
        ClusterShapeOffsets *info = static_cast<ClusterShapeOffsets *> (*o);

        if (info->dim != dim)
        {
            continue;
        }

        if (info->offset < 0)
        {
            // Constrain the objects with negative offsets to be 
            // to the left of the boundary.
            vpsc::Constraint *constraint = new vpsc::Constraint( 
                    vs[info->varIndex], vs[info->boundaryVar], 
                    -info->offset);
            cs.push_back(constraint);
        }
        else
        {
            // Constrain the objects with positive offsets to be 
            // to the right of the boundary.
            vpsc::Constraint *constraint = new vpsc::Constraint(
                    vs[info->boundaryVar], vs[info->varIndex], 
                    info->offset);
            cs.push_back(constraint);
        }
    }
}
Exemplo n.º 3
0
bool zagzig(const EdgePoint* a, const Segment* s) {
    COLA_UNUSED(a);
    if(s!=nullptr) {
        COLA_ASSERT(!sameCorner(a,s->start));
    }
    return false;
}
Exemplo n.º 4
0
void RectangularCluster::generateFixedRectangleConstraints(
        cola::CompoundConstraints& idleConstraints,
        vpsc::Rectangles& rc, vpsc::Variables (&vars)[2]) const
{
    COLA_UNUSED(vars);

    if (m_rectangle_index < 0)
    {
        // Not based on a Rectangle.
        return;
    }

    double halfWidth = rc[m_rectangle_index]->width() / 2;
    double halfHeight = rc[m_rectangle_index]->height() / 2;

    cola::SeparationConstraint *sc = 
            new cola::SeparationConstraint(vpsc::XDIM, clusterVarId, 
                    m_rectangle_index, halfWidth, true);
    idleConstraints.push_back(sc);
    sc = new cola::SeparationConstraint(vpsc::XDIM, 
                    m_rectangle_index, clusterVarId + 1, halfWidth, true);
    idleConstraints.push_back(sc);
    
    sc = new cola::SeparationConstraint(vpsc::YDIM, 
                    clusterVarId, m_rectangle_index, halfHeight, true);
    idleConstraints.push_back(sc);
    sc = new cola::SeparationConstraint(vpsc::YDIM, 
                    m_rectangle_index, clusterVarId + 1, halfHeight, true);
    idleConstraints.push_back(sc);
}
bool zigzag(const EdgePoint* a, const Segment* s) {
    COLA_UNUSED(a);
    if(s!=NULL) {
        COLA_ASSERT(!sameCorner(a,s->end));
    }
    return false;
}
void ClusterContainmentConstraints::generateVariables(const vpsc::Dim dim,
        vpsc::Variables& vars) 
{
    COLA_UNUSED(dim);
    COLA_UNUSED(vars);
}
Exemplo n.º 7
0
// Processes sweep events used to determine each horizontal and vertical
// line segment in a connector's channel of visibility.
// Four calls to this function are made at each position by the scanline:
//   1) Handle all Close event processing.
//   2) Remove Close event objects from the scanline.
//   3) Add Open event objects to the scanline.
//   4) Handle all Open event processing.
//
static void processShiftEvent(NodeSet& scanline, Event *e, size_t dim,
                              unsigned int pass)
{
    Node *v = e->v;

    if ( ((pass == 3) && (e->type == Open)) ||
            ((pass == 3) && (e->type == SegOpen)) )
    {
        std::pair<NodeSet::iterator, bool> result = scanline.insert(v);
        v->iter = result.first;
        COLA_ASSERT(result.second);

        NodeSet::iterator it = v->iter;
        // Work out neighbours
        if (it != scanline.begin())
        {
            Node *u = *(--it);
            v->firstAbove = u;
            u->firstBelow = v;
        }
        it = v->iter;
        if (++it != scanline.end())
        {
            Node *u = *it;
            v->firstBelow = u;
            u->firstAbove = v;
        }
    }

    if ( ((pass == 4) && (e->type == Open)) ||
            ((pass == 4) && (e->type == SegOpen)) ||
            ((pass == 1) && (e->type == SegClose)) ||
            ((pass == 1) && (e->type == Close)) )
    {
        if (v->ss)
        {
            // As far as we can see.
            double minLimit = v->firstObstacleAbove(dim);
            double maxLimit = v->firstObstacleBelow(dim);

            v->ss->minSpaceLimit =
                std::max(minLimit, v->ss->minSpaceLimit);
            v->ss->maxSpaceLimit =
                std::min(maxLimit, v->ss->maxSpaceLimit);
        }
        else
        {
            v->markShiftSegmentsAbove(dim);
            v->markShiftSegmentsBelow(dim);
        }
    }

    if ( ((pass == 2) && (e->type == SegClose)) ||
            ((pass == 2) && (e->type == Close)) )
    {
        // Clean up neighbour pointers.
        Node *l = v->firstAbove, *r = v->firstBelow;
        if (l != NULL)
        {
            l->firstBelow = v->firstBelow;
        }
        if (r != NULL)
        {
            r->firstAbove = v->firstAbove;
        }

        size_t result;
        result = scanline.erase(v);
        COLA_ASSERT(result == 1);
        COLA_UNUSED(result);  // Avoid warning.
        delete v;
    }
}
void NonOverlapConstraints::generateVariables(const vpsc::Dim dim,
        vpsc::Variables& vars) 
{
    COLA_UNUSED(dim);
    COLA_UNUSED(vars);
}