1 // Created on: 2009-01-29
2 // Created by: Pavel TELKOV
3 // Copyright (c) 2009-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
8 // under the terms of the GNU Lesser General Public 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.
17 * Purpose: This class represent pair of integer indices
18 * It is restricted to store more than two indices in it
19 * This pair uses to store element indices connected to link
22 #ifndef BRepMesh_PairOfIndex_HeaderFile
23 #define BRepMesh_PairOfIndex_HeaderFile
25 #include <Standard_OutOfRange.hxx>
27 class BRepMesh_PairOfIndex
30 BRepMesh_PairOfIndex()
31 { myIndx1 = myIndx2 = -1; }
33 BRepMesh_PairOfIndex(const BRepMesh_PairOfIndex& theOther)
35 myIndx1 = theOther.myIndx1;
36 myIndx2 = theOther.myIndx2;
42 myIndx1 = myIndx2 = -1;
45 //! append index (store first of last index of pair)
46 void Append(const Standard_Integer theIndx)
53 Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
58 //! prepend index (store first index)
59 void Prepend(const Standard_Integer theIndx)
62 Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Append, more than two index to store");
67 //! returns is pair not initialized by index
68 Standard_Boolean IsEmpty() const
70 return (myIndx1 < 0 /*optimisation && myIndx2 < 0*/);
73 //! returns numner of initialized indeces
74 Standard_Integer Extent() const
76 return (myIndx1 < 0 ? 0 : (myIndx2 < 0 ? 1 : 2));
79 //! returns first index from pair
80 Standard_Integer FirstIndex() const
85 //! returns last index
86 Standard_Integer LastIndex() const
88 return (myIndx2 < 0 ? myIndx1 : myIndx2);
91 Standard_Integer Index(const Standard_Integer theNum) const
93 return (theNum == 1 ? myIndx1 : myIndx2 /*(theNum == 2 ? myIndx2 : -1 )*/);
96 void SetIndex(const Standard_Integer theNum,
97 const Standard_Integer theIndex)
99 theNum == 1 ? myIndx1 = theIndex : myIndx2 = theIndex;
103 void RemoveIndex (const Standard_Integer theNum)
111 Standard_Integer myIndx1;
112 Standard_Integer myIndx2;