Compare commits

...

3 Commits

Author SHA1 Message Date
1be782b88d fix: Improve face creation from edges using BRepOffsetAPI_MakeFilling
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
2026-02-18 12:23:29 -07:00
3444e9e183 chore: Add debug logging for sketch face creation
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
2026-02-18 12:18:58 -07:00
fdd972b286 fix: Improve face creation for wire-based shapes by inferring plane
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
2026-02-18 12:16:45 -07:00

View File

@@ -15,8 +15,11 @@
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <ShapeAnalysis_FreeBounds.hxx> #include <ShapeAnalysis_FreeBounds.hxx>
#include <gp_Pln.hxx> #include <gp_Pln.hxx>
#include <BRepOffsetAPI_MakeFilling.hxx>
#include <GeomAbs_Shape.hxx>
#include <QJsonArray> #include <QJsonArray>
#include <QDebug>
SketchFeature::SketchFeature(const QString& name) SketchFeature::SketchFeature(const QString& name)
: Feature(name) : Feature(name)
@@ -122,26 +125,28 @@ void SketchFeature::buildShape()
} }
if (!lineEdges.isEmpty()) { if (!lineEdges.isEmpty()) {
TopoDS_Compound compound; qDebug() << "buildShape: processing" << lineEdges.size() << "line edges";
BRep_Builder builder;
builder.MakeCompound(compound); BRepOffsetAPI_MakeFilling faceMaker;
for (const auto& edge : lineEdges) { for (const TopoDS_Edge& edge : lineEdges) {
builder.Add(compound, edge); faceMaker.Add(edge, GeomAbs_C0);
} }
faceMaker.Build();
ShapeAnalysis_FreeBounds freeBounds(compound, 1e-6, Standard_True); if (faceMaker.IsDone()) {
TopoDS_Compound closedWires = freeBounds.GetClosedWires(); TopExp_Explorer explorer(faceMaker.Shape(), TopAbs_FACE);
int facesAdded = 0;
TopExp_Explorer explorer(closedWires, TopAbs_WIRE); for (; explorer.More(); explorer.Next()) {
for (; explorer.More(); explorer.Next()) { faces.append(TopoDS::Face(explorer.Current()));
TopoDS_Wire wire = TopoDS::Wire(explorer.Current()); facesAdded++;
BRepBuilderAPI_MakeFace faceBuilder(sketchPlane, wire);
if (faceBuilder.IsDone()) {
faces.append(faceBuilder.Face());
} }
qDebug() << "buildShape: added" << facesAdded << "face(s) using MakeFilling";
} else {
qDebug() << "buildShape: MakeFilling failed";
} }
} }
qDebug() << "buildShape: total faces created:" << faces.size();
if (faces.isEmpty()) { if (faces.isEmpty()) {
return; return;
} }