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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #define RAISE_IF_NOSUCHOBJECT 0
20 #include <StdFail_NotDone.hxx>
22 #include <Geom2dAdaptor_Curve.hxx>
23 #include <Geom2dHatch_Intersector.hxx>
24 #include <Geom2dHatch_Hatching.hxx>
25 #include <Geom2dHatch_Element.hxx>
27 //=======================================================================
28 // Function : Intersector
29 // Purpose : Returns the associated intersector.
30 //=======================================================================
32 inline const Geom2dHatch_Intersector& Geom2dHatch_Hatcher::Intersector ()
34 return myIntersector ;
37 //=======================================================================
38 // Function : ChangeIntersector
39 // Purpose : Returns the associated intersector.
40 //=======================================================================
42 inline Geom2dHatch_Intersector& Geom2dHatch_Hatcher::ChangeIntersector ()
44 return myIntersector ;
47 //=======================================================================
48 // Function : Confusion2d
49 // Purpose : Returns the 2d confusion tolerance.
50 //=======================================================================
52 inline Standard_Real Geom2dHatch_Hatcher::Confusion2d () const
54 return myConfusion2d ;
57 //=======================================================================
58 // Function : Confusion3d
59 // Purpose : Returns the 3d confusion tolerance.
60 //=======================================================================
62 inline Standard_Real Geom2dHatch_Hatcher::Confusion3d () const
64 return myConfusion3d ;
67 //=======================================================================
68 // Function : KeepPoints
69 // Purpose : Returns the flag about the points consideration.
70 //=======================================================================
72 inline Standard_Boolean Geom2dHatch_Hatcher::KeepPoints () const
77 //=======================================================================
78 // Function : KeepSegments
79 // Purpose : Returns the flag about the segments consideration.
80 //=======================================================================
82 inline Standard_Boolean Geom2dHatch_Hatcher::KeepSegments () const
84 return myKeepSegments ;
87 //=======================================================================
89 // Purpose : Removes all the hatchings and all the elements.
90 //=======================================================================
92 inline void Geom2dHatch_Hatcher::Clear ()
94 if (myNbHatchings != 0) ClrHatchings () ;
95 if (myNbElements != 0) ClrElements () ;
98 //=======================================================================
100 // Purpose : Returns the IndE-th element.
101 //=======================================================================
103 inline Geom2dHatch_Element& Geom2dHatch_Hatcher::Element (const Standard_Integer IndE)
105 #if RAISE_IF_NOSUCHOBJECT
106 Standard_NoSuchObject_Raise_if (!myElements.IsBound (IndE), "") ;
108 Geom2dHatch_Element& Element = myElements.ChangeFind (IndE) ;
112 //=======================================================================
113 // Function : ElementCurve
114 // Purpose : Returns the curve associated to the IndE-th element.
115 //=======================================================================
117 inline const Geom2dAdaptor_Curve& Geom2dHatch_Hatcher::ElementCurve (const Standard_Integer IndE) const
119 #if RAISE_IF_NOSUCHOBJECT
120 Standard_NoSuchObject_Raise_if (!myElements.IsBound (IndE), "") ;
122 const Geom2dHatch_Element& Element = myElements.Find (IndE) ;
123 return Element.Curve() ;
127 //=======================================================================
128 // Function : Hatching
129 // Purpose : Returns the IndH-th hatching.
130 //=======================================================================
132 inline Geom2dHatch_Hatching& Geom2dHatch_Hatcher::Hatching (const Standard_Integer IndH)
134 #if RAISE_IF_NOSUCHOBJECT
135 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
137 Geom2dHatch_Hatching& Hatching = myHatchings.ChangeFind (IndH) ;
141 //=======================================================================
142 // Function : HatchingCurve
143 // Purpose : Returns the curve associated to the IndH-th hatching.
144 //=======================================================================
146 inline const Geom2dAdaptor_Curve& Geom2dHatch_Hatcher::HatchingCurve (const Standard_Integer IndH) const
148 #if RAISE_IF_NOSUCHOBJECT
149 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
151 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
152 return Hatching.Curve() ;
155 //=======================================================================
156 // Function : NbPoints
157 // Purpose : Returns the number of intersection points of the IndH-th
159 //=======================================================================
161 inline Standard_Integer Geom2dHatch_Hatcher::NbPoints (const Standard_Integer IndH) const
163 #if RAISE_IF_NOSUCHOBJECT
164 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
166 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
167 return Hatching.NbPoints() ;
170 //=======================================================================
172 // Purpose : Returns the IndP-th intersection point of the IndH-th
174 //=======================================================================
176 inline const HatchGen_PointOnHatching& Geom2dHatch_Hatcher::Point (const Standard_Integer IndH,
177 const Standard_Integer IndP) const
179 #if RAISE_IF_NOSUCHOBJECT
180 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
182 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
183 #if RAISE_IF_NOSUCHOBJECT
184 Standard_OutOfRange_Raise_if (IndP < 0 || IndP > Hatching.NbPoints(), "") ;
186 const HatchGen_PointOnHatching& PntH = Hatching.Point (IndP) ;
190 //=======================================================================
191 // Function : TrimDone
192 // Purpose : Returns the fact that all the intersections were computed
193 // for the IndH-th hatching.
194 //=======================================================================
196 inline Standard_Boolean Geom2dHatch_Hatcher::TrimDone (const Standard_Integer IndH) const
198 #if RAISE_IF_NOSUCHOBJECT
199 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
201 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
202 return Hatching.TrimDone() ;
204 //=======================================================================
205 // Function : TrimFailed
206 // Purpose : Returns the fact that all the intersections failed
207 // for the IndH-th hatching.
208 //=======================================================================
210 inline Standard_Boolean Geom2dHatch_Hatcher::TrimFailed (const Standard_Integer IndH) const
212 #if RAISE_IF_NOSUCHOBJECT
213 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
215 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
216 return Hatching.TrimFailed() ;
219 //=======================================================================
221 // Purpose : Returns the fact that all the domains were computed
222 // for the IndH-th hatching.
223 //=======================================================================
225 inline Standard_Boolean Geom2dHatch_Hatcher::IsDone (const Standard_Integer IndH) const
227 #if RAISE_IF_NOSUCHOBJECT
228 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
230 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
231 return Hatching.IsDone() ;
233 //=======================================================================
235 // Purpose : Returns the status about the IndH-th hatching.
236 //=======================================================================
238 inline HatchGen_ErrorStatus Geom2dHatch_Hatcher::Status (const Standard_Integer IndH) const
240 #if RAISE_IF_NOSUCHOBJECT
241 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
243 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
244 return Hatching.Status() ;
246 //=======================================================================
247 // Function : NbDomains
248 // Purpose : Returns the number of domains of the IndH-th hatching.
249 //=======================================================================
251 inline Standard_Integer Geom2dHatch_Hatcher::NbDomains (const Standard_Integer IndH) const
253 #if RAISE_IF_NOSUCHOBJECT
254 Standard_NoSuchObject_Raise_if (!myHatchings.IsBound (IndH), "") ;
256 const Geom2dHatch_Hatching& Hatching = myHatchings.Find (IndH) ;
257 StdFail_NotDone_Raise_if (!Hatching.IsDone(), "Geom2dHatch_Hatcher::NbDomains") ;
258 return Hatching.NbDomains() ;