Validate face in extrusion feature
This commit is contained in:
parent
6ac2a2f3e8
commit
3025c6e292
|
@ -25,6 +25,7 @@
|
|||
#ifndef _PreComp_
|
||||
# include <cmath>
|
||||
# include <gp_Trsf.hxx>
|
||||
# include <BRepCheck_Analyzer.hxx>
|
||||
# include <BRepOffsetAPI_MakeOffset.hxx>
|
||||
# include <BRepBuilderAPI_Copy.hxx>
|
||||
# include <BRepBuilderAPI_MakeFace.hxx>
|
||||
|
@ -34,6 +35,7 @@
|
|||
# include <BRepPrimAPI_MakePrism.hxx>
|
||||
# include <Precision.hxx>
|
||||
# include <ShapeAnalysis.hxx>
|
||||
# include <ShapeFix_Shape.hxx>
|
||||
# include <ShapeFix_Wire.hxx>
|
||||
# include <TopoDS.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
|
@ -161,7 +163,7 @@ App::DocumentObjectExecReturn *Extrusion::execute(void)
|
|||
myShape = BRepBuilderAPI_Copy(myShape).Shape();
|
||||
if (makeSolid && myShape.ShapeType() == TopAbs_WIRE) {
|
||||
BRepBuilderAPI_MakeFace mkFace(TopoDS::Wire(myShape));
|
||||
myShape = mkFace.Face();
|
||||
myShape = validateFace(mkFace.Face());
|
||||
}
|
||||
BRepPrimAPI_MakePrism mkPrism(myShape, vec);
|
||||
TopoDS_Shape swept = mkPrism.Shape();
|
||||
|
@ -176,3 +178,43 @@ App::DocumentObjectExecReturn *Extrusion::execute(void)
|
|||
return new App::DocumentObjectExecReturn(e->GetMessageString());
|
||||
}
|
||||
}
|
||||
|
||||
TopoDS_Face Extrusion::validateFace(const TopoDS_Face& face) const
|
||||
{
|
||||
BRepCheck_Analyzer aChecker(face);
|
||||
if (!aChecker.IsValid()) {
|
||||
TopoDS_Wire outerwire = ShapeAnalysis::OuterWire(face);
|
||||
TopTools_IndexedMapOfShape myMap;
|
||||
myMap.Add(outerwire);
|
||||
|
||||
TopExp_Explorer xp(face,TopAbs_WIRE);
|
||||
ShapeFix_Wire fix;
|
||||
fix.SetFace(face);
|
||||
fix.Load(outerwire);
|
||||
fix.Perform();
|
||||
BRepBuilderAPI_MakeFace mkFace(fix.WireAPIMake());
|
||||
while (xp.More()) {
|
||||
if (!myMap.Contains(xp.Current())) {
|
||||
fix.Load(TopoDS::Wire(xp.Current()));
|
||||
fix.Perform();
|
||||
mkFace.Add(fix.WireAPIMake());
|
||||
}
|
||||
xp.Next();
|
||||
}
|
||||
|
||||
aChecker.Init(mkFace.Face());
|
||||
if (!aChecker.IsValid()) {
|
||||
ShapeFix_Shape fix(mkFace.Face());
|
||||
fix.SetPrecision(Precision::Confusion());
|
||||
fix.SetMaxTolerance(Precision::Confusion());
|
||||
fix.SetMaxTolerance(Precision::Confusion());
|
||||
fix.Perform();
|
||||
fix.FixWireTool()->Perform();
|
||||
fix.FixFaceTool()->Perform();
|
||||
return TopoDS::Face(fix.Shape());
|
||||
}
|
||||
return mkFace.Face();
|
||||
}
|
||||
|
||||
return face;
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <App/PropertyStandard.h>
|
||||
#include <App/PropertyUnits.h>
|
||||
#include "PartFeature.h"
|
||||
#include <TopoDS_Face.hxx>
|
||||
|
||||
namespace Part
|
||||
{
|
||||
|
@ -53,6 +54,9 @@ public:
|
|||
return "PartGui::ViewProviderExtrusion";
|
||||
}
|
||||
//@}
|
||||
|
||||
private:
|
||||
TopoDS_Face validateFace(const TopoDS_Face&) const;
|
||||
};
|
||||
|
||||
} //namespace Part
|
||||
|
|
Loading…
Reference in New Issue
Block a user