]> SALOME platform Git repositories - modules/geom.git/blobdiff - src/Material/Material_Model.cxx
Salome HOME
Fix for '#18490 GEOM build fail with master branch' issue.
[modules/geom.git] / src / Material / Material_Model.cxx
index 3f95c135a7630b6dab2eb0e71be3670d4dbcf458..5ab3d6e35f7ad8903a90d0af665abfc03d3faced 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,6 +27,8 @@
 
 #include <QMutexLocker>
 
+#include <Basics_OCCTVersion.hxx>
+
 /*!
   \brief Constructor
 
@@ -557,6 +559,14 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
   QColor c;
   
   // ambient reflection
+#if OCC_VERSION_LARGE >= 0x07040000
+  if ( color( Ambient ).isValid() ) {
+    c = color( Ambient );
+    aspect.SetAmbientColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Ambient, theIsFront ) ) );
+  }
+  if ( !hasReflection( Ambient ) )
+    aspect.SetAmbientColor( Quantity_NOC_BLACK );
+#else
   if ( color( Ambient ).isValid() ) {
     c = color( Ambient );
     aspect.SetAmbientColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@@ -566,8 +576,17 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
     aspect.SetReflectionModeOn( Graphic3d_TOR_AMBIENT );
   else
     aspect.SetReflectionModeOff( Graphic3d_TOR_AMBIENT );
+#endif
   
   // diffuse reflection
+#if OCC_VERSION_LARGE >= 0x07040000
+  if ( color( Diffuse ).isValid() ) {
+    c = color( Diffuse );
+    aspect.SetDiffuseColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Diffuse, theIsFront ) ) );
+  }
+  if ( !hasReflection( Diffuse ) )
+    aspect.SetDiffuseColor( Quantity_NOC_BLACK );
+#else
   if ( color( Diffuse ).isValid() ) {
     c = color( Diffuse );
     aspect.SetDiffuseColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@@ -577,8 +596,17 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
     aspect.SetReflectionModeOn( Graphic3d_TOR_DIFFUSE );
   else
     aspect.SetReflectionModeOff( Graphic3d_TOR_DIFFUSE );
+#endif
 
   // specular reflection
+#if OCC_VERSION_LARGE >= 0x07040000
+  if ( color( Specular ).isValid() ) {
+    c = color( Specular );
+    aspect.SetSpecularColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Specular, theIsFront ) ) );
+  }
+  if ( !hasReflection( Specular ) )
+    aspect.SetSpecularColor( Quantity_NOC_BLACK );
+#else
   if ( color( Specular ).isValid() ) {
     c = color( Specular );
     aspect.SetSpecularColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@@ -588,8 +616,17 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
     aspect.SetReflectionModeOn( Graphic3d_TOR_SPECULAR );
   else
     aspect.SetReflectionModeOff( Graphic3d_TOR_SPECULAR );
+#endif
 
   // emissive reflection
+#if OCC_VERSION_LARGE >= 0x07040000
+  if ( color( Emissive ).isValid() ) {
+    c = color( Emissive );
+    aspect.SetEmissiveColor( Quantity_Color( Graphic3d_Vec3( c.redF(), c.greenF(), c.blueF() ) * reflection( Emissive, theIsFront ) ) );
+  }
+  if ( !hasReflection( Emissive ) )
+    aspect.SetEmissiveColor( Quantity_NOC_BLACK );
+#else
   if ( color( Emissive ).isValid() ) {
     c = color( Emissive );
     aspect.SetEmissiveColor( Quantity_Color( c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB ) );
@@ -599,6 +636,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect( bool theIsFront )
     aspect.SetReflectionModeOn( Graphic3d_TOR_EMISSION );
   else
     aspect.SetReflectionModeOff( Graphic3d_TOR_EMISSION );
+#endif
   
   // shininess
   aspect.SetShininess( shininess( theIsFront ) );