mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0028600: Bad performance of the checkshape command
Shell check has been improved to use well-known width-first search. It significantly reduces computation time on the big shells. Test case has been added. Minor correction in test case
This commit is contained in:
parent
521efa926d
commit
83f32108f6
@ -44,51 +44,37 @@ IMPLEMENT_STANDARD_RTTIEXT(BRepCheck_Shell,BRepCheck_Result)
|
|||||||
//purpose :
|
//purpose :
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape& mapEF,
|
static void Propagate(const TopTools_IndexedDataMapOfShapeListOfShape& mapEF,
|
||||||
const TopoDS_Shape& theFac,
|
const TopoDS_Shape& theFace,
|
||||||
TopTools_MapOfShape& mapF)
|
TopTools_IndexedMapOfShape& theMapF)
|
||||||
{
|
{
|
||||||
if (mapF.Contains(theFac))
|
// Base for the traverse procedure.
|
||||||
{
|
theMapF.Add(theFace);
|
||||||
return;
|
|
||||||
}
|
|
||||||
mapF.Add(theFac); // attention, if oriented == Standard_True, fac should
|
|
||||||
// be FORWARD or REVERSED. It is not checked.
|
|
||||||
|
|
||||||
TopTools_MapIteratorOfMapOfShape itf(mapF);
|
// Perform well-known width-first traverse.
|
||||||
while(itf.More())
|
for (Standard_Integer anIdx = 1; anIdx <= theMapF.Extent(); ++anIdx)
|
||||||
{
|
{
|
||||||
Standard_Boolean hasBeenAdded = Standard_False;
|
const TopoDS_Shape& aFace = theMapF(anIdx);
|
||||||
const TopoDS_Shape& fac = itf.Key();
|
for (TopExp_Explorer ex(aFace, TopAbs_EDGE); ex.More(); ex.Next())
|
||||||
TopExp_Explorer ex;
|
|
||||||
for (ex.Init(fac,TopAbs_EDGE); ex.More(); ex.Next())
|
|
||||||
{
|
{
|
||||||
const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
|
const TopoDS_Edge& edg = TopoDS::Edge(ex.Current());
|
||||||
// test if the edge is in the map (only orienteed edges are present)
|
|
||||||
if (mapEF.Contains(edg))
|
|
||||||
{
|
|
||||||
for (TopTools_ListIteratorOfListOfShape itl(mapEF.FindFromKey(edg)); itl.More(); itl.Next())
|
|
||||||
{
|
|
||||||
if (!itl.Value().IsSame(fac) && !mapF.Contains(itl.Value()))
|
|
||||||
{
|
|
||||||
mapF.Add(itl.Value());
|
|
||||||
hasBeenAdded = Standard_True;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}//for (ex.Init(fac,TopAbs_EDGE); ex.More();)
|
|
||||||
|
|
||||||
if(hasBeenAdded)
|
// Test if the edge is in the map (only oriented edges are present).
|
||||||
{
|
const TopTools_ListOfShape* aList = mapEF.Seek(edg);
|
||||||
itf.Initialize(mapF);
|
|
||||||
}
|
if ( aList == NULL )
|
||||||
else
|
continue;
|
||||||
{
|
|
||||||
itf.Next();
|
for (TopTools_ListIteratorOfListOfShape itl(*aList); itl.More(); itl.Next())
|
||||||
|
{
|
||||||
|
// This code assumes that shape is added to an end of the map.
|
||||||
|
// The idea is simple: existing objects will not be added, new objects
|
||||||
|
// will be added to an end.
|
||||||
|
theMapF.Add(itl.Value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
//function : BRepCheck_Trace
|
//function : BRepCheck_Trace
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -218,7 +204,7 @@ void BRepCheck_Shell::Minimum()
|
|||||||
}
|
}
|
||||||
else if (nbface >= 2)
|
else if (nbface >= 2)
|
||||||
{
|
{
|
||||||
TopTools_MapOfShape mapF;
|
TopTools_IndexedMapOfShape mapF;
|
||||||
exp.ReInit();
|
exp.ReInit();
|
||||||
|
|
||||||
Propagate(myMapEF,exp.Current(),mapF);
|
Propagate(myMapEF,exp.Current(),mapF);
|
||||||
@ -338,7 +324,8 @@ BRepCheck_Status BRepCheck_Shell::Closed(const Standard_Boolean Update)
|
|||||||
//
|
//
|
||||||
Standard_Integer index, aNbF;
|
Standard_Integer index, aNbF;
|
||||||
TopExp_Explorer exp, ede;
|
TopExp_Explorer exp, ede;
|
||||||
TopTools_MapOfShape mapS, aMEToAvoid;
|
TopTools_IndexedMapOfShape mapS;
|
||||||
|
TopTools_MapOfShape aMEToAvoid;
|
||||||
myMapEF.Clear();
|
myMapEF.Clear();
|
||||||
|
|
||||||
|
|
||||||
|
19
tests/perf/modalg/bug28600
Normal file
19
tests/perf/modalg/bug28600
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_"
|
||||||
|
puts "========"
|
||||||
|
puts "OCC28600"
|
||||||
|
puts "========"
|
||||||
|
puts ""
|
||||||
|
########################################################################################################
|
||||||
|
# Bad performance of the checkshape command
|
||||||
|
########################################################################################################
|
||||||
|
|
||||||
|
pload ALL
|
||||||
|
|
||||||
|
# Read shape.
|
||||||
|
testreadstep [locate_data_file bug28600.stp] s1
|
||||||
|
|
||||||
|
# Measure performance metrics.
|
||||||
|
chrono s reset; chrono s start;
|
||||||
|
checkshape s1
|
||||||
|
chrono s stop counter checkshape; chrono s show;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user