fix: Improve face creation from edges using BRepOffsetAPI_MakeFilling
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
#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>
|
#include <QDebug>
|
||||||
@@ -124,30 +126,23 @@ void SketchFeature::buildShape()
|
|||||||
|
|
||||||
if (!lineEdges.isEmpty()) {
|
if (!lineEdges.isEmpty()) {
|
||||||
qDebug() << "buildShape: processing" << lineEdges.size() << "line edges";
|
qDebug() << "buildShape: processing" << lineEdges.size() << "line edges";
|
||||||
TopoDS_Compound compound;
|
|
||||||
BRep_Builder builder;
|
BRepOffsetAPI_MakeFilling faceMaker;
|
||||||
builder.MakeCompound(compound);
|
for (const TopoDS_Edge& edge : lineEdges) {
|
||||||
for (const auto& edge : lineEdges) {
|
faceMaker.Add(edge, GeomAbs_C0);
|
||||||
builder.Add(compound, edge);
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
if (closedWires.IsNull()) {
|
for (; explorer.More(); explorer.Next()) {
|
||||||
qDebug() << "buildShape: no closed wires found";
|
faces.append(TopoDS::Face(explorer.Current()));
|
||||||
}
|
facesAdded++;
|
||||||
|
|
||||||
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";
|
|
||||||
}
|
}
|
||||||
|
qDebug() << "buildShape: added" << facesAdded << "face(s) using MakeFilling";
|
||||||
|
} else {
|
||||||
|
qDebug() << "buildShape: MakeFilling failed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user