public CLienDeGrapheReseau( int nIdLienReseau, int nIdSchemaReseau, CNoeudDeGrapheReseau noeudDepart, CNoeudDeGrapheReseau noeudArrivee, CEtapesExtremiteLienDeGraphe etapesDepart, CEtapesExtremiteLienDeGraphe etapesArrivee) : base(nIdLienReseau, nIdSchemaReseau) { m_noeudDepart = noeudDepart; m_noeudArrive = noeudArrivee; m_etapesNoeudArrivee = etapesArrivee; m_etapesNoeudDepart = etapesDepart; }
/// <summary> /// Calcule un graphe pour un schéma donné /// </summary> /// <param name="schema"></param> /// <param name="sens"></param> /// <returns></returns> public CResultAErreur CalculeGraphe( CSchemaReseau schema, ESensAllerRetourLienReseau?sens) { CResultAErreur result = CResultAErreur.True; m_baseDeGraphes.AddGrapheReseau(schema.Id, sens, this); m_sensGraphe = sens; m_nIdSchemaReseauRacine = schema.Id; m_baseLiens.Clear(); m_baseNoeuds.Clear(); m_dicSuccesseurs.Clear(); m_dicPredecesseurs.Clear(); Dictionary <int, CNoeudDeGrapheReseauSite> dicIdSiteToNoeud = new Dictionary <int, CNoeudDeGrapheReseauSite>(); Dictionary <int, CNoeudDeGrapheReseauEquipement> dicIdEquipementToNoeud = new Dictionary <int, CNoeudDeGrapheReseauEquipement>(); foreach (CElementDeSchemaReseau elt in schema.ElementsDeSchema)//Ne prend que les éléments de premier niveau { CSite site = elt.ElementAssocie as CSite; if (site != null) { CNoeudDeGrapheReseauSite noeud = new CNoeudDeGrapheReseauSite(site.Id, schema.Id, elt.IsCableALinterieur); if (!m_baseNoeuds.Contains(noeud)) { if (IntegreNoeud == null || IntegreNoeud(noeud)) { m_baseNoeuds.Add(noeud); dicIdSiteToNoeud[site.Id] = noeud; } } } else { CEquipementLogique eqpt = elt.ElementAssocie as CEquipementLogique; if (eqpt != null) { CNoeudDeGrapheReseauEquipement noeud = new CNoeudDeGrapheReseauEquipement(eqpt.Id, schema.Id); if (!m_baseNoeuds.Contains(noeud)) { if (IntegreNoeud == null || IntegreNoeud(noeud)) { m_baseNoeuds.Add(noeud); dicIdEquipementToNoeud[eqpt.Id] = noeud; } } } } } Dictionary <int, CGrapheReseau> dicGraphesCalcules = new Dictionary <int, CGrapheReseau>(); foreach (CElementDeSchemaReseau elt in schema.GetElementsForType <CLienReseau>()) { if (elt.SchemaReseau.Id == schema.Id) //Ne prend pas les sous schémas { CLienReseau lien = elt.ElementAssocie as CLienReseau; if (lien != null) { if (m_sensGraphe != null) { CDonneeDessinLienDeSchemaReseau donneeDessin = elt.DonneeDessin as CDonneeDessinLienDeSchemaReseau; if (donneeDessin == null) { continue; } if (m_sensGraphe.Value != donneeDessin.Forward_Backward) { continue; } } EDirectionLienReseau[] directions = new EDirectionLienReseau[] { EDirectionLienReseau.UnVersDeux, EDirectionLienReseau.DeuxVersUn }; foreach (EDirectionLienReseau direction in directions) { if (direction == lien.Direction.Code || lien.Direction == EDirectionLienReseau.Bidirectionnel) { int nSigne = direction == EDirectionLienReseau.UnVersDeux ? 1 : -1; IElementALiensReseau elt1 = null; IElementALiensReseau elt2 = null; CCheminLienReseau chemin1 = null; CCheminLienReseau chemin2 = null; if (direction == EDirectionLienReseau.UnVersDeux) { elt1 = lien.Element1; chemin1 = elt.RacineChemin1; elt2 = lien.Element2; chemin2 = elt.RacineChemin2; } else if (direction == EDirectionLienReseau.DeuxVersUn) { elt1 = lien.Element2; chemin1 = elt.RacineChemin2; elt2 = lien.Element1; chemin2 = elt.RacineChemin2; } if (!(elt1 is CSite) && !(elt1 is CEquipementLogique)) { elt1 = null; } if (!(elt2 is CSite) && !(elt2 is CEquipementLogique)) { elt2 = null; } if (elt1 != null && elt2 != null) { CNoeudDeGrapheReseau noeud1 = null; if (chemin1 != null) { result = GetNoeudDansSousSchema(elt1, chemin1);//Result testé ensuite avec noeud1 = null; noeud1 = result.Data as CNoeudDeGrapheReseau; } else { if (elt1 is CSite) { CNoeudDeGrapheReseauSite noeudSite = null; dicIdSiteToNoeud.TryGetValue(elt1.Id, out noeudSite); noeud1 = noeudSite; } else if (elt1 is CEquipementLogique) { CNoeudDeGrapheReseauEquipement noeudEqpt = null; dicIdEquipementToNoeud.TryGetValue(elt1.Id, out noeudEqpt); noeud1 = noeudEqpt; } } if (noeud1 == null) { result.EmpileErreur(I.T("Can not find link @1 extremity|20043", lien.Libelle)); return(result); } CNoeudDeGrapheReseau noeud2 = null; if (chemin2 != null) { result = GetNoeudDansSousSchema(elt2, chemin2);//Result testé ensuite avec noeud2= null; noeud2 = result.Data as CNoeudDeGrapheReseau; } else { if (elt2 is CSite) { CNoeudDeGrapheReseauSite noeudSite = null; dicIdSiteToNoeud.TryGetValue(elt2.Id, out noeudSite); noeud2 = noeudSite; } else if (elt2 is CEquipementLogique) { CNoeudDeGrapheReseauEquipement noeudEquip = null; dicIdEquipementToNoeud.TryGetValue(elt2.Id, out noeudEquip); noeud2 = noeudEquip; } } if (noeud2 == null) { result.EmpileErreur(I.T("Can not find link @1 extremity|20043", lien.Libelle)); return(result); } CLienDeGrapheReseau lienDeGraphe = m_baseLiens.GetObjet(typeof(CLienDeGrapheReseau), nSigne * lien.Id, schema.Id); if (lienDeGraphe == null) { CEtapesExtremiteLienDeGraphe etapes1 = null; if (chemin1 != null) { etapes1 = new CEtapesExtremiteLienDeGraphe(chemin1); } CEtapesExtremiteLienDeGraphe etapes2 = null; if (chemin2 != null) { etapes2 = new CEtapesExtremiteLienDeGraphe(chemin2); } lienDeGraphe = new CLienDeGrapheReseau( nSigne * lien.Id, schema.Id, noeud1, noeud2, etapes1, etapes2); if (IntegreLiaison == null || IntegreLiaison(lienDeGraphe)) { m_baseLiens.Add(lienDeGraphe); m_dicSuccesseurs.AddSuccesseur(noeud1, lienDeGraphe); m_dicPredecesseurs.AddPredecesseur(noeud2, lienDeGraphe); } } } } } } } } return(result); }