public void TestCompareTo_ObjEqualInEverything() { Vertex vertex = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(vertex); HalfEdge otherEdge = new HalfEdge(vertex); HalfEdge twin = Auxilaries.RandomHalfEdge(); thisEdge.Twin = twin; otherEdge.Twin = twin; HalfEdge next = Auxilaries.RandomHalfEdge(); thisEdge.Next = next; otherEdge.Next = next; HalfEdge previous = Auxilaries.RandomHalfEdge(); thisEdge.Previous = previous; otherEdge.Previous = previous; int expected = 0; int actual = thisEdge.CompareTo(otherEdge); Assert.AreEqual(expected, actual); }
void TestCompareTo_ObjNotVertex_Helper() { Vertex vertex = Auxilaries.RandomVertex(); HalfEdge edge = Auxilaries.RandomHalfEdge(); vertex.CompareTo(edge); }
public void TestAddIncidentEdges_TwinsAndNextAndPreviousSet() { Vertex v1 = Auxilaries.RandomVertex(); Vertex v2 = Auxilaries.RandomVertex(); Vertex v3 = Auxilaries.RandomVertex(); HalfEdge e11 = new HalfEdge(v1); HalfEdge e12 = new HalfEdge(v2); HalfEdge e31 = new HalfEdge(v3); HalfEdge e32 = new HalfEdge(v1); HalfEdge e41 = new HalfEdge(v3); HalfEdge e42 = new HalfEdge(v2); e11.Twin = e12; e12.Twin = e11; e31.Twin = e32; e32.Twin = e31; e41.Twin = e42; e42.Twin = e41; e12.Next = e32; e32.Next = e41; e41.Next = e12; e12.Previous = e41; e32.Previous = e12; e41.Previous = e32; v1.AddIncidentEdge(e32); Assert.Contains(e32, v1.IncidentEdges); }
void TestCompareTo_ObjNotHalfedge_Helper() { HalfEdge edge = Auxilaries.RandomHalfEdge(); Vertex vertex = Auxilaries.RandomVertex(); edge.CompareTo(vertex); }
public void TestEquals_EqualBothIncidentFacesSet() { Vertex a = Auxilaries.RandomVertex(); Vertex b = Auxilaries.RandomVertex(); Vertex c = Auxilaries.RandomVertex(); HalfEdge abOther = new HalfEdge(a); HalfEdge abThis = new HalfEdge(a); HalfEdge ac = new HalfEdge(a); HalfEdge ba = new HalfEdge(b); HalfEdge bc = new HalfEdge(b); HalfEdge ca = new HalfEdge(c); HalfEdge cb = new HalfEdge(c); Face face = new Face(2, Auxilaries.RandomNormal()); face.AddOuterComponent(abThis); face.AddOuterComponent(bc); face.AddOuterComponent(ca); abThis.IncidentFace = face; abOther.IncidentFace = face; abThis.Twin = ba; abOther.Twin = ba; ac.Twin = ca; ba.Twin = abThis; bc.Twin = bc; ca.Twin = ac; cb.Twin = bc; abThis.Next = bc; abOther.Next = bc; ac.Next = cb; ba.Next = ac; bc.Next = ca; ca.Next = abThis; cb.Next = ba; abThis.Previous = ca; abOther.Previous = ca; ac.Previous = ba; ba.Previous = cb; bc.Previous = abThis; ca.Previous = bc; cb.Previous = ac; Assert.AreEqual(abThis.GetHashCode(), abOther.GetHashCode()); Assert.IsTrue(abThis.Equals(abOther)); Assert.IsTrue(abOther.Equals(abThis)); }
public void YIsNull() { Vertex x = Auxilaries.RandomVertex(); Vertex y = null; Assert.IsFalse(comparer.Equals(x, y)); Assert.AreNotEqual(comparer.GetHashCode(x), comparer.GetHashCode(y)); }
public void XAndyAreNotEqual_PositionDifferent() { Vertex x = Auxilaries.RandomVertex(); Vertex y = Auxilaries.RandomVertex(); Assert.IsFalse(comparer.Equals(x, y)); Assert.AreNotEqual(comparer.GetHashCode(x), comparer.GetHashCode(y)); }
public void TestAddIncidentEdges_NoOtherPropertiesSet() { Vertex v1 = Auxilaries.RandomVertex(); HalfEdge e11 = new HalfEdge(v1); v1.AddIncidentEdge(e11); Assert.Contains(e11, v1.IncidentEdges); }
public void TestEquals_PositionNotEqual() { Vertex thisVertex = Auxilaries.RandomVertex(); Vertex otherVertex = Auxilaries.RandomVertex(); Assert.IsFalse(thisVertex.Equals(otherVertex)); Assert.IsFalse(otherVertex.Equals(thisVertex)); Assert.AreNotEqual(thisVertex, otherVertex); }
public void XAndyAreEqual() { Vertex positon = Auxilaries.RandomVertex(); HalfEdge x = new HalfEdge(positon); HalfEdge y = new HalfEdge(positon); Assert.IsTrue(comparer.Equals(x, y)); Assert.AreEqual(comparer.GetHashCode(x), comparer.GetHashCode(y)); }
public void TestCompareTo_ObjNull() { Vertex vertex = Auxilaries.RandomVertex(); int expected = 1; int actual = vertex.CompareTo(null); Assert.AreEqual(expected, actual); }
public void TestAddIncidentEdges_ReplicateSegmentationFault() { Vertex v1 = Auxilaries.RandomVertex(); Vertex v2 = Auxilaries.RandomVertex(); Vertex v3 = Auxilaries.RandomVertex(); HalfEdge e11 = new HalfEdge(v1); HalfEdge e12 = new HalfEdge(v2); HalfEdge e31 = new HalfEdge(v3); HalfEdge e32 = new HalfEdge(v1); HalfEdge e41 = new HalfEdge(v3); HalfEdge e42 = new HalfEdge(v2); e11.Twin = e12; e12.Twin = e11; e31.Twin = e32; e32.Twin = e31; e41.Twin = e42; e42.Twin = e41; e12.Next = e32; e32.Next = e41; e41.Next = e12; e12.Previous = e41; e32.Previous = e12; e41.Previous = e32; Face f2 = new Face(2, Auxilaries.RandomNormal()); f2.AddOuterComponent(e32); f2.AddOuterComponent(e41); f2.AddOuterComponent(e12); e32.IncidentFace = f2; e41.IncidentFace = f2; e12.IncidentFace = f2; v1.AddIncidentEdge(e11); v1.AddIncidentEdge(e32); v2.AddIncidentEdge(e42); v2.AddIncidentEdge(e12); v3.AddIncidentEdge(e31); v3.AddIncidentEdge(e41); Assert.Contains(e11, v1.IncidentEdges); Assert.Contains(e32, v1.IncidentEdges); Assert.Contains(e42, v2.IncidentEdges); Assert.Contains(e12, v2.IncidentEdges); Assert.Contains(e31, v3.IncidentEdges); Assert.Contains(e41, v3.IncidentEdges); }
public void TestEquals_EqualsNoTwins() { Vertex origin = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(origin); HalfEdge otherEdge = new HalfEdge(origin); Assert.IsTrue(thisEdge.Equals(otherEdge)); Assert.IsTrue(otherEdge.Equals(thisEdge)); Assert.AreEqual(thisEdge.GetHashCode(), otherEdge.GetHashCode()); }
public void TestDestination_TwinIsNull() { Vertex origin = Auxilaries.RandomVertex(); HalfEdge edge = new HalfEdge(origin); Vertex actual = null; actual = edge.Destination; Assert.IsNull(actual); }
public void TestCompareTo_ObjEqualInPositionEverythingElseNull() { Vertex vertex = Auxilaries.RandomVertex(); HalfEdge thisHalfEdge = new HalfEdge(vertex); HalfEdge otherHalfEdge = new HalfEdge(vertex); int expected = 0; int actual = thisHalfEdge.CompareTo(otherHalfEdge); Assert.AreEqual(expected, actual); }
public void XAndyAreNotEqual_DestinationDifferent() { Vertex origin = Auxilaries.RandomVertex(); HalfEdge x = new HalfEdge(origin); HalfEdge y = new HalfEdge(origin); x.Twin = Auxilaries.RandomHalfEdge(); y.Twin = Auxilaries.RandomHalfEdge(); Assert.IsFalse(comparer.Equals(x, y)); Assert.AreNotEqual(comparer.GetHashCode(x), comparer.GetHashCode(y)); }
public void TestEquals_EqualsAllPropertiesSet() { Vertex a = Auxilaries.RandomVertex(); Vertex b = Auxilaries.RandomVertex(); Vertex c = Auxilaries.RandomVertex(); HalfEdge abOther = new HalfEdge(a); HalfEdge abThis = new HalfEdge(a); HalfEdge ac = new HalfEdge(a); HalfEdge ba = new HalfEdge(b); HalfEdge bc = new HalfEdge(b); HalfEdge ca = new HalfEdge(c); HalfEdge cb = new HalfEdge(c); abThis.Twin = ba; abOther.Twin = ba; ac.Twin = ca; ba.Twin = abThis; bc.Twin = bc; ca.Twin = ac; cb.Twin = bc; abThis.Next = bc; abOther.Next = bc; ac.Next = cb; ba.Next = ac; bc.Next = ca; ca.Next = abThis; cb.Next = ba; abThis.Previous = ca; abOther.Previous = ca; ac.Previous = ba; ba.Previous = cb; bc.Previous = abThis; ca.Previous = bc; cb.Previous = ac; Assert.IsTrue(abThis.Equals(abOther)); Assert.IsTrue(abOther.Equals(abThis)); Assert.AreEqual(abThis.GetHashCode(), abOther.GetHashCode()); }
public void TestDestination_TwinIsNotNull() { Vertex origin = Auxilaries.RandomVertex(); Vertex destination = Auxilaries.RandomVertex(); HalfEdge edge = new HalfEdge(origin); edge.Twin = new HalfEdge(destination); Vertex expected = destination; Vertex actual = edge.Destination; Assert.That(actual, Is.EqualTo(expected)); }
public void Test_Vertices_Rectangle() { Vertex a = Auxilaries.RandomVertex(); Vertex b = Auxilaries.RandomVertex(); Vertex c = Auxilaries.RandomVertex(); Vertex d = Auxilaries.RandomVertex(); HalfEdge ab = new HalfEdge(a); HalfEdge ba = new HalfEdge(b); HalfEdge bc = new HalfEdge(b); HalfEdge cb = new HalfEdge(c); HalfEdge cd = new HalfEdge(c); HalfEdge dc = new HalfEdge(d); HalfEdge da = new HalfEdge(d); HalfEdge ad = new HalfEdge(a); ab.Twin = ba; ab.Next = bc; ab.Previous = da; bc.Twin = cb; bc.Next = cd; bc.Previous = ab; cd.Twin = dc; cd.Next = da; cd.Previous = bc; da.Twin = ad; da.Next = ab; da.Previous = cd; Face face = new Face(0, Auxilaries.RandomNormal()); face.AddOuterComponent(bc); face.AddOuterComponent(cd); face.AddOuterComponent(da); face.AddOuterComponent(ab); ReadOnlyCollection <Vertex> expected = new List <Vertex> { a, b, c, d }.AsReadOnly(); ReadOnlyCollection <Vertex> actual = face.Vertices; Assert.That(actual, Is.EquivalentTo(expected)); }
public void TestCompareTo_ObjEqualInPositionLargerInPrevious() { Vertex vertex = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(vertex); HalfEdge otherEdge = new HalfEdge(vertex); thisEdge.Previous = new HalfEdge(new Vertex(new Vector3(3, 4, 5))); otherEdge.Previous = new HalfEdge(new Vertex(new Vector3(0, 1, 2))); int expected = +1; int actual = thisEdge.CompareTo(otherEdge); Assert.AreEqual(expected, actual); }
public void XAndyAreEqual_IncidentFaceDifferent() { Vertex origin = Auxilaries.RandomVertex(); Vertex destination = Auxilaries.RandomVertex(); HalfEdge x = new HalfEdge(origin); HalfEdge y = new HalfEdge(origin); x.Twin = new HalfEdge(destination); y.Twin = new HalfEdge(destination); x.IncidentFace = Auxilaries.RandomFace(); y.IncidentFace = Auxilaries.RandomFace(); Assert.IsTrue(comparer.Equals(x, y)); Assert.AreEqual(comparer.GetHashCode(x), comparer.GetHashCode(y)); }
public void TestArea_NotTriangle_Helper() { Vertex a = Auxilaries.RandomVertex(); Vertex b = Auxilaries.RandomVertex(); Vertex c = Auxilaries.RandomVertex(); Vertex d = Auxilaries.RandomVertex(); HalfEdge ab = new HalfEdge(a); HalfEdge ba = new HalfEdge(b); HalfEdge bc = new HalfEdge(b); HalfEdge cb = new HalfEdge(c); HalfEdge cd = new HalfEdge(c); HalfEdge dc = new HalfEdge(d); HalfEdge da = new HalfEdge(d); HalfEdge ad = new HalfEdge(a); ab.Twin = ba; ab.Next = bc; ab.Previous = da; bc.Twin = cb; bc.Next = cd; bc.Previous = ab; cd.Twin = dc; cd.Next = da; cd.Previous = bc; da.Twin = ad; da.Next = ab; da.Previous = cd; Face rectangle = new Face(0, Auxilaries.RandomNormal()); rectangle.AddOuterComponent(bc); rectangle.AddOuterComponent(cd); rectangle.AddOuterComponent(da); rectangle.AddOuterComponent(ab); float area = rectangle.Area; }
public void TestIsTriangular_Rectangle() { Vertex a = Auxilaries.RandomVertex(); Vertex b = Auxilaries.RandomVertex(); Vertex c = Auxilaries.RandomVertex(); Vertex d = Auxilaries.RandomVertex(); HalfEdge ab = new HalfEdge(a); HalfEdge ba = new HalfEdge(b); HalfEdge bc = new HalfEdge(b); HalfEdge cb = new HalfEdge(c); HalfEdge cd = new HalfEdge(c); HalfEdge dc = new HalfEdge(d); HalfEdge da = new HalfEdge(d); HalfEdge ad = new HalfEdge(a); ab.Twin = ba; ab.Next = bc; ab.Previous = da; bc.Twin = cb; bc.Next = cd; bc.Previous = ab; cd.Twin = dc; cd.Next = da; cd.Previous = bc; da.Twin = ad; da.Next = ab; da.Previous = cd; Face rectangle = new Face(0, Auxilaries.RandomNormal()); rectangle.AddOuterComponent(bc); rectangle.AddOuterComponent(cd); rectangle.AddOuterComponent(da); rectangle.AddOuterComponent(ab); Assert.IsFalse(rectangle.IsTriangular()); }
public void TestEquals_EqualsWithTwins() { Vertex origin = Auxilaries.RandomVertex(); Vertex destination = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(origin); HalfEdge otherEdge = new HalfEdge(origin); HalfEdge twin = new HalfEdge(destination); thisEdge.Twin = twin; otherEdge.Twin = twin; twin.Twin = thisEdge; Assert.IsTrue(thisEdge.Equals(otherEdge)); Assert.IsTrue(otherEdge.Equals(thisEdge)); Assert.AreEqual(thisEdge.GetHashCode(), otherEdge.GetHashCode()); }
public void TestCompareTo_ObjEqualInPositionSmallerInNextTwinSet() { Vertex vertex = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(vertex); HalfEdge otherEdge = new HalfEdge(vertex); HalfEdge twin = Auxilaries.RandomHalfEdge(); thisEdge.Twin = twin; otherEdge.Twin = twin; thisEdge.Next = new HalfEdge(new Vertex(new Vector3(0, 1, 2))); otherEdge.Next = new HalfEdge(new Vertex(new Vector3(3, 4, 5))); int expected = -1; int actual = thisEdge.CompareTo(otherEdge); Assert.AreEqual(expected, actual); }
public void TestAddIncidentEdges_TwinsAndNextAndPreviousOuterComponentSet() { Vertex v1 = Auxilaries.RandomVertex(); Vertex v2 = Auxilaries.RandomVertex(); Vertex v3 = Auxilaries.RandomVertex(); HalfEdge e11 = new HalfEdge(v1); HalfEdge e12 = new HalfEdge(v2); HalfEdge e31 = new HalfEdge(v3); HalfEdge e32 = new HalfEdge(v1); HalfEdge e41 = new HalfEdge(v3); HalfEdge e42 = new HalfEdge(v2); e11.Twin = e12; e12.Twin = e11; e31.Twin = e32; e32.Twin = e31; e41.Twin = e42; e42.Twin = e41; e12.Next = e32; e32.Next = e41; e41.Next = e12; e12.Previous = e41; e32.Previous = e12; e41.Previous = e32; Face f2 = new Face(2, Auxilaries.RandomNormal()); f2.AddOuterComponent(e32); f2.AddOuterComponent(e41); f2.AddOuterComponent(e12); v1.AddIncidentEdge(e32); Assert.Contains(e32, v1.IncidentEdges); }
public void TestEquals_NotEqualPreviousDifferent() { Vertex origin = Auxilaries.RandomVertex(); Vertex destination = Auxilaries.RandomVertex(); Vertex thisPreviousOrigin = Auxilaries.RandomVertex(); Vertex otherPreviousOrigin = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(origin); thisEdge.Twin = new HalfEdge(destination); thisEdge.Previous = new HalfEdge(thisPreviousOrigin); thisEdge.Previous.Twin = new HalfEdge(origin); HalfEdge otherEdge = new HalfEdge(origin); otherEdge.Twin = new HalfEdge(destination); otherEdge.Previous = new HalfEdge(otherPreviousOrigin); otherEdge.Previous.Twin = new HalfEdge(origin); Assert.IsFalse(thisEdge.Equals(otherEdge)); Assert.IsFalse(otherEdge.Equals(thisEdge)); Assert.AreNotEqual(thisEdge.GetHashCode(), otherEdge.GetHashCode()); }
public void TestEquals_NotEqualTwinDifferent() { Vertex origin = Auxilaries.RandomVertex(); Vertex thisDestination = Auxilaries.RandomVertex(); Vertex otherDestination = Auxilaries.RandomVertex(); HalfEdge thisEdge = new HalfEdge(origin); HalfEdge otherEdge = new HalfEdge(origin); HalfEdge thisEdgeTwin = new HalfEdge(thisDestination); thisEdge.Twin = thisEdgeTwin; thisEdgeTwin.Twin = thisEdge; HalfEdge otherEdgeTwin = new HalfEdge(otherDestination); otherEdge.Twin = new HalfEdge(otherDestination); otherEdgeTwin.Twin = otherEdge; Assert.IsFalse(thisEdge.Equals(otherEdge)); Assert.IsFalse(otherEdge.Equals(thisEdge)); Assert.AreNotEqual(thisEdge.GetHashCode(), otherEdge.GetHashCode()); }
public void XAndyAreNotEqual_ValuePositionDifferent() { KeyValuePair <Vector3, Vertex> x = new KeyValuePair <Vector3, Vertex>(new Vector3(1, 2, 3), Auxilaries.RandomVertex()); KeyValuePair <Vector3, Vertex> y = new KeyValuePair <Vector3, Vertex>(new Vector3(1, 2, 3), Auxilaries.RandomVertex()); HalfEdge edge = Auxilaries.RandomHalfEdge(); x.Value.AddIncidentEdge(edge); y.Value.AddIncidentEdge(edge); Assert.IsFalse(comparer.Equals(x, y)); Assert.AreNotEqual(comparer.GetHashCode(x), comparer.GetHashCode(y)); }
public void TestEquals_NotEqualsDifferentIncidentFaces() { Vertex a = Auxilaries.RandomVertex(); Vertex b = Auxilaries.RandomVertex(); Vertex c = Auxilaries.RandomVertex(); HalfEdge abOther = new HalfEdge(a); HalfEdge abThis = new HalfEdge(a); HalfEdge ac = new HalfEdge(a); HalfEdge ba = new HalfEdge(b); HalfEdge bc = new HalfEdge(b); HalfEdge ca = new HalfEdge(c); HalfEdge cb = new HalfEdge(c); Vector3 normal = Auxilaries.RandomNormal(); Face thisFace = new Face(0, normal); thisFace.AddOuterComponent(abThis); thisFace.AddOuterComponent(bc); thisFace.AddOuterComponent(ca); Face otherFace = new Face(1, normal); otherFace.AddOuterComponent(abOther); abThis.IncidentFace = thisFace; abOther.IncidentFace = otherFace; abThis.Twin = ba; abOther.Twin = ba; ac.Twin = ca; ba.Twin = abThis; bc.Twin = bc; ca.Twin = ac; cb.Twin = bc; abThis.Next = bc; abOther.Next = bc; ac.Next = cb; ba.Next = ac; bc.Next = ca; ca.Next = abThis; cb.Next = ba; abThis.Previous = ca; abOther.Previous = ca; ac.Previous = ba; ba.Previous = cb; bc.Previous = abThis; ca.Previous = bc; cb.Previous = ac; Assert.AreNotEqual(abThis.GetHashCode(), abOther.GetHashCode()); Assert.IsFalse(abThis.Equals(abOther)); Assert.IsFalse(abOther.Equals(abThis)); }