1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0031425: Visualization - free Edge has selection sensitivity inconsistent to presentation

BRepTools::Triangulation() has been extended with a new parameter for checking Poly_Polygon3D presense within free Edges.
StdPrs_WFShape::Add() now performs auto-triangulation in the same way as StdPrs_ShadedShape::Add().
StdSelect_BRepSelectionTool::GetEdgeSensitive() now creates Select3D_SensitiveSegment instead of Select3D_SensitiveCurve for tessellated segment.
Select3D_SensitiveSegment default sensitivity factor has been changed to 3 pixels to match Select3D_SensitiveCurve.

Test case bug23625_1, added workaround for out-of-range crash in HLRBRep_PolyAlgo on re-triangulated shape.
This commit is contained in:
kgv
2020-03-11 17:06:49 +03:00
committed by bugmaster
parent 08669adf1b
commit 29263c947e
14 changed files with 122 additions and 46 deletions

View File

@@ -903,25 +903,61 @@ void BRepTools::RemoveUnusedPCurves(const TopoDS_Shape& S)
//purpose :
//=======================================================================
Standard_Boolean BRepTools::Triangulation(const TopoDS_Shape& S,
const Standard_Real deflec)
Standard_Boolean BRepTools::Triangulation(const TopoDS_Shape& theShape,
const Standard_Real theLinDefl,
const Standard_Boolean theToCheckFreeEdges)
{
TopExp_Explorer exf, exe;
TopLoc_Location l;
Handle(Poly_Triangulation) T;
Handle(Poly_PolygonOnTriangulation) Poly;
for (exf.Init(S, TopAbs_FACE); exf.More(); exf.Next()) {
const TopoDS_Face& F = TopoDS::Face(exf.Current());
T = BRep_Tool::Triangulation(F, l);
if (T.IsNull() || (T->Deflection() > deflec))
TopExp_Explorer anEdgeIter;
TopLoc_Location aDummyLoc;
for (TopExp_Explorer aFaceIter (theShape, TopAbs_FACE); aFaceIter.More(); aFaceIter.Next())
{
const TopoDS_Face& aFace = TopoDS::Face (aFaceIter.Current());
const Handle(Poly_Triangulation)& aTri = BRep_Tool::Triangulation (aFace, aDummyLoc);
if (aTri.IsNull()
|| aTri->Deflection() > theLinDefl)
{
return Standard_False;
for (exe.Init(F, TopAbs_EDGE); exe.More(); exe.Next()) {
const TopoDS_Edge& E = TopoDS::Edge(exe.Current());
Poly = BRep_Tool::PolygonOnTriangulation(E, T, l);
if (Poly.IsNull()) return Standard_False;
}
for (anEdgeIter.Init (aFace, TopAbs_EDGE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current());
const Handle(Poly_PolygonOnTriangulation)& aPoly = BRep_Tool::PolygonOnTriangulation (anEdge, aTri, aDummyLoc);
if (aPoly.IsNull())
{
return Standard_False;
}
}
}
if (!theToCheckFreeEdges)
{
return Standard_True;
}
Handle(Poly_Triangulation) anEdgeTri;
for (anEdgeIter.Init (theShape, TopAbs_EDGE, TopAbs_FACE); anEdgeIter.More(); anEdgeIter.Next())
{
const TopoDS_Edge& anEdge = TopoDS::Edge (anEdgeIter.Current());
const Handle(Poly_Polygon3D)& aPolygon = BRep_Tool::Polygon3D (anEdge, aDummyLoc);
if (!aPolygon.IsNull())
{
if (aPolygon->Deflection() > theLinDefl)
{
return Standard_False;
}
}
else
{
const Handle(Poly_PolygonOnTriangulation)& aPoly = BRep_Tool::PolygonOnTriangulation (anEdge, anEdgeTri, aDummyLoc);
if (aPoly.IsNull()
|| anEdgeTri.IsNull()
|| anEdgeTri->Deflection() > theLinDefl)
{
return Standard_False;
}
}
}
return Standard_True;
}

View File

@@ -162,10 +162,18 @@ public:
//! refer to surfaces not belonging to any face of <S>
Standard_EXPORT static void RemoveUnusedPCurves (const TopoDS_Shape& S);
//! verifies that each face from the shape <S> has got
//! a triangulation with a deflection <= deflec and
//! the edges a discretisation on this triangulation.
Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& S, const Standard_Real deflec);
//! Verifies that each Face from the shape has got a triangulation with a deflection smaller or equal to specified one
//! and the Edges a discretization on this triangulation.
//! @param theShape [in] shape to verify
//! @param theLinDefl [in] maximum allowed linear deflection
//! @param theToCheckFreeEdges [in] if TRUE, then free Edges are required to have 3D polygon
//! @return FALSE if input Shape contains Faces without triangulation,
//! or that triangulation has worse (greater) deflection than specified one,
//! or Edges in Shape lack polygons on triangulation
//! or free Edges in Shape lack 3D polygons
Standard_EXPORT static Standard_Boolean Triangulation (const TopoDS_Shape& theShape,
const Standard_Real theLinDefl,
const Standard_Boolean theToCheckFreeEdges = Standard_False);
//! Returns True if the distance between the two
//! vertices is lower than their tolerance.