Esempio n. 1
0
        private void buttonProcess_Click(object sender, EventArgs e)
        {
            if (connection == null)
            {
                connection = new PriorNonTrivalConnection(Mesh);

                singularites = new List <KeyValuePair <HalfEdgeMesh.Vertex, double> >();
                //singularites.Add(new KeyValuePair<HalfEdgeMesh.Vertex, double>(Mesh.Vertices[0],2));
            }

            //Update Singularities
            connection.Singularities.Clear();
            for (int i = 0; i < selected.Count; i++)
            {
                connection.Singularities.Add(new KeyValuePair <HalfEdgeMesh.Vertex, double>(selected[i], selectedValues[i]));
            }


            //Update Generator
            connection.GeneratorValues.Clear();
            for (int i = 0; i < generatorsValues.Count; i++)
            {
                connection.GeneratorValues.Add(new KeyValuePair <List <HalfEdgeMesh.HalfEdge>, double>(connection.Generators[i], generatorsValues[i]));
            }

            connection.Update();

            Vector3D[] vectorFields = connection.ComputeVectorField(Angle);

            GlobalSetting.DisplaySetting.DisplayMode = EnumDisplayMode.Vector;
            GlobalData.Instance.FaceVectors          = vectorFields;
            GlobalData.Instance.N = (int)NnumericUpDown.Value;
            OnChanged(EventArgs.Empty);
        }
Esempio n. 2
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            if (selected == null)
            {
                selected = new List<TriMesh.Vertex>();
                selectedValues = new List<double>();

            }
            else
            {
                selected.Clear();
                selectedValues.Clear();
            }

            if (connection == null)
            {
                connection = new PriorNonTrivalConnection(Mesh);

                singularites = new List<KeyValuePair<HalfEdgeMesh.Vertex, double>>();

                for (int i = 0; i < selected.Count; i++)
                {
                    singularites.Add(new KeyValuePair<HalfEdgeMesh.Vertex, double>(selected[i], selectedValues[i]));
                }

                connection.Singularities = singularites;
            }
            List<List<TriMesh.HalfEdge>> Generators = connection.Generators;

            if (generatorsValues == null)
            {
                generatorsValues = new List<double>();

                //Find the max dual
                int max = int.MinValue;
                int index = 0;
                int count = 0;
                foreach (List<TriMesh.HalfEdge> cycle in connection.Generators)
                {
                    if (cycle.Count > max)
                    {
                        max = cycle.Count;
                        index = count;
                    }
                    count++;
                }

                for (int i = 0; i < Generators.Count; i++)
                {
                    generatorsValues.Add(i == index ? 2 : 0);
                }
            }
            else
            {
                generatorsValues.Clear();

                //Find the max dual
                int max = int.MinValue;
                int index = 0;
                int count = 0;
                foreach (List<TriMesh.HalfEdge> cycle in connection.Generators)
                {
                    if (cycle.Count > max)
                    {
                        max = cycle.Count;
                        index = count;
                    }
                    count++;
                }

                for (int i = 0; i < Generators.Count; i++)
                {
                    generatorsValues.Add(i == index ? 2 : 0);
                }

            }

            //Add vertex singularities
            foreach (TriMesh.Vertex v in Mesh.Vertices)
            {
                if (v.Traits.selectedFlag > 0)
                {
                    selected.Add(v);
                    selectedValues.Add(0f);
                }
            }

            int selectedCount = selectedValues.Count;
            double initValue = 2.0f / (double)selectedCount;

            for (int i = 0; i < selectedCount; i++)
            {
                selectedValues[i] = initValue;
            }

            dataGridViewSingularity.Rows.Clear();

            for (int i = 0; i < selectedCount; i++)
            {
                dataGridViewSingularity.Rows.Add("Vertex" + selected[i].Index, selectedValues[i].ToString());
            }

            for (int i = selectedCount; i < selectedCount + Generators.Count; i++)
            {
                dataGridViewSingularity.Rows.Add("Generator" + (i - selectedCount), generatorsValues[i - selectedCount].ToString());
            }

        }
