[TD]correct face detection to avoid ghost faces

This commit is contained in:
wandererfan
2019-11-24 13:08:02 -05:00
committed by WandererFan
parent 90702da536
commit fff0029de5
8 changed files with 306 additions and 155 deletions

View File

@@ -518,9 +518,16 @@ void DrawViewPart::extractFaces()
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw,true);
// int idb = 0;
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
for (; itWire != sortedWires.end(); itWire++) {
//version 1: 1 wire/face - no voids in face
//debug
// std::stringstream ss;
// ss << "DVPSWire" << idb << ".brep";
// std::string wireName = ss.str();
// BRepTools::Write((*itWire), wireName.c_str()); //debug
//debug idb++;
TechDraw::Face* f = new TechDraw::Face();
const TopoDS_Wire& wire = (*itWire);
TechDraw::Wire* w = new TechDraw::Wire(wire);
@@ -926,7 +933,7 @@ bool DrawViewPart::checkXDirection(void) const
Base::Vector3d origin(0.0,0.0,0.0);
Base::Vector3d xDir = getLegacyX(origin,
dir);
Base::Console().Warning("DVP - %s - XDirection property not set. Trying %s\n",
Base::Console().Log("DVP - %s - XDirection property not set. Trying %s\n",
getNameInDocument(),
DrawUtil::formatVector(xDir).c_str());
return false;

View File

@@ -49,6 +49,7 @@
#include <HLRAlgo_Projector.hxx>
#include <HLRBRep_HLRToShape.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeFix_Wire.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
@@ -371,14 +372,18 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
ss << "DVSScaledFace" << idb << ".brep" ;
std::string faceName = ss.str();
BRepTools::Write(pFace, faceName.c_str()); //debug
std::stringstream ss2;
ss2 << "DVSOuter" << idb << ".brep" ;
TopoDS_Wire owdb = ShapeAnalysis::OuterWire(pFace);
std::string wireName = ss2.str();
BRepTools::Write(owdb, wireName.c_str()); //debug
}
TopoDS_Wire ow = ShapeAnalysis::OuterWire(pFace);
// BRepTools::Write(ow, "outerwire.brep"); //debug
//this check helps prevent "ghost" faces
BRepCheck_Wire chkWire(ow);
TopoDS_Edge e1, e2;
BRepCheck_Status status = chkWire.SelfIntersect(pFace, e1, e2);
if (status == BRepCheck_NoError) {
if (status == BRepCheck_NoError) {
builder.Add(newFaces,pFace);
sectionFaceWires.push_back(ShapeAnalysis::OuterWire(pFace));
}

View File

@@ -39,6 +39,7 @@ class Bnd_Box;
class gp_Pln;
class gp_Pnt;
class TopoDS_Face;
class TopoDS_Wire;
class gp_Ax2;
namespace TechDraw

View File

@@ -426,6 +426,10 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge)
Handle(Geom_BezierCurve) bez = adapt.Bezier();
//if (bez->Degree() < 4) {
result = new BezierSegment(edge);
if (edge.Orientation() == TopAbs_REVERSED) {
result->reversed = true;
}
//}
// OCC is quite happy with Degree > 3 but QtGui handles only 2,3
} break;
@@ -456,7 +460,7 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge)
delete bspline;
bspline = nullptr;
}
}else {
} else {
result = bspline;
}
}
@@ -524,6 +528,9 @@ AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), ePt.Z());
midPnt = Base::Vector3d(m.X(), m.Y(), m.Z());
if (e.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
}
@@ -634,6 +641,9 @@ AOC::AOC(const TopoDS_Edge &e) : Circle(e)
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), s.Z());
midPnt = Base::Vector3d(m.X(), m.Y(), s.Z());
if (e.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
}
AOC::AOC(void) : Circle()
@@ -837,6 +847,9 @@ Generic::Generic(const TopoDS_Edge &e)
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
points.emplace_back(p.X(), p.Y(), p.Z());
}
if (e.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
}
@@ -1040,6 +1053,9 @@ BSpline::BSpline(const TopoDS_Edge &e)
}
segments.push_back(tempSegment);
}
if (e.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
}
@@ -1265,6 +1281,7 @@ TopoDS_Edge BSpline::asCircle(bool& arc)
result = newEdge;
}
}
return result;
}
@@ -1308,6 +1325,9 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e)
gp_Pnt controlPoint = bez->Pole(i);
pnts.emplace_back(controlPoint.X(), controlPoint.Y(), controlPoint.Z());
}
if (e.Orientation() == TopAbs_REVERSED) {
reversed = true;
}
}

View File

@@ -25,6 +25,7 @@
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRep_Builder.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <BRepLib.hxx>
#include <BRepLProp_CurveTool.hxx>
@@ -131,6 +132,16 @@ const std::vector<BaseGeom *> GeometryObject::getVisibleFaceEdges(const bool smo
}
}
}
//debug
//make compound of edges and save as brep file
// BRep_Builder builder;
// TopoDS_Compound comp;
// builder.MakeCompound(comp);
// for (auto& r: result) {
// builder.Add(comp, r->occEdge);
// }
// BRepTools::Write(comp, "GOVizFaceEdges.brep"); //debug
return result;
}