OpenWalnut  1.5.0dev
WPlane_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 WPLANE_TEST_H
26 #define WPLANE_TEST_H
27 
28 #include <memory>
29 #include <set>
30 
31 #include <cxxtest/TestSuite.h>
32 
33 #include "../../../common/math/test/WPositionTraits.h"
34 #include "../WPlane.h"
35 
36 /**
37  * Unit tests the WPlane class
38  */
39 class WPlaneTest : public CxxTest::TestSuite
40 {
41 public:
42 // /**
43 // * Simple sampling test
44 // */
45 // void testSamplePointsFromCenter( void )
46 // {
47 // WPlane p( WVector3d( 0, 0, 1 ), WPosition( 1.5, 1.5, 1. ) );
48 // WGridRegular3D grid( 2, 2, 2, 1., 1., 1. );
49 // std::shared_ptr< std::set< WPosition > > expected( new std::set< WPosition > );
50 // expected->insert( WPosition( 1, 1, 1 ) );
51 // expected->insert( WPosition( 1.5, 1, 1 ) );
52 // expected->insert( WPosition( 2, 1, 1 ) );
53 // expected->insert( WPosition( 1, 1.5, 1 ) );
54 // expected->insert( WPosition( 1.5, 1.5, 1 ) );
55 // expected->insert( WPosition( 2, 1.5, 1 ) );
56 // expected->insert( WPosition( 1, 2, 1 ) );
57 // expected->insert( WPosition( 1.5, 2, 1 ) );
58 // expected->insert( WPosition( 2, 2, 1 ) );
59 // using string_utils::operator<<;
60 // TS_ASSERT_EQUALS( *expected, *p.samplePoints( grid, 0.5 ) );
61 // }
62 
63  /**
64  * A predefined number of sampling points with step width from the center position.
65  */
66  void testFixedSampling( void )
67  {
68  WPlane p( WVector3d( 0, 0, 1 ), WPosition( 1.5, 1.5, 1. ) );
69  std::shared_ptr< std::set< WPosition > > expected( new std::set< WPosition > );
70  expected->insert( WPosition( 1, 1, 1 ) );
71  expected->insert( WPosition( 1, 1.5, 1 ) );
72  expected->insert( WPosition( 1, 2, 1 ) );
73  expected->insert( WPosition( 1.5, 1, 1 ) );
74  expected->insert( WPosition( 2, 1, 1 ) );
75  expected->insert( WPosition( 1.5, 1.5, 1 ) );
76  expected->insert( WPosition( 2, 1.5, 1 ) );
77  expected->insert( WPosition( 1, 1.5, 1 ) );
78  expected->insert( WPosition( 1.5, 2, 1 ) );
79  expected->insert( WPosition( 2, 2, 1 ) );
80  TS_ASSERT_EQUALS( *expected, *p.samplePoints( 0.5, 2, 2 ) );
81  }
82 };
83 
84 #endif // WPLANE_TEST_H
Unit tests the WPlane class.
Definition: WPlane_test.h:40
void testFixedSampling(void)
A predefined number of sampling points with step width from the center position.
Definition: WPlane_test.h:66
Represents a plane with a normal vector and a position in space.
Definition: WPlane.h:39
std::shared_ptr< std::set< WPosition > > samplePoints(const WGridRegular3D &grid, double stepWidth)
Computes sample points on that plane.
This only is a 3d double vector.