OpenWalnut  1.4.0
WPlane_test.h
00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WPLANE_TEST_H
00026 #define WPLANE_TEST_H
00027 
00028 #include <set>
00029 
00030 #include <cxxtest/TestSuite.h>
00031 
00032 #include "../../../common/math/test/WPositionTraits.h"
00033 #include "../WPlane.h"
00034 
00035 /**
00036  * Unit tests the WPlane class
00037  */
00038 class WPlaneTest : public CxxTest::TestSuite
00039 {
00040 public:
00041 //    /**
00042 //     * Simple sampling test
00043 //     */
00044 //    void testSamplePointsFromCenter( void )
00045 //    {
00046 //        WPlane p( WVector3d( 0, 0, 1 ), WPosition( 1.5, 1.5, 1. ) );
00047 //        WGridRegular3D grid( 2, 2, 2, 1., 1., 1. );
00048 //        boost::shared_ptr< std::set< WPosition > > expected( new std::set< WPosition > );
00049 //        expected->insert( WPosition(   1,   1, 1 ) );
00050 //        expected->insert( WPosition( 1.5,   1, 1 ) );
00051 //        expected->insert( WPosition(   2,   1, 1 ) );
00052 //        expected->insert( WPosition(   1, 1.5, 1 ) );
00053 //        expected->insert( WPosition( 1.5, 1.5, 1 ) );
00054 //        expected->insert( WPosition(   2, 1.5, 1 ) );
00055 //        expected->insert( WPosition(   1,   2, 1 ) );
00056 //        expected->insert( WPosition( 1.5,   2, 1 ) );
00057 //        expected->insert( WPosition(   2,   2, 1 ) );
00058 //        using string_utils::operator<<;
00059 //        TS_ASSERT_EQUALS( *expected, *p.samplePoints( grid, 0.5 ) );
00060 //    }
00061 
00062     /**
00063      * A predefined number of sampling points with step width from the center position.
00064      */
00065     void testFixedSampling( void )
00066     {
00067         WPlane p( WVector3d( 0, 0, 1 ), WPosition( 1.5, 1.5, 1. ) );
00068         boost::shared_ptr< std::set< WPosition > > expected( new std::set< WPosition > );
00069         expected->insert( WPosition(   1,   1, 1 ) );
00070         expected->insert( WPosition(   1, 1.5, 1 ) );
00071         expected->insert( WPosition(   1,   2, 1 ) );
00072         expected->insert( WPosition( 1.5,   1, 1 ) );
00073         expected->insert( WPosition(   2,   1, 1 ) );
00074         expected->insert( WPosition( 1.5, 1.5, 1 ) );
00075         expected->insert( WPosition(   2, 1.5, 1 ) );
00076         expected->insert( WPosition(   1, 1.5, 1 ) );
00077         expected->insert( WPosition( 1.5,   2, 1 ) );
00078         expected->insert( WPosition(   2,   2, 1 ) );
00079         TS_ASSERT_EQUALS( *expected, *p.samplePoints( 0.5, 2, 2 ) );
00080      }
00081 };
00082 
00083 #endif  // WPLANE_TEST_H