Example #1
0
        /// <summary>
        /// 面情報を作成する。
        /// </summary>
        /// <returns>The face.</returns>
        /// <param name="t">T.</param>
        /// <param name="contour">Contour.</param>
        /// <param name="vSet">V set.</param>
        Face2D MakeFace(Triangle2D t, List <Vector2> contour, VerticesSet2D vSet)
        {
            var a = vSet.FindNear(t.p0);
            var b = vSet.FindNear(t.p1);
            var c = vSet.FindNear(t.p2);

            var g = vSet.CheckAndAdd((a.p + b.p + c.p) / 3f);

            g.isExterior = false;

            var face = new Face2D(a, b, c, g);

            int  externalCount = 0;
            bool isExterior    = false;

            for (int i = 0, j = 2; i < 3; j = i++)
            {
                isExterior     = IsContourEdge(contour, face.vertices[i].p, face.vertices[j].p);
                externalCount += isExterior ? 1 : 0;
                var mid = vSet.CheckAndAdd((face.vertices[j].p + face.vertices[i].p) * 0.5f);
                mid.isExterior = false;
                var edge = new Edge2D(face.vertices[j], face.vertices[i], mid, isExterior);
                face.edges[j] = edge;
            }

            switch (externalCount)
            {
            case 0:
                face.category = Face2D.Category.Junction;
                break;

            case 1:
                face.category = Face2D.Category.Sleeve;
                break;

            case 2:
                face.category = Face2D.Category.Terminal;
                break;

            default:
                throw new System.Exception("輪郭情報とマッチしません。");
            }

            return(face);
        }
Example #2
0
        /// <summary>
        /// 頂点セットを作成する
        /// </summary>
        /// <param name="points">Points.</param>
        VerticesSet2D MakeVerticesSet(List <Vector2> points)
        {
            var vSet = new VerticesSet2D();

            for (var i = 0; i < points.Count; ++i)
            {
                var v = vSet.CheckAndAdd(points[i]);
                v.isExterior = true;
            }
            return(vSet);
        }