OpenWalnut  1.5.0dev
WMPointConnector_test.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMPOINTCONNECTOR_TEST_H
26 #define WMPOINTCONNECTOR_TEST_H
27 
28 #include <cxxtest/TestSuite.h>
29 
30 #include "../WMPointConnector.h"
31 
32 
33 /**
34  * Test functionality of WMPointConnector class
35  */
36 class WMPointConnectorTest : public CxxTest::TestSuite
37 {
38 public:
39  /**
40  * Setup logger and other stuff for each test.
41  */
42  void setUp()
43  {
45  }
46 
47  /**
48  * Instatiation should throw nothing.
49  */
51  {
52  TS_ASSERT_THROWS_NOTHING( WMPointConnector() );
53  }
54 
55  /**
56  * Test if ray trace algorithm hits vertex at least twice
57  */
59  {
60  osg::Vec3 rayStart( 0.0, 0.0, 0.0 );
61  osg::Vec3 rayDir( 0.0, 0.0, 1.0 );
62  osg::Vec3 targetVertex( 0.0, 0.0, 40.4 );
63  float targetVertexRadius = 1.0;
64 
65  TS_ASSERT_LESS_THAN( 0.0,
66  WMPointConnector().hitVertex( rayStart, rayDir, targetVertex, targetVertexRadius )
67  );
68  }
69 
70  /**
71  * Test if ray trace algorithm hits vertex at one point
72  */
74  {
75  osg::Vec3 rayStart( 0.0, 0.0, 0.0 );
76  osg::Vec3 rayDir( 0.0, 0.0, 1.0 );
77  osg::Vec3 targetVertex( 1.0, 0.0, 2.0 );
78  float targetVertexRadius = 1.0;
79 
80  TS_ASSERT_EQUALS( 0.0,
81  WMPointConnector().hitVertex( rayStart, rayDir, targetVertex, targetVertexRadius )
82  );
83  }
84 
85  /**
86  * Test if ray trace algorithm does not hit vertex in front of starting position
87  */
89  {
90  osg::Vec3 rayStart( 0.0, 0.0, 0.0 );
91  osg::Vec3 rayDir( 0.0, 0.0, 1.0 );
92  osg::Vec3 targetVertex( 3.0, 2.0, 12.0 );
93  float targetVertexRadius = 1.0;
94 
95  TS_ASSERT_LESS_THAN( WMPointConnector().hitVertex( rayStart, rayDir, targetVertex, targetVertexRadius ),
96  0.0
97  );
98  }
99 
100  /**
101  * Test if ray trace algorithm does not hit vertex behind starting position
102  */
104  {
105  osg::Vec3 rayStart( 0.0, 0.0, 0.0 );
106  osg::Vec3 rayDir( 0.0, 0.0, 1.0 );
107  osg::Vec3 targetVertex( 3.0, 2.0, -12.0 );
108  float targetVertexRadius = 1.0;
109 
110  TS_ASSERT_LESS_THAN( WMPointConnector().hitVertex( rayStart, rayDir, targetVertex, targetVertexRadius ),
111  0.0
112  );
113  }
114 };
115 
116 #endif // WMPOINTCONNECTOR_TEST_H
static void startup(std::ostream &output=std::cout, LogLevel level=LL_DEBUG)
Create the first and only instance of the logger as it is a singleton.
Definition: WLogger.cpp:41
Test functionality of WMPointConnector class.
void testHitVertex_MissAhead()
Test if ray trace algorithm does not hit vertex in front of starting position.
void setUp()
Setup logger and other stuff for each test.
void testInstantiation()
Instatiation should throw nothing.
void testHitVertex_MissBehind()
Test if ray trace algorithm does not hit vertex behind starting position.
void testHitVertex_Hit()
Test if ray trace algorithm hits vertex at least twice.
void testHitVertex_Tangent()
Test if ray trace algorithm hits vertex at one point.
This module connects the points in a point dataset.