More code reorganization (4)

git-svn-id: https://triangle.svn.codeplex.com/svn@75113 0e2699bc-83d4-4a8f-98e7-55e24ab8c7a5
This commit is contained in:
SND\wo80_cp
2014-06-26 13:21:12 +00:00
parent 0b4853faf8
commit 02f9d10bea
24 changed files with 344 additions and 229 deletions
@@ -860,7 +860,7 @@ namespace TriangleNet.Meshing.Algorithm
// Find an edge on the convex hull to start point location from.
startghost.Lprev(ref searchedge);
searchedge.SymSelf();
Mesh.dummytri.neighbors[0] = searchedge;
Triangle.Empty.neighbors[0] = searchedge;
// Remove the bounding box and count the convex hull edges.
startghost.Copy(ref dissolveedge);
hullsize = 0;
@@ -876,7 +876,7 @@ namespace TriangleNet.Meshing.Algorithm
if (noPoly)
{
// Watch out for the case where all the input vertices are collinear.
if (dissolveedge.triangle != Mesh.dummytri)
if (dissolveedge.triangle.id != Triangle.EmptyID)
{
markorg = dissolveedge.Org();
if (markorg.mark == 0)
@@ -35,7 +35,7 @@ namespace TriangleNet.Meshing.Algorithm
foreach (var v in mesh.vertices.Values)
{
starttri.triangle = Mesh.dummytri;
starttri.triangle = Triangle.Empty;
Osub tmp = default(Osub);
if (mesh.InsertVertex(v, ref starttri, ref tmp, false, false) == InsertVertexResult.Duplicate)
{
@@ -90,7 +90,7 @@ namespace TriangleNet.Meshing.Algorithm
inftri.SetApex(mesh.infvertex3);
// Link dummytri to the bounding box so we can always find an
// edge to begin searching (point location) from.
Mesh.dummytri.neighbors[0] = inftri;
Triangle.Empty.neighbors[0] = inftri;
}
/// <summary>
@@ -115,7 +115,7 @@ namespace TriangleNet.Meshing.Algorithm
bool noPoly = !mesh.behavior.Poly;
// Find a boundary triangle.
nextedge.triangle = Mesh.dummytri;
nextedge.triangle = Triangle.Empty;
nextedge.orient = 0;
nextedge.SymSelf();
// Mark a place to stop.
@@ -130,7 +130,7 @@ namespace TriangleNet.Meshing.Algorithm
// adjacent to the first one.
nextedge.Lnext(ref checkedge);
checkedge.SymSelf();
if (checkedge.triangle == Mesh.dummytri)
if (checkedge.triangle.id == Triangle.EmptyID)
{
// Go on to the next triangle. There are only three boundary
// triangles, and this next triangle cannot be the third one,
@@ -140,7 +140,7 @@ namespace TriangleNet.Meshing.Algorithm
}
// Find a new boundary edge to search from, as the current search
// edge lies on a bounding box triangle and will be deleted.
Mesh.dummytri.neighbors[0] = searchedge;
Triangle.Empty.neighbors[0] = searchedge;
hullsize = -2;
while (!nextedge.Equal(finaledge))
{
@@ -155,7 +155,7 @@ namespace TriangleNet.Meshing.Algorithm
// vertices are collinear, and thus all the triangles are part of
// the bounding box. Otherwise, the setvertexmark() call below
// will cause a bad pointer reference.
if (dissolveedge.triangle != Mesh.dummytri)
if (dissolveedge.triangle.id != Triangle.EmptyID)
{
markorg = dissolveedge.Org();
if (markorg.mark == 0)
@@ -171,7 +171,7 @@ namespace TriangleNet.Meshing.Algorithm
// Get rid of the bounding box triangle.
mesh.TriangleDealloc(deadtriangle.triangle);
// Do we need to turn the corner?
if (nextedge.triangle == Mesh.dummytri)
if (nextedge.triangle.id == Triangle.EmptyID)
{
// Turn the corner.
dissolveedge.Copy(ref nextedge);
@@ -701,7 +701,7 @@ namespace TriangleNet.Meshing.Algorithm
// Find an edge on the convex hull to start point location from.
startghost.Lprev(ref searchedge);
searchedge.SymSelf();
Mesh.dummytri.neighbors[0] = searchedge;
Triangle.Empty.neighbors[0] = searchedge;
// Remove the bounding box and count the convex hull edges.
startghost.Copy(ref dissolveedge);
hullsize = 0;
@@ -717,7 +717,7 @@ namespace TriangleNet.Meshing.Algorithm
if (noPoly)
{
// Watch out for the case where all the input vertices are collinear.
if (dissolveedge.triangle != Mesh.dummytri)
if (dissolveedge.triangle.id != Triangle.EmptyID)
{
markorg = dissolveedge.Org();
if (markorg.mark == 0)
@@ -64,7 +64,7 @@ namespace TriangleNet.Meshing
if (mesh.bounds.Contains(hole))
{
// Start searching from some triangle on the outer boundary.
searchtri.triangle = Mesh.dummytri;
searchtri.triangle = Triangle.Empty;
searchtri.orient = 0;
searchtri.SymSelf();
// Ensure that the hole is to the left of this boundary edge;
@@ -101,12 +101,12 @@ namespace TriangleNet.Meshing
// Find the starting triangle for each region.
foreach (var region in mesh.regions)
{
regionTris[i] = Mesh.dummytri;
regionTris[i] = Triangle.Empty;
// Ignore region points that aren't within the bounds of the mesh.
if (mesh.bounds.Contains(region.point))
{
// Start searching from some triangle on the outer boundary.
searchtri.triangle = Mesh.dummytri;
searchtri.triangle = Triangle.Empty;
searchtri.orient = 0;
searchtri.SymSelf();
// Ensure that the region point is to the left of this boundary
@@ -144,7 +144,7 @@ namespace TriangleNet.Meshing
for (int i = 0; i < regionTris.Length; i++)
{
if (regionTris[i] != Mesh.dummytri)
if (regionTris[i].id != Triangle.EmptyID)
{
// Make sure the triangle under consideration still exists.
// It may have been eaten by the virus.
@@ -261,7 +261,7 @@ namespace TriangleNet.Meshing
Vertex horg, hdest;
// Find a triangle handle on the hull.
hulltri.triangle = Mesh.dummytri;
hulltri.triangle = Triangle.Empty;
hulltri.orient = 0;
hulltri.SymSelf();
// Remember where we started so we know when to stop.
@@ -274,7 +274,7 @@ namespace TriangleNet.Meshing
{
// Is the triangle protected by a subsegment?
hulltri.SegPivot(ref hullsubseg);
if (hullsubseg.seg == Mesh.dummysub)
if (hullsubseg.seg == Segment.Empty)
{
// The triangle is not protected; infect it.
if (!hulltri.IsInfected())
@@ -305,7 +305,7 @@ namespace TriangleNet.Meshing
// To find the next hull edge, go clockwise around the next vertex.
hulltri.LnextSelf();
hulltri.Oprev(ref nexttri);
while (nexttri.triangle != Mesh.dummytri)
while (nexttri.triangle.id != Triangle.EmptyID)
{
nexttri.Copy(ref hulltri);
hulltri.Oprev(ref nexttri);
@@ -361,15 +361,15 @@ namespace TriangleNet.Meshing
// Check for a subsegment between the triangle and its neighbor.
testtri.SegPivot(ref neighborsubseg);
// Check if the neighbor is nonexistent or already infected.
if ((neighbor.triangle == Mesh.dummytri) || neighbor.IsInfected())
if ((neighbor.triangle.id == Triangle.EmptyID) || neighbor.IsInfected())
{
if (neighborsubseg.seg != Mesh.dummysub)
if (neighborsubseg.seg != Segment.Empty)
{
// There is a subsegment separating the triangle from its
// neighbor, but both triangles are dying, so the subsegment
// dies too.
mesh.SubsegDealloc(neighborsubseg.seg);
if (neighbor.triangle != Mesh.dummytri)
if (neighbor.triangle.id != Triangle.EmptyID)
{
// Make sure the subsegment doesn't get deallocated again
// later when the infected neighbor is visited.
@@ -381,7 +381,7 @@ namespace TriangleNet.Meshing
}
else
{ // The neighbor exists and is not infected.
if (neighborsubseg.seg == Mesh.dummysub)
if (neighborsubseg.seg == Segment.Empty)
{
// There is no subsegment protecting the neighbor, so
// the neighbor becomes infected.
@@ -436,7 +436,7 @@ namespace TriangleNet.Meshing
// Walk counterclockwise about the vertex.
testtri.Onext(ref neighbor);
// Stop upon reaching a boundary or the starting triangle.
while ((neighbor.triangle != Mesh.dummytri) &&
while ((neighbor.triangle.id != Triangle.EmptyID) &&
(!neighbor.Equal(testtri)))
{
if (neighbor.IsInfected())
@@ -453,12 +453,12 @@ namespace TriangleNet.Meshing
neighbor.OnextSelf();
}
// If we reached a boundary, we must walk clockwise as well.
if (neighbor.triangle == Mesh.dummytri)
if (neighbor.triangle.id == Triangle.EmptyID)
{
// Walk clockwise about the vertex.
testtri.Oprev(ref neighbor);
// Stop upon reaching a boundary.
while (neighbor.triangle != Mesh.dummytri)
while (neighbor.triangle.id != Triangle.EmptyID)
{
if (neighbor.IsInfected())
{
@@ -488,7 +488,7 @@ namespace TriangleNet.Meshing
for (testtri.orient = 0; testtri.orient < 3; testtri.orient++)
{
testtri.Sym(ref neighbor);
if (neighbor.triangle == Mesh.dummytri)
if (neighbor.triangle.id == Triangle.EmptyID)
{
// There is no neighboring triangle on this edge, so this edge
// is a boundary edge. This triangle is being deleted, so this
@@ -554,7 +554,7 @@ namespace TriangleNet.Meshing
// 'searchtri' faces directly away from 'searchpoint'. We could go left
// or right. Ask whether it's a triangle or a boundary on the left.
searchtri.Onext(ref checktri);
if (checktri.triangle == Mesh.dummytri)
if (checktri.triangle.id == Triangle.EmptyID)
{
leftflag = false;
}
@@ -567,7 +567,7 @@ namespace TriangleNet.Meshing
{
// Turn left until satisfied.
searchtri.OnextSelf();
if (searchtri.triangle == Mesh.dummytri)
if (searchtri.triangle.id == Triangle.EmptyID)
{
logger.Error("Unable to find a triangle on path.", "Mesh.FindDirection().1");
throw new Exception("Unable to find a triangle on path.");
@@ -581,7 +581,7 @@ namespace TriangleNet.Meshing
{
// Turn right until satisfied.
searchtri.OprevSelf();
if (searchtri.triangle == Mesh.dummytri)
if (searchtri.triangle.id == Triangle.EmptyID)
{
logger.Error("Unable to find a triangle on path.", "Mesh.FindDirection().2");
throw new Exception("Unable to find a triangle on path.");
@@ -696,12 +696,12 @@ namespace TriangleNet.Meshing
{
splitsubseg.SetSegOrg(newvertex);
splitsubseg.NextSelf();
} while (splitsubseg.seg != Mesh.dummysub);
} while (splitsubseg.seg != Segment.Empty);
do
{
opposubseg.SetSegOrg(newvertex);
opposubseg.NextSelf();
} while (opposubseg.seg != Mesh.dummysub);
} while (opposubseg.seg != Segment.Empty);
// Inserting the vertex may have caused edge flips. We wish to rediscover
// the edge connecting endpoint1 to the new intersection vertex.
@@ -789,7 +789,7 @@ namespace TriangleNet.Meshing
searchtri.Lnext(ref crosstri);
crosstri.SegPivot(ref crosssubseg);
// Check for a crossing segment.
if (crosssubseg.seg == Mesh.dummysub)
if (crosssubseg.seg == Segment.Empty)
{
return false;
}
@@ -850,12 +850,12 @@ namespace TriangleNet.Meshing
fixuptri.Lnext(ref neartri);
neartri.Sym(ref fartri);
// Check if the edge opposite the origin of fixuptri can be flipped.
if (fartri.triangle == Mesh.dummytri)
if (fartri.triangle.id == Triangle.EmptyID)
{
return;
}
neartri.SegPivot(ref faredge);
if (faredge.seg != Mesh.dummysub)
if (faredge.seg != Segment.Empty)
{
return;
}
@@ -1027,7 +1027,7 @@ namespace TriangleNet.Meshing
}
// Check for two intersecting segments.
fixuptri.SegPivot(ref crosssubseg);
if (crosssubseg.seg == Mesh.dummysub)
if (crosssubseg.seg == Segment.Empty)
{
mesh.Flip(ref fixuptri); // May create inverted triangle at left.
}
@@ -1077,7 +1077,7 @@ namespace TriangleNet.Meshing
if (checkvertex != endpoint1)
{
// Find a boundary triangle to search from.
searchtri1.triangle = Mesh.dummytri;
searchtri1.triangle = Triangle.Empty;
searchtri1.orient = 0;
searchtri1.SymSelf();
// Search for the segment's first endpoint by point location.
@@ -1111,7 +1111,7 @@ namespace TriangleNet.Meshing
if (checkvertex != endpoint2)
{
// Find a boundary triangle to search from.
searchtri2.triangle = Mesh.dummytri;
searchtri2.triangle = Triangle.Empty;
searchtri2.orient = 0;
searchtri2.SymSelf();
// Search for the segment's second endpoint by point location.
@@ -1148,7 +1148,7 @@ namespace TriangleNet.Meshing
Otri starttri = default(Otri);
// Find a triangle handle on the hull.
hulltri.triangle = Mesh.dummytri;
hulltri.triangle = Triangle.Empty;
hulltri.orient = 0;
hulltri.SymSelf();
// Remember where we started so we know when to stop.
@@ -1161,7 +1161,7 @@ namespace TriangleNet.Meshing
// To find the next hull edge, go clockwise around the next vertex.
hulltri.LnextSelf();
hulltri.Oprev(ref nexttri);
while (nexttri.triangle != Mesh.dummytri)
while (nexttri.triangle.id != Triangle.EmptyID)
{
nexttri.Copy(ref hulltri);
hulltri.Oprev(ref nexttri);
+7 -7
View File
@@ -100,7 +100,7 @@ namespace TriangleNet.Meshing
for (i = 0; i < mesh.vertices.Count; i++)
{
Otri tmp = default(Otri);
tmp.triangle = Mesh.dummytri;
tmp.triangle = Triangle.Empty;
vertexarray[i] = new List<Otri>(3);
vertexarray[i].Add(tmp);
}
@@ -158,7 +158,7 @@ namespace TriangleNet.Meshing
checktri = nexttri;
if (checktri.triangle != Mesh.dummytri)
if (checktri.triangle.id != Triangle.EmptyID)
{
tdest = tri.Dest();
tapex = tri.Apex();
@@ -186,7 +186,7 @@ namespace TriangleNet.Meshing
nexttri = vertexarray[aroundvertex][index];
checktri = nexttri;
} while (checktri.triangle != Mesh.dummytri);
} while (checktri.triangle.id != Triangle.EmptyID);
}
}
@@ -270,7 +270,7 @@ namespace TriangleNet.Meshing
// occurrence of a triangle on a list can (and does) represent
// an edge. In this way, most edges are represented twice, and
// every triangle-subsegment bond is represented once.
while (notfound && (checktri.triangle != Mesh.dummytri))
while (notfound && (checktri.triangle.id != Triangle.EmptyID))
{
checkdest = checktri.Dest();
@@ -283,7 +283,7 @@ namespace TriangleNet.Meshing
checktri.SegBond(ref subseg);
// Check if this is a boundary edge.
checktri.Sym(ref checkneighbor);
if (checkneighbor.triangle == Mesh.dummytri)
if (checkneighbor.triangle.id == Triangle.EmptyID)
{
// The next line doesn't insert a subsegment (because there's
// already one there), but it sets the boundary markers of
@@ -315,7 +315,7 @@ namespace TriangleNet.Meshing
nexttri = vertexarray[i][index];
checktri = nexttri;
while (checktri.triangle != Mesh.dummytri)
while (checktri.triangle.id != Triangle.EmptyID)
{
// Find the next triangle in the stack before this
// information gets overwritten.
@@ -324,7 +324,7 @@ namespace TriangleNet.Meshing
// No adjacent subsegment. (This overwrites the stack info.)
checktri.SegDissolve();
checktri.Sym(ref checkneighbor);
if (checkneighbor.triangle == Mesh.dummytri)
if (checkneighbor.triangle.id == Triangle.EmptyID)
{
mesh.InsertSubseg(ref checktri, 1);
hullsize++;
@@ -76,7 +76,7 @@ namespace TriangleNet.Meshing.Iterators
tri.Sym(ref neighbor);
if ((tri.triangle.id < neighbor.triangle.id) || (neighbor.triangle == Mesh.dummytri))
if ((tri.triangle.id < neighbor.triangle.id) || (neighbor.triangle.id == Triangle.EmptyID))
{
p1 = tri.Org();
p2 = tri.Dest();
@@ -66,8 +66,8 @@ namespace TriangleNet.Meshing.Iterators
testtri.SegPivot(ref neighborsubseg);
// Make sure the neighbor exists, is not already infected, and
// isn't protected by a subsegment.
if ((neighbor.triangle != Mesh.dummytri) && !neighbor.IsInfected()
&& (neighborsubseg.seg == Mesh.dummysub))
if ((neighbor.triangle.id != Triangle.EmptyID) && !neighbor.IsInfected()
&& (neighborsubseg.seg == Segment.Empty))
{
// Infect the neighbor.
neighbor.Infect();
@@ -104,7 +104,7 @@ namespace TriangleNet.Meshing.Iterators
/// </summary>
public void Process(Triangle triangle, Action<Triangle> func)
{
if (triangle != Mesh.dummytri)
if (triangle.id != Triangle.EmptyID)
{
// Make sure the triangle under consideration still exists.
// It may have been eaten by the virus.
+10 -10
View File
@@ -89,7 +89,7 @@ namespace TriangleNet.Meshing
// Check one neighbor of the subsegment.
testsubseg.TriPivot(ref neighbortri);
// Does the neighbor exist, or is this a boundary edge?
if (neighbortri.triangle != Mesh.dummytri)
if (neighbortri.triangle.id != Triangle.EmptyID)
{
sides++;
// Find a vertex opposite this subsegment.
@@ -119,7 +119,7 @@ namespace TriangleNet.Meshing
testsubseg.Sym(ref testsym);
testsym.TriPivot(ref neighbortri);
// Does the neighbor exist, or is this a boundary edge?
if (neighbortri.triangle != Mesh.dummytri)
if (neighbortri.triangle.id != Triangle.EmptyID)
{
sides++;
// Find the other vertex opposite this subsegment.
@@ -318,7 +318,7 @@ namespace TriangleNet.Meshing
// Check if both points lie in a common segment. If they do, the
// skinny triangle is enqueued to be split as usual.
tri1.SegPivot(ref testsub);
if (testsub.seg == Mesh.dummysub)
if (testsub.seg == Segment.Empty)
{
// No common segment. Find a subsegment that contains 'torg'.
tri1.Copy(ref tri2);
@@ -326,7 +326,7 @@ namespace TriangleNet.Meshing
{
tri1.OprevSelf();
tri1.SegPivot(ref testsub);
} while (testsub.seg == Mesh.dummysub);
} while (testsub.seg == Segment.Empty);
// Find the endpoints of the containing segment.
org1 = testsub.SegOrg();
dest1 = testsub.SegDest();
@@ -335,7 +335,7 @@ namespace TriangleNet.Meshing
{
tri2.DnextSelf();
tri2.SegPivot(ref testsub);
} while (testsub.seg == Mesh.dummysub);
} while (testsub.seg == Segment.Empty);
// Find the endpoints of the containing segment.
org2 = testsub.SegOrg();
dest2 = testsub.SegDest();
@@ -458,11 +458,11 @@ namespace TriangleNet.Meshing
currentenc.TriPivot(ref enctri);
enctri.Lnext(ref testtri);
testtri.SegPivot(ref testsh);
acuteorg = testsh.seg != Mesh.dummysub;
acuteorg = testsh.seg != Segment.Empty;
// Is the destination shared with another segment?
testtri.LnextSelf();
testtri.SegPivot(ref testsh);
acutedest = testsh.seg != Mesh.dummysub;
acutedest = testsh.seg != Segment.Empty;
// If we're using Chew's algorithm (rather than Ruppert's)
// to define encroachment, delete free vertices from the
@@ -483,17 +483,17 @@ namespace TriangleNet.Meshing
// Now, check the other side of the segment, if there's a triangle there.
enctri.Sym(ref testtri);
if (testtri.triangle != Mesh.dummytri)
if (testtri.triangle.id != Triangle.EmptyID)
{
// Is the destination shared with another segment?
testtri.LnextSelf();
testtri.SegPivot(ref testsh);
acutedest2 = testsh.seg != Mesh.dummysub;
acutedest2 = testsh.seg != Segment.Empty;
acutedest = acutedest || acutedest2;
// Is the origin shared with another segment?
testtri.LnextSelf();
testtri.SegPivot(ref testsh);
acuteorg2 = testsh.seg != Mesh.dummysub;
acuteorg2 = testsh.seg != Segment.Empty;
acuteorg = acuteorg || acuteorg2;
// Delete free vertices from the subsegment's diametral circle.