Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:34

0001 // Copyright (c) 2019 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _XCAFDoc_VisMaterialCommon_HeaderFile
0015 #define _XCAFDoc_VisMaterialCommon_HeaderFile
0016 
0017 #include <Graphic3d_Vec.hxx>
0018 #include <Image_Texture.hxx>
0019 #include <Quantity_ColorRGBA.hxx>
0020 #include <Standard_Dump.hxx>
0021 
0022 class Graphic3d_Aspects;
0023 class Graphic3d_MaterialAspect;
0024 
0025 //! Common (obsolete) material definition.
0026 struct XCAFDoc_VisMaterialCommon
0027 {
0028   Handle(Image_Texture)   DiffuseTexture;  //!< image defining diffuse color
0029   Quantity_Color          AmbientColor;    //!< ambient  color
0030   Quantity_Color          DiffuseColor;    //!< diffuse  color
0031   Quantity_Color          SpecularColor;   //!< specular color
0032   Quantity_Color          EmissiveColor;   //!< emission color
0033   Standard_ShortReal      Shininess;       //!< shininess value
0034   Standard_ShortReal      Transparency;    //!< transparency value within [0, 1] range with 0 meaning opaque
0035   Standard_Boolean        IsDefined;       //!< defined flag; TRUE by default
0036 
0037   //! Empty constructor.
0038   XCAFDoc_VisMaterialCommon()
0039   : AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
0040     DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
0041     SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
0042     EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
0043     Shininess (1.0f),
0044     Transparency (0.0f),
0045     IsDefined (Standard_True) {}
0046 
0047   //! Compare two materials.
0048   Standard_Boolean IsEqual (const XCAFDoc_VisMaterialCommon& theOther) const
0049   {
0050     if (&theOther == this)
0051     {
0052       return true;
0053     }
0054     else if (theOther.IsDefined != IsDefined)
0055     {
0056       return false;
0057     }
0058     else if (!IsDefined)
0059     {
0060       return true;
0061     }
0062 
0063     return theOther.DiffuseTexture  == DiffuseTexture
0064         && theOther.AmbientColor    == AmbientColor
0065         && theOther.DiffuseColor    == DiffuseColor
0066         && theOther.SpecularColor   == SpecularColor
0067         && theOther.EmissiveColor   == EmissiveColor
0068         && theOther.Shininess       == Shininess
0069         && theOther.Transparency    == Transparency;
0070   }
0071 
0072   //! Dumps the content of me into the stream
0073   void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const
0074   {
0075     OCCT_DUMP_CLASS_BEGIN (theOStream, XCAFDoc_VisMaterialCommon)
0076 
0077     OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, DiffuseTexture.get())
0078 
0079     OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &AmbientColor)
0080     OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &DiffuseColor)
0081     OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &SpecularColor)
0082     OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &EmissiveColor)
0083 
0084     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Shininess)
0085     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, Transparency)
0086     OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, IsDefined)
0087   }
0088 }; 
0089 
0090 #endif // _XCAFDoc_VisMaterialCommon_HeaderFile