0025571: Avoid base Classes without virtual Destructors
[occt.git] / src / HatchGen / HatchGen_PointOnElement.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
42cf5bc1 17
18#include <HatchGen_PointOnElement.hxx>
19#include <IntRes2d_IntersectionPoint.hxx>
7fd59977 20#include <Standard_Stream.hxx>
7fd59977 21
22//=======================================================================
23// Function : HatchGen_PointOnElement
24// Purpose : Constructor.
25//=======================================================================
7fd59977 26HatchGen_PointOnElement::HatchGen_PointOnElement () :
27 HatchGen_IntersectionPoint () ,
28 myType (HatchGen_UNDETERMINED)
29{
30}
31
32//=======================================================================
33// Function : HatchGen_PointOnElement
34// Purpose : Constructor.
35//=======================================================================
36
37HatchGen_PointOnElement::HatchGen_PointOnElement (const HatchGen_PointOnElement& Point)
38{
39 myIndex = Point.myIndex ;
40 myParam = Point.myParam ;
41 myPosit = Point.myPosit ;
42 myBefore = Point.myBefore ;
43 myAfter = Point.myAfter ;
44 mySegBeg = Point.mySegBeg ;
45 mySegEnd = Point.mySegEnd ;
46 myType = Point.myType ;
47}
48
49//=======================================================================
50// Function : HatchGen_PointOnElement
51// Purpose : Constructor.
52//=======================================================================
53
54HatchGen_PointOnElement::HatchGen_PointOnElement (const IntRes2d_IntersectionPoint& Point)
55{
56 const IntRes2d_Transition& TrsH = Point.TransitionOfFirst() ;
57 const IntRes2d_Transition& TrsE = Point.TransitionOfSecond() ;
58
59 myIndex = 0 ;
60
61 myParam = Point.ParamOnSecond() ;
62
63 switch (TrsE.PositionOnCurve()) {
64 case IntRes2d_Head : myPosit = TopAbs_FORWARD ; break ;
65 case IntRes2d_Middle : myPosit = TopAbs_INTERNAL ; break ;
66 case IntRes2d_End : myPosit = TopAbs_REVERSED ; break ;
67 }
68
69 switch (TrsH.TransitionType()) {
70 case IntRes2d_In : {
71 myBefore = TopAbs_OUT ;
72 myAfter = TopAbs_IN ;
73 myType = (myPosit == TopAbs_INTERNAL) ? HatchGen_TRUE : HatchGen_TOUCH ;
74 break ;
75 }
76 case IntRes2d_Out : {
77 myBefore = TopAbs_IN ;
78 myAfter = TopAbs_OUT ;
79 myType = (myPosit == TopAbs_INTERNAL) ? HatchGen_TRUE : HatchGen_TOUCH ;
80 break ;
81 }
82// Modified by Sergey KHROMOV - Fri Jan 5 12:07:34 2001 Begin
83 case IntRes2d_Touch : {
84 switch (TrsH.Situation()) {
85 case IntRes2d_Inside : {
86 myType = HatchGen_TANGENT ;
87 switch (myPosit) {
88 case TopAbs_FORWARD : {
89 if (TrsE.IsOpposite()) {
90 myBefore = TopAbs_IN;
91 myAfter = TopAbs_OUT;
92 } else {
93 myBefore = TopAbs_OUT;
94 myAfter = TopAbs_IN;
95 }
96 break ;
97 }
98 case TopAbs_INTERNAL : {
99 myBefore = TopAbs_IN ;
100 myAfter = TopAbs_IN ;
101 break ;
102 }
103 case TopAbs_REVERSED : {
104 if (TrsE.IsOpposite()) {
105 myBefore = TopAbs_OUT;
106 myAfter = TopAbs_IN;
107 } else {
108 myBefore = TopAbs_IN;
109 myAfter = TopAbs_OUT;
110 }
111 break ;
112 }
113 case TopAbs_EXTERNAL:
114 break ;
115 }
116 break ;
117 }
118 case IntRes2d_Outside : {
119 myType = HatchGen_TANGENT ;
120 switch (myPosit) {
121 case TopAbs_FORWARD : {
122 if (TrsE.IsOpposite()) {
123 myBefore = TopAbs_OUT;
124 myAfter = TopAbs_IN;
125 } else {
126 myBefore = TopAbs_IN;
127 myAfter = TopAbs_OUT;
128 }
129 break ;
130 }
131 case TopAbs_INTERNAL : {
132 myBefore = TopAbs_OUT ;
133 myAfter = TopAbs_OUT ;
134 break ;
135 }
136 case TopAbs_REVERSED : {
137 if (TrsE.IsOpposite()) {
138 myBefore = TopAbs_IN;
139 myAfter = TopAbs_OUT;
140 } else {
141 myBefore = TopAbs_OUT;
142 myAfter = TopAbs_IN;
143 }
144 break ;
145 }
146 case TopAbs_EXTERNAL:
147 break ;
148 }
149 break ;
150 }
151 case IntRes2d_Unknown : {
152 myBefore = TopAbs_UNKNOWN ;
153 myAfter = TopAbs_UNKNOWN ;
154 myType = HatchGen_TANGENT ;
155 break ;
156 }
157 }
158 break ;
159 }
160// Modified by Sergey KHROMOV - Fri Jan 5 12:07:46 2001 End
161 case IntRes2d_Undecided : {
162 myBefore = TopAbs_UNKNOWN ;
163 myAfter = TopAbs_UNKNOWN ;
164 myType = HatchGen_UNDETERMINED ;
165 break ;
166 }
167 }
168
169 mySegBeg = Standard_False ;
170 mySegEnd = Standard_False ;
171}
172
173
174//=======================================================================
175// Function : IsIdentical
176// Purpose : Tests if the point is identical to an other.
177//=======================================================================
178
179Standard_Boolean HatchGen_PointOnElement::IsIdentical (const HatchGen_PointOnElement& Point,
180 const Standard_Real Confusion) const
181{
182 Standard_Real Delta = Abs (myParam - Point.myParam) ;
183 return ( (Delta <= Confusion)
184 && (myIndex == Point.myIndex)
185 && (myPosit == Point.myPosit)
186 && (myType == Point.myType)
187 && (myBefore == Point.myBefore)
188 && (myAfter == Point.myAfter)
189 && (mySegBeg == Point.mySegBeg)
190 && (mySegEnd == Point.mySegEnd)) ;
191}
192
193//=======================================================================
194// Function : IsDifferent
195// Purpose : Tests if the point is different from an other.
196//=======================================================================
197
198Standard_Boolean HatchGen_PointOnElement::IsDifferent (const HatchGen_PointOnElement& Point,
199 const Standard_Real Confusion) const
200{
201 Standard_Real Delta = Abs (myParam - Point.myParam) ;
202 return ( (Delta > Confusion)
203 || (myIndex != Point.myIndex)
204 || (myPosit != Point.myPosit)
205 || (myType != Point.myType)
206 || (myBefore != Point.myBefore)
207 || (myAfter != Point.myAfter)
208 || (mySegBeg != Point.mySegBeg)
209 || (mySegEnd != Point.mySegEnd)) ;
210}
211
212//=======================================================================
213// Function : Dump
214// Purpose : Dump of the point on element
215//=======================================================================
216
217void HatchGen_PointOnElement::Dump (const Standard_Integer Index) const
218{
219 cout << " --- Point on element " ;
220 if (Index > 0) {
221 cout << "# " << setw(3) << Index << " " ;
222 } else {
223 cout << "------" ;
224 }
225 cout << "---------------" << endl ;
226
227 cout << " Index of the element = " << myIndex << endl ;
228 cout << " Parameter on element = " << myParam << endl ;
229 cout << " Position on element = " ;
230 switch (myPosit) {
231 case TopAbs_FORWARD : cout << "FORWARD (i.e. BEGIN )" ; break ;
232 case TopAbs_INTERNAL : cout << "INTERNAL (i.e. MIDDLE )" ; break ;
233 case TopAbs_REVERSED : cout << "REVERSED (i.e. END )" ; break ;
234 case TopAbs_EXTERNAL : cout << "EXTERNAL (i.e. UNKNOWN)" ; break ;
235 }
236 cout << endl ;
237 cout << " Intersection Type = " ;
238 switch (myType) {
239 case HatchGen_TRUE : cout << "TRUE" ; break ;
240 case HatchGen_TOUCH : cout << "TOUCH" ; break ;
241 case HatchGen_TANGENT : cout << "TANGENT" ; break ;
242 case HatchGen_UNDETERMINED : cout << "UNDETERMINED" ; break ;
243 }
244 cout << endl ;
245 cout << " State Before = " ;
246 switch (myBefore) {
247 case TopAbs_IN : cout << "IN" ; break ;
248 case TopAbs_OUT : cout << "OUT" ; break ;
249 case TopAbs_ON : cout << "ON" ; break ;
250 case TopAbs_UNKNOWN : cout << "UNKNOWN" ; break ;
251 }
252 cout << endl ;
253 cout << " State After = " ;
254 switch (myAfter) {
255 case TopAbs_IN : cout << "IN" ; break ;
256 case TopAbs_OUT : cout << "OUT" ; break ;
257 case TopAbs_ON : cout << "ON" ; break ;
258 case TopAbs_UNKNOWN : cout << "UNKNOWN" ; break ;
259 }
260 cout << endl ;
261 cout << " Beginning of segment = " << (mySegBeg ? "TRUE" : "FALSE") << endl ;
262 cout << " End of segment = " << (mySegEnd ? "TRUE" : "FALSE") << endl ;
263
264 cout << " ------------------------------------------" << endl ;
265}