0027232: Configuration - fix mblen missing building issue on Android
[occt.git] / src / BRepMesh / BRepMesh_PairOfIndex.hxx
CommitLineData
b311480e 1// Created on: 2009-01-29
2// Created by: Pavel TELKOV
973c2be1 3// Copyright (c) 2009-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
0d88155b 15
0d88155b
O
16#ifndef BRepMesh_PairOfIndex_HeaderFile
17#define BRepMesh_PairOfIndex_HeaderFile
18
19#include <Standard_OutOfRange.hxx>
20
fc9b36d6 21//! This class represents a pair of integer indices to store
22//! element indices connected to link. It is restricted to
23//! store more than two indices in it.
0d88155b
O
24class BRepMesh_PairOfIndex
25{
26public:
0d88155b 27
fc9b36d6 28 //! Default constructor
29 Standard_EXPORT BRepMesh_PairOfIndex()
0d88155b 30 {
fc9b36d6 31 Clear();
0d88155b
O
32 }
33
fc9b36d6 34 //! Clears indices.
0d88155b
O
35 void Clear()
36 {
fc9b36d6 37 myIndex[0] = myIndex[1] = -1;
0d88155b
O
38 }
39
fc9b36d6 40 //! Appends index to the pair.
41 inline void Append(const Standard_Integer theIndex)
0d88155b 42 {
fc9b36d6 43 if (myIndex[0] < 0)
44 myIndex[0] = theIndex;
0d88155b
O
45 else
46 {
fc9b36d6 47 if (myIndex[1] >= 0)
48 Standard_OutOfRange::Raise("BRepMesh_PairOfIndex::Append, more than two index to store");
49
50 myIndex[1] = theIndex;
0d88155b
O
51 }
52 }
53
fc9b36d6 54 //! Prepends index to the pair.
55 inline void Prepend(const Standard_Integer theIndex)
0d88155b 56 {
fc9b36d6 57 if (myIndex[1] >= 0)
a3ac9c24 58 Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Prepend, more than two index to store");
fc9b36d6 59
60 myIndex[1] = myIndex[0];
a3ac9c24 61 myIndex[0] = theIndex;
0d88155b
O
62 }
63
fc9b36d6 64 //! Returns is pair is empty.
65 inline Standard_Boolean IsEmpty() const
0d88155b 66 {
fc9b36d6 67 // Check only first index. It is impossible to update
68 // second index if the first one is empty.
69 return (myIndex[0] < 0);
0d88155b
O
70 }
71
fc9b36d6 72 //! Returns number of initialized indeces.
73 inline Standard_Integer Extent() const
0d88155b 74 {
fc9b36d6 75 return (myIndex[0] < 0 ? 0 : (myIndex[1] < 0 ? 1 : 2));
0d88155b
O
76 }
77
fc9b36d6 78 //! Returns first index of pair.
79 inline Standard_Integer FirstIndex() const
0d88155b 80 {
fc9b36d6 81 return myIndex[0];
0d88155b
O
82 }
83
fc9b36d6 84 //! Returns last index of pair
85 inline Standard_Integer LastIndex() const
0d88155b 86 {
fc9b36d6 87 return (myIndex[1] < 0 ? myIndex[0] : myIndex[1]);
0d88155b
O
88 }
89
fc9b36d6 90 //! Returns index corresponding to the given position in the pair.
848fa7e3 91 //! @param thePairPos position of index in the pair (1 or 2).
fc9b36d6 92 inline Standard_Integer Index(const Standard_Integer thePairPos) const
0d88155b 93 {
fc9b36d6 94 if (thePairPos != 1 && thePairPos != 2)
95 Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::Index, requested index is out of range");
96
97 return myIndex[thePairPos - 1];
0d88155b
O
98 }
99
fc9b36d6 100 //! Sets index corresponding to the given position in the pair.
848fa7e3 101 //! @param thePairPos position of index in the pair (1 or 2).
102 //! @param theIndex index to be stored.
fc9b36d6 103 inline void SetIndex(const Standard_Integer thePairPos,
104 const Standard_Integer theIndex)
0d88155b 105 {
fc9b36d6 106 if (thePairPos != 1 && thePairPos != 2)
107 Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::SetIndex, requested index is out of range");
108
109 myIndex[thePairPos - 1] = theIndex;
0d88155b
O
110 }
111
fc9b36d6 112 //! Remove index from the given position.
848fa7e3 113 //! @param thePairPos position of index in the pair (1 or 2).
fc9b36d6 114 inline void RemoveIndex(const Standard_Integer thePairPos)
0d88155b 115 {
fc9b36d6 116 if (thePairPos != 1 && thePairPos != 2)
117 Standard_OutOfRange::Raise ("BRepMesh_PairOfIndex::RemoveIndex, requested index is out of range");
118
119 if ( thePairPos == 1 )
120 myIndex[0] = myIndex[1];
121
122 myIndex[1] = -1;
0d88155b 123 }
fc9b36d6 124
0d88155b 125private:
fc9b36d6 126 Standard_Integer myIndex[2];
0d88155b
O
127};
128
129#endif