mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0030708: Modeling Data - Exception is raised while initializing TopoDS_Iterator with null shape
Added protection from null shapes to TopoDS_Iterator::Initialize method.
This commit is contained in:
parent
2b5ced28c3
commit
b008680dc0
@ -2531,6 +2531,54 @@ static Standard_Integer OCC28131 (Draw_Interpretor&, Standard_Integer theNbArgs,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : OCC30708_1
|
||||||
|
//purpose : Tests initialization of the TopoDS_Iterator with null shape
|
||||||
|
//=======================================================================
|
||||||
|
static Standard_Integer OCC30708_1 (Draw_Interpretor& di, Standard_Integer, const char**)
|
||||||
|
{
|
||||||
|
TopoDS_Iterator it;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
|
TopoDS_Shape empty;
|
||||||
|
it.Initialize (empty);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Standard_Failure)
|
||||||
|
{
|
||||||
|
di << "Cannot initialize TopoDS_Iterator with null shape\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it.More())
|
||||||
|
di << "Incorrect Iterator initialization: method More() returns true on null shape\n";
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
//function : OCC30708_2
|
||||||
|
//purpose : Tests initialization of the BRepLib_MakeWire with null wire
|
||||||
|
//=======================================================================
|
||||||
|
static Standard_Integer OCC30708_2 (Draw_Interpretor& di, Standard_Integer, const char**)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OCC_CATCH_SIGNALS
|
||||||
|
|
||||||
|
TopoDS_Wire empty;
|
||||||
|
BRepLib_MakeWire aWBuilder (empty);
|
||||||
|
}
|
||||||
|
catch (Standard_Failure)
|
||||||
|
{
|
||||||
|
di << "Cannot initialize BRepLib_MakeWire with null wire\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
||||||
const char *group = "QABugs";
|
const char *group = "QABugs";
|
||||||
|
|
||||||
@ -2560,5 +2608,11 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
|||||||
__FILE__, OCC28887, group);
|
__FILE__, OCC28887, group);
|
||||||
theCommands.Add("OCC28131", "OCC28131 name: creates face problematic for offset", __FILE__, OCC28131, group);
|
theCommands.Add("OCC28131", "OCC28131 name: creates face problematic for offset", __FILE__, OCC28131, group);
|
||||||
|
|
||||||
|
theCommands.Add ("OCC30708_1", "Tests initialization of the TopoDS_Iterator with null shape",
|
||||||
|
__FILE__, OCC30708_1, group);
|
||||||
|
|
||||||
|
theCommands.Add ("OCC30708_2", "Tests initialization of the BRepLib_MakeWire with null shape",
|
||||||
|
__FILE__, OCC30708_2, group);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,16 @@ void TopoDS_Iterator::Initialize(const TopoDS_Shape& S,
|
|||||||
myOrientation = S.Orientation();
|
myOrientation = S.Orientation();
|
||||||
else
|
else
|
||||||
myOrientation = TopAbs_FORWARD;
|
myOrientation = TopAbs_FORWARD;
|
||||||
myShapes.Initialize(S.TShape()->Shapes());
|
|
||||||
|
if (S.IsNull())
|
||||||
|
myShapes = TopoDS_ListIteratorOfListOfShape();
|
||||||
|
else
|
||||||
|
myShapes.Initialize(S.TShape()->myShapes);
|
||||||
|
|
||||||
if (More()) {
|
if (More()) {
|
||||||
myShape = myShapes.Value();
|
myShape = myShapes.Value();
|
||||||
myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
|
myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
|
||||||
//modified by NIZNHY-PKV Fri Jan 16 07:42:30 2009f
|
|
||||||
if (!myLocation.IsIdentity())
|
if (!myLocation.IsIdentity())
|
||||||
//modified by NIZNHY-PKV Fri Jan 16 07:42:37 2009t
|
|
||||||
myShape.Move(myLocation);
|
myShape.Move(myLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,9 +63,7 @@ void TopoDS_Iterator::Next()
|
|||||||
if (More()) {
|
if (More()) {
|
||||||
myShape = myShapes.Value();
|
myShape = myShapes.Value();
|
||||||
myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
|
myShape.Orientation(TopAbs::Compose(myOrientation,myShape.Orientation()));
|
||||||
//modified by NIZNHY-PKV Fri Jan 16 07:42:30 2009f
|
|
||||||
if (!myLocation.IsIdentity())
|
if (!myLocation.IsIdentity())
|
||||||
//modified by NIZNHY-PKV Fri Jan 16 07:42:37 2009t
|
|
||||||
myShape.Move(myLocation);
|
myShape.Move(myLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
tests/bugs/moddata_3/bug30708_1
Normal file
8
tests/bugs/moddata_3/bug30708_1
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "0030708: Modeling Data - Crash while initializing TopoDS_Iterator with null shape"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
if { [regexp "Cannot initialize" [OCC30708_1]]} {
|
||||||
|
puts "Error: Cannot initialize TopoDS_Iterator with null shape"
|
||||||
|
}
|
8
tests/bugs/moddata_3/bug30708_2
Normal file
8
tests/bugs/moddata_3/bug30708_2
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "0030708: Modeling Data - Crash while initializing TopoDS_Iterator with null shape"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
if { [regexp "Cannot initialize" [OCC30708_2]]} {
|
||||||
|
puts "Error: Cannot initialize BRepLib_MakeWire with null wire"
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user