Warnings on vc14 were eliminated
[occt.git] / src / Poly / Poly_CoherentTriPtr.cxx
1 // Created on: 2007-12-08
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <Poly_CoherentTriPtr.hxx>
17
18 //=======================================================================
19 //function : Iterator::Next
20 //purpose  :
21 //=======================================================================
22
23 void Poly_CoherentTriPtr::Iterator::Next ()
24 {
25   if (myCurrent)
26   {
27     myCurrent = myCurrent->myNext;
28     if (myCurrent == myFirst)
29       myCurrent = 0L;
30   }
31 }
32
33 //=======================================================================
34 //function : Append
35 //purpose  : 
36 //=======================================================================
37
38 void Poly_CoherentTriPtr::Append
39                         (const Poly_CoherentTriangle *           pTri,
40                          const Handle(NCollection_BaseAllocator)& theAlloc)
41 {
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;
49   myNext = aNewPtr;
50 }
51
52 //=======================================================================
53 //function : Prepend
54 //purpose  : 
55 //=======================================================================
56
57 void Poly_CoherentTriPtr::Prepend
58                         (const Poly_CoherentTriangle *           pTri,
59                          const Handle(NCollection_BaseAllocator)& theAlloc)
60 {
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;
68   myPrevious = aNewPtr;
69 }
70
71 //=======================================================================
72 //function : Remove
73 //purpose  : 
74 //=======================================================================
75
76 void Poly_CoherentTriPtr::Remove
77                         (Poly_CoherentTriPtr *                   thePtr,
78                          const Handle(NCollection_BaseAllocator)& theAlloc)
79 {
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;
88   }
89   anAlloc->Free(thePtr);
90 }
91
92 //=======================================================================
93 //function : RemoveList
94 //purpose  : 
95 //=======================================================================
96
97 void Poly_CoherentTriPtr::RemoveList
98                         (Poly_CoherentTriPtr *                   thePtr,
99                          const Handle(NCollection_BaseAllocator)& theAlloc)
100 {
101   Handle(NCollection_BaseAllocator) anAlloc = theAlloc;
102   if (theAlloc.IsNull())
103     anAlloc = NCollection_BaseAllocator::CommonBaseAllocator();
104   Poly_CoherentTriPtr * aPtr = thePtr;
105   do {
106     if (aPtr == 0L)
107       break;
108     Poly_CoherentTriPtr * aLostPtr = aPtr;
109     aPtr = aPtr->myNext;
110     anAlloc->Free(aLostPtr);
111   } while (aPtr != thePtr);
112 }