Added check to Revolution and Groove for sketch axis intersecting the sketch face
This commit is contained in:
@@ -52,6 +52,11 @@
|
||||
# include <ShapeAnalysis_Surface.hxx>
|
||||
# include <ShapeFix_Shape.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
# include <Extrema_ExtCC.hxx>
|
||||
# include <Extrema_POnCurv.hxx>
|
||||
# include <BRepAdaptor_CompCurve.hxx>
|
||||
# include <BRepAdaptor_Curve.hxx>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -532,6 +537,61 @@ const bool SketchBased::checkWireInsideFace(const TopoDS_Wire& wire, const TopoD
|
||||
return (proj.More() && proj.Current().Closed());
|
||||
}
|
||||
|
||||
const bool SketchBased::checkLineCrossesFace(const gp_Lin &line, const TopoDS_Face &face) {
|
||||
// This is not as easy as it looks, because a distance of zero might be OK if
|
||||
// the axis touches the sketchshape in in a linear edge or a vertex
|
||||
// Note: This algorithm does not catch cases where the sketchshape touches the
|
||||
// axis in two or more points
|
||||
// Note: And it only works on closed outer wires
|
||||
TopoDS_Wire outerWire = ShapeAnalysis::OuterWire(face);
|
||||
BRepBuilderAPI_MakeEdge mkEdge(line);
|
||||
if (!mkEdge.IsDone())
|
||||
throw Base::Exception("Revolve: Unexpected OCE failure");
|
||||
BRepAdaptor_Curve axis(TopoDS::Edge(mkEdge.Shape()));
|
||||
|
||||
TopExp_Explorer ex;
|
||||
int intersections = 0;
|
||||
std::vector<gp_Pnt> intersectionpoints;
|
||||
|
||||
// Note: We need to look at evey edge separately to catch coincident lines
|
||||
for (ex.Init(outerWire, TopAbs_EDGE); ex.More(); ex.Next()) {
|
||||
BRepAdaptor_Curve edge(TopoDS::Edge(ex.Current()));
|
||||
Extrema_ExtCC intersector(axis, edge);
|
||||
|
||||
if (intersector.IsDone()) {
|
||||
for (int i = 1; i <= intersector.NbExt(); i++) {
|
||||
|
||||
|
||||
if (intersector.SquareDistance(i) < Precision::Confusion()) {
|
||||
if (intersector.IsParallel()) {
|
||||
// A line that is coincident with the axis produces three intersections
|
||||
// 1 with the line itself and 2 with the adjacent edges
|
||||
intersections -= 2;
|
||||
} else {
|
||||
Extrema_POnCurv p1, p2;
|
||||
intersector.Points(i, p1, p2);
|
||||
intersectionpoints.push_back(p1.Value());
|
||||
intersections++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Note: We might check this inside the loop but then we have to rely on TopExp_Explorer
|
||||
// returning the wire's edges in adjacent order (because of the coincident line checking)
|
||||
if (intersections > 1) {
|
||||
// Check that we don't touch the sketchface just in two identical vertices
|
||||
if ((intersectionpoints.size() == 2) &&
|
||||
(intersectionpoints[0].IsEqual(intersectionpoints[1], Precision::Confusion())))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void SketchBased::remapSupportShape(const TopoDS_Shape& newShape)
|
||||
{
|
||||
TopTools_IndexedMapOfShape faceMap;
|
||||
|
||||
Reference in New Issue
Block a user