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