<commit_before>/*=========================================================================

Program:   Medical Imaging & Interaction Toolkit
Language:  C++
Date:      $Date: 2010-02-21 19:34:02 +0100 (So, 21 Feb 2010) $
Version:   $Revision: 16010 $

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include "mitkNavigationDataReferenceTransformFilter.h"
#include "mitkNavigationData.h"

#include "mitkTestingMacros.h"

#include <iostream>


/**Documentation
 *  test for the class "NavigationDataReferenceTransformFilter".
 */
int mitkNavigationDataReferenceTransformFilterTest(int /* argc */, char* /*argv*/[])
{

  MITK_TEST_BEGIN("NavigationDataReferenceTransformFilter")

  // let's create an object of our class  
  mitk::NavigationDataReferenceTransformFilter::Pointer myFilter = mitk::NavigationDataReferenceTransformFilter::New();
  
  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myFilter.IsNotNull(),"Testing instantiation");



  /*create helper objects: positions of the input sources*/
  mitk::NavigationData::PositionType initialPos1,initialPos2, initialPos3, initialPos4;
  mitk::FillVector3D(initialPos1, 11.1, 11.1, 11.1);
  mitk::FillVector3D(initialPos2, 22.2, 22.2, 22.2);
  mitk::FillVector3D(initialPos3, 33.3, 33.3, 33.3);
  mitk::FillVector3D(initialPos4, 44.4, 44.4, 44.4);

  /*create helper objects: orientations of the input sources*/
  mitk::NavigationData::OrientationType initialOri1(0.1, 0.1, 0.1, 0.1);
  mitk::NavigationData::OrientationType initialOri2(0.2, 0.2, 0.2, 0.2);
  mitk::NavigationData::OrientationType initialOri3(0.3, 0.3, 0.3, 0.3);
  mitk::NavigationData::OrientationType initialOri4(0.4, 0.4, 0.4, 0.4);
  
  /*create helper objects: ND position accurancy and validity bool*/
  mitk::ScalarType initialError(0.0);
  bool initialValid(true);

  /*create helper objects: NDs for the inputs*/
  mitk::NavigationData::Pointer nd1 = mitk::NavigationData::New();
  nd1->SetPosition(initialPos1);
  nd1->SetOrientation(initialOri1);
  nd1->SetPositionAccuracy(initialError);
  nd1->SetDataValid(initialValid);

  mitk::NavigationData::Pointer nd2 = mitk::NavigationData::New();
  nd2->SetPosition(initialPos2);
  nd2->SetOrientation(initialOri2);
  nd2->SetPositionAccuracy(initialError);
  nd2->SetDataValid(initialValid);

  mitk::NavigationData::Pointer nd3 = mitk::NavigationData::New();
  nd3->SetPosition(initialPos3);
  nd3->SetOrientation(initialOri3);
  nd3->SetPositionAccuracy(initialError);
  nd3->SetDataValid(initialValid);

  mitk::NavigationData::Pointer nd4 = mitk::NavigationData::New();
  nd4->SetPosition(initialPos4);
  nd4->SetOrientation(initialOri4);
  nd4->SetPositionAccuracy(initialError);
  nd4->SetDataValid(initialValid);

  /*  testing input setter */
  myFilter->SetInput(0,nd1);
  MITK_TEST_CONDITION(myFilter->GetInput(0) == nd1, "Testing Set-/GetInput() ND1");
  myFilter->SetInput(1,nd2);
  MITK_TEST_CONDITION(myFilter->GetInput(1) == nd2, "Testing Set-/GetInput() ND1");
  myFilter->SetInput(2,nd3);
  MITK_TEST_CONDITION(myFilter->GetInput(2) == nd3, "Testing Set-/GetInput() ND1");
  myFilter->SetInput(3,nd4);
  MITK_TEST_CONDITION(myFilter->GetInput(3) == nd4, "Testing Set-/GetInput() ND1");
  


  /* testing output getter */
  mitk::NavigationData* output1 = myFilter->GetOutput(0);
  MITK_TEST_CONDITION_REQUIRED(output1 != NULL, "Testing GetOutput() ND1");
  
  mitk::NavigationData* output2 = myFilter->GetOutput(1);
  MITK_TEST_CONDITION_REQUIRED(output2 != NULL, "Testing GetOutput() ND2");
 
  mitk::NavigationData* output3 = myFilter->GetOutput(2);
  MITK_TEST_CONDITION_REQUIRED(output3 != NULL, "Testing GetOutput() ND3");
 
  mitk::NavigationData* output4 = myFilter->GetOutput(3);
  MITK_TEST_CONDITION_REQUIRED(output4 != NULL, "Testing GetOutput() ND4");
 
  

  /* testing IsInitialized() before setting/generating any points */
  MITK_TEST_CONDITION_REQUIRED(myFilter->IsInitialized() == false, "Testing IsInitialized() before setting source points");

  /* trying to generate source landmarks with empty referenceID vector */
  myFilter->GenerateSourceLandmarks();
  
  /* create helper objects: reference input IDs vector */
  std::vector<int>* refIDs = new std::vector<int>();

  unsigned int refInpt = 0;

  refIDs->push_back(refInpt);

  myFilter->SetReferenceInputIndexes(refIDs);

  MITK_TEST_CONDITION_REQUIRED(myFilter->GetOneSourceRegistration() == true,"Testing switch from OneSourceRegistration false to true" );

  MITK_TEST_CONDITION(myFilter->GetReferenceInputIndexes().at(0) == refInpt, "Testing single value of ReferenceInputIndexes");
  MITK_TEST_CONDITION_REQUIRED(myFilter->GetReferenceInputIndexes().size()==1, "Testing size of ReferenceInputIndexes");

  myFilter->GenerateSourceLandmarks();

  MITK_TEST_CONDITION(myFilter->GetSourcePoints().size()==3 && myFilter->GetTargetPoints().size()==0, "Testing different SourcePoints and TargePoints sizes");

  /* testing IsInitialized() before setting target points */
  MITK_TEST_CONDITION_REQUIRED(myFilter->IsInitialized() == false, "Testing IsInitialized() before setting target points");
