Пример #1
0
 public void AddEdge(CavePoint point, CaveEdge edge)
 {
     if (!AdjacencyList.ContainsKey(point))
     {
         AdjacencyList.Add(point, new List<CaveEdge>());
     }
     AdjacencyList[point].Add(edge);
 }
Пример #2
0
 public CaveEdge(CavePoint startPoint, CavePoint endPoint, double length, double azimuth, double vangle)
 {
     StartPoint = startPoint;
     EndPoint = endPoint;
     Length = length;
     Azimuth = azimuth;
     VerticalAngle = vangle;
 }
Пример #3
0
        protected override IEnumerable<IGeometry> GetGeometry(CavePoint p1, CavePoint p2)
        {
            if (p1.Point != null && p2.Point != null)
            {
                return new[] {new LineSegment(p1.Point.Value, p2.Point.Value)};
            }

            LogManager.GetCurrentClassLogger().ErrorFormat("Can not build LineSegment one of the points has empty coordinates. p1Name={0}, p2Name={1}", p1.Name, p2.Name);
            return null;
        }
Пример #4
0
        public CavePoint GetPoint(string name, CaveGraph cave)
        {
            CavePoint p;
            if (cave.PointsDict.ContainsKey(name))
            {
                p = cave.PointsDict[name];
            }
            else
            {
                p = new CavePoint { Name = name };
                cave.PointsDict.Add(name, p);
            }

            return p;
        }
Пример #5
0
        protected override IEnumerable<IGeometry> GetGeometry(CavePoint p1, CavePoint p2)
        {
            if (p1.Point != null && p2.Point != null)
            {
                var geoms = new List<IGeometry>();
                geoms.Add(new TubeSegment(p1.Point.Value, p2.Point.Value, p1.Diameter, p2.Diameter));

                if (!points.ContainsKey(p1))
                {
                    points.Add(p1, new List<CavePoint>());
                }
                points[p1].Add(p2);

                if (!points.ContainsKey(p2))
                {
                    points.Add(p2, new List<CavePoint>());
                }
                points[p2].Add(p1);

                return geoms;
            }
            LogManager.GetCurrentClassLogger().ErrorFormat("Can not build TubeSegment one of the points has empty coordinates. p1Name={0}, p2Name={1}", p1.Name, p2.Name);
            return null;
        }
Пример #6
0
        private void Bfs(CavePoint root)
        {
            Queue<CavePoint> queue = new Queue<CavePoint>();
            queue.Enqueue(root);
            HashSet<string> used = new HashSet<string>();

            while(queue.Count>0)
            {
                var v = queue.Dequeue();
                used.Add(v.Name);

                if (!AdjacencyList.ContainsKey(v))
                {
                    continue;
                }

                foreach (var edge in AdjacencyList[v])
                {
                    if (!used.Contains(edge.EndPoint.Name))
                    {
                        edge.ResolveEndCoordinates();
                        used.Add(edge.EndPoint.Name);
                        queue.Enqueue(edge.EndPoint);
                    }
                }
            }
        }
Пример #7
0
 protected abstract IEnumerable<IGeometry> GetGeometry(CavePoint p1, CavePoint p2);