Exemplo n.º 1
0
        public Teddy(List <Vector2> contour)
        {
            if (contour.Count < 4)
            {
                throw new System.ArgumentException("輪郭の頂点数は4つ以上必要です。");
            }

            // 面情報を作成する。
            var delaunay = Delaunay2D.Contour(contour);

            vset  = MakeVerticesSet(contour);
            faces = MakeFaces(delaunay, contour, vset);

            // 辺による接続関係を作成する
            connection = MakeEdgeConnection(faces);

            // 面同士の接続関係を作成する
            var terminal = faces.Find(t => t.category == Face2D.Category.Terminal);

            axis = new ChordalAxis2D(terminal, connection);

            // 平面の骨格情報
            skeleton = new Skeleton2D(axis, contour);

            // 立体に変換
            volume = skeleton.ToSkeletalVolume();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public Skeleton2D(ChordalAxis2D axis, List <Vector2> contour)
 {
     this.axis = axis;
     fans      = PruneBranch(axis, contour);
     ElevateInterior();
 }