0023024: Update headers of OCCT files
[occt.git] / src / BOPTools / BOPTools_PaveBlock.cxx
1 // Created on: 2001-02-15
2 // Created by: Peter KURNEV
3 // Copyright (c) 2001-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21
22 #include <BOPTools_PaveBlock.ixx>
23
24 //=======================================================================
25 // function: BOPTools_PaveBlock::BOPTools_PaveBlock
26 // purpose: 
27 //=======================================================================
28 BOPTools_PaveBlock::BOPTools_PaveBlock()
29   : 
30   myEdge(0), 
31   myOriginalEdge(0),
32   myFace1(0),
33   myFace2(0)
34 {}
35 //=======================================================================
36 // function:  BOPTools_PaveBlock::BOPTools_PaveBlock
37 // purpose: 
38 //=======================================================================
39   BOPTools_PaveBlock::BOPTools_PaveBlock(const Standard_Integer theEdge,
40                                          const BOPTools_Pave& thePave1,
41                                          const BOPTools_Pave& thePave2)
42 {
43   myOriginalEdge=theEdge;
44   myPave1=thePave1;
45   myPave2=thePave2;
46   myFace1=0;
47   myFace2=0;
48 }
49
50 //=======================================================================
51 // function: SetCurve
52 // purpose: 
53 //=======================================================================
54   void BOPTools_PaveBlock::SetCurve(const IntTools_Curve& aC)
55 {
56    myCurve=aC;
57 }
58 //=======================================================================
59 // function: SetFace1
60 // purpose: 
61 //=======================================================================
62   void BOPTools_PaveBlock::SetFace1(const Standard_Integer theFace1)
63 {
64    myFace1=theFace1;
65 }
66 //=======================================================================
67 // function: SetFace2
68 // purpose: 
69 //=======================================================================
70   void BOPTools_PaveBlock::SetFace2(const Standard_Integer theFace2)
71 {
72    myFace2=theFace2;
73 }
74
75 //=======================================================================
76 // function: Face1
77 // purpose: 
78 //=======================================================================
79   Standard_Integer BOPTools_PaveBlock::Face1() const 
80 {
81    return myFace1;
82 }
83 //=======================================================================
84 // function: Face2
85 // purpose: 
86 //=======================================================================
87   Standard_Integer BOPTools_PaveBlock::Face2() const 
88 {
89    return myFace2;
90 }
91 //=======================================================================
92 // function: Curve
93 // purpose: 
94 //=======================================================================
95   const IntTools_Curve& BOPTools_PaveBlock::Curve() const
96 {
97    return myCurve;
98 }
99
100 //=======================================================================
101 // function: SetEdge
102 // purpose: 
103 //=======================================================================
104   void BOPTools_PaveBlock::SetEdge(const Standard_Integer theEdge)
105 {
106    myEdge=theEdge;
107 }
108 //=======================================================================
109 // function: SetOriginalEdge
110 // purpose: 
111 //=======================================================================
112   void BOPTools_PaveBlock::SetOriginalEdge(const Standard_Integer theEdge)
113 {
114    myOriginalEdge=theEdge;
115 }
116
117 //=======================================================================
118 // function: SetPave1
119 // purpose: 
120 //=======================================================================
121   void BOPTools_PaveBlock::SetPave1(const BOPTools_Pave& thePave1)
122 {
123    myPave1=thePave1;
124   
125 }
126 //=======================================================================
127 // function: SetPave2
128 // purpose: 
129 //=======================================================================
130   void BOPTools_PaveBlock::SetPave2(const BOPTools_Pave& thePave2)
131 {
132    myPave2=thePave2;
133 }
134
135 //=======================================================================
136 // function: SetShrunkRange
137 // purpose: 
138 //=======================================================================
139   void BOPTools_PaveBlock::SetShrunkRange(const IntTools_ShrunkRange& theSR)
140 {
141    myShrunkRange=theSR;
142 }
143
144 //=======================================================================
145 // function: SetPointBetween
146 // purpose: 
147 //=======================================================================
148   void BOPTools_PaveBlock::SetPointBetween (const BOPTools_PointBetween& thePB)
149 {
150    myPointBetween=thePB;
151 }
152
153 //=======================================================================
154 // function: PointBetween
155 // purpose: 
156 //=======================================================================
157   const BOPTools_PointBetween& BOPTools_PaveBlock::PointBetween ()const 
158 {
159    return myPointBetween;
160 }
161
162 //=======================================================================
163 // function: Pave1
164 // purpose: 
165 //=======================================================================
166   const BOPTools_Pave& BOPTools_PaveBlock::Pave1() const 
167 {
168   Standard_Real t1, t2;
169
170   t1=myPave1.Param();
171   t2=myPave2.Param();
172
173   if (t1<t2) {
174    return myPave1; 
175   }
176   return myPave2;
177 }
178 //=======================================================================
179 // function: Pave2
180 // purpose: 
181 //=======================================================================
182   const BOPTools_Pave& BOPTools_PaveBlock::Pave2() const 
183 {
184   Standard_Real t1, t2;
185
186   t1=myPave1.Param();
187   t2=myPave2.Param();
188
189   if (t1>t2) {
190    return myPave1; 
191   }
192   return myPave2;
193 }
194
195 //=======================================================================
196 // function: Edge
197 // purpose: 
198 //=======================================================================
199   Standard_Integer BOPTools_PaveBlock::Edge() const
200 {
201   return myEdge;
202 }
203
204 //=======================================================================
205 // function: OriginalEdge
206 // purpose: 
207 //=======================================================================
208   Standard_Integer BOPTools_PaveBlock::OriginalEdge() const
209 {
210   return myOriginalEdge;
211 }
212
213 //=======================================================================
214 // function: IsValid
215 // purpose: 
216 //=======================================================================
217   Standard_Boolean BOPTools_PaveBlock::IsValid() const
218 {
219   Standard_Integer anInd1, anInd2;
220   anInd1=myPave1.Index();
221   anInd2=myPave2.Index();
222
223   return (anInd1 && anInd2);
224 }
225 //=======================================================================
226 // function: IsEqual
227 // purpose: 
228 //=======================================================================
229   Standard_Boolean BOPTools_PaveBlock::IsEqual(const BOPTools_PaveBlock& Other) const
230 {
231   if (myOriginalEdge==Other.myOriginalEdge) {
232
233     const BOPTools_Pave& aP11=Pave1();
234     const BOPTools_Pave& aP12=Pave2();
235     const BOPTools_Pave& aP21=Other.Pave1();
236     const BOPTools_Pave& aP22=Other.Pave2();
237   
238     if (aP11.IsEqual(aP21)) {
239       if (aP12.IsEqual(aP22)) {
240         return Standard_True;
241       }
242     }
243   }
244   return Standard_False;
245 }
246 //=======================================================================
247 // function: Parameters
248 // purpose: 
249 //=======================================================================
250   void  BOPTools_PaveBlock::Parameters(Standard_Real& aT1, 
251                                        Standard_Real& aT2) const 
252 {
253   Standard_Real t1, t2;
254   t1=myPave1.Param();
255   t2=myPave2.Param();
256   aT1= (t1<t2) ? t1 : t2;
257   aT2= (t1>t2) ? t1 : t2;
258 }
259 //=======================================================================
260 // function: Range
261 // purpose: 
262 //=======================================================================
263   const IntTools_Range& BOPTools_PaveBlock::Range() const 
264 {
265   Standard_Real t1, t2;
266   t1=myPave1.Param();
267   t2=myPave2.Param();
268
269   IntTools_Range* pRange=(IntTools_Range*) &myRange;
270
271   if (t1<t2) {
272    pRange->SetFirst (t1); 
273    pRange->SetLast  (t2); 
274   }
275   else {
276     pRange->SetFirst (t2); 
277     pRange->SetLast  (t1);
278   }
279   return myRange;
280 }
281
282 //=======================================================================
283 // function: ShrunkRange
284 // purpose: 
285 //=======================================================================
286   const IntTools_ShrunkRange& BOPTools_PaveBlock::ShrunkRange()const 
287 {
288    return myShrunkRange;
289 }
290 //=======================================================================
291 // function:  IsInBlock
292 // purpose: 
293 //=======================================================================
294   Standard_Boolean BOPTools_PaveBlock::IsInBlock(const BOPTools_Pave& thePaveX) const
295 {
296   Standard_Boolean bIsInBlock;
297   Standard_Real aT1, aT2, aTx;
298   //
299   aTx=thePaveX.Param();
300   Parameters(aT1, aT2);
301   bIsInBlock=(aTx > aT1 && aTx < aT2);
302   return bIsInBlock;
303 }