mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0029902: Data Exchange, XCAF - provide extended Material definition for visualization purposes
Introduced new attribute XCAFDoc_VisMaterial storing visualization material definition.
This commit is contained in:
@@ -26,6 +26,7 @@ public:
|
||||
//! Default constructor.
|
||||
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
|
||||
: myIsHidden (false),
|
||||
myHasOwnMaterial(false),
|
||||
myHasOwnColor (false),
|
||||
myHasOwnTransp(false),
|
||||
myHasOwnWidth (false)
|
||||
@@ -36,6 +37,10 @@ public:
|
||||
bool IsHidden() const { return myIsHidden; }
|
||||
void SetHidden (const bool theToHide) { myIsHidden = theToHide;}
|
||||
|
||||
bool HasOwnMaterial() const { return myHasOwnMaterial; }
|
||||
void UnsetOwnMaterial() { myHasOwnMaterial = false; }
|
||||
void SetOwnMaterial() { myHasOwnMaterial = true; }
|
||||
|
||||
bool HasOwnColor() const { return myHasOwnColor; }
|
||||
void UnsetOwnColor() { myHasOwnColor = false; }
|
||||
void SetOwnColor (const Quantity_Color& /*theColor*/) { myHasOwnColor = true; }
|
||||
@@ -51,6 +56,7 @@ public:
|
||||
public: //! @name list of overridden properties
|
||||
|
||||
bool myIsHidden;
|
||||
bool myHasOwnMaterial;
|
||||
bool myHasOwnColor;
|
||||
bool myHasOwnTransp;
|
||||
bool myHasOwnWidth;
|
||||
|
@@ -333,7 +333,11 @@ void AIS_ColoredShape::SetMaterial (const Graphic3d_MaterialAspect& theMaterial)
|
||||
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||
//if (aDrawer->HasOwnMaterial()) continue;
|
||||
if (aDrawer->HasOwnMaterial())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (aDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
setMaterial (aDrawer, theMaterial, aDrawer->HasOwnColor(), aDrawer->HasOwnTransparency());
|
||||
|
@@ -308,6 +308,7 @@ void RWGltf_GltfJsonParser::gltfParseMaterials()
|
||||
}
|
||||
aMat->Id = aMatId.GetString();
|
||||
myMaterialsCommon.Bind (aMat->Id, aMat);
|
||||
gltfBindMaterial (Handle(RWGltf_MaterialMetallicRoughness)(), aMat);
|
||||
}
|
||||
}
|
||||
else if (aMatList->IsArray())
|
||||
@@ -342,10 +343,60 @@ void RWGltf_GltfJsonParser::gltfParseMaterials()
|
||||
aMatCommon->Id = TCollection_AsciiString ("mat_") + aMatIndex;
|
||||
myMaterialsCommon.Bind (TCollection_AsciiString (aMatIndex), aMatCommon);
|
||||
}
|
||||
|
||||
gltfBindMaterial (aMatPbr, aMatCommon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : gltfBindMaterial
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void RWGltf_GltfJsonParser::gltfBindMaterial (const Handle(RWGltf_MaterialMetallicRoughness)& theMatPbr,
|
||||
const Handle(RWGltf_MaterialCommon)& theMatCommon)
|
||||
{
|
||||
if (theMatPbr.IsNull()
|
||||
&& theMatCommon.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) aMat = new XCAFDoc_VisMaterial();
|
||||
if (!theMatCommon.IsNull())
|
||||
{
|
||||
XCAFDoc_VisMaterialCommon aMatXde;
|
||||
aMatXde.IsDefined = true;
|
||||
aMatXde.AmbientColor = theMatCommon->AmbientColor;
|
||||
aMatXde.DiffuseColor = theMatCommon->DiffuseColor;
|
||||
aMatXde.SpecularColor = theMatCommon->SpecularColor;
|
||||
aMatXde.EmissiveColor = theMatCommon->EmissiveColor;
|
||||
aMatXde.Shininess = theMatCommon->Shininess;
|
||||
aMatXde.Transparency = theMatCommon->Transparency;
|
||||
aMatXde.AmbientTexture = theMatCommon->AmbientTexture;
|
||||
aMatXde.DiffuseTexture = theMatCommon->DiffuseTexture;
|
||||
aMatXde.SpecularTexture = theMatCommon->SpecularTexture;
|
||||
aMat->SetCommonMaterial (aMatXde);
|
||||
}
|
||||
if (!theMatPbr.IsNull())
|
||||
{
|
||||
XCAFDoc_VisMaterialMetallicRoughness aMatXde;
|
||||
aMatXde.IsDefined = true;
|
||||
aMatXde.MetallicRoughnessTexture = theMatPbr->MetallicRoughnessTexture;
|
||||
aMatXde.BaseColorTexture = theMatPbr->BaseColorTexture;
|
||||
aMatXde.EmissiveTexture = theMatPbr->EmissiveTexture;
|
||||
aMatXde.OcclusionTexture = theMatPbr->OcclusionTexture;
|
||||
aMatXde.NormalTexture = theMatPbr->NormalTexture;
|
||||
aMatXde.BaseColor = theMatPbr->BaseColor;
|
||||
aMatXde.EmissiveFactor = theMatPbr->EmissiveFactor;
|
||||
aMatXde.Metallic = theMatPbr->Metallic;
|
||||
aMatXde.Roughness = theMatPbr->Roughness;
|
||||
aMat->SetMetalRougnessMaterial (aMatXde);
|
||||
}
|
||||
|
||||
myMaterials.Bind (!theMatPbr.IsNull() ? theMatPbr->Id : theMatCommon->Id, aMat);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : gltfParseStdMaterial
|
||||
// purpose :
|
||||
@@ -1116,7 +1167,12 @@ bool RWGltf_GltfJsonParser::gltfParseMesh (TopoDS_Shape& theMeshShape,
|
||||
{
|
||||
RWMesh_NodeAttributes aShapeAttribs;
|
||||
aShapeAttribs.RawName = aUserName;
|
||||
aShapeAttribs.Style.SetColorSurf (aMeshData->BaseColor());
|
||||
//aShapeAttribs.Style.SetColorSurf (aMeshData->BaseColor());
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) aMat;
|
||||
myMaterials.Find (!aMeshData->MaterialPbr().IsNull() ? aMeshData->MaterialPbr()->Id : aMeshData->MaterialCommon()->Id, aMat);
|
||||
aShapeAttribs.Style.SetMaterial (aMat);
|
||||
|
||||
myAttribMap->Bind (aFace, aShapeAttribs);
|
||||
}
|
||||
myFaceList.Append (aFace);
|
||||
@@ -1586,7 +1642,10 @@ void RWGltf_GltfJsonParser::bindNamedShape (TopoDS_Shape& theShape,
|
||||
{
|
||||
if (aLateData->HasStyle())
|
||||
{
|
||||
aShapeAttribs.Style.SetColorSurf (aLateData->BaseColor());
|
||||
//aShapeAttribs.Style.SetColorSurf (aLateData->BaseColor());
|
||||
Handle(XCAFDoc_VisMaterial) aMat;
|
||||
myMaterials.Find (!aLateData->MaterialPbr().IsNull() ? aLateData->MaterialPbr()->Id : aLateData->MaterialCommon()->Id, aMat);
|
||||
aShapeAttribs.Style.SetMaterial (aMat);
|
||||
}
|
||||
if (aShapeAttribs.Name.IsEmpty()
|
||||
&& myUseMeshNameAsFallback)
|
||||
|
@@ -150,6 +150,10 @@ protected:
|
||||
Standard_EXPORT bool gltfParseTexture (Handle(Image_Texture)& theTexture,
|
||||
const RWGltf_JsonValue* theTextureId);
|
||||
|
||||
//! Bind material definition to the map.
|
||||
Standard_EXPORT void gltfBindMaterial (const Handle(RWGltf_MaterialMetallicRoughness)& theMatPbr,
|
||||
const Handle(RWGltf_MaterialCommon)& theMatCommon);
|
||||
|
||||
protected:
|
||||
|
||||
//! Parse scene array of nodes recursively.
|
||||
@@ -397,6 +401,7 @@ protected:
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialMetallicRoughness)> myMaterialsPbr;
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(RWGltf_MaterialCommon)> myMaterialsCommon;
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(XCAFDoc_VisMaterial)> myMaterials;
|
||||
NCollection_DataMap<TCollection_AsciiString, TopoDS_Shape> myShapeMap[2];
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, bool> myProbedFiles;
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeMapTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWMesh_CafReader, Standard_Transient)
|
||||
|
||||
@@ -276,6 +277,13 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (const TopoDS_Shape& theShape
|
||||
{
|
||||
aColorTool->SetColor (aNewRefLabel, aShapeAttribs.Style.GetColorCurv(), XCAFDoc_ColorCurv);
|
||||
}
|
||||
if (!aShapeAttribs.Style.Material().IsNull())
|
||||
{
|
||||
/// TODO duplicates!
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (myXdeDoc->Main());
|
||||
const TDF_Label aMaterialLabel = aMatTool->AddMaterial (aShapeAttribs.Style.Material()->MetalRougnessMaterial(), aShapeAttribs.Style.Material()->CommonMaterial());
|
||||
aMatTool->SetShapeMaterial (aNewRefLabel, aMaterialLabel);
|
||||
}
|
||||
|
||||
// store sub-shapes (iterator is set to ignore Location)
|
||||
TCollection_AsciiString aDummyName;
|
||||
|
@@ -49,7 +49,26 @@ void RWObj_CafReader::BindNamedShape (const TopoDS_Shape& theShape,
|
||||
aShapeAttribs.Name = theName;
|
||||
if (theMaterial != NULL)
|
||||
{
|
||||
aShapeAttribs.Style.SetColorSurf (Quantity_ColorRGBA (theMaterial->DiffuseColor, 1.0f - theMaterial->Transparency));
|
||||
///aShapeAttribs.Style.SetColorSurf (Quantity_ColorRGBA (theMaterial->DiffuseColor, 1.0f - theMaterial->Transparency));
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) aMat = new XCAFDoc_VisMaterial();
|
||||
XCAFDoc_VisMaterialCommon aMatXde;
|
||||
aMatXde.IsDefined = true;
|
||||
aMatXde.AmbientColor = theMaterial->AmbientColor;
|
||||
aMatXde.DiffuseColor = theMaterial->DiffuseColor;
|
||||
aMatXde.SpecularColor = theMaterial->SpecularColor;
|
||||
aMatXde.Shininess = theMaterial->Shininess;
|
||||
aMatXde.Transparency = theMaterial->Transparency;
|
||||
if (!theMaterial->DiffuseTexture.IsEmpty())
|
||||
{
|
||||
aMatXde.DiffuseTexture = new Image_Texture (theMaterial->DiffuseTexture);
|
||||
}
|
||||
if (!theMaterial->SpecularTexture.IsEmpty())
|
||||
{
|
||||
aMatXde.SpecularTexture = new Image_Texture (theMaterial->SpecularTexture);
|
||||
}
|
||||
aMat->SetCommonMaterial (aMatXde);
|
||||
aShapeAttribs.Style.SetMaterial (aMat);
|
||||
}
|
||||
myAttribMap.Bind (theShape, aShapeAttribs);
|
||||
|
||||
|
@@ -63,5 +63,9 @@ XCAFDoc_View.cxx
|
||||
XCAFDoc_View.hxx
|
||||
XCAFDoc_ViewTool.cxx
|
||||
XCAFDoc_ViewTool.hxx
|
||||
XCAFDoc_VisMaterial.cxx
|
||||
XCAFDoc_VisMaterial.hxx
|
||||
XCAFDoc_VisMaterialTool.cxx
|
||||
XCAFDoc_VisMaterialTool.hxx
|
||||
XCAFDoc_Volume.cxx
|
||||
XCAFDoc_Volume.hxx
|
||||
|
@@ -171,6 +171,15 @@ const Standard_GUID& XCAFDoc::MaterialRefGUID ()
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VisMaterialRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Standard_GUID& XCAFDoc::VisMaterialRefGUID()
|
||||
{
|
||||
static const Standard_GUID ID ("936F4070-5369-405D-A7AD-2AC76C860EC8");
|
||||
return ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NoteRefGUID
|
||||
|
@@ -98,6 +98,9 @@ public:
|
||||
|
||||
Standard_EXPORT static const Standard_GUID& MaterialRefGUID();
|
||||
|
||||
//! Return GUID for TreeNode representing Visualization Material.
|
||||
Standard_EXPORT static const Standard_GUID& VisMaterialRefGUID();
|
||||
|
||||
//! Return GUIDs for representing notes
|
||||
Standard_EXPORT static const Standard_GUID& NoteRefGUID();
|
||||
|
||||
|
@@ -33,7 +33,25 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_ColorTool,TDF_Attribute)
|
||||
|
||||
#define AUTONAMING // automatically set names for labels
|
||||
static Standard_Boolean XCAFDoc_ColorTool_AutoNaming = Standard_True;
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAutoNaming
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_ColorTool::SetAutoNaming (Standard_Boolean theIsAutoNaming)
|
||||
{
|
||||
XCAFDoc_ColorTool_AutoNaming = theIsAutoNaming;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AutoNaming
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_ColorTool::AutoNaming()
|
||||
{
|
||||
return XCAFDoc_ColorTool_AutoNaming;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BaseLabel
|
||||
@@ -175,36 +193,32 @@ TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_Color& col) const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_ColorTool::AddColor(const Quantity_ColorRGBA& col) const
|
||||
TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_ColorRGBA& theColor) const
|
||||
{
|
||||
TDF_Label L;
|
||||
if (FindColor(col, L)) return L;
|
||||
TDF_Label aLab;
|
||||
if (FindColor (theColor, aLab))
|
||||
{
|
||||
return aLab;
|
||||
}
|
||||
|
||||
// create a new color entry
|
||||
|
||||
TDF_TagSource aTag;
|
||||
L = aTag.NewChild(Label());
|
||||
aLab = aTag.NewChild (Label());
|
||||
XCAFDoc_Color::Set (aLab, theColor);
|
||||
|
||||
XCAFDoc_Color::Set(L, col);
|
||||
if (XCAFDoc_ColorTool_AutoNaming)
|
||||
{
|
||||
// set name according to color value
|
||||
const NCollection_Vec4<float>& anRgbaF = theColor;
|
||||
const NCollection_Vec4<unsigned int> anRgba (anRgbaF * 255.0f);
|
||||
char aColorHex[32];
|
||||
Sprintf (aColorHex, "%02X%02X%02X%02X", anRgba.r(), anRgba.g(), anRgba.b(), anRgba.a());
|
||||
const TCollection_AsciiString aName = TCollection_AsciiString (Quantity_Color::StringName (theColor.GetRGB().Name()))
|
||||
+ " (#" + aColorHex + ")";
|
||||
TDataStd_Name::Set (aLab, aName);
|
||||
}
|
||||
|
||||
#ifdef AUTONAMING
|
||||
// set name according to color value
|
||||
TCollection_AsciiString str;
|
||||
Quantity_Color aColor = col.GetRGB();
|
||||
str += aColor.StringName(aColor.Name());
|
||||
str += " (";
|
||||
str += TCollection_AsciiString(aColor.Red());
|
||||
str += ",";
|
||||
str += TCollection_AsciiString(aColor.Green());
|
||||
str += ",";
|
||||
str += TCollection_AsciiString(aColor.Blue());
|
||||
str += ",";
|
||||
str += TCollection_AsciiString(col.Alpha());
|
||||
str += ")";
|
||||
TDataStd_Name::Set(L, str);
|
||||
#endif
|
||||
|
||||
return L;
|
||||
return aLab;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -43,10 +43,17 @@ DEFINE_STANDARD_HANDLE(XCAFDoc_ColorTool, TDF_Attribute)
|
||||
//! Provide tools for management of Colors section of document.
|
||||
class XCAFDoc_ColorTool : public TDF_Attribute
|
||||
{
|
||||
public:
|
||||
//! Returns current auto-naming mode; TRUE by default.
|
||||
//! If TRUE then for added colors the TDataStd_Name attribute will be automatically added.
|
||||
//! This setting is global.
|
||||
Standard_EXPORT static Standard_Boolean AutoNaming();
|
||||
|
||||
//! See also AutoNaming().
|
||||
Standard_EXPORT static void SetAutoNaming (Standard_Boolean theIsAutoNaming);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT XCAFDoc_ColorTool();
|
||||
|
||||
//! Creates (if not exist) ColorTool.
|
||||
|
@@ -13,6 +13,7 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
@@ -27,12 +28,12 @@
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <XCAFDoc_ClippingPlaneTool.hxx>
|
||||
#include <XCAFDoc_DimTolTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_LayerTool.hxx>
|
||||
#include <XCAFDoc_MaterialTool.hxx>
|
||||
#include <XCAFDoc_NotesTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_ViewTool.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_DocumentTool,TDF_Attribute)
|
||||
|
||||
@@ -225,6 +226,17 @@ TDF_Label XCAFDoc_DocumentTool::NotesLabel(const TDF_Label& acces)
|
||||
return L;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VisMaterialLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TDF_Label XCAFDoc_DocumentTool::VisMaterialLabel (const TDF_Label& theLabel)
|
||||
{
|
||||
TDF_Label aLabel = DocLabel (theLabel).FindChild (10, Standard_True);
|
||||
TDataStd_Name::Set (aLabel, "VisMaterials");
|
||||
return aLabel;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
@@ -246,6 +258,14 @@ Handle(XCAFDoc_ColorTool) XCAFDoc_DocumentTool::ColorTool (const TDF_Label& acce
|
||||
return XCAFDoc_ColorTool::Set(ColorsLabel(acces));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VisMaterialTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XCAFDoc_VisMaterialTool) XCAFDoc_DocumentTool::VisMaterialTool (const TDF_Label& theLabel)
|
||||
{
|
||||
return XCAFDoc_VisMaterialTool::Set (VisMaterialLabel (theLabel));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : LayerTool
|
||||
|
@@ -32,6 +32,7 @@ class XCAFDoc_DimTolTool;
|
||||
class XCAFDoc_MaterialTool;
|
||||
class XCAFDoc_NotesTool;
|
||||
class XCAFDoc_ViewTool;
|
||||
class XCAFDoc_VisMaterialTool;
|
||||
class TDF_Attribute;
|
||||
class TDF_RelocationTable;
|
||||
|
||||
@@ -47,7 +48,6 @@ class XCAFDoc_DocumentTool : public TDF_Attribute
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
//! Create (if not exist) DocumentTool attribute
|
||||
@@ -89,12 +89,19 @@ public:
|
||||
//! Returns sub-label of DocLabel() with tag 9.
|
||||
Standard_EXPORT static TDF_Label NotesLabel(const TDF_Label& acces);
|
||||
|
||||
//! Returns sub-label of DocLabel() with tag 10.
|
||||
Standard_EXPORT static TDF_Label VisMaterialLabel (const TDF_Label& theLabel);
|
||||
|
||||
//! Creates (if it does not exist) ShapeTool attribute on ShapesLabel().
|
||||
Standard_EXPORT static Handle(XCAFDoc_ShapeTool) ShapeTool (const TDF_Label& acces);
|
||||
|
||||
//! Creates (if it does not exist) ColorTool attribute on ColorsLabel().
|
||||
Standard_EXPORT static Handle(XCAFDoc_ColorTool) ColorTool (const TDF_Label& acces);
|
||||
|
||||
|
||||
//! Creates (if it does not exist) XCAFDoc_VisMaterialTool attribute on VisMaterialLabel().
|
||||
//! Should not be confused with MaterialTool() defining physical/manufacturing materials.
|
||||
Standard_EXPORT static Handle(XCAFDoc_VisMaterialTool) VisMaterialTool (const TDF_Label& theLabel);
|
||||
|
||||
//! Creates (if it does not exist) LayerTool attribute on LayersLabel().
|
||||
Standard_EXPORT static Handle(XCAFDoc_LayerTool) LayerTool (const TDF_Label& acces);
|
||||
|
||||
@@ -113,6 +120,8 @@ public:
|
||||
//! Creates (if it does not exist) NotesTool attribute on NotesLabel().
|
||||
Standard_EXPORT static Handle(XCAFDoc_NotesTool) NotesTool(const TDF_Label& acces);
|
||||
|
||||
public:
|
||||
|
||||
Standard_EXPORT XCAFDoc_DocumentTool();
|
||||
|
||||
//! to be called when reading this attribute from file
|
||||
@@ -128,22 +137,6 @@ public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_DocumentTool,TDF_Attribute)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _XCAFDoc_DocumentTool_HeaderFile
|
||||
|
144
src/XCAFDoc/XCAFDoc_VisMaterial.cxx
Normal file
144
src/XCAFDoc/XCAFDoc_VisMaterial.cxx
Normal file
@@ -0,0 +1,144 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_VisMaterial, TDF_Attribute)
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Standard_GUID& XCAFDoc_VisMaterial::GetID()
|
||||
{
|
||||
static Standard_GUID THE_VIS_MAT_ID ("EBB00255-03A0-4845-BD3B-A70EEDEEFA78");
|
||||
return THE_VIS_MAT_ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XCAFDoc_VisMaterial::XCAFDoc_VisMaterial()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterial::Set (const TDF_Label& theLabel,
|
||||
const XCAFDoc_VisMaterialMetallicRoughness& theMetRoughnessMat,
|
||||
const XCAFDoc_VisMaterialCommon& theCommonMat)
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) anAttrib;
|
||||
if (!theLabel.FindAttribute (XCAFDoc_VisMaterial::GetID(), anAttrib))
|
||||
{
|
||||
anAttrib = new XCAFDoc_VisMaterial();
|
||||
theLabel.AddAttribute (anAttrib);
|
||||
}
|
||||
|
||||
anAttrib->Backup();
|
||||
anAttrib->myMetalRoughMat = theMetRoughnessMat;
|
||||
anAttrib->myCommonMat = theCommonMat;
|
||||
return anAttrib;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMetalRougnessMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetMetalRougnessMaterial (const XCAFDoc_VisMaterialMetallicRoughness& theMaterial)
|
||||
{
|
||||
Backup();
|
||||
myMetalRoughMat = theMaterial;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCommonMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetCommonMaterial (const XCAFDoc_VisMaterialCommon& theMaterial)
|
||||
{
|
||||
Backup();
|
||||
myCommonMat = theMaterial;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::Restore (const Handle(TDF_Attribute)& theWith)
|
||||
{
|
||||
XCAFDoc_VisMaterial* anOther = dynamic_cast<XCAFDoc_VisMaterial* >(theWith.get());
|
||||
myMetalRoughMat = anOther->myMetalRoughMat;
|
||||
myCommonMat = anOther->myCommonMat;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) XCAFDoc_VisMaterial::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_VisMaterial();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::Paste (const Handle(TDF_Attribute)& theInto,
|
||||
const Handle(TDF_RelocationTable)& ) const
|
||||
{
|
||||
XCAFDoc_VisMaterial* anOther = dynamic_cast<XCAFDoc_VisMaterial* >(theInto.get());
|
||||
anOther->Backup();
|
||||
anOther->myMetalRoughMat = myMetalRoughMat;
|
||||
anOther->myCommonMat = myCommonMat;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FillMaterialAspect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::FillMaterialAspect (Graphic3d_MaterialAspect& theAspect) const
|
||||
{
|
||||
if (myCommonMat.IsDefined)
|
||||
{
|
||||
theAspect = Graphic3d_MaterialAspect (Graphic3d_NOM_UserDefined);
|
||||
theAspect.SetAmbientColor (myCommonMat.AmbientColor);
|
||||
theAspect.SetDiffuseColor (myCommonMat.DiffuseColor);
|
||||
theAspect.SetSpecularColor(myCommonMat.SpecularColor);
|
||||
theAspect.SetEmissiveColor(myCommonMat.EmissiveColor);
|
||||
theAspect.SetTransparency (myCommonMat.Transparency);
|
||||
theAspect.SetShininess (myCommonMat.Shininess);
|
||||
}
|
||||
if (myMetalRoughMat.IsDefined)
|
||||
{
|
||||
if (myCommonMat.IsDefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
theAspect = Graphic3d_MaterialAspect (Graphic3d_NOM_UserDefined);
|
||||
theAspect.SetDiffuseColor (myMetalRoughMat.BaseColor.GetRGB());
|
||||
theAspect.SetAlpha (myMetalRoughMat.BaseColor.Alpha());
|
||||
theAspect.SetSpecularColor(Quantity_Color (Graphic3d_Vec3 (myMetalRoughMat.Metallic)));
|
||||
theAspect.SetShininess (1.0f - myMetalRoughMat.Roughness);
|
||||
}
|
||||
}
|
223
src/XCAFDoc/XCAFDoc_VisMaterial.hxx
Normal file
223
src/XCAFDoc/XCAFDoc_VisMaterial.hxx
Normal file
@@ -0,0 +1,223 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _XCAFDoc_VisMaterial_HeaderFile
|
||||
#define _XCAFDoc_VisMaterial_HeaderFile
|
||||
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <Image_Texture.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
|
||||
class Graphic3d_MaterialAspect;
|
||||
|
||||
//! Common (obsolete) material definition.
|
||||
struct XCAFDoc_VisMaterialCommon
|
||||
{
|
||||
Handle(Image_Texture) AmbientTexture; //!< image defining ambient color
|
||||
Handle(Image_Texture) DiffuseTexture; //!< image defining diffuse color
|
||||
Handle(Image_Texture) SpecularTexture; //!< image defining specular color
|
||||
Quantity_Color AmbientColor; //!< ambient color
|
||||
Quantity_Color DiffuseColor; //!< diffuse color
|
||||
Quantity_Color SpecularColor; //!< specular color
|
||||
Quantity_Color EmissiveColor; //!< emission color
|
||||
Standard_ShortReal Shininess; //!< shininess value
|
||||
Standard_ShortReal Transparency; //!< transparency value within [0, 1] range with 0 meaning opaque
|
||||
Standard_Boolean IsDefined; //!< defined flag; FALSE by default
|
||||
|
||||
//! Empty constructor.
|
||||
XCAFDoc_VisMaterialCommon()
|
||||
: AmbientColor (0.1, 0.1, 0.1, Quantity_TOC_RGB),
|
||||
DiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_RGB),
|
||||
SpecularColor(0.2, 0.2, 0.2, Quantity_TOC_RGB),
|
||||
EmissiveColor(0.0, 0.0, 0.0, Quantity_TOC_RGB),
|
||||
Shininess (1.0f),
|
||||
Transparency (0.0f),
|
||||
IsDefined (Standard_False) {}
|
||||
|
||||
//! Compare two materials.
|
||||
Standard_Boolean IsEqual (const XCAFDoc_VisMaterialCommon& theOther) const
|
||||
{
|
||||
if (&theOther == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (theOther.IsDefined != IsDefined)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!IsDefined)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return theOther.AmbientTexture == AmbientTexture
|
||||
&& theOther.DiffuseTexture == DiffuseTexture
|
||||
&& theOther.SpecularTexture == SpecularTexture
|
||||
&& theOther.AmbientColor == AmbientColor
|
||||
&& theOther.DiffuseColor == DiffuseColor
|
||||
&& theOther.SpecularColor == SpecularColor
|
||||
&& theOther.EmissiveColor == EmissiveColor
|
||||
&& theOther.Shininess == Shininess
|
||||
&& theOther.Transparency == Transparency;
|
||||
}
|
||||
};
|
||||
|
||||
//! Metallic-roughness PBR material definition.
|
||||
struct XCAFDoc_VisMaterialMetallicRoughness
|
||||
{
|
||||
Handle(Image_Texture) BaseColorTexture; //!< RGB texture for the base color
|
||||
Handle(Image_Texture) MetallicRoughnessTexture; //!< RG texture packing the metallic and roughness properties together
|
||||
Handle(Image_Texture) EmissiveTexture; //!< RGB emissive map controls the color and intensity of the light being emitted by the material
|
||||
Handle(Image_Texture) OcclusionTexture; //!< R occlusion map indicating areas of indirect lighting
|
||||
Handle(Image_Texture) NormalTexture; //!< normal map
|
||||
Quantity_ColorRGBA BaseColor; //!< base color (or scale factor to the texture); [1.0, 1.0, 1.0, 1.0] by default
|
||||
Graphic3d_Vec3 EmissiveFactor; //!< emissive color; [0.0, 0.0, 0.0] by default
|
||||
Standard_ShortReal Metallic; //!< metalness (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
|
||||
Standard_ShortReal Roughness; //!< roughness (or scale factor to the texture) within range [0.0, 1.0]; 1.0 by default
|
||||
Standard_Boolean IsDefined; //!< defined flag; FALSE by default
|
||||
|
||||
//! Empty constructor.
|
||||
XCAFDoc_VisMaterialMetallicRoughness()
|
||||
: BaseColor (1.0f, 1.0f, 1.0f, 1.0f),
|
||||
EmissiveFactor (0.0f, 0.0f, 0.0f),
|
||||
Metallic (0.0f),
|
||||
Roughness (0.0f),
|
||||
IsDefined (Standard_False) {}
|
||||
|
||||
//! Compare two materials.
|
||||
Standard_Boolean IsEqual (const XCAFDoc_VisMaterialMetallicRoughness& theOther) const
|
||||
{
|
||||
if (&theOther == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (theOther.IsDefined != IsDefined)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else if (!IsDefined)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return theOther.BaseColorTexture == BaseColorTexture
|
||||
&& theOther.MetallicRoughnessTexture == MetallicRoughnessTexture
|
||||
&& theOther.EmissiveTexture == EmissiveTexture
|
||||
&& theOther.OcclusionTexture == OcclusionTexture
|
||||
&& theOther.NormalTexture == NormalTexture
|
||||
&& theOther.BaseColor == BaseColor
|
||||
&& theOther.EmissiveFactor == EmissiveFactor
|
||||
&& theOther.Metallic == Metallic
|
||||
&& theOther.Roughness == Roughness;
|
||||
}
|
||||
};
|
||||
|
||||
//! Attribute storing Material definition for visualization purposes.
|
||||
class XCAFDoc_VisMaterial : public TDF_Attribute
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_VisMaterial, TDF_Attribute)
|
||||
public:
|
||||
|
||||
//! Return attribute GUID.
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
//! Find, or create, the Material attribute.
|
||||
Standard_EXPORT static Handle(XCAFDoc_VisMaterial) Set (const TDF_Label& theLabel,
|
||||
const XCAFDoc_VisMaterialMetallicRoughness& theMetRoughnessMat,
|
||||
const XCAFDoc_VisMaterialCommon& theCommonMat);
|
||||
|
||||
//! Find, or create, the Material attribute.
|
||||
static Handle(XCAFDoc_VisMaterial) Set (const TDF_Label& theLabel,
|
||||
const XCAFDoc_VisMaterialMetallicRoughness& theMetRoughnessMat)
|
||||
{
|
||||
return Set (theLabel, theMetRoughnessMat, XCAFDoc_VisMaterialCommon());
|
||||
}
|
||||
|
||||
//! Find, or create, the Material attribute.
|
||||
static Handle(XCAFDoc_VisMaterial) Set (const TDF_Label& theLabel,
|
||||
const XCAFDoc_VisMaterialCommon& theCommonMat)
|
||||
{
|
||||
return Set (theLabel, XCAFDoc_VisMaterialMetallicRoughness(), theCommonMat);
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
Standard_EXPORT XCAFDoc_VisMaterial();
|
||||
|
||||
//! Return TRUE if material definition is empty.
|
||||
bool IsEmpty() const { return !myMetalRoughMat.IsDefined && !myCommonMat.IsDefined; }
|
||||
|
||||
//! Fill in material aspect.
|
||||
Standard_EXPORT void FillMaterialAspect (Graphic3d_MaterialAspect& theAspect) const;
|
||||
|
||||
//! Return TRUE if metal-roughness PBR material is defined.
|
||||
Standard_Boolean HasMetalRougnessMaterial() const { return myMetalRoughMat.IsDefined; }
|
||||
|
||||
//! Return metal-roughness PBR material.
|
||||
const XCAFDoc_VisMaterialMetallicRoughness& MetalRougnessMaterial() const { return myMetalRoughMat; }
|
||||
|
||||
//! Setup metal-roughness PBR material.
|
||||
Standard_EXPORT void SetMetalRougnessMaterial (const XCAFDoc_VisMaterialMetallicRoughness& theMaterial);
|
||||
|
||||
//! Setup undefined metal-roughness PBR material.
|
||||
void UnsetMetalRougnessMaterial() { SetMetalRougnessMaterial (XCAFDoc_VisMaterialMetallicRoughness()); }
|
||||
|
||||
//! Return TRUE if common material is defined.
|
||||
Standard_Boolean HasCommonMaterial() const { return myCommonMat.IsDefined; }
|
||||
|
||||
//! Return common material.
|
||||
const XCAFDoc_VisMaterialCommon& CommonMaterial() const { return myCommonMat; }
|
||||
|
||||
//! Setup common material.
|
||||
Standard_EXPORT void SetCommonMaterial (const XCAFDoc_VisMaterialCommon& theMaterial);
|
||||
|
||||
//! Setup undefined common material.
|
||||
void UnsetCommonMaterial() { SetCommonMaterial (XCAFDoc_VisMaterialCommon()); }
|
||||
|
||||
//! Compare two materials.
|
||||
/** Standard_Boolean IsEqual (const Handle(XCAFDoc_VisMaterial)& theOther) const
|
||||
{
|
||||
return theOther == this
|
||||
|| (theOther->myColor == myColor);
|
||||
}*/
|
||||
|
||||
public: //! @name interface implementation
|
||||
|
||||
//! Return GUID of this attribute type.
|
||||
virtual const Standard_GUID& ID() const Standard_OVERRIDE { return GetID(); }
|
||||
|
||||
//! Restore attribute from specified state.
|
||||
//! @param theWith [in] attribute state to restore (copy into this)
|
||||
Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& theWith) Standard_OVERRIDE;
|
||||
|
||||
//! Create a new empty attribute.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
//! Paste this attribute into another one.
|
||||
//! @param theInto [in/out] target attribute to copy this into
|
||||
//! @param theRelTable [in] relocation table
|
||||
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theInto,
|
||||
const Handle(TDF_RelocationTable)& theRelTable) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
XCAFDoc_VisMaterialMetallicRoughness myMetalRoughMat; //!< metal-roughness material definition
|
||||
XCAFDoc_VisMaterialCommon myCommonMat; //!< common material definition
|
||||
TCollection_AsciiString myId; //!< material identifier
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(XCAFDoc_VisMaterial, TDF_Attribute)
|
||||
|
||||
#endif // _XCAFDoc_VisMaterial_HeaderFile
|
320
src/XCAFDoc/XCAFDoc_VisMaterialTool.cxx
Normal file
320
src/XCAFDoc/XCAFDoc_VisMaterialTool.cxx
Normal file
@@ -0,0 +1,320 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataStd_UAttribute.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_VisMaterialTool, TDF_Attribute)
|
||||
|
||||
static Standard_Boolean XCAFDoc_VisMaterialTool_AutoNaming = Standard_True;
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAutoNaming
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterialTool::SetAutoNaming (Standard_Boolean theIsAutoNaming)
|
||||
{
|
||||
XCAFDoc_VisMaterialTool_AutoNaming = theIsAutoNaming;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AutoNaming
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::AutoNaming()
|
||||
{
|
||||
return XCAFDoc_VisMaterialTool_AutoNaming;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Standard_GUID& XCAFDoc_VisMaterialTool::GetID()
|
||||
{
|
||||
static Standard_GUID THE_VIS_MAT_TOOL_ID ("87B511CE-DA15-4A5E-98AF-E3F46AB5B6E8");
|
||||
return THE_VIS_MAT_TOOL_ID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XCAFDoc_VisMaterialTool) XCAFDoc_VisMaterialTool::Set (const TDF_Label& theLabel)
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterialTool) aTool;
|
||||
if (!theLabel.FindAttribute (XCAFDoc_VisMaterialTool::GetID(), aTool))
|
||||
{
|
||||
aTool = new XCAFDoc_VisMaterialTool();
|
||||
theLabel.AddAttribute (aTool);
|
||||
aTool->myShapeTool = XCAFDoc_DocumentTool::ShapeTool (theLabel);
|
||||
}
|
||||
return aTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_VisMaterialTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XCAFDoc_VisMaterialTool::XCAFDoc_VisMaterialTool()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Handle(XCAFDoc_ShapeTool)& XCAFDoc_VisMaterialTool::ShapeTool()
|
||||
{
|
||||
if (myShapeTool.IsNull())
|
||||
{
|
||||
myShapeTool = XCAFDoc_DocumentTool::ShapeTool (Label());
|
||||
}
|
||||
return myShapeTool;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterialTool::GetMaterial (const TDF_Label& theMatLabel) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aMatAttrib;
|
||||
if (theMatLabel.Father() == Label())
|
||||
{
|
||||
theMatLabel.FindAttribute (XCAFDoc_VisMaterial::GetID(), aMatAttrib);
|
||||
}
|
||||
return aMatAttrib;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
/**Standard_Boolean XCAFDoc_VisMaterialTool::FindMaterial (const Handle(XCAFDoc_VisMaterial)& theMaterial,
|
||||
TDF_Label& theLabel) const
|
||||
{
|
||||
for (TDF_ChildIDIterator aChildIter (Label(), XCAFDoc_VisMaterial::GetID()); aChildIter.More(); aChildIter.Next())
|
||||
{
|
||||
const TDF_Label aLabel = aChildIter.Value()->Label();
|
||||
if (Handle(XCAFDoc_VisMaterial) aMat = GetMaterial (aLabel))
|
||||
{
|
||||
if (aMat->IsEqual (theMaterial))
|
||||
{
|
||||
theLabel = aLabel;
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}*/
|
||||
|
||||
//=======================================================================
|
||||
//function : AddMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TDF_Label XCAFDoc_VisMaterialTool::AddMaterial (const XCAFDoc_VisMaterialMetallicRoughness& theMetRoughnessMat,
|
||||
const XCAFDoc_VisMaterialCommon& theCommonMat) const
|
||||
{
|
||||
TDF_TagSource aTag;
|
||||
TDF_Label aLab = aTag.NewChild (Label());
|
||||
XCAFDoc_VisMaterial::Set (aLab, theMetRoughnessMat, theCommonMat);
|
||||
if (!XCAFDoc_VisMaterialTool_AutoNaming)
|
||||
{
|
||||
return aLab;
|
||||
}
|
||||
|
||||
// set name according to color value
|
||||
/**const NCollection_Vec4<float>& anRgbaF = theColor;
|
||||
const NCollection_Vec4<unsigned int> anRgba (anRgbaF * 255.0f);
|
||||
char aColorHex[32];
|
||||
Sprintf (aColorHex, "%02X%02X%02X%02X", anRgba.r(), anRgba.g(), anRgba.b(), anRgba.a());
|
||||
const TCollection_AsciiString aName = TCollection_AsciiString (Quantity_Color::StringName (theColor.GetRGB().Name()))
|
||||
+ " (#" + aColorHex + ")";
|
||||
TDataStd_Name::Set (aLab, aName);*/
|
||||
|
||||
return aLab;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterialTool::RemoveMaterial (const TDF_Label& theLabel) const
|
||||
{
|
||||
theLabel.ForgetAllAttributes (true);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMaterials
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterialTool::GetMaterials (TDF_LabelSequence& theLabels) const
|
||||
{
|
||||
theLabels.Clear();
|
||||
for (TDF_ChildIDIterator aChildIDIterator (Label(), XCAFDoc_VisMaterial::GetID()); aChildIDIterator.More(); aChildIDIterator.Next())
|
||||
{
|
||||
const TDF_Label aLabel = aChildIDIterator.Value()->Label();
|
||||
if (IsMaterial (aLabel))
|
||||
{
|
||||
theLabels.Append (aLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterialTool::SetShapeMaterial (const TDF_Label& theShapeLabel,
|
||||
const TDF_Label& theMaterialLabel) const
|
||||
{
|
||||
// set reference
|
||||
Handle(TDataStd_TreeNode) aMainNode = TDataStd_TreeNode::Set (theMaterialLabel, XCAFDoc::VisMaterialRefGUID());
|
||||
Handle(TDataStd_TreeNode) aRefNode = TDataStd_TreeNode::Set (theShapeLabel, XCAFDoc::VisMaterialRefGUID());
|
||||
aRefNode->Remove(); // abv: fix against bug in TreeNode::Append()
|
||||
aMainNode->Prepend (aRefNode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterialTool::UnSetShapeMaterial (const TDF_Label& theShapeLabel) const
|
||||
{
|
||||
theShapeLabel.ForgetAttribute (XCAFDoc::VisMaterialRefGUID());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::IsSet (const TDF_Label& theLabel) const
|
||||
{
|
||||
Handle(TDataStd_TreeNode) aNode;
|
||||
return theLabel.FindAttribute (XCAFDoc::VisMaterialRefGUID(), aNode)
|
||||
&& aNode->HasFather();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::GetShapeMaterial (const TDF_Label& theShapeLabel,
|
||||
TDF_Label& theMaterialLabel)
|
||||
{
|
||||
Handle(TDataStd_TreeNode) aNode;
|
||||
if (!theShapeLabel.FindAttribute (XCAFDoc::VisMaterialRefGUID(), aNode)
|
||||
|| !aNode->HasFather())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
theMaterialLabel = aNode->Father()->Label();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterialTool::GetShapeMaterial (const TDF_Label& theShapeLabel)
|
||||
{
|
||||
TDF_Label aMatLabel;
|
||||
return GetShapeMaterial (theShapeLabel, aMatLabel)
|
||||
? GetMaterial (aMatLabel)
|
||||
: Handle(XCAFDoc_VisMaterial)();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::SetShapeMaterial (const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theMaterialLabel)
|
||||
{
|
||||
TDF_Label aShapeLabel;
|
||||
if (!ShapeTool()->Search (theShape, aShapeLabel))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
SetShapeMaterial (aShapeLabel, theMaterialLabel);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::UnSetShapeMaterial (const TopoDS_Shape& theShape)
|
||||
{
|
||||
TDF_Label aShapeLabel;
|
||||
if (!ShapeTool()->Search (theShape, aShapeLabel))
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
UnSetShapeMaterial (aShapeLabel);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::IsSet (const TopoDS_Shape& theShape)
|
||||
{
|
||||
TDF_Label aShapeLabel;
|
||||
return ShapeTool()->Search (theShape, aShapeLabel)
|
||||
&& IsSet (aShapeLabel);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::GetShapeMaterial (const TopoDS_Shape& theShape,
|
||||
TDF_Label& theMaterialLabel)
|
||||
{
|
||||
TDF_Label aShapeLabel;
|
||||
return ShapeTool()->Search (theShape, aShapeLabel)
|
||||
&& GetShapeMaterial (aShapeLabel, theMaterialLabel);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(XCAFDoc_VisMaterial) XCAFDoc_VisMaterialTool::GetShapeMaterial (const TopoDS_Shape& theShape)
|
||||
{
|
||||
TDF_Label aMatLabel;
|
||||
return GetShapeMaterial (theShape, aMatLabel)
|
||||
? GetMaterial (aMatLabel)
|
||||
: Handle(XCAFDoc_VisMaterial)();
|
||||
}
|
165
src/XCAFDoc/XCAFDoc_VisMaterialTool.hxx
Normal file
165
src/XCAFDoc/XCAFDoc_VisMaterialTool.hxx
Normal file
@@ -0,0 +1,165 @@
|
||||
// Copyright (c) 2019 OPEN CASCADE SAS
|
||||
//
|
||||
// This file is part of Open CASCADE Technology software library.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#ifndef _XCAFDoc_VisMaterialTool_HeaderFile
|
||||
#define _XCAFDoc_VisMaterialTool_HeaderFile
|
||||
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
class Quantity_ColorRGBA;
|
||||
class XCAFDoc_ShapeTool;
|
||||
class XCAFDoc_VisMaterial;
|
||||
struct XCAFDoc_VisMaterialMetallicRoughness;
|
||||
struct XCAFDoc_VisMaterialCommon;
|
||||
|
||||
//! Provides tools to store and retrieve attributes (visualization materials) of TopoDS_Shape in and from TDocStd_Document.
|
||||
class XCAFDoc_VisMaterialTool : public TDF_Attribute
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_VisMaterialTool, TDF_Attribute)
|
||||
public:
|
||||
//! Returns current auto-naming mode; TRUE by default.
|
||||
//! If TRUE then for added colors the TDataStd_Name attribute will be automatically added.
|
||||
//! This setting is global.
|
||||
Standard_EXPORT static Standard_Boolean AutoNaming();
|
||||
|
||||
//! See also AutoNaming().
|
||||
Standard_EXPORT static void SetAutoNaming (Standard_Boolean theIsAutoNaming);
|
||||
|
||||
//! Creates (if not exist) ColorTool.
|
||||
Standard_EXPORT static Handle(XCAFDoc_VisMaterialTool) Set (const TDF_Label& L);
|
||||
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
public:
|
||||
|
||||
Standard_EXPORT XCAFDoc_VisMaterialTool();
|
||||
|
||||
//! returns the label under which colors are stored
|
||||
Standard_EXPORT TDF_Label BaseLabel() const { return Label(); }
|
||||
|
||||
//! Returns internal XCAFDoc_ShapeTool tool
|
||||
Standard_EXPORT const Handle(XCAFDoc_ShapeTool)& ShapeTool();
|
||||
|
||||
//! Returns TRUE if Label belongs to a Material Table.
|
||||
Standard_Boolean IsMaterial (const TDF_Label& theLabel) const { return !GetMaterial (theLabel).IsNull(); }
|
||||
|
||||
//! Returns Material defined by specified Label, or NULL if the label is not in Material Table.
|
||||
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetMaterial (const TDF_Label& theMatLabel) const;
|
||||
|
||||
//! Finds Material definition in Material Table and returns its label if found.
|
||||
/*Standard_EXPORT Standard_Boolean FindMaterial (const Handle(XCAFDoc_VisMaterial)& theMaterial,
|
||||
TDF_Label& theLabel) const;*/
|
||||
|
||||
//! Finds a color definition in a colortable and returns its label if found (or Null label else)
|
||||
/** TDF_Label FindColor (const Quantity_ColorRGBA& theColor) const
|
||||
{
|
||||
TDF_Label aLabel;
|
||||
FindColor (theColor, aLabel);
|
||||
return aLabel;
|
||||
}*/
|
||||
|
||||
//! Adds Material definition to a Material Table and returns its Label (returns existing label if the same material is already defined).
|
||||
Standard_EXPORT TDF_Label AddMaterial (const XCAFDoc_VisMaterialMetallicRoughness& theMetRoughnessMat,
|
||||
const XCAFDoc_VisMaterialCommon& theCommonMat) const;
|
||||
|
||||
//! Adds Material definition to a Material Table and returns its Label (returns existing label if the same material is already defined).
|
||||
/*Standard_EXPORT TDF_Label AddUniqueMaterial (const XCAFDoc_VisMaterialMetallicRoughness& theMetRoughnessMat,
|
||||
const XCAFDoc_VisMaterialCommon& theCommonMat) const;*/
|
||||
|
||||
//! Removes Material from the Material Table
|
||||
Standard_EXPORT void RemoveMaterial (const TDF_Label& theLabel) const;
|
||||
|
||||
//! Returns a sequence of Materials currently stored in the Material Table.
|
||||
Standard_EXPORT void GetMaterials (TDF_LabelSequence& Labels) const;
|
||||
|
||||
//! Sets a link with GUID defined by <type> (see
|
||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
//! defined by <colorL>. Color of shape is defined following way
|
||||
//! in dependance with type of color.
|
||||
//! If type of color is XCAFDoc_ColorGen - then this color
|
||||
//! defines default color for surfaces and curves.
|
||||
//! If for shape color with types XCAFDoc_ColorSurf or XCAFDoc_ColorCurv is specified
|
||||
//! then such color overrides generic color.
|
||||
Standard_EXPORT void SetShapeMaterial (const TDF_Label& theShapeLabel,
|
||||
const TDF_Label& theMaterialLabel) const;
|
||||
|
||||
//! Removes a link with GUID defined by <type> (see
|
||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
Standard_EXPORT void UnSetShapeMaterial (const TDF_Label& theShapeLabel) const;
|
||||
|
||||
//! Returns True if label <L> has a color assignment
|
||||
//! of the type <type>
|
||||
Standard_EXPORT Standard_Boolean IsSet (const TDF_Label& L) const;
|
||||
|
||||
//! Returns label with color assigned to <L> as <type>
|
||||
//! Returns False if no such color is assigned
|
||||
Standard_EXPORT static Standard_Boolean GetShapeMaterial (const TDF_Label& theShapeLabel, TDF_Label& theMaterialLabel);
|
||||
|
||||
//! Returns color assigned to <L> as <type>
|
||||
//! Returns False if no such color is assigned
|
||||
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetShapeMaterial (const TDF_Label& theShapeLabel);
|
||||
|
||||
//! Sets a link with GUID defined by <type> (see
|
||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
//! defined by <colorL>
|
||||
//! Returns False if cannot find a label for shape S
|
||||
Standard_EXPORT Standard_Boolean SetShapeMaterial (const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theMaterialLabel);
|
||||
|
||||
//! Removes a link with GUID defined by <type> (see
|
||||
//! XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
//! Returns True if such link existed
|
||||
Standard_EXPORT Standard_Boolean UnSetShapeMaterial (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Returns True if label <L> has a color assignment
|
||||
//! of the type <type>
|
||||
Standard_EXPORT Standard_Boolean IsSet (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Returns label with color assigned to <L> as <type>
|
||||
//! Returns False if no such color is assigned
|
||||
Standard_EXPORT Standard_Boolean GetShapeMaterial (const TopoDS_Shape& theShape, TDF_Label& theMaterialLabel);
|
||||
|
||||
//! Returns color assigned to <L> as <type>
|
||||
//! Returns False if no such color is assigned
|
||||
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetShapeMaterial (const TopoDS_Shape& theShape);
|
||||
|
||||
/// TODO
|
||||
///Standard_EXPORT Standard_Boolean ReverseChainsOfTreeNodes();
|
||||
|
||||
public:
|
||||
|
||||
//! Returns GUID of this attribute type.
|
||||
virtual const Standard_GUID& ID() const Standard_OVERRIDE { return GetID(); }
|
||||
|
||||
//! Does nothing.
|
||||
virtual void Restore (const Handle(TDF_Attribute)& ) Standard_OVERRIDE {}
|
||||
|
||||
//! Creates new instance of this tool.
|
||||
virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE { return new XCAFDoc_VisMaterialTool(); }
|
||||
|
||||
//! Does nothing.
|
||||
virtual void Paste (const Handle(TDF_Attribute)& ,
|
||||
const Handle(TDF_RelocationTable)& ) const Standard_OVERRIDE {}
|
||||
|
||||
private:
|
||||
|
||||
Handle(XCAFDoc_ShapeTool) myShapeTool;
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(XCAFDoc_VisMaterialTool, TDF_Attribute)
|
||||
|
||||
#endif // _XCAFDoc_VisMaterialTool_HeaderFile
|
@@ -13,8 +13,8 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <XCAFPrs.hxx>
|
||||
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <TColStd_HSequenceOfExtendedString.hxx>
|
||||
#include <TDF_AttributeSequence.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
@@ -29,12 +29,33 @@
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_GraphNode.hxx>
|
||||
#include <XCAFDoc_LayerTool.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFPrs.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
|
||||
static Standard_Boolean viewnameMode = Standard_False;
|
||||
|
||||
//! Fill colors of XCAFPrs_Style structure.
|
||||
static void fillStyleColors (XCAFPrs_Style& theStyle,
|
||||
const Handle(XCAFDoc_ColorTool)& theTool,
|
||||
const TDF_Label& theLabel)
|
||||
{
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (theTool->GetColor (theLabel, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
theStyle.SetColorCurv (aColor.GetRGB());
|
||||
theStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (theTool->GetColor (theLabel, XCAFDoc_ColorSurf, aColor))
|
||||
{
|
||||
theStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (theTool->GetColor (theLabel, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
theStyle.SetColorCurv (aColor.GetRGB());
|
||||
}
|
||||
}
|
||||
|
||||
static Standard_Boolean getShapesOfSHUO (TopLoc_IndexedMapOfLocation& theaPrevLocMap,
|
||||
const Handle(XCAFDoc_ShapeTool)& theSTool,
|
||||
const TDF_Label& theSHUOlab,
|
||||
@@ -128,6 +149,8 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
|
||||
// collect settings on subshapes
|
||||
Handle(XCAFDoc_ColorTool) aColorTool = XCAFDoc_DocumentTool::ColorTool(theLabel);
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (theLabel);
|
||||
|
||||
TDF_LabelSequence aLabSeq;
|
||||
XCAFDoc_ShapeTool::GetSubShapes (theLabel, aLabSeq);
|
||||
// and add the shape itself
|
||||
@@ -136,12 +159,14 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
{
|
||||
const TDF_Label& aLabel = aLabIter.Value();
|
||||
XCAFPrs_Style aStyle;
|
||||
aStyle.SetVisibility (aColorTool->IsVisible (aLabel));
|
||||
aStyle.SetMaterial (aMatTool->GetShapeMaterial (aLabel));
|
||||
|
||||
Standard_Boolean isVisible = aColorTool->IsVisible (aLabel);
|
||||
if (isVisible)
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames;
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (aLabel);
|
||||
if (aStyle.IsVisible())
|
||||
{
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (aLabel);
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerTool->GetLayers (aLabel, aLayerNames);
|
||||
Standard_Integer aNbHidden = 0;
|
||||
for (TColStd_HSequenceOfExtendedString::Iterator aLayerIter (*aLayerNames); aLayerIter.More(); aLayerIter.Next())
|
||||
@@ -152,54 +177,38 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
++aNbHidden;
|
||||
}
|
||||
}
|
||||
isVisible = aNbHidden == 0
|
||||
|| aNbHidden != aLayerNames->Length();
|
||||
aStyle.SetVisibility (aNbHidden == 0
|
||||
|| aNbHidden != aLayerNames->Length());
|
||||
}
|
||||
|
||||
if (!isVisible)
|
||||
if (aColorTool->IsColorByLayer (aLabel))
|
||||
{
|
||||
aStyle.SetVisibility (Standard_False);
|
||||
Quantity_ColorRGBA aLayerColor = theLayerColor;
|
||||
if (aLayerNames.IsNull())
|
||||
{
|
||||
aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerTool->GetLayers (aLabel, aLayerNames);
|
||||
}
|
||||
if (aLayerNames->Length() == 1)
|
||||
{
|
||||
TDF_Label aLayer = aLayerTool->FindLayer (aLayerNames->First());
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLayer, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
aLayerColor = aColor;
|
||||
}
|
||||
}
|
||||
|
||||
aStyle.SetColorCurv (aLayerColor.GetRGB());
|
||||
aStyle.SetColorSurf (aLayerColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aColorTool->IsColorByLayer(aLabel))
|
||||
{
|
||||
Quantity_ColorRGBA aLayerColor = theLayerColor;
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (aLabel);
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerTool->GetLayers (aLabel, aLayerNames);
|
||||
if (aLayerNames->Length() == 1)
|
||||
{
|
||||
TDF_Label aLayer = aLayerTool->FindLayer (aLayerNames->First());
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLayer, XCAFDoc_ColorGen, aColor))
|
||||
aLayerColor = aColor;
|
||||
}
|
||||
|
||||
aStyle.SetColorCurv (aLayerColor.GetRGB());
|
||||
aStyle.SetColorSurf (aLayerColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorSurf, aColor))
|
||||
{
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aLabel, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
aStyle.SetColorCurv (aColor.GetRGB());
|
||||
}
|
||||
}
|
||||
fillStyleColors (aStyle, aColorTool, aLabel);
|
||||
}
|
||||
|
||||
// PTV try to set color from SHUO structure
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = aColorTool->ShapeTool();
|
||||
const Handle(XCAFDoc_ShapeTool)& aShapeTool = aColorTool->ShapeTool();
|
||||
if (aShapeTool->IsComponent (aLabel))
|
||||
{
|
||||
TDF_AttributeSequence aShuoAttribSeq;
|
||||
@@ -222,31 +231,11 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
}
|
||||
|
||||
Quantity_ColorRGBA aColor;
|
||||
XCAFPrs_Style aShuoStyle;
|
||||
if (!aColorTool->IsVisible (aShuolab))
|
||||
{
|
||||
aShuoStyle.SetVisibility (Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aColorTool->GetColor (aShuolab, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
aShuoStyle.SetColorCurv (aColor.GetRGB());
|
||||
aShuoStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aShuolab, XCAFDoc_ColorSurf, aColor))
|
||||
{
|
||||
aShuoStyle.SetColorSurf (aColor);
|
||||
}
|
||||
if (aColorTool->GetColor (aShuolab, XCAFDoc_ColorCurv, aColor))
|
||||
{
|
||||
aShuoStyle.SetColorCurv (aColor.GetRGB());
|
||||
}
|
||||
}
|
||||
if (!aShuoStyle.IsSetColorCurv()
|
||||
&& !aShuoStyle.IsSetColorSurf()
|
||||
&& aShuoStyle.IsVisible())
|
||||
aShuoStyle.SetMaterial (aMatTool->GetShapeMaterial (aShuolab));
|
||||
aShuoStyle.SetVisibility(aColorTool->IsVisible (aShuolab));
|
||||
fillStyleColors (aShuoStyle, aColorTool, aShuolab);
|
||||
if (aShuoStyle.IsEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -293,9 +282,7 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
}
|
||||
|
||||
if (!aStyle.IsSetColorCurv()
|
||||
&& !aStyle.IsSetColorSurf()
|
||||
&& aStyle.IsVisible())
|
||||
if (aStyle.IsEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Graphic3d_AspectFillArea3d.hxx>
|
||||
#include <Graphic3d_AspectLine3d.hxx>
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Prs3d_Drawer.hxx>
|
||||
#include <Prs3d_DimensionAspect.hxx>
|
||||
#include <Prs3d_IsoAspect.hxx>
|
||||
@@ -37,9 +38,36 @@
|
||||
#include <XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFPrs_AISObject,AIS_ColoredShape)
|
||||
|
||||
namespace
|
||||
{
|
||||
//! Texture holder.
|
||||
class XCAFPrs_Texture : public Graphic3d_Texture2Dmanual
|
||||
{
|
||||
DEFINE_STANDARD_RTTI_INLINE(XCAFPrs_Texture, Graphic3d_Texture2Dmanual)
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
explicit XCAFPrs_Texture (const Image_Texture& theImageSource,
|
||||
const Graphic3d_TextureUnit theUnit)
|
||||
: Graphic3d_Texture2Dmanual (""),
|
||||
myImageSource (theImageSource)
|
||||
{
|
||||
if (!myImageSource.TextureId().IsEmpty())
|
||||
{
|
||||
myTexId = myImageSource.TextureId();
|
||||
}
|
||||
myParams->SetTextureUnit (theUnit);
|
||||
}
|
||||
|
||||
//! Image reader.
|
||||
virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE { return myImageSource.ReadImage(); }
|
||||
private:
|
||||
Image_Texture myImageSource;
|
||||
};
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFPrs_AISObject
|
||||
//purpose :
|
||||
@@ -139,10 +167,7 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
// Getting default colors
|
||||
XCAFPrs_Style aDefStyle;
|
||||
DefaultStyle (aDefStyle);
|
||||
Quantity_Color aColorCurv = aDefStyle.GetColorCurv();
|
||||
Quantity_ColorRGBA aColorSurf = aDefStyle.GetColorSurfRGBA();
|
||||
|
||||
SetColors (myDrawer, aColorCurv, aColorSurf);
|
||||
setStyleToDrawer (myDrawer, aDefStyle, aDefStyle, myDrawer->ShadingAspect()->Aspect()->FrontMaterial());
|
||||
|
||||
// collect sub-shapes with the same style into compounds
|
||||
BRep_Builder aBuilder;
|
||||
@@ -184,11 +209,17 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
myShapeColors.Bind (aShapeCur, aDrawer);
|
||||
const XCAFPrs_Style& aStyle = aStyleGroupIter.Key();
|
||||
aDrawer->SetHidden (!aStyle.IsVisible());
|
||||
|
||||
aColorCurv = aStyle.IsSetColorCurv() ? aStyle.GetColorCurv() : aDefStyle.GetColorCurv();
|
||||
aColorSurf = aStyle.IsSetColorSurf() ? aStyle.GetColorSurfRGBA() : aDefStyle.GetColorSurfRGBA();
|
||||
|
||||
SetColors (aDrawer, aColorCurv, aColorSurf);
|
||||
if (!aStyle.Material().IsNull()
|
||||
&& !aStyle.Material()->IsEmpty())
|
||||
{
|
||||
aDrawer->SetOwnMaterial();
|
||||
}
|
||||
if (aStyle.IsSetColorSurf()
|
||||
|| aStyle.IsSetColorCurv())
|
||||
{
|
||||
aDrawer->SetOwnColor (Quantity_Color());
|
||||
}
|
||||
setStyleToDrawer (aDrawer, aStyle, aDefStyle, myDrawer->ShadingAspect()->Aspect()->FrontMaterial());
|
||||
}
|
||||
aStyleGroups.Clear();
|
||||
}
|
||||
@@ -243,83 +274,91 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& the
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColors
|
||||
//function : setStyleToDrawer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFPrs_AISObject::SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_ColorRGBA& theColorSurf)
|
||||
void XCAFPrs_AISObject::setStyleToDrawer (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const XCAFPrs_Style& theStyle,
|
||||
const XCAFPrs_Style& theDefStyle,
|
||||
const Graphic3d_MaterialAspect& theDefMaterial)
|
||||
{
|
||||
if (!theDrawer->HasOwnShadingAspect())
|
||||
theDrawer->SetupOwnShadingAspect();
|
||||
theDrawer->SetOwnLineAspects();
|
||||
|
||||
Quantity_ColorRGBA aSurfColor = theDefStyle.GetColorSurfRGBA();
|
||||
Quantity_Color aCurvColor = theDefStyle.GetColorCurv();
|
||||
Graphic3d_MaterialAspect aMaterial = theDefMaterial;
|
||||
const Handle(XCAFDoc_VisMaterial)& anXMat = !theStyle.Material().IsNull() ? theStyle.Material() : theDefStyle.Material();
|
||||
if (!anXMat.IsNull()
|
||||
&& !anXMat->IsEmpty())
|
||||
{
|
||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
if (theDrawer->HasLink())
|
||||
anXMat->FillMaterialAspect (aMaterial);
|
||||
aSurfColor = Quantity_ColorRGBA (aMaterial.Color(), aMaterial.Alpha());
|
||||
aCurvColor = aMaterial.Color();
|
||||
|
||||
Handle(Image_Texture) aColorTexture, aNormTexture;
|
||||
if (!anXMat->CommonMaterial().DiffuseTexture.IsNull())
|
||||
{
|
||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
||||
aColorTexture = anXMat->CommonMaterial().DiffuseTexture;
|
||||
}
|
||||
else if (!anXMat->MetalRougnessMaterial().BaseColorTexture.IsNull())
|
||||
{
|
||||
aColorTexture = anXMat->MetalRougnessMaterial().BaseColorTexture;
|
||||
}
|
||||
else if (!anXMat->CommonMaterial().AmbientTexture.IsNull())
|
||||
{
|
||||
aColorTexture = anXMat->CommonMaterial().AmbientTexture;
|
||||
}
|
||||
|
||||
if (!anXMat->MetalRougnessMaterial().NormalTexture.IsNull())
|
||||
{
|
||||
aNormTexture = anXMat->MetalRougnessMaterial().NormalTexture;
|
||||
}
|
||||
|
||||
Standard_Integer aNbTextures = 0;
|
||||
if (!aColorTexture.IsNull())
|
||||
{
|
||||
++aNbTextures;
|
||||
}
|
||||
if (!aNormTexture.IsNull())
|
||||
{
|
||||
//++aNbTextures;
|
||||
}
|
||||
if (aNbTextures != 0)
|
||||
{
|
||||
Handle(Graphic3d_TextureSet) aTextureSet = new Graphic3d_TextureSet (aNbTextures);
|
||||
Standard_Integer aTextureIndex = 0;
|
||||
if (!aColorTexture.IsNull())
|
||||
{
|
||||
aTextureSet->SetValue (aTextureIndex++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_BaseColor));
|
||||
}
|
||||
if (!aNormTexture.IsNull())
|
||||
{
|
||||
//aTextureSet->SetValue (aTextureIndex++, new XCAFPrs_Texture (*aColorTexture, Graphic3d_TextureUnit_Normal));
|
||||
}
|
||||
theDrawer->ShadingAspect()->Aspect()->SetTextureSet (aTextureSet);
|
||||
theDrawer->ShadingAspect()->Aspect()->SetTextureMapOn (true);
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnLineAspect())
|
||||
if (theStyle.IsSetColorSurf())
|
||||
{
|
||||
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
|
||||
}
|
||||
aSurfColor = theStyle.GetColorSurfRGBA();
|
||||
aMaterial.SetColor (aSurfColor.GetRGB());
|
||||
aMaterial.SetAlpha (aSurfColor.Alpha());
|
||||
}
|
||||
if (!theDrawer->HasOwnWireAspect())
|
||||
if (theStyle.IsSetColorCurv())
|
||||
{
|
||||
theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnUIsoAspect())
|
||||
{
|
||||
theDrawer->SetUIsoAspect (new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->UIsoAspect()->Aspect() = *theDrawer->Link()->UIsoAspect()->Aspect();
|
||||
theDrawer->UIsoAspect()->SetNumber (theDrawer->Link()->UIsoAspect()->Number());
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnVIsoAspect())
|
||||
{
|
||||
theDrawer->SetVIsoAspect (new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->VIsoAspect()->Aspect() = *theDrawer->Link()->VIsoAspect()->Aspect();
|
||||
theDrawer->VIsoAspect()->SetNumber (theDrawer->Link()->VIsoAspect()->Number());
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnFreeBoundaryAspect())
|
||||
{
|
||||
theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (!theDrawer->HasOwnUnFreeBoundaryAspect())
|
||||
{
|
||||
theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
|
||||
}
|
||||
aCurvColor = theStyle.GetColorCurv();
|
||||
}
|
||||
|
||||
theDrawer->UnFreeBoundaryAspect()->SetColor (theColorCurv);
|
||||
theDrawer->FreeBoundaryAspect()->SetColor (theColorCurv);
|
||||
theDrawer->WireAspect()->SetColor (theColorCurv);
|
||||
theDrawer->UnFreeBoundaryAspect()->SetColor (aCurvColor);
|
||||
theDrawer->FreeBoundaryAspect()->SetColor (aCurvColor);
|
||||
theDrawer->WireAspect()->SetColor (aCurvColor);
|
||||
|
||||
Graphic3d_MaterialAspect aMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
|
||||
aMaterial.SetColor (theColorSurf.GetRGB());
|
||||
aMaterial.SetAlpha (theColorSurf.Alpha());
|
||||
theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (theColorSurf);
|
||||
theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aSurfColor);
|
||||
theDrawer->ShadingAspect()->Aspect()->SetFrontMaterial (aMaterial);
|
||||
theDrawer->UIsoAspect()->SetColor (theColorSurf.GetRGB());
|
||||
theDrawer->VIsoAspect()->SetColor (theColorSurf.GetRGB());
|
||||
theDrawer->UIsoAspect()->SetColor (aSurfColor.GetRGB());
|
||||
theDrawer->VIsoAspect()->SetColor (aSurfColor.GetRGB());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -341,17 +380,25 @@ void XCAFPrs_AISObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial
|
||||
XCAFPrs_Style aDefStyle;
|
||||
DefaultStyle (aDefStyle);
|
||||
setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
|
||||
SetColors (myDrawer, aDefStyle.GetColorCurv(), aDefStyle.GetColorSurf());
|
||||
setStyleToDrawer (myDrawer, aDefStyle, aDefStyle, myDrawer->ShadingAspect()->Aspect()->FrontMaterial());
|
||||
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||
if (aDrawer->HasOwnMaterial())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// take current color
|
||||
const Quantity_Color aColorCurv = aDrawer->WireAspect()->Aspect()->Color();
|
||||
const Quantity_ColorRGBA aSurfColor = aDrawer->ShadingAspect()->Aspect()->InteriorColorRGBA();
|
||||
|
||||
// SetColors() will take the material from myDrawer
|
||||
SetColors (aDrawer, aColorCurv, aSurfColor);
|
||||
if (aDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
// take current color
|
||||
const Quantity_ColorRGBA aSurfColor = aDrawer->ShadingAspect()->Aspect()->InteriorColorRGBA();
|
||||
Graphic3d_MaterialAspect aMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
|
||||
aMaterial.SetColor (aSurfColor.GetRGB());
|
||||
aMaterial.SetAlpha (aSurfColor.Alpha());
|
||||
aDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aSurfColor);
|
||||
aDrawer->ShadingAspect()->Aspect()->SetFrontMaterial (aMaterial);
|
||||
}
|
||||
}
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
@@ -57,21 +57,19 @@ protected:
|
||||
const Handle(Prs3d_Presentation)& thePresentation,
|
||||
const Standard_Integer theMode) Standard_OVERRIDE;
|
||||
|
||||
//! Set colors to drawer
|
||||
Standard_EXPORT void SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_ColorRGBA& theColorSurf);
|
||||
|
||||
//! Set colors to drawer
|
||||
void SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_Color& theColorSurf) { SetColors (theDrawer, theColorCurv, Quantity_ColorRGBA (theColorSurf)); }
|
||||
|
||||
//! Fills out a default style object which is used when styles are
|
||||
//! not explicitly defined in the document.
|
||||
//! By default, the style uses white color for curves and surfaces.
|
||||
Standard_EXPORT virtual void DefaultStyle (XCAFPrs_Style& theStyle) const;
|
||||
|
||||
protected:
|
||||
|
||||
//! Assign style to drawer.
|
||||
static void setStyleToDrawer (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const XCAFPrs_Style& theStyle,
|
||||
const XCAFPrs_Style& theDefStyle,
|
||||
const Graphic3d_MaterialAspect& theDefMaterial);
|
||||
|
||||
protected:
|
||||
|
||||
TDF_Label myLabel; //!< label pointing onto the shape
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Quantity_ColorRGBAHasher.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
|
||||
//! Represents a set of styling settings applicable to a (sub)shape
|
||||
class XCAFPrs_Style
|
||||
@@ -31,6 +32,21 @@ public:
|
||||
//! Empty constructor - colors are unset, visibility is TRUE.
|
||||
Standard_EXPORT XCAFPrs_Style();
|
||||
|
||||
//! Return TRUE if style is empty - does not override any properties.
|
||||
Standard_Boolean IsEmpty() const
|
||||
{
|
||||
return !myHasColorSurf
|
||||
&& !myHasColorCurv
|
||||
&& myMaterial.IsNull()
|
||||
&& myIsVisible;
|
||||
}
|
||||
|
||||
//! Return material.
|
||||
const Handle(XCAFDoc_VisMaterial)& Material() const { return myMaterial; }
|
||||
|
||||
//! Set material.
|
||||
void SetMaterial (const Handle(XCAFDoc_VisMaterial)& theMaterial) { myMaterial = theMaterial; }
|
||||
|
||||
//! Return TRUE if surface color has been defined.
|
||||
Standard_Boolean IsSetColorSurf() const { return myHasColorSurf; }
|
||||
|
||||
@@ -82,6 +98,7 @@ public:
|
||||
|
||||
return myHasColorSurf == theOther.myHasColorSurf
|
||||
&& myHasColorCurv == theOther.myHasColorCurv
|
||||
&& myMaterial == theOther.myMaterial
|
||||
&& (!myHasColorSurf || myColorSurf == theOther.myColorSurf)
|
||||
&& (!myHasColorCurv || myColorCurv == theOther.myColorCurv);
|
||||
}
|
||||
@@ -112,6 +129,10 @@ public:
|
||||
{
|
||||
aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorCurv, theUpperBound);
|
||||
}
|
||||
if (!theStyle.myMaterial.IsNull())
|
||||
{
|
||||
aHashCode = aHashCode ^ ::HashCode (theStyle.myMaterial, theUpperBound);
|
||||
}
|
||||
return ::HashCode (aHashCode, theUpperBound);
|
||||
}
|
||||
|
||||
@@ -126,6 +147,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) myMaterial;
|
||||
Quantity_ColorRGBA myColorSurf;
|
||||
Quantity_Color myColorCurv;
|
||||
Standard_Boolean myHasColorSurf;
|
||||
|
Reference in New Issue
Block a user