Пример #1
0
NodePtr LazyHydroGraph::addNode(CurvePtr c, int i, Graph::Changes &changed)
{
    CurveId riverId = c.cast<HydroCurve>()->getRiver();
    float potential = c.cast<HydroCurve>()->getPotential();
    NodePtr n = Graph::addNode(c, i, changed);
    for (int i = 0; i < 2; i++) {
        CurvePtr cc = n->getCurve(i);
        if (!(cc->getId() == c->getId())) {
            cc.cast<HydroCurve>()->setRiver(riverId);
            cc.cast<HydroCurve>()->setPotential(potential);
        }
    }
    return n;
}
Пример #2
0
CurvePtr LazyGraph::newCurve(CurvePtr model, NodePtr start, NodePtr end)
{
    CurveId id = nextCurveId;
    nextCurveId.id++;
    CurvePtr c = new LazyCurve(this, id, start->getId(), end->getId());
    start->addCurve(id);
    end->addCurve(id);
    if (model != NULL) {
        map<CurveId, long int>::iterator ci = curveOffsets.find(model->getId());
        curveOffsets.insert(make_pair(id, ci->second));
    } else {
        curveOffsets.insert(make_pair(id, (long int) -1));
    }
    curves.insert(make_pair(id, c.get()));

    curveCache->add(c.get(), true);
    return c;
}