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 commit59715114f5. Revert "core: fix various issues exporting step files, ie. #25540 #24962 #25567" This reverts commite226e9b06e. Revert "export: step file preserve last feature when exporting step file, fix issue #25567" This reverts commit9c48c9a3e3. Revert "core: preserve body name in step file when exporting part that contains body with feature, fixes #24962" This reverts commit246218b28b. Revert "Import: STEP export preserve body names (#25042)" This reverts commitf218c5f25c. Revert "Import: Export tip when body is selected (#24678)" This reverts commit6fd6558040.
This commit is contained in:
committed by
Kacper Donat
parent
a4bff812d7
commit
7da646754a
@@ -2,7 +2,6 @@
|
||||
|
||||
set(Import_LIBS
|
||||
Part
|
||||
PartDesign
|
||||
${OCC_OCAF_LIBRARIES}
|
||||
${OCC_OCAF_DEBUG_LIBRARIES}
|
||||
)
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
#include <App/Part.h>
|
||||
#include <Mod/Part/App/Interface.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
|
||||
#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<PartDesign::Body*>(obj);
|
||||
App::DocumentObject* tip = body->Tip.getValue();
|
||||
if (tip && tip->isDerivedFrom<Part::Feature>()) {
|
||||
// use the tip instead of the body for export
|
||||
obj = tip;
|
||||
}
|
||||
}
|
||||
|
||||
if (obj->isDerivedFrom<Part::Feature>()) {
|
||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
||||
std::vector<Base::Color> 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<Base::Color>& colors,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part,
|
||||
const char* labelOverride
|
||||
std::vector<App::DocumentObject*>& 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) {
|
||||
|
||||
@@ -72,8 +72,7 @@ public:
|
||||
const std::vector<Base::Color>&,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part,
|
||||
const char* labelOverride = nullptr
|
||||
std::vector<App::DocumentObject*>& hierarchical_part
|
||||
);
|
||||
void getPartColors(
|
||||
std::vector<App::DocumentObject*> hierarchical_part,
|
||||
|
||||
@@ -52,8 +52,6 @@
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/Interface.h>
|
||||
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/Feature.h>
|
||||
|
||||
#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<PartDesign::Body*>(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<PartDesign::Body*>(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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user