From 7da646754aa8cd9673929e534945c84b75fcc5d6 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 24 Dec 2025 15:52:14 -0600 Subject: [PATCH] Import: Revert recent STEP file object naming work After discussion in several recent PR review meetings the Maintainer team has decided to roll back some recent work on object naming in STEP files. Inadequate automated testing has led to a situation where every change made to address one bug introduces another someplace else. It is difficult to determine which, if any, of these fixes represent an appropriate path forward, versus fixing a symptom rather than the underlying problem. --- Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" This reverts commit 59715114f5a4fbf4d97f13a2f41277bb02e50cf0. Revert "core: fix various issues exporting step files, ie. #25540 #24962 #25567" This reverts commit e226e9b06e5fd813ae862c0699885b6400a75c38. Revert "export: step file preserve last feature when exporting step file, fix issue #25567" This reverts commit 9c48c9a3e3c4592e3c85065d74965383aa544c15. Revert "core: preserve body name in step file when exporting part that contains body with feature, fixes #24962" This reverts commit 246218b28b7a18500cf1c9e9e794ec628bff57c3. Revert "Import: STEP export preserve body names (#25042)" This reverts commit f218c5f25cdb8dfe216583dc25e1e0f55e500555. Revert "Import: Export tip when body is selected (#24678)" This reverts commit 6fd6558040bb61cc1a9d35fd360cb1a169276cd3. --- src/Mod/Import/App/CMakeLists.txt | 1 - src/Mod/Import/App/ExportOCAF.cpp | 24 ++-------- src/Mod/Import/App/ExportOCAF.h | 3 +- src/Mod/Import/App/ExportOCAF2.cpp | 71 ++++-------------------------- 4 files changed, 13 insertions(+), 86 deletions(-) diff --git a/src/Mod/Import/App/CMakeLists.txt b/src/Mod/Import/App/CMakeLists.txt index 4c99bc0874..4b56acc74f 100644 --- a/src/Mod/Import/App/CMakeLists.txt +++ b/src/Mod/Import/App/CMakeLists.txt @@ -2,7 +2,6 @@ set(Import_LIBS Part - PartDesign ${OCC_OCAF_LIBRARIES} ${OCC_OCAF_DEBUG_LIBRARIES} ) diff --git a/src/Mod/Import/App/ExportOCAF.cpp b/src/Mod/Import/App/ExportOCAF.cpp index 1b9e157952..a81f47018c 100644 --- a/src/Mod/Import/App/ExportOCAF.cpp +++ b/src/Mod/Import/App/ExportOCAF.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include "ExportOCAF.h" #include "Tools.h" @@ -177,26 +176,12 @@ int ExportOCAF::exportObject( return_label = root_id; } - // keep a copy of the original object for naming purposes - App::DocumentObject* originalObj = obj; - - if (obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { - PartDesign::Body* body = static_cast(obj); - App::DocumentObject* tip = body->Tip.getValue(); - if (tip && tip->isDerivedFrom()) { - // use the tip instead of the body for export - obj = tip; - } - } - if (obj->isDerivedFrom()) { Part::Feature* part = static_cast(obj); std::vector colors; findColors(part, colors); - const char* label = (originalObj != obj) ? originalObj->Label.getValue() : nullptr; - return_label - = saveShape(part, colors, hierarchical_label, hierarchical_loc, hierarchical_part, label); + return_label = saveShape(part, colors, hierarchical_label, hierarchical_loc, hierarchical_part); } return return_label; @@ -240,8 +225,7 @@ int ExportOCAF::saveShape( const std::vector& colors, std::vector& hierarchical_label, std::vector& hierarchical_loc, - std::vector& hierarchical_part, - const char* labelOverride + std::vector& hierarchical_part ) { const TopoDS_Shape& shape = part->Shape.getValue(); @@ -276,8 +260,8 @@ int ExportOCAF::saveShape( TDF_Label shapeLabel = aShapeTool->NewShape(); aShapeTool->SetShape(shapeLabel, baseShape); - const char* labelToUse = labelOverride ? labelOverride : part->Label.getValue(); - TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(labelToUse, true)); + TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), true)); + /* if (keepExplicitPlacement) { diff --git a/src/Mod/Import/App/ExportOCAF.h b/src/Mod/Import/App/ExportOCAF.h index f1d6874c61..5afa69f1b8 100644 --- a/src/Mod/Import/App/ExportOCAF.h +++ b/src/Mod/Import/App/ExportOCAF.h @@ -72,8 +72,7 @@ public: const std::vector&, std::vector& hierarchical_label, std::vector& hierarchical_loc, - std::vector& hierarchical_part, - const char* labelOverride = nullptr + std::vector& hierarchical_part ); void getPartColors( std::vector hierarchical_part, diff --git a/src/Mod/Import/App/ExportOCAF2.cpp b/src/Mod/Import/App/ExportOCAF2.cpp index 34a0d80f64..ba300526f3 100644 --- a/src/Mod/Import/App/ExportOCAF2.cpp +++ b/src/Mod/Import/App/ExportOCAF2.cpp @@ -52,8 +52,6 @@ #include #include #include -#include -#include #include "ExportOCAF2.h" @@ -391,21 +389,7 @@ TDF_Label ExportOCAF2::exportObject( const char* name ) { - App::DocumentObject* obj = nullptr; - // keep a copy of the original object for naming purposes - App::DocumentObject* originalObj = parentObj; - - // check if this is a body and get its tip before getting the shape - if (parentObj && parentObj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { - // if (obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { - auto* body = static_cast(parentObj); - App::DocumentObject* tip = body->Tip.getValue(); - if (tip) { - // obj = tip; - parentObj = tip; - } - } - + App::DocumentObject* obj; auto shape = Part::Feature::getTopoShape( parentObj, (sub ? Part::ShapeOption::NoFlag : Part::ShapeOption::Transform), @@ -420,21 +404,6 @@ TDF_Label ExportOCAF2::exportObject( return {}; } - // after resolution, check if obj is a body accessed via sub path and get the tip shape - if (sub && obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { - auto* body = static_cast(obj); - App::DocumentObject* tip = body->Tip.getValue(); - if (tip) { - // reget shape from tip to ensure latest feature is included - auto tipShape = Part::Feature::getTopoShape(tip, Part::ShapeOption::Transform); - if (!tipShape.isNull()) { - shape = tipShape; - } - // use tip for colors (will be handled later in setupObject) - obj = tip; - } - } - // sub may contain more than one hierarchy, e.g. Assembly container may use // getSubObjects to skip some hierarchy containing constraints and stuff // when exporting. We search for extra '.', and set it as prefix if found. @@ -493,9 +462,7 @@ TDF_Label ExportOCAF2::exportObject( else { label = aShapeTool->AddShape(shape.getShape(), Standard_False, Standard_False); } - - // use originalObj to preserve name - setupObject(label, name ? parentObj : originalObj, shape, prefix, name); + setupObject(label, name ? parentObj : obj, shape, prefix, name); return label; } auto next = linked->getLinkedObject(false, nullptr, false, depth++); @@ -508,12 +475,7 @@ TDF_Label ExportOCAF2::exportObject( auto subs = obj->getSubObjects(); // subs empty means obj is not a container. - // treat as non container if: - // 1. no subobjects (subs.empty()) - // 2. is a partdesign feature ie. pad, pocket, boolean - // 3. is a partdesign body, should export as single shape via its tip, not as assembly - if (subs.empty() || obj->isDerivedFrom(PartDesign::Feature::getClassTypeId()) - || obj->isDerivedFrom(PartDesign::Body::getClassTypeId())) { + if (subs.empty()) { if (!parent.IsNull()) { // Search for non-located shape to see if we've stored the original shape before @@ -523,14 +485,11 @@ TDF_Label ExportOCAF2::exportObject( baseShape.setShape(baseShape.getShape().Located(TopLoc_Location())); label = aShapeTool->NewShape(); aShapeTool->SetShape(label, baseShape.getShape()); - if (originalObj != linked) { - setupObject(label, linked, baseShape, prefix, nullptr, false); - } - setupObject(label, originalObj, baseShape, prefix, nullptr, false); + setupObject(label, linked, baseShape, prefix); } label = aShapeTool->AddComponent(parent, shape.getShape(), Standard_False); - setupObject(label, name ? parentObj : originalObj, shape, prefix, name); + setupObject(label, name ? parentObj : obj, shape, prefix, name); } else { // Here means we are exporting a single non-assembly object. We must @@ -550,7 +509,7 @@ TDF_Label ExportOCAF2::exportObject( shape.setShape(shape.getShape().Located(TopLoc_Location())); } label = aShapeTool->AddShape(shape.getShape(), Standard_False, Standard_False); - auto o = name ? parentObj : originalObj; + auto o = name ? parentObj : obj; if (o != linked) { setupObject(label, linked, shape, prefix, nullptr, true); } @@ -561,10 +520,6 @@ TDF_Label ExportOCAF2::exportObject( for (auto link : links) { myObjects.emplace(link, label); } - // also cache the body if it's different from obj (the tip) - if (originalObj != obj) { - myObjects.emplace(originalObj, label); - } return label; } @@ -666,29 +621,19 @@ TDF_Label ExportOCAF2::exportObject( myObjects.emplace(link, label); } - if (originalObj != obj) { - myObjects.emplace(originalObj, label); - } - if (!parent.IsNull() && !links.empty()) { linked = links.back(); } else { linked = obj; } - // use the originalObj for naming if we changed obj to tip - App::DocumentObject* setupObj = (originalObj != obj) ? originalObj : linked; - setupObject(label, setupObj, baseShape, prefix); - -#ifdef FC_DEBUG - Base::Console().warning("assembly name set to: %s\n", linked->Label.getValue()); -#endif + setupObject(label, linked, baseShape, prefix); if (!parent.IsNull()) { // If we are a component, swap in the base shape but keep our location. shape.setShape(baseShape.getShape().Located(shape.getShape().Location())); label = aShapeTool->AddComponent(parent, label, shape.getShape().Location()); - setupObject(label, name ? parentObj : originalObj, shape, prefix, name); + setupObject(label, name ? parentObj : obj, shape, prefix, name); } return label; }