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

Method createObject

src/Mod/Import/App/ImportOCAF2.cpp:282–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

280}
281
282bool ImportOCAF2::createObject(
283 App::Document* doc,
284 TDF_Label label,
285 const TopoDS_Shape& shape,
286 Info& info,
287 bool newDoc
288)
289{
290 if (shape.IsNull() || !TopExp_Explorer(shape, TopAbs_VERTEX).More()) {
291 FC_WARN(Tools::labelName(label) << " has empty shape");
292 return false;
293 }
294
295 getColor(shape, info);
296 bool hasFaceColors = false;
297 bool hasEdgeColors = false;
298
299 Part::TopoShape tshape(shape);
300 std::vector<Base::Color> faceColors;
301 std::vector<Base::Color> edgeColors;
302
303 TDF_LabelSequence seq;
304 if (!label.IsNull() && aShapeTool->GetSubShapes(label, seq)) {
305
306 TopTools_IndexedMapOfShape faceMap, edgeMap;
307 TopExp::MapShapes(tshape.getShape(), TopAbs_FACE, faceMap);
308 TopExp::MapShapes(tshape.getShape(), TopAbs_EDGE, edgeMap);
309
310 faceColors.assign(faceMap.Extent(), info.faceColor);
311 edgeColors.assign(edgeMap.Extent(), info.edgeColor);
312 // Two passes to get sub shape colors. First pass, look for solid, and
313 // second pass look for face and edges. This allows lower level
314 // subshape to override color of higher level ones.
315 for (int j = 0; j < 2; ++j) {
316 for (int i = 1; i <= seq.Length(); ++i) {
317 TDF_Label l = seq.Value(i);
318 TopoDS_Shape subShape = aShapeTool->GetShape(l);
319 if (subShape.IsNull()) {
320 continue;
321 }
322 if (subShape.ShapeType() == TopAbs_FACE || subShape.ShapeType() == TopAbs_EDGE) {
323 if (j == 0) {
324 continue;
325 }
326 }
327 else if (j != 0) {
328 continue;
329 }
330
331 bool foundFaceColor = false, foundEdgeColor = false;
332 Base::Color faceColor, edgeColor;
333 Quantity_ColorRGBA aColor;
334 if (aColorTool->GetColor(l, XCAFDoc_ColorSurf, aColor)
335 || aColorTool->GetColor(l, XCAFDoc_ColorGen, aColor)) {
336 faceColor = Tools::convertColor(aColor);
337 foundFaceColor = true;
338 }
339 if (aColorTool->GetColor(l, XCAFDoc_ColorCurv, aColor)) {

Callers 11

createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45
createFunction · 0.45

Calls 15

TopExp_ExplorerClass · 0.85
applyFaceColorsFunction · 0.85
applyEdgeColorsFunction · 0.85
assignMethod · 0.80
GetShapeMethod · 0.80
GetColorMethod · 0.80
getColorFunction · 0.50
getDocumentFunction · 0.50
IsNullMethod · 0.45
MoreMethod · 0.45
getShapeMethod · 0.45
ExtentMethod · 0.45

Tested by

no test coverage detected