0023934: Compiler warnings in MS VC++ 10
[occt.git] / src / Geom2dAPI / Geom2dAPI_InterCurveCurve.cxx
1 // Created on: 1994-03-24
2 // Created by: Bruno DUMORTIER
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <Geom2dAPI_InterCurveCurve.ixx>
24
25 #include <Geom2dAdaptor_Curve.hxx>
26 #include <Geom2d_TrimmedCurve.hxx>
27 #include <IntRes2d_IntersectionPoint.hxx>
28 #include <IntRes2d_IntersectionSegment.hxx>
29
30 #include <Standard_NotImplemented.hxx>
31
32 //=======================================================================
33 //function : Geom2dAPI_InterCurveCurve
34 //purpose  : 
35 //=======================================================================
36
37 Geom2dAPI_InterCurveCurve::Geom2dAPI_InterCurveCurve()
38 {
39   myIsDone = Standard_False;
40 }
41
42
43 //=======================================================================
44 //function : Geom2dAPI_InterCurveCurve
45 //purpose  : 
46 //=======================================================================
47
48 Geom2dAPI_InterCurveCurve::Geom2dAPI_InterCurveCurve
49   (const Handle(Geom2d_Curve)& C1,
50    const Handle(Geom2d_Curve)& C2,
51    const Standard_Real         Tol)
52 {
53   Init( C1, C2, Tol);
54 }
55
56
57 //=======================================================================
58 //function : Geom2dAPI_InterCurveCurve
59 //purpose  : 
60 //=======================================================================
61
62 Geom2dAPI_InterCurveCurve::Geom2dAPI_InterCurveCurve
63   (const Handle(Geom2d_Curve)& C1,
64    const Standard_Real         Tol)
65 {
66   Init( C1, Tol);
67 }
68
69
70 //=======================================================================
71 //function : Init
72 //purpose  : 
73 //=======================================================================
74
75 void Geom2dAPI_InterCurveCurve::Init
76   (const Handle(Geom2d_Curve)& C1,
77    const Handle(Geom2d_Curve)& C2,
78    const Standard_Real         Tol)
79 {
80   myCurve1 = Handle(Geom2d_Curve)::DownCast(C1->Copy());
81   myCurve2 = Handle(Geom2d_Curve)::DownCast(C2->Copy());
82
83   Geom2dAdaptor_Curve AC1(C1);
84   Geom2dAdaptor_Curve AC2(C2);
85   myIntersector = Geom2dInt_GInter( AC1, AC2, Tol, Tol);
86   myIsDone = myIntersector.IsDone();
87
88 }
89
90
91 //=======================================================================
92 //function : Init
93 //purpose  : 
94 //=======================================================================
95
96 void Geom2dAPI_InterCurveCurve::Init
97   (const Handle(Geom2d_Curve)& C1,
98    const Standard_Real         Tol)
99 {
100   myCurve1 = Handle(Geom2d_Curve)::DownCast(C1->Copy());
101   myCurve2.Nullify();
102
103   Geom2dAdaptor_Curve AC1(C1);
104   myIntersector = Geom2dInt_GInter( AC1, Tol, Tol);
105   myIsDone = myIntersector.IsDone();
106
107 }
108
109
110 //=======================================================================
111 //function : NbPoints
112 //purpose  : 
113 //=======================================================================
114
115 Standard_Integer Geom2dAPI_InterCurveCurve::NbPoints() const 
116 {
117   if ( myIsDone)  
118     return myIntersector.NbPoints();
119   else
120     return 0;
121 }
122
123
124 //=======================================================================
125 //function : Point
126 //purpose  : 
127 //=======================================================================
128
129 gp_Pnt2d Geom2dAPI_InterCurveCurve::Point
130   (const Standard_Integer Index) const 
131 {
132   Standard_OutOfRange_Raise_if(Index < 0 || Index > NbPoints(),
133                                "Geom2dAPI_InterCurveCurve::Points");
134
135   return (myIntersector.Point(Index)).Value();
136 }
137
138
139 //=======================================================================
140 //function : NbSegments
141 //purpose  : 
142 //=======================================================================
143
144 Standard_Integer Geom2dAPI_InterCurveCurve::NbSegments() const 
145 {
146   if ( myIsDone)
147     return myIntersector.NbSegments();
148   else
149     return 0;
150 }
151
152
153 //=======================================================================
154 //function : Segment
155 //purpose  : 
156 //=======================================================================
157
158 void Geom2dAPI_InterCurveCurve::Segment
159   (const Standard_Integer      Index,
160          Handle(Geom2d_Curve)& Curve1,
161          Handle(Geom2d_Curve)& Curve2) const 
162 {
163   Standard_OutOfRange_Raise_if(Index < 0 || Index > NbSegments(),
164                                "Geom2dAPI_InterCurveCurve::Segment");
165
166   Standard_NullObject_Raise_if(myCurve2.IsNull(),
167                                "Geom2dAPI_InterCurveCurve::Segment");
168
169   Standard_Real U1, U2, V1, V2;
170
171   IntRes2d_IntersectionSegment Seg = myIntersector.Segment(Index);
172   if ( Seg.IsOpposite()) {
173     if ( Seg.HasFirstPoint()) {
174       IntRes2d_IntersectionPoint IP1 = Seg.FirstPoint();
175       U1 = IP1.ParamOnFirst();
176       V2 = IP1.ParamOnSecond();
177     }
178     else {
179       U1 = Curve1->FirstParameter();
180       V2 = Curve2->LastParameter();
181     }
182     if ( Seg.HasLastPoint()) {
183       IntRes2d_IntersectionPoint IP2 = Seg.LastPoint();
184       U2 = IP2.ParamOnFirst();
185       V1 = IP2.ParamOnSecond();
186     }
187     else {
188       U2 = Curve1->FirstParameter();
189       V1 = Curve2->LastParameter();
190     }
191   }
192   else {
193     if ( Seg.HasFirstPoint()) {
194       IntRes2d_IntersectionPoint IP1 = Seg.FirstPoint();
195       U1 = IP1.ParamOnFirst();
196       V1 = IP1.ParamOnSecond();
197     }
198     else {
199       U1 = Curve1->FirstParameter();
200       V1 = Curve2->FirstParameter();
201     }
202     if ( Seg.HasLastPoint()) {
203       IntRes2d_IntersectionPoint IP2 = Seg.LastPoint();
204       U2 = IP2.ParamOnFirst();
205       V2 = IP2.ParamOnSecond();
206     }
207     else {
208       U2 = Curve1->FirstParameter();
209       V2 = Curve2->FirstParameter();
210     }
211   }
212
213   Curve1 = new Geom2d_TrimmedCurve(myCurve1, U1, U2);
214   Curve2 = new Geom2d_TrimmedCurve(myCurve2, V1, V2);
215
216 }
217
218
219 //=======================================================================
220 //function : Segment
221 //purpose  : 
222 //=======================================================================
223
224 void Geom2dAPI_InterCurveCurve::Segment (const Standard_Integer Index,
225                                          Handle(Geom2d_Curve)&) const 
226 {
227   Standard_NotImplemented::Raise(" ");
228   (void)Index; // avoid compiler warning in Release mode
229   Standard_OutOfRange_Raise_if(Index < 0 || Index > NbSegments(),
230                                "Geom2dAPI_InterCurveCurve::Segment");
231 }