0024662: Removing unused "generic" classes. Part 3
[occt.git] / src / HatchGen / HatchGen_PointOnHatching.cxx
CommitLineData
b311480e 1// Created on: 1993-10-29
2// Created by: Jean Marc LACHAUME
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <Standard_Stream.hxx>
18#include <HatchGen_PointOnHatching.ixx>
19
20#define RAISE_IF_NOSUCHOBJECT 0
21
22//=======================================================================
23// Function : HatchGen_PointOnHatching
24// Purpose : Constructor.
25//=======================================================================
26
27HatchGen_PointOnHatching::HatchGen_PointOnHatching () :
28 HatchGen_IntersectionPoint () ,
29 myPoints ()
30{
31}
32
33//=======================================================================
34// Function : HatchGen_PointOnHatching
35// Purpose : Constructor.
36//=======================================================================
37
38HatchGen_PointOnHatching::HatchGen_PointOnHatching (const HatchGen_PointOnHatching& Point)
39{
40 myIndex = Point.myIndex ;
41 myParam = Point.myParam ;
42 myPosit = Point.myPosit ;
43 myBefore = Point.myBefore ;
44 myAfter = Point.myAfter ;
45 mySegBeg = Point.mySegBeg ;
46 mySegEnd = Point.mySegEnd ;
47 myPoints = Point.myPoints ;
48}
49
50//=======================================================================
51// Function : HatchGen_PointOnHatching
52// Purpose : Constructor.
53//=======================================================================
54
55HatchGen_PointOnHatching::HatchGen_PointOnHatching (const IntRes2d_IntersectionPoint& Point)
56{
57 myIndex = 0 ;
58 myParam = Point.ParamOnFirst() ;
59 switch (Point.TransitionOfFirst().PositionOnCurve()) {
60 case IntRes2d_Head : myPosit = TopAbs_FORWARD ; break ;
61 case IntRes2d_Middle : myPosit = TopAbs_INTERNAL ; break ;
62 case IntRes2d_End : myPosit = TopAbs_REVERSED ; break ;
63 }
64 myBefore = TopAbs_UNKNOWN ;
65 myAfter = TopAbs_UNKNOWN ;
66 mySegBeg = Standard_False ;
67 mySegEnd = Standard_False ;
68 myPoints.Clear() ;
69}
70
71void HatchGen_PointOnHatching::Delete()
72{}
73
74//=======================================================================
75// Function : AddPoint
76// Purpose : Adds a point on element to the point.
77//=======================================================================
78
79void HatchGen_PointOnHatching::AddPoint (const HatchGen_PointOnElement& Point,
80 const Standard_Real Confusion)
81{
82 Standard_Integer NbPnt = myPoints.Length() ;
83 // for (Standard_Integer IPnt = 1 ;
84 Standard_Integer IPnt;
85 for ( IPnt = 1 ;
86 IPnt <= NbPnt && myPoints(IPnt).IsDifferent (Point, Confusion) ;
87 IPnt++) ;
88 if (IPnt > NbPnt) myPoints.Append (Point) ;
89}
90
91
92//=======================================================================
93// Function : NbPoints
94// Purpose : Returns the number of elements intersecting the hatching at
95// this point.
96//=======================================================================
97
98Standard_Integer HatchGen_PointOnHatching::NbPoints () const
99{
100 return myPoints.Length() ;
101}
102
103//=======================================================================
104// Function : Point
105// Purpose : Returns the Index-th point on element of the point.
106//=======================================================================
107
108const HatchGen_PointOnElement& HatchGen_PointOnHatching::Point (const Standard_Integer Index) const
109{
110#if RAISE_IF_NOSUCHOBJECT
111 Standard_Integer NbPnt = myPoints.Length() ;
112 Standard_OutOfRange_Raise_if (Index < 1 || Index > NbPnt, "") ;
113#endif
114 const HatchGen_PointOnElement& Point = myPoints.Value (Index) ;
115 return Point ;
116}
117
118//=======================================================================
119// Function : RemPoint
120// Purpose : Removes the Index-th point on element of the point..
121//=======================================================================
122
123void HatchGen_PointOnHatching::RemPoint (const Standard_Integer Index)
124{
125#if RAISE_IF_NOSUCHOBJECT
126 Standard_Integer NbPnt = myPoints.Length() ;
127 Standard_OutOfRange_Raise_if (Index < 1 || Index > NbPnt, "") ;
128#endif
129 myPoints.Remove (Index) ;
130}
131
132//=======================================================================
133// Function : ClrPoints
134// Purpose : Removes all the points on element of the point.
135//=======================================================================
136
137void HatchGen_PointOnHatching::ClrPoints ()
138{
139 myPoints.Clear() ;
140}
141
142//=======================================================================
143// Function : IsLower
144// Purpose : Tests if the point is lower than an other.
145//=======================================================================
146
147Standard_Boolean HatchGen_PointOnHatching::IsLower (const HatchGen_PointOnHatching& Point,
148 const Standard_Real Confusion) const
149{
150 return (Point.myParam - myParam > Confusion) ;
151}
152
153//=======================================================================
154// Function : IsEqual
155// Purpose : Tests if the point is equal to an other.
156//=======================================================================
157
158Standard_Boolean HatchGen_PointOnHatching::IsEqual (const HatchGen_PointOnHatching& Point,
159 const Standard_Real Confusion) const
160{
161 return (Abs (Point.myParam - myParam) <= Confusion) ;
162}
163
164//=======================================================================
165// Function : IsGreater
166// Purpose : Tests if the point is greater than an other.
167//=======================================================================
168
169Standard_Boolean HatchGen_PointOnHatching::IsGreater (const HatchGen_PointOnHatching& Point,
170 const Standard_Real Confusion) const
171{
172 return (myParam - Point.myParam > Confusion) ;
173}
174
175//=======================================================================
176// Function : Dump
177// Purpose : Dump of the point.
178//=======================================================================
179
180void HatchGen_PointOnHatching::Dump (const Standard_Integer Index) const
181{
182 cout << "--- Point on hatching " ;
183 if (Index > 0) {
184 cout << "# " << setw(3) << Index << " " ;
185 } else {
186 cout << "------" ;
187 }
188 cout << "------------------" << endl ;
189
190 cout << " Index of the hatching = " << myIndex << endl ;
191 cout << " Parameter on hatching = " << myParam << endl ;
192 cout << " Position on hatching = " ;
193 switch (myPosit) {
194 case TopAbs_FORWARD : cout << "FORWARD (i.e. BEGIN )" ; break ;
195 case TopAbs_INTERNAL : cout << "INTERNAL (i.e. MIDDLE )" ; break ;
196 case TopAbs_REVERSED : cout << "REVERSED (i.e. END )" ; break ;
197 case TopAbs_EXTERNAL : cout << "EXTERNAL (i.e. UNKNOWN)" ; break ;
198 }
199 cout << endl ;
200 cout << " State Before = " ;
201 switch (myBefore) {
202 case TopAbs_IN : cout << "IN" ; break ;
203 case TopAbs_OUT : cout << "OUT" ; break ;
204 case TopAbs_ON : cout << "ON" ; break ;
205 case TopAbs_UNKNOWN : cout << "UNKNOWN" ; break ;
206 }
207 cout << endl ;
208 cout << " State After = " ;
209 switch (myAfter) {
210 case TopAbs_IN : cout << "IN" ; break ;
211 case TopAbs_OUT : cout << "OUT" ; break ;
212 case TopAbs_ON : cout << "ON" ; break ;
213 case TopAbs_UNKNOWN : cout << "UNKNOWN" ; break ;
214 }
215 cout << endl ;
216 cout << " Beginning of segment = " << (mySegBeg ? "TRUE" : "FALSE") << endl ;
217 cout << " End of segment = " << (mySegEnd ? "TRUE" : "FALSE") << endl ;
218
219 Standard_Integer NbPnt = myPoints.Length () ;
220 if (NbPnt == 0) {
221 cout << " No points on element" << endl ;
222 } else {
223 cout << " Contains " << NbPnt << " points on element" << endl ;
224 for (Standard_Integer IPnt = 1 ; IPnt <= NbPnt ; IPnt++) {
225 const HatchGen_PointOnElement& Point = myPoints.Value (IPnt) ;
226 Point.Dump (IPnt) ;
227 }
228 }
229
230 cout << "----------------------------------------------" << endl ;
231}