0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / Geom2dHatch / Geom2dHatch_Hatcher.lxx
1 // Created on: 1995-01-03
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1995-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 #define RAISE_IF_NOSUCHOBJECT 0
18 #define TRACE 0
19
20 #include <StdFail_NotDone.hxx>
21
22 #include <Geom2dAdaptor_Curve.hxx>
23 #include <Geom2dHatch_Intersector.hxx>
24 #include <Geom2dHatch_Hatching.hxx>
25 #include <Geom2dHatch_Element.hxx>
26
27 //=======================================================================
28 // Function : Intersector
29 // Purpose  : Returns the associated intersector.
30 //=======================================================================
31
32 inline const Geom2dHatch_Intersector& Geom2dHatch_Hatcher::Intersector ()
33 {
34   return myIntersector ;
35 }
36
37 //=======================================================================
38 // Function : ChangeIntersector
39 // Purpose  : Returns the associated intersector.
40 //=======================================================================
41
42 inline Geom2dHatch_Intersector& Geom2dHatch_Hatcher::ChangeIntersector ()
43 {
44   return myIntersector ;
45 }
46
47 //=======================================================================
48 // Function : Confusion2d
49 // Purpose  : Returns the 2d confusion tolerance.
50 //=======================================================================
51
52 inline Standard_Real Geom2dHatch_Hatcher::Confusion2d () const
53 {
54   return myConfusion2d ;
55 }
56
57 //=======================================================================
58 // Function : Confusion3d
59 // Purpose  : Returns the 3d confusion tolerance.
60 //=======================================================================
61
62 inline Standard_Real Geom2dHatch_Hatcher::Confusion3d () const
63 {
64   return myConfusion3d ;
65 }
66
67 //=======================================================================
68 // Function : KeepPoints
69 // Purpose  : Returns the flag about the points consideration.
70 //=======================================================================
71
72 inline Standard_Boolean Geom2dHatch_Hatcher::KeepPoints () const
73 {
74   return myKeepPoints ;
75 }
76
77 //=======================================================================
78 // Function : KeepSegments
79 // Purpose  : Returns the flag about the segments consideration.
80 //=======================================================================
81
82 inline Standard_Boolean Geom2dHatch_Hatcher::KeepSegments () const
83 {
84   return myKeepSegments ;
85 }
86
87 //=======================================================================
88 // Function : Clear
89 // Purpose  : Removes all the hatchings and all the elements.
90 //=======================================================================
91
92 inline void Geom2dHatch_Hatcher::Clear ()
93 {
94   if (myNbHatchings != 0) ClrHatchings () ;
95   if (myNbElements  != 0) ClrElements  () ;
96 }
97
98 //=======================================================================
99 // Function : Element
100 // Purpose  : Returns the IndE-th element.
101 //=======================================================================
102
103 inline Geom2dHatch_Element& Geom2dHatch_Hatcher::Element (const Standard_Integer IndE)
104 {
105 #if RAISE_IF_NOSUCHOBJECT
106   Standard_NoSuchObject_Raise_if (!myElements.IsBound (IndE), "") ;
107 #endif
108   Geom2dHatch_Element& Element = myElements.ChangeFind (IndE) ;
109   return Element ;
110 }
111
112 //=======================================================================
113 // Function : ElementCurve
114 // Purpose  : Returns the curve associated to the IndE-th element.
115 //=======================================================================
116
117 inline const Geom2dAdaptor_Curve& Geom2dHatch_Hatcher::ElementCurve (const Standard_Integer IndE) const
118 {
119 #if RAISE_IF_NOSUCHOBJECT
120   Standard_NoSuchObject_Raise_if (!myElements.IsBound (IndE), "") ;
121 #endif
122   const Geom2dHatch_Element& Element = myElements.Find (IndE) ;
123   return Element.Curve() ;
124 }
125
126
127 //=======================================================================
128 // Function : Hatching
129 // Purpose  : Returns the IndH-th hatching.
130 //=======================================================================
131
132 inline Geom2dHatch_Hatching& Geom2dHatch_Hatcher::Hatching (const Standard_Integer IndH)
133 {
134 #if RAISE_IF_NOSUCHOBJECT
135   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
136 #endif
137   Geom2dHatch_Hatching& Hatching = myHatchings.ChangeFind (IndH) ;
138   return Hatching ;
139 }
140
141 //=======================================================================
142 // Function : HatchingCurve
143 // Purpose  : Returns the curve associated to the IndH-th hatching.
144 //=======================================================================
145
146 inline const Geom2dAdaptor_Curve& Geom2dHatch_Hatcher::HatchingCurve (const Standard_Integer IndH) const
147 {
148 #if RAISE_IF_NOSUCHOBJECT
149   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
150 #endif
151   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
152   return Hatching.Curve() ;
153 }
154
155 //=======================================================================
156 // Function : NbPoints
157 // Purpose  : Returns the number of intersection points of the IndH-th
158 //            hatching.
159 //=======================================================================
160
161 inline Standard_Integer Geom2dHatch_Hatcher::NbPoints (const Standard_Integer IndH) const
162 {
163 #if RAISE_IF_NOSUCHOBJECT
164   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
165 #endif
166   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
167   return Hatching.NbPoints() ;
168 }
169
170 //=======================================================================
171 // Function : Point
172 // Purpose  : Returns the IndP-th intersection point of the IndH-th
173 //            hatching.
174 //=======================================================================
175
176 inline const HatchGen_PointOnHatching& Geom2dHatch_Hatcher::Point (const Standard_Integer IndH,
177                                                          const Standard_Integer IndP) const
178 {
179 #if RAISE_IF_NOSUCHOBJECT
180   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
181 #endif
182   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
183 #if RAISE_IF_NOSUCHOBJECT
184   Standard_OutOfRange_Raise_if (IndP < 0 || IndP > Hatching.NbPoints(), "") ;
185 #endif
186   const HatchGen_PointOnHatching& PntH = Hatching.Point (IndP) ;
187   return PntH ;
188 }
189
190 //=======================================================================
191 // Function : TrimDone
192 // Purpose  : Returns the fact that all the intersections were computed
193 //            for the IndH-th hatching. 
194 //=======================================================================
195
196 inline Standard_Boolean Geom2dHatch_Hatcher::TrimDone (const Standard_Integer IndH) const
197 {
198 #if RAISE_IF_NOSUCHOBJECT
199   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
200 #endif
201   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
202   return Hatching.TrimDone() ;
203 }
204 //=======================================================================
205 // Function : TrimFailed
206 // Purpose  : Returns the fact that all the intersections failed
207 //            for the IndH-th hatching. 
208 //=======================================================================
209
210 inline Standard_Boolean Geom2dHatch_Hatcher::TrimFailed (const Standard_Integer IndH) const
211 {
212 #if RAISE_IF_NOSUCHOBJECT
213   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
214 #endif
215   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
216   return Hatching.TrimFailed() ;
217 }
218
219 //=======================================================================
220 // Function : IsDone
221 // Purpose  : Returns the fact that all the domains were computed
222 //            for the IndH-th hatching. 
223 //=======================================================================
224
225 inline Standard_Boolean Geom2dHatch_Hatcher::IsDone (const Standard_Integer IndH) const
226 {
227 #if RAISE_IF_NOSUCHOBJECT
228   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
229 #endif
230   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
231   return Hatching.IsDone() ;
232 }
233 //=======================================================================
234 // Function : Status
235 // Purpose  : Returns the status about the IndH-th hatching. 
236 //=======================================================================
237
238 inline HatchGen_ErrorStatus Geom2dHatch_Hatcher::Status (const Standard_Integer IndH) const
239 {
240 #if RAISE_IF_NOSUCHOBJECT
241   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
242 #endif
243   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
244   return Hatching.Status() ;
245 }
246 //=======================================================================
247 // Function : NbDomains
248 // Purpose  : Returns the number of domains of the IndH-th hatching.
249 //=======================================================================
250
251 inline Standard_Integer Geom2dHatch_Hatcher::NbDomains (const Standard_Integer IndH) const
252 {
253 #if RAISE_IF_NOSUCHOBJECT
254   Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
255 #endif
256   const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
257   StdFail_NotDone_Raise_if (!Hatching.IsDone(), "Geom2dHatch_Hatcher::NbDomains") ;
258   return Hatching.NbDomains() ;
259 }
260
261
262