// File: BooleanOperations_OnceExplorer.cxx // Created: Thu Sep 7 17:13:36 2000 // Author: Vincent DELOS // #include //#define theStackSize (20) const static Standard_Integer theStackSize=20; #define BITFLAG(n) (1 << (n)) // creation of 2 power n. #define BITSET(word,mask) (word) |= (mask) // to set a bit to 1 in word using mask. #define BITCLEAR(word,mask) (word) &= ~(mask) // to set a bit to 0 in word using mask. #define BITISSET(word,mask) ((word) & (mask)) // returns the value of the bit corresponding to mask. #define LEMOT(id) ((id) >> 5) // the number of the integer we will work on. #define LEBIT(id) (BITFLAG((id) & 31)) // the number of the bit we will work on (2 power (id%32)). #define CC0BIT(id,anArray) BITCLEAR(anArray[LEMOT(id)],LEBIT(id)) // sets to 0 the bit number id in anArray. #define CC1BIT(id,anArray) BITSET(anArray[LEMOT(id)],LEBIT(id)) // sets to 1 the bit number id in anArray. #define NNNBIT(id,anArray) (BITISSET(anArray[LEMOT(id)],LEBIT(id)) ? 1 : 0) // returns the bit number id in anArray. //=========================================================================== //function : BooleanOperations_OnceExplorer //purpose : //=========================================================================== BooleanOperations_OnceExplorer::BooleanOperations_OnceExplorer (const BooleanOperations_ShapesDataStructure& SDS): BooleanOperations_Explorer(SDS) { hasMore = Standard_False; // The size of the array of bits is the lower multiple of //32 greater than the number of shapes in myShapesDataStructure. Standard_Integer MultipleOf32= (((*myShapesDataStructure).myLength+31) & (~31)); mySizeOfArrayOfBits = MultipleOf32/32; myArrayOfBits = 0L; } //modified by NIZNHY-PKV Sun Dec 15 16:28:15 2002 f //=========================================================================== //function : Delete //purpose : alias ~BooleanOperations_Explorer //=========================================================================== void BooleanOperations_OnceExplorer::Delete() { if (myArrayOfBits) { free (myArrayOfBits); } BooleanOperations_Explorer::Delete(); } //modified by NIZNHY-PKV Sun Dec 15 16:29:10 2002 t //=========================================================================== //function : Init //purpose : //=========================================================================== void BooleanOperations_OnceExplorer::Init(const Standard_Integer aShapeNumber, const TopAbs_ShapeEnum TargetToFind, const TopAbs_ShapeEnum TargetToAvoid) { Standard_Integer i,j,k,theNumberOfTheShapeOnTop,aSuccessorNumber; Standard_Integer* anArrayOfBits; Standard_Boolean shapeAlreadyProcessed; TopAbs_ShapeEnum theTypeOfShapeOnTop,successorType; myTargetToFind = TargetToFind; myTargetToAvoid = TargetToAvoid; // Modified by skv - Thu Apr 7 11:19:39 2005 Begin hasMore = Standard_False; // Modified by skv - Thu Apr 7 11:19:41 2005 End // We first test if myShapesDataStructure has changed. Standard_Integer MultipleOf32= (((*myShapesDataStructure).myLength+31) & (~31)); Standard_Integer NewSize = MultipleOf32/32; if (myArrayOfBits!=0L) free(myArrayOfBits); myArrayOfBits = (Standard_Integer*)calloc(mySizeOfArrayOfBits,sizeof(Standard_Integer)); mySizeOfArrayOfBits = NewSize; 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; } // Modified by skv - Thu Apr 7 11:19:39 2005 Begin if (theTypeOfShapeOnTop == TopAbs_VERTEX) { hasMore = Standard_False; return; } // Modified by skv - Thu Apr 7 11:19:41 2005 End 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 new 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