mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Compare commits
1 Commits
CR29632_74
...
CR0-Intera
Author | SHA1 | Date | |
---|---|---|---|
|
961713db52 |
@@ -26,7 +26,6 @@ public:
|
||||
//! Default constructor.
|
||||
AIS_ColoredDrawer (const Handle(Prs3d_Drawer)& theLink)
|
||||
: myIsHidden (false),
|
||||
myHasOwnMaterial(false),
|
||||
myHasOwnColor (false),
|
||||
myHasOwnTransp(false),
|
||||
myHasOwnWidth (false)
|
||||
@@ -37,10 +36,6 @@ 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; }
|
||||
@@ -56,7 +51,6 @@ public:
|
||||
public: //! @name list of overridden properties
|
||||
|
||||
bool myIsHidden;
|
||||
bool myHasOwnMaterial;
|
||||
bool myHasOwnColor;
|
||||
bool myHasOwnTransp;
|
||||
bool myHasOwnWidth;
|
||||
|
@@ -333,11 +333,7 @@ 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());
|
||||
|
@@ -204,7 +204,6 @@ void BinMDataStd_NamedDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
if(S.IsNull()) return;
|
||||
// Standard_Integer i=0;
|
||||
|
||||
S->LoadDeferredData();
|
||||
if(S->HasIntegers() && !S->GetIntegersContainer().IsEmpty()) {
|
||||
theTarget.PutInteger(1) << S->GetIntegersContainer().Extent(); //dim
|
||||
TColStd_DataMapIteratorOfDataMapOfStringInteger itr(S->GetIntegersContainer());
|
||||
|
@@ -41,8 +41,6 @@
|
||||
#include <BinMXCAFDoc_ShapeToolDriver.hxx>
|
||||
#include <BinMXCAFDoc_ViewDriver.hxx>
|
||||
#include <BinMXCAFDoc_ViewToolDriver.hxx>
|
||||
#include <BinMXCAFDoc_VisMaterialDriver.hxx>
|
||||
#include <BinMXCAFDoc_VisMaterialToolDriver.hxx>
|
||||
#include <BinMXCAFDoc_VolumeDriver.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
@@ -79,7 +77,6 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_DimensionDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_DimTolDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_MaterialDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_VisMaterialDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBalloonDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
|
||||
@@ -91,7 +88,6 @@ void BinMXCAFDoc::AddDrivers(const Handle(BinMDF_ADriverTable)& theDriverTable,
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_ShapeToolDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_DimTolToolDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_MaterialToolDriver(theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_VisMaterialToolDriver(theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_NotesToolDriver (theMsgDrv));
|
||||
theDriverTable->AddDriver( new BinMXCAFDoc_ViewToolDriver (theMsgDrv));
|
||||
}
|
||||
|
@@ -1,245 +0,0 @@
|
||||
// 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 <BinMXCAFDoc_VisMaterialDriver.hxx>
|
||||
|
||||
#include <BinObjMgt_Persistent.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_VisMaterialDriver, BinMDF_ADriver)
|
||||
|
||||
//! Encode alpha mode into character.
|
||||
static Standard_Byte alphaModeToChar (Graphic3d_AlphaMode theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_AlphaMode_Opaque: return 'O';
|
||||
case Graphic3d_AlphaMode_Mask: return 'M';
|
||||
case Graphic3d_AlphaMode_Blend: return 'B';
|
||||
case Graphic3d_AlphaMode_BlendAuto: return 'A';
|
||||
}
|
||||
return 'A';
|
||||
}
|
||||
|
||||
//! Decode alpha mode from character.
|
||||
static Graphic3d_AlphaMode alphaModeFromChar (Standard_Byte theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case 'O': return Graphic3d_AlphaMode_Opaque;
|
||||
case 'M': return Graphic3d_AlphaMode_Mask;
|
||||
case 'B': return Graphic3d_AlphaMode_Blend;
|
||||
case 'A': return Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
return Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
|
||||
//! Encode vec3.
|
||||
static void writeVec3 (BinObjMgt_Persistent& theTarget,
|
||||
const Graphic3d_Vec3& theVec3)
|
||||
{
|
||||
theTarget.PutShortReal (theVec3[0]);
|
||||
theTarget.PutShortReal (theVec3[1]);
|
||||
theTarget.PutShortReal (theVec3[2]);
|
||||
}
|
||||
|
||||
//! Encode vec4.
|
||||
static void writeVec4 (BinObjMgt_Persistent& theTarget,
|
||||
const Graphic3d_Vec4& theVec4)
|
||||
{
|
||||
theTarget.PutShortReal (theVec4[0]);
|
||||
theTarget.PutShortReal (theVec4[1]);
|
||||
theTarget.PutShortReal (theVec4[2]);
|
||||
theTarget.PutShortReal (theVec4[3]);
|
||||
}
|
||||
|
||||
//! Decode vec3.
|
||||
static void readVec3 (const BinObjMgt_Persistent& theSource,
|
||||
Graphic3d_Vec3& theVec3)
|
||||
{
|
||||
theSource.GetShortReal (theVec3[0]);
|
||||
theSource.GetShortReal (theVec3[1]);
|
||||
theSource.GetShortReal (theVec3[2]);
|
||||
}
|
||||
|
||||
//! Decode vec3.
|
||||
static void readColor (const BinObjMgt_Persistent& theSource,
|
||||
Quantity_Color& theColor)
|
||||
{
|
||||
Graphic3d_Vec3 aVec3;
|
||||
readVec3 (theSource, aVec3);
|
||||
theColor = Quantity_Color (aVec3);
|
||||
}
|
||||
|
||||
//! Decode vec4.
|
||||
static void readColor (const BinObjMgt_Persistent& theSource,
|
||||
Quantity_ColorRGBA& theColor)
|
||||
{
|
||||
Graphic3d_Vec4 aVec4;
|
||||
theSource.GetShortReal (aVec4[0]);
|
||||
theSource.GetShortReal (aVec4[1]);
|
||||
theSource.GetShortReal (aVec4[2]);
|
||||
theSource.GetShortReal (aVec4[3]);
|
||||
theColor = Quantity_ColorRGBA (aVec4);
|
||||
}
|
||||
|
||||
//! Encode texture path.
|
||||
static void writeTexture (BinObjMgt_Persistent& theTarget,
|
||||
const Handle(Image_Texture)& theImage)
|
||||
{
|
||||
theTarget.PutAsciiString (!theImage.IsNull()
|
||||
&& !theImage->FilePath().IsEmpty()
|
||||
&& theImage->FileOffset() == -1
|
||||
? theImage->FilePath()
|
||||
: "");
|
||||
}
|
||||
|
||||
//! Decode texture path.
|
||||
static void readTexture (const BinObjMgt_Persistent& theSource,
|
||||
Handle(Image_Texture)& theTexture)
|
||||
{
|
||||
TCollection_AsciiString aPath;
|
||||
theSource.GetAsciiString (aPath);
|
||||
if (!aPath.IsEmpty())
|
||||
{
|
||||
theTexture = new Image_Texture (aPath);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_VisMaterialDriver::BinMXCAFDoc_VisMaterialDriver (const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_VisMaterial)->Name())
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_VisMaterialDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_VisMaterial();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_VisMaterialDriver::Paste (const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& /*theRelocTable*/) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theTarget);
|
||||
Standard_Byte aVerMaj = 0, aVerMin = 0;
|
||||
theSource.GetByte (aVerMaj);
|
||||
theSource.GetByte (aVerMin);
|
||||
if (aVerMaj < 1 || aVerMaj > MaterialVersionMajor)
|
||||
{
|
||||
myMessageDriver->Send (TCollection_AsciiString ("Skipping XCAFDoc_VisMaterial of unknown version ")
|
||||
+ Standard_Integer(aVerMaj) + "." + Standard_Integer(aVerMin)
|
||||
+ " (supported version: " + Standard_Integer(MaterialVersionMajor) + "." + Standard_Integer(MaterialVersionMinor) + ")");
|
||||
return false;
|
||||
}
|
||||
|
||||
Standard_Byte isDoubleSided = 0, anAlphaMode = 0;
|
||||
Standard_ShortReal anAlphaCutOff = 0.5f;
|
||||
theSource.GetByte (isDoubleSided);
|
||||
theSource.GetByte (anAlphaMode);
|
||||
theSource.GetShortReal (anAlphaCutOff);
|
||||
aMat->SetDoubleSided (isDoubleSided == '1');
|
||||
aMat->SetAlphaMode (alphaModeFromChar (anAlphaMode), anAlphaCutOff);
|
||||
|
||||
bool hasPbrMat = false;
|
||||
theSource.GetBoolean (hasPbrMat);
|
||||
if (hasPbrMat)
|
||||
{
|
||||
XCAFDoc_VisMaterialPBR aPbrMat;
|
||||
aPbrMat.IsDefined = true;
|
||||
readColor (theSource, aPbrMat.BaseColor);
|
||||
readVec3 (theSource, aPbrMat.EmissiveFactor);
|
||||
theSource.GetShortReal (aPbrMat.Metallic);
|
||||
theSource.GetShortReal (aPbrMat.Roughness);
|
||||
readTexture (theSource, aPbrMat.BaseColorTexture);
|
||||
readTexture (theSource, aPbrMat.MetallicRoughnessTexture);
|
||||
readTexture (theSource, aPbrMat.EmissiveTexture);
|
||||
readTexture (theSource, aPbrMat.OcclusionTexture);
|
||||
readTexture (theSource, aPbrMat.NormalTexture);
|
||||
aMat->SetPbrMaterial (aPbrMat);
|
||||
}
|
||||
|
||||
bool hasComMat = false;
|
||||
theSource.GetBoolean (hasComMat);
|
||||
if (hasComMat)
|
||||
{
|
||||
XCAFDoc_VisMaterialCommon aComMat;
|
||||
aComMat.IsDefined = true;
|
||||
readColor (theSource, aComMat.AmbientColor);
|
||||
readColor (theSource, aComMat.DiffuseColor);
|
||||
readColor (theSource, aComMat.SpecularColor);
|
||||
readColor (theSource, aComMat.EmissiveColor);
|
||||
theSource.GetShortReal (aComMat.Shininess);
|
||||
theSource.GetShortReal (aComMat.Transparency);
|
||||
readTexture (theSource, aComMat.DiffuseTexture);
|
||||
aMat->SetCommonMaterial (aComMat);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_VisMaterialDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theSource);
|
||||
theTarget.PutByte (MaterialVersionMajor);
|
||||
theTarget.PutByte (MaterialVersionMinor);
|
||||
|
||||
theTarget.PutByte (aMat->IsDoubleSided() ? '1' : '0');
|
||||
theTarget.PutByte (alphaModeToChar (aMat->AlphaMode()));
|
||||
theTarget.PutShortReal (aMat->AlphaCutOff());
|
||||
|
||||
theTarget.PutBoolean (aMat->HasPbrMaterial());
|
||||
if (aMat->HasPbrMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialPBR& aPbrMat = aMat->PbrMaterial();
|
||||
writeVec4 (theTarget, aPbrMat.BaseColor);
|
||||
writeVec3 (theTarget, aPbrMat.EmissiveFactor);
|
||||
theTarget.PutShortReal (aPbrMat.Metallic);
|
||||
theTarget.PutShortReal (aPbrMat.Roughness);
|
||||
writeTexture (theTarget, aPbrMat.BaseColorTexture);
|
||||
writeTexture (theTarget, aPbrMat.MetallicRoughnessTexture);
|
||||
writeTexture (theTarget, aPbrMat.EmissiveTexture);
|
||||
writeTexture (theTarget, aPbrMat.OcclusionTexture);
|
||||
writeTexture (theTarget, aPbrMat.NormalTexture);
|
||||
}
|
||||
|
||||
theTarget.PutBoolean (aMat->HasCommonMaterial());
|
||||
if (aMat->HasCommonMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialCommon& aComMat = aMat->CommonMaterial();
|
||||
writeVec3 (theTarget, aComMat.AmbientColor);
|
||||
writeVec3 (theTarget, aComMat.DiffuseColor);
|
||||
writeVec3 (theTarget, aComMat.SpecularColor);
|
||||
writeVec3 (theTarget, aComMat.EmissiveColor);
|
||||
theTarget.PutShortReal (aComMat.Shininess);
|
||||
theTarget.PutShortReal (aComMat.Transparency);
|
||||
writeTexture (theTarget, aComMat.DiffuseTexture);
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
// 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 _BinMXCAFDoc_VisMaterialDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_VisMaterialDriver_HeaderFile
|
||||
|
||||
#include <BinMDF_ADriver.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <BinObjMgt_RRelocationTable.hxx>
|
||||
#include <BinObjMgt_SRelocationTable.hxx>
|
||||
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_VisMaterialDriver, BinMDF_ADriver)
|
||||
|
||||
//! Binary persistence driver for XCAFDoc_VisMaterial attribute.
|
||||
class BinMXCAFDoc_VisMaterialDriver : public BinMDF_ADriver
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_VisMaterialDriver, BinMDF_ADriver)
|
||||
|
||||
//! Persistence version (major for breaking changes, minor for adding new fields at end).
|
||||
enum { MaterialVersionMajor = 1, MaterialVersionMinor = 0 };
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT BinMXCAFDoc_VisMaterialDriver (const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
//! Create new instance of XCAFDoc_VisMaterial.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from persistence into document.
|
||||
Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from document into persistence.
|
||||
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BinMXCAFDoc_VisMaterialDriver_HeaderFile
|
@@ -1,59 +0,0 @@
|
||||
// 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 <BinMXCAFDoc_VisMaterialToolDriver.hxx>
|
||||
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_VisMaterialToolDriver, BinMDF_ADriver)
|
||||
|
||||
//=======================================================================
|
||||
//function : BinMXCAFDoc_VisMaterialToolDriver
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
BinMXCAFDoc_VisMaterialToolDriver::BinMXCAFDoc_VisMaterialToolDriver (const Handle(Message_Messenger)& theMsgDriver)
|
||||
: BinMDF_ADriver (theMsgDriver, STANDARD_TYPE(XCAFDoc_VisMaterialTool)->Name())
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) BinMXCAFDoc_VisMaterialToolDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_VisMaterialTool();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean BinMXCAFDoc_VisMaterialToolDriver::Paste (const BinObjMgt_Persistent& ,
|
||||
const Handle(TDF_Attribute)& ,
|
||||
BinObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void BinMXCAFDoc_VisMaterialToolDriver::Paste (const Handle(TDF_Attribute)& ,
|
||||
BinObjMgt_Persistent& ,
|
||||
BinObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
//
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
// 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 _BinMXCAFDoc_VisMaterialToolDriver_HeaderFile
|
||||
#define _BinMXCAFDoc_VisMaterialToolDriver_HeaderFile
|
||||
|
||||
#include <BinMDF_ADriver.hxx>
|
||||
|
||||
DEFINE_STANDARD_HANDLE(BinMXCAFDoc_VisMaterialToolDriver, BinMDF_ADriver)
|
||||
|
||||
//! Binary persistence driver for XCAFDoc_VisMaterialTool attribute.
|
||||
class BinMXCAFDoc_VisMaterialToolDriver : public BinMDF_ADriver
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_VisMaterialToolDriver, BinMDF_ADriver)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT BinMXCAFDoc_VisMaterialToolDriver (const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
//! Create new instance of XCAFDoc_VisMaterialTool.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from persistence into document.
|
||||
Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from document into persistence.
|
||||
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource,
|
||||
BinObjMgt_Persistent& theTarget,
|
||||
BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // _BinMXCAFDoc_VisMaterialToolDriver_HeaderFile
|
@@ -51,9 +51,5 @@ BinMXCAFDoc_ViewDriver.cxx
|
||||
BinMXCAFDoc_ViewDriver.hxx
|
||||
BinMXCAFDoc_ViewToolDriver.cxx
|
||||
BinMXCAFDoc_ViewToolDriver.hxx
|
||||
BinMXCAFDoc_VisMaterialDriver.cxx
|
||||
BinMXCAFDoc_VisMaterialDriver.hxx
|
||||
BinMXCAFDoc_VisMaterialToolDriver.cxx
|
||||
BinMXCAFDoc_VisMaterialToolDriver.hxx
|
||||
BinMXCAFDoc_VolumeDriver.cxx
|
||||
BinMXCAFDoc_VolumeDriver.hxx
|
||||
|
@@ -3202,7 +3202,6 @@ static Standard_Integer DDataStd_SetNDataIntegers2 (Draw_Interpretor& di,
|
||||
|
||||
j = 1111;
|
||||
TCollection_ExtendedString aKey("Key_");
|
||||
anAtt->LoadDeferredData();
|
||||
for(Standard_Integer i = 1; i<=aNumP; i++) {
|
||||
TCollection_ExtendedString key = aKey + i;
|
||||
Standard_Integer aVal = j+i;
|
||||
@@ -3248,7 +3247,6 @@ static Standard_Integer DDataStd_SetNDataIntAr2 (Draw_Interpretor& di,
|
||||
anArr->SetValue(i, aVal);
|
||||
j++;
|
||||
}
|
||||
anAtt->LoadDeferredData();
|
||||
anAtt->SetArrayOfIntegers(aKey, anArr);
|
||||
return 0;
|
||||
}
|
||||
@@ -3365,7 +3363,6 @@ static Standard_Integer DDataStd_SetNDataIntegers (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
|
||||
j = 4;
|
||||
anAtt->LoadDeferredData();
|
||||
for(Standard_Integer i = 1; i<=aNumP; i++) {
|
||||
TCollection_ExtendedString aKey(arg[j]);
|
||||
Standard_Integer aVal = Draw::Atoi(arg[j+1]);
|
||||
@@ -3400,7 +3397,6 @@ static Standard_Integer DDataStd_GetNDIntegers (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
const TColStd_DataMapOfStringInteger& aMap = anAtt->GetIntegersContainer();
|
||||
TColStd_DataMapIteratorOfDataMapOfStringInteger itr(aMap);
|
||||
for (; itr.More(); itr.Next()){
|
||||
@@ -3438,7 +3434,6 @@ static Standard_Integer DDataStd_GetNDInteger (Draw_Interpretor& di,
|
||||
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
if(!anAtt->HasInteger(arg[3])) {
|
||||
std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
|
||||
return 1;
|
||||
@@ -3478,7 +3473,6 @@ static Standard_Integer DDataStd_SetNDataReals (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
|
||||
j = 4;
|
||||
anAtt->LoadDeferredData();
|
||||
for(Standard_Integer i = 1; i<=aNumP; i++) {
|
||||
TCollection_ExtendedString aKey(arg[j]);
|
||||
Standard_Real aVal = Draw::Atof(arg[j+1]);
|
||||
@@ -3512,7 +3506,6 @@ static Standard_Integer DDataStd_GetNDReals (Draw_Interpretor& di,
|
||||
std::cout << "NamedData attribute is not found or not set" << std::endl;
|
||||
return 1;}
|
||||
|
||||
anAtt->LoadDeferredData();
|
||||
const TDataStd_DataMapOfStringReal& aMap = anAtt->GetRealsContainer();
|
||||
TDataStd_DataMapIteratorOfDataMapOfStringReal itr(aMap);
|
||||
for (; itr.More(); itr.Next()){
|
||||
@@ -3549,7 +3542,6 @@ static Standard_Integer DDataStd_GetNDReal (Draw_Interpretor& di,
|
||||
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
if(!anAtt->HasReal(arg[3])) {
|
||||
std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
|
||||
return 1;
|
||||
@@ -3589,7 +3581,6 @@ static Standard_Integer DDataStd_SetNDataStrings (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
|
||||
j = 4;
|
||||
anAtt->LoadDeferredData();
|
||||
for(Standard_Integer i = 1; i<=aNumP; i++) {
|
||||
TCollection_ExtendedString aKey(arg[j]);
|
||||
TCollection_ExtendedString aVal(arg[j+1]);
|
||||
@@ -3623,7 +3614,6 @@ static Standard_Integer DDataStd_GetNDStrings (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
const TDataStd_DataMapOfStringString& aMap = anAtt->GetStringsContainer();
|
||||
TDataStd_DataMapIteratorOfDataMapOfStringString itr(aMap);
|
||||
for (; itr.More(); itr.Next()){
|
||||
@@ -3661,7 +3651,6 @@ static Standard_Integer DDataStd_GetNDString (Draw_Interpretor& di,
|
||||
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
if(!anAtt->HasString(arg[3])) {
|
||||
std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
|
||||
return 1;
|
||||
@@ -3702,7 +3691,6 @@ static Standard_Integer DDataStd_SetNDataBytes (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
|
||||
j = 4;
|
||||
anAtt->LoadDeferredData();
|
||||
for(Standard_Integer i = 1; i<=aNumP; i++) {
|
||||
TCollection_ExtendedString aKey(arg[j]);
|
||||
Standard_Byte aVal = (Standard_Byte)Draw::Atoi(arg[j+1]);
|
||||
@@ -3736,7 +3724,6 @@ static Standard_Integer DDataStd_GetNDBytes (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
const TDataStd_DataMapOfStringByte& aMap = anAtt->GetBytesContainer();
|
||||
TDataStd_DataMapIteratorOfDataMapOfStringByte itr(aMap);
|
||||
for (; itr.More(); itr.Next()){
|
||||
@@ -3773,7 +3760,6 @@ static Standard_Integer DDataStd_GetNDByte (Draw_Interpretor& di,
|
||||
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
if(!anAtt->HasByte(arg[3])) {
|
||||
std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
|
||||
return 1;
|
||||
@@ -3821,7 +3807,6 @@ static Standard_Integer DDataStd_SetNDataIntAr (Draw_Interpretor& di,
|
||||
anArr->SetValue(i, aVal);
|
||||
j++;
|
||||
}
|
||||
anAtt->LoadDeferredData();
|
||||
anAtt->SetArrayOfIntegers(aKey, anArr);
|
||||
return 0;
|
||||
}
|
||||
@@ -3851,7 +3836,6 @@ static Standard_Integer DDataStd_GetNDIntArrays (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
const TDataStd_DataMapOfStringHArray1OfInteger& aMap = anAtt->GetArraysOfIntegersContainer();
|
||||
TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfInteger itr(aMap);
|
||||
for (; itr.More(); itr.Next()){
|
||||
@@ -3897,7 +3881,6 @@ static Standard_Integer DDataStd_GetNDIntArray (Draw_Interpretor& di,
|
||||
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
if(!anAtt->HasArrayOfIntegers(arg[3])) {
|
||||
std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
|
||||
return 1;
|
||||
@@ -3954,7 +3937,6 @@ static Standard_Integer DDataStd_SetNDataRealAr (Draw_Interpretor& di,
|
||||
anArr->SetValue(i, aVal);
|
||||
j++;
|
||||
}
|
||||
anAtt->LoadDeferredData();
|
||||
anAtt->SetArrayOfReals(aKey, anArr);
|
||||
return 0;
|
||||
}
|
||||
@@ -3984,7 +3966,6 @@ static Standard_Integer DDataStd_GetNDRealArrays (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
const TDataStd_DataMapOfStringHArray1OfReal& aMap = anAtt->GetArraysOfRealsContainer();
|
||||
TDataStd_DataMapIteratorOfDataMapOfStringHArray1OfReal itr(aMap);
|
||||
for (; itr.More(); itr.Next()){
|
||||
@@ -4029,8 +4010,7 @@ static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di,
|
||||
return 1;}
|
||||
|
||||
std::cout <<std::endl;
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
anAtt->LoadDeferredData();
|
||||
std::cout <<"NamedData attribute at Label = " << arg[2] <<std::endl;
|
||||
if(!anAtt->HasArrayOfReals(arg[3])) {
|
||||
std::cout << "There is no data specified by Key = "<< arg[3] << std::endl;
|
||||
return 1;
|
||||
|
@@ -276,7 +276,6 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
|
||||
XCAFPrs_Style own = settings.FindFromKey(S);
|
||||
if ( own.IsSetColorCurv() ) style.SetColorCurv ( own.GetColorCurv() );
|
||||
if ( own.IsSetColorSurf() ) style.SetColorSurf ( own.GetColorSurf() );
|
||||
style.SetMaterial (own.Material());
|
||||
}
|
||||
|
||||
// analyze whether current entity should get a color
|
||||
@@ -287,12 +286,6 @@ void IGESCAFControl_Writer::MakeColors (const TopoDS_Shape &S,
|
||||
hasColor = Standard_True;
|
||||
col = style.GetColorSurf();
|
||||
}
|
||||
else if (!style.Material().IsNull()
|
||||
&& !style.Material()->IsEmpty())
|
||||
{
|
||||
hasColor = Standard_True;
|
||||
col = style.Material()->BaseColor().GetRGB();
|
||||
}
|
||||
}
|
||||
else if ( S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE ) {
|
||||
if ( style.IsSetColorCurv() ) {
|
||||
|
@@ -1,7 +1,6 @@
|
||||
RWGltf_GltfAccessor.hxx
|
||||
RWGltf_GltfAccessorCompType.hxx
|
||||
RWGltf_GltfAccessorLayout.hxx
|
||||
RWGltf_GltfAlphaMode.hxx
|
||||
RWGltf_GltfArrayType.hxx
|
||||
RWGltf_GltfBufferView.hxx
|
||||
RWGltf_GltfBufferViewTarget.hxx
|
||||
|
@@ -1,46 +0,0 @@
|
||||
// Author: Kirill Gavrilov
|
||||
// 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 _RWGltf_GltfAlphaMode_HeaderFile
|
||||
#define _RWGltf_GltfAlphaMode_HeaderFile
|
||||
|
||||
#include <Standard_CString.hxx>
|
||||
|
||||
//! Low-level glTF enumeration defining Alpha Mode.
|
||||
enum RWGltf_GltfAlphaMode
|
||||
{
|
||||
RWGltf_GltfAlphaMode_Opaque, //!< alpha value is ignored and the rendered output is fully opaque
|
||||
RWGltf_GltfAlphaMode_Mask, //!< rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
|
||||
RWGltf_GltfAlphaMode_Blend, //!< alpha value is used to composite the source and destination areas
|
||||
};
|
||||
|
||||
//! Parse RWGltf_GltfAlphaMode from string.
|
||||
inline RWGltf_GltfAlphaMode RWGltf_GltfParseAlphaMode (const char* theType)
|
||||
{
|
||||
if (IsEqual ("OPAQUE", theType))
|
||||
{
|
||||
return RWGltf_GltfAlphaMode_Opaque;
|
||||
}
|
||||
else if (IsEqual ("MASK", theType))
|
||||
{
|
||||
return RWGltf_GltfAlphaMode_Mask;
|
||||
}
|
||||
else if (IsEqual ("BLEND", theType))
|
||||
{
|
||||
return RWGltf_GltfAlphaMode_Blend;
|
||||
}
|
||||
return RWGltf_GltfAlphaMode_Opaque;
|
||||
}
|
||||
|
||||
#endif // _RWGltf_GltfAlphaMode_HeaderFile
|
@@ -308,7 +308,6 @@ void RWGltf_GltfJsonParser::gltfParseMaterials()
|
||||
}
|
||||
aMat->Id = aMatId.GetString();
|
||||
myMaterialsCommon.Bind (aMat->Id, aMat);
|
||||
gltfBindMaterial (Handle(RWGltf_MaterialMetallicRoughness)(), aMat);
|
||||
}
|
||||
}
|
||||
else if (aMatList->IsArray())
|
||||
@@ -343,98 +342,10 @@ 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.DiffuseTexture = theMatCommon->DiffuseTexture;
|
||||
if (aMatXde.DiffuseTexture.IsNull()
|
||||
&& !theMatCommon->AmbientTexture.IsNull())
|
||||
{
|
||||
aMatXde.DiffuseTexture = theMatCommon->AmbientTexture;
|
||||
}
|
||||
aMat->SetCommonMaterial (aMatXde);
|
||||
if (!theMatCommon->Name.IsEmpty())
|
||||
{
|
||||
aMat->SetRawName (new TCollection_HAsciiString (theMatCommon->Name));
|
||||
}
|
||||
}
|
||||
if (!theMatPbr.IsNull())
|
||||
{
|
||||
XCAFDoc_VisMaterialPBR 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->SetPbrMaterial (aMatXde);
|
||||
|
||||
Graphic3d_AlphaMode anAlphaMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
switch (theMatPbr->AlphaMode)
|
||||
{
|
||||
case RWGltf_GltfAlphaMode_Opaque:
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_Opaque;
|
||||
if (aMatXde.BaseColor.Alpha() < 1.0f)
|
||||
{
|
||||
Message::DefaultMessenger()->Send ("glTF reader - material with non-zero Transparency specifies Opaque AlphaMode", Message_Warning);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RWGltf_GltfAlphaMode_Mask:
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_Mask;
|
||||
break;
|
||||
}
|
||||
case RWGltf_GltfAlphaMode_Blend:
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_Blend;
|
||||
break;
|
||||
}
|
||||
}
|
||||
aMat->SetAlphaMode (anAlphaMode, theMatPbr->AlphaCutOff);
|
||||
aMat->SetDoubleSided (theMatPbr->IsDoubleSided);
|
||||
|
||||
if (!theMatPbr->Name.IsEmpty())
|
||||
{
|
||||
aMat->SetRawName (new TCollection_HAsciiString (theMatPbr->Name));
|
||||
}
|
||||
}
|
||||
|
||||
myMaterials.Bind (!theMatPbr.IsNull() ? theMatPbr->Id : theMatCommon->Id, aMat);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : gltfParseStdMaterial
|
||||
// purpose :
|
||||
@@ -539,9 +450,6 @@ bool RWGltf_GltfJsonParser::gltfParsePbrMaterial (Handle(RWGltf_MaterialMetallic
|
||||
const RWGltf_JsonValue* anEmissFactorVal = findObjectMember (theMatNode, "emissiveFactor");
|
||||
const RWGltf_JsonValue* anEmissTexVal = findObjectMember (theMatNode, "emissiveTexture");
|
||||
const RWGltf_JsonValue* anOcclusionTexVal = findObjectMember (theMatNode, "occlusionTexture");
|
||||
const RWGltf_JsonValue* aDoubleSidedVal = findObjectMember (theMatNode, "doubleSided");
|
||||
const RWGltf_JsonValue* anAlphaModeVal = findObjectMember (theMatNode, "alphaMode");
|
||||
const RWGltf_JsonValue* anAlphaCutoffVal = findObjectMember (theMatNode, "alphaCutoff");
|
||||
if (aMetalRoughVal == NULL)
|
||||
{
|
||||
return false;
|
||||
@@ -554,22 +462,6 @@ bool RWGltf_GltfJsonParser::gltfParsePbrMaterial (Handle(RWGltf_MaterialMetallic
|
||||
const RWGltf_JsonValue* aRoughnessFactorVal = findObjectMember (*aMetalRoughVal, "roughnessFactor");
|
||||
const RWGltf_JsonValue* aMetalRoughTexVal = findObjectMember (*aMetalRoughVal, "metallicRoughnessTexture");
|
||||
|
||||
if (aDoubleSidedVal != NULL
|
||||
&& aDoubleSidedVal->IsBool())
|
||||
{
|
||||
theMat->IsDoubleSided = aDoubleSidedVal->GetBool();
|
||||
}
|
||||
if (anAlphaCutoffVal != NULL
|
||||
&& anAlphaCutoffVal->IsNumber())
|
||||
{
|
||||
theMat->AlphaCutOff = (float )anAlphaCutoffVal->GetDouble();
|
||||
}
|
||||
if (anAlphaModeVal != NULL
|
||||
&& anAlphaModeVal->IsString())
|
||||
{
|
||||
theMat->AlphaMode = RWGltf_GltfParseAlphaMode (anAlphaModeVal->GetString());
|
||||
}
|
||||
|
||||
if (aBaseColorTexVal != NULL
|
||||
&& aBaseColorTexVal->IsObject())
|
||||
{
|
||||
@@ -1224,14 +1116,7 @@ bool RWGltf_GltfJsonParser::gltfParseMesh (TopoDS_Shape& theMeshShape,
|
||||
{
|
||||
RWMesh_NodeAttributes aShapeAttribs;
|
||||
aShapeAttribs.RawName = aUserName;
|
||||
|
||||
// assign material and not color
|
||||
//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);
|
||||
|
||||
aShapeAttribs.Style.SetColorSurf (aMeshData->BaseColor());
|
||||
myAttribMap->Bind (aFace, aShapeAttribs);
|
||||
}
|
||||
myFaceList.Append (aFace);
|
||||
@@ -1701,12 +1586,7 @@ void RWGltf_GltfJsonParser::bindNamedShape (TopoDS_Shape& theShape,
|
||||
{
|
||||
if (aLateData->HasStyle())
|
||||
{
|
||||
// assign material and not color
|
||||
//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);
|
||||
aShapeAttribs.Style.SetColorSurf (aLateData->BaseColor());
|
||||
}
|
||||
if (aShapeAttribs.Name.IsEmpty()
|
||||
&& myUseMeshNameAsFallback)
|
||||
|
@@ -150,10 +150,6 @@ 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.
|
||||
@@ -401,7 +397,6 @@ 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;
|
||||
|
@@ -17,7 +17,6 @@
|
||||
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
#include <RWGltf_GltfAlphaMode.hxx>
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
@@ -39,18 +38,12 @@ public:
|
||||
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_ShortReal AlphaCutOff; //!< alpha cutoff value; 0.5 by default
|
||||
RWGltf_GltfAlphaMode AlphaMode; //!< alpha mode; RWGltf_GltfAlphaMode_Opaque by default
|
||||
Standard_Boolean IsDoubleSided; //!< specifies whether the material is double sided; FALSE by default
|
||||
|
||||
RWGltf_MaterialMetallicRoughness()
|
||||
RWGltf_MaterialMetallicRoughness()
|
||||
: BaseColor (1.0f, 1.0f, 1.0f, 1.0f),
|
||||
EmissiveFactor (0.0f, 0.0f, 0.0f),
|
||||
Metallic (1.0f),
|
||||
Roughness (1.0f),
|
||||
AlphaCutOff (0.5f),
|
||||
AlphaMode (RWGltf_GltfAlphaMode_Opaque),
|
||||
IsDoubleSided (Standard_False) {}
|
||||
Metallic (0.0f),
|
||||
Roughness (0.0f) {}
|
||||
|
||||
};
|
||||
|
||||
|
@@ -32,7 +32,6 @@
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeMapTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(RWMesh_CafReader, Standard_Transient)
|
||||
|
||||
@@ -163,114 +162,19 @@ void RWMesh_CafReader::fillDocument()
|
||||
const Standard_Boolean wasAutoNaming = XCAFDoc_ShapeTool::AutoNaming();
|
||||
XCAFDoc_ShapeTool::SetAutoNaming (Standard_False);
|
||||
const TCollection_AsciiString aRootName; // = generateRootName (theFile);
|
||||
CafDocumentTools aTools;
|
||||
aTools.ShapeTool = XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main());
|
||||
aTools.ColorTool = XCAFDoc_DocumentTool::ColorTool (myXdeDoc->Main());
|
||||
aTools.VisMaterialTool = XCAFDoc_DocumentTool::VisMaterialTool (myXdeDoc->Main());
|
||||
for (TopTools_SequenceOfShape::Iterator aRootIter (myRootShapes); aRootIter.More(); aRootIter.Next())
|
||||
{
|
||||
addShapeIntoDoc (aTools, aRootIter.Value(), TDF_Label(), aRootName);
|
||||
addShapeIntoDoc (aRootIter.Value(), TDF_Label(), aRootName);
|
||||
}
|
||||
XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main())->UpdateAssemblies();
|
||||
XCAFDoc_ShapeTool::SetAutoNaming (wasAutoNaming);
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setShapeName
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void RWMesh_CafReader::setShapeName (const TDF_Label& theLabel,
|
||||
const TopAbs_ShapeEnum theShapeType,
|
||||
const TCollection_AsciiString& theName,
|
||||
const TDF_Label& theParentLabel,
|
||||
const TCollection_AsciiString& theParentName)
|
||||
{
|
||||
if (!theName.IsEmpty())
|
||||
{
|
||||
TDataStd_Name::Set (theLabel, theName);
|
||||
}
|
||||
else if (!theParentLabel.IsNull())
|
||||
{
|
||||
TDataStd_Name::Set (theLabel, shapeTypeToString (theShapeType));
|
||||
}
|
||||
else if (theParentLabel.IsNull()
|
||||
&& !theParentName.IsEmpty())
|
||||
{
|
||||
TDataStd_Name::Set (theLabel, theParentName);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setShapeStyle
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void RWMesh_CafReader::setShapeStyle (const CafDocumentTools& theTools,
|
||||
const TDF_Label& theLabel,
|
||||
const XCAFPrs_Style& theStyle)
|
||||
{
|
||||
if (theStyle.IsSetColorSurf())
|
||||
{
|
||||
theTools.ColorTool->SetColor (theLabel, theStyle.GetColorSurfRGBA(), XCAFDoc_ColorSurf);
|
||||
}
|
||||
if (theStyle.IsSetColorCurv())
|
||||
{
|
||||
theTools.ColorTool->SetColor (theLabel, theStyle.GetColorCurv(), XCAFDoc_ColorCurv);
|
||||
}
|
||||
if (!theStyle.Material().IsNull())
|
||||
{
|
||||
TDF_Label aMaterialLabel = theStyle.Material()->Label();
|
||||
if (aMaterialLabel.IsNull())
|
||||
{
|
||||
const TCollection_AsciiString aMatName = !theStyle.Material()->RawName().IsNull()
|
||||
? theStyle.Material()->RawName()->String()
|
||||
: "";
|
||||
aMaterialLabel = theTools.VisMaterialTool->AddMaterial (theStyle.Material(), aMatName);
|
||||
}
|
||||
theTools.VisMaterialTool->SetShapeMaterial (theLabel, aMaterialLabel);
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : setShapeNamedData
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void RWMesh_CafReader::setShapeNamedData (const CafDocumentTools& ,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDataStd_NamedData)& theNameData)
|
||||
{
|
||||
if (theNameData.IsNull())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const TDF_Label aNameDataLabel = theNameData->Label();
|
||||
Handle(TDataStd_NamedData) anOtherNamedData;
|
||||
if (theLabel.FindAttribute (theNameData->ID(), anOtherNamedData))
|
||||
{
|
||||
if (anOtherNamedData->Label() != aNameDataLabel)
|
||||
{
|
||||
Message::DefaultMessenger()->Send ("Error! Different NamedData is already set to shape", Message_Alarm);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aNameDataLabel.IsNull())
|
||||
{
|
||||
theLabel.AddAttribute (theNameData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Message::DefaultMessenger()->Send ("Error! Skipped NamedData instance shared across shapes", Message_Alarm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : addShapeIntoDoc
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (CafDocumentTools& theTools,
|
||||
const TopoDS_Shape& theShape,
|
||||
Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theLabel,
|
||||
const TCollection_AsciiString& theParentName)
|
||||
{
|
||||
@@ -280,9 +184,10 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (CafDocumentTools& theTools,
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool (myXdeDoc->Main());
|
||||
|
||||
const TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
|
||||
TopoDS_Shape aShapeToAdd = theShape;
|
||||
const TopoDS_Shape aShapeNoLoc = theShape.Located (TopLoc_Location());
|
||||
Standard_Boolean toMakeAssembly = Standard_False;
|
||||
if (theShape.ShapeType() == TopAbs_COMPOUND)
|
||||
{
|
||||
@@ -300,9 +205,9 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (CafDocumentTools& theTools,
|
||||
|| (myAttribMap.Find (aFace, aSubFaceAttribs) && !aSubFaceAttribs.Name.IsEmpty());
|
||||
}
|
||||
|
||||
// create empty compound to add as assembly
|
||||
if (toMakeAssembly)
|
||||
{
|
||||
// create an empty Compound to add as assembly, so that we can add children one-by-one via AddComponent()
|
||||
TopoDS_Compound aCompound;
|
||||
BRep_Builder aBuilder;
|
||||
aBuilder.MakeCompound (aCompound);
|
||||
@@ -311,35 +216,21 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (CafDocumentTools& theTools,
|
||||
}
|
||||
}
|
||||
|
||||
TDF_Label aNewLabel, anOldLabel;
|
||||
TDF_Label aNewLabel;
|
||||
if (theLabel.IsNull())
|
||||
{
|
||||
// add new shape
|
||||
aNewLabel = theTools.ShapeTool->AddShape (aShapeToAdd, toMakeAssembly);
|
||||
aNewLabel = aShapeTool->AddShape (aShapeToAdd, toMakeAssembly);
|
||||
}
|
||||
else if (theTools.ShapeTool->IsAssembly (theLabel))
|
||||
else if (aShapeTool->IsAssembly (theLabel))
|
||||
{
|
||||
// add shape as component
|
||||
if (theTools.ComponentMap.Find (aShapeNoLoc, anOldLabel))
|
||||
{
|
||||
aNewLabel = theTools.ShapeTool->AddComponent (theLabel, anOldLabel, theShape.Location());
|
||||
}
|
||||
else
|
||||
{
|
||||
aNewLabel = theTools.ShapeTool->AddComponent (theLabel, aShapeToAdd, toMakeAssembly);
|
||||
|
||||
TDF_Label aRefLabel = aNewLabel;
|
||||
theTools.ShapeTool->GetReferredShape (aNewLabel, aRefLabel);
|
||||
if (!aRefLabel.IsNull())
|
||||
{
|
||||
theTools.ComponentMap.Bind (aShapeNoLoc, aRefLabel);
|
||||
}
|
||||
}
|
||||
aNewLabel = aShapeTool->AddComponent (theLabel, aShapeToAdd, toMakeAssembly);
|
||||
}
|
||||
else
|
||||
{
|
||||
// add shape as sub-shape
|
||||
aNewLabel = theTools.ShapeTool->AddSubShape (theLabel, theShape);
|
||||
aNewLabel = aShapeTool->AddSubShape (theLabel, theShape);
|
||||
if (!aNewLabel.IsNull())
|
||||
{
|
||||
Handle(XCAFDoc_ShapeMapTool) aShapeMapTool = XCAFDoc_ShapeMapTool::Set (aNewLabel);
|
||||
@@ -353,127 +244,44 @@ Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (CafDocumentTools& theTools,
|
||||
|
||||
// if new label is a reference get referred shape
|
||||
TDF_Label aNewRefLabel = aNewLabel;
|
||||
theTools.ShapeTool->GetReferredShape (aNewLabel, aNewRefLabel);
|
||||
aShapeTool->GetReferredShape (aNewLabel, aNewRefLabel);
|
||||
|
||||
RWMesh_NodeAttributes aRefShapeAttribs;
|
||||
myAttribMap.Find (aShapeNoLoc, aRefShapeAttribs);
|
||||
|
||||
bool hasProductName = false;
|
||||
if (aNewLabel != aNewRefLabel)
|
||||
// store name
|
||||
RWMesh_NodeAttributes aShapeAttribs;
|
||||
myAttribMap.Find (theShape, aShapeAttribs);
|
||||
if (aShapeAttribs.Name.IsEmpty())
|
||||
{
|
||||
// put attributes to the Instance (overrides Product attributes)
|
||||
RWMesh_NodeAttributes aShapeAttribs;
|
||||
if (!theShape.Location().IsIdentity()
|
||||
&& myAttribMap.Find (theShape, aShapeAttribs))
|
||||
if (theLabel.IsNull())
|
||||
{
|
||||
if (!aShapeAttribs.Style.IsEqual (aRefShapeAttribs.Style))
|
||||
{
|
||||
setShapeStyle (theTools, aNewLabel, aShapeAttribs.Style);
|
||||
}
|
||||
if (aShapeAttribs.NamedData != aRefShapeAttribs.NamedData)
|
||||
{
|
||||
setShapeNamedData (theTools, aNewLabel, aShapeAttribs.NamedData);
|
||||
}
|
||||
setShapeName (aNewLabel, aShapeType, aShapeAttribs.Name, theLabel, theParentName);
|
||||
if (aRefShapeAttribs.Name.IsEmpty()
|
||||
&& !aShapeAttribs.Name.IsEmpty())
|
||||
{
|
||||
// it is not nice having unnamed Product, so copy name from first Instance (probably the only one)
|
||||
hasProductName = true;
|
||||
setShapeName (aNewRefLabel, aShapeType, aShapeAttribs.Name, theLabel, theParentName);
|
||||
}
|
||||
aShapeAttribs.Name = theParentName;
|
||||
}
|
||||
else
|
||||
if (aShapeAttribs.Name.IsEmpty()
|
||||
&& !theLabel.IsNull())
|
||||
{
|
||||
// copy name from Product
|
||||
setShapeName (aNewLabel, aShapeType, aRefShapeAttribs.Name, theLabel, theParentName);
|
||||
aShapeAttribs.Name = shapeTypeToString (aShapeType);
|
||||
}
|
||||
}
|
||||
|
||||
if (!anOldLabel.IsNull())
|
||||
if (!aShapeAttribs.Name.IsEmpty())
|
||||
{
|
||||
// already defined in the document
|
||||
return Standard_True;
|
||||
TDataStd_Name::Set (aNewRefLabel, aShapeAttribs.Name);
|
||||
}
|
||||
|
||||
// put attributes to the Product (shared across Instances)
|
||||
if (!hasProductName)
|
||||
// store color
|
||||
Handle(XCAFDoc_ColorTool) aColorTool = XCAFDoc_DocumentTool::ColorTool (myXdeDoc->Main());
|
||||
if (aShapeAttribs.Style.IsSetColorSurf())
|
||||
{
|
||||
setShapeName (aNewRefLabel, aShapeType, aRefShapeAttribs.Name, theLabel, theParentName);
|
||||
aColorTool->SetColor (aNewRefLabel, aShapeAttribs.Style.GetColorSurfRGBA(), XCAFDoc_ColorSurf);
|
||||
}
|
||||
setShapeStyle (theTools, aNewRefLabel, aRefShapeAttribs.Style);
|
||||
setShapeNamedData (theTools, aNewRefLabel, aRefShapeAttribs.NamedData);
|
||||
|
||||
if (theTools.ShapeTool->IsAssembly (aNewRefLabel))
|
||||
if (aShapeAttribs.Style.IsSetColorCurv())
|
||||
{
|
||||
// store sub-shapes (iterator is set to not inherit Location of parent object)
|
||||
TCollection_AsciiString aDummyName;
|
||||
for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); aSubShapeIter.More(); aSubShapeIter.Next())
|
||||
{
|
||||
addShapeIntoDoc (theTools, aSubShapeIter.Value(), aNewRefLabel, aDummyName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// store a plain list of sub-shapes in case if they have custom attributes (usually per-face color)
|
||||
RWMesh_NodeAttributes aSubShapeAttribs;
|
||||
for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); aSubShapeIter.More(); aSubShapeIter.Next())
|
||||
{
|
||||
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
|
||||
if (myAttribMap.Find (aSubShape.Located (TopLoc_Location()), aSubShapeAttribs))
|
||||
{
|
||||
addSubShapeIntoDoc (theTools, aSubShape, aNewRefLabel, aSubShapeAttribs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : addSubShapeIntoDoc
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Standard_Boolean RWMesh_CafReader::addSubShapeIntoDoc (CafDocumentTools& theTools,
|
||||
const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theParentLabel,
|
||||
const RWMesh_NodeAttributes& theAttribs)
|
||||
{
|
||||
if (theShape.IsNull()
|
||||
|| myXdeDoc.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
aColorTool->SetColor (aNewRefLabel, aShapeAttribs.Style.GetColorCurv(), XCAFDoc_ColorCurv);
|
||||
}
|
||||
|
||||
const TopAbs_ShapeEnum aShapeType = theShape.ShapeType();
|
||||
TDF_Label aNewLabel = theTools.ShapeTool->AddSubShape (theParentLabel, theShape);
|
||||
if (aNewLabel.IsNull())
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
{
|
||||
Handle(XCAFDoc_ShapeMapTool) aShapeMapTool = XCAFDoc_ShapeMapTool::Set (aNewLabel);
|
||||
aShapeMapTool->SetShape (theShape);
|
||||
}
|
||||
|
||||
// if new label is a reference get referred shape
|
||||
TDF_Label aNewRefLabel = aNewLabel;
|
||||
theTools.ShapeTool->GetReferredShape (aNewLabel, aNewRefLabel);
|
||||
|
||||
// put attributes to the Product (shared across Instances)
|
||||
static const TCollection_AsciiString anEmptyString;
|
||||
setShapeName (aNewRefLabel, aShapeType, theAttribs.Name, TDF_Label(), anEmptyString);
|
||||
setShapeStyle (theTools, aNewRefLabel, theAttribs.Style);
|
||||
setShapeNamedData (theTools, aNewRefLabel, theAttribs.NamedData);
|
||||
|
||||
RWMesh_NodeAttributes aSubShapeAttribs;
|
||||
// store sub-shapes (iterator is set to ignore Location)
|
||||
TCollection_AsciiString aDummyName;
|
||||
for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); aSubShapeIter.More(); aSubShapeIter.Next())
|
||||
{
|
||||
const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
|
||||
if (myAttribMap.Find (aSubShape.Located (TopLoc_Location()), aSubShapeAttribs))
|
||||
{
|
||||
addSubShapeIntoDoc (theTools, aSubShape, theParentLabel, aSubShapeAttribs);
|
||||
}
|
||||
addShapeIntoDoc (aSubShapeIter.Value(), aNewRefLabel, aDummyName);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
@@ -24,9 +24,6 @@
|
||||
|
||||
class Message_ProgressIndicator;
|
||||
class TDocStd_Document;
|
||||
class XCAFDoc_ShapeTool;
|
||||
class XCAFDoc_ColorTool;
|
||||
class XCAFDoc_VisMaterialTool;
|
||||
|
||||
//! Extended status bits.
|
||||
enum RWMesh_CafReaderStatusEx
|
||||
@@ -48,17 +45,6 @@ enum RWMesh_CafReaderStatusEx
|
||||
class RWMesh_CafReader : public Standard_Transient
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(RWMesh_CafReader, Standard_Transient)
|
||||
public:
|
||||
|
||||
//! Structure holding tools for filling the document.
|
||||
struct CafDocumentTools
|
||||
{
|
||||
Handle(XCAFDoc_ShapeTool) ShapeTool;
|
||||
Handle(XCAFDoc_ColorTool) ColorTool;
|
||||
Handle(XCAFDoc_VisMaterialTool) VisMaterialTool;
|
||||
NCollection_DataMap<TopoDS_Shape, TDF_Label, TopTools_ShapeMapHasher> ComponentMap;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
@@ -203,34 +189,10 @@ protected:
|
||||
Standard_EXPORT void fillDocument();
|
||||
|
||||
//! Append new shape into the document (recursively).
|
||||
Standard_EXPORT Standard_Boolean addShapeIntoDoc (CafDocumentTools& theTools,
|
||||
const TopoDS_Shape& theShape,
|
||||
Standard_EXPORT Standard_Boolean addShapeIntoDoc (const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theLabel,
|
||||
const TCollection_AsciiString& theParentName);
|
||||
|
||||
//! Append new sub-shape into the document (recursively).
|
||||
Standard_EXPORT Standard_Boolean addSubShapeIntoDoc (CafDocumentTools& theTools,
|
||||
const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theParentLabel,
|
||||
const RWMesh_NodeAttributes& theAttribs);
|
||||
|
||||
//! Put name attribute onto the label.
|
||||
Standard_EXPORT void setShapeName (const TDF_Label& theLabel,
|
||||
const TopAbs_ShapeEnum theShapeType,
|
||||
const TCollection_AsciiString& theName,
|
||||
const TDF_Label& theParentLabel,
|
||||
const TCollection_AsciiString& theParentName);
|
||||
|
||||
//! Put color and material attributes onto the label.
|
||||
Standard_EXPORT void setShapeStyle (const CafDocumentTools& theTools,
|
||||
const TDF_Label& theLabel,
|
||||
const XCAFPrs_Style& theStyle);
|
||||
|
||||
//! Put name data (metadata) attribute onto the label.
|
||||
Standard_EXPORT void setShapeNamedData (const CafDocumentTools& theTools,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDataStd_NamedData)& theNameData);
|
||||
|
||||
//! Generate names for root labels starting from specified index.
|
||||
Standard_EXPORT void generateNames (const TCollection_AsciiString& theFile,
|
||||
const Standard_Integer theRootLower,
|
||||
|
@@ -20,15 +20,12 @@
|
||||
#include <TopTools_ShapeMapHasher.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
|
||||
class TDataStd_NamedData;
|
||||
|
||||
//! Attributes of the node.
|
||||
struct RWMesh_NodeAttributes
|
||||
{
|
||||
TCollection_AsciiString Name; //!< name for the user
|
||||
TCollection_AsciiString RawName; //!< name within low-level format structure
|
||||
Handle(TDataStd_NamedData) NamedData; //!< optional metadata
|
||||
XCAFPrs_Style Style; //!< presentation style
|
||||
TCollection_AsciiString Name; //!< name for the user
|
||||
TCollection_AsciiString RawName; //!< name within low-level format structure
|
||||
XCAFPrs_Style Style; //!< presentation style
|
||||
};
|
||||
typedef NCollection_DataMap<TopoDS_Shape, RWMesh_NodeAttributes, TopTools_ShapeMapHasher> RWMesh_NodeAttributeMap;
|
||||
|
||||
|
@@ -49,29 +49,7 @@ void RWObj_CafReader::BindNamedShape (const TopoDS_Shape& theShape,
|
||||
aShapeAttribs.Name = theName;
|
||||
if (theMaterial != NULL)
|
||||
{
|
||||
// assign material and not color
|
||||
//aShapeAttribs.Style.SetColorSurf (Quantity_ColorRGBA (theMaterial->DiffuseColor, 1.0f - theMaterial->Transparency));
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) aMat = new XCAFDoc_VisMaterial();
|
||||
if (!myObjMaterialMap.Find (theMaterial->Name, aMat)) // material names are used as unique keys in OBJ
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
aMat = new XCAFDoc_VisMaterial();
|
||||
aMat->SetCommonMaterial (aMatXde);
|
||||
aMat->SetRawName (new TCollection_HAsciiString (theMaterial->Name));
|
||||
}
|
||||
aShapeAttribs.Style.SetMaterial (aMat);
|
||||
aShapeAttribs.Style.SetColorSurf (Quantity_ColorRGBA (theMaterial->DiffuseColor, 1.0f - theMaterial->Transparency));
|
||||
}
|
||||
myAttribMap.Bind (theShape, aShapeAttribs);
|
||||
|
||||
|
@@ -56,7 +56,6 @@ protected:
|
||||
|
||||
protected:
|
||||
|
||||
NCollection_DataMap<TCollection_AsciiString, Handle(XCAFDoc_VisMaterial)> myObjMaterialMap;
|
||||
Standard_Boolean myIsSinglePrecision; //!< flag for reading vertex data with single or double floating point precision
|
||||
|
||||
};
|
||||
|
@@ -97,9 +97,25 @@ namespace
|
||||
return aPoly;
|
||||
}
|
||||
|
||||
//! Add new solid
|
||||
virtual void AddSolid() Standard_OVERRIDE
|
||||
{
|
||||
Handle(Poly_Triangulation) aCurrentTri = GetTriangulation();
|
||||
myTriangulationList.Append(aCurrentTri);
|
||||
myNodes.Clear();
|
||||
myTriangles.Clear();
|
||||
}
|
||||
|
||||
NCollection_Sequence<Handle(Poly_Triangulation)> GetTriangulationList()
|
||||
{
|
||||
return myTriangulationList;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
NCollection_Vector<gp_XYZ> myNodes;
|
||||
NCollection_Vector<Poly_Triangle> myTriangles;
|
||||
NCollection_Sequence<Handle(Poly_Triangulation)> myTriangulationList;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -118,6 +134,17 @@ Handle(Poly_Triangulation) RWStl::ReadFile (const Standard_CString theFile,
|
||||
return aReader.GetTriangulation();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ReadFile
|
||||
//purpose :
|
||||
//=============================================================================
|
||||
void RWStl::ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList)
|
||||
{
|
||||
Reader aReader;
|
||||
aReader.Read(theFile, Handle(Message_ProgressIndicator)(), true);
|
||||
theTriangList = aReader.GetTriangulationList();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//function : ReadFile
|
||||
//purpose :
|
||||
|
@@ -50,6 +50,8 @@ public:
|
||||
Standard_EXPORT static Handle(Poly_Triangulation) ReadFile (const Standard_CString theFile,
|
||||
const Handle(Message_ProgressIndicator)& aProgInd = Handle(Message_ProgressIndicator)());
|
||||
|
||||
Standard_EXPORT static void ReadFile(const Standard_CString theFile, NCollection_Sequence<Handle(Poly_Triangulation)>& theTriangList);
|
||||
|
||||
//! Read triangulation from a binary STL file
|
||||
//! In case of error, returns Null handle.
|
||||
Standard_EXPORT static Handle(Poly_Triangulation) ReadBinary (const OSD_Path& thePath,
|
||||
|
@@ -126,7 +126,8 @@ namespace
|
||||
//==============================================================================
|
||||
|
||||
Standard_Boolean RWStl_Reader::Read (const char* theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
const Handle(Message_ProgressIndicator)& theProgress,
|
||||
bool IsMultiSolid)
|
||||
{
|
||||
std::filebuf aBuf;
|
||||
OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
|
||||
@@ -165,6 +166,8 @@ Standard_Boolean RWStl_Reader::Read (const char* theFile,
|
||||
}
|
||||
}
|
||||
aStream >> std::ws; // skip any white spaces
|
||||
if (IsMultiSolid)
|
||||
AddSolid();
|
||||
}
|
||||
return ! aStream.fail();
|
||||
}
|
||||
|
@@ -39,7 +39,8 @@ public:
|
||||
//! Format is recognized automatically by analysis of the file header.
|
||||
//! Returns true if success, false on error or user break.
|
||||
Standard_EXPORT Standard_Boolean Read (const char* theFile,
|
||||
const Handle(Message_ProgressIndicator)& theProgress);
|
||||
const Handle(Message_ProgressIndicator)& theProgress,
|
||||
bool IsMultiSolid = false);
|
||||
|
||||
//! Guess whether the stream is an Ascii STL file, by analysis of the first bytes (~200).
|
||||
//! The function attempts to put back the read symbols to the stream which thus must support ungetc().
|
||||
@@ -74,6 +75,8 @@ public:
|
||||
//! Should create new triangle built on specified nodes in the target model.
|
||||
virtual void AddTriangle (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3) = 0;
|
||||
|
||||
virtual void AddSolid() = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -233,8 +233,6 @@
|
||||
#include <XCAFDoc_MaterialTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_Volume.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
#include <XCAFPrs.hxx>
|
||||
#include <XCAFPrs_DataMapIteratorOfDataMapOfStyleShape.hxx>
|
||||
#include <XCAFPrs_IndexedDataMapOfShapeStyle.hxx>
|
||||
@@ -1165,7 +1163,6 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
|
||||
|
||||
// Iterate on shapes in the document
|
||||
Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( labels(1) );
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool( labels(1) );
|
||||
if ( CTool.IsNull() ) return Standard_False;
|
||||
|
||||
STEPConstruct_Styles Styles ( WS );
|
||||
@@ -1235,16 +1232,6 @@ Standard_Boolean STEPCAFControl_Writer::WriteColors (const Handle(XSControl_Work
|
||||
style.SetColorSurf ( C );
|
||||
if ( CTool->GetColor ( lab, XCAFDoc_ColorCurv, C ) )
|
||||
style.SetColorCurv ( C );
|
||||
if (!style.IsSetColorSurf())
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aVisMat = aMatTool->GetShapeMaterial (lab);
|
||||
if (!aVisMat.IsNull()
|
||||
&& !aVisMat->IsEmpty())
|
||||
{
|
||||
// only color can be stored in STEP
|
||||
style.SetColorSurf (aVisMat->BaseColor());
|
||||
}
|
||||
}
|
||||
|
||||
// commented, cause we are need to take reference from
|
||||
// if ( isComponent && lab == L && !isVisible)
|
||||
@@ -1672,7 +1659,6 @@ Standard_Boolean STEPCAFControl_Writer::WriteLayers (const Handle(XSControl_Work
|
||||
//=======================================================================
|
||||
static Standard_Boolean getSHUOstyle(const TDF_Label& aSHUOlab,
|
||||
const Handle(XCAFDoc_ColorTool)& CTool,
|
||||
const Handle(XCAFDoc_VisMaterialTool)& theMatTool,
|
||||
XCAFPrs_Style& SHUOstyle)
|
||||
{
|
||||
Quantity_Color C;
|
||||
@@ -1687,16 +1673,6 @@ static Standard_Boolean getSHUOstyle(const TDF_Label& aSHUOlab,
|
||||
SHUOstyle.SetColorSurf ( C );
|
||||
if ( CTool->GetColor ( aSHUOlab, XCAFDoc_ColorCurv, C ) )
|
||||
SHUOstyle.SetColorCurv ( C );
|
||||
if (!SHUOstyle.IsSetColorSurf())
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aVisMat = theMatTool->GetShapeMaterial (aSHUOlab);
|
||||
if (!aVisMat.IsNull()
|
||||
&& !aVisMat->IsEmpty())
|
||||
{
|
||||
// only color can be stored in STEP
|
||||
SHUOstyle.SetColorSurf (aVisMat->BaseColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !SHUOstyle.IsSetColorCurv() &&
|
||||
!SHUOstyle.IsSetColorSurf() &&
|
||||
@@ -2001,7 +1977,6 @@ Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkS
|
||||
|
||||
// get working data
|
||||
Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool( labels(1) );
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool( labels(1) );
|
||||
if (CTool.IsNull() )
|
||||
return Standard_False;
|
||||
// map of transfered SHUO
|
||||
@@ -2034,7 +2009,7 @@ Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkS
|
||||
aMapOfMainSHUO.Add( aSHUO );
|
||||
// check if it is styled SHUO
|
||||
XCAFPrs_Style SHUOstyle;
|
||||
if ( !getSHUOstyle ( aSHUOlab, CTool, aMatTool, SHUOstyle ) ) {
|
||||
if ( !getSHUOstyle ( aSHUOlab, CTool, SHUOstyle ) ) {
|
||||
#ifdef OCCT_DEBUG
|
||||
std::cout << "Warning: " << __FILE__ << ": do not store SHUO without any style to the STEP model" << std::endl;
|
||||
#endif
|
||||
|
@@ -72,6 +72,7 @@ TDataStd_Name.cxx
|
||||
TDataStd_Name.hxx
|
||||
TDataStd_NamedData.cxx
|
||||
TDataStd_NamedData.hxx
|
||||
TDataStd_NamedData.lxx
|
||||
TDataStd_NoteBook.cxx
|
||||
TDataStd_NoteBook.hxx
|
||||
TDataStd_PtrTreeNode.hxx
|
||||
|
@@ -13,9 +13,9 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <TDataStd_NamedData.hxx>
|
||||
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TCollection_ExtendedString.hxx>
|
||||
#include <TColStd_DataMapIteratorOfDataMapOfStringInteger.hxx>
|
||||
#include <TDataStd_DataMapIteratorOfDataMapOfStringByte.hxx>
|
||||
@@ -29,12 +29,18 @@
|
||||
#include <TDataStd_HDataMapOfStringInteger.hxx>
|
||||
#include <TDataStd_HDataMapOfStringReal.hxx>
|
||||
#include <TDataStd_HDataMapOfStringString.hxx>
|
||||
|
||||
#include <TDataStd_NamedData.hxx>
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(TDataStd_NamedData,TDF_Attribute)
|
||||
|
||||
#ifdef _WIN32
|
||||
#define EXCEPTION ...
|
||||
#else
|
||||
#define EXCEPTION Standard_Failure
|
||||
#endif
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
@@ -69,19 +75,6 @@ Handle(TDataStd_NamedData) TDataStd_NamedData::Set(const TDF_Label& label)
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : clear
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::clear()
|
||||
{
|
||||
myIntegers.Nullify();
|
||||
myReals.Nullify();
|
||||
myStrings.Nullify();
|
||||
myBytes.Nullify();
|
||||
myArraysOfIntegers.Nullify();
|
||||
myArraysOfReals.Nullify();
|
||||
}
|
||||
|
||||
//Category: Integers
|
||||
|
||||
@@ -109,21 +102,6 @@ Standard_Integer TDataStd_NamedData::GetInteger(const TCollection_ExtendedString
|
||||
return myIntegers->Map()(theName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setInteger
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::setInteger (const TCollection_ExtendedString& theName,
|
||||
const Standard_Integer theInteger)
|
||||
{
|
||||
if (!HasIntegers())
|
||||
{
|
||||
TColStd_DataMapOfStringInteger aMap;
|
||||
myIntegers = new TDataStd_HDataMapOfStringInteger (aMap);
|
||||
}
|
||||
myIntegers->ChangeMap().Bind (theName, theInteger);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetInteger
|
||||
//purpose : Defines a named integer. If the integer already exists,
|
||||
@@ -132,23 +110,17 @@ void TDataStd_NamedData::setInteger (const TCollection_ExtendedString& theName,
|
||||
void TDataStd_NamedData::SetInteger(const TCollection_ExtendedString& theName,
|
||||
const Standard_Integer theInteger)
|
||||
{
|
||||
if (!HasIntegers())
|
||||
{
|
||||
if(!HasIntegers()) {
|
||||
TColStd_DataMapOfStringInteger aMap;
|
||||
myIntegers = new TDataStd_HDataMapOfStringInteger(aMap);
|
||||
}
|
||||
if (Standard_Integer* aValuePtr = myIntegers->ChangeMap().ChangeSeek (theName))
|
||||
{
|
||||
if (*aValuePtr != theInteger)
|
||||
{
|
||||
Backup();
|
||||
*aValuePtr = theInteger;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!myIntegers->Map().IsBound(theName) || myIntegers->Map().Find(theName) != theInteger)
|
||||
{
|
||||
Backup();
|
||||
myIntegers->ChangeMap().Bind (theName, theInteger);
|
||||
if (myIntegers->Map().IsBound(theName))
|
||||
myIntegers->ChangeMap().ChangeFind(theName) = theInteger;
|
||||
else
|
||||
myIntegers->ChangeMap().Bind(theName, theInteger);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,21 +181,6 @@ Standard_Real TDataStd_NamedData::GetReal(const TCollection_ExtendedString& theN
|
||||
return myReals->Map()(theName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setReal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::setReal (const TCollection_ExtendedString& theName,
|
||||
const Standard_Real theReal)
|
||||
{
|
||||
if (!HasReals())
|
||||
{
|
||||
TDataStd_DataMapOfStringReal aMap;
|
||||
myReals = new TDataStd_HDataMapOfStringReal (aMap);
|
||||
}
|
||||
myReals->ChangeMap().Bind (theName, theReal);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetReal
|
||||
//purpose : Defines a named real. If the real already exists,
|
||||
@@ -232,22 +189,17 @@ void TDataStd_NamedData::setReal (const TCollection_ExtendedString& theName,
|
||||
void TDataStd_NamedData::SetReal(const TCollection_ExtendedString& theName,
|
||||
const Standard_Real theReal)
|
||||
{
|
||||
if (!HasReals())
|
||||
{
|
||||
if(!HasReals()) {
|
||||
TDataStd_DataMapOfStringReal aMap;
|
||||
myReals = new TDataStd_HDataMapOfStringReal(aMap);
|
||||
}
|
||||
if (Standard_Real* aValuePtr = myReals->ChangeMap().ChangeSeek (theName))
|
||||
}
|
||||
if (!myReals->Map().IsBound(theName) || myReals->Map().Find(theName) != theReal)
|
||||
{
|
||||
if (*aValuePtr != theReal)
|
||||
{
|
||||
Backup();
|
||||
*aValuePtr = theReal;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
myReals->ChangeMap().Bind (theName, theReal);
|
||||
Backup();
|
||||
if (myReals->Map().IsBound(theName))
|
||||
myReals->ChangeMap().ChangeFind(theName) = theReal;
|
||||
else
|
||||
myReals->ChangeMap().Bind(theName, theReal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,22 +258,6 @@ const TCollection_ExtendedString& TDataStd_NamedData::GetString(const TCollectio
|
||||
return myStrings->Map()(theName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::setString (const TCollection_ExtendedString& theName,
|
||||
const TCollection_ExtendedString& theString)
|
||||
{
|
||||
if (!HasStrings())
|
||||
{
|
||||
TDataStd_DataMapOfStringString aMap;
|
||||
myStrings = new TDataStd_HDataMapOfStringString (aMap);
|
||||
}
|
||||
|
||||
myStrings->ChangeMap().Bind (theName, theString);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetString
|
||||
//purpose : Defines a named string. If the string already exists,
|
||||
@@ -330,24 +266,17 @@ void TDataStd_NamedData::setString (const TCollection_ExtendedString& theName,
|
||||
void TDataStd_NamedData::SetString(const TCollection_ExtendedString& theName,
|
||||
const TCollection_ExtendedString& theString)
|
||||
{
|
||||
if (!HasStrings())
|
||||
{
|
||||
if(!HasStrings()) {
|
||||
TDataStd_DataMapOfStringString aMap;
|
||||
myStrings = new TDataStd_HDataMapOfStringString(aMap);
|
||||
}
|
||||
|
||||
if (TCollection_ExtendedString* aValuePtr = myStrings->ChangeMap().ChangeSeek (theName))
|
||||
{
|
||||
if (*aValuePtr != theString)
|
||||
{
|
||||
Backup();
|
||||
*aValuePtr = theString;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!myStrings->Map().IsBound(theName) || myStrings->Map().Find(theName) != theString)
|
||||
{
|
||||
Backup();
|
||||
myStrings->ChangeMap().Bind(theName, theString);
|
||||
if (myStrings->Map().IsBound(theName))
|
||||
myStrings->ChangeMap().ChangeFind(theName) = theString;
|
||||
else
|
||||
myStrings->ChangeMap().Bind(theName, theString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,21 +335,6 @@ Standard_Byte TDataStd_NamedData::GetByte(const TCollection_ExtendedString& theN
|
||||
return myBytes->Map()(theName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setByte
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::setByte (const TCollection_ExtendedString& theName,
|
||||
const Standard_Byte theByte)
|
||||
{
|
||||
if (!HasBytes())
|
||||
{
|
||||
TDataStd_DataMapOfStringByte aMap;
|
||||
myBytes = new TDataStd_HDataMapOfStringByte (aMap);
|
||||
}
|
||||
myBytes->ChangeMap().Bind (theName, theByte);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetByte
|
||||
//purpose : Defines a named byte. If the byte already exists,
|
||||
@@ -429,24 +343,17 @@ void TDataStd_NamedData::setByte (const TCollection_ExtendedString& theName,
|
||||
void TDataStd_NamedData::SetByte(const TCollection_ExtendedString& theName,
|
||||
const Standard_Byte theByte)
|
||||
{
|
||||
if (!HasBytes())
|
||||
{
|
||||
if(!HasBytes()) {
|
||||
TDataStd_DataMapOfStringByte aMap;
|
||||
myBytes = new TDataStd_HDataMapOfStringByte (aMap);
|
||||
myBytes = new TDataStd_HDataMapOfStringByte(aMap);
|
||||
}
|
||||
|
||||
if (Standard_Byte* aValuePtr = myBytes->ChangeMap().ChangeSeek (theName))
|
||||
{
|
||||
if (*aValuePtr != theByte)
|
||||
{
|
||||
Backup();
|
||||
*aValuePtr = theByte;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!myBytes->Map().IsBound(theName) || myBytes->Map().Find(theName) != theByte)
|
||||
{
|
||||
Backup();
|
||||
myBytes->ChangeMap().Bind (theName, theByte);
|
||||
if (myBytes->Map().IsBound(theName))
|
||||
myBytes->ChangeMap().ChangeFind(theName) = theByte;
|
||||
else
|
||||
myBytes->ChangeMap().Bind(theName, theByte);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,30 +416,35 @@ const Handle(TColStd_HArray1OfInteger)& TDataStd_NamedData::GetArrayOfIntegers
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setArrayOfIntegers
|
||||
//purpose :
|
||||
//function : SetArrayOfIntegers
|
||||
//purpose : Defines a named array of integer values.
|
||||
// : If the array already exists, it changes its value to <theArrayOfIntegers>.
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::setArrayOfIntegers (const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfInteger)& theArrayOfIntegers)
|
||||
void TDataStd_NamedData::SetArrayOfIntegers(const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfInteger)& theArrayOfIntegers)
|
||||
{
|
||||
if (!HasArraysOfIntegers())
|
||||
{
|
||||
if(!HasArraysOfIntegers()) {
|
||||
TDataStd_DataMapOfStringHArray1OfInteger aMap;
|
||||
myArraysOfIntegers = new TDataStd_HDataMapOfStringHArray1OfInteger (aMap);
|
||||
myArraysOfIntegers = new TDataStd_HDataMapOfStringHArray1OfInteger(aMap);
|
||||
}
|
||||
|
||||
Handle(TColStd_HArray1OfInteger) anArray;
|
||||
Backup();
|
||||
// Deep copy of the array
|
||||
Handle(TColStd_HArray1OfInteger) arr;
|
||||
if (!theArrayOfIntegers.IsNull())
|
||||
{
|
||||
// deep copy of the array
|
||||
const Standard_Integer aLower = theArrayOfIntegers->Lower(), anUpper = theArrayOfIntegers->Upper();
|
||||
anArray = new TColStd_HArray1OfInteger (aLower, anUpper);
|
||||
for (Standard_Integer anIter = aLower; anIter <= anUpper; ++anIter)
|
||||
Standard_Integer lower = theArrayOfIntegers->Lower(), i = lower, upper = theArrayOfIntegers->Upper();
|
||||
arr = new TColStd_HArray1OfInteger(lower, upper);
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
anArray->SetValue (anIter, theArrayOfIntegers->Value (anIter));
|
||||
arr->SetValue(i, theArrayOfIntegers->Value(i));
|
||||
}
|
||||
}
|
||||
myArraysOfIntegers->ChangeMap().Bind (theName, anArray);
|
||||
|
||||
if (myArraysOfIntegers->Map().IsBound(theName))
|
||||
myArraysOfIntegers->ChangeMap().ChangeFind(theName) = arr;
|
||||
else
|
||||
myArraysOfIntegers->ChangeMap().Bind(theName, arr);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -596,30 +508,35 @@ const Handle(TColStd_HArray1OfReal)& TDataStd_NamedData::GetArrayOfReals
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setArrayOfReals
|
||||
//purpose :
|
||||
//function : SetArrayOfReals
|
||||
//purpose : Defines a named array of real values.
|
||||
// : If the array already exists, it changes its value to <theArrayOfReals>.
|
||||
//=======================================================================
|
||||
void TDataStd_NamedData::setArrayOfReals (const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfReal)& theArrayOfReals)
|
||||
void TDataStd_NamedData::SetArrayOfReals(const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfReal)& theArrayOfReals)
|
||||
{
|
||||
if (!HasArraysOfReals())
|
||||
{
|
||||
if(!HasArraysOfReals()) {
|
||||
TDataStd_DataMapOfStringHArray1OfReal aMap;
|
||||
myArraysOfReals = new TDataStd_HDataMapOfStringHArray1OfReal (aMap);
|
||||
myArraysOfReals = new TDataStd_HDataMapOfStringHArray1OfReal(aMap);
|
||||
}
|
||||
Backup();
|
||||
|
||||
Handle(TColStd_HArray1OfReal) anArray;
|
||||
// Deep copy of the array
|
||||
Handle(TColStd_HArray1OfReal) arr;
|
||||
if (!theArrayOfReals.IsNull())
|
||||
{
|
||||
// deep copy of the array
|
||||
const Standard_Integer aLower = theArrayOfReals->Lower(), anUpper = theArrayOfReals->Upper();
|
||||
anArray = new TColStd_HArray1OfReal (aLower, anUpper);
|
||||
for (Standard_Integer anIter = aLower; anIter <= anUpper; ++anIter)
|
||||
Standard_Integer lower = theArrayOfReals->Lower(), i = lower, upper = theArrayOfReals->Upper();
|
||||
arr = new TColStd_HArray1OfReal(lower, upper);
|
||||
for (; i <= upper; i++)
|
||||
{
|
||||
anArray->SetValue (anIter, theArrayOfReals->Value (anIter));
|
||||
arr->SetValue(i, theArrayOfReals->Value(i));
|
||||
}
|
||||
}
|
||||
myArraysOfReals->ChangeMap().Bind (theName, anArray);
|
||||
|
||||
if (myArraysOfReals->Map().IsBound(theName))
|
||||
myArraysOfReals->ChangeMap().ChangeFind(theName) = arr;
|
||||
else
|
||||
myArraysOfReals->ChangeMap().Bind(theName, arr);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -16,23 +16,35 @@
|
||||
#ifndef _TDataStd_NamedData_HeaderFile
|
||||
#define _TDataStd_NamedData_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <TDF_Attribute.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <TColStd_DataMapOfStringInteger.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <Standard_Real.hxx>
|
||||
#include <TDataStd_DataMapOfStringReal.hxx>
|
||||
#include <TDataStd_DataMapOfStringString.hxx>
|
||||
#include <Standard_Byte.hxx>
|
||||
#include <TDataStd_DataMapOfStringByte.hxx>
|
||||
#include <TColStd_HArray1OfInteger.hxx>
|
||||
#include <TDataStd_DataMapOfStringHArray1OfInteger.hxx>
|
||||
#include <TColStd_HArray1OfReal.hxx>
|
||||
#include <TDataStd_DataMapOfStringHArray1OfReal.hxx>
|
||||
|
||||
#include <Standard_OStream.hxx>
|
||||
class TDataStd_HDataMapOfStringInteger;
|
||||
class TDataStd_HDataMapOfStringReal;
|
||||
class TDataStd_HDataMapOfStringString;
|
||||
class TDataStd_HDataMapOfStringByte;
|
||||
class TDataStd_HDataMapOfStringHArray1OfInteger;
|
||||
class TDataStd_HDataMapOfStringHArray1OfReal;
|
||||
class Standard_GUID;
|
||||
class TDF_Label;
|
||||
class TCollection_ExtendedString;
|
||||
class TDF_Attribute;
|
||||
class TDF_RelocationTable;
|
||||
|
||||
|
||||
class TDataStd_NamedData;
|
||||
DEFINE_STANDARD_HANDLE(TDataStd_NamedData, TDF_Attribute)
|
||||
@@ -40,22 +52,24 @@ DEFINE_STANDARD_HANDLE(TDataStd_NamedData, TDF_Attribute)
|
||||
//! Contains a named data.
|
||||
class TDataStd_NamedData : public TDF_Attribute
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
//! Static methods
|
||||
//! ==============
|
||||
//! Returns the ID of the named data attribute.
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
//! Finds or creates a named data attribute.
|
||||
Standard_EXPORT static Handle(TDataStd_NamedData) Set (const TDF_Label& label);
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
|
||||
Standard_EXPORT TDataStd_NamedData();
|
||||
|
||||
//! Returns true if at least one named integer value is kept in the attribute.
|
||||
Standard_Boolean HasIntegers() const { return !myIntegers.IsNull(); }
|
||||
|
||||
//! Returns true if at least one named integer value is
|
||||
//! kept in the attribute.
|
||||
Standard_Boolean HasIntegers() const;
|
||||
|
||||
//! Returns true if the attribute contains specified by Name
|
||||
//! integer value.
|
||||
Standard_EXPORT Standard_Boolean HasInteger (const TCollection_ExtendedString& theName) const;
|
||||
@@ -74,10 +88,11 @@ public:
|
||||
|
||||
//! Replace the container content by new content of the <theIntegers>.
|
||||
Standard_EXPORT void ChangeIntegers (const TColStd_DataMapOfStringInteger& theIntegers);
|
||||
|
||||
//! Returns true if at least one named real value is kept in the attribute.
|
||||
Standard_Boolean HasReals() const { return !myReals.IsNull(); }
|
||||
|
||||
|
||||
//! Returns true if at least one named real value is
|
||||
//! kept in the attribute.
|
||||
Standard_Boolean HasReals() const;
|
||||
|
||||
//! Returns true if the attribute contains a real specified by Name.
|
||||
Standard_EXPORT Standard_Boolean HasReal (const TCollection_ExtendedString& theName) const;
|
||||
|
||||
@@ -97,8 +112,8 @@ public:
|
||||
Standard_EXPORT void ChangeReals (const TDataStd_DataMapOfStringReal& theReals);
|
||||
|
||||
//! Returns true if there are some named strings in the attribute.
|
||||
Standard_Boolean HasStrings() const { return !myStrings.IsNull(); }
|
||||
|
||||
Standard_Boolean HasStrings() const;
|
||||
|
||||
//! Returns true if the attribute contains this named string.
|
||||
Standard_EXPORT Standard_Boolean HasString (const TCollection_ExtendedString& theName) const;
|
||||
|
||||
@@ -118,8 +133,8 @@ public:
|
||||
Standard_EXPORT void ChangeStrings (const TDataStd_DataMapOfStringString& theStrings);
|
||||
|
||||
//! Returns true if there are some named bytes in the attribute.
|
||||
Standard_Boolean HasBytes() const { return !myBytes.IsNull(); }
|
||||
|
||||
Standard_Boolean HasBytes() const;
|
||||
|
||||
//! Returns true if the attribute contains this named byte.
|
||||
Standard_EXPORT Standard_Boolean HasByte (const TCollection_ExtendedString& theName) const;
|
||||
|
||||
@@ -139,8 +154,8 @@ public:
|
||||
Standard_EXPORT void ChangeBytes (const TDataStd_DataMapOfStringByte& theBytes);
|
||||
|
||||
//! Returns true if there are some named arrays of integer values in the attribute.
|
||||
Standard_Boolean HasArraysOfIntegers() const { return !myArraysOfIntegers.IsNull(); }
|
||||
|
||||
Standard_Boolean HasArraysOfIntegers() const;
|
||||
|
||||
//! Returns true if the attribute contains this named array of integer values.
|
||||
Standard_EXPORT Standard_Boolean HasArrayOfIntegers (const TCollection_ExtendedString& theName) const;
|
||||
|
||||
@@ -148,17 +163,11 @@ public:
|
||||
//! It returns a NULL Handle if there is no such a named array of integers
|
||||
//! (use HasArrayOfIntegers()).
|
||||
Standard_EXPORT const Handle(TColStd_HArray1OfInteger)& GetArrayOfIntegers (const TCollection_ExtendedString& theName);
|
||||
|
||||
|
||||
//! Defines a named array of integer values.
|
||||
//! @param theName [in] key
|
||||
//! @param theArrayOfIntegers [in] new value, overrides existing (passed array will be copied by value!)
|
||||
void SetArrayOfIntegers (const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfInteger)& theArrayOfIntegers)
|
||||
{
|
||||
Backup();
|
||||
setArrayOfIntegers (theName, theArrayOfIntegers);
|
||||
}
|
||||
|
||||
//! If the array already exists, it changes its value to <theArrayOfIntegers>.
|
||||
Standard_EXPORT void SetArrayOfIntegers (const TCollection_ExtendedString& theName, const Handle(TColStd_HArray1OfInteger)& theArrayOfIntegers);
|
||||
|
||||
//! Returns the internal container of named arrays of integer values.
|
||||
Standard_EXPORT const TDataStd_DataMapOfStringHArray1OfInteger& GetArraysOfIntegersContainer();
|
||||
|
||||
@@ -166,8 +175,8 @@ public:
|
||||
Standard_EXPORT void ChangeArraysOfIntegers (const TDataStd_DataMapOfStringHArray1OfInteger& theArraysOfIntegers);
|
||||
|
||||
//! Returns true if there are some named arrays of real values in the attribute.
|
||||
Standard_Boolean HasArraysOfReals() const { return !myArraysOfReals.IsNull(); }
|
||||
|
||||
Standard_Boolean HasArraysOfReals() const;
|
||||
|
||||
//! Returns true if the attribute contains this named array of real values.
|
||||
Standard_EXPORT Standard_Boolean HasArrayOfReals (const TCollection_ExtendedString& theName) const;
|
||||
|
||||
@@ -175,119 +184,40 @@ public:
|
||||
//! It returns a NULL Handle if there is no such a named array of reals
|
||||
//! (use HasArrayOfReals()).
|
||||
Standard_EXPORT const Handle(TColStd_HArray1OfReal)& GetArrayOfReals (const TCollection_ExtendedString& theName);
|
||||
|
||||
|
||||
//! Defines a named array of real values.
|
||||
//! @param theName [in] key
|
||||
//! @param theArrayOfIntegers [in] new value, overrides existing (passed array will be copied by value!)
|
||||
void SetArrayOfReals (const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfReal)& theArrayOfReals)
|
||||
{
|
||||
Backup();
|
||||
setArrayOfReals (theName, theArrayOfReals);
|
||||
}
|
||||
|
||||
//! If the array already exists, it changes its value to <theArrayOfReals>.
|
||||
Standard_EXPORT void SetArrayOfReals (const TCollection_ExtendedString& theName, const Handle(TColStd_HArray1OfReal)& theArrayOfReals);
|
||||
|
||||
//! Returns the internal container of named arrays of real values.
|
||||
Standard_EXPORT const TDataStd_DataMapOfStringHArray1OfReal& GetArraysOfRealsContainer();
|
||||
|
||||
//! Replace the container content by new content of the <theArraysOfReals>.
|
||||
Standard_EXPORT void ChangeArraysOfReals (const TDataStd_DataMapOfStringHArray1OfReal& theArraysOfReals);
|
||||
|
||||
//! Clear data.
|
||||
void Clear()
|
||||
{
|
||||
Backup();
|
||||
clear();
|
||||
}
|
||||
|
||||
public: //! @name late-load deferred data interface
|
||||
|
||||
//! Returns TRUE if some data is not loaded from deferred storage and can be loaded using LoadDeferredData().
|
||||
//!
|
||||
//! Late-load interface allows to avoid loading auxiliary data into memory until it is needed by application
|
||||
//! and also speed up reader by skipping data chunks in file.
|
||||
//! This feature requires file format having special structure, and usually implies read-only access,
|
||||
//! therefore default implementation will return FALSE here.
|
||||
//!
|
||||
//! Late-load elements require special attention to ensure data consistency,
|
||||
//! as such elements are created in undefined state (no data) and Undo/Redo mechanism will not work until deferred data being loaded.
|
||||
//!
|
||||
//! Usage scenarios:
|
||||
//! - Application displays model in read-only way.
|
||||
//! Late-load elements are loaded temporarily on demand and immediatly unloaded.
|
||||
//! theNamedData->LoadDeferredData (true);
|
||||
//! TCollection_AsciiString aValue = theNamedData->GetString (theKey);
|
||||
//! theNamedData->UnloadDeferredData();
|
||||
//! - Application saves the model into another format.
|
||||
//! All late-load elements should be loaded (at least temporary during operation).
|
||||
//! - Application modifies the model.
|
||||
//! Late-load element should be loaded with removed link to deferred storage,
|
||||
//! so that Undo()/Redo() will work as expected since loading.
|
||||
//! theNamedData->LoadDeferredData (false);
|
||||
//! theNamedData->SetString (theKey, theNewValue);
|
||||
virtual Standard_Boolean HasDeferredData() const { return false; }
|
||||
|
||||
//! Load data from deferred storage, without calling Backup().
|
||||
//! As result, the content of the object will be overidden by data from deferred storage (which is normally read-only).
|
||||
//! @param theToKeepDeferred [in] when TRUE, the link to deferred storage will be preserved
|
||||
//! so that it will be possible calling UnloadDeferredData() afterwards for releasing memory
|
||||
//! @return FALSE if deferred storage is unavailable or deferred data has been already loaded
|
||||
virtual Standard_Boolean LoadDeferredData (Standard_Boolean theToKeepDeferred = false)
|
||||
{
|
||||
(void )theToKeepDeferred;
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Releases data if object has connected deferred storage, without calling Backup().
|
||||
//! WARNING! This operation does not unload modifications to deferred storage (normally it is read-only),
|
||||
//! so that modifications will be discarded (if any).
|
||||
//! @return FALSE if object has no deferred data
|
||||
virtual Standard_Boolean UnloadDeferredData() { return false; }
|
||||
|
||||
public:
|
||||
|
||||
//! Clear data without calling Backup().
|
||||
Standard_EXPORT void clear();
|
||||
|
||||
//! Defines a named integer (without calling Backup).
|
||||
Standard_EXPORT void setInteger (const TCollection_ExtendedString& theName,
|
||||
const Standard_Integer theInteger);
|
||||
|
||||
//! Defines a named real (without calling Backup).
|
||||
Standard_EXPORT void setReal (const TCollection_ExtendedString& theName,
|
||||
const Standard_Real theReal);
|
||||
|
||||
//! Defines a named string (without calling Backup).
|
||||
Standard_EXPORT void setString (const TCollection_ExtendedString& theName,
|
||||
const TCollection_ExtendedString& theString);
|
||||
|
||||
//! Defines a named byte (without calling Backup).
|
||||
Standard_EXPORT void setByte (const TCollection_ExtendedString& theName,
|
||||
const Standard_Byte theByte);
|
||||
|
||||
//! Defines a named array of integer values (without calling Backup).
|
||||
Standard_EXPORT void setArrayOfIntegers (const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfInteger)& theArrayOfIntegers);
|
||||
|
||||
//! Defines a named array of real values (without calling Backup).
|
||||
Standard_EXPORT void setArrayOfReals (const TCollection_ExtendedString& theName,
|
||||
const Handle(TColStd_HArray1OfReal)& theArrayOfReals);
|
||||
|
||||
public: //! @name TDF_Attribute interface
|
||||
|
||||
Standard_EXPORT virtual const Standard_GUID& ID() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(TDataStd_NamedData,TDF_Attribute)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Handle(TDataStd_HDataMapOfStringInteger) myIntegers;
|
||||
Handle(TDataStd_HDataMapOfStringReal) myReals;
|
||||
Handle(TDataStd_HDataMapOfStringString) myStrings;
|
||||
@@ -295,6 +225,14 @@ protected:
|
||||
Handle(TDataStd_HDataMapOfStringHArray1OfInteger) myArraysOfIntegers;
|
||||
Handle(TDataStd_HDataMapOfStringHArray1OfReal) myArraysOfReals;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#include <TDataStd_NamedData.lxx>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _TDataStd_NamedData_HeaderFile
|
||||
|
71
src/TDataStd/TDataStd_NamedData.lxx
Normal file
71
src/TDataStd/TDataStd_NamedData.lxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// Created on: 2007-08-20
|
||||
// Created by: Sergey ZARITCHNY
|
||||
// Copyright (c) 2007-2014 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.
|
||||
|
||||
//=======================================================================
|
||||
//function : HasIntegers
|
||||
//purpose : Returns true if there are some named integers in the attribute.
|
||||
//=======================================================================
|
||||
|
||||
inline Standard_Boolean TDataStd_NamedData::HasIntegers() const
|
||||
{
|
||||
return !myIntegers.IsNull();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasReals
|
||||
//purpose : Returns true if there are some named reals in the attribute.
|
||||
//=======================================================================
|
||||
inline Standard_Boolean TDataStd_NamedData::HasReals() const
|
||||
{
|
||||
return !myReals.IsNull();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasStrings
|
||||
//purpose : Returns true if there are some named strings in the attribute.
|
||||
//=======================================================================
|
||||
inline Standard_Boolean TDataStd_NamedData::HasStrings() const
|
||||
{
|
||||
return !myStrings.IsNull();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasBytes
|
||||
//purpose : Returns true if there are some named bytes in the attribute.
|
||||
//=======================================================================
|
||||
inline Standard_Boolean TDataStd_NamedData::HasBytes() const
|
||||
{
|
||||
return !myBytes.IsNull();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : HasArraysOfIntegers
|
||||
//purpose : Returns true if there are at least one array of integer
|
||||
// : values in the internal container of the attribute.
|
||||
//=======================================================================
|
||||
inline Standard_Boolean TDataStd_NamedData::HasArraysOfIntegers() const
|
||||
{
|
||||
return !myArraysOfIntegers.IsNull();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : HasArraysOfReals
|
||||
//purpose : Returns true if there are some named arrays of real values
|
||||
// : in the attribute.
|
||||
//=======================================================================
|
||||
inline Standard_Boolean TDataStd_NamedData::HasArraysOfReals() const
|
||||
{
|
||||
return !myArraysOfReals.IsNull();
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
TKBRep
|
||||
TKXCAF
|
||||
TKMath
|
||||
TKService
|
||||
TKernel
|
||||
TKBinL
|
||||
TKG2d
|
||||
|
@@ -3,7 +3,6 @@ TKBRep
|
||||
TKCDF
|
||||
TKMath
|
||||
TKernel
|
||||
TKService
|
||||
TKG2d
|
||||
TKGeomBase
|
||||
TKCAF
|
||||
|
@@ -52,9 +52,7 @@
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddShape
|
||||
@@ -599,7 +597,6 @@ void VrmlData_ShapeConvert::addShape (const Handle(VrmlData_Group)& theParent,
|
||||
{
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
|
||||
Handle(XCAFDoc_ColorTool) aColorTool = XCAFDoc_DocumentTool::ColorTool(theDoc->Main());
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool(theDoc->Main());
|
||||
|
||||
NCollection_DataMap<TopoDS_Shape, TDF_Label> aChildShapeToLabels;
|
||||
TDF_LabelSequence aChildLabels;
|
||||
@@ -664,50 +661,26 @@ void VrmlData_ShapeConvert::addShape (const Handle(VrmlData_Group)& theParent,
|
||||
}
|
||||
|
||||
// set color
|
||||
XCAFPrs_Style aStyle;
|
||||
Quantity_ColorRGBA aColor;
|
||||
TDF_Label aLabel, anAttribLab;
|
||||
if (aChildShapeToLabels.Find (anExp.Current(), aLabel))
|
||||
TDF_Label aColorL;
|
||||
Standard_Boolean findColor = Standard_False;
|
||||
const TDF_Label* aLabel = aChildShapeToLabels.Seek(anExp.Current());
|
||||
if (aLabel != NULL)
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aVisMat = aMatTool->GetShapeMaterial (aLabel);
|
||||
if (!aVisMat.IsNull()
|
||||
&& !aVisMat->IsEmpty())
|
||||
{
|
||||
anAttribLab = aVisMat->Label();
|
||||
aStyle.SetMaterial (aVisMat);
|
||||
}
|
||||
else if (aColorTool->GetColor (aLabel, XCAFDoc_ColorSurf, anAttribLab)
|
||||
|| aColorTool->GetColor (aLabel, XCAFDoc_ColorGen, anAttribLab))
|
||||
{
|
||||
aColorTool->GetColor (anAttribLab, aColor);
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
findColor = aColorTool->GetColor(*aLabel, XCAFDoc_ColorSurf, aColorL)
|
||||
|| aColorTool->GetColor(*aLabel, XCAFDoc_ColorGen, aColorL);
|
||||
}
|
||||
if (!aStyle.IsSetColorSurf()
|
||||
&& aStyle.Material().IsNull())
|
||||
if (!findColor)
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aVisMat = aMatTool->GetShapeMaterial (theLabel);
|
||||
if (!aVisMat.IsNull()
|
||||
&& !aVisMat->IsEmpty())
|
||||
{
|
||||
anAttribLab = aVisMat->Label();
|
||||
aStyle.SetMaterial (aVisMat);
|
||||
}
|
||||
if (aColorTool->GetColor (theLabel, XCAFDoc_ColorSurf, anAttribLab)
|
||||
|| aColorTool->GetColor (theLabel, XCAFDoc_ColorGen, anAttribLab))
|
||||
{
|
||||
aColorTool->GetColor (anAttribLab, aColor);
|
||||
aStyle.SetColorSurf (aColor);
|
||||
}
|
||||
findColor = aColorTool->GetColor(theLabel, XCAFDoc_ColorSurf, aColorL)
|
||||
|| aColorTool->GetColor(theLabel, XCAFDoc_ColorGen, aColorL);
|
||||
}
|
||||
if (!aStyle.IsSetColorSurf()
|
||||
&& aStyle.Material().IsNull())
|
||||
if (!findColor)
|
||||
{
|
||||
aShapeNode->SetAppearance(defaultMaterialFace());
|
||||
}
|
||||
else
|
||||
{
|
||||
aShapeNode->SetAppearance (makeMaterialFromStyle (aStyle, anAttribLab));
|
||||
aShapeNode->SetAppearance(makeMaterialFromColor(aColorL, aColorTool));
|
||||
}
|
||||
|
||||
myScene.AddNode(aShapeNode, theParent.IsNull() && aGroup.IsNull());
|
||||
@@ -904,20 +877,22 @@ void VrmlData_ShapeConvert::ConvertDocument(const Handle(TDocStd_Document) &theD
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : makeMaterialFromStyle
|
||||
//purpose :
|
||||
//function : makeMaterialFromColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(VrmlData_Appearance) VrmlData_ShapeConvert::makeMaterialFromStyle (const XCAFPrs_Style& theStyle,
|
||||
const TDF_Label& theAttribLab) const
|
||||
|
||||
Handle(VrmlData_Appearance) VrmlData_ShapeConvert::makeMaterialFromColor(
|
||||
const TDF_Label& theColorL,
|
||||
const Handle(XCAFDoc_ColorTool)& theColorTool) const
|
||||
{
|
||||
const Quantity_ColorRGBA aColor = !theStyle.Material().IsNull()
|
||||
? theStyle.Material()->BaseColor()
|
||||
: theStyle.GetColorSurfRGBA();
|
||||
Quantity_ColorRGBA aColor;
|
||||
theColorTool->GetColor(theColorL, aColor);
|
||||
|
||||
TCollection_AsciiString aNodeName = "_materialFace_";
|
||||
Handle(TDataStd_Name) aNameAttribute;
|
||||
if (theAttribLab.FindAttribute(TDataStd_Name::GetID(), aNameAttribute))
|
||||
if (theColorL.FindAttribute(TDataStd_Name::GetID(), aNameAttribute))
|
||||
{
|
||||
aNodeName.AssignCat(aNameAttribute->Get());
|
||||
Standard_Integer n = aNodeName.Search(" ");
|
||||
@@ -935,16 +910,19 @@ Handle(VrmlData_Appearance) VrmlData_ShapeConvert::makeMaterialFromStyle (const
|
||||
aNodeName.AssignCat(aColor.GetRGB().Blue());
|
||||
}
|
||||
|
||||
Handle(VrmlData_Appearance) anAppearance = Handle(VrmlData_Appearance)::DownCast(myScene.FindNode(aNodeName.ToCString()));
|
||||
if (anAppearance.IsNull())
|
||||
{
|
||||
Handle(VrmlData_Material) aMaterial = new VrmlData_Material (myScene, 0L);
|
||||
aMaterial->SetDiffuseColor (aColor.GetRGB());
|
||||
myScene.AddNode (aMaterial, Standard_False);
|
||||
anAppearance = new VrmlData_Appearance (myScene, aNodeName.ToCString());
|
||||
anAppearance->SetMaterial (aMaterial);
|
||||
myScene.AddNode (anAppearance, Standard_False);
|
||||
Handle(VrmlData_Appearance) anAppearance =
|
||||
Handle(VrmlData_Appearance)::DownCast(myScene.FindNode(aNodeName.ToCString()));
|
||||
if (anAppearance.IsNull()) {
|
||||
const Handle(VrmlData_Material) aMaterial =
|
||||
new VrmlData_Material(myScene, 0L);
|
||||
aMaterial->SetDiffuseColor(aColor.GetRGB());
|
||||
myScene.AddNode(aMaterial, Standard_False);
|
||||
anAppearance = new VrmlData_Appearance(myScene, aNodeName.ToCString());
|
||||
anAppearance->SetMaterial(aMaterial);
|
||||
myScene.AddNode(anAppearance, Standard_False);
|
||||
}
|
||||
|
||||
return anAppearance;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class VrmlData_Coordinate;
|
||||
class TopoDS_Face;
|
||||
class Poly_Polygon3D;
|
||||
class Poly_Triangulation;
|
||||
class XCAFPrs_Style;
|
||||
class XCAFDoc_ColorTool;
|
||||
class TDocStd_Document;
|
||||
class TDF_Label;
|
||||
|
||||
@@ -129,8 +129,9 @@ class VrmlData_ShapeConvert
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc);
|
||||
|
||||
Handle(VrmlData_Appearance) makeMaterialFromStyle (const XCAFPrs_Style& theStyle,
|
||||
const TDF_Label& theAttribLab) const;
|
||||
Handle(VrmlData_Appearance) makeMaterialFromColor(const TDF_Label& theColorL,
|
||||
const Handle(XCAFDoc_ColorTool)& theColorTool) const;
|
||||
|
||||
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
@@ -63,11 +63,5 @@ XCAFDoc_View.cxx
|
||||
XCAFDoc_View.hxx
|
||||
XCAFDoc_ViewTool.cxx
|
||||
XCAFDoc_ViewTool.hxx
|
||||
XCAFDoc_VisMaterial.cxx
|
||||
XCAFDoc_VisMaterial.hxx
|
||||
XCAFDoc_VisMaterialCommon.hxx
|
||||
XCAFDoc_VisMaterialPBR.hxx
|
||||
XCAFDoc_VisMaterialTool.cxx
|
||||
XCAFDoc_VisMaterialTool.hxx
|
||||
XCAFDoc_Volume.cxx
|
||||
XCAFDoc_Volume.hxx
|
||||
|
@@ -171,15 +171,6 @@ 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,9 +98,6 @@ 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,25 +33,7 @@
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_ColorTool,TDF_Attribute)
|
||||
|
||||
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;
|
||||
}
|
||||
#define AUTONAMING // automatically set names for labels
|
||||
|
||||
//=======================================================================
|
||||
//function : BaseLabel
|
||||
@@ -193,32 +175,36 @@ TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_Color& col) const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_ColorRGBA& theColor) const
|
||||
TDF_Label XCAFDoc_ColorTool::AddColor(const Quantity_ColorRGBA& col) const
|
||||
{
|
||||
TDF_Label aLab;
|
||||
if (FindColor (theColor, aLab))
|
||||
{
|
||||
return aLab;
|
||||
}
|
||||
TDF_Label L;
|
||||
if (FindColor(col, L)) return L;
|
||||
|
||||
// create a new color entry
|
||||
|
||||
TDF_TagSource aTag;
|
||||
aLab = aTag.NewChild (Label());
|
||||
XCAFDoc_Color::Set (aLab, theColor);
|
||||
L = aTag.NewChild(Label());
|
||||
|
||||
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);
|
||||
}
|
||||
XCAFDoc_Color::Set(L, col);
|
||||
|
||||
return aLab;
|
||||
#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;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@@ -43,17 +43,10 @@ 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,7 +13,6 @@
|
||||
// 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>
|
||||
@@ -28,12 +27,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)
|
||||
|
||||
@@ -226,17 +225,6 @@ 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 :
|
||||
@@ -258,14 +246,6 @@ 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,7 +32,6 @@ class XCAFDoc_DimTolTool;
|
||||
class XCAFDoc_MaterialTool;
|
||||
class XCAFDoc_NotesTool;
|
||||
class XCAFDoc_ViewTool;
|
||||
class XCAFDoc_VisMaterialTool;
|
||||
class TDF_Attribute;
|
||||
class TDF_RelocationTable;
|
||||
|
||||
@@ -48,6 +47,7 @@ class XCAFDoc_DocumentTool : public TDF_Attribute
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
//! Create (if not exist) DocumentTool attribute
|
||||
@@ -89,19 +89,12 @@ 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);
|
||||
|
||||
@@ -120,8 +113,6 @@ 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
|
||||
@@ -137,6 +128,22 @@ public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_DocumentTool,TDF_Attribute)
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _XCAFDoc_DocumentTool_HeaderFile
|
||||
|
@@ -1,318 +0,0 @@
|
||||
// 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_Aspects.hxx>
|
||||
#include <Graphic3d_MaterialAspect.hxx>
|
||||
#include <Standard_GUID.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <XCAFPrs_Texture.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()
|
||||
: myAlphaMode (Graphic3d_AlphaMode_BlendAuto),
|
||||
myAlphaCutOff (0.5f),
|
||||
myIsDoubleSided (Standard_True)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMetalRougnessMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetPbrMaterial (const XCAFDoc_VisMaterialPBR& theMaterial)
|
||||
{
|
||||
Backup();
|
||||
myPbrMat = theMaterial;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetCommonMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetCommonMaterial (const XCAFDoc_VisMaterialCommon& theMaterial)
|
||||
{
|
||||
Backup();
|
||||
myCommonMat = theMaterial;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetAlphaMode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetAlphaMode (Graphic3d_AlphaMode theMode,
|
||||
Standard_ShortReal theCutOff)
|
||||
{
|
||||
Backup();
|
||||
myAlphaMode = theMode;
|
||||
myAlphaCutOff = theCutOff;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDoubleSided
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::SetDoubleSided (Standard_Boolean theIsDoubleSided)
|
||||
{
|
||||
Backup();
|
||||
myIsDoubleSided = theIsDoubleSided;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::Restore (const Handle(TDF_Attribute)& theWith)
|
||||
{
|
||||
XCAFDoc_VisMaterial* anOther = dynamic_cast<XCAFDoc_VisMaterial* >(theWith.get());
|
||||
myPbrMat = anOther->myPbrMat;
|
||||
myCommonMat = anOther->myCommonMat;
|
||||
myAlphaMode = anOther->myAlphaMode;
|
||||
myAlphaCutOff = anOther->myAlphaCutOff;
|
||||
myIsDoubleSided = anOther->myIsDoubleSided;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//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->myPbrMat = myPbrMat;
|
||||
anOther->myCommonMat = myCommonMat;
|
||||
anOther->myAlphaMode = myAlphaMode;
|
||||
anOther->myAlphaCutOff = myAlphaCutOff;
|
||||
anOther->myIsDoubleSided = myIsDoubleSided;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : BaseColor
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Quantity_ColorRGBA XCAFDoc_VisMaterial::BaseColor() const
|
||||
{
|
||||
if (myPbrMat.IsDefined)
|
||||
{
|
||||
return myPbrMat.BaseColor;
|
||||
}
|
||||
else if (myCommonMat.IsDefined)
|
||||
{
|
||||
return Quantity_ColorRGBA (myCommonMat.DiffuseColor, 1.0f - myCommonMat.Transparency);
|
||||
}
|
||||
return Quantity_ColorRGBA (Quantity_NOC_WHITE);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToCommonMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XCAFDoc_VisMaterialCommon XCAFDoc_VisMaterial::ConvertToCommonMaterial()
|
||||
{
|
||||
if (myCommonMat.IsDefined)
|
||||
{
|
||||
return myCommonMat;
|
||||
}
|
||||
else if (!myPbrMat.IsDefined)
|
||||
{
|
||||
return XCAFDoc_VisMaterialCommon();
|
||||
}
|
||||
|
||||
// convert metal-roughness into common
|
||||
XCAFDoc_VisMaterialCommon aComMat;
|
||||
aComMat.IsDefined = true;
|
||||
aComMat.DiffuseColor = myPbrMat.BaseColor.GetRGB();
|
||||
aComMat.SpecularColor = Quantity_Color (Graphic3d_Vec3 (myPbrMat.Metallic));
|
||||
aComMat.Transparency = 1.0f - myPbrMat.BaseColor.Alpha();
|
||||
aComMat.Shininess = 1.0f - myPbrMat.Roughness;
|
||||
return aComMat;
|
||||
}
|
||||
|
||||
//! Compute material roughness from common material.
|
||||
static Standard_ShortReal roughnessFromCommon (const XCAFDoc_VisMaterialCommon& theMat)
|
||||
{
|
||||
Standard_Real aRoughnessFactor = 1.0 - theMat.Shininess;
|
||||
//Standard_Real aSpecIntens = theMat.SpecularColor.Light() * theMat.SpecularColor;
|
||||
const Standard_Real aSpecIntens = theMat.SpecularColor.Red() * 0.2125
|
||||
+ theMat.SpecularColor.Green() * 0.7154
|
||||
+ theMat.SpecularColor.Blue() * 0.0721;
|
||||
if (aSpecIntens < 0.1)
|
||||
{
|
||||
// low specular intensity should produce a rough material even if shininess is high
|
||||
aRoughnessFactor *= (1.0 - aSpecIntens);
|
||||
}
|
||||
return (Standard_ShortReal )aRoughnessFactor;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertToPbrMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XCAFDoc_VisMaterialPBR XCAFDoc_VisMaterial::ConvertToPbrMaterial()
|
||||
{
|
||||
if (myPbrMat.IsDefined)
|
||||
{
|
||||
return myPbrMat;
|
||||
}
|
||||
else if (!myCommonMat.IsDefined)
|
||||
{
|
||||
return XCAFDoc_VisMaterialPBR();
|
||||
}
|
||||
|
||||
XCAFDoc_VisMaterialPBR aPbrMat;
|
||||
aPbrMat.IsDefined = true;
|
||||
aPbrMat.BaseColor.SetRGB (myCommonMat.DiffuseColor);
|
||||
aPbrMat.BaseColor.SetAlpha (1.0f - myCommonMat.Transparency);
|
||||
// we allow to save any number in range [0, 1] but logically metallicity can be either 0 or 1
|
||||
aPbrMat.Metallic = ((Graphic3d_Vec3 )myCommonMat.SpecularColor).maxComp(); // > 0.1f ? 1.0 : 0.0;
|
||||
aPbrMat.Roughness = roughnessFromCommon (myCommonMat);
|
||||
return aPbrMat;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//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);
|
||||
|
||||
// convert common into metal-roughness
|
||||
if (!myPbrMat.IsDefined)
|
||||
{
|
||||
#ifdef _Graphic3d_PBRMaterial_HeaderFile
|
||||
Graphic3d_PBRMaterial aPbr;
|
||||
aPbr.SetColor (myCommonMat.DiffuseColor);
|
||||
aPbr.SetMetallic (((Graphic3d_Vec3 )myCommonMat.SpecularColor).maxComp());
|
||||
aPbr.SetRoughness (roughnessFromCommon (myCommonMat));
|
||||
theAspect.SetPBRMaterial (aPbr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (myPbrMat.IsDefined)
|
||||
{
|
||||
if (!myCommonMat.IsDefined)
|
||||
{
|
||||
// convert metal-roughness into common
|
||||
theAspect = Graphic3d_MaterialAspect (Graphic3d_NOM_UserDefined);
|
||||
theAspect.SetDiffuseColor (myPbrMat.BaseColor.GetRGB());
|
||||
theAspect.SetAlpha (myPbrMat.BaseColor.Alpha());
|
||||
theAspect.SetSpecularColor(Quantity_Color (Graphic3d_Vec3 (myPbrMat.Metallic)));
|
||||
theAspect.SetShininess (1.0f - myPbrMat.Roughness);
|
||||
}
|
||||
|
||||
#ifdef _Graphic3d_PBRMaterial_HeaderFile
|
||||
Graphic3d_PBRMaterial aPbr;
|
||||
aPbr.SetColor (myPbrMat.BaseColor);
|
||||
aPbr.SetMetallic (myPbrMat.Metallic);
|
||||
aPbr.SetRoughness(myPbrMat.Roughness);
|
||||
aPbr.SetEmission (myPbrMat.EmissiveFactor);
|
||||
theAspect.SetPBRMaterial (aPbr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FillAspect
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFDoc_VisMaterial::FillAspect (const Handle(Graphic3d_Aspects)& theAspect) const
|
||||
{
|
||||
if (IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Graphic3d_MaterialAspect aMaterial;
|
||||
FillMaterialAspect (aMaterial);
|
||||
theAspect->SetFrontMaterial (aMaterial);
|
||||
theAspect->SetAlphaMode (myAlphaMode , myAlphaCutOff);
|
||||
theAspect->SetSuppressBackFaces (!myIsDoubleSided);
|
||||
|
||||
Handle(Image_Texture) aColorTexture, aNormTexture;
|
||||
if (!myCommonMat.DiffuseTexture.IsNull())
|
||||
{
|
||||
aColorTexture = myCommonMat.DiffuseTexture;
|
||||
}
|
||||
else if (!myPbrMat.BaseColorTexture.IsNull())
|
||||
{
|
||||
aColorTexture = myPbrMat.BaseColorTexture;
|
||||
}
|
||||
|
||||
if (!myPbrMat.NormalTexture.IsNull())
|
||||
{
|
||||
aNormTexture = myPbrMat.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));
|
||||
}
|
||||
theAspect->SetTextureSet (aTextureSet);
|
||||
theAspect->SetTextureMapOn (true);
|
||||
}
|
||||
}
|
@@ -1,171 +0,0 @@
|
||||
// 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 <TDF_Attribute.hxx>
|
||||
#include <XCAFDoc_VisMaterialCommon.hxx>
|
||||
#include <XCAFDoc_VisMaterialPBR.hxx>
|
||||
|
||||
class Graphic3d_Aspects;
|
||||
class Graphic3d_MaterialAspect;
|
||||
|
||||
//! Attribute storing Material definition for visualization purposes.
|
||||
//!
|
||||
//! Visualization material provides extended information about how object should be displayed on the screen
|
||||
//! (albedo, metalness, roughness - not just a single color as in case of XCAFDoc_Color).
|
||||
//! It is expected to correlate with physical material properties (XCAFDoc_Material), but not necessarily (like painted/polished/rusty object).
|
||||
//!
|
||||
//! The document defines the list of visualization materials via global attribute XCAFDoc_VisMaterialTool,
|
||||
//! while particular material assignment to the shape is done through tree-nodes links.
|
||||
//! Therefore, XCAFDoc_VisMaterialTool methods should be used for managing XCAFDoc_VisMaterial attributes.
|
||||
//!
|
||||
//! Visualization material definition consists of two options: Common and PBR (for Physically Based Rendering).
|
||||
//! Common material definition is an obsolete model defined by very first version of OpenGL graphics API
|
||||
//! and having specific hardware-accelerated implementation in past (like T&L).
|
||||
//! PBR metallic-roughness model is closer to physical material properties, and intended to be used within physically-based renderer.
|
||||
//!
|
||||
//! For compatibility reasons, this attribute allows defining both material models,
|
||||
//! so that it is up-to Data Exchange and Application deciding which one to define and use for rendering (depending on viewer capabilities).
|
||||
//! Automatic conversion from one model to another is possible, but lossy (converted material will not look the same).
|
||||
//!
|
||||
//! Within Data Exchange, different file formats have different capabilities for storing visualization material properties
|
||||
//! from simple color (STEP, IGES), to common (OBJ, glTF 1.0) and PBR (glTF 2.0).
|
||||
//! This should be taken into account while defining or converting document into one or another format - material definition might be lost or disturbed.
|
||||
//!
|
||||
//! @sa XCAFDoc_VisMaterialTool
|
||||
class XCAFDoc_VisMaterial : public TDF_Attribute
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_VisMaterial, TDF_Attribute)
|
||||
public:
|
||||
|
||||
//! Return attribute GUID.
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
public:
|
||||
|
||||
//! Empty constructor.
|
||||
Standard_EXPORT XCAFDoc_VisMaterial();
|
||||
|
||||
//! Return TRUE if material definition is empty.
|
||||
bool IsEmpty() const { return !myPbrMat.IsDefined && !myCommonMat.IsDefined; }
|
||||
|
||||
//! Fill in material aspect.
|
||||
Standard_EXPORT void FillMaterialAspect (Graphic3d_MaterialAspect& theAspect) const;
|
||||
|
||||
//! Fill in graphic aspects.
|
||||
Standard_EXPORT void FillAspect (const Handle(Graphic3d_Aspects)& theAspect) const;
|
||||
|
||||
//! Return TRUE if metal-roughness PBR material is defined.
|
||||
Standard_Boolean HasPbrMaterial() const { return myPbrMat.IsDefined; }
|
||||
|
||||
//! Return metal-roughness PBR material.
|
||||
const XCAFDoc_VisMaterialPBR& PbrMaterial() const { return myPbrMat; }
|
||||
|
||||
//! Setup metal-roughness PBR material.
|
||||
Standard_EXPORT void SetPbrMaterial (const XCAFDoc_VisMaterialPBR& theMaterial);
|
||||
|
||||
//! Setup undefined metal-roughness PBR material.
|
||||
void UnsetPbrMaterial() { SetPbrMaterial (XCAFDoc_VisMaterialPBR()); }
|
||||
|
||||
//! 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()); }
|
||||
|
||||
//! Return base color.
|
||||
Standard_EXPORT Quantity_ColorRGBA BaseColor() const;
|
||||
|
||||
//! Return alpha mode; Graphic3d_AlphaMode_BlendAuto by default.
|
||||
Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
|
||||
|
||||
//! Return alpha cutoff value; 0.5 by default.
|
||||
Standard_ShortReal AlphaCutOff() const { return myAlphaCutOff; }
|
||||
|
||||
//! Set alpha mode.
|
||||
Standard_EXPORT void SetAlphaMode (Graphic3d_AlphaMode theMode,
|
||||
Standard_ShortReal theCutOff = 0.5f);
|
||||
|
||||
//! Specifies whether the material is double sided; TRUE by default.
|
||||
Standard_Boolean IsDoubleSided() const { return myIsDoubleSided; }
|
||||
|
||||
//! Specifies whether the material is double sided.
|
||||
Standard_EXPORT void SetDoubleSided (Standard_Boolean theIsDoubleSided);
|
||||
|
||||
//! Return material name / tag (transient data, not stored in the document).
|
||||
const Handle(TCollection_HAsciiString)& RawName() const { return myRawName; }
|
||||
|
||||
//! Set material name / tag (transient data, not stored in the document).
|
||||
void SetRawName (const Handle(TCollection_HAsciiString)& theName) { myRawName = theName; }
|
||||
|
||||
//! Compare two materials.
|
||||
//! Performs deep comparison by actual values - e.g. can be useful for merging materials.
|
||||
Standard_Boolean IsEqual (const Handle(XCAFDoc_VisMaterial)& theOther) const
|
||||
{
|
||||
if (theOther.get() == this)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return theOther->myIsDoubleSided == myIsDoubleSided
|
||||
&& theOther->myAlphaCutOff == myAlphaCutOff
|
||||
&& theOther->myAlphaMode == myAlphaMode
|
||||
&& theOther->myCommonMat.IsEqual (myCommonMat)
|
||||
&& theOther->myPbrMat.IsEqual (myPbrMat);
|
||||
}
|
||||
|
||||
//! Return Common material or convert PBR into Common material.
|
||||
Standard_EXPORT XCAFDoc_VisMaterialCommon ConvertToCommonMaterial();
|
||||
|
||||
//! Return PBR material or convert Common into PBR material.
|
||||
Standard_EXPORT XCAFDoc_VisMaterialPBR ConvertToPbrMaterial();
|
||||
|
||||
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:
|
||||
|
||||
Handle(TCollection_HAsciiString) myRawName; //!< material name / tag (transient data)
|
||||
XCAFDoc_VisMaterialPBR myPbrMat; //!< metal-roughness material definition
|
||||
XCAFDoc_VisMaterialCommon myCommonMat; //!< common material definition
|
||||
Graphic3d_AlphaMode myAlphaMode; //!< alpha mode; Graphic3d_AlphaMode_BlendAuto by default
|
||||
Standard_ShortReal myAlphaCutOff; //!< alpha cutoff value; 0.5 by default
|
||||
Standard_Boolean myIsDoubleSided; //!< specifies whether the material is double sided; TRUE by default
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(XCAFDoc_VisMaterial, TDF_Attribute)
|
||||
|
||||
#endif // _XCAFDoc_VisMaterial_HeaderFile
|
@@ -1,73 +0,0 @@
|
||||
// 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_VisMaterialCommon_HeaderFile
|
||||
#define _XCAFDoc_VisMaterialCommon_HeaderFile
|
||||
|
||||
#include <Graphic3d_AlphaMode.hxx>
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <Image_Texture.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
|
||||
class Graphic3d_Aspects;
|
||||
class Graphic3d_MaterialAspect;
|
||||
|
||||
//! Common (obsolete) material definition.
|
||||
struct XCAFDoc_VisMaterialCommon
|
||||
{
|
||||
Handle(Image_Texture) DiffuseTexture; //!< image defining diffuse 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.DiffuseTexture == DiffuseTexture
|
||||
&& theOther.AmbientColor == AmbientColor
|
||||
&& theOther.DiffuseColor == DiffuseColor
|
||||
&& theOther.SpecularColor == SpecularColor
|
||||
&& theOther.EmissiveColor == EmissiveColor
|
||||
&& theOther.Shininess == Shininess
|
||||
&& theOther.Transparency == Transparency;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _XCAFDoc_VisMaterialCommon_HeaderFile
|
@@ -1,72 +0,0 @@
|
||||
// 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_VisMaterialPBR_HeaderFile
|
||||
#define _XCAFDoc_VisMaterialPBR_HeaderFile
|
||||
|
||||
#include <Graphic3d_AlphaMode.hxx>
|
||||
#include <Graphic3d_Vec.hxx>
|
||||
#include <Image_Texture.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
|
||||
//! Metallic-roughness PBR material definition.
|
||||
struct XCAFDoc_VisMaterialPBR
|
||||
{
|
||||
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_VisMaterialPBR()
|
||||
: BaseColor (1.0f, 1.0f, 1.0f, 1.0f),
|
||||
EmissiveFactor (0.0f, 0.0f, 0.0f),
|
||||
Metallic (1.0f),
|
||||
Roughness (1.0f),
|
||||
IsDefined (Standard_False) {}
|
||||
|
||||
//! Compare two materials.
|
||||
Standard_Boolean IsEqual (const XCAFDoc_VisMaterialPBR& 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;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _XCAFDoc_VisMaterialPBR_HeaderFile
|
@@ -1,292 +0,0 @@
|
||||
// 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)
|
||||
|
||||
//=======================================================================
|
||||
//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 : AddMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TDF_Label XCAFDoc_VisMaterialTool::AddMaterial (const Handle(XCAFDoc_VisMaterial)& theMat,
|
||||
const TCollection_AsciiString& theName) const
|
||||
{
|
||||
TDF_TagSource aTag;
|
||||
TDF_Label aLab = aTag.NewChild (Label());
|
||||
aLab.AddAttribute (theMat);
|
||||
if (!theName.IsEmpty())
|
||||
{
|
||||
TDataStd_Name::Set (aLab, theName);
|
||||
}
|
||||
return aLab;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
TDF_Label XCAFDoc_VisMaterialTool::AddMaterial (const TCollection_AsciiString& theName) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aNewMat = new XCAFDoc_VisMaterial();
|
||||
TDF_TagSource aTag;
|
||||
TDF_Label aLab = aTag.NewChild (Label());
|
||||
aLab.AddAttribute (aNewMat);
|
||||
if (!theName.IsEmpty())
|
||||
{
|
||||
TDataStd_Name::Set (aLab, theName);
|
||||
}
|
||||
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
|
||||
{
|
||||
if (theMaterialLabel.IsNull())
|
||||
{
|
||||
theShapeLabel.ForgetAttribute (XCAFDoc::VisMaterialRefGUID());
|
||||
return;
|
||||
}
|
||||
|
||||
// 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 : IsSetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::IsSetShapeMaterial (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 Label().HasChild() // do not waste time on shape attributes if materials map is empty
|
||||
&& 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 : IsSetShapeMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XCAFDoc_VisMaterialTool::IsSetShapeMaterial (const TopoDS_Shape& theShape)
|
||||
{
|
||||
TDF_Label aShapeLabel;
|
||||
return ShapeTool()->Search (theShape, aShapeLabel)
|
||||
&& IsSetShapeMaterial (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)();
|
||||
}
|
@@ -1,141 +0,0 @@
|
||||
// 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;
|
||||
|
||||
//! Provides tools to store and retrieve attributes (visualization materials) of TopoDS_Shape in and from TDocStd_Document.
|
||||
//!
|
||||
//! This attribute defines the list of visualization materials (XCAFDoc_VisMaterial) within the whole document.
|
||||
//! Particular material is assigned to the shape through tree-nodes links.
|
||||
//!
|
||||
//! Visualization materials might co-exists with independent color attributes (XCAFDoc_ColorTool),
|
||||
//! but beware to preserve consistency between them (it is better using one attribute type at once to avoid ambiguity).
|
||||
//! Unlike color attributes, list of materials should be managed explicitly by application,
|
||||
//! so that there is no tool eliminating material duplicates or removing unused materials.
|
||||
//!
|
||||
//! @sa XCAFDoc_VisMaterial
|
||||
class XCAFDoc_VisMaterialTool : public TDF_Attribute
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFDoc_VisMaterialTool, TDF_Attribute)
|
||||
public:
|
||||
|
||||
//! Creates (if not exist) ColorTool.
|
||||
Standard_EXPORT static Handle(XCAFDoc_VisMaterialTool) Set (const TDF_Label& L);
|
||||
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
|
||||
public:
|
||||
//! Empty constructor.
|
||||
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;
|
||||
|
||||
//! Adds Material definition to a Material Table and returns its Label.
|
||||
Standard_EXPORT TDF_Label AddMaterial (const Handle(XCAFDoc_VisMaterial)& theMat,
|
||||
const TCollection_AsciiString& theName) const;
|
||||
|
||||
//! Adds Material definition to a Material Table and returns its Label.
|
||||
Standard_EXPORT TDF_Label AddMaterial(const TCollection_AsciiString& theName) 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 new material to the shape.
|
||||
Standard_EXPORT void SetShapeMaterial (const TDF_Label& theShapeLabel,
|
||||
const TDF_Label& theMaterialLabel) const;
|
||||
|
||||
//! Removes a link with GUID XCAFDoc::VisMaterialRefGUID() from shape label to material.
|
||||
Standard_EXPORT void UnSetShapeMaterial (const TDF_Label& theShapeLabel) const;
|
||||
|
||||
//! Returns TRUE if label has a material assignment.
|
||||
Standard_EXPORT Standard_Boolean IsSetShapeMaterial (const TDF_Label& theLabel) const;
|
||||
|
||||
//! Returns label with material assigned to shape label.
|
||||
//! @param theShapeLabel [in] shape label
|
||||
//! @param theMaterialLabel [out] material label
|
||||
//! @return FALSE if no material is assigned
|
||||
Standard_EXPORT static Standard_Boolean GetShapeMaterial (const TDF_Label& theShapeLabel, TDF_Label& theMaterialLabel);
|
||||
|
||||
//! Returns material assigned to the shape label.
|
||||
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetShapeMaterial (const TDF_Label& theShapeLabel);
|
||||
|
||||
//! Sets a link with GUID XCAFDoc::VisMaterialRefGUID() from shape label to material label.
|
||||
//! @param theShape [in] shape
|
||||
//! @param theMaterialLabel [in] material label
|
||||
//! @return FALSE if cannot find a label for shape
|
||||
Standard_EXPORT Standard_Boolean SetShapeMaterial (const TopoDS_Shape& theShape,
|
||||
const TDF_Label& theMaterialLabel);
|
||||
|
||||
//! Removes a link with GUID XCAFDoc::VisMaterialRefGUID() from shape label to material.
|
||||
//! @return TRUE if such link existed
|
||||
Standard_EXPORT Standard_Boolean UnSetShapeMaterial (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Returns TRUE if shape has a material assignment.
|
||||
Standard_EXPORT Standard_Boolean IsSetShapeMaterial (const TopoDS_Shape& theShape);
|
||||
|
||||
//! Returns label with material assigned to shape.
|
||||
//! @param theShape [in] shape
|
||||
//! @param theMaterialLabel [out] material label
|
||||
//! @return FALSE if no material is assigned
|
||||
Standard_EXPORT Standard_Boolean GetShapeMaterial (const TopoDS_Shape& theShape, TDF_Label& theMaterialLabel);
|
||||
|
||||
//! Returns material assigned to shape or NULL if not assigned.
|
||||
Standard_EXPORT Handle(XCAFDoc_VisMaterial) GetShapeMaterial (const TopoDS_Shape& theShape);
|
||||
|
||||
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
|
@@ -16,5 +16,3 @@ XCAFPrs_Driver.cxx
|
||||
XCAFPrs_Driver.hxx
|
||||
XCAFPrs_Style.cxx
|
||||
XCAFPrs_Style.hxx
|
||||
XCAFPrs_Texture.cxx
|
||||
XCAFPrs_Texture.hxx
|
||||
|
@@ -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,33 +29,12 @@
|
||||
#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,
|
||||
@@ -149,8 +128,6 @@ 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
|
||||
@@ -159,14 +136,12 @@ 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));
|
||||
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames;
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (aLabel);
|
||||
if (aStyle.IsVisible())
|
||||
Standard_Boolean isVisible = aColorTool->IsVisible (aLabel);
|
||||
if (isVisible)
|
||||
{
|
||||
aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
Handle(XCAFDoc_LayerTool) aLayerTool = XCAFDoc_DocumentTool::LayerTool (aLabel);
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerNames = new TColStd_HSequenceOfExtendedString();
|
||||
aLayerTool->GetLayers (aLabel, aLayerNames);
|
||||
Standard_Integer aNbHidden = 0;
|
||||
for (TColStd_HSequenceOfExtendedString::Iterator aLayerIter (*aLayerNames); aLayerIter.More(); aLayerIter.Next())
|
||||
@@ -177,38 +152,54 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
++aNbHidden;
|
||||
}
|
||||
}
|
||||
aStyle.SetVisibility (aNbHidden == 0
|
||||
|| aNbHidden != aLayerNames->Length());
|
||||
isVisible = aNbHidden == 0
|
||||
|| aNbHidden != aLayerNames->Length();
|
||||
}
|
||||
|
||||
if (aColorTool->IsColorByLayer (aLabel))
|
||||
if (!isVisible)
|
||||
{
|
||||
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);
|
||||
aStyle.SetVisibility (Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
fillStyleColors (aStyle, aColorTool, aLabel);
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PTV try to set color from SHUO structure
|
||||
const Handle(XCAFDoc_ShapeTool)& aShapeTool = aColorTool->ShapeTool();
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool = aColorTool->ShapeTool();
|
||||
if (aShapeTool->IsComponent (aLabel))
|
||||
{
|
||||
TDF_AttributeSequence aShuoAttribSeq;
|
||||
@@ -231,11 +222,31 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
}
|
||||
|
||||
Quantity_ColorRGBA aColor;
|
||||
XCAFPrs_Style aShuoStyle;
|
||||
aShuoStyle.SetMaterial (aMatTool->GetShapeMaterial (aShuolab));
|
||||
aShuoStyle.SetVisibility(aColorTool->IsVisible (aShuolab));
|
||||
fillStyleColors (aShuoStyle, aColorTool, aShuolab);
|
||||
if (aShuoStyle.IsEmpty())
|
||||
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())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -282,7 +293,9 @@ void XCAFPrs::CollectStyleSettings (const TDF_Label& theLabel,
|
||||
}
|
||||
}
|
||||
|
||||
if (aStyle.IsEmpty())
|
||||
if (!aStyle.IsSetColorCurv()
|
||||
&& !aStyle.IsSetColorSurf()
|
||||
&& aStyle.IsVisible())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@
|
||||
#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>
|
||||
@@ -38,6 +37,7 @@
|
||||
#include <XCAFPrs_DataMapIteratorOfIndexedDataMapOfShapeStyle.hxx>
|
||||
#include <XCAFPrs_Style.hxx>
|
||||
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFPrs_AISObject,AIS_ColoredShape)
|
||||
|
||||
//=======================================================================
|
||||
@@ -139,7 +139,10 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
// Getting default colors
|
||||
XCAFPrs_Style aDefStyle;
|
||||
DefaultStyle (aDefStyle);
|
||||
setStyleToDrawer (myDrawer, aDefStyle, aDefStyle, myDrawer->ShadingAspect()->Aspect()->FrontMaterial());
|
||||
Quantity_Color aColorCurv = aDefStyle.GetColorCurv();
|
||||
Quantity_ColorRGBA aColorSurf = aDefStyle.GetColorSurfRGBA();
|
||||
|
||||
SetColors (myDrawer, aColorCurv, aColorSurf);
|
||||
|
||||
// collect sub-shapes with the same style into compounds
|
||||
BRep_Builder aBuilder;
|
||||
@@ -181,17 +184,11 @@ void XCAFPrs_AISObject::DispatchStyles (const Standard_Boolean theToSyncStyles)
|
||||
myShapeColors.Bind (aShapeCur, aDrawer);
|
||||
const XCAFPrs_Style& aStyle = aStyleGroupIter.Key();
|
||||
aDrawer->SetHidden (!aStyle.IsVisible());
|
||||
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());
|
||||
|
||||
aColorCurv = aStyle.IsSetColorCurv() ? aStyle.GetColorCurv() : aDefStyle.GetColorCurv();
|
||||
aColorSurf = aStyle.IsSetColorSurf() ? aStyle.GetColorSurfRGBA() : aDefStyle.GetColorSurfRGBA();
|
||||
|
||||
SetColors (aDrawer, aColorCurv, aColorSurf);
|
||||
}
|
||||
aStyleGroups.Clear();
|
||||
}
|
||||
@@ -246,48 +243,83 @@ void XCAFPrs_AISObject::Compute (const Handle(PrsMgr_PresentationManager3d)& the
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setStyleToDrawer
|
||||
//function : SetColors
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XCAFPrs_AISObject::setStyleToDrawer (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const XCAFPrs_Style& theStyle,
|
||||
const XCAFPrs_Style& theDefStyle,
|
||||
const Graphic3d_MaterialAspect& theDefMaterial)
|
||||
void XCAFPrs_AISObject::SetColors (const Handle(Prs3d_Drawer)& theDrawer,
|
||||
const Quantity_Color& theColorCurv,
|
||||
const Quantity_ColorRGBA& theColorSurf)
|
||||
{
|
||||
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())
|
||||
if (!theDrawer->HasOwnShadingAspect())
|
||||
{
|
||||
anXMat->FillAspect (theDrawer->ShadingAspect()->Aspect());
|
||||
aMaterial = theDrawer->ShadingAspect()->Aspect()->FrontMaterial();
|
||||
aSurfColor = Quantity_ColorRGBA (aMaterial.Color(), aMaterial.Alpha());
|
||||
aCurvColor = aMaterial.Color();
|
||||
theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (theStyle.IsSetColorSurf())
|
||||
if (!theDrawer->HasOwnLineAspect())
|
||||
{
|
||||
aSurfColor = theStyle.GetColorSurfRGBA();
|
||||
aMaterial.SetColor (aSurfColor.GetRGB());
|
||||
aMaterial.SetAlpha (aSurfColor.Alpha());
|
||||
theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
|
||||
if (theDrawer->HasLink())
|
||||
{
|
||||
*theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
|
||||
}
|
||||
}
|
||||
if (theStyle.IsSetColorCurv())
|
||||
if (!theDrawer->HasOwnWireAspect())
|
||||
{
|
||||
aCurvColor = theStyle.GetColorCurv();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
theDrawer->UnFreeBoundaryAspect()->SetColor (aCurvColor);
|
||||
theDrawer->FreeBoundaryAspect()->SetColor (aCurvColor);
|
||||
theDrawer->WireAspect()->SetColor (aCurvColor);
|
||||
theDrawer->UnFreeBoundaryAspect()->SetColor (theColorCurv);
|
||||
theDrawer->FreeBoundaryAspect()->SetColor (theColorCurv);
|
||||
theDrawer->WireAspect()->SetColor (theColorCurv);
|
||||
|
||||
theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (aSurfColor);
|
||||
Graphic3d_MaterialAspect aMaterial = myDrawer->ShadingAspect()->Aspect()->FrontMaterial();
|
||||
aMaterial.SetColor (theColorSurf.GetRGB());
|
||||
aMaterial.SetAlpha (theColorSurf.Alpha());
|
||||
theDrawer->ShadingAspect()->Aspect()->SetInteriorColor (theColorSurf);
|
||||
theDrawer->ShadingAspect()->Aspect()->SetFrontMaterial (aMaterial);
|
||||
theDrawer->UIsoAspect()->SetColor (aSurfColor.GetRGB());
|
||||
theDrawer->VIsoAspect()->SetColor (aSurfColor.GetRGB());
|
||||
theDrawer->UIsoAspect()->SetColor (theColorSurf.GetRGB());
|
||||
theDrawer->VIsoAspect()->SetColor (theColorSurf.GetRGB());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -309,25 +341,17 @@ void XCAFPrs_AISObject::SetMaterial (const Graphic3d_MaterialAspect& theMaterial
|
||||
XCAFPrs_Style aDefStyle;
|
||||
DefaultStyle (aDefStyle);
|
||||
setMaterial (myDrawer, theMaterial, HasColor(), IsTransparent());
|
||||
setStyleToDrawer (myDrawer, aDefStyle, aDefStyle, myDrawer->ShadingAspect()->Aspect()->FrontMaterial());
|
||||
SetColors (myDrawer, aDefStyle.GetColorCurv(), aDefStyle.GetColorSurf());
|
||||
for (AIS_DataMapOfShapeDrawer::Iterator anIter (myShapeColors); anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(AIS_ColoredDrawer)& aDrawer = anIter.Value();
|
||||
if (aDrawer->HasOwnMaterial())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
SynchronizeAspects();
|
||||
}
|
||||
|
@@ -57,19 +57,21 @@ 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,7 +20,6 @@
|
||||
#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
|
||||
@@ -32,21 +31,6 @@ 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; }
|
||||
|
||||
@@ -98,7 +82,6 @@ public:
|
||||
|
||||
return myHasColorSurf == theOther.myHasColorSurf
|
||||
&& myHasColorCurv == theOther.myHasColorCurv
|
||||
&& myMaterial == theOther.myMaterial
|
||||
&& (!myHasColorSurf || myColorSurf == theOther.myColorSurf)
|
||||
&& (!myHasColorCurv || myColorCurv == theOther.myColorCurv);
|
||||
}
|
||||
@@ -129,10 +112,6 @@ public:
|
||||
{
|
||||
aHashCode = aHashCode ^ Quantity_ColorHasher::HashCode (theStyle.myColorCurv, theUpperBound);
|
||||
}
|
||||
if (!theStyle.myMaterial.IsNull())
|
||||
{
|
||||
aHashCode = aHashCode ^ ::HashCode (theStyle.myMaterial, theUpperBound);
|
||||
}
|
||||
return ::HashCode (aHashCode, theUpperBound);
|
||||
}
|
||||
|
||||
@@ -147,7 +126,6 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) myMaterial;
|
||||
Quantity_ColorRGBA myColorSurf;
|
||||
Quantity_Color myColorCurv;
|
||||
Standard_Boolean myHasColorSurf;
|
||||
|
@@ -1,43 +0,0 @@
|
||||
// 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 <XCAFPrs_Texture.hxx>
|
||||
|
||||
#include <Graphic3d_TextureParams.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XCAFPrs_Texture, Graphic3d_Texture2Dmanual)
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFPrs_Texture
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XCAFPrs_Texture::XCAFPrs_Texture (const Image_Texture& theImageSource,
|
||||
const Graphic3d_TextureUnit theUnit)
|
||||
: Graphic3d_Texture2Dmanual (""),
|
||||
myImageSource (theImageSource)
|
||||
{
|
||||
if (!myImageSource.TextureId().IsEmpty())
|
||||
{
|
||||
myTexId = myImageSource.TextureId();
|
||||
}
|
||||
myParams->SetTextureUnit (theUnit);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetImage
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Image_PixMap) XCAFPrs_Texture::GetImage() const
|
||||
{
|
||||
return myImageSource.ReadImage();
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
// Created on: 2000-08-11
|
||||
// Created by: Andrey BETENEV
|
||||
// Copyright (c) 2000-2014 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 _XCAFPrs_Texture_HeaderFile
|
||||
#define _XCAFPrs_Texture_HeaderFile
|
||||
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Graphic3d_TextureUnit.hxx>
|
||||
#include <Image_Texture.hxx>
|
||||
|
||||
//! Texture holder.
|
||||
class XCAFPrs_Texture : public Graphic3d_Texture2Dmanual
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XCAFPrs_Texture, Graphic3d_Texture2Dmanual)
|
||||
public:
|
||||
|
||||
//! Constructor.
|
||||
Standard_EXPORT explicit XCAFPrs_Texture (const Image_Texture& theImageSource,
|
||||
const Graphic3d_TextureUnit theUnit);
|
||||
|
||||
//! Image reader.
|
||||
Standard_EXPORT virtual Handle(Image_PixMap) GetImage() const Standard_OVERRIDE;
|
||||
|
||||
//! Return image source.
|
||||
const Image_Texture& GetImageSource() const { return myImageSource; }
|
||||
|
||||
protected:
|
||||
|
||||
Image_Texture myImageSource;
|
||||
|
||||
};
|
||||
|
||||
#endif // _XCAFPrs_Texture_HeaderFile
|
@@ -20,20 +20,16 @@
|
||||
#include <Precision.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <ViewerTest.hxx>
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
#include <XDEDRAW_Colors.hxx>
|
||||
|
||||
//! Parse XCAFDoc_ColorType enumeration argument.
|
||||
@@ -64,102 +60,6 @@ static bool parseXDocColorType (const TCollection_AsciiString& theArg,
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Print triplet of values.
|
||||
template<class S, class T> static S& operator<< (S& theStream, const NCollection_Vec3<T>& theVec)
|
||||
{
|
||||
theStream << theVec[0] << " " << theVec[1] << " " << theVec[2];
|
||||
return theStream;
|
||||
}
|
||||
|
||||
//! Print 4 values.
|
||||
template<class S, class T> static S& operator<< (S& theStream, const NCollection_Vec4<T>& theVec)
|
||||
{
|
||||
theStream << theVec[0] << " " << theVec[1] << " " << theVec[2] << " " << theVec[3];
|
||||
return theStream;
|
||||
}
|
||||
|
||||
//! Convert alpha mode into string.
|
||||
static const char* alphaModeToString (Graphic3d_AlphaMode theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_AlphaMode_Opaque: return "Opaque";
|
||||
case Graphic3d_AlphaMode_Mask: return "Mask";
|
||||
case Graphic3d_AlphaMode_Blend: return "Blend";
|
||||
case Graphic3d_AlphaMode_BlendAuto: return "BlendAuto";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//! Find existing visualization material in the document.
|
||||
static TDF_Label findVisMaterial (const Handle(TDocStd_Document)& theDoc,
|
||||
const TCollection_AsciiString& theKey)
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (theDoc->Main());
|
||||
TDF_Label aMatLab;
|
||||
TDF_Tool::Label (theDoc->GetData(), theKey, aMatLab);
|
||||
if (!aMatLab.IsNull())
|
||||
{
|
||||
return aMatTool->IsMaterial (aMatLab) ? aMatLab : TDF_Label();
|
||||
}
|
||||
|
||||
TDF_LabelSequence aLabels;
|
||||
aMatTool->GetMaterials (aLabels);
|
||||
for (TDF_LabelSequence::Iterator aLabIter (aLabels); aLabIter.More(); aLabIter.Next())
|
||||
{
|
||||
Handle(TDataStd_Name) aNodeName;
|
||||
if (aLabIter.Value().FindAttribute (TDataStd_Name::GetID(), aNodeName)
|
||||
&& aNodeName->Get().IsEqual (theKey))
|
||||
{
|
||||
return aLabIter.Value();
|
||||
}
|
||||
}
|
||||
return TDF_Label();
|
||||
}
|
||||
|
||||
//! Check if image file exists.
|
||||
static bool isImageFileExist (const TCollection_AsciiString& thePath)
|
||||
{
|
||||
const OSD_Path aPath (thePath);
|
||||
if (!OSD_File (aPath).Exists())
|
||||
{
|
||||
std::cout << "Error: file '" << thePath << " not found\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Parse RGB values coming after specified argument.
|
||||
static bool parseRgbColor (Standard_Integer& theArgIter,
|
||||
Quantity_Color& theColor,
|
||||
Standard_Integer theNbArgs,
|
||||
const char** theArgVec)
|
||||
{
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - theArgIter - 1,
|
||||
theArgVec + theArgIter + 1,
|
||||
theColor);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error at '" << theArgVec[theArgIter] << "'\n";
|
||||
return false;
|
||||
}
|
||||
theArgIter += aNbParsed;
|
||||
return true;
|
||||
}
|
||||
|
||||
//! Parse normalized real value within 0..1 range.
|
||||
static bool parseNormalizedReal (const char* theString,
|
||||
Standard_ShortReal& theValue)
|
||||
{
|
||||
theValue = (Standard_ShortReal )Draw::Atof (theString);
|
||||
if (theValue < 0.0f || theValue > 1.0f)
|
||||
{
|
||||
std::cerr << "Syntax error at '" << theString << "'\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// Section: Work with colors
|
||||
//=======================================================================
|
||||
@@ -367,6 +267,7 @@ static Standard_Integer getAllColors (Draw_Interpretor& di, Standard_Integer arg
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static Standard_Integer addColor (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
|
||||
{
|
||||
if (argc < 3)
|
||||
@@ -719,510 +620,6 @@ static Standard_Integer setStyledcolor (Draw_Interpretor& , Standard_Integer arg
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : XGetAllVisMaterials
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
static Standard_Integer XGetAllVisMaterials (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
|
||||
{
|
||||
if (theNbArgs != 2 && theNbArgs != 3)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
DDocStd::GetDocument (theArgVec[1], aDoc);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[1] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool toPrintNames = true;
|
||||
if (theNbArgs == 3)
|
||||
{
|
||||
TCollection_AsciiString anArgCase (theArgVec[2]);
|
||||
anArgCase.LowerCase();
|
||||
if (anArgCase == "-names")
|
||||
{
|
||||
toPrintNames = true;
|
||||
}
|
||||
else if (anArgCase == "-labels")
|
||||
{
|
||||
toPrintNames = false;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (aDoc->Main());
|
||||
TDF_LabelSequence aLabels;
|
||||
aMatTool->GetMaterials (aLabels);
|
||||
Standard_Integer aMatIndex = 1;
|
||||
for (TDF_LabelSequence::Iterator aLabIter (aLabels); aLabIter.More(); aLabIter.Next(), ++aMatIndex)
|
||||
{
|
||||
const TDF_Label& aMatLab = aLabIter.Value();
|
||||
if (!toPrintNames)
|
||||
{
|
||||
TCollection_AsciiString anEntryId;
|
||||
TDF_Tool::Entry (aMatLab, anEntryId);
|
||||
theDI << anEntryId << " ";
|
||||
continue;
|
||||
}
|
||||
|
||||
Handle(TDataStd_Name) aNodeName;
|
||||
if (aMatLab.FindAttribute (TDataStd_Name::GetID(), aNodeName))
|
||||
{
|
||||
theDI << aNodeName->Get() << " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
TCollection_AsciiString aName = TCollection_AsciiString("<UNNAMED") + aMatIndex + ">";
|
||||
theDI << aName << " ";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : XGetVisMaterial
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
static Standard_Integer XGetVisMaterial (Draw_Interpretor& theDI, Standard_Integer theNbArgs, const char** theArgVec)
|
||||
{
|
||||
if (theNbArgs != 3)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
DDocStd::GetDocument (theArgVec[1], aDoc);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[1] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (aDoc->Main());
|
||||
Handle(XCAFDoc_VisMaterial) aMat;
|
||||
TDF_Label aMatLab = findVisMaterial (aDoc, theArgVec[2]);
|
||||
if (!aMatLab.IsNull())
|
||||
{
|
||||
aMat = aMatTool->GetMaterial (aMatLab);
|
||||
}
|
||||
else
|
||||
{
|
||||
TDF_Label aShapeLab;
|
||||
TDF_Tool::Label (aDoc->GetData(), theArgVec[2], aShapeLab);
|
||||
if (aShapeLab.IsNull())
|
||||
{
|
||||
TopoDS_Shape aShape = DBRep::Get (theArgVec[2]);
|
||||
if (!aShape.IsNull())
|
||||
{
|
||||
aShapeLab = aMatTool->ShapeTool()->FindShape (aShape);
|
||||
}
|
||||
}
|
||||
if (!aShapeLab.IsNull()
|
||||
&& !aMatTool->ShapeTool()->IsShape (aShapeLab))
|
||||
{
|
||||
aShapeLab.Nullify();
|
||||
}
|
||||
if (aShapeLab.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[2] << " is not material nor shape\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
aMat = aMatTool->GetShapeMaterial (aShapeLab);
|
||||
}
|
||||
|
||||
if (aMat.IsNull())
|
||||
{
|
||||
theDI << "EMPTY\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
TCollection_AsciiString anEntryId;
|
||||
TDF_Tool::Entry (aMat->Label(), anEntryId);
|
||||
theDI << "Label: " << anEntryId << "\n";
|
||||
|
||||
Handle(TDataStd_Name) aNodeName;
|
||||
if (aMat->Label().FindAttribute (TDataStd_Name::GetID(), aNodeName))
|
||||
{
|
||||
theDI << "Name: " << aNodeName->Get() << "\n";
|
||||
}
|
||||
if (aMat->IsEmpty())
|
||||
{
|
||||
theDI << "EMPTY\n";
|
||||
return 0;
|
||||
}
|
||||
theDI << "AlphaMode: " << alphaModeToString (aMat->AlphaMode()) << "\n";
|
||||
theDI << "AlphaCutOff: " << aMat->AlphaCutOff() << "\n";
|
||||
theDI << "IsDoubleSided: " << aMat->IsDoubleSided() << "\n";
|
||||
if (aMat->HasCommonMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialCommon& aMatCom = aMat->CommonMaterial();
|
||||
theDI << "Common.Ambient: " << (Graphic3d_Vec3 )aMatCom.AmbientColor << "\n";
|
||||
theDI << "Common.Diffuse: " << (Graphic3d_Vec3 )aMatCom.DiffuseColor << "\n";
|
||||
if (!aMatCom.DiffuseTexture.IsNull())
|
||||
{
|
||||
theDI << "Common.DiffuseTexture: " << aMatCom.DiffuseTexture->TextureId() << "\n";
|
||||
}
|
||||
theDI << "Common.Specular: " << (Graphic3d_Vec3 )aMatCom.SpecularColor << "\n";
|
||||
theDI << "Common.Emissive: " << (Graphic3d_Vec3 )aMatCom.EmissiveColor << "\n";
|
||||
theDI << "Common.Shininess: " << aMatCom.Shininess << "\n";
|
||||
theDI << "Common.Transparency: " << aMatCom.Transparency << "\n";
|
||||
}
|
||||
if (aMat->HasPbrMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialPBR& aMatPbr = aMat->PbrMaterial();
|
||||
theDI << "PBR.BaseColor: " << (Graphic3d_Vec3 )aMatPbr.BaseColor.GetRGB() << "\n";
|
||||
theDI << "PBR.Transparency: " << (1.0 - aMatPbr.BaseColor.Alpha()) << "\n";
|
||||
if (!aMatPbr.BaseColorTexture.IsNull())
|
||||
{
|
||||
theDI << "PBR.BaseColorTexture: " << aMatPbr.BaseColorTexture->TextureId() << "\n";
|
||||
}
|
||||
theDI << "PBR.EmissiveFactor: " << aMatPbr.EmissiveFactor << "\n";
|
||||
if (!aMatPbr.EmissiveTexture.IsNull())
|
||||
{
|
||||
theDI << "PBR.EmissiveTexture: " << aMatPbr.EmissiveTexture->TextureId() << "\n";
|
||||
}
|
||||
theDI << "PBR.Metallic: " << aMatPbr.Metallic << "\n";
|
||||
theDI << "PBR.Roughness: " << aMatPbr.Roughness << "\n";
|
||||
if (!aMatPbr.MetallicRoughnessTexture.IsNull())
|
||||
{
|
||||
theDI << "PBR.MetallicRoughnessTexture: " << aMatPbr.MetallicRoughnessTexture->TextureId() << "\n";
|
||||
}
|
||||
if (!aMatPbr.OcclusionTexture.IsNull())
|
||||
{
|
||||
theDI << "PBR.OcclusionTexture: " << aMatPbr.OcclusionTexture->TextureId() << "\n";
|
||||
}
|
||||
if (!aMatPbr.NormalTexture.IsNull())
|
||||
{
|
||||
theDI << "PBR.NormalTexture: " << aMatPbr.NormalTexture->TextureId() << "\n";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : XAddVisMaterial
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
static Standard_Integer XAddVisMaterial (Draw_Interpretor& , Standard_Integer theNbArgs, const char** theArgVec)
|
||||
{
|
||||
if (theNbArgs < 3)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
DDocStd::GetDocument (theArgVec[1], aDoc);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[1] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (aDoc->Main());
|
||||
TDF_Label aMatLab = findVisMaterial (aDoc, theArgVec[2]);
|
||||
if (aMatLab.IsNull())
|
||||
{
|
||||
aMatLab = aMatTool->AddMaterial (theArgVec[2]);
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterial) aMat = aMatTool->GetMaterial (aMatLab);
|
||||
XCAFDoc_VisMaterialCommon aMatCom = aMat->CommonMaterial();
|
||||
XCAFDoc_VisMaterialPBR aMatPbr = aMat->PbrMaterial();
|
||||
Standard_ShortReal aRealValue = 0.0f;
|
||||
for (Standard_Integer anArgIter = 3; anArgIter < theNbArgs; ++anArgIter)
|
||||
{
|
||||
TCollection_AsciiString anArg (theArgVec[anArgIter]);
|
||||
anArg.LowerCase();
|
||||
if ((anArg == "-transparency"
|
||||
|| anArg == "-alpha")
|
||||
&& anArgIter + 1 < theNbArgs
|
||||
&& parseNormalizedReal (theArgVec[anArgIter + 1], aMatCom.Transparency))
|
||||
{
|
||||
++anArgIter;
|
||||
if (anArg == "-alpha")
|
||||
{
|
||||
aMatCom.Transparency = 1.0f - aMatCom.Transparency;
|
||||
}
|
||||
aMatPbr.BaseColor.SetAlpha (1.0f - aMatCom.Transparency);
|
||||
}
|
||||
else if (anArg == "-alphaMode"
|
||||
&& anArgIter + 2 < theNbArgs
|
||||
&& parseNormalizedReal (theArgVec[anArgIter + 2], aRealValue))
|
||||
{
|
||||
TCollection_AsciiString aModeStr (theArgVec[anArgIter + 1]);
|
||||
aModeStr.LowerCase();
|
||||
Graphic3d_AlphaMode anAlphaMode = Graphic3d_AlphaMode_Opaque;
|
||||
if (aModeStr == "opaque")
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_Opaque;
|
||||
}
|
||||
else if (aModeStr == "mask")
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_Mask;
|
||||
}
|
||||
else if (aModeStr == "blend")
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_Blend;
|
||||
}
|
||||
else if (aModeStr == "blendauto")
|
||||
{
|
||||
anAlphaMode = Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Syntax error at '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
aMat->SetAlphaMode (anAlphaMode, aRealValue);
|
||||
anArgIter += 2;
|
||||
}
|
||||
else if (anArg == "-diffuse"
|
||||
|| anArg == "-basecolor"
|
||||
|| anArg == "-albedo")
|
||||
{
|
||||
Quantity_ColorRGBA aColorRGBA;
|
||||
Standard_Integer aNbParsed = ViewerTest::ParseColor (theNbArgs - anArgIter - 1,
|
||||
theArgVec + anArgIter + 1,
|
||||
aColorRGBA);
|
||||
if (aNbParsed == 0)
|
||||
{
|
||||
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
anArgIter += aNbParsed;
|
||||
|
||||
if (anArg == "-diffuse")
|
||||
{
|
||||
aMatCom.IsDefined = true;
|
||||
aMatCom.DiffuseColor = aColorRGBA.GetRGB();
|
||||
if (aNbParsed == 2 || aNbParsed == 4)
|
||||
{
|
||||
aMatCom.Transparency = 1.0f - aColorRGBA.Alpha();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
if (aNbParsed == 2 || aNbParsed == 4)
|
||||
{
|
||||
aMatPbr.BaseColor = aColorRGBA;
|
||||
}
|
||||
else
|
||||
{
|
||||
aMatPbr.BaseColor.SetRGB (aColorRGBA.GetRGB());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (anArg == "-specular"
|
||||
&& parseRgbColor (anArgIter, aMatCom.SpecularColor,
|
||||
theNbArgs, theArgVec))
|
||||
{
|
||||
aMatCom.IsDefined = true;
|
||||
}
|
||||
else if (anArg == "-ambient"
|
||||
&& parseRgbColor (anArgIter, aMatCom.AmbientColor,
|
||||
theNbArgs, theArgVec))
|
||||
{
|
||||
aMatCom.IsDefined = true;
|
||||
}
|
||||
else if (anArg == "-emissive"
|
||||
&& parseRgbColor (anArgIter, aMatCom.EmissiveColor,
|
||||
theNbArgs, theArgVec))
|
||||
{
|
||||
aMatCom.IsDefined = true;
|
||||
}
|
||||
else if (anArg == "-shininess"
|
||||
&& anArgIter + 1 < theNbArgs)
|
||||
{
|
||||
aMatCom.IsDefined = true;
|
||||
aMatCom.Shininess = (float )Draw::Atof (theArgVec[++anArgIter]);
|
||||
if (aMatCom.Shininess < 0.0f || aMatCom.Shininess > 1.0f)
|
||||
{
|
||||
std::cout << "Syntax error at '" << anArg << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-diffusetexture"
|
||||
&& isImageFileExist (theArgVec[anArgIter + 1]))
|
||||
{
|
||||
aMatCom.IsDefined = true;
|
||||
aMatCom.DiffuseTexture = new Image_Texture (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-basecolortexture"
|
||||
&& isImageFileExist (theArgVec[anArgIter + 1]))
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
aMatPbr.BaseColorTexture = new Image_Texture (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-emissivetexture"
|
||||
&& isImageFileExist (theArgVec[anArgIter + 1]))
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
aMatPbr.EmissiveTexture = new Image_Texture (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-metallicroughnesstexture"
|
||||
&& isImageFileExist (theArgVec[anArgIter + 1]))
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
aMatPbr.MetallicRoughnessTexture = new Image_Texture (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-normaltexture"
|
||||
&& isImageFileExist (theArgVec[anArgIter + 1]))
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
aMatPbr.NormalTexture = new Image_Texture (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-occlusiontexture"
|
||||
&& isImageFileExist (theArgVec[anArgIter + 1]))
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
aMatPbr.OcclusionTexture = new Image_Texture (theArgVec[++anArgIter]);
|
||||
}
|
||||
else if (anArg == "-emissivefactor"
|
||||
&& anArgIter + 4 < theNbArgs)
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
aMatPbr.EmissiveFactor.SetValues ((float )Draw::Atof (theArgVec[anArgIter + 1]),
|
||||
(float )Draw::Atof (theArgVec[anArgIter + 2]),
|
||||
(float )Draw::Atof (theArgVec[anArgIter + 3]));
|
||||
anArgIter += 3;
|
||||
}
|
||||
else if (anArg == "-doublesided")
|
||||
{
|
||||
aMatPbr.IsDefined = true;
|
||||
bool isDoubleSided = true;
|
||||
if (anArgIter + 1 < theNbArgs
|
||||
&& ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isDoubleSided))
|
||||
{
|
||||
++anArgIter;
|
||||
}
|
||||
aMat->SetDoubleSided (isDoubleSided);
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-metallic"
|
||||
&& parseNormalizedReal (theArgVec[anArgIter + 1], aMatPbr.Metallic))
|
||||
{
|
||||
++anArgIter;
|
||||
aMatPbr.IsDefined = true;
|
||||
}
|
||||
else if (anArgIter + 1 < theNbArgs
|
||||
&& anArg == "-roughness"
|
||||
&& parseNormalizedReal (theArgVec[anArgIter + 1], aMatPbr.Roughness))
|
||||
{
|
||||
++anArgIter;
|
||||
aMatPbr.IsDefined = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
aMat->SetCommonMaterial (aMatCom);
|
||||
aMat->SetPbrMaterial (aMatPbr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : XRemoveVisMaterial
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
static Standard_Integer XRemoveVisMaterial (Draw_Interpretor& , Standard_Integer theNbArgs, const char** theArgVec)
|
||||
{
|
||||
if (theNbArgs != 3)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
DDocStd::GetDocument (theArgVec[1], aDoc);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[1] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label aMatLab = findVisMaterial (aDoc, theArgVec[2]);
|
||||
if (aMatLab.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[2] << " is not a material\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (aDoc->Main());
|
||||
aMatTool->RemoveMaterial (aMatLab);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
// Function : XSetVisMaterial
|
||||
// Purpose :
|
||||
// ================================================================
|
||||
static Standard_Integer XSetVisMaterial (Draw_Interpretor& , Standard_Integer theNbArgs, const char** theArgVec)
|
||||
{
|
||||
if (theNbArgs != 3 && theNbArgs != 4)
|
||||
{
|
||||
std::cout << "Syntax error: wrong number of arguments\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDocStd_Document) aDoc;
|
||||
TDF_Label aShapeLab;
|
||||
DDocStd::GetDocument (theArgVec[1], aDoc);
|
||||
if (aDoc.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[1] << " is not a document\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Tool::Label (aDoc->GetData(), theArgVec[2], aShapeLab);
|
||||
Handle(XCAFDoc_ColorTool) aColorTool = XCAFDoc_DocumentTool::ColorTool (aDoc->Main());
|
||||
if (aShapeLab.IsNull())
|
||||
{
|
||||
// get label by shape
|
||||
TopoDS_Shape aShape = DBRep::Get (theArgVec[2]);
|
||||
if (!aShape.IsNull())
|
||||
{
|
||||
aShapeLab = aColorTool->ShapeTool()->FindShape (aShape, Standard_True);
|
||||
}
|
||||
}
|
||||
if (aShapeLab.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[2] << " is not a label not shape\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
TDF_Label aMatLab;
|
||||
if (theNbArgs == 4)
|
||||
{
|
||||
aMatLab = findVisMaterial (aDoc, theArgVec[3]);
|
||||
if (aMatLab.IsNull())
|
||||
{
|
||||
std::cout << "Syntax error: " << theArgVec[3] << " is not a material\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Handle(XCAFDoc_VisMaterialTool) aMatTool = XCAFDoc_DocumentTool::VisMaterialTool (aDoc->Main());
|
||||
aMatTool->SetShapeMaterial (aShapeLab, aMatLab);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : InitCommands
|
||||
//purpose :
|
||||
@@ -1292,32 +689,4 @@ void XDEDRAW_Colors::InitCommands(Draw_Interpretor& di)
|
||||
di.Add ("XSetInstanceColor","Doc Shape R G B [alpha] [{generic|surface|curve}=gen]"
|
||||
"\t: sets color for component of shape if SHUO structure exists already",
|
||||
__FILE__, setStyledcolor, g);
|
||||
|
||||
di.Add ("XGetAllVisMaterials","Doc [{-names|-labels}=-names]"
|
||||
"\t: Print all visualization materials defined in document",
|
||||
__FILE__, XGetAllVisMaterials, g);
|
||||
di.Add ("XGetVisMaterial","Doc {Material|Shape}"
|
||||
"\t: Print visualization material properties",
|
||||
__FILE__, XGetVisMaterial, g);
|
||||
di.Add ("XAddVisMaterial",
|
||||
"Doc Material"
|
||||
"\n\t\t: [-transparency 0..1] [-alphaMode {Opaque|Mask|Blend|BlendAuto} CutOffValue]"
|
||||
"\n\t\t: [-diffuse RGB] [-diffuseTexture ImagePath]"
|
||||
"\n\t\t: [-specular RGB] [-ambient RGB] [-emissive RGB] [-shininess 0..1]"
|
||||
"\n\t\t: [-baseColor RGB] [-baseColorTexture ImagePath]"
|
||||
"\n\t\t: [-emissiveFactor RGB] [-emissiveTexture ImagePath]"
|
||||
"\n\t\t: [-metallic 0..1] [-roughness 0..1] [-metallicRoughnessTexture ImagePath]"
|
||||
"\n\t\t: [-occlusionTexture ImagePath] [-normalTexture ImagePath]"
|
||||
"\n\t\t: [-doubleSided {0|1}]"
|
||||
"\n\t\t: Add material into Document's material table.",
|
||||
__FILE__, XAddVisMaterial, g);
|
||||
di.Add ("XRemoveVisMaterial","Doc Material"
|
||||
"\t: Remove material in document from material table",
|
||||
__FILE__, XRemoveVisMaterial, g);
|
||||
di.Add ("XSetVisMaterial", "Doc Shape Material"
|
||||
"\t: Set material to shape",
|
||||
__FILE__, XSetVisMaterial, g);
|
||||
di.Add ("XUnsetVisMaterial", "Doc Shape"
|
||||
"\t: Unset material from shape",
|
||||
__FILE__, XSetVisMaterial, g);
|
||||
}
|
||||
|
@@ -958,7 +958,6 @@ static Standard_Integer XGetProperties(Draw_Interpretor& di, Standard_Integer ar
|
||||
return 0;
|
||||
}
|
||||
|
||||
aNamedData->LoadDeferredData();
|
||||
if (aNamedData->HasIntegers())
|
||||
{
|
||||
TColStd_DataMapOfStringInteger anIntProperties = aNamedData->GetIntegersContainer();
|
||||
|
@@ -411,6 +411,22 @@ static Standard_Integer ReadObj (Draw_Interpretor& theDI,
|
||||
{
|
||||
aFilePath = theArgVec[anArgIter];
|
||||
}
|
||||
else if (theArgc == 4 && strcmp("multi", theArgv[3]) == 0)
|
||||
{
|
||||
NCollection_Sequence<Handle(Poly_Triangulation)> theTriangList;
|
||||
RWStl::ReadFile(theArgv[2], theTriangList);
|
||||
BRep_Builder aB;
|
||||
TopoDS_Compound aCmp;
|
||||
aB.MakeCompound(aCmp);
|
||||
for (int i = 1; i <= theTriangList.Length(); i++)
|
||||
{
|
||||
TopoDS_Face aFace;
|
||||
aB.MakeFace(aFace);
|
||||
aB.UpdateFace(aFace, theTriangList(i));
|
||||
aB.Add(aCmp, aFace);
|
||||
}
|
||||
DBRep::Set(theArgv[1], aCmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Syntax error at '" << theArgVec[anArgIter] << "'\n";
|
||||
|
@@ -649,7 +649,6 @@ void XmlMDataStd_NamedDataDriver::Paste(const Handle(TDF_Attribute)& theSource,
|
||||
Standard_Integer i=0, up;
|
||||
XmlObjMgt_Element& anElement = theTarget;
|
||||
XmlObjMgt_Document aDoc (anElement.getOwnerDocument());
|
||||
S->LoadDeferredData();
|
||||
if(S->HasIntegers() && !S->GetIntegersContainer().IsEmpty()) {
|
||||
// store a set of elements with string in each of them
|
||||
up = S->GetIntegersContainer().Extent();
|
||||
|
@@ -45,9 +45,5 @@ XmlMXCAFDoc_ShapeToolDriver.cxx
|
||||
XmlMXCAFDoc_ShapeToolDriver.hxx
|
||||
XmlMXCAFDoc_ViewToolDriver.cxx
|
||||
XmlMXCAFDoc_ViewToolDriver.hxx
|
||||
XmlMXCAFDoc_VisMaterialDriver.cxx
|
||||
XmlMXCAFDoc_VisMaterialDriver.hxx
|
||||
XmlMXCAFDoc_VisMaterialToolDriver.cxx
|
||||
XmlMXCAFDoc_VisMaterialToolDriver.hxx
|
||||
XmlMXCAFDoc_VolumeDriver.cxx
|
||||
XmlMXCAFDoc_VolumeDriver.hxx
|
||||
|
@@ -33,13 +33,11 @@
|
||||
#include <XmlMXCAFDoc_LayerToolDriver.hxx>
|
||||
#include <XmlMXCAFDoc_LocationDriver.hxx>
|
||||
#include <XmlMXCAFDoc_MaterialDriver.hxx>
|
||||
#include <XmlMXCAFDoc_VisMaterialDriver.hxx>
|
||||
#include <XmlMXCAFDoc_NotesToolDriver.hxx>
|
||||
#include <XmlMXCAFDoc_NoteBalloonDriver.hxx>
|
||||
#include <XmlMXCAFDoc_NoteCommentDriver.hxx>
|
||||
#include <XmlMXCAFDoc_NoteBinDataDriver.hxx>
|
||||
#include <XmlMXCAFDoc_MaterialToolDriver.hxx>
|
||||
#include <XmlMXCAFDoc_VisMaterialToolDriver.hxx>
|
||||
#include <XmlMXCAFDoc_ShapeToolDriver.hxx>
|
||||
#include <XmlMXCAFDoc_ViewToolDriver.hxx>
|
||||
#include <XmlMXCAFDoc_VolumeDriver.hxx>
|
||||
@@ -74,7 +72,6 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_DatumDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_VisMaterialDriver(anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBalloonDriver(anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteCommentDriver(anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_NoteBinDataDriver(anMsgDrv));
|
||||
@@ -85,7 +82,6 @@ void XmlMXCAFDoc::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_ShapeToolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_DimTolToolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_MaterialToolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_VisMaterialToolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_NotesToolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_ViewToolDriver (anMsgDrv));
|
||||
aDriverTable -> AddDriver (new XmlMXCAFDoc_ClippingPlaneToolDriver(anMsgDrv));
|
||||
|
@@ -1,319 +0,0 @@
|
||||
// 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 <XmlMXCAFDoc_VisMaterialDriver.hxx>
|
||||
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <XCAFDoc_VisMaterial.hxx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlObjMgt_Persistent.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_VisMaterialDriver, XmlMDF_ADriver)
|
||||
|
||||
IMPLEMENT_DOMSTRING(IsDoubleSided, "isdoublesided")
|
||||
IMPLEMENT_DOMSTRING(AlphaMode, "alpha_mode")
|
||||
IMPLEMENT_DOMSTRING(AlphaCutOff, "alpha_cutoff")
|
||||
//
|
||||
IMPLEMENT_DOMSTRING(BaseColor, "base_color")
|
||||
IMPLEMENT_DOMSTRING(EmissiveFactor, "emissive_factor")
|
||||
IMPLEMENT_DOMSTRING(Metallic, "metallic")
|
||||
IMPLEMENT_DOMSTRING(Roughness, "roughness")
|
||||
IMPLEMENT_DOMSTRING(BaseColorTexture, "base_color_texture")
|
||||
IMPLEMENT_DOMSTRING(MetallicRoughnessTexture, "metallic_roughness_texture")
|
||||
IMPLEMENT_DOMSTRING(EmissiveTexture, "emissive_texture")
|
||||
IMPLEMENT_DOMSTRING(OcclusionTexture, "occlusion_texture")
|
||||
IMPLEMENT_DOMSTRING(NormalTexture, "normal_texture")
|
||||
//
|
||||
IMPLEMENT_DOMSTRING(AmbientColor, "ambient_color")
|
||||
IMPLEMENT_DOMSTRING(DiffuseColor, "diffuse_color")
|
||||
IMPLEMENT_DOMSTRING(SpecularColor, "specular_color")
|
||||
IMPLEMENT_DOMSTRING(EmissiveColor, "emissive_color")
|
||||
IMPLEMENT_DOMSTRING(Shininess, "shininess")
|
||||
IMPLEMENT_DOMSTRING(Transparency, "transparency")
|
||||
IMPLEMENT_DOMSTRING(DiffuseTexture, "diffuse_texture")
|
||||
|
||||
//! Encode alpha mode into character.
|
||||
static const char* alphaModeToString (Graphic3d_AlphaMode theMode)
|
||||
{
|
||||
switch (theMode)
|
||||
{
|
||||
case Graphic3d_AlphaMode_Opaque: return "Opaque";
|
||||
case Graphic3d_AlphaMode_Mask: return "Mask";
|
||||
case Graphic3d_AlphaMode_Blend: return "Blend";
|
||||
case Graphic3d_AlphaMode_BlendAuto: return "Auto";
|
||||
}
|
||||
return "Auto";
|
||||
}
|
||||
|
||||
//! Decode alpha mode from string.
|
||||
static Graphic3d_AlphaMode alphaModeFromString (const char* theMode)
|
||||
{
|
||||
switch (*theMode)
|
||||
{
|
||||
case 'O': return Graphic3d_AlphaMode_Opaque;
|
||||
case 'M': return Graphic3d_AlphaMode_Mask;
|
||||
case 'B': return Graphic3d_AlphaMode_Blend;
|
||||
case 'A': return Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
return Graphic3d_AlphaMode_BlendAuto;
|
||||
}
|
||||
|
||||
//! Encode short real value.
|
||||
static void writeReal (XmlObjMgt_Persistent& theTarget,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
const Standard_ShortReal theValue)
|
||||
{
|
||||
theTarget.Element().setAttribute (theName, TCollection_AsciiString(theValue).ToCString());
|
||||
}
|
||||
|
||||
//! Encode short real value.
|
||||
static bool readReal (const XmlObjMgt_Element& theElement,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
Standard_ShortReal& theValue)
|
||||
{
|
||||
Standard_Real aValue = 0.0;
|
||||
if (XmlObjMgt::GetReal (theElement.getAttribute (theName), aValue))
|
||||
{
|
||||
theValue = (Standard_ShortReal )aValue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Encode vec3.
|
||||
static void writeVec3 (XmlObjMgt_Persistent& theTarget,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
const Graphic3d_Vec3& theVec3)
|
||||
{
|
||||
TCollection_AsciiString aString = TCollection_AsciiString() + theVec3[0] + " " + theVec3[1] + " " + theVec3[2];
|
||||
theTarget.Element().setAttribute (theName, aString.ToCString());
|
||||
}
|
||||
|
||||
//! Decode vec3.
|
||||
static bool readVec3 (const XmlObjMgt_Element& theElement,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
Graphic3d_Vec3& theVec3)
|
||||
{
|
||||
Graphic3d_Vec3 aVec3;
|
||||
LDOMString aString = theElement.getAttribute (theName);
|
||||
const char* aPos = aString.GetString();
|
||||
char* aNext = NULL;
|
||||
aVec3[0] = (float )Strtod (aPos, &aNext);
|
||||
aPos = aNext;
|
||||
aVec3[1] = (float )Strtod (aPos, &aNext);
|
||||
aPos = aNext;
|
||||
aVec3[2] = (float )Strtod (aPos, &aNext);
|
||||
if (aPos != aNext)
|
||||
{
|
||||
theVec3 = aVec3;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Decode vec3.
|
||||
static bool readColor (const XmlObjMgt_Element& theElement,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
Quantity_Color& theColor)
|
||||
{
|
||||
Graphic3d_Vec3 aVec3;
|
||||
if (readVec3 (theElement, theName, aVec3))
|
||||
{
|
||||
theColor = Quantity_Color (aVec3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Encode vec4.
|
||||
static void writeVec4 (XmlObjMgt_Persistent& theTarget,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
const Graphic3d_Vec4& theVec4)
|
||||
{
|
||||
TCollection_AsciiString aString = TCollection_AsciiString() + theVec4[0] + " " + theVec4[1] + " " + theVec4[2] + " " + theVec4[3];
|
||||
theTarget.Element().setAttribute (theName, aString.ToCString());
|
||||
}
|
||||
|
||||
//! Decode vec34
|
||||
static bool readVec4 (const XmlObjMgt_Element& theElement,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
Graphic3d_Vec4& theVec4)
|
||||
{
|
||||
Graphic3d_Vec4 aVec4;
|
||||
LDOMString aString = theElement.getAttribute (theName);
|
||||
const char* aPos = aString.GetString();
|
||||
char* aNext = NULL;
|
||||
aVec4[0] = (float )Strtod (aPos, &aNext);
|
||||
aPos = aNext;
|
||||
aVec4[1] = (float )Strtod (aPos, &aNext);
|
||||
aPos = aNext;
|
||||
aVec4[2] = (float )Strtod (aPos, &aNext);
|
||||
aPos = aNext;
|
||||
aVec4[3] = (float )Strtod (aPos, &aNext);
|
||||
if (aPos != aNext)
|
||||
{
|
||||
theVec4 = aVec4;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Decode vec4.
|
||||
static bool readColor (const XmlObjMgt_Element& theElement,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
Quantity_ColorRGBA& theColor)
|
||||
{
|
||||
Graphic3d_Vec4 aVec4;
|
||||
if (readVec4 (theElement, theName, aVec4))
|
||||
{
|
||||
theColor = Quantity_ColorRGBA (aVec4);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Encode texture path.
|
||||
static void writeTexture (XmlObjMgt_Persistent& theTarget,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
const Handle(Image_Texture)& theImage)
|
||||
{
|
||||
if (!theImage.IsNull()
|
||||
&& !theImage->FilePath().IsEmpty()
|
||||
&& theImage->FileOffset() == -1)
|
||||
{
|
||||
theTarget.Element().setAttribute (theName, theImage->FilePath().ToCString());
|
||||
}
|
||||
}
|
||||
|
||||
//! Decode texture path.
|
||||
static void readTexture (const XmlObjMgt_Element& theElement,
|
||||
const XmlObjMgt_DOMString& theName,
|
||||
Handle(Image_Texture)& theImage)
|
||||
{
|
||||
TCollection_AsciiString aPath (theElement.getAttribute (theName).GetString());
|
||||
if (!aPath.IsEmpty())
|
||||
{
|
||||
theImage = new Image_Texture (aPath);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMXCAFDoc_VisMaterialDriver
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XmlMXCAFDoc_VisMaterialDriver::XmlMXCAFDoc_VisMaterialDriver (const Handle(Message_Messenger)& theMsgDriver)
|
||||
: XmlMDF_ADriver (theMsgDriver, "xcaf", "VisMaterial")
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) XmlMXCAFDoc_VisMaterialDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_VisMaterial();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMXCAFDoc_VisMaterialDriver::Paste (const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theTarget);
|
||||
|
||||
const XmlObjMgt_DOMString aDoubleSidedStr = theSource.Element().getAttribute (::IsDoubleSided());
|
||||
Standard_Integer isDoubleSided = 1;
|
||||
aDoubleSidedStr.GetInteger (isDoubleSided);
|
||||
Standard_ShortReal anAlphaCutOff = 0.5f;
|
||||
readReal (theSource, ::AlphaCutOff(), anAlphaCutOff);
|
||||
aMat->SetDoubleSided (isDoubleSided != 0);
|
||||
aMat->SetAlphaMode (alphaModeFromString (theSource.Element().getAttribute (::AlphaMode()).GetString()), anAlphaCutOff);
|
||||
|
||||
Quantity_ColorRGBA aBaseColor;
|
||||
if (readColor (theSource, ::BaseColor(), aBaseColor))
|
||||
{
|
||||
XCAFDoc_VisMaterialPBR aPbrMat;
|
||||
aPbrMat.IsDefined = true;
|
||||
aPbrMat.BaseColor = aBaseColor;
|
||||
readVec3 (theSource, ::EmissiveFactor(), aPbrMat.EmissiveFactor);
|
||||
readReal (theSource, ::Metallic(), aPbrMat.Metallic);
|
||||
readReal (theSource, ::Roughness(), aPbrMat.Roughness);
|
||||
readTexture (theSource, ::BaseColorTexture(), aPbrMat.BaseColorTexture);
|
||||
readTexture (theSource, ::MetallicRoughnessTexture(), aPbrMat.MetallicRoughnessTexture);
|
||||
readTexture (theSource, ::EmissiveTexture(), aPbrMat.EmissiveTexture);
|
||||
readTexture (theSource, ::OcclusionTexture(), aPbrMat.OcclusionTexture);
|
||||
readTexture (theSource, ::NormalTexture(), aPbrMat.NormalTexture);
|
||||
aMat->SetPbrMaterial (aPbrMat);
|
||||
}
|
||||
|
||||
Quantity_Color aDiffColor;
|
||||
if (readColor (theSource, ::DiffuseColor(), aDiffColor))
|
||||
{
|
||||
XCAFDoc_VisMaterialCommon aComMat;
|
||||
aComMat.IsDefined = true;
|
||||
aComMat.DiffuseColor = aDiffColor;
|
||||
readColor (theSource, ::AmbientColor(), aComMat.AmbientColor);
|
||||
readColor (theSource, ::SpecularColor(), aComMat.SpecularColor);
|
||||
readColor (theSource, ::EmissiveColor(), aComMat.EmissiveColor);
|
||||
readReal (theSource, ::Shininess(), aComMat.Shininess);
|
||||
readReal (theSource, ::Transparency(), aComMat.Transparency);
|
||||
readTexture (theSource, ::DiffuseTexture(), aComMat.DiffuseTexture);
|
||||
aMat->SetCommonMaterial (aComMat);
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMXCAFDoc_VisMaterialDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(XCAFDoc_VisMaterial) aMat = Handle(XCAFDoc_VisMaterial)::DownCast(theSource);
|
||||
|
||||
theTarget.Element().setAttribute (::IsDoubleSided(), aMat->IsDoubleSided() ? 1 : 0);
|
||||
theTarget.Element().setAttribute (::AlphaMode(), alphaModeToString (aMat->AlphaMode()));
|
||||
writeReal (theTarget, ::AlphaCutOff(), aMat->AlphaCutOff());
|
||||
if (aMat->HasPbrMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialPBR& aPbrMat = aMat->PbrMaterial();
|
||||
writeVec4 (theTarget, ::BaseColor(), aPbrMat.BaseColor);
|
||||
writeVec3 (theTarget, ::EmissiveFactor(), aPbrMat.EmissiveFactor);
|
||||
writeReal (theTarget, ::Metallic(), aPbrMat.Metallic);
|
||||
writeReal (theTarget, ::Roughness(), aPbrMat.Roughness);
|
||||
writeTexture (theTarget, ::BaseColorTexture(), aPbrMat.BaseColorTexture);
|
||||
writeTexture (theTarget, ::MetallicRoughnessTexture(), aPbrMat.MetallicRoughnessTexture);
|
||||
writeTexture (theTarget, ::EmissiveTexture(), aPbrMat.EmissiveTexture);
|
||||
writeTexture (theTarget, ::OcclusionTexture(), aPbrMat.OcclusionTexture);
|
||||
writeTexture (theTarget, ::NormalTexture(), aPbrMat.NormalTexture);
|
||||
}
|
||||
|
||||
if (aMat->HasCommonMaterial())
|
||||
{
|
||||
const XCAFDoc_VisMaterialCommon& aComMat = aMat->CommonMaterial();
|
||||
writeVec3 (theTarget, ::AmbientColor(), aComMat.AmbientColor);
|
||||
writeVec3 (theTarget, ::DiffuseColor(), aComMat.DiffuseColor);
|
||||
writeVec3 (theTarget, ::SpecularColor(), aComMat.SpecularColor);
|
||||
writeVec3 (theTarget, ::EmissiveColor(), aComMat.EmissiveColor);
|
||||
writeReal (theTarget, ::Shininess(), aComMat.Shininess);
|
||||
writeReal (theTarget, ::Transparency(), aComMat.Transparency);
|
||||
writeTexture (theTarget, ::DiffuseTexture(), aComMat.DiffuseTexture);
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
// 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 _XmlMXCAFDoc_VisMaterialDriver_HeaderFile
|
||||
#define _XmlMXCAFDoc_VisMaterialDriver_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
|
||||
#include <XmlMDF_ADriver.hxx>
|
||||
#include <Standard_Boolean.hxx>
|
||||
#include <XmlObjMgt_RRelocationTable.hxx>
|
||||
#include <XmlObjMgt_SRelocationTable.hxx>
|
||||
|
||||
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_VisMaterialDriver, XmlMDF_ADriver)
|
||||
|
||||
//! Attribute Driver.
|
||||
class XmlMXCAFDoc_VisMaterialDriver : public XmlMDF_ADriver
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_VisMaterialDriver, XmlMDF_ADriver)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT XmlMXCAFDoc_VisMaterialDriver (const Handle(Message_Messenger)& theMessageDriver);
|
||||
|
||||
//! Create new instance of XCAFDoc_VisMaterial.
|
||||
Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from persistence into document.
|
||||
Standard_EXPORT Standard_Boolean Paste (const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from document into persistence.
|
||||
Standard_EXPORT void Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // _XmlMXCAFDoc_VisMaterialDriver_HeaderFile
|
@@ -1,61 +0,0 @@
|
||||
// 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 <XmlMXCAFDoc_VisMaterialToolDriver.hxx>
|
||||
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <XCAFDoc_VisMaterialTool.hxx>
|
||||
#include <XmlObjMgt_Persistent.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_VisMaterialToolDriver, XmlMDF_ADriver)
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMXCAFDoc_VisMaterialToolDriver
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
XmlMXCAFDoc_VisMaterialToolDriver::XmlMXCAFDoc_VisMaterialToolDriver (const Handle(Message_Messenger)& theMsgDriver)
|
||||
: XmlMDF_ADriver (theMsgDriver, "xcaf", "VisMaterialTool")
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) XmlMXCAFDoc_VisMaterialToolDriver::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_VisMaterialTool();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMXCAFDoc_VisMaterialToolDriver::Paste (const XmlObjMgt_Persistent& ,
|
||||
const Handle(TDF_Attribute)& ,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XmlMXCAFDoc_VisMaterialToolDriver::Paste (const Handle(TDF_Attribute)& ,
|
||||
XmlObjMgt_Persistent& ,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
//
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
// 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 _XmlMXCAFDoc_VisMaterialToolDriver_HeaderFile
|
||||
#define _XmlMXCAFDoc_VisMaterialToolDriver_HeaderFile
|
||||
|
||||
#include <XmlMDF_ADriver.hxx>
|
||||
|
||||
DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_VisMaterialToolDriver, XmlMDF_ADriver)
|
||||
|
||||
//! XML persistence driver for XCAFDoc_VisMaterialTool.
|
||||
class XmlMXCAFDoc_VisMaterialToolDriver : public XmlMDF_ADriver
|
||||
{
|
||||
DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_VisMaterialToolDriver, XmlMDF_ADriver)
|
||||
public:
|
||||
|
||||
//! Main constructor.
|
||||
Standard_EXPORT XmlMXCAFDoc_VisMaterialToolDriver (const Handle(Message_Messenger)& theMsgDriver);
|
||||
|
||||
//! Create new instance of XCAFDoc_VisMaterialTool.
|
||||
Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from persistence into document.
|
||||
Standard_EXPORT virtual Standard_Boolean Paste (const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
//! Paste attribute from document into persistence.
|
||||
Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // _XmlMXCAFDoc_VisMaterialToolDriver_HeaderFile
|
Reference in New Issue
Block a user