]> OCCT Git - occt.git/commitdiff
0033430: IFC Import - Adding basic support of materials
authoranv <anv@opencascade.com>
Wed, 26 Jul 2023 04:07:41 +0000 (05:07 +0100)
committerdpasukhi <dpasukhi@opencascade.com>
Wed, 17 Apr 2024 22:19:48 +0000 (23:19 +0100)
Updated XStat to show VisMaterials info

src/XDEDRAW/XDEDRAW.cxx

index 49d6c2685b3db12c14ff33e8606efd7c57d48994..f953df03785459d824ae6491eb016188d5dcaa00 100644 (file)
@@ -98,6 +98,7 @@
 #include <XCAFDoc_LayerTool.hxx>
 #include <XCAFDoc_Material.hxx>
 #include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFDoc_VisMaterialTool.hxx>
 #include <XCAFDoc_Volume.hxx>
 #include <XCAFPrs.hxx>
 #include <XCAFPrs_AISObject.hxx>
@@ -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 = "<<NbShapesWithName<<"\n";
   di<<"Number of labels with color link = "<<NbShapesWithColor<<"\n";
   di<<"Number of labels with layer link = "<<NbShapesWithLayer<<"\n";
+  di << "Number of labels with vis material link = " << NbShapesWithVisMaterial << "\n";
 
   di<<"\nStatistis of Props in the document:\n";
   di<<"Number of Centroid Props = "<<NbCentroidProp<<"\n";
@@ -520,6 +539,23 @@ static Standard_Integer statdoc (Draw_Interpretor& di, Standard_Integer argc, co
     di<<"\n";
   }
 
+  Handle(XCAFDoc_VisMaterialTool) VMTool = XCAFDoc_DocumentTool::VisMaterialTool(Doc->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;
 }