diff --git a/src/TopExp/TopExp_Explorer.cxx b/src/TopExp/TopExp_Explorer.cxx index 569f5f21b1..d87dd372ed 100644 --- a/src/TopExp/TopExp_Explorer.cxx +++ b/src/TopExp/TopExp_Explorer.cxx @@ -33,49 +33,49 @@ static const Standard_Integer theStackSize = 20; //======================================================================= //function : TopExp_Explorer -//purpose : +//purpose : //======================================================================= - -TopExp_Explorer::TopExp_Explorer() : - myStack(0L),myTop(-1),hasMore(Standard_False) +TopExp_Explorer::TopExp_Explorer() +: myStack (0L), + myTop (-1), + mySizeOfStack (theStackSize), + toFind (TopAbs_SHAPE), + toAvoid (TopAbs_SHAPE), + hasMore (Standard_False) { myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator)); - mySizeOfStack = theStackSize; } - //======================================================================= //function : TopExp_Explorer -//purpose : +//purpose : //======================================================================= - -TopExp_Explorer::TopExp_Explorer(const TopoDS_Shape& S, - const TopAbs_ShapeEnum ToFind, - const TopAbs_ShapeEnum ToAvoid): - myStack(0L),myTop(-1),hasMore(Standard_False) - +TopExp_Explorer::TopExp_Explorer (const TopoDS_Shape& theS, + const TopAbs_ShapeEnum theToFind, + const TopAbs_ShapeEnum theToAvoid) +: myStack (0L), + myTop (-1), + mySizeOfStack (theStackSize), + toFind (theToFind), + toAvoid (theToAvoid), + hasMore (Standard_False) { myStack = (TopoDS_Iterator*)Standard::Allocate(theStackSize*sizeof(TopoDS_Iterator)); - mySizeOfStack = theStackSize; - Init(S,ToFind,ToAvoid); + + Init (theS, theToFind, theToAvoid); } //======================================================================= //function : Init -//purpose : +//purpose : //======================================================================= - void TopExp_Explorer::Init(const TopoDS_Shape& S, const TopAbs_ShapeEnum ToFind, const TopAbs_ShapeEnum ToAvoid) { - if(myTop >=0) { - for(int i=0;i<= myTop; i++) - myStack[i].~TopoDS_Iterator(); - } - - myTop = -1; + Clear(); + myShape = S; toFind = ToFind; toAvoid = ToAvoid; @@ -131,18 +131,11 @@ const TopoDS_Shape& TopExp_Explorer::Current()const return myShape; } - //======================================================================= //function : Next -//purpose : +//purpose : //======================================================================= - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4291) // to avoid warning when using new(buffer) syntax -#endif - -void TopExp_Explorer::Next() +void TopExp_Explorer::Next() { Standard_Integer NewSize; TopoDS_Shape ShapTop; @@ -219,28 +212,40 @@ void TopExp_Explorer::Next() hasMore = Standard_False; } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - //======================================================================= //function : ReInit -//purpose : +//purpose : //======================================================================= - -void TopExp_Explorer::ReInit() +void TopExp_Explorer::ReInit() { Init(myShape,toFind,toAvoid); } -void TopExp_Explorer::Destroy() +//======================================================================= +//function : ~TopExp_Explorer +//purpose : +//======================================================================= +TopExp_Explorer::~TopExp_Explorer() { - if (myStack) - { - for(int i=0;i<= myTop; i++)myStack[i].~TopoDS_Iterator(); - Standard::Free(myStack); - } + Clear(); + if (myStack) + { + Standard::Free(myStack); + } mySizeOfStack = 0; myStack = 0L; } +//======================================================================= +//function : Clear +//purpose : +//======================================================================= +void TopExp_Explorer::Clear() +{ + hasMore = Standard_False; + for (int i = 0; i <= myTop; ++i) + { + myStack[i].~TopoDS_Iterator(); + } + myTop = -1; +} diff --git a/src/TopExp/TopExp_Explorer.hxx b/src/TopExp/TopExp_Explorer.hxx index a49d3f15e7..bbdaba0d2e 100644 --- a/src/TopExp/TopExp_Explorer.hxx +++ b/src/TopExp/TopExp_Explorer.hxx @@ -18,6 +18,7 @@ #define _TopExp_Explorer_HeaderFile #include +#include #include //! An Explorer is a Tool to visit a Topological Data @@ -136,39 +137,21 @@ public: //! Clears the content of the explorer. It will return //! False on More(). - void Clear(); - - Standard_EXPORT void Destroy(); -~TopExp_Explorer() -{ - Destroy(); -} + Standard_EXPORT void Clear(); + + //! Destructor. + Standard_EXPORT ~TopExp_Explorer(); private: TopExp_Stack myStack; + TopoDS_Shape myShape; Standard_Integer myTop; Standard_Integer mySizeOfStack; - TopoDS_Shape myShape; - Standard_Boolean hasMore; TopAbs_ShapeEnum toFind; TopAbs_ShapeEnum toAvoid; + Standard_Boolean hasMore; }; -#include - -inline void TopExp_Explorer::Clear() -{ - hasMore = Standard_False; - if (myTop > 0) - { - for (int i = 1; i <= myTop; i++) - { - myStack[i].~TopoDS_Iterator(); - } - } - myTop = 0; -} - #endif // _TopExp_Explorer_HeaderFile