col3.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #pragma once
  17. #include "math.h"
  18. namespace embree
  19. {
  20. ////////////////////////////////////////////////////////////////////////////////
  21. /// RGB Color Class
  22. ////////////////////////////////////////////////////////////////////////////////
  23. template<typename T> struct Col3
  24. {
  25. T r, g, b;
  26. ////////////////////////////////////////////////////////////////////////////////
  27. /// Construction
  28. ////////////////////////////////////////////////////////////////////////////////
  29. __forceinline Col3 ( ) { }
  30. __forceinline Col3 ( const Col3& other ) { r = other.r; g = other.g; b = other.b; }
  31. __forceinline Col3& operator=( const Col3& other ) { r = other.r; g = other.g; b = other.b; return *this; }
  32. __forceinline explicit Col3 (const T& v) : r(v), g(v), b(v) {}
  33. __forceinline Col3 (const T& r, const T& g, const T& b) : r(r), g(g), b(b) {}
  34. ////////////////////////////////////////////////////////////////////////////////
  35. /// Constants
  36. ////////////////////////////////////////////////////////////////////////////////
  37. __forceinline Col3 (ZeroTy) : r(zero) , g(zero) , b(zero) {}
  38. __forceinline Col3 (OneTy) : r(one) , g(one) , b(one) {}
  39. __forceinline Col3 (PosInfTy) : r(pos_inf), g(pos_inf), b(pos_inf) {}
  40. __forceinline Col3 (NegInfTy) : r(neg_inf), g(neg_inf), b(neg_inf) {}
  41. };
  42. /*! output operator */
  43. template<typename T> inline std::ostream& operator<<(std::ostream& cout, const Col3<T>& a) {
  44. return cout << "(" << a.r << ", " << a.g << ", " << a.b << ")";
  45. }
  46. /*! default template instantiations */
  47. typedef Col3<unsigned char> Col3uc;
  48. typedef Col3<float > Col3f;
  49. }