Ejemplo n.º 1
0
        private void treeCoTreeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeCoTree treeCotree = new TreeCoTree(Mesh);

            List <List <TriMesh.HalfEdge> > loops = treeCotree.ExtractHonologyGenerator(Mesh);

            OnChanged(EventArgs.Empty);
        }
Ejemplo n.º 2
0
        private void buttonGenerate_Click(object sender, EventArgs e)
        {
            TreeCoTree treeCotree = new TreeCoTree(Mesh);

            List <List <TriMesh.HalfEdge> > loops = treeCotree.ExtractHonologyGenerator(Mesh);

            GlobalData.Instance.Generators           = loops;
            GlobalSetting.DisplaySetting.DisplayMode = EnumDisplayMode.Generator;
            OnChanged(EventArgs.Empty);
        }
Ejemplo n.º 3
0
        public void Init()
        {
            if (Singularities == null)
            {
                Singularities = new List <KeyValuePair <HalfEdgeMesh.Vertex, double> >();
            }
            else
            {
                Singularities.Clear();
            }

            if (GeneratorValues == null)
            {
                GeneratorValues = new List <KeyValuePair <List <HalfEdgeMesh.HalfEdge>, double> >();
            }
            else
            {
                GeneratorValues.Clear();
            }

            if (treeCotree == null)
            {
                treeCotree = new TreeCoTree(Mesh);
            }

            foreach (KeyValuePair <HalfEdgeMesh.Vertex, double> selectedV in Singularities)
            {
                selectedV.Key.Traits.SelectedFlag = 1;
            }

            EdgeTheta      = new double[Mesh.Edges.Count];
            EdgeHodgeStar1 = new double[Mesh.Edges.Count];

            basisCycles         = Append1RingBases(Mesh);
            nContractibleCycles = basisCycles.Count;

            dualCycles          = treeCotree.ExtractHonologyGenerator(Mesh);
            GeneratorOnBoundary = new bool[dualCycles.Count];


            //Append to basisCycle
            foreach (List <TriMesh.HalfEdge> dualCycle in dualCycles)
            {
                basisCycles.Add(dualCycle);
            }

            //basisCycles.RemoveAt(basisCycles.Count - 1);
        }
Ejemplo n.º 4
0
        private void buttonTreeCotree_Click(object sender, EventArgs e)
        {
            TreeCoTree treeCotree = new TreeCoTree(Mesh);

            DynamicTree <TriMesh.Vertex> tree;
            DynamicTree <TriMesh.Face>   cotree;

            treeCotree.GeneratorTreeCotree(Mesh, out tree, out cotree);

            GlobalData.Instance.tree   = treeCotree.BuildTree(tree);
            GlobalData.Instance.cotree = treeCotree.BuildCoTree(cotree);


            GlobalSetting.DisplaySetting.DisplayMode = EnumDisplayMode.TreeCotree;
            OnChanged(EventArgs.Empty);
        }
Ejemplo n.º 5
0
 public HarmonicBasis(TriMesh mesh)
 {
     this.mesh = mesh;
     treeCoTree = new TreeCoTree(mesh);
 }
Ejemplo n.º 6
0
        public void InitProcess(TriMesh mesh)
        {
            TreeCoTree treeCotree = new TreeCoTree(mesh);

            generatorLoops = treeCotree.ExtractHonologyGenerator(mesh);

            HarmonicBasis basis = new HarmonicBasis(mesh);

            HarmonicBasis = basis.BuildHarmonicBasis(generatorLoops);
            int numberOfHarmBases = basis.NumberOfHarmonicBases(generatorLoops);

            //Still need to built
            u = InitWithTrivalHolonmy(Laplace, mesh);

            HarmonicCoffition = new double[numberOfHarmBases];


            if (numberOfHarmBases == 0)
            {
                return;
            }

            DenseMatrixDouble  b = new DenseMatrixDouble(numberOfHarmBases, 1);
            SparseMatrixDouble H = new SparseMatrixDouble(numberOfHarmBases, numberOfHarmBases);

            int row = 0;

            bool skipBoundaryLoop = true;

            for (int i = 0; i < generatorLoops.Count; i++)
            {
                List <TriMesh.HalfEdge> cycle = generatorLoops[i];

                if (skipBoundaryLoop && treeCotree.IsBoundaryGenerator(cycle))
                {
                    skipBoundaryLoop = false;
                    continue;
                }

                foreach (TriMesh.HalfEdge hf in cycle)
                {
                    for (int col = 0; col < numberOfHarmBases; col++)
                    {
                        H[row, col] += HarmonicBasis[hf.Index][col];
                    }
                }

                double value = -GeneratorHolomy(cycle, HarmonicBasis, HarmonicCoffition, u);

                b[row, 0] = value;
                row++;
            }

            DenseMatrixDouble x = null;

            if (b.F_Norm() > 1.0e-8)
            {
                x = LinearSystemGenericByLib.Instance.SolveLinerSystem(ref H, ref b);
            }
            else
            {
                x = new DenseMatrixDouble(numberOfHarmBases, 1);
            }

            for (int i = 0; i < numberOfHarmBases; i++)
            {
                HarmonicCoffition[i] = x[i, 0];
            }
        }