<commit_msg>FIX (#4943): changed unsined int - int comparision<commit_after>/*=========================================================================

Program:   Medical Imaging & Interaction Toolkit
Language:  C++
Date:      $Date: 2010-02-21 19:34:02 +0100 (So, 21 Feb 2010) $
Version:   $Revision: 16010 $

Copyright (c) German Cancer Research Center, Division of Medical and
Biological Informatics. All rights reserved.
See MITKCopyright.txt or http://www.mitk.org/copyright.html for details.

This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

#include "mitkNavigationDataReferenceTransformFilter.h"
#include "mitkNavigationData.h"

#include "mitkTestingMacros.h"

#include <iostream>


/**Documentation
 *  test for the class "NavigationDataReferenceTransformFilter".
 */
int mitkNavigationDataReferenceTransformFilterTest(int /* argc */, char* /*argv*/[])
{

  MITK_TEST_BEGIN("NavigationDataReferenceTransformFilter")

  // let's create an object of our class  
  mitk::NavigationDataReferenceTransformFilter::Pointer myFilter = mitk::NavigationDataReferenceTransformFilter::New();
  
  // first test: did this work?
  // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
  // it makes no sense to continue without an object.
  MITK_TEST_CONDITION_REQUIRED(myFilter.IsNotNull(),"Testing instantiation");



  /*create helper objects: positions of the input sources*/
  mitk::NavigationData::PositionType initialPos1,initialPos2, initialPos3, initialPos4;
  mitk::FillVector3D(initialPos1, 11.1, 11.1, 11.1);
  mitk::FillVector3D(initialPos2, 22.2, 22.2, 22.2);
  mitk::FillVector3D(initialPos3, 33.3, 33.3, 33.3);
  mitk::FillVector3D(initialPos4, 44.4, 44.4, 44.4);

  /*create helper objects: orientations of the input sources*/
  mitk::NavigationData::OrientationType initialOri1(0.1, 0.1, 0.1, 0.1);
  mitk::NavigationData::OrientationType initialOri2(0.2, 0.2, 0.2, 0.2);
  mitk::NavigationData::OrientationType initialOri3(0.3, 0.3, 0.3, 0.3);
  mitk::NavigationData::OrientationType initialOri4(0.4, 0.4, 0.4, 0.4);
  
  /*create helper objects: ND position accurancy and validity bool*/
  mitk::ScalarType initialError(0.0);
  bool initialValid(true);

  /*create helper objects: NDs for the inputs*/
  mitk::NavigationData::Pointer nd1 = mitk::NavigationData::New();
  nd1->SetPosition(initialPos1);
  nd1->SetOrientation(initialOri1);
  nd1->SetPositionAccuracy(initialError);
  nd1->SetDataValid(initialValid);

  mitk::NavigationData::Pointer nd2 = mitk::NavigationData::New();
  nd2->SetPosition(initialPos2);
  nd2->SetOrientation(initialOri2);
  nd2->SetPositionAccuracy(initialError);
  nd2->SetDataValid(initialValid);

  mitk::NavigationData::Pointer nd3 = mitk::NavigationData::New();
  nd3->SetPosition(initialPos3);
  nd3->SetOrientation(initialOri3);
  nd3->SetPositionAccuracy(initialError);
  nd3->SetDataValid(initialValid);

  mitk::NavigationData::Pointer nd4 = mitk::NavigationData::New();
  nd4->SetPosition(initialPos4);
  nd4->SetOrientation(initialOri4);
  nd4->SetPositionAccuracy(initialError);
  nd4->SetDataValid(initialValid);

  /*  testing input setter */
  myFilter->SetInput(0,nd1);
  MITK_TEST_CONDITION(myFilter->GetInput(0) == nd1, "Testing Set-/GetInput() ND1");
  myFilter->SetInput(1,nd2);
  MITK_TEST_CONDITION(myFilter->GetInput(1) == nd2, "Testing Set-/GetInput() ND1");
  myFilter->SetInput(2,nd3);
  MITK_TEST_CONDITION(myFilter->GetInput(2) == nd3, "Testing Set-/GetInput() ND1");
  myFilter->SetInput(3,nd4);
  MITK_TEST_CONDITION(myFilter->GetInput(3) == nd4, "Testing Set-/GetInput() ND1");
  


  /* testing output getter */
  mitk::NavigationData* output1 = myFilter->GetOutput(0);
  MITK_TEST_CONDITION_REQUIRED(output1 != NULL, "Testing GetOutput() ND1");
  
  mitk::NavigationData* output2 = myFilter->GetOutput(1);
  MITK_TEST_CONDITION_REQUIRED(output2 != NULL, "Testing GetOutput() ND2");
 
  mitk::NavigationData* output3 = myFilter->GetOutput(2);
  MITK_TEST_CONDITION_REQUIRED(output3 != NULL, "Testing GetOutput() ND3");
 
  mitk::NavigationData* output4 = myFilter->GetOutput(3);
  MITK_TEST_CONDITION_REQUIRED(output4 != NULL, "Testing GetOutput() ND4");
 
  

  /* testing IsInitialized() before setting/generating any points */
  MITK_TEST_CONDITION_REQUIRED(myFilter->IsInitialized() == false, "Testing IsInitialized() before setting source points");

  /* trying to generate source landmarks with empty referenceID vector */
  myFilter->GenerateSourceLandmarks();
  
  /* create helper objects: reference input IDs vector */
  std::vector<int>* refIDs = new std::vector<int>();

  int refInpt = 0;

  refIDs->push_back(refInpt);

  myFilter->SetReferenceInputIndexes(refIDs);

  MITK_TEST_CONDITION_REQUIRED(myFilter->GetOneSourceRegistration() == true,"Testing switch from OneSourceRegistration false to true" );

  MITK_TEST_CONDITION(myFilter->GetReferenceInputIndexes().at(0) == refInpt, "Testing single value of ReferenceInputIndexes");
  MITK_TEST_CONDITION_REQUIRED(myFilter->GetReferenceInputIndexes().size()==1, "Testing size of ReferenceInputIndexes");

  myFilter->GenerateSourceLandmarks();

  MITK_TEST_CONDITION(myFilter->GetSourcePoints().size()==3 && myFilter->GetTargetPoints().size()==0, "Testing different SourcePoints and TargePoints sizes");

  /* testing IsInitialized() before setting target points */
  MITK_TEST_CONDITION_REQUIRED(myFilter->IsInitialized() == false, "Testing IsInitialized() before setting target points");

{'fraction_non_alphanumeric': 0.15213932107496464, 'fraction_numerical': 0.03288543140028288, 'mean_word_length': 6.160126582278481, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2371278', 'n_tokens_mistral': 3715, 'n_tokens_neox': 3483, 'n_words': 753}