// File: BooleanOperations_Explorer.cxx // Created: Mon Sep 4 11:58:18 2000 // Author: Vincent DELOS // #include const static Standard_Integer theStackSize=20; // //=========================================================================== //function : BooleanOperations_Explorer //purpose : //=========================================================================== BooleanOperations_Explorer::BooleanOperations_Explorer (const BooleanOperations_ShapesDataStructure& SDS): myStack(0L), myTopOfStack(-1), mySizeOfStack(-1), myTargetToFind(TopAbs_SHAPE), myTargetToAvoid(TopAbs_SHAPE) { myShapesDataStructure = (BooleanOperations_PShapesDataStructure)&SDS; } //=========================================================================== //function : Delete //purpose : ~BooleanOperations_Explorer //=========================================================================== void BooleanOperations_Explorer::Delete() { if(myStack != 0L) { Standard::Free((Standard_Address&)myStack); } myStack = 0; } //=========================================================================== //function : Init //purpose : //=========================================================================== void BooleanOperations_Explorer::Init(const Standard_Integer aShapeNumber, const TopAbs_ShapeEnum TargetToFind, const TopAbs_ShapeEnum TargetToAvoid) { Standard_Integer i,j,k,theNumberOfTheShapeOnTop; TopAbs_ShapeEnum theTypeOfShapeOnTop,successorType; myTargetToFind = TargetToFind; myTargetToAvoid = TargetToAvoid; if (myStack != 0L) { Standard::Free((Standard_Address&)myStack); } mySizeOfStack = theStackSize; myStack = (Standard_Integer*)Standard::Allocate(theStackSize*sizeof(Standard_Integer)); ((Standard_Integer*)myStack)[0] = aShapeNumber; myTopOfStack = 0; theNumberOfTheShapeOnTop = ((Standard_Integer*)myStack)[myTopOfStack]; theTypeOfShapeOnTop = (*myShapesDataStructure).GetShapeType(theNumberOfTheShapeOnTop); if (theTypeOfShapeOnTop == myTargetToFind) { hasMore = Standard_True; return; } while (theTypeOfShapeOnTop != myTargetToFind) { Standard_Address theSuccessors; Standard_Integer theNumberOfSuccessors; // We get the successors of the shape on top of the stack. (*myShapesDataStructure).GetSuccessors(theNumberOfTheShapeOnTop,theSuccessors,theNumberOfSuccessors); // Do we have enough place to store our new successors ? if ((myTopOfStack+theNumberOfSuccessors > mySizeOfStack) && (theSuccessors != 0L)) { // We don't have enough place so we reallocate. Standard_Address theNewStack = (Standard_Integer*)Standard::Allocate ((mySizeOfStack+theStackSize+theNumberOfSuccessors)*sizeof(Standard_Integer)); // We copy the old array in the one. for (j=0;j mySizeOfStack) && (theSuccessors != 0L)) { Standard_Address theNewStack; theNewStack = (Standard_Integer*)Standard::Allocate ((mySizeOfStack+theNumberOfSuccessors+theStackSize)*sizeof(Standard_Integer)); for (j=0;j