本文整理汇总了C#中GraphicResearchHuiZhao.TriMesh.AppendToEdgeList方法的典型用法代码示例。如果您正苦于以下问题:C# TriMesh.AppendToEdgeList方法的具体用法?C# TriMesh.AppendToEdgeList怎么用?C# TriMesh.AppendToEdgeList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicResearchHuiZhao.TriMesh
的用法示例。
在下文中一共展示了TriMesh.AppendToEdgeList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InsertEdge
private static void InsertEdge(TriMesh mesh, TriMesh.HalfEdge inner, TriMesh.HalfEdge outer)
{
//TriMesh.Edge left = new TriMesh.Edge();
//left.HalfEdge0 = outer;
//outer.Edge = left;
//inner.Next.Edge = left;
//TriMesh.Edge right = outer.Edge;
//right.HalfEdge0 = inner;
//inner.Edge = right;
//outer.Opposite.Edge = right;
//inner.Opposite = outer.Opposite;
//inner.Next.Opposite = outer;
//outer.Opposite.Opposite = inner;
//outer.Opposite = inner.Next;
inner.Opposite = outer.Opposite;
inner.Next.Opposite = outer;
outer.Opposite.Opposite = inner;
outer.Opposite = inner.Next;
outer.Edge.HalfEdge0 = outer;
TriMesh.Edge edge = new TriMesh.Edge();
edge.HalfEdge0 = inner;
inner.Edge = edge;
inner.Opposite.Edge = edge;
inner.Next.Edge = outer.Edge;
mesh.AppendToEdgeList(edge);
}
示例2: CreateFace
/// <summary>
/// Adds a face to the mesh with the specified face traits.
/// </summary>
/// <param name="faceTraits">The custom traits for the face to add to the mesh.</param>
/// <param name="faceVertices">The vertices of the face in counterclockwise order.</param>
/// <returns>The face created by this method.</returns>
/// <exception cref="BadTopologyException">
/// Thrown when fewer than three vertices are given or the vertices cannot form a valid face.
/// </exception>
/// <exception cref="ArgumentNullException">Thrown when a null vertex is given.</exception>
private static TriMesh.Face CreateFace(TriMesh mesh, params TriMesh.Vertex[] faceVertices)
{
int n = faceVertices.Length;
// Require at least 3 vertices
if (n < 3)
{
throw new BadTopologyException("Cannot create a polygon with fewer than three vertices.");
}
TriMesh.Edge e;
TriMesh.Face f;
TriMesh.HalfEdge[] faceHalfedges = new TriMesh.HalfEdge[n];
bool[] isNewEdge = new bool[n], isUsedVertex = new bool[n];
for (int i = 0; i < n; i++)
{
int j = (i + 1) % n;
faceHalfedges[i] = faceVertices[i].FindHalfedgeTo(faceVertices[j]);
}
// Make sure input is (mostly) acceptable before making any changes to the mesh
for (int i = 0; i < n; ++i)
{
int j = (i + 1) % n;
if (faceVertices[i] == null)
{
throw new ArgumentNullException("Can't add a null vertex to a face.");
}
if (!faceVertices[i].OnBoundary)
{
throw new BadTopologyException("Can't add an edge to a vertex on the interior of a mesh.");
}
// Find existing halfedges for this face
faceHalfedges[i] = faceVertices[i].FindHalfedgeTo(faceVertices[j]);
isNewEdge[i] = (faceHalfedges[i] == null);
isUsedVertex[i] = (faceVertices[i].HalfEdge != null);
if (!isNewEdge[i] && !faceHalfedges[i].OnBoundary)
{
throw new BadTopologyException("Can't add more than two faces to an edge.");
}
}
// Create face
f = new TriMesh.Face(default(FaceTraits));
mesh.AppendToFaceList(f);
// Create new edges
for (int i = 0; i < n; ++i)
{
int j = (i + 1) % n;
if (isNewEdge[i])
{
// Create new edge
e = new TriMesh.Edge();
mesh.AppendToEdgeList(e);
// Create new halfedges
faceHalfedges[i] = new TriMesh.HalfEdge();
mesh.AppendToHalfedgeList(faceHalfedges[i]);
faceHalfedges[i].Opposite = new TriMesh.HalfEdge();
mesh.AppendToHalfedgeList(faceHalfedges[i].Opposite);
// Connect opposite halfedge to inner halfedge
faceHalfedges[i].Opposite.Opposite = faceHalfedges[i];
// Connect edge to halfedges
e.HalfEdge0 = faceHalfedges[i];
// Connect halfedges to edge
faceHalfedges[i].Edge = e;
faceHalfedges[i].Opposite.Edge = e;
// Connect halfedges to vertices
faceHalfedges[i].ToVertex = faceVertices[j];
faceHalfedges[i].Opposite.ToVertex = faceVertices[i];
// Connect vertex to outgoing halfedge if it doesn't have one yet
if (faceVertices[i].HalfEdge == null)
{
faceVertices[i].HalfEdge = faceHalfedges[i];
}
}
if (faceHalfedges[i].Face != null)
{
throw new BadTopologyException("An inner halfedge already has a face assigned to it.");
}
// Connect inner halfedge to face
faceHalfedges[i].Face = f;
}
// Connect next/previous halfedges
for (int i = 0; i < n; ++i)
{
int j = (i + 1) % n;
// Outer halfedges
if (isNewEdge[i] && isNewEdge[j] && isUsedVertex[j]) // Both edges are new and vertex has faces connected already
{
TriMesh.HalfEdge closeHalfedge = null;
//.........这里部分代码省略.........