Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-18 09:22:26

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 <NCollection_Vec2.hxx>
0018 
0019 #include <Standard_TypeDef.hxx>
0020 
0021 #include <NCollection_Vec3.hxx>
0022 
0023 #include <NCollection_Vec4.hxx>
0024 
0025 #include <NCollection_Mat4.hxx>
0026 #include <Image_Texture.hxx>
0027 #include <Quantity_ColorRGBA.hxx>
0028 #include <Standard_Dump.hxx>
0029 
0030 class Graphic3d_Aspects;
0031 class Graphic3d_MaterialAspect;
0032 
0033 //! Common (obsolete) material definition.
0034 struct XCAFDoc_VisMaterialCommon
0035 {
0036   occ::handle<Image_Texture> DiffuseTexture; //!< image defining diffuse color
0037   Quantity_Color             AmbientColor;   //!< ambient  color
0038   Quantity_Color             DiffuseColor;   //!< diffuse  color
0039   Quantity_Color             SpecularColor;  //!< specular color
0040   Quantity_Color             EmissiveColor;  //!< emission color
0041   float                      Shininess;      //!< shininess value
0042                                              // clang-format off
0043   float      Transparency;    //!< transparency value within [0, 1] range with 0 meaning opaque
0044                                              // clang-format on
0045   bool IsDefined;                            //!< defined flag; TRUE by default
0046 
0047   //! Empty constructor.
0048   XCAFDoc_VisMaterialCommon()
0049       : AmbientColor(0.1, 0.1, 0.1, Quantity_TOC_RGB),
0050         DiffuseColor(0.8, 0.8, 0.8, Quantity_TOC_RGB),
0051         SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
0052         EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
0053         Shininess(1.0f),
0054         Transparency(0.0f),
0055         IsDefined(true)
0056   {
0057   }
0058 
0059   //! Compare two materials.
0060   bool IsEqual(const XCAFDoc_VisMaterialCommon& theOther) const
0061   {
0062     if (&theOther == this)
0063     {
0064       return true;
0065     }
0066     else if (theOther.IsDefined != IsDefined)
0067     {
0068       return false;
0069     }
0070     else if (!IsDefined)
0071     {
0072       return true;
0073     }
0074 
0075     return theOther.DiffuseTexture == DiffuseTexture && theOther.AmbientColor == AmbientColor
0076            && theOther.DiffuseColor == DiffuseColor && theOther.SpecularColor == SpecularColor
0077            && theOther.EmissiveColor == EmissiveColor && theOther.Shininess == Shininess
0078            && theOther.Transparency == Transparency;
0079   }
0080 
0081   //! Dumps the content of me into the stream
0082   void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const
0083   {
0084     OCCT_DUMP_CLASS_BEGIN(theOStream, XCAFDoc_VisMaterialCommon)
0085 
0086     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, DiffuseTexture.get())
0087 
0088     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &AmbientColor)
0089     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &DiffuseColor)
0090     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &SpecularColor)
0091     OCCT_DUMP_FIELD_VALUES_DUMPED(theOStream, theDepth, &EmissiveColor)
0092 
0093     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Shininess)
0094     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, Transparency)
0095     OCCT_DUMP_FIELD_VALUE_NUMERICAL(theOStream, IsDefined)
0096   }
0097 };
0098 
0099 #endif // _XCAFDoc_VisMaterialCommon_HeaderFile