42cf5bc1 |
1 | // Created on: 1992-04-06 |
2 | // Created by: Christophe MARION |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _HLRAlgo_EdgesBlock_HeaderFile |
18 | #define _HLRAlgo_EdgesBlock_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TColStd_Array1OfInteger.hxx> |
24 | #include <TColStd_Array1OfBoolean.hxx> |
25 | #include <Standard_Integer.hxx> |
25e59720 |
26 | #include <Standard_Transient.hxx> |
42cf5bc1 |
27 | #include <TopAbs_Orientation.hxx> |
28 | #include <Standard_Boolean.hxx> |
42cf5bc1 |
29 | |
30 | |
31 | class HLRAlgo_EdgesBlock; |
25e59720 |
32 | DEFINE_STANDARD_HANDLE(HLRAlgo_EdgesBlock, Standard_Transient) |
42cf5bc1 |
33 | |
34 | //! An EdgesBlock is a set of Edges. It is used by the |
35 | //! DataStructure to structure the Edges. |
36 | //! |
37 | //! An EdgesBlock contains : |
38 | //! |
39 | //! * An Array of index of Edges. |
40 | //! |
41 | //! * An Array of flagsf ( Orientation |
42 | //! OutLine |
43 | //! Internal |
44 | //! Double |
45 | //! IsoLine) |
25e59720 |
46 | class HLRAlgo_EdgesBlock : public Standard_Transient |
42cf5bc1 |
47 | { |
48 | |
49 | public: |
681f3919 |
50 | struct MinMaxIndices |
51 | { |
52 | Standard_Integer Min[8], Max[8]; |
53 | |
54 | MinMaxIndices& Minimize(const MinMaxIndices& theMinMaxIndices) |
55 | { |
56 | for (Standard_Integer aI = 0; aI < 8; ++aI) |
57 | { |
58 | if (Min[aI] > theMinMaxIndices.Min[aI]) |
59 | { |
60 | Min[aI] = theMinMaxIndices.Min[aI]; |
61 | } |
62 | if (Max[aI] > theMinMaxIndices.Max[aI]) |
63 | { |
64 | Max[aI] = theMinMaxIndices.Max[aI]; |
65 | } |
66 | } |
67 | return *this; |
68 | } |
69 | |
70 | MinMaxIndices& Maximize(const MinMaxIndices& theMinMaxIndices) |
71 | { |
72 | for (Standard_Integer aI = 0; aI < 8; ++aI) |
73 | { |
74 | if (Min[aI] < theMinMaxIndices.Min[aI]) |
75 | { |
76 | Min[aI] = theMinMaxIndices.Min[aI]; |
77 | } |
78 | if (Max[aI] < theMinMaxIndices.Max[aI]) |
79 | { |
80 | Max[aI] = theMinMaxIndices.Max[aI]; |
81 | } |
82 | } |
83 | return *this; |
84 | } |
85 | }; |
42cf5bc1 |
86 | |
42cf5bc1 |
87 | //! Create a Block of Edges for a wire. |
88 | Standard_EXPORT HLRAlgo_EdgesBlock(const Standard_Integer NbEdges); |
42cf5bc1 |
89 | |
dde68833 |
90 | Standard_Integer NbEdges() const { return myEdges.Upper(); } |
42cf5bc1 |
91 | |
dde68833 |
92 | void Edge (const Standard_Integer I, const Standard_Integer EI) { myEdges(I) = EI; } |
42cf5bc1 |
93 | |
dde68833 |
94 | Standard_Integer Edge (const Standard_Integer I) const { return myEdges(I); } |
42cf5bc1 |
95 | |
dde68833 |
96 | void Orientation (const Standard_Integer I, const TopAbs_Orientation Or) |
97 | { |
98 | myFlags(I) &= ~EMaskOrient; |
99 | myFlags(I) |= (Or & EMaskOrient); |
100 | } |
42cf5bc1 |
101 | |
dde68833 |
102 | TopAbs_Orientation Orientation (const Standard_Integer I) const |
103 | { |
104 | return ((TopAbs_Orientation)(myFlags(I) & EMaskOrient)); |
105 | } |
42cf5bc1 |
106 | |
dde68833 |
107 | Standard_Boolean OutLine (const Standard_Integer I) const { return (myFlags(I) & EMaskOutLine) != 0; } |
42cf5bc1 |
108 | |
dde68833 |
109 | void OutLine (const Standard_Integer I, const Standard_Boolean B) |
110 | { |
111 | if (B) myFlags(I) |= EMaskOutLine; |
112 | else myFlags(I) &= ~EMaskOutLine; |
113 | } |
42cf5bc1 |
114 | |
dde68833 |
115 | Standard_Boolean Internal (const Standard_Integer I) const { return (myFlags(I) & EMaskInternal) != 0; } |
42cf5bc1 |
116 | |
dde68833 |
117 | void Internal (const Standard_Integer I, const Standard_Boolean B) |
118 | { |
119 | if (B) myFlags(I) |= EMaskInternal; |
120 | else myFlags(I) &= ~EMaskInternal; |
121 | } |
42cf5bc1 |
122 | |
dde68833 |
123 | Standard_Boolean Double (const Standard_Integer I) const { return (myFlags(I) & EMaskDouble) != 0; } |
42cf5bc1 |
124 | |
dde68833 |
125 | void Double (const Standard_Integer I, const Standard_Boolean B) |
126 | { |
127 | if (B) myFlags(I) |= EMaskDouble; |
128 | else myFlags(I) &= ~EMaskDouble; |
129 | } |
42cf5bc1 |
130 | |
dde68833 |
131 | Standard_Boolean IsoLine (const Standard_Integer I) const { return (myFlags(I) & EMaskIsoLine) != 0; } |
42cf5bc1 |
132 | |
dde68833 |
133 | void IsoLine (const Standard_Integer I, const Standard_Boolean B) |
134 | { |
135 | if (B) myFlags(I) |= EMaskIsoLine; |
136 | else myFlags(I) &= ~EMaskIsoLine; |
137 | } |
138 | |
681f3919 |
139 | void UpdateMinMax(const MinMaxIndices& TotMinMax) |
140 | { |
141 | myMinMax = TotMinMax; |
142 | } |
dde68833 |
143 | |
681f3919 |
144 | MinMaxIndices& MinMax() |
145 | { |
146 | return myMinMax; |
147 | } |
42cf5bc1 |
148 | |
25e59720 |
149 | DEFINE_STANDARD_RTTIEXT(HLRAlgo_EdgesBlock,Standard_Transient) |
42cf5bc1 |
150 | |
dde68833 |
151 | protected: |
42cf5bc1 |
152 | |
dde68833 |
153 | enum EMskFlags |
154 | { |
155 | EMaskOrient = 15, |
156 | EMaskOutLine = 16, |
157 | EMaskInternal = 32, |
158 | EMaskDouble = 64, |
159 | EMaskIsoLine = 128 |
160 | }; |
42cf5bc1 |
161 | |
dde68833 |
162 | private: |
42cf5bc1 |
163 | |
dde68833 |
164 | TColStd_Array1OfInteger myEdges; |
165 | TColStd_Array1OfInteger myFlags; |
681f3919 |
166 | MinMaxIndices myMinMax; |
dde68833 |
167 | }; |
42cf5bc1 |
168 | |
169 | #endif // _HLRAlgo_EdgesBlock_HeaderFile |