From ead71c66a3bad3e28d837af34d23a05c4047271b Mon Sep 17 00:00:00 2001 From: anv Date: Wed, 26 Jul 2023 05:07:41 +0100 Subject: [PATCH] 0033430: IFC Import - Adding basic support of materials Updated XStat to show VisMaterials info --- src/XDEDRAW/XDEDRAW.cxx | 52 ++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index 49d6c2685b..f953df0378 100644 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -98,6 +98,7 @@ #include #include #include +#include #include #include #include @@ -323,7 +324,7 @@ static Standard_Integer dump (Draw_Interpretor& di, Standard_Integer argc, const //======================================================================= static void StatAssembly(const TDF_Label L, - const Standard_Integer level, + const Standard_Integer level, Handle(TColStd_HArray1OfInteger) &HAI, Standard_Integer &NbCentroidProp, Standard_Integer &NbVolumeProp, @@ -331,9 +332,10 @@ static void StatAssembly(const TDF_Label L, Standard_Integer &NbShapesWithName, Standard_Integer &NbShapesWithColor, Standard_Integer &NbShapesWithLayer, + Standard_Integer &NbShapesWithVisMaterial, Handle(TDocStd_Document) &aDoc, Standard_Boolean &PrintStructMode, - Draw_Interpretor& di) + Draw_Interpretor& di) { if(PrintStructMode) { for(Standard_Integer j=0; j<=level; j++) @@ -370,6 +372,7 @@ static void StatAssembly(const TDF_Label L, } Handle(XCAFDoc_ColorTool) CTool = XCAFDoc_DocumentTool::ColorTool(aDoc->Main()); Handle(XCAFDoc_LayerTool) LTool = XCAFDoc_DocumentTool::LayerTool(aDoc->Main()); + Handle(XCAFDoc_VisMaterialTool) VMTool = XCAFDoc_DocumentTool::VisMaterialTool(aDoc->Main()); Quantity_ColorRGBA col; Standard_Boolean IsColor = Standard_False; Standard_Boolean IsByLayer = Standard_False; @@ -386,7 +389,7 @@ static void StatAssembly(const TDF_Label L, { Handle(TColStd_HSequenceOfExtendedString) aLayerS; LTool->GetLayers(L, aLayerS); - // Currently for DXF pnly, thus + // Currently for DXF only, thus // only 1 Layer should be. if(aLayerS->Length() == 1) { @@ -428,14 +431,29 @@ static void StatAssembly(const TDF_Label L, } NbShapesWithLayer++; } - if(PrintStructMode) di<<"\n"; - + + TDF_Label aVMat; + if (VMTool->GetShapeMaterial(L, aVMat)) + { + if (PrintStructMode) { + di << "VisMaterial("; + Handle(TDataStd_Name) aNodeName; + if (aVMat.FindAttribute(TDataStd_Name::GetID(), aNodeName)) + { + di << "\"" << aNodeName->Get() << "\""; + } + di << ") "; + } + NbShapesWithVisMaterial++; + } + if (PrintStructMode) di << "\n"; + HAI->SetValue(level, HAI->Value(level)+1 ); if(L.HasChild()) { for(Standard_Integer i=1; i<=L.NbChildren(); i++) { StatAssembly(L.FindChild(i), level+1, HAI, NbCentroidProp, NbVolumeProp, NbAreaProp, NbShapesWithName, NbShapesWithColor, - NbShapesWithLayer, aDoc, PrintStructMode, di); + NbShapesWithLayer, NbShapesWithVisMaterial, aDoc, PrintStructMode, di); } } @@ -465,14 +483,14 @@ static Standard_Integer statdoc (Draw_Interpretor& di, Standard_Integer argc, co if(PrintStructMode) di<<"\nStructure of shapes in the document:\n"; Standard_Integer level=0; Standard_Integer NbCentroidProp=0, NbVolumeProp=0, NbAreaProp=0; - Standard_Integer NbShapesWithName=0, NbShapesWithColor=0, NbShapesWithLayer=0; + Standard_Integer NbShapesWithName=0, NbShapesWithColor=0, NbShapesWithLayer=0, NbShapesWithVisMaterial = 0; Handle(TColStd_HArray1OfInteger) HAI = new TColStd_HArray1OfInteger(0,20); Standard_Integer i=0; for(i=0; i<=20; i++) HAI->SetValue(i,0); for(i=1; i<=SeqLabels.Length(); i++) { StatAssembly(SeqLabels.Value(i), level, HAI, NbCentroidProp, NbVolumeProp, NbAreaProp, NbShapesWithName, NbShapesWithColor, - NbShapesWithLayer, Doc, PrintStructMode, di); + NbShapesWithLayer, NbShapesWithVisMaterial, Doc, PrintStructMode, di); } Standard_Integer NbLabelsShape = 0; di<<"\nStatistis of shapes in the document:\n"; @@ -486,6 +504,7 @@ static Standard_Integer statdoc (Draw_Interpretor& di, Standard_Integer argc, co di<<"Number of labels with name = "<Main()); + TDF_LabelSequence aVMats; + VMTool->GetMaterials(aVMats); + di << "\nNumber of vis materials = " << aVMats.Length() << "\n"; + if (!aVMats.IsEmpty()) + { + for (TDF_LabelSequence::Iterator aVMIter(aVMats); aVMIter.More(); aVMIter.Next()) + { + Handle(TDataStd_Name) aNodeName; + if (aVMIter.Value().FindAttribute(TDataStd_Name::GetID(), aNodeName)) + { + di << "\"" << aNodeName->Get() << "\" "; + } + } + di << "\n"; + } + di<<"\n"; return 0; }