1 // Created on: 2007-12-08
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <Poly_CoherentTriPtr.hxx>
18 //=======================================================================
19 //function : Iterator::Next
21 //=======================================================================
23 void Poly_CoherentTriPtr::Iterator::Next ()
27 myCurrent = myCurrent->myNext;
28 if (myCurrent == myFirst)
33 //=======================================================================
36 //=======================================================================
38 void Poly_CoherentTriPtr::Append
39 (const Poly_CoherentTriangle * pTri,
40 const Handle(NCollection_BaseAllocator)& theAlloc)
42 Handle(NCollection_BaseAllocator) anAlloc = theAlloc;
43 if (theAlloc.IsNull())
44 anAlloc = NCollection_BaseAllocator::CommonBaseAllocator();
45 Poly_CoherentTriPtr * aNewPtr = new (anAlloc) Poly_CoherentTriPtr(* pTri);
46 aNewPtr->myNext = myNext;
47 myNext->myPrevious = aNewPtr;
48 aNewPtr->myPrevious = this;
52 //=======================================================================
55 //=======================================================================
57 void Poly_CoherentTriPtr::Prepend
58 (const Poly_CoherentTriangle * pTri,
59 const Handle(NCollection_BaseAllocator)& theAlloc)
61 Handle(NCollection_BaseAllocator) anAlloc = theAlloc;
62 if (theAlloc.IsNull())
63 anAlloc = NCollection_BaseAllocator::CommonBaseAllocator();
64 Poly_CoherentTriPtr * aNewPtr = new (anAlloc) Poly_CoherentTriPtr(* pTri);
65 aNewPtr->myPrevious = myPrevious;
66 myPrevious->myNext = aNewPtr;
67 aNewPtr->myNext = this;
71 //=======================================================================
74 //=======================================================================
76 void Poly_CoherentTriPtr::Remove
77 (Poly_CoherentTriPtr * thePtr,
78 const Handle(NCollection_BaseAllocator)& theAlloc)
80 Handle(NCollection_BaseAllocator) anAlloc = theAlloc;
81 if (theAlloc.IsNull())
82 anAlloc = NCollection_BaseAllocator::CommonBaseAllocator();
83 if (thePtr->myNext && thePtr->myPrevious) {
84 thePtr->myPrevious->myNext = thePtr->myNext;
85 thePtr->myNext->myPrevious = thePtr->myPrevious;
86 thePtr->myNext = thePtr;
87 thePtr->myPrevious = thePtr;
89 anAlloc->Free(thePtr);
92 //=======================================================================
93 //function : RemoveList
95 //=======================================================================
97 void Poly_CoherentTriPtr::RemoveList
98 (Poly_CoherentTriPtr * thePtr,
99 const Handle(NCollection_BaseAllocator)& theAlloc)
101 Handle(NCollection_BaseAllocator) anAlloc = theAlloc;
102 if (theAlloc.IsNull())
103 anAlloc = NCollection_BaseAllocator::CommonBaseAllocator();
104 Poly_CoherentTriPtr * aPtr = thePtr;
108 Poly_CoherentTriPtr * aLostPtr = aPtr;
110 anAlloc->Free(aLostPtr);
111 } while (aPtr != thePtr);