void TNEANet::DelNode(const int& NId) { int i; const TNode& Node = GetNode(NId); for (int out = 0; out < Node.GetOutDeg(); out++) { const int EId = Node.GetOutEId(out); const TEdge& Edge = GetEdge(EId); IAssert(Edge.GetSrcNId() == NId); GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); // Delete from Edge Attributes for (i = 0; i < VecOfIntVecsE.Len(); i++) { TVec<TInt>& IntVec = VecOfIntVecsE[i]; IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn); } for (i = 0; i < VecOfStrVecsE.Len(); i++) { TVec<TStr>& StrVec = VecOfStrVecsE[i]; StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr()); } for (i = 0; i < VecOfFltVecsE.Len(); i++) { TVec<TFlt>& FltVec = VecOfFltVecsE[i]; FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn); } } for (int in = 0; in < Node.GetInDeg(); in++) { const int EId = Node.GetInEId(in); const TEdge& Edge = GetEdge(EId); IAssert(Edge.GetDstNId() == NId); GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId); EdgeH.DelKey(EId); // Delete from Edge Attributes for (i = 0; i < VecOfIntVecsE.Len(); i++) { TVec<TInt>& IntVec = VecOfIntVecsE[i]; IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn); } for (i = 0; i < VecOfStrVecsE.Len(); i++) { TVec<TStr>& StrVec = VecOfStrVecsE[i]; StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr()); } for (i = 0; i < VecOfFltVecsE.Len(); i++) { TVec<TFlt>& FltVec = VecOfFltVecsE[i]; FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn); } } for (i = 0; i < VecOfIntVecsN.Len(); i++) { TVec<TInt>& IntVec = VecOfIntVecsN[i]; IntVec.Ins(NodeH.GetKeyId(NId), TInt::Mn); } for (i = 0; i < VecOfStrVecsN.Len(); i++) { TVec<TStr>& StrVec = VecOfStrVecsN[i]; StrVec.Ins(NodeH.GetKeyId(NId), TStr::GetNullStr()); } for (i = 0; i < VecOfFltVecsN.Len(); i++) { TVec<TFlt>& FltVec = VecOfFltVecsN[i]; FltVec.Ins(NodeH.GetKeyId(NId), TFlt::Mn); } NodeH.DelKey(NId); }
void TNEGraph::DelEdge(const int& EId) { IAssert(IsEdge(EId)); const int SrcNId = GetEdge(EId).GetSrcNId(); const int DstNId = GetEdge(EId).GetDstNId(); GetNode(SrcNId).OutEIdV.DelIfIn(EId); GetNode(DstNId).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); }
void ribi::cmap::QtConceptMap::CheckInvariants() const noexcept { #ifndef NDEBUG //If there is one QtEdge selected, its Edge must be able to been found try { const auto qtedge = ExtractTheOneSelectedQtEdge(*GetScene()); //The QtEdge its edge must be in the concept map //Can only compare IDs, as QtEdge::GetEdge() and its equivalent in the concept map may mismatch assert( has_custom_edge_with_my_edge( qtedge->GetEdge(), GetConceptMap(), [](const Edge& lhs, const Edge& rhs) { return lhs.GetId() == rhs.GetId(); } ) ); const auto edge = ExtractTheOneSelectedEdge(this->GetConceptMap(), *GetScene()); assert(qtedge->GetEdge().GetId() == edge.GetId()); } catch (...) {} //No problem //All QtNodes must have a scene { const auto qtnodes = GetQtNodes(scene()); for (const auto qtnode: qtnodes) { assert(qtnode); assert(qtnode->scene()); } } //All QtEdges, their QtNodes and Arrows must have a scene { const auto qtedges = GetQtEdges(scene()); for (const auto qtedge: qtedges) { assert(qtedge); assert(qtedge->scene()); assert(qtedge->GetArrow()); assert(qtedge->GetArrow()->scene()); assert(qtedge->GetQtNode()); assert(qtedge->GetQtNode()->scene()); assert(qtedge->GetFrom()); assert(qtedge->GetFrom()->scene()); assert(qtedge->GetTo()); assert(qtedge->GetTo()->scene()); } } #endif }
int AdjacentNode(graph *g, int FromNode, int index) { edge *retEdge = GetEdge(g, FromNode, index); if(retEdge == NULL) return -1; else return retEdge->to; }
int ValueFromEdge(graph *g, int FromNode, int index) { edge *retEdge = GetEdge(g, FromNode, index); if(retEdge == NULL) return -1; else return retEdge->value; }
double CostFromEdge(graph *g, int FromNode, int index) { edge *retEdge = GetEdge(g, FromNode, index); if(retEdge == NULL) return -1; else return retEdge->cost; }
/* ================== WriteFace ================== */ void WriteFace (face_t *f) { dface_t *df; int i; int e; f->outputnumber = numfaces; df = &dfaces[numfaces]; if (numfaces >= MAX_MAP_FACES) Error ("numfaces == MAX_MAP_FACES"); numfaces++; df->planenum = f->planenum & (~1); df->side = f->planenum & 1; df->firstedge = numsurfedges; df->numedges = f->numpoints; df->texinfo = f->texturenum; for (i=0 ; i<f->numpoints ; i++) { e = GetEdge (f->pts[i], f->pts[(i+1)%f->numpoints], f); if (numsurfedges >= MAX_MAP_SURFEDGES) Error ("numsurfedges == MAX_MAP_SURFEDGES"); dsurfedges[numsurfedges] = e; numsurfedges++; } }
// // try to guess type of roof from looking at slopes of edges of // this level // RoofType vtLevel::GuessRoofType() { int sloped = 0, vert = 0, hori = 0; int i, edges = NumEdges(); for (i = 0; i < edges; i++) { vtEdge *edge = GetEdge(i); if (edge->m_iSlope == 0) hori++; else if (edge->m_iSlope == 90) vert++; else sloped++; } if (hori) return ROOF_FLAT; if (sloped == 1 && vert == edges-1) return ROOF_SHED; if (sloped == edges) return ROOF_HIP; if (sloped > 0 && vert > 0) return ROOF_GABLE; return ROOF_UNKNOWN; }
/** * @sa EmitDrawNode_r * @note Called for every node face */ static void EmitFace (const face_t* f) { dBspSurface_t* df; int i; if (f->numpoints < 3) { return; /* degenerated */ } if (f->merged || f->split[0] || f->split[1]) { return; /* not a final face */ } if (curTile->numfaces >= MAX_MAP_FACES) Sys_Error("numfaces >= MAX_MAP_FACES (%i)", curTile->numfaces); df = &curTile->faces[curTile->numfaces]; curTile->numfaces++; df->planenum = f->planenum & (~1); df->side = f->planenum & 1; df->firstedge = curTile->numsurfedges; df->numedges = f->numpoints; df->texinfo = f->texinfo; for (i = 0; i < f->numpoints; i++) { const int e = GetEdge(f->vertexnums[i], f->vertexnums[(i + 1) % f->numpoints], f); if (curTile->numsurfedges >= MAX_MAP_SURFEDGES) Sys_Error("numsurfedges >= MAX_MAP_SURFEDGES (%i)", curTile->numsurfedges); curTile->surfedges[curTile->numsurfedges] = e; curTile->numsurfedges++; } for (i = 0; i < LIGHTMAP_MAX; i++) df->lightofs[i] = -1; }
void touchmind::view::linkedge::impl::ArrowLinkEdgeView::CreateDeviceDependentResources( touchmind::Context *pContext, ID2D1RenderTarget *pRenderTarget) { if (GetLinkModel().expired()) { return; } auto link = GetLinkModel().lock(); if (!link->IsValid()) { return; } auto linkEdge = link->GetEdge(GetEdgeId()); auto node = link->GetNode(GetEdgeId()); if (linkEdge->IsRepaintRequired(GetRepaintCounter()) || m_pArrowGeometry == nullptr || m_pBrush == nullptr) { ID2D1Factory *pD2DFactory = pContext->GetD2DFactory(); D2D1_POINT_2F point0 = link->GetEdgePoint(GetEdgeId()); std::vector<D2D1_POINT_2F> points; view::GeometryBuilder::CalculateArrowPoints(point0, linkEdge->GetMarkerSize() + link->GetLineWidth(), linkEdge->GetMarkerSize() + link->GetLineWidth(), linkEdge->GetAngle(), node->GetAncestorPosition(), points); m_pArrowGeometry = nullptr; CHK_RES(m_pArrowGeometry, view::GeometryBuilder::CreatePathGeometryFromPoints(pD2DFactory, points, &m_pArrowGeometry)); m_pBrush = nullptr; CHK_RES(m_pBrush, pRenderTarget->CreateSolidColorBrush(link->GetLineColor(), D2D1::BrushProperties(), &m_pBrush)); SetRepaintCounter(linkEdge); } }
bool TNEGraph::IsEdge(const int& SrcNId, const int& DstNId, int& EId, const bool& Dir) const { const TNode& SrcNode = GetNode(SrcNId); for (int edge = 0; edge < SrcNode.GetOutDeg(); edge++) { const TEdge& Edge = GetEdge(SrcNode.GetOutEId(edge)); if (DstNId == Edge.GetDstNId()) { EId = Edge.GetId(); return true; } } if (! Dir) { for (int edge = 0; edge < SrcNode.GetInDeg(); edge++) { const TEdge& Edge = GetEdge(SrcNode.GetInEId(edge)); if (DstNId == Edge.GetSrcNId()) { EId = Edge.GetId(); return true; } } } return false; }
float PolyLine2::Distance( const PolyLine2& p ) const { int nSA = GetNSegments(); int nSB = p.GetNSegments(); if (nSA == 0 || nSB == 0) return 0.0f; float res = GetEdge( 0 ).dist2( p.GetEdge( 0 ) ); for (int i = 0; i < nSA; i++) { for (int j = 0; j < nSB; j++) { float cDist = GetEdge( i ).dist2( p.GetEdge( j ) ); if (cDist < res) res = cDist; } } return sqrtf( res ); }
void TNEGraph::DelNode(const int& NId) { const TNode& Node = GetNode(NId); for (int out = 0; out < Node.GetOutDeg(); out++) { const int EId = Node.GetOutEId(out); const TEdge& Edge = GetEdge(EId); IAssert(Edge.GetSrcNId() == NId); GetNode(Edge.GetDstNId()).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); } for (int in = 0; in < Node.GetInDeg(); in++) { const int EId = Node.GetInEId(in); const TEdge& Edge = GetEdge(EId); IAssert(Edge.GetDstNId() == NId); GetNode(Edge.GetSrcNId()).OutEIdV.DelIfIn(EId); EdgeH.DelKey(EId); } NodeH.DelKey(NId); }
void ribi::cmap::QtEdge::OnTextChanged(QtRoundedEditRectItem* item) noexcept { assert(!"Am I called?"); const auto new_name = item->GetText()[0]; const auto old_name = GetEdge().GetNode().GetConcept().GetName(); if (old_name != new_name) { this->GetEdge().GetNode().GetConcept().SetName(new_name); } }
CMesh::TTriangle *CMesh::AddTriangle(TVertex *pVert0, TVertex *pVert1, TVertex *pVert2, int iIndex) { ASSERT(m_hashVertices.Find(pVert0) && m_hashVertices.Find(pVert1) && m_hashVertices.Find(pVert2)); #ifdef _DEBUG { TTriangle kTestTri(pVert0, pVert1, pVert2); TTriangleHash::TIter it = m_hashTriangles.Find(&kTestTri); ASSERT(!it); CVector<3> vNormal = kTestTri.GetNormal(); float fArea = vNormal.Length(); ASSERT(fArea > 0.25); float fEdgeLen = Util::Max((pVert0->m_vCoord - pVert1->m_vCoord).Length(), Util::Max((pVert1->m_vCoord - pVert2->m_vCoord).Length(), (pVert2->m_vCoord - pVert0->m_vCoord).Length())); ASSERT(fEdgeLen * fEdgeLen / fArea < MAX_ELONGATION); } #endif TTriangle *pTri = new TTriangle(pVert0, pVert1, pVert2); if (iIndex >= 0) pTri->m_iIndex = iIndex; else pTri->m_iIndex = m_hashTriangles.m_iCount; m_hashTriangles.Add(pTri); pVert0->AddTriangle(pTri); pVert1->AddTriangle(pTri); pVert2->AddTriangle(pTri); TEdge *pEdge0, *pEdge1, *pEdge2; pEdge0 = GetEdge(pVert0, pVert1, true); pEdge0->AddTriangle(pTri); pEdge1 = GetEdge(pVert1, pVert2, true); ASSERT(pEdge1 != pEdge0); pEdge1->AddTriangle(pTri); pEdge2 = GetEdge(pVert2, pVert0, true); ASSERT(pEdge2 != pEdge1 && pEdge2 != pEdge0); pEdge2->AddTriangle(pTri); return pTri; }
void touchmind::model::node::NodeModel::UpdateLinkStatus_SaveRequired() { std::for_each(m_links.begin(), m_links.end(), [](std::weak_ptr<touchmind::model::link::LinkModel> _link) { if (!_link.expired()) { auto link = _link.lock(); link->IncrementSaveRequiredCounter(); link->GetEdge(EDGE_ID_1)->IncrementSaveRequiredCounter(); link->GetEdge(EDGE_ID_2)->IncrementSaveRequiredCounter(); } }); }
bool PolyLine2::Intersects( const Seg2& seg, bool bClosed ) const { int nSeg = GetNSegments(); if (!bClosed) nSeg--; for (int i = 0; i < nSeg; i++) { if (seg.intersects( GetEdge( i ), true )) return true; } return false; }
int CP_GeneralPolygon2D::GetEdgeIndex(CP_MeshVertex3D *v1, CP_MeshVertex3D *v2 ) { int numOfEdge = GetEdgeSize(); for (int i = 0; i < numOfEdge; ++i) { CP_GeneralEdge *edgei = GetEdge(i); if ((edgei->m_pStart == v1) && (edgei->m_pEnd == v2) || (edgei->m_pStart == v2) && (edgei->m_pEnd == v1)) { return i; } } return -1; }
int TriMesh::GetAdjacentTri(int tri,int e) const { int a,b; GetEdge(tri,e,a,b); for(size_t i=0;i<tris.size();i++) { if((int)i==tri) continue; if(tris[i].contains(a) && tris[i].contains(b)) return i; } return -1; }
/* ================== FindFaceEdges ================== */ static void FindFaceEdges (face_t *face) { int i; face->outputnumber = -1; if (face->numpoints > MAXEDGES) Error ("%s: %i points", __thisfunc__, face->numpoints); for (i = 0; i < face->numpoints ; i++) face->edges[i] = GetEdge (face->pts[i], face->pts[(i+1)%face->numpoints], face); }
void HitMap::CalculateTotalEdgel() { int edgelCount = 0; int edgeNum = GetEdgeNum(); for(int i=0;i<edgeNum;i++) { HitMapEdge edge = GetEdge(i); int edgelNum = edge.GetEdgelNum(); edgelCount += edgelNum; } totalEdgelNum = edgelCount; }
bool CMesh::CheckEdges() { TEdgeHash::TIter it; int i; for (it = m_hashEdges; it; ++it) { for (i = 0; i < 2; i++) if (it->m_pTriangles[i]) { TEdge *pEdge0, *pEdge1, *pEdge2; pEdge0 = GetEdge(it->m_pTriangles[i]->m_pVertices[0], it->m_pTriangles[i]->m_pVertices[1]); pEdge1 = GetEdge(it->m_pTriangles[i]->m_pVertices[1], it->m_pTriangles[i]->m_pVertices[2]); pEdge2 = GetEdge(it->m_pTriangles[i]->m_pVertices[2], it->m_pTriangles[i]->m_pVertices[0]); ASSERT(*it == pEdge0 || *it == pEdge1 || *it == pEdge2); } } TTriangleHash::TIter itTri; for (itTri = m_hashTriangles; itTri; ++itTri) { TEdge *pEdge0, *pEdge1, *pEdge2; pEdge0 = GetEdge(itTri->m_pVertices[0], itTri->m_pVertices[1]); pEdge1 = GetEdge(itTri->m_pVertices[1], itTri->m_pVertices[2]); pEdge2 = GetEdge(itTri->m_pVertices[2], itTri->m_pVertices[0]); ASSERT(pEdge0 && pEdge0->m_pTriangles[0] == *itTri || pEdge0->m_pTriangles[1] == *itTri); ASSERT(pEdge1 && pEdge1->m_pTriangles[0] == *itTri || pEdge1->m_pTriangles[1] == *itTri); ASSERT(pEdge2 && pEdge2->m_pTriangles[0] == *itTri || pEdge2->m_pTriangles[1] == *itTri); } return true; }
bool PolyLine2::FindPath( const Seg2& moveSeg, PolyLine2& path ) const { path.Clear(); const Vec2& a = moveSeg.a; const Vec2& b = moveSeg.b; if (!PtIn( a ) || !PtIn( b )) return false; int nPt = m_Points.size(); Vec2 pt; float minDist = FLT_MAX; float maxDist = 0.0f; int nBeg1 = -1; int nBeg2 = -1; int nEnd1 = -1; int nEnd2 = -1; for (int i = 0; i < nPt; i++) { Seg2 seg = GetEdge( i ); if (!seg.intersects( moveSeg, false, &pt )) continue; float dist = pt.dist2( a ); if (dist < minDist) { minDist = dist; nBeg1 = i; nBeg2 = i + 1; } if (dist > maxDist) { maxDist = dist; nEnd1 = i + 1; nEnd2 = i; } } GetSubPoly( nBeg1, nEnd1, path, false ); path.InsertPoint( 0, a ); path.AddPoint( b ); float len = path.GetLength( false ); GetSubPoly( nBeg2, nEnd2, path, true ); path.InsertPoint( 0, a ); path.AddPoint( b ); if (path.GetLength( false ) > len) { GetSubPoly( nBeg1, nEnd1, path, false ); path.InsertPoint( 0, a ); path.AddPoint( b ); } return true; }
void TNEANet::DelEdge(const int& EId) { int i; IAssert(IsEdge(EId)); const int SrcNId = GetEdge(EId).GetSrcNId(); const int DstNId = GetEdge(EId).GetDstNId(); GetNode(SrcNId).OutEIdV.DelIfIn(EId); GetNode(DstNId).InEIdV.DelIfIn(EId); EdgeH.DelKey(EId); for (i = 0; i < VecOfIntVecsE.Len(); i++) { TVec<TInt>& IntVec = VecOfIntVecsE[i]; IntVec.Ins(EdgeH.GetKeyId(EId), TInt::Mn); } for (i = 0; i < VecOfStrVecsE.Len(); i++) { TVec<TStr>& StrVec = VecOfStrVecsE[i]; StrVec.Ins(EdgeH.GetKeyId(EId), TStr::GetNullStr()); } for (i = 0; i < VecOfFltVecsE.Len(); i++) { TVec<TFlt>& FltVec = VecOfFltVecsE[i]; FltVec.Ins(EdgeH.GetKeyId(EId), TFlt::Mn); } }
bool PolyLine2::AddPoint( const Vec2& pt, bool bNoSelfCross ) { int nP = GetNPoints(); if (bNoSelfCross && nP > 0) { int nSeg = GetNSegments() - 2; Seg2 newSeg( pt, GetPoint( nP - 1 ) ); for (int i = 0; i < nSeg; i++) { if (newSeg.intersects( GetEdge( i ) )) return false; } } m_Points.push_back( pt ); return true; }
void CMesh::RemoveTriangleEdge(TTriangle *pTri, int iEdge) { TEdge *pEdge = GetEdge(pTri->m_pVertices[iEdge], pTri->m_pVertices[(iEdge + 1) % 3]); ASSERT(pEdge); pEdge->RemoveTriangle(pTri); if (!pEdge->m_pTriangles[0]) { m_hashEdges.RemoveValue(pEdge); ASSERT(pEdge->m_iHeapInd[0] >= 0 && pEdge->m_iHeapInd[1] >= 0); ASSERT(m_heapEdgeRefs[pEdge->m_iHeapInd[0]].m_pEdge == pEdge); ASSERT(m_heapEdgeRefs[pEdge->m_iHeapInd[1]].m_pEdge == pEdge); m_heapEdgeRefs.Remove(pEdge->m_iHeapInd[0]); m_heapEdgeRefs.Remove(pEdge->m_iHeapInd[1]); delete pEdge; } }
void SCH_SHEET_PIN::SwapData( SCH_ITEM* aItem ) { wxCHECK_RET( aItem->Type() == SCH_SHEET_PIN_T, wxString::Format( wxT( "SCH_SHEET_PIN object cannot swap data with %s object." ), GetChars( aItem->GetClass() ) ) ); SCH_SHEET_PIN* pin = ( SCH_SHEET_PIN* ) aItem; SCH_TEXT::SwapData( (SCH_TEXT*) pin ); int tmp = pin->GetNumber(); pin->SetNumber( GetNumber() ); SetNumber( tmp ); SHEET_SIDE stmp = pin->GetEdge(); pin->SetEdge( GetEdge() ); SetEdge( stmp ); }
void ProcessEdges() { for (EdgeStructSet::const_iterator itr = m_edgeStructs.begin(); itr != m_edgeStructs.end(); ++itr) { CDotEdge * dotEdge = itr->second.get(); assert(dotEdge); IVertex * vSource = m_graph->GetVertex(dotEdge->m_source, true); assert(vSource); IVertex * vTarget = m_graph->GetVertex(dotEdge->m_target, true); assert(vTarget); assert(!dotEdge->m_name.empty()); IEdge * edge = GetEdge(m_graph, dotEdge->m_name, vSource, vTarget, m_merge); assert(edge); edge->SetProperty(DOT_PROP_CDOTITEM, dotEdge); } }
/* ============ idAASLocal::ShowWallEdges ============ */ void idAASLocal::ShowWallEdges( const idVec3 &origin ) const { int i, areaNum, numEdges, edges[1024]; idVec3 start, end; idPlayer *player; player = gameLocal.GetLocalPlayer(); if( !player ) { return; } areaNum = PointReachableAreaNum( origin, DefaultSearchBounds(), ( AREA_REACHABLE_WALK | AREA_REACHABLE_FLY ) ); numEdges = GetWallEdges( areaNum, idBounds( origin ).Expand( 256.0f ), TFL_WALK, edges, 1024 ); for( i = 0; i < numEdges; i++ ) { GetEdge( edges[i], start, end ); gameRenderWorld->DebugLine( colorRed, start, end ); gameRenderWorld->DrawText( va( "%d", edges[i] ), ( start + end ) * 0.5f, 0.1f, colorWhite, player->viewAxis ); } }
bool CPlanarGraph::CheckDuplicatedEdge(const CGraphEdge& edge) { int idx10 = edge.GetIdx0(); int idx11 = edge.GetIdx1(); for ( int i=0; i<GetNumOfEdges(); i++ ) { CGraphEdge& edge0 = GetEdge(i); int idx00 = edge0.GetIdx0(); int idx01 = edge0.GetIdx1(); if ( (idx00 == idx10 && idx01 == idx11) || (idx00 == idx11 && idx01 == idx10) ) { return true; } } return false; }