using System using System Collections Generic using NUnit Framework us

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using Eurosoft.Geometry;
using Eurosoft.Geometry.Utilities;
using Wintellect.PowerCollections;
namespace Eurosoft.Geometry.UnitTests.Tests.GeoLibAdapterTest
{
[TestFixture]
public class PolygonPolygon : GeoLibAdapterTest
{
[SetUp]
public override void PrepareTestData()
{
base.PrepareTestData();
}
[TearDown]
public override void PerformTest()
{
GeoLibAdapter.ComputePolygonToPolygonIntersection((Polygon<_3D>)obj1, (Polygon<_3D>)obj2, factory, _list, _tolerance);
CompareResultsWithExpectations();
}
private Polygon<_3D> CreateTestPolygon()
{
return factory.CreatePolygon(new _3D[] {
new _3D( 0.0, 0.0, 0.0), // 0 // ^ Y
new _3D(10.0, 0.0, 0.0), // 1 // |
new _3D(10.0, 6.0, 0.0), // 2 //11| 10 7 6 3 2
new _3D( 8.0, 6.0, 0.0), // 3 // ***** ***** *****
new _3D( 8.0, 3.0, 0.0), // 4 // * * * * * *
new _3D( 6.0, 3.0, 0.0), // 5 // * ***** * * *
new _3D( 6.0, 6.0, 0.0), // 6 // * 9 8 ***** *
new _3D( 4.0, 6.0, 0.0), // 7 // * 5 4 *
new _3D( 4.0, 4.0, 0.0), // 8 // * *
new _3D( 2.0, 4.0, 0.0), // 9 // *********************----------> X
new _3D( 2.0, 6.0, 0.0), // 10 // 0 1
new _3D( 0.0, 6.0, 0.0) }, // 11
true
);
}
[Test]
public void NonComplanar()
{
obj1 = CreateTestPolygon();
obj2 = factory.CreatePolygon(new _3D[] {
new _3D( 0.0, 4.0, -2.0), // 0
new _3D( 2.0, 4.0, -2.0), // 1
new _3D( 2.0, 4.0, 1.0), // 2
new _3D( 4.0, 4.0, 1.0), // 3
new _3D( 4.0, 4.0, -1.0), // 4
new _3D( 5.0, 4.0, -1.0), // 5 // ^ Z
new _3D( 5.0, 4.0, 0.0), // 6 // |
new _3D( 8.0, 4.0, 0.0), // 7 // |
new _3D( 8.0, 4.0, 1.0), // 8 //13*********************12
new _3D( 9.0, 4.0, 1.0), // 9 // * 2***** 6 8***9*
new _3D( 9.0, 4.0, -1.0), // 10 // *---*--3*-*******-*-*---------> X
new _3D(10.0, 4.0, -1.0), // 11 // * * *** 7 ***
new _3D(10.0, 4.0, 2.0), // 12 // ***** 4 5 10 11
new _3D( 0.0, 4.0, 2.0) }, // 13 // 0 1
true
);
_expectedIntersections = new GeometricalObject<_3D>[] {
factory.CreateLine(new _3D(0.0, 4.0, 0.0), new _3D(2.0, 4.0, 0.0)),
factory.CreateLine(new _3D(4.0, 4.0, 0.0), new _3D(6.0, 4.0, 0.0)),
factory.CreateLine(new _3D(9.0, 4.0, 0.0), new _3D(10.0, 4.0, 0.0)),
factory.CreatePoint(new _3D(8.0, 4.0, 0.0))
};
_tolerance = 1e-15;
}
[Test]
public void Complanar()
{
obj1 = CreateTestPolygon();
obj2 = factory.CreatePolygon(new _3D[] {
new _3D( 0.0, 6.0, 0.0), // 0
new _3D( 3.0, 6.0, 0.0), // 1
new _3D( 3.0, 5.0, 0.0), // 2
new _3D( 7.0, 5.0, 0.0), // 3 // 9 8
new _3D( 7.0, 6.0, 0.0), // 4 // *********************
new _3D( 8.0, 6.0, 0.0), // 5 // * 1 4 6*****
new _3D( 8.0, 7.0, 0.0), // 6 // ******* *** 7
new _3D(10.0, 7.0, 0.0), // 7 // 0 ********* 5
new _3D(10.0, 8.0, 0.0), // 8 // 2 3
new _3D( 0.0, 8.0, 0.0) }, // 9
true
);
_expectedIntersections = new GeometricalObject<_3D>[] {
factory.CreatePoint(new _3D(8.0, 6.0, 0.0)),
factory.CreateLine(new _3D(0.0, 6.0, 0.0), new _3D(2.0, 6.0, 0.0)),
factory.CreatePolygon(new _3D[] {
new _3D(4.0, 5.0, 0.0),
new _3D(6.0, 5.0, 0.0),
new _3D(6.0, 6.0, 0.0),
new _3D(4.0, 6.0, 0.0) },
true)
};
_tolerance = 1e-161;
}
}
}