mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0033670: Coding - TopExp_Explorer performance update
Reorganized Explorer memory behavior
This commit is contained in:
parent
4c8faa5e2d
commit
3cb62db951
@ -43,7 +43,7 @@ TopExp_Explorer::TopExp_Explorer()
|
|||||||
toAvoid (TopAbs_SHAPE),
|
toAvoid (TopAbs_SHAPE),
|
||||||
hasMore (Standard_False)
|
hasMore (Standard_False)
|
||||||
{
|
{
|
||||||
myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator));
|
myStack = (TopoDS_Iterator*)Standard::AllocateOptimal(theStackSize*sizeof(TopoDS_Iterator));
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@ -60,7 +60,7 @@ TopExp_Explorer::TopExp_Explorer (const TopoDS_Shape& theS,
|
|||||||
toAvoid (theToAvoid),
|
toAvoid (theToAvoid),
|
||||||
hasMore (Standard_False)
|
hasMore (Standard_False)
|
||||||
{
|
{
|
||||||
myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator));
|
myStack = (TopoDS_Iterator*)Standard::AllocateOptimal(theStackSize*sizeof(TopoDS_Iterator));
|
||||||
|
|
||||||
Init (theS, theToFind, theToAvoid);
|
Init (theS, theToFind, theToAvoid);
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ const TopoDS_Shape& TopExp_Explorer::Current()const
|
|||||||
void TopExp_Explorer::Next()
|
void TopExp_Explorer::Next()
|
||||||
{
|
{
|
||||||
Standard_Integer NewSize;
|
Standard_Integer NewSize;
|
||||||
TopoDS_Shape ShapTop;
|
TopoDS_Shape const* ShapTop = nullptr;
|
||||||
TopAbs_ShapeEnum ty;
|
TopAbs_ShapeEnum ty;
|
||||||
Standard_NoMoreObject_Raise_if(!hasMore,"TopExp_Explorer::Next");
|
Standard_NoMoreObject_Raise_if(!hasMore,"TopExp_Explorer::Next");
|
||||||
|
|
||||||
@ -159,16 +159,9 @@ void TopExp_Explorer::Next()
|
|||||||
else {
|
else {
|
||||||
// push and try to find
|
// push and try to find
|
||||||
if(++myTop >= mySizeOfStack) {
|
if(++myTop >= mySizeOfStack) {
|
||||||
NewSize = mySizeOfStack + theStackSize;
|
NewSize = mySizeOfStack + theStackSize;
|
||||||
TopExp_Stack newStack = (TopoDS_Iterator*)Standard::Allocate(NewSize*sizeof(TopoDS_Iterator));
|
myStack = (TopoDS_Iterator*)Standard::Reallocate(myStack, NewSize * sizeof(TopoDS_Iterator));
|
||||||
Standard_Integer i;
|
mySizeOfStack = NewSize;
|
||||||
for ( i =0; i < myTop; i++) {
|
|
||||||
new (&newStack[i]) TopoDS_Iterator(myStack[i]);
|
|
||||||
myStack[i].~TopoDS_Iterator();
|
|
||||||
}
|
|
||||||
Standard::Free(myStack);
|
|
||||||
mySizeOfStack = NewSize;
|
|
||||||
myStack = newStack;
|
|
||||||
}
|
}
|
||||||
new (&myStack[myTop]) TopoDS_Iterator(myShape);
|
new (&myStack[myTop]) TopoDS_Iterator(myShape);
|
||||||
}
|
}
|
||||||
@ -177,8 +170,8 @@ void TopExp_Explorer::Next()
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (myStack[myTop].More()) {
|
if (myStack[myTop].More()) {
|
||||||
ShapTop = myStack[myTop].Value();
|
ShapTop = &myStack[myTop].Value();
|
||||||
ty = ShapTop.ShapeType();
|
ty = ShapTop->ShapeType();
|
||||||
if (SAMETYPE(toFind,ty)) {
|
if (SAMETYPE(toFind,ty)) {
|
||||||
hasMore = Standard_True;
|
hasMore = Standard_True;
|
||||||
return;
|
return;
|
||||||
@ -186,17 +179,10 @@ void TopExp_Explorer::Next()
|
|||||||
else if (LESSCOMPLEX(toFind,ty) && !AVOID(toAvoid,ty)) {
|
else if (LESSCOMPLEX(toFind,ty) && !AVOID(toAvoid,ty)) {
|
||||||
if(++myTop >= mySizeOfStack) {
|
if(++myTop >= mySizeOfStack) {
|
||||||
NewSize = mySizeOfStack + theStackSize;
|
NewSize = mySizeOfStack + theStackSize;
|
||||||
TopExp_Stack newStack = (TopoDS_Iterator*)Standard::Allocate(NewSize*sizeof(TopoDS_Iterator));
|
myStack = (TopoDS_Iterator*)Standard::Reallocate(myStack, NewSize * sizeof(TopoDS_Iterator));
|
||||||
Standard_Integer i;
|
|
||||||
for (i =0; i < myTop; i++) {
|
|
||||||
new (&newStack[i]) TopoDS_Iterator(myStack[i]);
|
|
||||||
myStack[i].~TopoDS_Iterator();
|
|
||||||
}
|
|
||||||
Standard::Free(myStack);
|
|
||||||
mySizeOfStack = NewSize;
|
mySizeOfStack = NewSize;
|
||||||
myStack = newStack;
|
|
||||||
}
|
}
|
||||||
new (&myStack[myTop]) TopoDS_Iterator(ShapTop);
|
new (&myStack[myTop]) TopoDS_Iterator(*ShapTop);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myStack[myTop].Next();
|
myStack[myTop].Next();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user