0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead...
[occt.git] / src / HLRAlgo / HLRAlgo_EdgeStatus.cxx
1 // Created on: 1992-02-18
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 No_Exception
18 #define No_Exception
19 #endif
20
21
22 #include <HLRAlgo_EdgeStatus.hxx>
23 #include <Standard_OutOfRange.hxx>
24
25 //=======================================================================
26 //function : HLRAlgo_EdgeStatus
27 //purpose  : 
28 //=======================================================================
29 HLRAlgo_EdgeStatus::HLRAlgo_EdgeStatus()
30 : myStart     (0.0),
31   myEnd       (0.0),
32   myTolStart  (0.0f),
33   myTolEnd    (0.0f),
34   myAllHidden (false),
35   myAllVisible(false)
36 {
37 }
38
39 //=======================================================================
40 //function : HLRAlgo_EdgeStatus
41 //purpose  : 
42 //=======================================================================
43
44 HLRAlgo_EdgeStatus::HLRAlgo_EdgeStatus (const Standard_Real Start,
45                                         const Standard_ShortReal TolStart,
46                                         const Standard_Real End  ,
47                                         const Standard_ShortReal TolEnd) :
48   myStart     (Start),
49   myEnd       (End),
50   myTolStart  (TolStart),
51   myTolEnd    (TolEnd),
52   myAllHidden (false),
53   myAllVisible(false)
54 {
55   ShowAll();
56 }
57
58 //=======================================================================
59 //function : Initialize
60 //purpose  : 
61 //=======================================================================
62
63 void HLRAlgo_EdgeStatus::Initialize (const Standard_Real Start,
64                                      const Standard_ShortReal TolStart,
65                                      const Standard_Real End  ,
66                                      const Standard_ShortReal TolEnd)
67 {
68   myStart      = Start;
69   myTolStart   = TolStart;
70   myEnd        = End;
71   myTolEnd     = TolEnd;
72   ShowAll();
73 }
74
75 //=======================================================================
76 //function : NbVisiblePart
77 //purpose  : 
78 //=======================================================================
79
80 Standard_Integer HLRAlgo_EdgeStatus::NbVisiblePart () const
81 {
82   if      (AllHidden ()) return 0;
83   else if (AllVisible()) return 1;
84   else                   return myVisibles.NbIntervals();
85 }
86
87 //=======================================================================
88 //function : VisiblePart
89 //purpose  : 
90 //=======================================================================
91
92 void HLRAlgo_EdgeStatus::VisiblePart (const Standard_Integer Index,
93                                       Standard_Real& Start,
94                                       Standard_ShortReal& TolStart,
95                                       Standard_Real& End  ,
96                                       Standard_ShortReal& TolEnd  ) const
97
98   if (AllVisible())            Bounds(Start,TolStart,End,TolEnd);
99   else myVisibles.Value(Index).Bounds(Start,TolStart,End,TolEnd);
100 }
101
102 //=======================================================================
103 //function : Hide
104 //purpose  : 
105 //=======================================================================
106
107 void HLRAlgo_EdgeStatus::Hide (const Standard_Real Start     ,
108                                const Standard_ShortReal TolStart,
109                                const Standard_Real End       ,
110                                const Standard_ShortReal TolEnd  ,
111                                const Standard_Boolean OnFace ,
112                                const Standard_Boolean)
113 {
114   if (!OnFace) {
115     if (AllVisible()) {
116       myVisibles = Intrv_Intervals
117         (Intrv_Interval(myStart,myTolStart,myEnd,myTolEnd));
118       AllVisible(Standard_False);
119     }
120     myVisibles.Subtract(Intrv_Interval(Start,TolStart,End,TolEnd));
121     if (!AllHidden()) AllHidden(myVisibles.NbIntervals() == 0);
122   }
123 }