Archived issue #0033090
Access violation using fuzzy boolean operations
Description
While debugging the code in the field reproduction, an access violation was reported by Author. The attached file contains the necessary data.
Occurs in OCCT 7.4.0. Respective Code is unchanged in OCCT 7.6.0:
happens if myUparams.IsNull() in
void IntTools_SurfaceRangeLocalizeData::SetFrame(const Standard_Real theUMin,
const Standard_Real theUMax,
const Standard_Real theVMin,
const Standard_Real theVMax)
{
myUIndMin = 0;
myUIndMax = 0;
myVIndMin = 0;
myVIndMax = 0;
if (myUParams.IsNull() || myVParams.IsNull()) {
return;
}
The routine is used in
IntTools\IntTools_BeanFaceIntersector.cxx
void BuildBox(const Handle(Geom_BSplineSurface) &theSurf,
const Standard_Real theFirstU,
const Standard_Real theLastU,
const Standard_Real theFirstV,
const Standard_Real theLastV,
IntTools_SurfaceRangeLocalizeData &theSurfaceData,
Bnd_Box &theBox)
{
Standard_Integer i;
Standard_Integer j;
Standard_Integer aNbUPnts;
Standard_Integer aNbVPnts;
Standard_Real aParam;
gp_Pnt aPnt;
theSurfaceData.SetFrame(theFirstU, theLastU, theFirstV, theLastV);
aNbUPnts = theSurfaceData.GetNBUPointsInFrame();
aNbVPnts = theSurfaceData.GetNBVPointsInFrame();
// Add corner points.
theSurf->D0(theFirstU, theFirstV, aPnt);
theBox.Add(aPnt);
theSurf->D0(theLastU, theFirstV, aPnt);
theBox.Add(aPnt);
theSurf->D0(theFirstU, theLastV, aPnt);
theBox.Add(aPnt);
theSurf->D0(theLastU, theLastV, aPnt);
theBox.Add(aPnt);
for (i = 1; i <= aNbUPnts; i++) {
// Add top and bottom points.
aParam = theSurfaceData.GetUParamInFrame(i);
and the access violation occurs then in GetUParamInFrame(i), because e.g. aNbUPnts = 1, because:
inline Standard_Integer IntTools_SurfaceRangeLocalizeData::
GetNBUPointsInFrame() const
{
return myUIndMax - myUIndMin + 1;
}
0-0+1 = 1
Occurs in OCCT 7.4.0. Respective Code is unchanged in OCCT 7.6.0:
happens if myUparams.IsNull() in
void IntTools_SurfaceRangeLocalizeData::SetFrame(const Standard_Real theUMin,
const Standard_Real theUMax,
const Standard_Real theVMin,
const Standard_Real theVMax)
{
myUIndMin = 0;
myUIndMax = 0;
myVIndMin = 0;
myVIndMax = 0;
if (myUParams.IsNull() || myVParams.IsNull()) {
return;
}
The routine is used in
IntTools\IntTools_BeanFaceIntersector.cxx
void BuildBox(const Handle(Geom_BSplineSurface) &theSurf,
const Standard_Real theFirstU,
const Standard_Real theLastU,
const Standard_Real theFirstV,
const Standard_Real theLastV,
IntTools_SurfaceRangeLocalizeData &theSurfaceData,
Bnd_Box &theBox)
{
Standard_Integer i;
Standard_Integer j;
Standard_Integer aNbUPnts;
Standard_Integer aNbVPnts;
Standard_Real aParam;
gp_Pnt aPnt;
theSurfaceData.SetFrame(theFirstU, theLastU, theFirstV, theLastV);
aNbUPnts = theSurfaceData.GetNBUPointsInFrame();
aNbVPnts = theSurfaceData.GetNBVPointsInFrame();
// Add corner points.
theSurf->D0(theFirstU, theFirstV, aPnt);
theBox.Add(aPnt);
theSurf->D0(theLastU, theFirstV, aPnt);
theBox.Add(aPnt);
theSurf->D0(theFirstU, theLastV, aPnt);
theBox.Add(aPnt);
theSurf->D0(theLastU, theLastV, aPnt);
theBox.Add(aPnt);
for (i = 1; i <= aNbUPnts; i++) {
// Add top and bottom points.
aParam = theSurfaceData.GetUParamInFrame(i);
and the access violation occurs then in GetUParamInFrame(i), because e.g. aNbUPnts = 1, because:
inline Standard_Integer IntTools_SurfaceRangeLocalizeData::
GetNBUPointsInFrame() const
{
return myUIndMax - myUIndMin + 1;
}
0-0+1 = 1
Steps to reproduce
This would be a model to reproduce the bug:
TopoDS_Shape s;
BRep_Builder b;
std::ifstream is;
is.open("D://EF.brep");
BRepTools::Read(s, is, b);
is.close();
TopExp_Explorer exp(s, TopAbs_FACE);
TopExp_Explorer expe(s, TopAbs_EDGE);
IntTools_EdgeFace* in = new IntTools_EdgeFace();
in->SetEdge(TopoDS::Edge(expe.Current()));
in->SetFuzzyValue(0.1);
in->SetFace(TopoDS::Face(exp.Current()));
in->UseQuickCoincidenceCheck(false);
in->SetRange(5.1673518776073308, 6.7381478044021721);
in->Perform();
TopoDS_Shape s;
BRep_Builder b;
std::ifstream is;
is.open("D://EF.brep");
BRepTools::Read(s, is, b);
is.close();
TopExp_Explorer exp(s, TopAbs_FACE);
TopExp_Explorer expe(s, TopAbs_EDGE);
IntTools_EdgeFace* in = new IntTools_EdgeFace();
in->SetEdge(TopoDS::Edge(expe.Current()));
in->SetFuzzyValue(0.1);
in->SetFace(TopoDS::Face(exp.Current()));
in->UseQuickCoincidenceCheck(false);
in->SetRange(5.1673518776073308, 6.7381478044021721);
in->Perform();
Additional information
The problem does not occur if using the following code:
src/IntTools/IntTools_SurfaceRangeLocalizeData.lxx
+ 2
- 2
Viewed
@@ -115,13 +115,13 @@ inline const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetGridPoint
inline Standard_Integer IntTools_SurfaceRangeLocalizeData::
GetNBUPointsInFrame() const
{
- return myUIndMax - myUIndMin + 1;
+ return myUParams.IsNull()? 0 : myUIndMax - myUIndMin + 1;
}
inline Standard_Integer IntTools_SurfaceRangeLocalizeData::
GetNBVPointsInFrame() const
{
- return myVIndMax - myVIndMin + 1;
+ return myVParams.IsNull()? 0 : myVIndMax - myVIndMin + 1;
}
src/IntTools/IntTools_SurfaceRangeLocalizeData.lxx
+ 2
- 2
Viewed
@@ -115,13 +115,13 @@ inline const gp_Pnt &IntTools_SurfaceRangeLocalizeData::GetGridPoint
inline Standard_Integer IntTools_SurfaceRangeLocalizeData::
GetNBUPointsInFrame() const
{
- return myUIndMax - myUIndMin + 1;
+ return myUParams.IsNull()? 0 : myUIndMax - myUIndMin + 1;
}
inline Standard_Integer IntTools_SurfaceRangeLocalizeData::
GetNBVPointsInFrame() const
{
- return myVIndMax - myVIndMin + 1;
+ return myVParams.IsNull()? 0 : myVIndMax - myVIndMin + 1;
}
Public activity
No public notes
Participants are labeled by their role within this record.