本文整理汇总了C#中Mesh.MakeSegment方法的典型用法代码示例。如果您正苦于以下问题:C# Mesh.MakeSegment方法的具体用法?C# Mesh.MakeSegment怎么用?C# Mesh.MakeSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.MakeSegment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToMesh
/// <summary>
/// Reconstruct a triangulation from its raw data representation.
/// </summary>
public static Mesh ToMesh(Polygon polygon, ITriangle[] triangles)
{
Otri tri = default(Otri);
Osub subseg = default(Osub);
int i = 0;
int elements = triangles == null ? 0 : triangles.Length;
int segments = polygon.Segments.Count;
// TODO: Configuration should be a function argument.
var mesh = new Mesh(new Configuration());
mesh.TransferNodes(polygon.Points);
mesh.regions.AddRange(polygon.Regions);
mesh.behavior.useRegions = polygon.Regions.Count > 0;
if (polygon.Segments.Count > 0)
{
mesh.behavior.Poly = true;
mesh.holes.AddRange(polygon.Holes);
}
// Create the triangles.
for (i = 0; i < elements; i++)
{
mesh.MakeTriangle(ref tri);
}
if (mesh.behavior.Poly)
{
mesh.insegments = segments;
// Create the subsegments.
for (i = 0; i < segments; i++)
{
mesh.MakeSegment(ref subseg);
}
}
var vertexarray = SetNeighbors(mesh, triangles);
SetSegments(mesh, polygon, vertexarray);
return mesh;
}
示例2: Reconstruct
/// <summary>
/// Reconstruct a triangulation from its raw data representation.
/// </summary>
/// <param name="mesh"></param>
/// <param name="input"></param>
/// <returns></returns>
/// <remarks>
/// Reads an .ele file and reconstructs the original mesh. If the -p switch
/// is used, this procedure will also read a .poly file and reconstruct the
/// subsegments of the original mesh. If the -a switch is used, this
/// procedure will also read an .area file and set a maximum area constraint
/// on each triangle.
///
/// Vertices that are not corners of triangles, such as nodes on edges of
/// subparametric elements, are discarded.
///
/// This routine finds the adjacencies between triangles (and subsegments)
/// by forming one stack of triangles for each vertex. Each triangle is on
/// three different stacks simultaneously. Each triangle's subsegment
/// pointers are used to link the items in each stack. This memory-saving
/// feature makes the code harder to read. The most important thing to keep
/// in mind is that each triangle is removed from a stack precisely when
/// the corresponding pointer is adjusted to refer to a subsegment rather
/// than the next triangle of the stack.
/// </remarks>
public static int Reconstruct(Mesh mesh, InputGeometry input, ITriangle[] triangles)
{
int hullsize = 0;
Otri tri = default(Otri);
Otri triangleleft = default(Otri);
Otri checktri = default(Otri);
Otri checkleft = default(Otri);
Otri checkneighbor = default(Otri);
Osub subseg = default(Osub);
List<Otri>[] vertexarray; // Triangle
Otri prevlink; // Triangle
Otri nexttri; // Triangle
Vertex tdest, tapex;
Vertex checkdest, checkapex;
Vertex shorg;
Vertex segmentorg, segmentdest;
int[] corner = new int[3];
int[] end = new int[2];
//bool segmentmarkers = false;
int boundmarker;
int aroundvertex;
bool notfound;
int i = 0;
int elements = triangles == null ? 0 : triangles.Length;
int numberofsegments = input.segments.Count;
mesh.inelements = elements;
mesh.regions.AddRange(input.regions);
// Create the triangles.
for (i = 0; i < mesh.inelements; i++)
{
mesh.MakeTriangle(ref tri);
// Mark the triangle as living.
//tri.triangle.neighbors[0].triangle = tri.triangle;
}
if (mesh.behavior.Poly)
{
mesh.insegments = numberofsegments;
// Create the subsegments.
for (i = 0; i < mesh.insegments; i++)
{
mesh.MakeSegment(ref subseg);
// Mark the subsegment as living.
//subseg.ss.subsegs[0].ss = subseg.ss;
}
}
// Allocate a temporary array that maps each vertex to some adjacent
// triangle. I took care to allocate all the permanent memory for
// triangles and subsegments first.
vertexarray = new List<Otri>[mesh.vertices.Count];
// Each vertex is initially unrepresented.
for (i = 0; i < mesh.vertices.Count; i++)
{
Otri tmp = default(Otri);
tmp.triangle = Mesh.dummytri;
vertexarray[i] = new List<Otri>(3);
vertexarray[i].Add(tmp);
}
i = 0;
// Read the triangles from the .ele file, and link
// together those that share an edge.
foreach (var item in mesh.triangles.Values)
{
tri.triangle = item;
corner[0] = triangles[i].P0;
corner[1] = triangles[i].P1;
//.........这里部分代码省略.........