示例#1
0
文件: Graph.cs 项目: moto2002/BoEG
        public void DeleteHalfEdge(HalfEdge edge)
        {
            if (edge.Origin.Edge == edge)
            {
                foreach (var temp in edge.Origin.Walk())
                {
                    if (temp == edge)
                    {
                        continue;
                    }
                    edge.Origin.SetEdge(temp);
                    break;
                }

                if (edge.Origin.Edge == edge)
                {
                    edge.Origin.SetEdge(null);
                }
            }

            if (edge.Twin.Origin.Edge == edge.Twin)
            {
                foreach (var temp in edge.Twin.Origin.Walk())
                {
                    if (temp == edge.Twin)
                    {
                        continue;
                    }
                    edge.Twin.Origin.SetEdge(temp);
                    break;
                }

                if (edge.Twin.Origin.Edge == edge)
                {
                    edge.Twin.Origin.SetEdge(null);
                }
            }


//            edge.Next.SetPrevious(edge.Previous);
//            edge.Twin.Next.SetPrevious(edge.Twin.Previous);

            HalfEdges.Remove(edge.Twin);
            HalfEdges.Remove(edge);

            edge.Twin.SetOrigin(null);
            edge.Twin.SetPolygon(null);
            edge.Twin.SetNext(null);
            edge.Twin.SetPrevious(null);
            edge.Twin.SetTwin(null);

            edge.SetPair(null);
            edge.Twin.SetPair(null);

            edge.SetOrigin(null);
            edge.SetPolygon(null);
            edge.SetNext(null);
            edge.SetPrevious(null);
            edge.SetTwin(null);
        }
示例#2
0
文件: Graph.cs 项目: moto2002/BoEG
        public HalfEdge CreateEdge(Node aNode, Node bNode, bool isDirected = false)
        {
//            if (aNode.Edge != null && bNode.Edge != null)
//                throw new Exception();

            var edgeAB = new HalfEdge(this);
            var edgeBA = new HalfEdge(this);
            var edge   = new Edge(this);

            var edgePolygon = CreatePolygon(edgeAB);

            edgeAB.SetOrigin(aNode);
            edgeBA.SetOrigin(bNode);

            edgeAB.SetNext(edgeBA);
            edgeAB.SetPrevious(edgeBA);
            edgeAB.SetTwin(edgeBA);

            edgeAB.SetPolygon(edgePolygon);
            edgeBA.SetPolygon(edgePolygon);

            if (isDirected)
            {
                edgeBA.SetActive(false);
            }

            edge.SetPair(edgeAB);

            Edges.Add(edge);
            HalfEdges.Add(edgeAB);
            HalfEdges.Add(edgeBA);
            return(edgeAB);
        }
示例#3
0
 public void SetEdge(HalfEdge edge)
 {
     Edge = edge;
     if (edge != null && edge.Origin != this)
     {
         edge.SetOrigin(this);
     }
 }