本文整理汇总了C#中SparseMatrix.AddElementIfNotExist方法的典型用法代码示例。如果您正苦于以下问题:C# SparseMatrix.AddElementIfNotExist方法的具体用法?C# SparseMatrix.AddElementIfNotExist怎么用?C# SparseMatrix.AddElementIfNotExist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix.AddElementIfNotExist方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildAdjacentMatrixFV
public SparseMatrix BuildAdjacentMatrixFV(TriMesh mesh)
{
SparseMatrix m = new SparseMatrix(mesh.Faces.Count,
mesh.Vertices.Count);
foreach (var face in mesh.Faces)
{
foreach (var v in face.Vertices)
{
m.AddElementIfNotExist(face.Index, v.Index, 1.0);
}
}
m.SortElement();
return m;
}
示例2: BuildTwoRingVV
public SparseMatrix BuildTwoRingVV(TriMesh mesh)
{
int n = mesh.Vertices.Count;
SparseMatrix L = new SparseMatrix(n, n, 6);
for (int i = 0; i < n; i++)
{
foreach (TriMesh.Vertex v1 in mesh.Vertices[i].Vertices)
foreach (TriMesh.Vertex v2 in mesh.Vertices[v1.Index].Vertices)
L.AddElementIfNotExist(i, v2.Index, 1);
}
L.SortElement();
return L;
}
示例3: BuildAdjacentMatrixVV
public SparseMatrix BuildAdjacentMatrixVV(TriMesh mesh)
{
SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
mesh.Vertices.Count);
foreach (var center in mesh.Vertices)
{
foreach (var round in center.Vertices)
{
m.AddElementIfNotExist(center.Index,
round.Index, 1.0);
}
}
m.SortElement();
return m;
}
示例4: BuildLaplaceTutte
public SparseMatrix BuildLaplaceTutte(TriMesh mesh)
{
SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
mesh.Vertices.Count);
foreach (TriMesh.Vertex vertex in mesh.Vertices)
{
foreach (TriMesh.Vertex neigh in vertex.Vertices)
{
double result = -1d / vertex.VertexCount;
m.AddElementIfNotExist(vertex.Index,
neigh.Index,
result);
}
m.AddValueTo(vertex.Index, vertex.Index, 1);
}
m.SortElement();
return m;
}
示例5: BuildAdjacentMatrixFF
public SparseMatrix BuildAdjacentMatrixFF()
{
SparseMatrix m = new SparseMatrix(faceCount, faceCount, 3);
for (int i = 0; i < faceCount; i++)
{
int v1 = faceIndex[i * 3];
int v2 = faceIndex[i * 3 + 1];
int v3 = faceIndex[i * 3 + 2];
foreach (int j in adjVF[v1])
if (j != i && IsContainVertex(j, v2))
m.AddElementIfNotExist(i, j, 1.0);
foreach (int j in adjVF[v2])
if (j != i && IsContainVertex(j, v3))
m.AddElementIfNotExist(i, j, 1.0);
foreach (int j in adjVF[v3])
if (j != i && IsContainVertex(j, v1))
m.AddElementIfNotExist(i, j, 1.0);
}
return m;
}
示例6: BuildAdjacentMatrixFV
public SparseMatrix BuildAdjacentMatrixFV()
{
SparseMatrix m = new SparseMatrix(faceCount, vertexCount, 6);
for (int i=0,j=0; i<faceCount; i++,j+=3)
{
m.AddElementIfNotExist(i, faceIndex[j], 1.0);
m.AddElementIfNotExist(i, faceIndex[j+1], 1.0);
m.AddElementIfNotExist(i, faceIndex[j+2], 1.0);
}
m.SortElement();
return m;
}
示例7: BuildAdjacentMatrix
public SparseMatrix BuildAdjacentMatrix()
{
SparseMatrix m = new SparseMatrix(vertexCount, vertexCount, 6);
for (int i=0,j=0; i<faceCount; i++,j+=3)
{
int c1 = faceIndex[j];
int c2 = faceIndex[j+1];
int c3 = faceIndex[j+2];
m.AddElementIfNotExist(c1, c2, 1.0);
m.AddElementIfNotExist(c2, c3, 1.0);
m.AddElementIfNotExist(c3, c1, 1.0);
m.AddElementIfNotExist(c2, c1, 1.0);
m.AddElementIfNotExist(c3, c2, 1.0);
m.AddElementIfNotExist(c1, c3, 1.0);
}
m.SortElement();
return m;
}
示例8: BuildTwoRingVV
public static SparseMatrix BuildTwoRingVV(ref NonManifoldMesh mesh)
{
int n = mesh.VertexCount;
SparseMatrix L = new SparseMatrix(n, n, 6);
for (int i = 0; i < n; i++)
{
foreach (int j in mesh.AdjVV[i])
foreach (int k in mesh.AdjVV[j])
L.AddElementIfNotExist(i, k, 0);
}
L.SortElement();
return L;
}
示例9: BuildMatrixDegree
public SparseMatrix BuildMatrixDegree(TriMesh mesh)
{
SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
mesh.Vertices.Count);
foreach (TriMesh.Vertex vertex in mesh.Vertices)
{
m.AddElementIfNotExist(vertex.Index,
vertex.Index, vertex.VertexCount);
}
m.SortElement();
return m;
}
示例10: BuildAdjacentMatrixEF
public SparseMatrix BuildAdjacentMatrixEF(TriMesh mesh)
{
SparseMatrix m = new SparseMatrix(mesh.Edges.Count,
mesh.Faces.Count);
foreach (var edge in mesh.Edges)
{
m.AddElementIfNotExist(edge.Index, edge.Face0.Index, 1.0);
m.AddElementIfNotExist(edge.Index, edge.Face1.Index, 1.0);
}
m.SortElement();
return m;
}
示例11: BuildAdjacentMatrixVE
//private bool IsContainVertex(TriMesh.Face face, int vIndex)
//{
// int v1 = face.GetVertex(0).Index;
// int v2 = face.GetVertex(1).Index;
// int v3 = face.GetVertex(2).Index;
// return (v1 == vIndex) || (v2 == vIndex) || (v3 == vIndex);
//}
public SparseMatrix BuildAdjacentMatrixVE(TriMesh mesh)
{
SparseMatrix m = new SparseMatrix(mesh.Vertices.Count,
mesh.Edges.Count);
foreach (var v in mesh.Vertices)
{
foreach (var edge in v.Edges)
{
m.AddElementIfNotExist(v.Index, edge.Index, 1.0);
}
}
m.SortElement();
return m;
}