0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model
[occt.git] / src / Image / Image_Color.hxx
index ace24c0..fa2184f 100644 (file)
@@ -1,21 +1,17 @@
 // Created on: 2012-07-18
 // Created by: Kirill GAVRILOV
-// Copyright (c) 2012 OPEN CASCADE SAS
+// Copyright (c) 2012-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #ifndef _Image_Color_H__
 #define _Image_Color_H__
@@ -270,6 +266,31 @@ public:
 
 };
 
+//! POD structure for packed float RG color value (2 floats)
+struct Image_ColorRGF
+{
+  //! Component type.
+  typedef Standard_ShortReal ComponentType_t;
+
+  //! Returns the number of components.
+  static Standard_Integer Length() { return 2; }
+
+  //! Alias to 1st component (red intensity).
+  Standard_ShortReal r() const { return v[0]; }
+
+  //! Alias to 2nd component (green intensity).
+  Standard_ShortReal g() const { return v[1]; }
+
+  //! Alias to 1st component (red intensity).
+  Standard_ShortReal& r() { return v[0]; }
+
+  //! Alias to 2nd component (green intensity).
+  Standard_ShortReal& g() { return v[1]; }
+
+public:
+  Standard_ShortReal v[2];
+};
+
 //! POD structure for packed float RGB color value (3 floats)
 struct Image_ColorRGBF
 {
@@ -430,144 +451,4 @@ public:
 
 };
 
-//! Addition operator
-template<typename ColorType_t>
-inline ColorType_t Image_ColorSumm3 (const ColorType_t& theA, const ColorType_t& theB)
-{
-  ColorType_t aRes = {{typename ColorType_t::ComponentType_t (theA.v[0] + theB.v[0]),
-                       typename ColorType_t::ComponentType_t (theA.v[1] + theB.v[1]),
-                       typename ColorType_t::ComponentType_t (theA.v[2] + theB.v[2])}};
-  return aRes;
-}
-
-inline Image_ColorRGB operator+ (const Image_ColorRGB& theA, const Image_ColorRGB& theB)
-{
-  return Image_ColorSumm3 (theA, theB);
-}
-
-inline Image_ColorBGR operator+ (const Image_ColorBGR& theA, const Image_ColorBGR& theB)
-{
-  return Image_ColorSumm3 (theA, theB);
-}
-
-inline Image_ColorRGBF operator+ (const Image_ColorRGBF& theA, const Image_ColorRGBF& theB)
-{
-  return Image_ColorSumm3 (theA, theB);
-}
-
-inline Image_ColorBGRF operator+ (const Image_ColorBGRF& theA, const Image_ColorBGRF& theB)
-{
-  return Image_ColorSumm3 (theA, theB);
-}
-
-template<typename ColorType_t>
-inline ColorType_t Image_ColorSumm4 (const ColorType_t& theA, const ColorType_t& theB)
-{
-  ColorType_t aRes = {{typename ColorType_t::ComponentType_t (theA.v[0] + theB.v[0]),
-                       typename ColorType_t::ComponentType_t (theA.v[1] + theB.v[1]),
-                       typename ColorType_t::ComponentType_t (theA.v[2] + theB.v[2]),
-                       typename ColorType_t::ComponentType_t (theA.v[3] + theB.v[3])}};
-  return aRes;
-}
-
-inline Image_ColorRGBA operator+ (const Image_ColorRGBA& theA, const Image_ColorRGBA& theB)
-{
-  return Image_ColorSumm4 (theA, theB);
-}
-
-inline Image_ColorBGRA operator+ (const Image_ColorBGRA& theA, const Image_ColorBGRA& theB)
-{
-  return Image_ColorSumm4 (theA, theB);
-}
-
-inline Image_ColorRGB32 operator+ (const Image_ColorRGB32& theA, const Image_ColorRGB32& theB)
-{
-  return Image_ColorSumm4 (theA, theB);
-}
-
-inline Image_ColorBGR32 operator+ (const Image_ColorBGR32& theA, const Image_ColorBGR32& theB)
-{
-  return Image_ColorSumm4 (theA, theB);
-}
-
-inline Image_ColorRGBAF operator+ (const Image_ColorRGBAF& theA, const Image_ColorRGBAF& theB)
-{
-  return Image_ColorSumm4 (theA, theB);
-}
-
-inline Image_ColorBGRAF operator+ (const Image_ColorBGRAF& theA, const Image_ColorBGRAF& theB)
-{
-  return Image_ColorSumm4 (theA, theB);
-}
-
-//! Subtraction operator
-template<typename ColorType_t>
-inline ColorType_t Image_ColorSub3 (const ColorType_t& theA, const ColorType_t& theB)
-{
-  ColorType_t aRes = {{typename ColorType_t::ComponentType_t (theA.v[0] - theB.v[0]),
-                       typename ColorType_t::ComponentType_t (theA.v[1] - theB.v[1]),
-                       typename ColorType_t::ComponentType_t (theA.v[2] - theB.v[2])}};
-  return aRes;
-}
-
-inline Image_ColorRGB operator- (const Image_ColorRGB& theA, const Image_ColorRGB& theB)
-{
-  return Image_ColorSub3 (theA, theB);
-}
-
-inline Image_ColorBGR operator- (const Image_ColorBGR& theA, const Image_ColorBGR& theB)
-{
-  return Image_ColorSub3 (theA, theB);
-}
-
-inline Image_ColorRGBF operator- (const Image_ColorRGBF& theA, const Image_ColorRGBF& theB)
-{
-  return Image_ColorSub3 (theA, theB);
-}
-
-inline Image_ColorBGRF operator- (const Image_ColorBGRF& theA, const Image_ColorBGRF& theB)
-{
-  return Image_ColorSub3 (theA, theB);
-}
-
-template<typename ColorType_t>
-inline ColorType_t Image_ColorSub4 (const ColorType_t& theA, const ColorType_t& theB)
-{
-  ColorType_t aRes = {{typename ColorType_t::ComponentType_t (theA.v[0] - theB.v[0]),
-                       typename ColorType_t::ComponentType_t (theA.v[1] - theB.v[1]),
-                       typename ColorType_t::ComponentType_t (theA.v[2] - theB.v[2]),
-                       typename ColorType_t::ComponentType_t (theA.v[3] - theB.v[3])}};
-  return aRes;
-}
-
-inline Image_ColorRGBA operator- (const Image_ColorRGBA& theA, const Image_ColorRGBA& theB)
-{
-  return Image_ColorSub4 (theA, theB);
-}
-
-inline Image_ColorBGRA operator- (const Image_ColorBGRA& theA, const Image_ColorBGRA& theB)
-{
-  return Image_ColorSub4 (theA, theB);
-}
-
-inline Image_ColorRGB32 operator- (const Image_ColorRGB32& theA, const Image_ColorRGB32& theB)
-{
-  return Image_ColorSub4 (theA, theB);
-}
-
-inline Image_ColorBGR32 operator- (const Image_ColorBGR32& theA, const Image_ColorBGR32& theB)
-{
-  return Image_ColorSub4 (theA, theB);
-}
-
-inline Image_ColorRGBAF operator- (const Image_ColorRGBAF& theA, const Image_ColorRGBAF& theB)
-{
-  return Image_ColorSub4 (theA, theB);
-}
-
-inline Image_ColorBGRAF operator- (const Image_ColorBGRAF& theA, const Image_ColorBGRAF& theB)
-{
-  return Image_ColorSub4 (theA, theB);
-}
-
 #endif // _Image_Color_H__