Ejemplo n.º 7
0
        private void treeCoTreeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeCoTree treeCotree = new TreeCoTree(Mesh);

            List<List<TriMesh.HalfEdge>> loops = treeCotree.ExtractHonologyGenerator(Mesh);
 
            OnChanged(EventArgs.Empty);
        }
Ejemplo n.º 8
0
        public void Init()
        {
            if (Singularities == null)
            {
                Singularities = new List<KeyValuePair<HalfEdgeMesh.Vertex, double>>();
            }
            else
            {
                Singularities.Clear();
            }

            if (GeneratorValues == null)
            {
                GeneratorValues = new List<KeyValuePair<List<HalfEdgeMesh.HalfEdge>, double>>();
            }
            else
            {
                GeneratorValues.Clear();
            }

            if (treeCotree == null)
            {
                treeCotree = new TreeCoTree(Mesh);
            }

            foreach (KeyValuePair<HalfEdgeMesh.Vertex, double> selectedV in Singularities)
            {
                selectedV.Key.Traits.SelectedFlag = 1;
            }

            EdgeTheta = new double[Mesh.Edges.Count];
            EdgeHodgeStar1 = new double[Mesh.Edges.Count];

            basisCycles = Append1RingBases(Mesh);
            nContractibleCycles = basisCycles.Count;

            dualCycles = treeCotree.ExtractHonologyGenerator(Mesh);
            GeneratorOnBoundary = new bool[dualCycles.Count];


            //Append to basisCycle
            foreach (List<TriMesh.HalfEdge> dualCycle in dualCycles)
            {
                basisCycles.Add(dualCycle);
            }

            //basisCycles.RemoveAt(basisCycles.Count - 1);
        }
Ejemplo n.º 9
0
 public HarmonicBasis(TriMesh mesh)
 {
     this.mesh  = mesh;
     treeCoTree = new TreeCoTree(mesh);
 }
Ejemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            TreeCoTree treeCotree = new TreeCoTree(Mesh);

            List<List<TriMesh.HalfEdge>> loops = treeCotree.ExtractHonologyGenerator(Mesh);

            HarmonicBasis basis = new HarmonicBasis(Mesh);
            basis.BuildHarmonicBasis(loops);

            GlobalData.Instance.Generators = loops;
            GlobalSetting.DisplaySetting.DisplayMode = EnumDisplayMode.Generator;
            OnChanged(EventArgs.Empty);

        }
Ejemplo n.º 11
0
        private void buttonTreeCotree_Click(object sender, EventArgs e)
        {
            TreeCoTree treeCotree = new TreeCoTree(Mesh);

            DynamicTree<TriMesh.Vertex> tree;
            DynamicTree<TriMesh.Face> cotree;

            treeCotree.GeneratorTreeCotree(Mesh, out tree, out cotree);

            GlobalData.Instance.tree = treeCotree.BuildTree(tree);
            GlobalData.Instance.cotree = treeCotree.BuildCoTree(cotree);

            
            GlobalSetting.DisplaySetting.DisplayMode = EnumDisplayMode.TreeCotree;
            OnChanged(EventArgs.Empty);
        }
Ejemplo n.º 12
0
        public void InitProcess(TriMesh mesh)
        {

            TreeCoTree treeCotree = new TreeCoTree(mesh);

            generatorLoops = treeCotree.ExtractHonologyGenerator(mesh);

            HarmonicBasis basis = new HarmonicBasis(mesh);
            HarmonicBasis = basis.BuildHarmonicBasis(generatorLoops);
            int numberOfHarmBases = basis.NumberOfHarmonicBases(generatorLoops);

            //Still need to built
            u = InitWithTrivalHolonmy(Laplace, mesh);

            HarmonicCoffition = new double[numberOfHarmBases];


            if (numberOfHarmBases == 0)
            {
                return;
            }

            DenseMatrixDouble b = new DenseMatrixDouble(numberOfHarmBases, 1);
            SparseMatrixDouble H = new SparseMatrixDouble(numberOfHarmBases, numberOfHarmBases);

            int row = 0;

            bool skipBoundaryLoop = true;
            for (int i = 0; i < generatorLoops.Count; i++)
            {
                List<TriMesh.HalfEdge> cycle = generatorLoops[i];

                if (skipBoundaryLoop && treeCotree.IsBoundaryGenerator(cycle))
                {
                    skipBoundaryLoop = false;
                    continue;
                }

                foreach (TriMesh.HalfEdge hf in cycle)
                {
                    for (int col = 0; col < numberOfHarmBases; col++)
                    {
                        H[row, col] += HarmonicBasis[hf.Index][col];
                    }
                }

                double value = -GeneratorHolomy(cycle, HarmonicBasis, HarmonicCoffition, u);

                b[row, 0] = value;
                row++;
            }

            DenseMatrixDouble x = null;

            if (b.F_Norm() > 1.0e-8)
            {
                x = LinearSystemGenericByLib.Instance.SolveLinerSystem(ref H, ref b);
            }
            else
            {
                x = new DenseMatrixDouble(numberOfHarmBases, 1);
            }

            for (int i = 0; i < numberOfHarmBases; i++)
            {
                HarmonicCoffition[i] = x[i, 0];
            }

        }