Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

main.cpp 4.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#include <core/args.h>
#include <core/data.h>
#include <core/function.h>
#include <core/fitter.h>
#include <core/plugins_manager.h>

#include <QPluginLoader>
#include <QtPlugin>
#include <QCoreApplication>
#include <QDir>
#include <QTime>

#include <iostream>
#include <vector>
#include <iostream>
#include <fstream>
#include <limits>
#include <cstdlib>

20 21 22 23 24 25 26 27
#define EPSILON 1.0E-5

bool is_close(double x, double y)
{
	return std::abs(x - y) < EPSILON;
}

int parametrization_tests();
28 29 30 31 32 33 34 35 36 37 38 39

int main(int argc, char** argv)
{
	QCoreApplication app(argc, argv, false);
	arguments args(argc, argv) ;

	plugins_manager manager(args) ;

	int nb_tests_failed = 0;

	// Parametrization tests
	//
40
	nb_tests_failed += parametrization_tests();
41 42 43 44 45 46 47

	// Evaluation tests
	//

	std::cout << "<<INFO>> " << nb_tests_failed << " tests failed" << std::endl;


48 49 50 51 52 53 54 55
	return nb_tests_failed;
}

int parametrization_tests()
{
	// Params
	int nb_tests_failed = 0;

Laurent Belcour's avatar
Laurent Belcour committed
56 57 58 59 60 61 62 63 64 65

	// Test the rotation code
	vec x(3);
	x[0] = 0; x[1] = 0; x[2] = 1;
	params::rotate_binormal(&x[0], 0.5*M_PI);
	std::cout << "<<DEBUG>> x = " << x << std::endl;

	params::rotate_binormal(&x[0], -0.5*M_PI);
	std::cout << "<<DEBUG>> x = " << x << std::endl;
	std::cout << "<<DEBUG>> acos(x[2]) = " << acos(x[2]) << std::endl;
66 67
	
	// Test Rusinkevich parametrization
Laurent Belcour's avatar
Laurent Belcour committed
68
	vec cart(6), spherical(4);
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	vec rusi(3);

	// Equal directions test, when the PHI_D is ZERO
	rusi[0] = 0.25*M_PI; rusi[1] = 0.0; rusi[2] = 0.0;
	params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::CARTESIAN, &cart[0]);

	const double dot = cart[0]*cart[3] + cart[1]*cart[4] + cart[2]*cart[5];

	if(!is_close(cart[0], cart[3]) || !is_close(cart[1], cart[4]) ||
	   !is_close(cart[2], cart[5]) || !is_close(dot, 1.0))
	{
		std::cout << "<<DEBUG>> rusin 3d: " << rusi << std::endl;
		std::cout << "<<DEBUG>> cartesian: " << cart << std::endl;
		std::cout << "<<DEBUG>> dot: " << dot << std::endl;
		std::cout << std::endl;
		nb_tests_failed++;
	}


Laurent Belcour's avatar
Laurent Belcour committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101
	// Pathological case when THETA_H and THETA_D are equal to
	// PI/4 and PHI_D PI, the conversion seems to fail.
	rusi[0] = 0.759218; rusi[1] = 0.759218; rusi[2] = 3.14159;
	try
	{
		params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
		params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
	}
	catch(...)
	{
		std::cout << "<<ERROR>> the conversion failed" << std::endl;
		std::cout << "<<DEBUG>> rusin 3d: " << rusi << std::endl;
		std::cout << "<<DEBUG>> cartesian: " << spherical << std::endl;
		nb_tests_failed++;
102
    }
Laurent Belcour's avatar
Laurent Belcour committed
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120


	// Convert issue #1
	vec cart2(6);
	spherical[0] = 0; spherical[1] = 0; spherical[2] = 1.51844; spherical[3] = -2.96706;
	params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::CARTESIAN, &cart2[0]);
	try
	{
		params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
		params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
		params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::CARTESIAN, &cart[0]);
	}
	catch(...)
	{
		std::cout << "<<ERROR>> the conversion failed" << std::endl;
		std::cout << "<<DEBUG>> rusin 3d: " << rusi << std::endl;
		std::cout << "<<DEBUG>> spherical: " << spherical << std::endl;
		nb_tests_failed++;
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
    }



	/// Test on a known couple of directions
	/// in = [0, 0, 1] out = [1, 0, 0]

	// Convert from Cartesian to spherical
	cart[0] = 0; cart[1] = 0; cart[2] = 1; 
	cart[3] = 1; cart[4] = 0; cart[5] = 0; 
    params::convert(&cart[0], params::CARTESIAN, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
	 std::cout << "From cartesian to spherical" << std::endl;
	 std::cout << spherical << std::endl << std::endl;
    
	 params::convert(&cart[0], params::CARTESIAN, params::RUSIN_TH_TD_PD, &rusi[0]);
	 std::cout << "From cartesian to rusi" << std::endl;
    std::cout << rusi << std::endl << std::endl;
    
	 params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::CARTESIAN, &cart[0]);
	 std::cout << "From rusi to cartesian" << std::endl;
    std::cout << cart << std::endl << std::endl;

    params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
	 std::cout << "From spherical to rusi" << std::endl;
    std::cout << rusi << std::endl << std::endl;

    params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::SPHERICAL_TL_PL_TV_PV, &spherical[0]);
	 std::cout << "From rusi to spherical" << std::endl;
    std::cout << spherical << std::endl << std::endl;

    params::convert(&rusi[0], params::RUSIN_TH_TD_PD, params::CARTESIAN, &cart[0]);
	 std::cout << "From rusi to cartesian" << std::endl;
    std::cout << cart << std::endl << std::endl;

    params::convert(&spherical[0], params::SPHERICAL_TL_PL_TV_PV, params::RUSIN_TH_TD_PD, &rusi[0]);
	 std::cout << "From spherical to rusi" << std::endl;
    std::cout << rusi << std::endl << std::endl;
Laurent Belcour's avatar
Laurent Belcour committed
158

159 160
	return nb_tests_failed;
}