From 1be782b88d499c7e058e7cfe78db3707170e4d7a Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 18 Feb 2026 12:23:29 -0700 Subject: [PATCH] fix: Improve face creation from edges using BRepOffsetAPI_MakeFilling Co-authored-by: aider (gemini/gemini-2.5-pro) --- src/SketchFeature.cpp | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/SketchFeature.cpp b/src/SketchFeature.cpp index 2cfd28d..6663be0 100644 --- a/src/SketchFeature.cpp +++ b/src/SketchFeature.cpp @@ -15,6 +15,8 @@ #include #include #include +#include +#include #include #include @@ -124,30 +126,23 @@ void SketchFeature::buildShape() if (!lineEdges.isEmpty()) { qDebug() << "buildShape: processing" << lineEdges.size() << "line edges"; - TopoDS_Compound compound; - BRep_Builder builder; - builder.MakeCompound(compound); - for (const auto& edge : lineEdges) { - builder.Add(compound, edge); + + BRepOffsetAPI_MakeFilling faceMaker; + for (const TopoDS_Edge& edge : lineEdges) { + faceMaker.Add(edge, GeomAbs_C0); } + faceMaker.Build(); - ShapeAnalysis_FreeBounds freeBounds(compound, 1e-6, Standard_True); - TopoDS_Compound closedWires = freeBounds.GetClosedWires(); - - if (closedWires.IsNull()) { - qDebug() << "buildShape: no closed wires found"; - } - - TopExp_Explorer explorer(closedWires, TopAbs_WIRE); - for (; explorer.More(); explorer.Next()) { - TopoDS_Wire wire = TopoDS::Wire(explorer.Current()); - BRepBuilderAPI_MakeFace faceBuilder(wire); - if (faceBuilder.IsDone()) { - faces.append(faceBuilder.Face()); - qDebug() << "buildShape: face created from wire"; - } else { - qDebug() << "buildShape: face creation from wire FAILED"; + if (faceMaker.IsDone()) { + TopExp_Explorer explorer(faceMaker.Shape(), TopAbs_FACE); + int facesAdded = 0; + for (; explorer.More(); explorer.Next()) { + faces.append(TopoDS::Face(explorer.Current())); + facesAdded++; } + qDebug() << "buildShape: added" << facesAdded << "face(s) using MakeFilling"; + } else { + qDebug() << "buildShape: MakeFilling failed"; } }