public static double[][] ComputeUniformLap(ref NonManifoldMesh mesh) { SparseMatrix L = MeshOperators.BuildUniformMatrixL(ref mesh); if (L == null) { throw new Exception("Laplacian matrix is null"); } int n = mesh.VertexCount; double[] v = new double[n]; double[][] lap = new double[3][]; for (int i = 0; i < 3; i++) { lap[i] = new double[n]; for (int j = 0, k = 0; j < n; j++, k += 3) { v[j] = mesh.VertexPos[k + i]; } L.Multiply(v, 0, lap[i], 0); } return(lap); }
public static SparseMatrix CreateMatrixATA(ref SparseMatrix A, ref NonManifoldMesh mesh) { // assume A is sorted // assume values in parameter adj is in order if (A == null) { throw new Exception("A matrix is null"); } int[][] adj = MeshOperators.BuildTwoRingVV(ref mesh).GetRowIndex(); int n = A.ColumnSize; SparseMatrix ATA = new SparseMatrix(n, n); for (int i = 0; i < n; i++) { List <SparseMatrix.Element> col1 = A.GetColumn(i); foreach (int j in adj[i]) { List <SparseMatrix.Element> col2 = A.GetColumn(j); int c1 = 0, c2 = 0; double sum = 0.0; bool used = false; while (c1 < col1.Count && c2 < col2.Count) { if (col1[c1].i < col2[c2].i) { c1++; continue; } if (col1[c1].i > col2[c2].i) { c2++; continue; } sum += col1[c1].value * col2[c2].value; used = true; c1++; c2++; } if (used) { ATA.AddElement(i, j, sum); } } } if (ATA.IsSymmetric() == false) { throw new Exception("ATA is not symmetric!!"); } return(ATA); }
public void DrawLapCoord(NonManifoldMesh mesh) { GL.LineWidth(2.0f); GL.Color3(1.0, 0.0, 0.0); GL.Begin(BeginMode.Lines); double[] lapCoordiante = MeshOperators.ComputeDualLap(ref mesh); for (int i = 0, j = 0; i < mesh.FaceCount; i++, j += 3) { GraphicResearchHuiZhao.Vector3D u = mesh.GetDualPosition(i); GraphicResearchHuiZhao.Vector3D lap = new GraphicResearchHuiZhao.Vector3D(lapCoordiante[j], lapCoordiante[j + 1], lapCoordiante[j + 2]); GraphicResearchHuiZhao.Vector3D v = u + 3.0 * lap; GL.Vertex3(u.x, u.y, u.z); GL.Vertex3(v.x, v.y, v.z); } GL.End(); }
public static void SetMeshColorToGaussianCurvature(NonManifoldMesh mesh) { double[] gaussianCurvature = MeshOperators.ComputeGaussianCurvature(ref mesh); UpdateColor(ref mesh, ref gaussianCurvature); }
public static double[] GaussianCurvatureArray(NonManifoldMesh mesh) { return(MeshOperators.ComputeGaussianCurvature(ref mesh)); }
public static void SetMeshColorToPricipal2(NonManifoldMesh mesh) { double[][] pricipal = MeshOperators.ComputePricipalCurvature(ref mesh); UpdateColor(ref mesh, ref pricipal[1]); }