本文整理汇总了C#中GraphicResearchHuiZhao.TriMesh.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# TriMesh.Clear方法的具体用法?C# TriMesh.Clear怎么用?C# TriMesh.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicResearchHuiZhao.TriMesh
的用法示例。
在下文中一共展示了TriMesh.Clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InverseFace
public static void InverseFace(TriMesh mesh)
{
List<TriMesh.Vertex[]> faces = new List<HalfEdgeMesh.Vertex[]>();
foreach (TriMesh.Face face in mesh.Faces)
{
TriMesh.HalfEdge hf = face.HalfEdge;
TriMesh.Vertex[] arr = new TriMesh.Vertex[]{
hf.Next.ToVertex,
hf.ToVertex,
hf.FromVertex
};
faces.Add(arr);
}
TriMesh.Vertex[] vertices = new TriMesh.Vertex[mesh.Vertices.Count];
for (int i = 0; i < mesh.Vertices.Count; i++)
{
vertices[i] = mesh.Vertices[i];
vertices[i].HalfEdge = null;
}
mesh.Clear();
foreach (var v in vertices)
{
mesh.AppendToVertexList(v);
}
foreach (var face in faces)
{
mesh.Faces.AddTriangles(face);
}
}
示例2: ChangeTopologyLoop
private TriMesh ChangeTopologyLoop(TriMesh sourceMesh)
{
TriMesh newMesh = new TriMesh();
newMesh.Clear();
vMap = new HalfEdgeMesh.Vertex[sourceMesh.Vertices.Count];
eMap = new HalfEdgeMesh.Vertex[sourceMesh.Edges.Count];
foreach (var v in sourceMesh.Vertices)
{
vMap[v.Index] = newMesh.Vertices.Add(new VertexTraits(v.Traits.Position));
}
foreach (var edge in sourceMesh.Edges)
{
eMap[edge.Index] = newMesh.Vertices.Add(
new VertexTraits(TriMeshUtil.GetMidPoint(edge)));
}
foreach(TriMesh.Face face in sourceMesh.Faces)
{
foreach (var hf in face.Halfedges)
{
newMesh.Faces.AddTriangles(eMap[hf.Edge.Index],
vMap[hf.ToVertex.Index], eMap[hf.Next.Edge.Index]);
}
newMesh.Faces.AddTriangles(
eMap[face.HalfEdge.Previous.Edge.Index],
eMap[face.HalfEdge.Edge.Index],
eMap[face.HalfEdge.Next.Edge.Index]);
}
return newMesh;
}
示例3: ChangeTopologyLoopSelected
private TriMesh ChangeTopologyLoopSelected(TriMesh sourceMesh)
{
TriMesh newMesh = new TriMesh();
newMesh.Clear();
vMap = new HalfEdgeMesh.Vertex[sourceMesh.Vertices.Count];
eMap = new HalfEdgeMesh.Vertex[Mesh.Edges.Count];
foreach (var v in sourceMesh.Vertices)
{
vMap[v.Index] = newMesh.Vertices.Add(new VertexTraits(v.Traits.Position));
}
foreach (var edge in sourceMesh.Edges)
{
if (edge.Vertex0.Traits.SelectedFlag != 0 && edge.Vertex1.Traits.SelectedFlag != 0)
{
eMap[edge.Index] = newMesh.Vertices.Add(new VertexTraits(TriMeshUtil.GetMidPoint(edge)));
}
}
foreach (TriMesh.Face face in sourceMesh.Faces)
{
List<TriMesh.HalfEdge> list = new List<HalfEdgeMesh.HalfEdge>();
foreach (var hf in face.Halfedges)
{
if (hf.ToVertex.Traits.SelectedFlag != 0 && hf.FromVertex.Traits.SelectedFlag != 0)
{
list.Add(hf);
}
}
switch (list.Count)
{
case 0:
newMesh.Faces.AddTriangles(
vMap[face.GetVertex(0).Index],
vMap[face.GetVertex(1).Index],
vMap[face.GetVertex(2).Index]);
break;
case 1:
TriMesh.HalfEdge h = list[0];
newMesh.Faces.AddTriangles(
eMap[h.Edge.Index],
vMap[h.ToVertex.Index],
vMap[h.Next.ToVertex.Index]);
newMesh.Faces.AddTriangles(
eMap[h.Edge.Index],
vMap[h.Next.ToVertex.Index],
vMap[h.FromVertex.Index]);
break;
case 3:
foreach (var hf in face.Halfedges)
{
newMesh.Faces.AddTriangles(eMap[hf.Edge.Index], vMap[hf.ToVertex.Index], eMap[hf.Next.Edge.Index]);
}
newMesh.Faces.AddTriangles(
eMap[face.HalfEdge.Previous.Edge.Index],
eMap[face.HalfEdge.Edge.Index],
eMap[face.HalfEdge.Next.Edge.Index]);
break;
default:
break;
}
}
return newMesh;
}