Exemplo n.º 1
0
        private static void CalculateScore(NativeArray <float2> vertices, ref IndexScore indexScore)
        {
            var prev = vertices[indexScore.PrevIndex];
            var curr = vertices[indexScore.CurrIndex];
            var next = vertices[indexScore.NextIndex];

            indexScore.Score = Cross(next - curr, curr - prev);
        }
Exemplo n.º 2
0
        public ScoreView(Employee _employee, ScoreViewType _type, string _tag)
        {
            InitializeComponent();
            List <IndexScore> l;

            this.DataContext = _employee;
            if (_type == ScoreViewType.Reba)
            {
                if (_tag == "left")
                {
                    l = new IndexScore().GetReba(_employee.Id, _employee.LeftReba_score.id);
                }
                else
                {
                    l = new IndexScore().GetReba(_employee.Id, _employee.Reba_score.id);
                }
            }
            else
            {
                if (_tag == "left")
                {
                    l = new IndexScore().GetRula(_employee.Id, _employee.LeftRula_score.id);
                }
                else
                {
                    l = new IndexScore().GetRula(_employee.Id, _employee.Rula_score.id);
                }
            }

            foreach (IndexScore _indexScore in l)
            {
                Label t = new Label();
                t.Content  = _indexScore.DisplayName;
                t.FontSize = 16;
                _stackPane1.Children.Add(t);

                Label t2 = new Label();
                t2.Content                    = (_indexScore.Score + _indexScore.AdditionalScore).ToString();
                t2.FontSize                   = 16;
                t2.BorderThickness            = new Thickness(0, 0, 0, 1);
                t2.BorderBrush                = (Brush)TryFindResource("KinectBluish");
                t2.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;

                _stackPane2.Children.Add(t2);
            }
        }
Exemplo n.º 3
0
        public static void Triangulate(NativeArray <float2> vertices, NativeArray <int> outIndices, out int outIndexCount)
        {
            outIndexCount = 0;

            if (vertices.Length < 3)
            {
                return;
            }

            var open = _sTempIndexScores ?? (_sTempIndexScores = new List <IndexScore>());

            open.Clear();

            var indexScore = new IndexScore
            {
                PrevIndex = vertices.Length - 2,
                CurrIndex = vertices.Length - 1
            };

            for (var i = 0; i < vertices.Length; ++i)
            {
                indexScore.NextIndex = i;

                CalculateScore(vertices, ref indexScore);

                open.Add(indexScore);

                indexScore.PrevIndex = indexScore.CurrIndex;
                indexScore.CurrIndex = indexScore.NextIndex;
            }

            // Ear clipping

            while (open.Count > 2)
            {
                var bestScore = float.PositiveInfinity;
                var bestIndex = -1;

                for (var i = 0; i < open.Count; ++i)
                {
                    var score = open[i].Score;

                    if (score > 0f && score < bestScore)
                    {
                        bestScore = score;
                        bestIndex = i;
                    }
                }

                if (bestIndex == -1)
                {
                    break;
                }

                var best = open[bestIndex];

                outIndices[outIndexCount++] = best.PrevIndex;
                outIndices[outIndexCount++] = best.CurrIndex;
                outIndices[outIndexCount++] = best.NextIndex;

                var prevIndex = (bestIndex - 1 + open.Count) % open.Count;
                var nextIndex = (bestIndex + 1) % open.Count;

                var prev = open[prevIndex];
                var next = open[nextIndex];

                prev.NextIndex = best.NextIndex;
                next.PrevIndex = best.PrevIndex;

                CalculateScore(vertices, ref prev);
                CalculateScore(vertices, ref next);

                open[prevIndex] = prev;
                open[nextIndex] = next;

                open.RemoveAt(bestIndex);
            }

            open.Clear();
        }