1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031139: Data Exchange - fix misprint in RWObj_CafReader

RWObj_CafReader::BindNamedShape(), added missing bind to material map.
XCAFDoc_VisMaterial::ConvertToCommonMaterial()/::ConvertToPbrMaterial(), added copying of base color texture.
XCAFPrs_DocumentExplorer now properly fills XCAFDoc_VisMaterial property of XCAFPrs_Style.
This commit is contained in:
kgv
2019-11-07 00:11:57 +03:00
committed by bugmaster
parent a1a9b24952
commit a14f2b4722
4 changed files with 36 additions and 13 deletions

View File

@@ -19,12 +19,14 @@
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_DocumentTool.hxx>
#include <XCAFDoc_ShapeTool.hxx>
#include <XCAFDoc_VisMaterialTool.hxx>
#include <XCAFPrs_DocumentIdIterator.hxx>
namespace
{
//! Return merged style for the child node.
static XCAFPrs_Style mergedStyle (const Handle(XCAFDoc_ColorTool)& theColorTool,
const Handle(XCAFDoc_VisMaterialTool)& theVisMatTool,
const XCAFPrs_Style& theParenStyle,
const TDF_Label& theLabel,
const TDF_Label& theRefLabel)
@@ -35,6 +37,10 @@ namespace
}
XCAFPrs_Style aStyle = theParenStyle;
if (Handle(XCAFDoc_VisMaterial) aVisMat = theVisMatTool->GetShapeMaterial (theRefLabel))
{
aStyle.SetMaterial (aVisMat);
}
Quantity_ColorRGBA aColor;
if (theColorTool->GetColor (theRefLabel, XCAFDoc_ColorGen, aColor))
{
@@ -53,6 +59,10 @@ namespace
if (theLabel != theRefLabel)
{
// override Reference style with Instance style when defined (bad model?)
if (Handle(XCAFDoc_VisMaterial) aVisMat = theVisMatTool->GetShapeMaterial (theLabel))
{
aStyle.SetMaterial (aVisMat);
}
if (theColorTool->GetColor (theLabel, XCAFDoc_ColorGen, aColor))
{
aStyle.SetColorCurv (aColor.GetRGB());
@@ -224,10 +234,12 @@ void XCAFPrs_DocumentExplorer::Init (const Handle(TDocStd_Document)& theDocument
if ((theFlags & XCAFPrs_DocumentExplorerFlags_NoStyle) == 0)
{
myColorTool = XCAFDoc_DocumentTool::ColorTool (theDocument->Main());
myVisMatTool = XCAFDoc_DocumentTool::VisMaterialTool (theDocument->Main());
}
else
{
myColorTool.Nullify();
myVisMatTool.Nullify();
}
myDefStyle = theDefStyle;
@@ -309,7 +321,7 @@ void XCAFPrs_DocumentExplorer::initCurrent (Standard_Boolean theIsAssmebly)
XCAFDoc_ShapeTool::GetReferredShape (myCurrent.Label, myCurrent.RefLabel);
myCurrent.LocalTrsf= XCAFDoc_ShapeTool::GetLocation (myCurrent.Label);
myCurrent.Location = myCurrent.LocalTrsf;
myCurrent.Style = mergedStyle (myColorTool, myDefStyle, myCurrent.Label, myCurrent.RefLabel);
myCurrent.Style = mergedStyle (myColorTool, myVisMatTool, myDefStyle, myCurrent.Label, myCurrent.RefLabel);
myCurrent.Id = DefineChildId (myCurrent.Label, TCollection_AsciiString());
}
else
@@ -320,7 +332,7 @@ void XCAFPrs_DocumentExplorer::initCurrent (Standard_Boolean theIsAssmebly)
XCAFDoc_ShapeTool::GetReferredShape (myCurrent.Label, myCurrent.RefLabel);
myCurrent.LocalTrsf= XCAFDoc_ShapeTool::GetLocation (myCurrent.Label);
myCurrent.Location = aTopNodeInStack.Location * myCurrent.LocalTrsf;
myCurrent.Style = mergedStyle (myColorTool, aTopNodeInStack.Style, myCurrent.Label, myCurrent.RefLabel);
myCurrent.Style = mergedStyle (myColorTool, myVisMatTool, aTopNodeInStack.Style, myCurrent.Label, myCurrent.RefLabel);
myCurrent.Id = DefineChildId (myCurrent.Label, aTopNodeInStack.Id);
}
}
@@ -359,7 +371,7 @@ void XCAFPrs_DocumentExplorer::Next()
aNodeInStack.ChildIter = TDF_ChildIterator (aNodeInStack.RefLabel);
aNodeInStack.LocalTrsf = XCAFDoc_ShapeTool::GetLocation (aNodeInStack.Label);
aNodeInStack.Location = aNodeInStack.LocalTrsf;
aNodeInStack.Style = mergedStyle (myColorTool, myDefStyle, aNodeInStack.Label, aNodeInStack.RefLabel);
aNodeInStack.Style = mergedStyle (myColorTool, myVisMatTool, myDefStyle, aNodeInStack.Label, aNodeInStack.RefLabel);
aNodeInStack.Id = DefineChildId (aNodeInStack.Label, TCollection_AsciiString());
myNodeStack.SetValue (0, aNodeInStack);
if ((myFlags & XCAFPrs_DocumentExplorerFlags_OnlyLeafNodes) == 0)
@@ -408,7 +420,7 @@ void XCAFPrs_DocumentExplorer::Next()
aNodeInStack.RefLabel = aRefLabel;
aNodeInStack.LocalTrsf = XCAFDoc_ShapeTool::GetLocation (aNodeInStack.Label);
aNodeInStack.Location = aParent.Location * aNodeInStack.LocalTrsf;
aNodeInStack.Style = mergedStyle (myColorTool, aParent.Style, aNodeInStack.Label, aNodeInStack.RefLabel);
aNodeInStack.Style = mergedStyle (myColorTool, myVisMatTool, aParent.Style, aNodeInStack.Label, aNodeInStack.RefLabel);
aNodeInStack.Id = DefineChildId (aNodeInStack.Label, aParent.Id);
aNodeInStack.ChildIter = TDF_ChildIterator (aNodeInStack.RefLabel);
myNodeStack.SetValue (myTop, aNodeInStack);

View File

@@ -24,6 +24,7 @@
class TDocStd_Document;
class XCAFDoc_ShapeTool;
class XCAFDoc_ColorTool;
class XCAFDoc_VisMaterialTool;
typedef Standard_Integer XCAFPrs_DocumentExplorerFlags;
@@ -148,6 +149,12 @@ public:
//! Go to the next node.
Standard_EXPORT void Next();
//! Return color tool.
const Handle(XCAFDoc_ColorTool)& ColorTool() const { return myColorTool; }
//! Return material tool.
const Handle(XCAFDoc_VisMaterialTool)& VisMaterialTool() const { return myVisMatTool; }
protected:
//! Initialize root label.
@@ -158,16 +165,17 @@ protected:
protected:
Handle(XCAFDoc_ColorTool) myColorTool; //!< color tool
TDF_LabelSequence myRoots; //!< sequence of root labels
TDF_LabelSequence::Iterator myRootIter; //!< current root label
Handle(XCAFDoc_ColorTool) myColorTool; //!< color tool
Handle(XCAFDoc_VisMaterialTool) myVisMatTool; //!< visual material tool
TDF_LabelSequence myRoots; //!< sequence of root labels
TDF_LabelSequence::Iterator myRootIter; //!< current root label
NCollection_Vector<XCAFPrs_DocumentNode>
myNodeStack; //!< node stack
Standard_Integer myTop; //!< top position in the node stack
Standard_Boolean myHasMore; //!< global flag indicating that iterator points to the label
XCAFPrs_Style myDefStyle; //!< default style
XCAFPrs_DocumentNode myCurrent; //!< current label info
XCAFPrs_DocumentExplorerFlags myFlags; //!< iteration flags
myNodeStack; //!< node stack
Standard_Integer myTop; //!< top position in the node stack
Standard_Boolean myHasMore; //!< global flag indicating that iterator points to the label
XCAFPrs_Style myDefStyle; //!< default style
XCAFPrs_DocumentNode myCurrent; //!< current label info
XCAFPrs_DocumentExplorerFlags myFlags; //!< iteration flags
};