// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#define BUC60565 //GG_19/10/99 ; Don't change the color components when the corresponding
-// coefficient is modified because the resulting color is computed in
-// low level driver.
-
-#define IMP150200 //GG : Add IsEqual() IsDifferent() methods.
-// Add NumberOfMaterials() MaterialName() class methods
-
-#define IMP171201 //GG : Add Add MaterialName() SetMaterialName() instance
-// methods in order to set or retrieve name of the current
-// material.
-// Capitalize all material name strings.
-// Thanks to Stephane ROUTELOUS.
-
-
-//-Version
-
-//-Design Declaration of variables specific to the definition
-// of materials
-
-//-Warning A material is defined by :
-// - coefficient of transparence
-// - coefficient of disperse reflection
-// - coefficient of ambiant reflection
-// - coefficient of specular reflection
-// - coefficient of emission
-
-// 2 properties permiting to define a material :
-// - transparence
-// - reflection, i.e. absorbtion properties
-// and light diffusion
-
-// Disperse reflection is considered a component
-// The specular reflection is considered a component
-// of the color of the light source
-
-// To determine 3 colors of reflection it is necessary :
-// - coefficient of disperse reflection
-// - coefficient of ambiant reflection
-// - coefficient of specular reflection
-
-// ( Under GL, 3 colors are determined)
-
-//-References Getting started with DEC PHIGS, annexe C
-// Iris Advanced Graphics, unite D
-
-//-Language C++ 2.0
-
-//-Declarations
-
-// for the class
#include <Graphic3d_MaterialAspect.ixx>
#include <Standard_Assert.hxx>
-//-Aliases
-
-//-Global data definitions
-
-// -- le coefficient de reflection diffuse, la couleur et l'activite
-// MyDiffuseCoef : Standard_ShortReal;
-// MyDiffuseColor : Color;
-// MyDiffuseActivity : Standard_Boolean;
-
-// -- le coefficient de reflection ambiante, la couleur et l'activite
-// MyAmbientCoef : Standard_ShortReal;
-// MyAmbientColor : Color;
-// MyAmbientActivity : Standard_Boolean;
-
-// -- le coefficient de reflection speculaire, la couleur et l'activite
-// MySpecularCoef : Standard_ShortReal;
-// MySpecularColor : Color;
-// MySpecularActivity : Standard_Boolean;
-
-// -- le coefficient d emission du materiau, la couleur et l'activite
-// MyEmissiveCoef : Standard_ShortReal;
-// MyEmissiveActivity : Standard_Boolean;
-
-// -- le coefficient de transparence
-// MyTransparencyCoef : Standard_ShortReal;
-
-// -- le coefficient de concentration lumineuse
-// MyShininess : Standard_ShortReal;
-
-//-Constructors
-
-//-Destructors
-
-//-Methods, in order
-
-Graphic3d_MaterialAspect::Graphic3d_MaterialAspect ()
-: MyAmbientColor(0.2, 0.2, 0.2, Quantity_TOC_RGB)
-{
-#ifdef IMP171201
- MyRequestedMaterialName = Graphic3d_NOM_DEFAULT;
- Init(MyRequestedMaterialName);
-#else
- Init(Graphic3d_NOM_DEFAULT);
-#endif
-}
-
-Graphic3d_MaterialAspect::Graphic3d_MaterialAspect (const Graphic3d_NameOfMaterial AName)
-: MyAmbientColor(0.2, 0.2, 0.2, Quantity_TOC_RGB)
-{
-#ifdef IMP171201
- MyRequestedMaterialName = AName;
- Init(MyRequestedMaterialName);
-#else
- Init(AName);
-#endif
-}
-
-void Graphic3d_MaterialAspect::Init(const Graphic3d_NameOfMaterial AName) {
-
- MyMaterialType = Graphic3d_MATERIAL_ASPECT;
- MyTransparencyCoef = Standard_ShortReal (0.0);
- MyDiffuseActivity = Standard_True;
- MyDiffuseCoef = Standard_ShortReal (0.65);
- MyAmbientActivity = Standard_True;
- MyAmbientCoef = Standard_ShortReal (0.3);
- MySpecularActivity = Standard_True;
- MySpecularCoef = Standard_ShortReal (0.0);
- MyEmissiveActivity = Standard_False;
- MyEmissiveCoef = Standard_ShortReal (0.0);
- MyEnvReflexion = Standard_ShortReal(0.0);
- MyShininess = Standard_ShortReal (0.039);
- MyDiffuseColor.SetValues (0.0, 0.0, 0.0, Quantity_TOC_RGB);
- MySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
- MyMaterialName = AName;
-#ifdef IMP171201
- Standard_Integer index = Standard_Integer(AName);
- if( index < NumberOfMaterials() ) {
- MyStringName = MaterialName(index+1);
- }
-#endif
-
- switch (AName) {
- case Graphic3d_NOM_PLASTIC : /* Blue plastic */
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.0078125);
- MyAmbientCoef = Standard_ShortReal (0.5);
- MyDiffuseCoef = Standard_ShortReal (0.24);
- MySpecularCoef = Standard_ShortReal (0.06);
- break;
-
- case Graphic3d_NOM_SHINY_PLASTIC : /* black plastic */
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (1.0);
- MyAmbientCoef = Standard_ShortReal (0.44);
- MyDiffuseCoef = Standard_ShortReal (0.5);
- MySpecularCoef = Standard_ShortReal (1.0);
- break;
-
- case Graphic3d_NOM_SATIN :
- MyShininess = Standard_ShortReal (0.09375);
- MyAmbientCoef = Standard_ShortReal (0.33);
- MyDiffuseCoef = Standard_ShortReal (0.4);
- MySpecularCoef = Standard_ShortReal (0.44);
- break;
-
- case Graphic3d_NOM_NEON_GNC:
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.05);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (0.62);
- MyEmissiveCoef = Standard_ShortReal (1.0);
- MyEmissiveActivity = Standard_True;
- MyAmbientActivity = Standard_False;
- break;
-
- case Graphic3d_NOM_METALIZED :
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.13);
- MyAmbientCoef = Standard_ShortReal (0.9);
- MyDiffuseCoef = Standard_ShortReal (0.47);
- MySpecularCoef = Standard_ShortReal (0.45);
- MyAmbientActivity = Standard_False;
-
- /* Color resulting from dispersed */
- //MyDiffuseColor.SetValues (0.87, 0.96, 1.0, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- //MySpecularColor.SetValues (0.93, 0.95, 0.78, Quantity_TOC_RGB);
- break;
-
-// Ascending Compatibility physical materials. The same definition is taken
-// as in the next constructor.
-
- case Graphic3d_NOM_BRASS :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Initialisation of coefficients and lighting color : brass */
- MyShininess = Standard_ShortReal (0.21794844);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.329412, 0.223529, 0.027451, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.780392, 0.568627, 0.113725, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.992157, 0.941176, 0.807843, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_BRONZE :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.2);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.2125, 0.1275, 0.054, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.714, 0.4284, 0.18144, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.393548, 0.271906, 0.166721, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_COPPER :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.93);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.33, 0.26, 0.23, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.50, 0.11, 0.0, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.95, 0.73, 0.0, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_GOLD :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.0625);
- MyAmbientCoef = Standard_ShortReal (0.3);
- MyDiffuseCoef = Standard_ShortReal (0.4);
- MySpecularCoef = Standard_ShortReal (0.9);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (1.0, 0.76862745, 0.31764706, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (1.0, 0.69, 0.0, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (1.0, 0.98, 0.78, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_PEWTER :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.076923047);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.105882, 0.058824, 0.113725, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.427451, 0.470588, 0.541176, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.333333, 0.333333, 0.521569, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_PLASTER :
-#ifdef BUG // The plaster material must be considered as Generic.
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.2);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-#else
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.0078125)
-;
- MyAmbientCoef = Standard_ShortReal (0.26);
- MyDiffuseCoef = Standard_ShortReal (0.23);
- MySpecularCoef = Standard_ShortReal (0.06);
-#endif
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.19225, 0.19225, 0.19225, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.50754, 0.50754, 0.50754, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.508273, 0.508273, 0.508273, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_SILVER :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.2);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.19225, 0.19225, 0.19225, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.50754, 0.50754, 0.50754, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.508273, 0.508273, 0.508273, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_STEEL :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.06);
- MyAmbientCoef = Standard_ShortReal (0.01);
- MyDiffuseCoef = Standard_ShortReal (0.03);
- MySpecularCoef = Standard_ShortReal (0.98);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_STONE :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.17);
- MyAmbientCoef = Standard_ShortReal (0.19);
- MyDiffuseCoef = Standard_ShortReal (0.75);
- MySpecularCoef = Standard_ShortReal (0.08);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (1.0, 0.8, 0.62, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (1.0, 0.8, 0.62, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.98, 1.0, 0.60, Quantity_TOC_RGB);
- break;
-
-// Ascending Compatibility of physical materials. Takes the same definition
-// as in the next constructor. New materials
-
- case Graphic3d_NOM_CHROME :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.1);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.35, 0.35, 0.35, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.4, 0.4, 0.4, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.974597, 0.974597, 0.974597, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_NEON_PHC:
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.05);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (0.62);
- MyEmissiveCoef = Standard_ShortReal (0.9);
- MyEmissiveActivity = Standard_True;
- MyAmbientActivity = Standard_False;
- MyDiffuseActivity = Standard_False;
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MyEmissiveColor.SetValues (0.0, 1.0, 0.46, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_ALUMINIUM :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.09);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.30, 0.30, 0.30, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.30, 0.30, 0.30, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.70, 0.70, 0.80, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_OBSIDIAN :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.3);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.05375, 0.05, 0.06625, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.18275, 0.17, 0.22525, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.332741, 0.328634, 0.346435, Quantity_TOC_RGB);
- break;
-
- case Graphic3d_NOM_JADE :
- MyMaterialType = Graphic3d_MATERIAL_PHYSIC;
- /* Lighting Coefficient */
- MyShininess = Standard_ShortReal (0.1);
- MyAmbientCoef = Standard_ShortReal (1.0);
- MyDiffuseCoef = Standard_ShortReal (1.0);
- MySpecularCoef = Standard_ShortReal (1.0);
-
- /* Color resulting from ambient */
- MyAmbientColor.SetValues (0.135, 0.2225, 0.1575, Quantity_TOC_RGB);
-
- /* Color resulting from dispersed */
- MyDiffuseColor.SetValues (0.54, 0.89, 0.63, Quantity_TOC_RGB);
-
- /* Color resulting from specular */
- MySpecularColor.SetValues (0.316228, 0.316228, 0.316228, Quantity_TOC_RGB);
- break;
- default:
-#ifdef IMP171201
- case Graphic3d_NOM_DEFAULT :
- MyStringName = "Default";
- break;
- case Graphic3d_NOM_UserDefined :
- MyStringName = "UserDefined";
-#endif
- break ;
- }
-}
-
-void Graphic3d_MaterialAspect::IncreaseShine (const Standard_Real ADelta) {
-
-Standard_ShortReal OldShine;
-
- OldShine = MyShininess;
- MyShininess = (Standard_ShortReal)(MyShininess + MyShininess * ADelta / 100.);
- if ( (MyShininess > 1.0) || (MyShininess < 0.0) ) {
- MyShininess = OldShine;
- }
-}
-
-/* Attribution of the type of material */
-void Graphic3d_MaterialAspect::SetMaterialType( const Graphic3d_TypeOfMaterial AType ) {
- MyMaterialType = AType ;
-#ifdef IMP171201
- if( AType != MyMaterialType )
- SetMaterialName("UserDefined");
-#endif
-}
-
-
-void Graphic3d_MaterialAspect::SetAmbient (const Standard_Real AValue) {
-
- if ((AValue < 0.0) || (AValue > 1.0))
- Graphic3d_MaterialDefinitionError::Raise
- ("Bad value for SetAmbient < 0. or > 1.0");
-
-
- MyAmbientCoef = Standard_ShortReal (AValue);
-#ifndef BUC60565
- Standard_Real R, G, B;
- MyAmbientColor.Values (R, G, B, Quantity_TOC_RGB);
- MyAmbientColor.SetValues
- (R*AValue, G*AValue, B*AValue, Quantity_TOC_RGB);
-#endif
-#ifdef IMP171201
- if( MyAmbientActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
-}
-
-void Graphic3d_MaterialAspect::SetColor (const Quantity_Color& AColor) {
-
- MyAmbientColor = AColor;
-#ifdef IMP171201
- if( MyAmbientActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
-}
-
-/* Attribution of color ambient lighting */
-void Graphic3d_MaterialAspect::SetAmbientColor (const Quantity_Color& AColor) {
-
- MyAmbientColor = AColor;
-#ifdef IMP171201
- if( MyAmbientActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
-}
-
-/* Attribution of color dispersed lighting */
-void Graphic3d_MaterialAspect::SetDiffuseColor (const Quantity_Color& AColor) {
-
- MyDiffuseColor = AColor;
-#ifdef IMP171201
- if( MyDiffuseActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
-}
-
-/* Attribution of color specular lighting */
-void Graphic3d_MaterialAspect::SetSpecularColor (const Quantity_Color& AColor) {
-
- MySpecularColor = AColor;
-#ifdef IMP171201
- if( MySpecularActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
-}
-/* Affectation couleur d emission */
-void Graphic3d_MaterialAspect::SetEmissiveColor (const Quantity_Color& AColor) {
+// =======================================================================
+// function : Graphic3d_MaterialAspect
+// purpose :
+// =======================================================================
+Graphic3d_MaterialAspect::Graphic3d_MaterialAspect()
+: myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB)
+{
+ myRequestedMaterialName = Graphic3d_NOM_DEFAULT;
+ Init (myRequestedMaterialName);
+}
- MyEmissiveColor = AColor;
-#ifdef IMP171201
- if( MyEmissiveActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
+// =======================================================================
+// function : Graphic3d_MaterialAspect
+// purpose :
+// =======================================================================
+Graphic3d_MaterialAspect::Graphic3d_MaterialAspect (const Graphic3d_NameOfMaterial theName)
+: myAmbientColor (0.2, 0.2, 0.2, Quantity_TOC_RGB)
+{
+ myRequestedMaterialName = theName;
+ Init (myRequestedMaterialName);
}
-void Graphic3d_MaterialAspect::SetDiffuse (const Standard_Real AValue) {
+// =======================================================================
+// function : Init
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::Init (const Graphic3d_NameOfMaterial theName)
+{
+ myMaterialType = Graphic3d_MATERIAL_ASPECT;
+ myTransparencyCoef = 0.0f;
+ myRefractionIndex = 1.0f;
+ myDiffuseActivity = Standard_True;
+ myDiffuseCoef = 0.65f;
+ myAmbientActivity = Standard_True;
+ myAmbientCoef = 0.3f;
+ mySpecularActivity = Standard_True;
+ mySpecularCoef = 0.0f;
+ myEmissiveActivity = Standard_False;
+ myEmissiveCoef = 0.0f;
+ myEnvReflexion = 0.0f;
+ myShininess = 0.039f;
+ myDiffuseColor .SetValues (0.0, 0.0, 0.0, Quantity_TOC_RGB);
+ mySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
+ myMaterialName = theName;
+
+ Standard_Integer index = Standard_Integer (theName);
+ if (index < NumberOfMaterials())
+ {
+ myStringName = MaterialName (index + 1);
+ }
- if ((AValue < 0.0) || (AValue > 1.0))
- Graphic3d_MaterialDefinitionError::Raise
- ("Bad value for SetDiffuse < 0. or > 1.0");
+ switch (theName)
+ {
+ case Graphic3d_NOM_PLASTIC: // Blue plastic
+ myShininess = Standard_ShortReal (0.0078125);
+ myAmbientCoef = Standard_ShortReal (0.5);
+ myDiffuseCoef = Standard_ShortReal (0.24);
+ mySpecularCoef = Standard_ShortReal (0.06);
+ break;
+ case Graphic3d_NOM_SHINY_PLASTIC: // black plastic
+ myShininess = Standard_ShortReal (1.0);
+ myAmbientCoef = Standard_ShortReal (0.44);
+ myDiffuseCoef = Standard_ShortReal (0.5);
+ mySpecularCoef = Standard_ShortReal (1.0);
+ break;
+ case Graphic3d_NOM_SATIN :
+ myShininess = Standard_ShortReal (0.09375);
+ myAmbientCoef = Standard_ShortReal (0.33);
+ myDiffuseCoef = Standard_ShortReal (0.4);
+ mySpecularCoef = Standard_ShortReal (0.44);
+ break;
+ case Graphic3d_NOM_NEON_GNC:
+ myShininess = Standard_ShortReal (0.05);
+ myAmbientCoef = Standard_ShortReal (1.0);
+ myDiffuseCoef = Standard_ShortReal (1.0);
+ mySpecularCoef = Standard_ShortReal (0.62);
+ myEmissiveCoef = Standard_ShortReal (1.0);
+ myEmissiveActivity = Standard_True;
+ myAmbientActivity = Standard_False;
+ break;
+ case Graphic3d_NOM_METALIZED:
+ myShininess = Standard_ShortReal (0.13);
+ myAmbientCoef = Standard_ShortReal (0.9);
+ myDiffuseCoef = Standard_ShortReal (0.47);
+ mySpecularCoef = Standard_ShortReal (0.45);
+ myAmbientActivity = Standard_False;
+
+ // Color resulting from dispersed
+ //myDiffuseColor .SetValues (0.87, 0.96, 1.0, Quantity_TOC_RGB);
+ // Color resulting from specular
+ //mySpecularColor.SetValues (0.93, 0.95, 0.78, Quantity_TOC_RGB);
+ break;
+ // Ascending Compatibility physical materials. The same definition is taken as in the next constructor.
+ case Graphic3d_NOM_BRASS:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.65f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.329f, 0.224f, 0.027f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.780f, 0.569f, 0.114f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.992f, 0.941f, 0.808f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_BRONZE:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.65f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.213f, 0.128f, 0.054f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.714f, 0.428f, 0.181f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.590f, 0.408f, 0.250f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_COPPER:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.65f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.191f, 0.074f, 0.023f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.604f, 0.270f, 0.083f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.950f, 0.640f, 0.540f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_GOLD:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.80f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.300f, 0.230f, 0.095f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.752f, 0.580f, 0.100f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (1.000f, 0.710f, 0.290f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_PEWTER:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.50f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.106f, 0.059f, 0.114f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.427f, 0.471f, 0.541f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.333f, 0.333f, 0.522f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_PLASTER:
+ myShininess = 0.01f;
+ myAmbientCoef = 0.26f;
+ myDiffuseCoef = 0.75f;
+ mySpecularCoef = 0.05f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.192f, 0.192f, 0.192f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.508f, 0.508f, 0.508f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.508f, 0.508f, 0.508f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_SILVER:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.75f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.275f, 0.275f, 0.250f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.630f, 0.630f, 0.630f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.950f, 0.930f, 0.880f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_STEEL:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.90f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.150f, 0.150f, 0.180f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.500f, 0.510f, 0.520f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.560f, 0.570f, 0.580f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_STONE:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.17f;
+ myAmbientCoef = 0.19f;
+ myDiffuseCoef = 0.75f;
+ mySpecularCoef = 0.08f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (1.0, 0.8, 0.62, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (1.0, 0.8, 0.62, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.98, 1.0, 0.60, Quantity_TOC_RGB);
+ break;
+ // Ascending Compatibility of physical materials. Takes the same definition as in the next constructor. New materials
+ case Graphic3d_NOM_CHROME:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.90f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.200f, 0.200f, 0.225f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.550f, 0.550f, 0.550f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.975f, 0.975f, 0.975f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_ALUMINIUM:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.75f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.300f, 0.300f, 0.300f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.600f, 0.600f, 0.600f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.910f, 0.920f, 0.920f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_NEON_PHC:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.05f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 0.62f;
+ myEmissiveCoef = 0.90f;
+ myAmbientActivity = Standard_False;
+ myDiffuseActivity = Standard_False;
+ myEmissiveActivity = Standard_True;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (1.0, 1.0, 1.0, Quantity_TOC_RGB);
+ // Color resulting from specular
+ myEmissiveColor.SetValues (0.0, 1.0, 0.46, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_OBSIDIAN:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.3f;
+ myAmbientCoef = 1.0f;
+ myDiffuseCoef = 1.0f;
+ mySpecularCoef = 1.0f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.054f, 0.050f, 0.066f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.183f, 0.170f, 0.225f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.333f, 0.329f, 0.346f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_JADE:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.10f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.135f, 0.223f, 0.158f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.540f, 0.890f, 0.630f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.316f, 0.316f, 0.316f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_CHARCOAL:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.01f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+
+ // Color resulting from ambient
+ myAmbientColor .SetValues (0.050f, 0.050f, 0.050f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor .SetValues (0.150f, 0.150f, 0.150f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.000f, 0.000f, 0.000f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_WATER:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.90f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+ myRefractionIndex = 1.33f;
+ myTransparencyCoef = 0.80f;
+
+ // Color resulting from ambient
+ myAmbientColor.SetValues (0.450f, 0.450f, 0.475f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor.SetValues (0.050f, 0.050f, 0.075f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.380f, 0.380f, 0.380f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_GLASS:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.50f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+ myRefractionIndex = 1.62f;
+ myTransparencyCoef = 0.80f;
+
+ // Color resulting from ambient
+ myAmbientColor.SetValues (0.550f, 0.575f, 0.575f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor.SetValues (0.050f, 0.075f, 0.075f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.920f, 0.920f, 0.920f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_DIAMOND:
+ myMaterialType = Graphic3d_MATERIAL_PHYSIC;
+
+ myShininess = 0.90f;
+ myAmbientCoef = 1.00f;
+ myDiffuseCoef = 1.00f;
+ mySpecularCoef = 1.00f;
+ myRefractionIndex = 2.42f;
+ myTransparencyCoef = 0.80f;
+
+ // Color resulting from ambient
+ myAmbientColor.SetValues (0.550f, 0.550f, 0.550f, Quantity_TOC_RGB);
+ // Color resulting from dispersed
+ myDiffuseColor.SetValues (0.100f, 0.100f, 0.100f, Quantity_TOC_RGB);
+ // Color resulting from specular
+ mySpecularColor.SetValues (0.970f, 0.970f, 0.970f, Quantity_TOC_RGB);
+ break;
+ case Graphic3d_NOM_UserDefined:
+ myStringName = "UserDefined";
+ break;
+ case Graphic3d_NOM_DEFAULT:
+ default:
+ myStringName = "Default";
+ break;
+ }
+}
+// =======================================================================
+// function : IncreaseShine
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::IncreaseShine (const Standard_Real theDelta)
+{
+ Standard_ShortReal anOldShine = myShininess;
+ myShininess = Standard_ShortReal(myShininess + myShininess * theDelta / 100.0);
+ if (myShininess > 1.0 || myShininess < 0.0)
+ {
+ myShininess = anOldShine;
+ }
+}
- MyDiffuseCoef = Standard_ShortReal (AValue);
-#ifndef BUC60565
- Standard_Real R, G, B;
- MyDiffuseColor.Values (R, G, B, Quantity_TOC_RGB);
- MyDiffuseColor.SetValues
- (R*AValue, G*AValue, B*AValue, Quantity_TOC_RGB);
-#endif
-#ifdef IMP171201
- if( MyDiffuseActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
+// =======================================================================
+// function : SetMaterialType
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetMaterialType (const Graphic3d_TypeOfMaterial theType)
+{
+ myMaterialType = theType;
+ if (theType != myMaterialType)
+ {
+ SetMaterialName ("UserDefined");
+ }
}
-/* Attribution of coefficient of emission */
-void Graphic3d_MaterialAspect::SetEmissive (const Standard_Real AValue) {
+// =======================================================================
+// function : SetAmbient
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetAmbient (const Standard_Real theValue)
+{
+ if (theValue < 0.0
+ || theValue > 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetAmbient < 0. or > 1.0");
+ }
- if ((AValue < 0.0) || (AValue > 1.0))
- Graphic3d_MaterialDefinitionError::Raise
- ("Bad value for SetEmissive < 0. or > 1.0");
+ myAmbientCoef = Standard_ShortReal (theValue);
+ if (myAmbientActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
-//Standard_Real R, G, B;
+// =======================================================================
+// function : SetColor
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetColor (const Quantity_Color& theColor)
+{
+ const Standard_ShortReal anAmbientCoeff = 0.25f;
+ myAmbientColor.SetValues (theColor.Red() * anAmbientCoeff,
+ theColor.Green() * anAmbientCoeff,
+ theColor.Blue() * anAmbientCoeff, Quantity_TOC_RGB);
+ myDiffuseColor = theColor;
+ if (myAmbientActivity && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
- MyEmissiveCoef = Standard_ShortReal (AValue);
-#ifdef IMP171201
- if( MyDiffuseActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
+// =======================================================================
+// function : SetAmbientColor
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetAmbientColor (const Quantity_Color& theColor)
+{
+ myAmbientColor = theColor;
+ if (myAmbientActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
}
-void Graphic3d_MaterialAspect::SetReflectionModeOn (const Graphic3d_TypeOfReflection AType) {
+// =======================================================================
+// function : SetDiffuseColor
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetDiffuseColor (const Quantity_Color& theColor)
+{
+ myDiffuseColor = theColor;
+ if (myDiffuseActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
- switch (AType) {
+// =======================================================================
+// function : SetSpecularColor
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetSpecularColor (const Quantity_Color& theColor)
+{
+ mySpecularColor = theColor;
+ if (mySpecularActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
- case Graphic3d_TOR_AMBIENT :
- MyAmbientActivity = Standard_True;
- break;
+// =======================================================================
+// function : SetEmissiveColor
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetEmissiveColor (const Quantity_Color& theColor)
+{
+ myEmissiveColor = theColor;
+ if (myEmissiveActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
- case Graphic3d_TOR_DIFFUSE :
- MyDiffuseActivity = Standard_True;
- break;
+// =======================================================================
+// function : SetDiffuse
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetDiffuse (const Standard_Real theValue)
+{
+ if (theValue < 0.0
+ || theValue > 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetDiffuse < 0. or > 1.0");
+ }
- case Graphic3d_TOR_SPECULAR :
- MySpecularActivity = Standard_True;
- break;
-
- case Graphic3d_TOR_EMISSION :
- MyEmissiveActivity = Standard_True;
- break;
- }
-#ifdef IMP171201
- if( MyMaterialType == Graphic3d_MATERIAL_PHYSIC )
- SetMaterialName("UserDefined");
-#endif
+ myDiffuseCoef = Standard_ShortReal (theValue);
+ if (myDiffuseActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
}
-void Graphic3d_MaterialAspect::SetReflectionModeOff (const Graphic3d_TypeOfReflection AType) {
-
- switch (AType) {
+// =======================================================================
+// function : SetEmissive
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetEmissive (const Standard_Real theValue)
+{
+ if (theValue < 0.0
+ || theValue > 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetEmissive < 0. or > 1.0");
+ }
- case Graphic3d_TOR_AMBIENT :
- MyAmbientActivity = Standard_False;
- break;
+ myEmissiveCoef = Standard_ShortReal (theValue);
+ if (myDiffuseActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
- case Graphic3d_TOR_DIFFUSE :
- MyDiffuseActivity = Standard_False;
- break;
+// =======================================================================
+// function : SetReflectionModeOn
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetReflectionModeOn (const Graphic3d_TypeOfReflection theType)
+{
+ switch (theType)
+ {
+ case Graphic3d_TOR_AMBIENT:
+ myAmbientActivity = Standard_True;
+ break;
+ case Graphic3d_TOR_DIFFUSE:
+ myDiffuseActivity = Standard_True;
+ break;
+ case Graphic3d_TOR_SPECULAR:
+ mySpecularActivity = Standard_True;
+ break;
+ case Graphic3d_TOR_EMISSION:
+ myEmissiveActivity = Standard_True;
+ break;
+ }
+ if (myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
- case Graphic3d_TOR_SPECULAR :
- MySpecularActivity = Standard_False;
- break;
-
- case Graphic3d_TOR_EMISSION :
- MyEmissiveActivity = Standard_False;
- break;
- }
-#ifdef IMP171201
- if( MyMaterialType == Graphic3d_MATERIAL_PHYSIC )
- SetMaterialName("UserDefined");
-#endif
+// =======================================================================
+// function : SetReflectionModeOff
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetReflectionModeOff (const Graphic3d_TypeOfReflection theType)
+{
+ switch (theType)
+ {
+ case Graphic3d_TOR_AMBIENT:
+ myAmbientActivity = Standard_False;
+ break;
+ case Graphic3d_TOR_DIFFUSE:
+ myDiffuseActivity = Standard_False;
+ break;
+ case Graphic3d_TOR_SPECULAR:
+ mySpecularActivity = Standard_False;
+ break;
+ case Graphic3d_TOR_EMISSION:
+ myEmissiveActivity = Standard_False;
+ break;
+ }
+ if (myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
}
-void Graphic3d_MaterialAspect::SetSpecular (const Standard_Real AValue) {
+// =======================================================================
+// function : SetSpecular
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetSpecular (const Standard_Real theValue)
+{
+ if (theValue < 0.0
+ || theValue > 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetSpecular < 0. or > 1.0");
+ }
- if ((AValue < 0.0) || (AValue > 1.0))
- Graphic3d_MaterialDefinitionError::Raise
- ("Bad value for SetSpecular < 0. or > 1.0");
+ mySpecularCoef = Standard_ShortReal (theValue);
+ if (mySpecularActivity
+ && myMaterialType == Graphic3d_MATERIAL_PHYSIC)
+ {
+ SetMaterialName ("UserDefined");
+ }
+}
+// =======================================================================
+// function : SetTransparency
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetTransparency (const Standard_Real theValue)
+{
+ if (theValue < 0.0
+ || theValue > 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for SetTransparency < 0. or > 1.0");
+ }
- MySpecularCoef = Standard_ShortReal (AValue);
-#ifndef BUC60565
- Standard_Real R, G, B;
- MySpecularColor.Values (R, G, B, Quantity_TOC_RGB);
- MySpecularColor.SetValues
- (R*AValue, G*AValue, B*AValue, Quantity_TOC_RGB);
-#endif
-#ifdef IMP171201
- if( MySpecularActivity &&
- (MyMaterialType == Graphic3d_MATERIAL_PHYSIC) )
- SetMaterialName("UserDefined");
-#endif
+ myTransparencyCoef = Standard_ShortReal (theValue);
}
-void Graphic3d_MaterialAspect::SetTransparency (const Standard_Real AValue) {
-
- if ((AValue < 0.0) || (AValue > 1.0))
- Graphic3d_MaterialDefinitionError::Raise
- ("Bad value for SetTransparency < 0. or > 1.0");
+// =======================================================================
+// function : SetRefractionIndex
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetRefractionIndex (const Standard_Real theValue)
+{
+ if (theValue < 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for refraction index < 1.0");
+ }
- MyTransparencyCoef = Standard_ShortReal (AValue);
+ myRefractionIndex = static_cast<Standard_ShortReal> (theValue);
}
+// =======================================================================
+// function : Color
+// purpose :
+// =======================================================================
const Quantity_Color& Graphic3d_MaterialAspect::Color() const
{
- return MyAmbientColor;
+ return myAmbientColor;
}
+// =======================================================================
+// function : AmbientColor
+// purpose :
+// =======================================================================
const Quantity_Color& Graphic3d_MaterialAspect::AmbientColor() const
{
- return MyAmbientColor;
+ return myAmbientColor;
}
+// =======================================================================
+// function : DiffuseColor
+// purpose :
+// =======================================================================
const Quantity_Color& Graphic3d_MaterialAspect::DiffuseColor() const
{
- return MyDiffuseColor;
+ return myDiffuseColor;
}
+// =======================================================================
+// function : SpecularColor
+// purpose :
+// =======================================================================
const Quantity_Color& Graphic3d_MaterialAspect::SpecularColor() const
{
- return MySpecularColor;
+ return mySpecularColor;
}
+// =======================================================================
+// function : EmissiveColor
+// purpose :
+// =======================================================================
const Quantity_Color& Graphic3d_MaterialAspect::EmissiveColor() const
{
- return MyEmissiveColor;
+ return myEmissiveColor;
}
-/* Access to the type of material */
-Standard_Boolean Graphic3d_MaterialAspect::MaterialType( const Graphic3d_TypeOfMaterial AType ) const {
- return ( MyMaterialType == AType ) ;
+// =======================================================================
+// function : MaterialType
+// purpose :
+// =======================================================================
+Standard_Boolean Graphic3d_MaterialAspect::MaterialType (const Graphic3d_TypeOfMaterial theType) const
+{
+ return myMaterialType == theType;
}
-Standard_Boolean Graphic3d_MaterialAspect::ReflectionMode (const Graphic3d_TypeOfReflection AType) const {
-
-Standard_Boolean Result;
-
- Result = Standard_False;
-
- switch (AType) {
-
- case Graphic3d_TOR_AMBIENT :
- Result = MyAmbientActivity;
- break;
-
- case Graphic3d_TOR_DIFFUSE :
- Result = MyDiffuseActivity;
- break;
-
- case Graphic3d_TOR_SPECULAR :
- Result = MySpecularActivity;
- break;
-
- case Graphic3d_TOR_EMISSION :
- Result = MyEmissiveActivity;
- break;
- }
- return (Result);
-
+// =======================================================================
+// function : ReflectionMode
+// purpose :
+// =======================================================================
+Standard_Boolean Graphic3d_MaterialAspect::ReflectionMode (const Graphic3d_TypeOfReflection theType) const
+{
+ switch (theType)
+ {
+ case Graphic3d_TOR_AMBIENT: return myAmbientActivity;
+ case Graphic3d_TOR_DIFFUSE: return myDiffuseActivity;
+ case Graphic3d_TOR_SPECULAR: return mySpecularActivity;
+ case Graphic3d_TOR_EMISSION: return myEmissiveActivity;
+ }
+ return Standard_False;
}
-/* Access to the color of the ambient lighting */
-Standard_Real Graphic3d_MaterialAspect::Ambient () const {
-
- return (Standard_Real (MyAmbientCoef));
-
+// =======================================================================
+// function : Ambient
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::Ambient() const
+{
+ return Standard_Real (myAmbientCoef);
}
-/* Access to the color of the dispersed lighting */
-Standard_Real Graphic3d_MaterialAspect::Diffuse () const {
-
- return (Standard_Real (MyDiffuseCoef));
-
+// =======================================================================
+// function : Diffuse
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::Diffuse() const
+{
+ return Standard_Real (myDiffuseCoef);
}
-/* Value of the coefficient of emission */
-Standard_Real Graphic3d_MaterialAspect::Emissive () const {
-
- return (Standard_Real (MyEmissiveCoef));
-
+// =======================================================================
+// function : Emissive
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::Emissive() const
+{
+ return Standard_Real (myEmissiveCoef);
}
-/* Access to the color of the specular lighting */
-Standard_Real Graphic3d_MaterialAspect::Specular () const {
-
- return (Standard_Real (MySpecularCoef));
-
+// =======================================================================
+// function : Specular
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::Specular() const
+{
+ return Standard_Real (mySpecularCoef);
}
-/* Access to the coefficient of transparency */
-Standard_Real Graphic3d_MaterialAspect::Transparency () const {
-
- return (Standard_Real (MyTransparencyCoef));
-
+// =======================================================================
+// function : Transparency
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::Transparency() const
+{
+ return Standard_Real (myTransparencyCoef);
}
-/* Access to the coefficient of shineness */
-Standard_Real Graphic3d_MaterialAspect::Shininess () const {
-
- return (Standard_Real (MyShininess));
-
+// =======================================================================
+// function : RefractionIndex
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::RefractionIndex() const
+{
+ return myRefractionIndex;
}
-/* Attribution of the coefficient of shineness */
-void Graphic3d_MaterialAspect::SetShininess (const Standard_Real AValue) {
+// =======================================================================
+// function : Shininess
+// purpose :
+// =======================================================================
+Standard_Real Graphic3d_MaterialAspect::Shininess() const
+{
+ return Standard_Real (myShininess);
+}
- if ((AValue < 0.0) || (AValue > 1.0))
- Graphic3d_MaterialDefinitionError::Raise
- ("Bad value for Shininess < 0. or > 1.0");
+// =======================================================================
+// function : SetShininess
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetShininess (const Standard_Real theValue)
+{
+ if (theValue < 0.0
+ || theValue > 1.0)
+ {
+ Graphic3d_MaterialDefinitionError::Raise ("Bad value for Shininess < 0. or > 1.0");
+ }
- MyShininess = Standard_ShortReal (AValue);
-#ifdef IMP171201
- SetMaterialName("UserDefined");
-#endif
+ myShininess = Standard_ShortReal (theValue);
+ SetMaterialName ("UserDefined");
}
-
-void Graphic3d_MaterialAspect::SetEnvReflexion(const Standard_ShortReal AValue)
+// =======================================================================
+// function : SetEnvReflexion
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetEnvReflexion (const Standard_ShortReal theValue)
{
- MyEnvReflexion = AValue;
+ myEnvReflexion = theValue;
}
-
+// =======================================================================
+// function : EnvReflexion
+// purpose :
+// =======================================================================
Standard_ShortReal Graphic3d_MaterialAspect::EnvReflexion() const
{
- return MyEnvReflexion;
+ return myEnvReflexion;
}
+// =======================================================================
+// function : Name
+// purpose :
+// =======================================================================
Graphic3d_NameOfMaterial Graphic3d_MaterialAspect::Name() const
{
- return MyMaterialName;
-}
-
-void Graphic3d_MaterialAspect::Reset() {
-#ifdef IMP171201
- Init(MyRequestedMaterialName);
-#else
- Init(MyMaterialName);
-#endif
+ return myMaterialName;
}
-#ifdef IMP150200
-Standard_Boolean Graphic3d_MaterialAspect::IsEqual(const Graphic3d_MaterialAspect& other) const {
-
- if( MyAmbientCoef == other.Ambient() &&
- MyDiffuseCoef == other.Diffuse() &&
- MySpecularCoef == other.Specular() &&
- MyEmissiveCoef == other.Emissive() &&
- MyTransparencyCoef == other.Transparency() &&
- MyShininess == other.Shininess() &&
- MyEnvReflexion == other.EnvReflexion() &&
- MyAmbientColor == other.AmbientColor() &&
- MyDiffuseColor == other.DiffuseColor() &&
- MySpecularColor == other.SpecularColor() &&
- MyEmissiveColor == other.EmissiveColor() &&
- MyAmbientActivity == other.ReflectionMode(Graphic3d_TOR_AMBIENT) &&
- MyDiffuseActivity == other.ReflectionMode(Graphic3d_TOR_DIFFUSE) &&
- MySpecularActivity == other.ReflectionMode(Graphic3d_TOR_SPECULAR) &&
- MyEmissiveActivity == other.ReflectionMode(Graphic3d_TOR_EMISSION) )
- return Standard_True;
-
- return Standard_False;
+// =======================================================================
+// function : Reset
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::Reset()
+{
+ Init (myRequestedMaterialName);
}
-Standard_Boolean Graphic3d_MaterialAspect::IsDifferent(const Graphic3d_MaterialAspect& other) const {
-
- return !IsEqual(other);
+// =======================================================================
+// function : IsEqual
+// purpose :
+// =======================================================================
+Standard_Boolean Graphic3d_MaterialAspect::IsEqual (const Graphic3d_MaterialAspect& theOther) const
+{
+ return myAmbientCoef == theOther.myAmbientCoef
+ && myDiffuseCoef == theOther.myDiffuseCoef
+ && mySpecularCoef == theOther.mySpecularCoef
+ && myEmissiveCoef == theOther.myEmissiveCoef
+ && myTransparencyCoef == theOther.myTransparencyCoef
+ && myRefractionIndex == theOther.myRefractionIndex
+ && myShininess == theOther.myShininess
+ && myEnvReflexion == theOther.myEnvReflexion
+ && myAmbientColor == theOther.myAmbientColor
+ && myDiffuseColor == theOther.myDiffuseColor
+ && mySpecularColor == theOther.mySpecularColor
+ && myEmissiveColor == theOther.myEmissiveColor
+ && myAmbientActivity == theOther.myAmbientActivity
+ && myDiffuseActivity == theOther.myDiffuseActivity
+ && mySpecularActivity == theOther.mySpecularActivity
+ && myEmissiveActivity == theOther.myEmissiveActivity;
+}
+
+// =======================================================================
+// function : IsDifferent
+// purpose :
+// =======================================================================
+Standard_Boolean Graphic3d_MaterialAspect::IsDifferent (const Graphic3d_MaterialAspect& theOther) const
+{
+ return !IsEqual (theOther);
}
-typedef struct _Material {
- const char* name;
+typedef struct _Material
+{
+ const char* name;
Graphic3d_TypeOfMaterial type;
} Material;
-static Material theMaterials[] = {
- {"Brass",Graphic3d_MATERIAL_PHYSIC},
- {"Bronze",Graphic3d_MATERIAL_PHYSIC},
- {"Copper",Graphic3d_MATERIAL_PHYSIC},
- {"Gold",Graphic3d_MATERIAL_PHYSIC},
- {"Pewter",Graphic3d_MATERIAL_PHYSIC},
- {"Plastered",Graphic3d_MATERIAL_ASPECT},
- {"Plastified",Graphic3d_MATERIAL_ASPECT},
- {"Silver",Graphic3d_MATERIAL_PHYSIC},
- {"Steel",Graphic3d_MATERIAL_PHYSIC},
- {"Stone",Graphic3d_MATERIAL_PHYSIC},
- {"Shiny_plastified",Graphic3d_MATERIAL_ASPECT},
- {"Satined",Graphic3d_MATERIAL_ASPECT},
- {"Metalized",Graphic3d_MATERIAL_ASPECT},
- {"Ionized",Graphic3d_MATERIAL_ASPECT},
- {"Chrome",Graphic3d_MATERIAL_PHYSIC},
- {"Aluminium",Graphic3d_MATERIAL_PHYSIC},
- {"Obsidian",Graphic3d_MATERIAL_PHYSIC},
- {"Neon",Graphic3d_MATERIAL_PHYSIC},
- {"Jade",Graphic3d_MATERIAL_PHYSIC}
+static Material theMaterials[] =
+{
+ {"Brass", Graphic3d_MATERIAL_PHYSIC},
+ {"Bronze", Graphic3d_MATERIAL_PHYSIC},
+ {"Copper", Graphic3d_MATERIAL_PHYSIC},
+ {"Gold", Graphic3d_MATERIAL_PHYSIC},
+ {"Pewter", Graphic3d_MATERIAL_PHYSIC},
+ {"Plastered", Graphic3d_MATERIAL_ASPECT},
+ {"Plastified", Graphic3d_MATERIAL_ASPECT},
+ {"Silver", Graphic3d_MATERIAL_PHYSIC},
+ {"Steel", Graphic3d_MATERIAL_PHYSIC},
+ {"Stone", Graphic3d_MATERIAL_PHYSIC},
+ {"Shiny_plastified", Graphic3d_MATERIAL_ASPECT},
+ {"Satined", Graphic3d_MATERIAL_ASPECT},
+ {"Metalized", Graphic3d_MATERIAL_ASPECT},
+ {"Ionized", Graphic3d_MATERIAL_ASPECT},
+ {"Chrome", Graphic3d_MATERIAL_PHYSIC},
+ {"Aluminium", Graphic3d_MATERIAL_PHYSIC},
+ {"Obsidian", Graphic3d_MATERIAL_PHYSIC},
+ {"Neon", Graphic3d_MATERIAL_PHYSIC},
+ {"Jade", Graphic3d_MATERIAL_PHYSIC},
+ {"Charcoal", Graphic3d_MATERIAL_PHYSIC},
+ {"Water", Graphic3d_MATERIAL_PHYSIC},
+ {"Glass", Graphic3d_MATERIAL_PHYSIC},
+ {"Diamond", Graphic3d_MATERIAL_PHYSIC}
+
};
-Standard_Integer Graphic3d_MaterialAspect::NumberOfMaterials() {
+// =======================================================================
+// function : NumberOfMaterials
+// purpose :
+// =======================================================================
+Standard_Integer Graphic3d_MaterialAspect::NumberOfMaterials()
+{
Standard_STATIC_ASSERT(sizeof(theMaterials)/sizeof(Material) == Graphic3d_NOM_DEFAULT);
-
return Graphic3d_NOM_DEFAULT;
}
-Standard_CString Graphic3d_MaterialAspect::MaterialName(const Standard_Integer aRank) {
-
- if( aRank < 1 || aRank > NumberOfMaterials() )
- Standard_OutOfRange::Raise(" BAD index of material");
-
- return theMaterials[aRank-1].name;
+// =======================================================================
+// function : MaterialName
+// purpose :
+// =======================================================================
+Standard_CString Graphic3d_MaterialAspect::MaterialName (const Standard_Integer theRank)
+{
+ if (theRank < 1 || theRank > NumberOfMaterials())
+ {
+ Standard_OutOfRange::Raise ("BAD index of material");
+ }
+ return theMaterials[theRank - 1].name;
}
+// =======================================================================
+// function : MaterialFromName
+// purpose :
+// =======================================================================
Graphic3d_NameOfMaterial Graphic3d_MaterialAspect::MaterialFromName (const Standard_CString theName)
{
TCollection_AsciiString aName (theName);
return Graphic3d_NOM_DEFAULT;
}
-Graphic3d_TypeOfMaterial Graphic3d_MaterialAspect::MaterialType(const Standard_Integer aRank) {
-
- if( aRank < 1 || aRank > NumberOfMaterials() )
- Standard_OutOfRange::Raise(" BAD index of material");
-
- return theMaterials[aRank-1].type;
+// =======================================================================
+// function : MaterialType
+// purpose :
+// =======================================================================
+Graphic3d_TypeOfMaterial Graphic3d_MaterialAspect::MaterialType (const Standard_Integer theRank)
+{
+ if (theRank < 1 || theRank > NumberOfMaterials())
+ {
+ Standard_OutOfRange::Raise ("BAD index of material");
+ }
+ return theMaterials[theRank - 1].type;
}
-#endif
-#ifdef IMP171201
+// =======================================================================
+// function : MaterialName
+// purpose :
+// =======================================================================
Standard_CString Graphic3d_MaterialAspect::MaterialName() const
{
- return MyStringName.ToCString();
+ return myStringName.ToCString();
}
-void Graphic3d_MaterialAspect::SetMaterialName(const Standard_CString aNewName)
+
+// =======================================================================
+// function : SetMaterialName
+// purpose :
+// =======================================================================
+void Graphic3d_MaterialAspect::SetMaterialName (const Standard_CString theNewName)
{
-// if a component of a "standard" material change, the
-// result is no more standard ( a blue gold is not a gold )
- MyMaterialName = Graphic3d_NOM_UserDefined;
- MyStringName = aNewName;
+ // if a component of a "standard" material change, the
+ // result is no more standard (a blue gold is not a gold)
+ myMaterialName = Graphic3d_NOM_UserDefined;
+ myStringName = theNewName;
}
-#endif