int ParseTree::addEdge(int fromNode, int toNode, int gEdge) { int idx = edgeSet().size(); for ( int i = 0; i < idx; ++i ) { if ( edgeSet()[i]->idx()[PtEdge::IDX_FROM] == fromNode && edgeSet()[i]->idx()[PtEdge::IDX_TO] == toNode ) { RGM_LOG(error, "duplicated pt edge" ); return -1; } } getEdgeSet().push_back( new PtEdge(fromNode, toNode, gEdge)); getEdgeSet().back()->getIdx()[PtEdge::IDX_MYSELF] = idx; getNodeSet()[fromNode]->getIdxOutEdges().push_back(idx); getNodeSet()[toNode]->getIdxInEdges().push_back(idx); return idx; }
void GNEJunction::updateCrossingAttributes(NBNode::Crossing crossing) { EdgeSet edgeSet(crossing.edges.begin(), crossing.edges.end()); for (std::vector<NBNode::Crossing>::iterator it = myNBNode.myCrossings.begin(); it != myNBNode.myCrossings.end(); ++it) { EdgeSet edgeSet2((*it).edges.begin(), (*it).edges.end()); if (edgeSet == edgeSet2) { (*it).width = crossing.width; (*it).priority = crossing.priority; myNet->refreshElement(this); break; } } }
void GNEJunction::removeFromCrossings(GNEEdge* edge, GNEUndoList* undoList) { // @todo implement GNEChange_Crossing UNUSED_PARAMETER(undoList); // make a copy because the original will be modified const std::vector<NBNode::Crossing> crossings = myNBNode.getCrossings(); for (std::vector<NBNode::Crossing>::const_iterator it = crossings.begin(); it != crossings.end(); it++) { EdgeSet edgeSet((*it).edges.begin(), (*it).edges.end()); if (edgeSet.count(edge->getNBEdge()) == 1) { myNBNode.removeCrossing((*it).edges); } } }
void EdgeSetIF::fillJSON(rapidjson::Document& jsonDoc, rapidjson::Document::AllocatorType& allocator, unsigned short depth) { rapidjson::Value edgeSet(rapidjson::kArrayType); jsonDoc.AddMember("Number of edges", numberOfEdges, allocator); begin(); while (hasNext()) { edgeSet.PushBack( JSONUtils::getDepthLimitedJSON(next(), allocator, "EdgeIF", depth), allocator); } jsonDoc.AddMember("Edge set", edgeSet, allocator); }
/// Returns a list of edges in the delaunay triangulation. const std::vector<DelaunayTriangulation::Edge>& DelaunayTriangulation::edges() const { if(d->delaunayEdges.empty()){ std::vector<Edge> edges; EdgeSet edgeSet(d->vertices.size()); foreach(const std::vector<int> &tetrahedron, tetrahedra()){ for(int i = 0; i < 4; i++){ for(int j = i + 1; j < 4; j++){ Edge edge; edge[0] = tetrahedron[i]; edge[1] = tetrahedron[j]; if(!edgeSet.contains(edge[0], edge[1])){ edges.push_back(edge); edgeSet.insert(edge[0], edge[1]); } } } } d->delaunayEdges = edges; }
CellCountAccessor *MBBigRealCalculator::followBlackEdge(const CPoint &p, CellCountAccessor *cca, UINT maxCount) { if(!enterFollowBlackEdge(p, cca)) { return cca; } try { CHECKPENDING(); MBContainer &mbc = getMBContainer(); const CSize sz = mbc.getWindowSize(); const CRect rect(m_currentRect.left,m_currentRect.top, sz.cx, sz.cy); CPoint q = p; Direction dir = S, firstDir = NODIR; int edgeCount = 1; // p assumed to be set to black bool innerSetEmpty = true; PointSet edgeSet(rect), innerSet(rect); edgeSet.add(p); cca->setCount(p, maxCount); m_doneCount++; #ifdef SAVE_CALCULATORINFO m_info = new CalculatorInfo(getId(), rect); #endif // DLOG(_T("Follow black edge starting at (%d,%d)\n"), p.x,p.y); EdgeMatrix edgeMatrix; for(;;) { for(int dy = -1; dy <= 1; dy++) { const int qy = q.y + dy; if(qy < rect.top) { edgeMatrix.setRowOutside(0); continue; } else if(qy >= rect.bottom) { edgeMatrix.setRowOutside(2); continue; } for(int dx = -1; dx <= 1; dx++) { if(!edgeMatrix.isDirty(dy+1, dx+1)) { continue; } const int qx = q.x+dx; if((qx < rect.left) || (qx >= rect.right)) { edgeMatrix.setOutside(dy+1, dx+1); } else { const UINT c = cca->getCount(qx, qy); if(c == maxCount) { edgeMatrix.setInside(dy+1, dx+1); } else if(c != EMPTYCELLVALUE) { edgeMatrix.setOutside(dy+1, dx+1); } else { const BigReal &xt = s_xValue[qx]; const BigReal &yt = s_yValue[qy]; const UINT count = FINDCOUNT(xt, yt, maxCount); if(count == maxCount) { edgeMatrix.setInside(dy+1, dx+1); } else { edgeMatrix.setOutside(dy+1, dx+1); cca->setCount(qx,qy, count); m_doneCount++; } } } } } if((dir = edgeMatrix.findStepDirection(dir)) == NODIR) { if(!innerSetEmpty) { DLOG(_T("dir == NODIR and has innerpoints\n")); innerSet -= edgeSet; } #ifdef SAVE_CALCULATORINFO m_info->setEdgeAndInnerSet(edgeSet, innerSet); addInfoToPool(); #endif goto Return; } else if(firstDir == NODIR) { firstDir = dir; } else if((q == p) && dir == firstDir) { break; } if(edgeMatrix.getLeftAttr(dir)) { innerSet.add(q + EdgeMatrix::s_leftStep[dir]); innerSetEmpty = false; CHECKPENDING(); } q += EdgeMatrix::s_dirStep[dir]; if(!edgeSet.contains(q)) { cca->setCount(q, maxCount); m_doneCount++; edgeSet.add(q); if(!(edgeCount++ & 0xf)) updateThreadTime(); } edgeMatrix.adjustAttributes(dir); } bool edgeIsSubtracted = false; if((edgeCount >= 8) && !innerSetEmpty) { innerSet -= edgeSet; edgeIsSubtracted = true; cca = fillInnerArea(innerSet, cca, maxCount); } #ifdef SAVE_CALCULATORINFO if(!edgeIsSubtracted) { innerSet -= edgeSet; edgeIsSubtracted = true; } m_info->setEdgeAndInnerSet(edgeSet, innerSet); addInfoToPool(); #endif Return: leaveFollowBlackEdge(); return cca; } catch (...) { leaveFollowBlackEdge(); throw; } }