MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / processSubShapes

Method processSubShapes

src/Mod/Import/App/ReaderGltf.cpp:95–132  ·  view source on GitHub ↗

NOLINTNEXTLINE

Source from the content-addressed store, hash-verified

93
94// NOLINTNEXTLINE
95TopoDS_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
134bool ReaderGltf::cleanup() const
135{

Callers

nothing calls this directly

Calls 8

GetShapeMethod · 0.80
SetColorMethod · 0.80
moveFunction · 0.50
LengthMethod · 0.45
ValueMethod · 0.45
IsNullMethod · 0.45
AddMethod · 0.45
SetShapeMethod · 0.45

Tested by

no test coverage detected