Ejemplo n.º 1
0
 public Edge2D(Vertex2D a, Vertex2D b, Vertex2D mid, bool isExterior)
 {
     this.a          = a;
     this.b          = b;
     this.mid        = mid;
     this.isExterior = isExterior;
 }
Ejemplo n.º 2
0
        public Face2D(Vertex2D a, Vertex2D b, Vertex2D c, Vertex2D g)
        {
            this.vertices    = new Vertex2D[3];
            this.vertices[0] = a;
            this.vertices[1] = b;
            this.vertices[2] = c;

            this.g = g;

            this.edges = new Edge2D[3];
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 距離を確認し付近にすでに存在しない場合に追加する。
        /// </summary>
        /// <param name="p">P.</param>
        public Vertex2D CheckAndAdd(Vector2 p)
        {
            var nearest = FindNear(p);

            if (nearest != null)
            {
                return(nearest);
            }
            var v = new Vertex2D(p);

            v.index = vertices.Count;
            vertices.Add(v);
            return(v);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 重複がないかを確認して追加する
 /// </summary>
 /// <param name="v">V.</param>
 /// <param name="e">E.</param>
 void CheckAndAdd(Vertex2D v, Vertex2D e)
 {
     if (!connection.ContainsKey(v))
     {
         connection.Add(v, new List <Vertex2D> {
             e
         });
     }
     else
     {
         if (!connection[v].Contains(e))
         {
             connection[v].Add(e);
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 入力された座標の近くに頂点が存在する場合はそれを返す。
        /// </summary>
        /// <returns>The near.</returns>
        /// <param name="p">P.</param>
        /// <param name="range">Range.</param>
        public Vertex2D FindNear(Vector2 p, float range = 0.01f)
        {
            if (vertices.Count <= 0)
            {
                return(null);
            }
            float    d       = range;
            Vertex2D nearest = null;

            for (var i = 0; i < vertices.Count; ++i)
            {
                var v  = vertices[i];
                var td = (v.p - p).magnitude;
                if (td < d)
                {
                    d       = td;
                    nearest = v;
                }
            }
            return(nearest);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 内側に広がる面を作成する
        /// </summary>
        /// <returns>The surface interior.</returns>
        /// <param name="dic">Dic.</param>
        /// <param name="a">The alpha component.</param>
        /// <param name="b">The blue component.</param>
        /// <param name="m">M.</param>
        Surface MakeSurface_Interior(Dictionary <ElevatedEdge, ElevatedEdge> dic, Vertex2D a, Vertex2D b, Vertex2D m, bool isReverse = false)
        {
            var d = UtilsMath.Cross(a.p - m.p, m.p - b.p);

            if (!isReverse ? d >= 0 : d < 0)
            {
                var temp = a;
                a = b;
                b = temp;
            }

            ElevatedEdge ma = new ElevatedEdge(m, a);
            ElevatedEdge mb = new ElevatedEdge(m, b);

            CheckAndAdd(dic, ma);
            CheckAndAdd(dic, mb);

            Surface surf = new Surface(Surface.Divergent.Interior, dic[ma], dic[mb]);

            return(surf);
        }
Ejemplo n.º 7
0
 public ElevatedEdge(Vertex2D foot, Vertex2D top)
 {
     this.foot = foot;
     this.top  = top;
 }
Ejemplo n.º 8
0
 public Vertex2D GetOtherVertex(Vertex2D v)
 {
     return(v == a ? b : a);
 }
Ejemplo n.º 9
0
 public bool HasVertex(Vertex2D v)
 {
     return(v.GetHashCode() == a.GetHashCode() || v.GetHashCode() == b.GetHashCode());
 }
Ejemplo n.º 10
0
 public Fan2D(Vertex2D baseVertex, List <Vertex2D> fanVertices, List <Vector2> contour, Face2D baseFace)
 {
     this.baseVertex  = baseVertex;
     this.fanVertices = AlignFanVertices(fanVertices, contour);
     this.baseFace    = baseFace;
 }