Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2817-BinPackingSpeedup/HeuristicLab.Tests/HeuristicLab.Problems.Bin-Packing-3.3/3D/Geometry/Plane3DTest.cs @ 15554

Last change on this file since 15554 was 15554, checked in by rhanghof, 6 years ago

#2817:

  • Unittests
  • Bugfixes on the line projection based extreme point creation method
File size: 3.9 KB
Line 
1using System;
2using Microsoft.VisualStudio.TestTools.UnitTesting;
3using HeuristicLab.Problems.BinPacking3D.Geometry;
4using HeuristicLab.Problems.BinPacking3D;
5
6namespace HeuristicLab.Problems.BinPacking._3D.Geometry.Test {
7  [TestClass]
8  public class Plane3DTest {
9
10    Line3D _line1;
11    Line3D _line2;
12    Line3D _line3;
13    Line3D _line4;
14    Line3D _line5;
15    Line3D _line6;
16
17    Vector3D _point1;
18    Vector3D _point2;
19    Vector3D _point3;
20    Vector3D _point4;
21    Vector3D _point5;
22    Vector3D _point6;
23
24    Plane3D _plane1;
25    Plane3D _plane2;
26    Plane3D _plane3;
27
28    [TestInitialize]
29    public void Initialize() {
30      _line1 = new Line3D(new Vector3D(0, 0, 0), new Vector3D(10, 0, 0));
31      _line2 = new Line3D(new Vector3D(0, 0, 0), new Vector3D(0, 10, 0));
32      _line3 = new Line3D(new Vector3D(0, 0, 0), new Vector3D(0, 0, 10));
33
34      _line4 = new Line3D(new Vector3D(-10, 2, 2), new Vector3D(10, 0, 0));
35      _line5 = new Line3D(new Vector3D(2, -10, 2), new Vector3D(0, 10, 0));
36      _line6 = new Line3D(new Vector3D(2, 2, -10), new Vector3D(0, 0, 10));
37
38      _point1 = new Vector3D(3, 0, 0);
39      _point2 = new Vector3D(0, 3, 0);
40      _point3 = new Vector3D(0, 0, 3);
41
42      _point4 = new Vector3D(5, 5, 5);
43      _point5 = new Vector3D(2, 2, 2);
44      _point6 = new Vector3D(0, 0, 0);
45
46      _plane1 = new Plane3D(_point6.ToPackingPosition(0), new PackingItem(10, 10, 10, new PackingShape()), Side.Top);
47      _plane2 = new Plane3D(_point6.ToPackingPosition(0), new PackingItem(10, 10, 10, new PackingShape()), Side.Right);
48      _plane3 = new Plane3D(_point6.ToPackingPosition(0), new PackingItem(10, 10, 10, new PackingShape()), Side.Front);
49    }
50
51
52    [TestMethod]
53    [TestCategory("Problems.BinPacking.3D")]
54    [TestProperty("Time", "short")]
55    public void TestIsElementOf() {
56      Assert.IsTrue(_plane1.IsElementOf(new Vector3D(0, 10, 0)));
57      Assert.IsTrue(_plane1.IsElementOf(new Vector3D(5, 10, 0)));
58      Assert.IsTrue(_plane1.IsElementOf(new Vector3D(0, 10, 5)));
59      Assert.IsTrue(_plane1.IsElementOf(new Vector3D(5, 10, 5)));
60      Assert.IsFalse(_plane1.IsElementOf(new Vector3D(0, 9, 0)));
61      Assert.IsFalse(_plane1.IsElementOf(new Vector3D(0, 11, 0)));
62    }
63
64
65    [TestMethod]
66    [TestCategory("Problems.BinPacking.3D")]
67    [TestProperty("Time", "short")]
68    public void TestIntersects() {
69      Assert.IsFalse(_plane1.Intersects(_line1));
70      Assert.IsTrue(_plane1.Intersects(_line2));
71      Assert.IsFalse(_plane1.Intersects(_line3));
72
73      Assert.IsTrue(_plane2.Intersects(_line1));
74      Assert.IsFalse(_plane2.Intersects(_line2));
75      Assert.IsFalse(_plane2.Intersects(_line3));
76
77      Assert.IsFalse(_plane3.Intersects(_line1));
78      Assert.IsFalse(_plane3.Intersects(_line2));
79      Assert.IsTrue(_plane3.Intersects(_line3));
80
81      Assert.IsTrue(_plane1.Intersects(new Line3D(new Vector3D(-1, -2, 2), new Vector3D(1, 3, 1))));
82      Assert.IsFalse(_plane1.Intersects(new Line3D(new Vector3D(-1, -2, 2), new Vector3D(-1, -3, 1))));
83    }
84
85
86    [TestMethod]
87    [TestCategory("Problems.BinPacking.3D")]
88    [TestProperty("Time", "short")]
89    public void TestIntersect() {
90      Assert.IsNull(_plane1.Intersect(_line1));
91      Assert.AreEqual(new Vector3D(0, 10, 0), _plane1.Intersect(_line2));
92      Assert.IsNull(_plane1.Intersect(_line3));
93
94      Assert.AreEqual(new Vector3D(10, 0, 0), _plane2.Intersect(_line1));
95      Assert.IsNull(_plane2.Intersect(_line2));
96      Assert.IsNull(_plane2.Intersect(_line3));
97
98      Assert.IsNull(_plane3.Intersect(_line1));
99      Assert.IsNull(_plane3.Intersect(_line2));
100      Assert.AreEqual(new Vector3D(0, 0, 10), _plane3.Intersect(_line3));
101      Assert.AreEqual(new Vector3D(3, 10, 6), _plane1.Intersect(new Line3D(new Vector3D(-1, -2, 2), new Vector3D(1, 3, 1))));
102      Assert.IsNull(_plane1.Intersect(new Line3D(new Vector3D(-1, -2, 2), new Vector3D(-1, -3, 1))));
103    }
104  }
105}
Note: See TracBrowser for help on using the repository browser.