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

Method exportObject

src/Mod/Import/App/ExportOCAF2.cpp:385–639  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385TDF_Label ExportOCAF2::exportObject(
386 App::DocumentObject* parentObj,
387 const char* sub,
388 TDF_Label parent,
389 const char* name
390)
391{
392 App::DocumentObject* obj;
393 auto shape = Part::Feature::getTopoShape(
394 parentObj,
395 (sub ? Part::ShapeOption::NoFlag : Part::ShapeOption::Transform),
396 sub,
397 nullptr,
398 &obj
399 );
400 if (!obj || shape.isNull()) {
401 if (obj) {
402 FC_WARN(obj->getFullName() << " has null shape");
403 }
404 return {};
405 }
406
407 // sub may contain more than one hierarchy, e.g. Assembly container may use
408 // getSubObjects to skip some hierarchy containing constraints and stuff
409 // when exporting. We search for extra '.', and set it as prefix if found.
410 // When setting SHUO's, we'll need this prefix for matching.
411 std::string prefix;
412 if (sub) {
413 auto len = strlen(sub);
414 if (len > 1) {
415 --len;
416 // The prefix ends with the second last '.', so search for it.
417 for (int i = 0; len != 0; --len) {
418 if (sub[len] == '.' && ++i == 2) {
419 prefix = std::string(sub, len + 1);
420 break;
421 }
422 }
423 }
424 }
425
426 TDF_Label label;
427 std::vector<App::DocumentObject*> links;
428
429 int depth = 0;
430 auto linked = obj;
431 auto linkedShape = shape;
432 while (true) {
433 auto s = Part::Feature::getTopoShape(
434 linked,
435 Part::ShapeOption::ResolveLink | Part::ShapeOption::Transform
436 );
437 if (s.isNull() || !s.getShape().IsPartner(shape.getShape())) {
438 break;
439 }
440 linkedShape = s;
441 // Search using our own cache. We can't rely on ShapeTool::FindShape()
442 // in case this is an assembly. Because FindShape() search among its

Callers

nothing calls this directly

Calls 15

GetShapeMethod · 0.80
FindShapeMethod · 0.80
GetColorMethod · 0.80
SetColorMethod · 0.80
TopLoc_LocationClass · 0.70
PlacementClass · 0.50
isNullMethod · 0.45
getFullNameMethod · 0.45
getShapeMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emplaceMethod · 0.45

Tested by

no test coverage detected