1 #ifndef color_xyy_convert_xyz
2 #define color_xyy_convert_xyz
3 
4 #include "../../_internal/convert.hpp"
5 
6 #include "../category.hpp"
7 
8 
9 #include "../../xyz/xyz.hpp"
10 
11 #include "../../_internal/normalize.hpp"
12 #include "../../_internal/diverse.hpp"
13 
14 
15 
16 namespace color
17  {
18   namespace _internal
19    {
20 
21     template
22      <
23        typename xyy_tag_name
24       ,typename xyz_tag_name
25      >
26      struct convert
27       <
28         ::color::category::xyy<  xyy_tag_name >
29        ,::color::category::xyz<  xyz_tag_name >
30       >
31       {
32        public:
33          typedef ::color::category::xyy< xyy_tag_name >    xyy_category_type, category_left_type;
34          typedef ::color::category::xyz< xyz_tag_name >    xyz_category_type, category_right_type;
35 
36          typedef typename ::color::trait::scalar<category_left_type>                scalar_trait_type;
37          typedef typename ::color::trait::scalar<category_left_type>::instance_type scalar_type;
38 
39          typedef  ::color::category::xyy< scalar_type >  xyySCALAR_category_type;
40          typedef  ::color::category::xyz< scalar_type >  xyzSCALAR_category_type;
41 
42          typedef ::color::model< xyy_category_type >  xyy_model_type;
43          typedef ::color::model< xyz_category_type >  xyz_model_type;
44 
45          typedef ::color::trait::container<category_left_type>     container_left_trait_type;
46          typedef ::color::trait::container<category_right_type>    container_right_trait_type;
47 
48          typedef typename container_left_trait_type::input_type         container_left_input_type;
49          typedef typename container_right_trait_type::model_type  container_right_const_input_type;
50 
51          typedef ::color::_internal::reformat< xyy_category_type, xyySCALAR_category_type >     reformatXYY_type;
52          typedef ::color::_internal::reformat< xyzSCALAR_category_type, xyz_category_type >     reformatXYZ_type;
53 
54          typedef ::color::constant::xyz::illuminant::point< scalar_type, ::color::constant::xyz::illuminant::D65_entity, ::color::constant::xyz::illuminant::two_entity  > white_point_type;
55 
processcolor::_internal::convert56          static void process
57           (
58             container_left_input_type         left
59            ,container_right_const_input_type  right
60           )
61           {
62            scalar_type x = reformatXYZ_type::template process<0,0>( container_right_trait_type::template get<0>( right ) );
63            scalar_type y = reformatXYZ_type::template process<1,1>( container_right_trait_type::template get<1>( right ) );
64            scalar_type z = reformatXYZ_type::template process<2,2>( container_right_trait_type::template get<2>( right ) );
65 
66            scalar_type s = x + y + z;
67 
68                  scalar_type small_x = 0;
69                  scalar_type small_y = 0;
70            const scalar_type big_Y   = y;
71 
72            if( false == scalar_trait_type::is_small( s ) )
73             {
74              small_x = x / s;
75              small_y = y / s;
76             }
77 
78            container_left_trait_type::template set<0>( left, reformatXYY_type::template process< 0, 0>( small_x ) );
79            container_left_trait_type::template set<1>( left, reformatXYY_type::template process< 1, 1>( small_y ) );
80            container_left_trait_type::template set<2>( left, reformatXYY_type::template process< 2, 2>( big_Y   ) );
81           }
82 
83 
84         };
85 
86    }
87  }
88 
89 #endif
90