Esempio n. 3
0
        private void buttonProcess_Click(object sender, EventArgs e)
        {
            if (connection == null)
            {
                connection = new PriorNonTrivalConnection(Mesh);

                singularites = new List<KeyValuePair<HalfEdgeMesh.Vertex, double>>();
                //singularites.Add(new KeyValuePair<HalfEdgeMesh.Vertex, double>(Mesh.Vertices[0],2));


            }

            //Update Singularities
            connection.Singularities.Clear();
            for (int i = 0; i < selected.Count; i++)
            {
                connection.Singularities.Add(new KeyValuePair<HalfEdgeMesh.Vertex, double>(selected[i], selectedValues[i]));
            }


            //Update Generator
            connection.GeneratorValues.Clear();
            for (int i = 0; i < generatorsValues.Count; i++)
            {
                connection.GeneratorValues.Add(new KeyValuePair<List<HalfEdgeMesh.HalfEdge>, double>(connection.Generators[i], generatorsValues[i]));
            }

            connection.Update();

            Vector3D[] vectorFields = connection.ComputeVectorField(Angle);

            GlobalSetting.DisplaySetting.DisplayMode = EnumDisplayMode.Vector;
            GlobalData.Instance.FaceVectors = vectorFields;
            GlobalData.Instance.N = (int)NnumericUpDown.Value;
            OnChanged(EventArgs.Empty);

        }
Esempio n. 4
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            if (selected == null)
            {
                selected       = new List <TriMesh.Vertex>();
                selectedValues = new List <double>();
            }
            else
            {
                selected.Clear();
                selectedValues.Clear();
            }

            if (connection == null)
            {
                connection = new PriorNonTrivalConnection(Mesh);

                singularites = new List <KeyValuePair <HalfEdgeMesh.Vertex, double> >();

                for (int i = 0; i < selected.Count; i++)
                {
                    singularites.Add(new KeyValuePair <HalfEdgeMesh.Vertex, double>(selected[i], selectedValues[i]));
                }

                connection.Singularities = singularites;
            }
            List <List <TriMesh.HalfEdge> > Generators = connection.Generators;

            if (generatorsValues == null)
            {
                generatorsValues = new List <double>();

                //Find the max dual
                int max   = int.MinValue;
                int index = 0;
                int count = 0;
                foreach (List <TriMesh.HalfEdge> cycle in connection.Generators)
                {
                    if (cycle.Count > max)
                    {
                        max   = cycle.Count;
                        index = count;
                    }
                    count++;
                }

                for (int i = 0; i < Generators.Count; i++)
                {
                    generatorsValues.Add(i == index ? 2 : 0);
                }
            }
            else
            {
                generatorsValues.Clear();

                //Find the max dual
                int max   = int.MinValue;
                int index = 0;
                int count = 0;
                foreach (List <TriMesh.HalfEdge> cycle in connection.Generators)
                {
                    if (cycle.Count > max)
                    {
                        max   = cycle.Count;
                        index = count;
                    }
                    count++;
                }

                for (int i = 0; i < Generators.Count; i++)
                {
                    generatorsValues.Add(i == index ? 2 : 0);
                }
            }

            //Add vertex singularities
            foreach (TriMesh.Vertex v in Mesh.Vertices)
            {
                if (v.Traits.selectedFlag > 0)
                {
                    selected.Add(v);
                    selectedValues.Add(0f);
                }
            }

            int    selectedCount = selectedValues.Count;
            double initValue     = 2.0f / (double)selectedCount;

            for (int i = 0; i < selectedCount; i++)
            {
                selectedValues[i] = initValue;
            }

            dataGridViewSingularity.Rows.Clear();

            for (int i = 0; i < selectedCount; i++)
            {
                dataGridViewSingularity.Rows.Add("Vertex" + selected[i].Index, selectedValues[i].ToString());
            }

            for (int i = selectedCount; i < selectedCount + Generators.Count; i++)
            {
                dataGridViewSingularity.Rows.Add("Generator" + (i - selectedCount), generatorsValues[i - selectedCount].ToString());
            }
        }