NOLINTNEXTLINE
| 93 | |
| 94 | // NOLINTNEXTLINE |
| 95 | TopoDS_Shape ReaderGltf::processSubShapes( |
| 96 | Handle(TDocStd_Document) hDoc, |
| 97 | const TDF_LabelSequence& subShapeLabels |
| 98 | ) |
| 99 | { |
| 100 | TopoDS_Compound compound; |
| 101 | Handle(XCAFDoc_ShapeTool) aShapeTool = XCAFDoc_DocumentTool::ShapeTool(hDoc->Main()); |
| 102 | Handle(XCAFDoc_ColorTool) aColorTool = XCAFDoc_DocumentTool::ColorTool(hDoc->Main()); |
| 103 | Handle(XCAFDoc_VisMaterialTool) aVisTool = XCAFDoc_DocumentTool::VisMaterialTool(hDoc->Main()); |
| 104 | |
| 105 | BRep_Builder builder; |
| 106 | builder.MakeCompound(compound); |
| 107 | for (Standard_Integer i = 1; i <= subShapeLabels.Length(); i++) { |
| 108 | auto faceLabel = subShapeLabels.Value(i); |
| 109 | |
| 110 | // OCCT handles colors of a glTF with material labels but the ImportOCAF(2) class |
| 111 | // expects color labels. Thus, the material labels are converted into color labels. |
| 112 | Handle(XCAFDoc_VisMaterial) aVisMat = aVisTool->GetShapeMaterial(faceLabel); |
| 113 | |
| 114 | Quantity_ColorRGBA rgba; |
| 115 | bool hasVisMat {false}; |
| 116 | if (!aVisMat.IsNull()) { |
| 117 | rgba = aVisMat->BaseColor(); |
| 118 | hasVisMat = true; |
| 119 | } |
| 120 | |
| 121 | TopoDS_Shape face = aShapeTool->GetShape(faceLabel); |
| 122 | TopoDS_Shape fixed = fixShape(face); |
| 123 | builder.Add(compound, fixed); |
| 124 | aShapeTool->SetShape(faceLabel, fixed); |
| 125 | |
| 126 | if (hasVisMat) { |
| 127 | aColorTool->SetColor(faceLabel, rgba, XCAFDoc_ColorSurf); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return {std::move(compound)}; |
| 132 | } |
| 133 | |
| 134 | bool ReaderGltf::cleanup() const |
| 135 | { |