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

0029712: Extrema algorithm raises exception

1. Extrema algorithm calls Curve-surface intersector. This intersector returns flag about infinite solution (in spite of extrema's returning not-parallel status correctly - axes of considered cylinder and circle are not parallel). In this case, attempt of obtaining number of intersection points leads to exception.

So, the fix adds check of infinite solution after the intersection algorithm.

2. The methods IsDone(), IsParallel(), NbExt(), SquareDistance() and Points() (of Extrema_* classes) have been corrected to make them consistent to the documentation.

3. Revision of some Extrema_* classes has been made in order to avoid places with uninitialized variables.

4. Currently Extrema does not store any points in case when the arguments are parallel. It stores the distance only.

5. Some cases on Extrema-algo have been moved from "fclasses"-group to "modalg"-group.
This commit is contained in:
nbv
2018-04-20 17:00:48 +03:00
committed by bugmaster
parent 395a5977d5
commit 638ad7f3c5
80 changed files with 2394 additions and 748 deletions

View File

@@ -83,35 +83,43 @@ Standard_Boolean BRepClass3d_BndBoxTreeSelectorLine::Accept (const Standard_Inte
if (sht == TopAbs_EDGE)
{
const TopoDS_Edge& E = TopoDS::Edge(shp);
Standard_Real EdgeTSq = BRep_Tool::Tolerance(E);
Standard_Real EdgeTSq = BRep_Tool::Tolerance(E);
EdgeTSq *= EdgeTSq;
Standard_Real f, l;
BRepAdaptor_Curve C(E);
BRep_Tool::Range(E,f,l);
BRep_Tool::Range(E, f, l);
// Edge-Line interference.
Extrema_ExtCC ExtCC(C, myLC, f, l, myLC.FirstParameter(), myLC.LastParameter());
if (ExtCC.IsDone() && ExtCC.NbExt() > 0)
{
Standard_Boolean IsInside = Standard_False;
for (Standard_Integer i = 1; i <= ExtCC.NbExt(); i++)
if (ExtCC.IsDone())
{
if (ExtCC.IsParallel())
{
if (ExtCC.SquareDistance(i) < EdgeTSq)
{
Extrema_POnCurv P1, P2;
ExtCC.Points(i,P1, P2);
EdgeParam EP;
EP.myE = E;
EP.myParam = P1.Parameter(); // Original curve is the first parameter.
EP.myLParam = P2.Parameter(); // Linear curve is the second parameter.
myEP.Append(EP);
IsInside = Standard_True;
}
// Tangent case is invalid for classification
myIsValid = Standard_False;
}
else if (ExtCC.NbExt() > 0)
{
Standard_Boolean IsInside = Standard_False;
for (Standard_Integer i = 1; i <= ExtCC.NbExt(); i++)
{
if (ExtCC.SquareDistance(i) < EdgeTSq)
{
Extrema_POnCurv P1, P2;
ExtCC.Points(i, P1, P2);
EdgeParam EP;
EP.myE = E;
EP.myParam = P1.Parameter(); // Original curve is the first parameter.
EP.myLParam = P2.Parameter(); // Linear curve is the second parameter.
myEP.Append(EP);
IsInside = Standard_True;
}
}
if (IsInside)
return Standard_True;
}
if (IsInside)
return Standard_True;
}
}
else if (sht == TopAbs_VERTEX)

View File

@@ -83,7 +83,9 @@ public:
public:
BRepClass3d_BndBoxTreeSelectorLine(const TopTools_IndexedMapOfShape& theMapOfShape)
: BRepClass3d_BndBoxTreeSelectorLine::Selector(), myMapOfShape (theMapOfShape)
: BRepClass3d_BndBoxTreeSelectorLine::Selector(),
myMapOfShape(theMapOfShape),
myIsValid(Standard_True)
{}
Standard_Boolean Reject (const Bnd_Box& theBox) const
@@ -135,6 +137,13 @@ public:
{
myEP.Clear();
myVP.Clear();
myIsValid = Standard_True;
}
//! Returns TRUE if correct classification is possible
Standard_Boolean IsCorrect() const
{
return myIsValid;
}
private:
@@ -147,6 +156,7 @@ private:
NCollection_Sequence<EdgeParam> myEP; //output result (edge vs line)
NCollection_Sequence<VertParam> myVP; //output result (vertex vs line)
GeomAdaptor_Curve myLC;
Standard_Boolean myIsValid;
};
#endif

View File

@@ -285,6 +285,14 @@ void BRepClass3d_SClassifier::Perform(BRepClass3d_SolidExplorer& SolidExplorer,
aSelectorLine.SetCurrentLine(L, Par);
Standard_Integer SelsEVL = 0;
SelsEVL = aTree.Select(aSelectorLine); //SelsEE > 0 => Line/Edges & Line/Vertex intersection
if (!aSelectorLine.IsCorrect())
{
// Go to the next segment
isFaultyLine = Standard_True;
continue;
}
if (SelsEVL > 0 )
{
// Line and edges / vertices interference.