1 // Created on: 2011-11-02
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <OpenGl_PriorityList.hxx>
23 #include <OpenGl_Structure.hxx>
25 /*----------------------------------------------------------------------*/
27 void OpenGl_PriorityList::Add (const OpenGl_Structure *AStructure,const Standard_Integer APriority)
29 Standard_Integer anIndex = APriority;
30 if (anIndex < 0) anIndex = 0;
31 else if (anIndex >= myArray.Length()) anIndex = myArray.Length()-1;
32 myArray(anIndex).Append(AStructure);
36 /*----------------------------------------------------------------------*/
38 Standard_Integer OpenGl_PriorityList::Remove (const OpenGl_Structure *AStructure)
40 const Standard_Integer aNbPr = myArray.Length();
41 Standard_Integer i = 0;
42 OpenGl_SequenceOfStructure::Iterator its;
43 for (; i < aNbPr; i++)
45 OpenGl_SequenceOfStructure &aSeq = myArray(i);
46 for (its.Init(aSeq); its.More(); its.Next())
48 if (its.Value() == AStructure)
60 /*----------------------------------------------------------------------*/
62 void OpenGl_PriorityList::Render (const Handle(OpenGl_Workspace) &AWorkspace) const
64 const Standard_Integer aNbPr = myArray.Length();
65 Standard_Integer i = 0;
66 OpenGl_SequenceOfStructure::Iterator its;
67 for (; i < aNbPr; i++)
69 for (its.Init(myArray(i)); its.More(); its.Next())
70 its.Value()->Render(AWorkspace);
74 //=======================================================================
77 //=======================================================================
79 Standard_Boolean OpenGl_PriorityList::Append (const OpenGl_PriorityList& theOther)
81 // the source priority list shouldn't have more priorities
82 const Standard_Integer aNbPriorities = theOther.NbPriorities ();
83 if (aNbPriorities > NbPriorities ())
84 return Standard_False;
86 // add all structures to destination priority list
87 Standard_Integer aIdx = 0;
88 OpenGl_SequenceOfStructure::Iterator anIts;
89 for (; aIdx < aNbPriorities; aIdx++)
91 const OpenGl_SequenceOfStructure& aSeq = theOther.myArray (aIdx);
92 for (anIts.Init (aSeq); anIts.More (); anIts.Next ())
93 Add (anIts.Value (), aIdx);
99 //=======================================================================
100 //function : NbPriorities
102 //=======================================================================
104 Standard_Integer OpenGl_PriorityList::NbPriorities() const
106 return myArray.Length();