00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date: 2010-03-15 11:12:36 +0100 (Mo, 15 Mrz 2010) $ 00006 Version: $Revision: 21745 $ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 #include "mitkTestingMacros.h" 00019 #include "mitkPlanarArrow.h" 00020 #include "mitkPlaneGeometry.h" 00021 00022 00023 class mitkPlanarArrowTestClass 00024 { 00025 00026 public: 00027 00028 00029 static void TestPlanarArrowPlacement( mitk::PlanarArrow::Pointer PlanarArrow ) 00030 { 00031 // Test for correct minimum number of control points in cross-mode 00032 MITK_TEST_CONDITION( PlanarArrow->GetMinimumNumberOfControlPoints() == 2, "Minimum number of control points" ); 00033 00034 // Test for correct maximum number of control points in cross-mode 00035 MITK_TEST_CONDITION( PlanarArrow->GetMaximumNumberOfControlPoints() == 2, "Maximum number of control points" ); 00036 00037 // Initial placement of PlanarArrow 00038 mitk::Point2D p0; 00039 p0[0] = 00.0; p0[1] = 0.0; 00040 PlanarArrow->PlaceFigure( p0 ); 00041 00042 // Add second control point 00043 mitk::Point2D p1; 00044 p1[0] = 50.0; p1[1] = 00.0; 00045 PlanarArrow->SetControlPoint(1, p1 ); 00046 00047 // Test for number of control points 00048 MITK_TEST_CONDITION( PlanarArrow->GetNumberOfControlPoints() == 2, "Number of control points after placement" ); 00049 00050 // Test for number of polylines 00051 const mitk::PlanarFigure::VertexContainerType* polyLine0 = PlanarArrow->GetPolyLine( 0 ); 00052 MITK_TEST_CONDITION( PlanarArrow->GetPolyLinesSize() == 1, "Number of polylines after placement" ); 00053 00054 // Get polylines and check if the generated coordinates are OK 00055 const mitk::Point2D& pp0 = polyLine0->ElementAt( 0 ); 00056 const mitk::Point2D& pp1 = polyLine0->ElementAt( 1 ); 00057 MITK_TEST_CONDITION( (pp0 == p0) && (pp1 == p1), "Correct polyline 1" ); 00058 00059 00060 // Test for number of measurement features 00061 // none yet 00062 00063 } 00064 }; 00071 int mitkPlanarArrowTest(int /* argc */, char* /*argv*/[]) 00072 { 00073 // always start with this! 00074 MITK_TEST_BEGIN("PlanarArrow") 00075 00076 // create PlaneGeometry on which to place the PlanarArrow 00077 mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); 00078 planeGeometry->InitializeStandardPlane( 100.0, 100.0 ); 00079 00080 // ************************************************************************** 00081 // 1. Instantiation and basic tests 00082 mitk::PlanarArrow::Pointer PlanarArrow = mitk::PlanarArrow::New(); 00083 PlanarArrow->SetGeometry2D( planeGeometry ); 00084 00085 // first test: did this work? 00086 MITK_TEST_CONDITION_REQUIRED( PlanarArrow.IsNotNull(), "Testing instantiation" ); 00087 00088 // Test placement of PlanarArrow by control points 00089 mitkPlanarArrowTestClass::TestPlanarArrowPlacement( PlanarArrow ); 00090 00091 // always end with this! 00092 MITK_TEST_END(); 00093 }