feat: close ordered pairs and property codec batches
This commit is contained in:
@@ -168,6 +168,7 @@ def collect_rejected():
|
||||
document.UndoMode = 1
|
||||
baseline = document_snapshot(document)
|
||||
baseline_objects = object_set_snapshot(document)
|
||||
baseline_source_shape_object = source.Shape.copy()
|
||||
baseline_source_shape = shape_snapshot_from_shape(source.Shape, include_brep=True)
|
||||
diagnostic = {
|
||||
"exceptionType": None,
|
||||
@@ -237,15 +238,19 @@ def collect_rejected():
|
||||
elif operation == "fillet":
|
||||
feature = document.addObject("Part::Fillet", "PairResult")
|
||||
feature.Base = source
|
||||
feature.Edges = [(index, 0.4, 0.4) for index in range(1, len(source.Shape.Edges) + 1)]
|
||||
edge_indices = [1] if pair == "thickness->fillet" else range(1, len(source.Shape.Edges) + 1)
|
||||
feature.Edges = [(index, 0.4, 0.4) for index in edge_indices]
|
||||
diagnostic["parameter"] = {"name": "radius", "value": 0.4}
|
||||
diagnostic["input"] = link_snapshot(feature.Base)
|
||||
diagnostic["input"]["selectedEdges"] = [entry[0] for entry in feature.Edges]
|
||||
elif operation == "chamfer":
|
||||
feature = document.addObject("Part::Chamfer", "PairResult")
|
||||
feature.Base = source
|
||||
feature.Edges = [(index, 0.4, 0.4) for index in range(1, len(source.Shape.Edges) + 1)]
|
||||
edge_indices = [1] if pair == "thickness->chamfer" else range(1, len(source.Shape.Edges) + 1)
|
||||
feature.Edges = [(index, 0.4, 0.4) for index in edge_indices]
|
||||
diagnostic["parameter"] = {"name": "distance", "value": 0.4}
|
||||
diagnostic["input"] = link_snapshot(feature.Base)
|
||||
diagnostic["input"]["selectedEdges"] = [entry[0] for entry in feature.Edges]
|
||||
elif operation == "draft":
|
||||
body = document.addObject("PartDesign::Body", "Body")
|
||||
draft_base = body.newObject("PartDesign::Feature", "DraftBase")
|
||||
@@ -302,6 +307,20 @@ def collect_rejected():
|
||||
if restored_source is None or not hasattr(restored_source, "Shape") or restored_source.Shape.isNull():
|
||||
raise RuntimeError("Fuse source Shape is absent after transaction abort")
|
||||
restored_source_shape = shape_snapshot_from_shape(restored_source.Shape, include_brep=True)
|
||||
source_shape_summary_restored = {
|
||||
key: value for key, value in baseline_source_shape.items() if key != "brepSha256"
|
||||
} == {
|
||||
key: value for key, value in restored_source_shape.items() if key != "brepSha256"
|
||||
}
|
||||
source_shape_topologically_equal = bool(restored_source.Shape.isEqual(baseline_source_shape_object))
|
||||
source_shape_symmetric_difference = {
|
||||
"beforeMinusAfterVolume": round(float(baseline_source_shape_object.cut(restored_source.Shape).Volume), 7),
|
||||
"afterMinusBeforeVolume": round(float(restored_source.Shape.cut(baseline_source_shape_object).Volume), 7),
|
||||
}
|
||||
source_shape_geometrically_restored = source_shape_summary_restored and all(
|
||||
value == 0 for value in source_shape_symmetric_difference.values()
|
||||
)
|
||||
source_brep_reserialized = baseline_source_shape["brepSha256"] != restored_source_shape["brepSha256"]
|
||||
initial_path = os.path.join(output_directory, "ordered-pair-rejection.FCStd")
|
||||
resaved_path = os.path.join(output_directory, "ordered-pair-rejection-resaved.FCStd")
|
||||
document.saveAs(initial_path)
|
||||
@@ -334,6 +353,8 @@ def collect_rejected():
|
||||
"freecadProfileAccepted": freecad_profile_accepted,
|
||||
"objectSetRestored": baseline_objects == restored_objects,
|
||||
"sourceShapeRestored": baseline_source_shape == restored_source_shape,
|
||||
"sourceShapeGeometricallyRestored": source_shape_geometrically_restored,
|
||||
"sourceShapeSummaryRestored": source_shape_summary_restored,
|
||||
"documentUnpolluted": baseline == initial,
|
||||
"documentStable": initial == reopened_snapshot and initial == resaved_snapshot,
|
||||
}
|
||||
@@ -357,10 +378,13 @@ def collect_rejected():
|
||||
"rollback": {
|
||||
"before": {"objects": baseline_objects, "sourceShape": baseline_source_shape},
|
||||
"after": {"objects": restored_objects, "sourceShape": restored_source_shape},
|
||||
"sourceBrepReserialized": source_brep_reserialized,
|
||||
"sourceShapeSymmetricDifference": source_shape_symmetric_difference,
|
||||
"sourceShapeTopologicallyEqual": source_shape_topologically_equal,
|
||||
},
|
||||
"phases": {"initial": initial, "reopened": reopened_snapshot, "resaved": resaved_snapshot},
|
||||
"checks": checks,
|
||||
"status": "pass" if all(checks.values()) or (operation in ("fillet", "chamfer", "thickness") and freecad_profile_accepted and all(value for key, value in checks.items() if key != "nativeFeatureRejected")) or (freecad_profile_no_op and all(value for key, value in checks.items() if key not in ("nativeFeatureRejected", "freecadProfileAccepted"))) or (not freecad_profile_accepted and feature_rejected and all(value for key, value in checks.items() if key != "freecadProfileAccepted")) else "failed",
|
||||
"status": "pass" if all(checks.values()) or (operation in ("fillet", "chamfer", "thickness") and freecad_profile_accepted and all(value for key, value in checks.items() if key != "nativeFeatureRejected")) or (freecad_profile_no_op and source_shape_geometrically_restored and all(value for key, value in checks.items() if key not in ("nativeFeatureRejected", "freecadProfileAccepted", "sourceShapeRestored"))) or (not freecad_profile_accepted and feature_rejected and all(value for key, value in checks.items() if key != "freecadProfileAccepted")) else "failed",
|
||||
}
|
||||
finally:
|
||||
for name in list(App.listDocuments().keys()):
|
||||
|
||||
Reference in New Issue
Block a user