0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IntWalk / IntWalk_IWLine.lxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <Standard_DomainError.hxx>
16 #include <IntSurf_LineOn2S.hxx>
17 #include <IntSurf_Couple.hxx>
18 #include <IntSurf_SequenceOfCouple.hxx>
19
20 inline void IntWalk_IWLine::Cut(const Standard_Integer Index)
21 {
22 //--   std::cout<<" split : "<<Index<<std::endl;
23   Handle(IntSurf_LineOn2S) lost = line->Split(Index);
24 }
25
26 inline void IntWalk_IWLine::AddPoint(const IntSurf_PntOn2S& P)
27 {
28   line->Add(P);
29 }
30
31 inline void IntWalk_IWLine::AddStatusFirst(const Standard_Boolean Closed,
32                                            const Standard_Boolean HasFirst)
33 {
34   closed = Closed;
35   hasFirst = HasFirst; 
36 }
37
38 inline void IntWalk_IWLine::AddStatusLast (const Standard_Boolean HasLast)
39 {
40   hasLast = HasLast; 
41 }
42
43 inline void IntWalk_IWLine::AddStatusFirst(const Standard_Boolean Closed,
44                                            const Standard_Boolean HasFirst,
45                                            const Standard_Integer Index,
46                                            const TheStartPoint& P ) {
47   closed = Closed;
48   hasFirst = HasFirst; 
49   firstIndex = Index;
50   theFirstPoint = P;
51 }
52
53 inline void IntWalk_IWLine::AddStatusLast(const Standard_Boolean HasLast,
54                                           const Standard_Integer Index,
55                                           const TheStartPoint& P ) {
56   hasLast = HasLast; 
57   lastIndex = Index;
58   theLastPoint = P;
59 }
60
61 inline void IntWalk_IWLine::AddStatusFirstLast(const Standard_Boolean Closed,
62                                                const Standard_Boolean HasFirst,
63                                                const Standard_Boolean HasLast )
64 {
65   closed = Closed;
66   hasFirst = HasFirst; 
67   hasLast = HasLast;
68 }
69
70 inline void IntWalk_IWLine::AddIndexPassing(const Standard_Integer Index)
71
72 {
73   couple.Append(IntSurf_Couple(line->NbPoints()+1, Index));
74 }
75
76 inline Standard_Integer IntWalk_IWLine::NbPoints() const
77 {
78   return line->NbPoints();
79 }
80   
81 inline const IntSurf_PntOn2S& IntWalk_IWLine::Value
82   (const Standard_Integer Index) const
83 {
84   return line->Value(Index);
85 }
86
87 inline const Handle(IntSurf_LineOn2S)& IntWalk_IWLine::Line () const
88 {
89   return line;
90 }
91
92 inline Standard_Boolean IntWalk_IWLine::IsClosed() const
93 {
94   return closed;
95 }
96
97 inline Standard_Boolean IntWalk_IWLine::HasFirstPoint() const
98 {
99   return hasFirst;
100 }
101
102 inline Standard_Integer IntWalk_IWLine::FirstPointIndex() const
103 {
104   if (!hasFirst) throw Standard_DomainError();
105   return firstIndex;
106 }
107
108 inline const TheStartPoint& IntWalk_IWLine::FirstPoint() const
109 {
110  if (!hasFirst) throw Standard_DomainError();
111  return theFirstPoint;
112 }
113
114 inline Standard_Boolean IntWalk_IWLine::HasLastPoint() const
115 {
116   return hasLast;
117 }
118
119 inline const TheStartPoint& IntWalk_IWLine::LastPoint() const
120 {
121   if (!hasLast) throw Standard_DomainError();
122   return theLastPoint;
123 }
124
125 inline Standard_Integer IntWalk_IWLine::LastPointIndex() const
126 {
127   if (!hasLast) throw Standard_DomainError();
128   return lastIndex;
129 }
130
131 inline Standard_Integer IntWalk_IWLine::NbPassingPoint() const
132
133   return couple.Length();
134 }
135
136 inline void IntWalk_IWLine::PassingPoint(const Standard_Integer Index,
137                                          Standard_Integer& IndexLine,
138                                          Standard_Integer& IndexPnts) const 
139 {
140   IndexLine = couple(Index).First();
141   IndexPnts = couple(Index).Second();
142 }
143
144 inline void IntWalk_IWLine::SetTangentVector (const gp_Vec& V,
145                                               const Standard_Integer Index) {
146   indextg = Index;
147   vcttg = V;
148   
149   //-- std::cout<<"\n IntWalk_IWLine::SetTangentVector : "<<V.X()<<" "<<V.Y()<<" "<<V.Z()<<"   Ind:"<<Index<<"  NbPts:"<<NbPoints()<<std::endl;
150   
151 }
152
153 inline void IntWalk_IWLine::SetTangencyAtBegining
154   (const Standard_Boolean IsTangent) {
155
156   istgtend = IsTangent;
157 }
158
159 inline void IntWalk_IWLine::SetTangencyAtEnd
160   (const Standard_Boolean IsTangent) {
161
162   istgtend = IsTangent;
163 }
164
165 inline const gp_Vec& IntWalk_IWLine::TangentVector
166   (Standard_Integer& Index) const {
167 //--    if(istgtend == Standard_False && istgtbeg == Standard_False) { 
168 //--      std::cout<<" IntWalk_IWLine.lxx : Pb "<<std::endl;
169 //--    }
170   Index = indextg;
171   return vcttg;
172 }
173
174 inline Standard_Boolean IntWalk_IWLine::IsTangentAtBegining () const {
175
176   return istgtbeg;
177 }
178
179 inline Standard_Boolean IntWalk_IWLine::IsTangentAtEnd () const {
180
181   return istgtend;
182 }
183
184