Beispiel #1
0
        public ChordalAxis2D(Face2D terminal, EdgeConnection2D connection)
        {
            sleeveChords   = new List <Chord2D>();
            junctionChords = new List <Chord2D>();
            terminalChords = new List <Chord2D>();

            MakeChordalAxis(terminal, connection);
        }
Beispiel #2
0
        /// <summary>
        /// 辺による面の接続関係を作成する。
        /// </summary>
        /// <returns>The edge connection.</returns>
        /// <param name="faces">Faces.</param>
        EdgeConnection2D MakeEdgeConnection(List <Face2D> faces)
        {
            var edgeConnection = new EdgeConnection2D();

            for (var i = 0; i < faces.Count; ++i)
            {
                edgeConnection.AddFace(faces[i]);
            }
            return(edgeConnection);
        }
Beispiel #3
0
        /// <summary>
        /// 終端の面と接続情報から軸を作成する
        /// </summary>
        /// <param name="terminal">Terminal.</param>
        /// <param name="connection">Connection.</param>
        void MakeChordalAxis(Face2D terminal, EdgeConnection2D connection)
        {
            if (terminal.category != Face2D.Category.Terminal)
            {
                throw new System.ArgumentException("最初の面はterminalでなければなりません。");
            }

            var origin = new Chord2D();

            origin.face = terminal;
            for (int i = 0, j = terminal.edges.Length - 1; i < terminal.edges.Length; j = i++)
            {
                if (!terminal.edges[i].isExterior)
                {
                    origin.src     = terminal.vertices[j];
                    origin.dstEdge = terminal.edges[i];
                    origin.dst     = origin.dstEdge.mid;
                    break;
                }
            }

            origin.pair = origin;

            this.terminalChords.Add(origin);
            this.origin = origin;

            Face2D          neighbor;
            Stack <Chord2D> exploring = new Stack <Chord2D>();
            List <Chord2D>  temporary = new List <Chord2D>();

            exploring.Push(origin);

            while (exploring.Count > 0)
            {
                var cur = exploring.Pop();
                if (cur == null)
                {
                    continue;
                }

                if (!connection.TryGetNeighbor(cur.dstEdge, cur.face, out neighbor))
                {
                    throw new System.ArgumentException("接続情報が構築されていません");
                }

                temporary.Clear();
                switch (neighbor.category)
                {
                case Face2D.Category.Sleeve:
                    MakeSleeveChord(cur, neighbor, ref temporary);
                    break;

                case Face2D.Category.Junction:
                    MakeJunctionChord(cur, neighbor, ref temporary);
                    break;

                case Face2D.Category.Terminal:
                    MakeTerminalChord(cur, neighbor, ref temporary);
                    break;
                }
                for (int i = 0; i < temporary.Count; ++i)
                {
                    exploring.Push(temporary[i]);
                }
            }
        }