예제 #1
0
void IRInstruction::setOpcode(Opcode newOpc) {
  assert(hasEdges() || !JIT::hasEdges(newOpc)); // cannot allocate new edges
  if (hasEdges() && !JIT::hasEdges(newOpc)) {
    clearEdges();
  }
  m_op = newOpc;
}
예제 #2
0
long
GNEVehicleFrame::TripRouteCreator::onCmdAbortRouteCreation(FXObject*, FXSelector, void*) {
    clearEdges();
    // disable buttons
    myFinishCreationButton->disable();
    myAbortCreationButton->disable();
    myRemoveLastInsertedEdge->disable();
    return 1;
}
예제 #3
0
void IRInstruction::convertToNop() {
  if (hasEdges()) clearEdges();
  IRInstruction nop(Nop, marker());
  // copy all but m_id, m_edges, m_listNode
  m_op = nop.m_op;
  m_typeParam = nop.m_typeParam;
  m_numSrcs = nop.m_numSrcs;
  m_srcs = nop.m_srcs;
  m_numDsts = nop.m_numDsts;
  m_dst = nop.m_dst;
  m_extra = nullptr;
}
예제 #4
0
long
GNEVehicleFrame::TripRouteCreator::onCmdFinishRouteCreation(FXObject*, FXSelector, void*) {
    // only create route if there is more than two edges
    if (mySelectedEdges.size() > 1) {
        // obtain tag (only for improve code legibility)
        SumoXMLTag vehicleTag = myVehicleFrameParent->myItemSelector->getCurrentTagProperties().getTag();

        // Declare map to keep attributes from Frames from Frame
        std::map<SumoXMLAttr, std::string> valuesMap = myVehicleFrameParent->myVehicleAttributes->getAttributesAndValues(false);

        // add ID
        valuesMap[SUMO_ATTR_ID] = myVehicleFrameParent->myViewNet->getNet()->generateDemandElementID(vehicleTag);

        // add VType
        valuesMap[SUMO_ATTR_TYPE] = myVehicleFrameParent->myVTypeSelector->getCurrentVehicleType()->getID();

        // Add parameter departure
        if (valuesMap.count(SUMO_ATTR_DEPART) == 0) {
            valuesMap[SUMO_ATTR_DEPART] = "0";
        }


        // declare SUMOSAXAttributesImpl_Cached to convert valuesMap into SUMOSAXAttributes
        SUMOSAXAttributesImpl_Cached SUMOSAXAttrs(valuesMap, myVehicleFrameParent->getPredefinedTagsMML(), toString(vehicleTag));

        // obtain trip parameters in tripParameters
        SUMOVehicleParameter* tripParameters = SUMOVehicleParserHelper::parseVehicleAttributes(SUMOSAXAttrs);

        // create it in RouteFrame
        GNERouteHandler::buildTrip(myVehicleFrameParent->myViewNet, true, tripParameters, mySelectedEdges);

        // delete tripParameters
        delete tripParameters;

        // clear edges
        clearEdges();

        // disable buttons
        myFinishCreationButton->disable();
        myAbortCreationButton->disable();
        myRemoveLastInsertedEdge->disable();
    }
    return 1;
}
예제 #5
0
CommonGraphPtr findMSTKruskal(const CommonGraphPtr& graph)
{
    auto edges = graph->getEdges();
    std::sort(edges.begin(), edges.end(),
            [](const Edge& e1, const Edge& e2)
            {
                return e1.cost < e2.cost;
            });

    std::vector<unsigned> vertexGroups(graph->numberOfVertices_);
    for (unsigned i=0; i<vertexGroups.size(); ++i)
    {
        vertexGroups[i] = i;
    }

    auto mst = graph->clone();
    mst->clearEdges();

    for (const auto& e : edges)
    {
        if (vertexGroups[e.from] != vertexGroups[e.to])
        {
            mst->insertEdge(e.from, e.to, e.cost);

            unsigned sourceGroup = vertexGroups[e.from];
            unsigned destGroup = vertexGroups[e.to];

            for (auto& v : vertexGroups)
            {
                if (v == sourceGroup)
                {
                    v = destGroup;
                }
            }
        }
        if (mst->numberOfEdges_ == mst->numberOfVertices_ - 1)
        {
            break;
        }
    }

    return mst;
}
예제 #6
0
void IRInstruction::become(IRUnit& unit, IRInstruction* other) {
  assert(other->isTransient() || m_numDsts == other->m_numDsts);
  auto& arena = unit.arena();

  // Copy all but m_id, m_edges[].from, m_listNode, m_marker, and don't clone
  // dests---the whole point of become() is things still point to us.
  if (hasEdges() && !other->hasEdges()) {
    clearEdges();
  } else if (!hasEdges() && other->hasEdges()) {
    m_edges = new (arena) Edge[2];
    setNext(other->next());
    setTaken(other->taken());
  }
  m_op = other->m_op;
  m_typeParam = other->m_typeParam;
  m_numSrcs = other->m_numSrcs;
  m_extra = other->m_extra ? cloneExtra(m_op, other->m_extra, arena) : nullptr;
  m_srcs = new (arena) SSATmp*[m_numSrcs];
  std::copy(other->m_srcs, other->m_srcs + m_numSrcs, m_srcs);
}
예제 #7
0
파일: ofxFace.cpp 프로젝트: rezaali/ofxMesh
void ofxFace::clear()
{
    clearVerts();
    clearEdges();
}
예제 #8
0
CommonGraphPtr findMSTPrim(const CommonGraphPtr& graph)
{
    auto mst = graph->clone();
    mst->clearEdges();

    std::vector<unsigned> keys(graph->numberOfVertices_, infinity);
    std::vector<unsigned> parents(graph->numberOfVertices_, infinity);

    std::vector<unsigned> verticesLeft;
    verticesLeft.reserve(graph->numberOfVertices_);
    for (unsigned i=0; i<graph->numberOfVertices_; ++i)
    {
        verticesLeft.emplace_back(i);
    }

    auto getVertexWithLowestKey =
        [&]()
        {
            return
                std::min_element(verticesLeft.begin(), verticesLeft.end(),
                    [&](unsigned k1, unsigned k2)
                    {
                        return keys[k1] < keys[k2];
                    });
        };

    // variables used in the main loop
    auto minKeyVertexIt = verticesLeft.begin();
    auto minKeyVertex = *minKeyVertexIt;
    auto minKeyVertexParent = parents[minKeyVertex];
    unsigned edgeCost = 0;

    // first pass
    keys[0] = 0;
    parents[0] = 0;
    verticesLeft.erase(verticesLeft.begin());
    auto neighbours = graph->getNeighbours(0);
    for (const auto& n : neighbours)
    {
        parents[n.to] = 0;
        keys[n.to] = n.cost;
    }
    // main loop
    while (!verticesLeft.empty())
    {
        minKeyVertexIt = getVertexWithLowestKey();
        minKeyVertex = *minKeyVertexIt;
        verticesLeft.erase(minKeyVertexIt);

        minKeyVertexParent = parents[minKeyVertex];
        edgeCost = graph->getCost(minKeyVertex, minKeyVertexParent);
        mst->insertEdge(minKeyVertex, minKeyVertexParent, edgeCost);

        // update adjacent vertices
        neighbours = graph->getNeighbours(minKeyVertex);
        for (const auto& n : neighbours)
        {
            edgeCost = n.cost;
            if (edgeCost < keys[n.to])
            {
                parents[n.to] = minKeyVertex;
                keys[n.to] = edgeCost;
            }
        }

    }
    return mst;
}