Пример #1
0
        /// <summary>
        /// Sleeve部分のChordを作成する
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="neighbor">Neighbor.</param>
        /// <param name="pushChords">Push chords.</param>
        void MakeSleeveChord(Chord2D from, Face2D neighbor, ref List <Chord2D> pushChords)
        {
            Edge2D[] nextDstEdge;
            if (!neighbor.TryGetOtheInteriorEdge(from.dstEdge, out nextDstEdge))
            {
                throw new System.Exception("辺の内外判定が不正です。");
            }

            var chord = new Chord2D();

            chord.face    = neighbor;
            chord.src     = from.dst;
            chord.srcEdge = from.dstEdge;
            chord.dstEdge = nextDstEdge[0];
            chord.dst     = chord.dstEdge.mid;

            from.connections.Add(chord);

            var pair = new Chord2D();

            pair.face    = neighbor;
            pair.src     = chord.dst;
            pair.srcEdge = chord.dstEdge;
            pair.dstEdge = chord.srcEdge;
            pair.dst     = from.dst;

            pair.connections.Add(from.pair);

            chord.pair = pair;
            pair.pair  = chord;

            pushChords.Add(chord);
            sleeveChords.Add(chord);
        }
Пример #2
0
        /// <summary>
        /// Terminal部分のChordを作成する
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="neighbor">Neighbor.</param>
        /// <param name="pushChords">Push chords.</param>
        void MakeTerminalChord(Chord2D from, Face2D neighbor, ref List <Chord2D> pushChords)
        {
            var chord = new Chord2D();

            chord.face    = neighbor;
            chord.src     = neighbor.ExcludeVertex(from.dstEdge);
            chord.dstEdge = from.dstEdge;
            chord.dst     = chord.dstEdge.mid;

            chord.pair = chord;

            chord.connections.Add(from.pair);
            from.connections.Add(chord);

            terminalChords.Add(chord);
        }
Пример #3
0
        /// <summary>
        /// 入力したChordを削除する
        /// </summary>
        /// <param name="chord">Chord.</param>
        public void RemoveChord(Chord2D chord)
        {
            switch (chord.face.category)
            {
            case Face2D.Category.Sleeve:
                sleeveChords.Remove(chord);
                sleeveChords.Remove(chord.pair);
                break;

            case Face2D.Category.Junction:
                junctionChords.Remove(chord);
                junctionChords.Remove(chord.pair);
                break;

            case Face2D.Category.Terminal:
                terminalChords.Remove(chord);
                terminalChords.Remove(chord.pair);
                break;
            }
            chord.DisconnectSelf();
        }
Пример #4
0
        /// <summary>
        /// Junction部分のChordを作成する
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="neighbor">Neighbor.</param>
        /// <param name="pushChords">Push chords.</param>
        void MakeJunctionChord(Chord2D from, Face2D neighbor, ref List <Chord2D> pushChords)
        {
            var chord = new Chord2D();

            chord.face    = neighbor;
            chord.src     = from.dst;
            chord.srcEdge = from.dstEdge;
            chord.dst     = neighbor.g;

            from.connections.Add(chord);

            var pair = new Chord2D();

            pair.face    = neighbor;
            pair.src     = chord.dst;
            pair.dstEdge = from.dstEdge;
            pair.dst     = chord.src;

            pair.connections.Add(from.pair);

            chord.pair = pair;
            pair.pair  = chord;

            junctionChords.Add(chord);

            Edge2D[] otherEdges;
            if (!neighbor.TryGetOtheInteriorEdge(from.dstEdge, out otherEdges))
            {
                throw new System.Exception("辺の内外判定が不正です。");
            }
            foreach (var e in otherEdges)
            {
                var c = new Chord2D();
                c.face    = neighbor;
                c.src     = chord.dst;
                c.dst     = e.mid;
                c.dstEdge = e;

                chord.connections.Add(c);

                var p = new Chord2D();
                p.face    = neighbor;
                p.src     = c.dst;
                c.srcEdge = e;
                p.dst     = c.src;

                p.connections.Add(pair);

                c.pair = p;
                p.pair = c;

                junctionChords.Add(c);

                pushChords.Add(c);
            }

            var cp0 = chord.connections[0].pair;

            cp0.connections.Add(chord.connections[1]);

            var cp1 = chord.connections[1].pair;

            cp1.connections.Add(chord.connections[0]);
        }
Пример #5
0
        /// <summary>
        /// 軸の接続情報から余分な軸を削除する
        /// </summary>
        /// <returns>The fans.</returns>
        List <Fan2D> PruneBranch(ChordalAxis2D axis, List <Vector2> contour)
        {
            Stack <Chord2D> exploring = new Stack <Chord2D>();
            List <Vertex2D> vertices  = new List <Vertex2D>();
            List <Fan2D>    fans      = new List <Fan2D>();

            List <Chord2D> route = new List <Chord2D>();
            Chord2D        start = null;

            foreach (var c in axis.terminalChords)
            {
                exploring.Push(c);
            }

            while (exploring.Count > 0)
            {
                var c = exploring.Pop();
                if (c.face.category == Face2D.Category.Terminal)
                {
                    vertices.Clear();
                    route.Clear();
                    route.Add(c);
                    start = c;
                }

                if (c.face.category == Face2D.Category.Junction)
                {
                    vertices.Add(c.pair.dstEdge.a);
                    vertices.Add(c.pair.dstEdge.b);
                    var fan = new Fan2D(c.dst, vertices, contour, c.face);
                    fans.Add(fan);

                    // chordの接続を切る
                    foreach (var r in route)
                    {
                        axis.RemoveChord(r);
                    }
                }
                else
                {
                    var cc = c.dstEdge.circumscribedCircle;
                    vertices.Add(c.face.ExcludeVertex(c.dstEdge));

                    bool unoverlapped = false;
                    foreach (var v in vertices)
                    {
                        if (!cc.Overlap(v.p))
                        {
                            unoverlapped = true;
                            break;
                        }
                    }
                    if (unoverlapped)
                    {
                        vertices.Add(c.dstEdge.a);
                        vertices.Add(c.dstEdge.b);
                        var fan = new Fan2D(c.dstEdge.mid, vertices, contour, c.face);
                        fans.Add(fan);

                        // chordの接続を切る
                        foreach (var r in route)
                        {
                            axis.RemoveChord(r);
                        }
                    }
                    else
                    {
                        route.Add(c.connections[0]);
                        exploring.Push(c.connections[0]);
                    }
                }
            }

            return(fans);
        }