0024096: Eliminate compiler warning C4505 in MSVC++ with warning level 4
[occt.git] / src / ChFiKPart / ChFiKPart_ComputeData.cxx
CommitLineData
b311480e 1// Created on: 1993-12-23
2// Created by: Isabelle GRIGNON
3// Copyright (c) 1993-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
7fd59977 21
22
23#include <ChFiKPart_ComputeData.ixx>
24
25#include <Standard_NotImplemented.hxx>
26#include <Standard_ConstructionError.hxx>
27#include <Precision.hxx>
28#include <gp.hxx>
29#include <gp_Pnt2d.hxx>
30#include <gp_Dir2d.hxx>
31#include <gp_Lin2d.hxx>
32#include <gp_Pnt.hxx>
33#include <gp_Dir.hxx>
34#include <gp_Vec.hxx>
35#include <gp_Lin.hxx>
36#include <gp_Ax2.hxx>
37#include <gp_Ax3.hxx>
38#include <gp_Circ.hxx>
39#include <gp_Pln.hxx>
40#include <gp_Cylinder.hxx>
41#include <ElCLib.hxx>
42#include <ElSLib.hxx>
43#include <Geom2d_Curve.hxx>
44#include <Geom2d_Line.hxx>
45#include <Geom2d_Circle.hxx>
46#include <Geom2d_BSplineCurve.hxx>
47#include <Geom_Curve.hxx>
48#include <Geom_Line.hxx>
49#include <Geom_Circle.hxx>
50#include <Geom_Surface.hxx>
51#include <Geom_Plane.hxx>
52#include <Geom_CylindricalSurface.hxx>
53#include <Geom_ToroidalSurface.hxx>
54#include <Geom_ConicalSurface.hxx>
55#include <Geom_SphericalSurface.hxx>
56#include <GeomAbs_CurveType.hxx>
57#include <GeomAbs_SurfaceType.hxx>
58#include <GeomAdaptor_Curve.hxx>
59#include <Geom2dAdaptor_Curve.hxx>
60//#include <BRepAdaptor_Curve2d.hxx>
61#include <BRepAdaptor_HSurface.hxx>
62#include <IntSurf_Transition.hxx>
63#include <IntSurf_TypeTrans.hxx>
64#include <IntRes2d_Transition.hxx>
65#include <IntRes2d_TypeTrans.hxx>
66#include <IntRes2d_Position.hxx>
67#include <IntRes2d_IntersectionPoint.hxx>
68#include <IntAna_QuadQuadGeo.hxx>
69#include <Geom2dInt_GInter.hxx>
70#include <TopExp.hxx>
71//#include <BRepAdaptor_HCurve2d.hxx>
72#include <ChFiDS_FilSpine.hxx>
73#include <ChFiDS_ChamfSpine.hxx>
74
75#include <TopOpeBRepDS_Curve.hxx>
76#include <TopOpeBRepDS_Surface.hxx>
77
78#include <ChFiKPart_ComputeData_Fcts.hxx>
79#include <ChFiKPart_ComputeData_ChPlnPln.hxx>
80#include <ChFiKPart_ComputeData_ChPlnCyl.hxx>
81#include <ChFiKPart_ComputeData_ChPlnCon.hxx>
82#include <ChFiKPart_ComputeData_ChAsymPlnPln.hxx>
83#include <ChFiKPart_ComputeData_ChAsymPlnCyl.hxx>
84#include <ChFiKPart_ComputeData_ChAsymPlnCon.hxx>
85#include <ChFiKPart_ComputeData_FilPlnCon.hxx>
86#include <ChFiKPart_ComputeData_FilPlnCyl.hxx>
87#include <ChFiKPart_ComputeData_FilPlnPln.hxx>
88
89
90#include <ChFiKPart_ComputeData_CS.hxx>
91#include <ChFiKPart_ComputeData_Rotule.hxx>
92#include <ChFiKPart_ComputeData_Sphere.hxx>
93
94//=======================================================================
7fd59977 95//function : Compute
96//purpose :
97//=======================================================================
98 Standard_Boolean ChFiKPart_ComputeData::Compute
99 (TopOpeBRepDS_DataStructure& DStr,
100 Handle(ChFiDS_SurfData)& Data,
101 const Handle_Adaptor3d_HSurface& S1,
102 const Handle_Adaptor3d_HSurface& S2,
103 const TopAbs_Orientation Or1,
104 const TopAbs_Orientation Or2,
105 const Handle(ChFiDS_Spine)& Sp,
106 const Standard_Integer Iedge)
107{
108 Standard_Real Wref = 0.;
109
110 Handle(ChFiDS_FilSpine) Spine = Handle(ChFiDS_FilSpine)::DownCast(Sp);
111 Handle(ChFiDS_ChamfSpine) CSpine = Handle(ChFiDS_ChamfSpine)::DownCast(Sp);
7fd59977 112 Standard_Boolean surfok = Standard_False;
7fd59977 113 GeomAbs_SurfaceType typ1 = S1->GetType();
114 GeomAbs_SurfaceType typ2 = S2->GetType();
115 GeomAbs_CurveType ctyp;
116
117 if (!Spine.IsNull())
118 ctyp = Spine->CurrentElementarySpine(Iedge).GetType();
119 else
120 ctyp = CSpine->CurrentElementarySpine(Iedge).GetType();
121
81bba717 122 // Return orientations.
7fd59977 123 TopAbs_Orientation OrFace1 = TopAbs_FORWARD, OrFace2 = TopAbs_FORWARD;
124 Handle(BRepAdaptor_HSurface) HS = Handle(BRepAdaptor_HSurface)::DownCast(S1);
125 if (!HS.IsNull()) OrFace1 = HS->ChangeSurface().Face().Orientation();
126 HS = Handle(BRepAdaptor_HSurface)::DownCast(S2);
127 if (!HS.IsNull()) OrFace2 = HS->ChangeSurface().Face().Orientation();
128
129 if(!Spine.IsNull()){
130 Standard_Real Radius = Spine->Radius(Iedge);
131 if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Plane ){
132 surfok = ChFiKPart_MakeFillet(DStr,Data,S1->Plane(),S2->Plane(),
133 Or1,Or2,Radius,Spine->Line(),
134 Wref,OrFace1);
135 }
136 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder ){
137 if (ctyp == GeomAbs_Line)
138 surfok = ChFiKPart_MakeFillet(DStr,Data,S1->Plane(),S2->Cylinder(),
139 S2->FirstUParameter(),S2->LastUParameter(),
140 Or1,Or2,Radius,Spine->Line(),
141 Wref,OrFace1,Standard_True);
142 else
143 surfok = ChFiKPart_MakeFillet(DStr,Data,S1->Plane(),S2->Cylinder(),
144 S2->FirstUParameter(),S2->LastUParameter(),
145 Or1,Or2,Radius,Spine->Circle(),
146 Wref,OrFace1,Standard_True);
147 }
148 else if ( typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane ){
149 if (ctyp == GeomAbs_Line)
150 surfok = ChFiKPart_MakeFillet(DStr,Data,S2->Plane(),S1->Cylinder(),
151 S1->FirstUParameter(),S1->LastUParameter(),
152 Or2,Or1,Radius,Spine->Line(),
153 Wref,OrFace2,Standard_False);
154 else
155 surfok = ChFiKPart_MakeFillet(DStr,Data,S2->Plane(),S1->Cylinder(),
156 S1->FirstUParameter(),S1->LastUParameter(),
157 Or2,Or1,Radius,Spine->Circle(),
158 Wref,OrFace2,Standard_False);
159 }
160 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone ){
161 surfok = ChFiKPart_MakeFillet(DStr,Data,S1->Plane(),S2->Cone(),
162 S2->FirstUParameter(),S2->LastUParameter(),
163 Or1,Or2,Radius,Spine->Circle(),
164 Wref,OrFace1,Standard_True);
165 }
166 else if ( typ1 == GeomAbs_Cone && typ2 == GeomAbs_Plane ){
167 surfok = ChFiKPart_MakeFillet(DStr,Data,S2->Plane(),S1->Cone(),
168 S1->FirstUParameter(),S1->LastUParameter(),
169 Or2,Or1,Radius,Spine->Circle(),
170 Wref,OrFace2,Standard_False);
171 }
172 else{
81bba717 173 Standard_NotImplemented::Raise("particular case not written");
7fd59977 174 }
175 }
176 else if(!CSpine.IsNull()){
177 if (CSpine->IsChamfer() == ChFiDS_Sym) {
178 Standard_Real dis;
179 CSpine->GetDist(dis);
180 if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Plane ){
181 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Plane(),
182 Or1,Or2,dis, dis,CSpine->Line(),
183 Wref,OrFace1);
184 }
185 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder ){
186 if (ctyp == GeomAbs_Circle)
187 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Cylinder(),
188 S2->FirstUParameter(),S2->LastUParameter(),
189 Or1,Or2,dis,dis ,CSpine->Circle(),
190 Wref,OrFace1,Standard_True);
191 else
192 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Cylinder(),
193 S2->FirstUParameter(),S2->LastUParameter(),
194 Or1,Or2,dis,dis,CSpine->Line(),
195 Wref,OrFace1,Standard_True);
196 }
197 else if ( typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane ){
198 if (ctyp == GeomAbs_Circle)
199 surfok = ChFiKPart_MakeChamfer(DStr,Data,S2->Plane(),S1->Cylinder(),
200 S1->FirstUParameter(),S1->LastUParameter(),
201 Or2,Or1,dis,dis,CSpine->Circle(),
202 Wref,OrFace2,Standard_False);
203 else
204 surfok = ChFiKPart_MakeChamfer(DStr,Data,S2->Plane(),S1->Cylinder(),
205 S1->FirstUParameter(),S1->LastUParameter(),
206 Or2,Or1,dis,dis,CSpine->Line(),
207 Wref,OrFace2,Standard_False);
208 }
209 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone ){
210 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Cone(),
211 S2->FirstUParameter(),S2->LastUParameter(),
212 Or1,Or2,dis,dis,CSpine->Circle(),
213 Wref,OrFace1,Standard_True);
214 }
215 else if ( typ1 == GeomAbs_Cone && typ2 == GeomAbs_Plane ){
216 surfok = ChFiKPart_MakeChamfer(DStr,Data,S2->Plane(),S1->Cone(),
217 S1->FirstUParameter(),S1->LastUParameter(),
218 Or2,Or1,dis,dis,CSpine->Circle(),
219 Wref,OrFace2,Standard_False);
220 }
221 else{
81bba717 222 Standard_NotImplemented::Raise("particular case not written");
7fd59977 223 }
224 }
225 else if (CSpine->IsChamfer() == ChFiDS_TwoDist) {
226 Standard_Real dis1,dis2;
227 CSpine->Dists(dis1,dis2);
228 if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Plane ){
229 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Plane(),
230 Or1,Or2,dis1,dis2,CSpine->Line(),
231 Wref,OrFace1);
232 }
233 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder ){
234 if (ctyp == GeomAbs_Circle)
235 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Cylinder(),
236 S2->FirstUParameter(),S2->LastUParameter(),
237 Or1,Or2,dis1,dis2,CSpine->Circle(),
238 Wref,OrFace1,Standard_True);
239 else
240 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Cylinder(),
241 S2->FirstUParameter(),S2->LastUParameter(),
242 Or1,Or2,dis1,dis2,CSpine->Line(),
243 Wref,OrFace1,Standard_True);
244 }
245 else if ( typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane ){
246 if (ctyp == GeomAbs_Circle)
247 surfok = ChFiKPart_MakeChamfer(DStr,Data,S2->Plane(),S1->Cylinder(),
248 S1->FirstUParameter(),S1->LastUParameter(),
249 Or2,Or1,dis2,dis1,CSpine->Circle(),
250 Wref,OrFace2,Standard_False);
251 else
252 surfok = ChFiKPart_MakeChamfer(DStr,Data,S2->Plane(),S1->Cylinder(),
253 S1->FirstUParameter(),S1->LastUParameter(),
254 Or2,Or1,dis2,dis1,CSpine->Line(),
255 Wref,OrFace2,Standard_False);
256 }
257 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone ){
258 surfok = ChFiKPart_MakeChamfer(DStr,Data,S1->Plane(),S2->Cone(),
259 S2->FirstUParameter(),S2->LastUParameter(),
260 Or1,Or2,dis1,dis2,CSpine->Circle(),
261 Wref,OrFace1,Standard_True);
262 }
263 else if ( typ1 == GeomAbs_Cone && typ2 == GeomAbs_Plane ){
264 surfok = ChFiKPart_MakeChamfer(DStr,Data,S2->Plane(),S1->Cone(),
265 S1->FirstUParameter(),S1->LastUParameter(),
266 Or2,Or1,dis2,dis1,CSpine->Circle(),
267 Wref,OrFace2,Standard_False);
268 }
269 else{
81bba717 270 Standard_NotImplemented::Raise("particular case not written");
7fd59977 271 }
272 }
273 else {
274 Standard_Real dis, Angle;
275 Standard_Boolean DisOnP;
276 CSpine->GetDistAngle(dis, Angle, DisOnP);
277 if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Plane ){
278 surfok = ChFiKPart_MakeChAsym(DStr,Data,S1->Plane(),S2->Plane(),
279 Or1,Or2, dis, Angle, CSpine->Line(),
280 Wref,OrFace1, DisOnP);
281 }
282 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cylinder ){
283 if (ctyp == GeomAbs_Circle)
284 surfok = ChFiKPart_MakeChAsym(DStr,Data,S1->Plane(),S2->Cylinder(),
285 S2->FirstUParameter(),S2->LastUParameter(),
286 Or1,Or2,dis, Angle, CSpine->Circle(),
287 Wref,OrFace1,Standard_True, DisOnP);
288 else
289 surfok = ChFiKPart_MakeChAsym(DStr,Data,S1->Plane(),S2->Cylinder(),
290 S2->FirstUParameter(),S2->LastUParameter(),
291 Or1,Or2, dis, Angle, CSpine->Line(),
292 Wref,OrFace1,Standard_True, DisOnP);
293 }
294 else if ( typ1 == GeomAbs_Cylinder && typ2 == GeomAbs_Plane ){
295 if (ctyp == GeomAbs_Circle)
296 surfok = ChFiKPart_MakeChAsym(DStr,Data,S2->Plane(),S1->Cylinder(),
297 S1->FirstUParameter(),S1->LastUParameter(),
298 Or2,Or1,dis, Angle, CSpine->Circle(),
299 Wref,OrFace2,Standard_False, DisOnP);
300 else
301 surfok = ChFiKPart_MakeChAsym(DStr,Data,S2->Plane(),S1->Cylinder(),
302 S1->FirstUParameter(),S1->LastUParameter(),
303 Or2,Or1,dis, Angle, CSpine->Line(),
304 Wref,OrFace2,Standard_False, DisOnP);
305 }
306 else if ( typ1 == GeomAbs_Plane && typ2 == GeomAbs_Cone ){
307 surfok = ChFiKPart_MakeChAsym(DStr,Data,S1->Plane(),S2->Cone(),
308 S2->FirstUParameter(),S2->LastUParameter(),
309 Or1,Or2, dis, Angle, CSpine->Circle(),
310 Wref,OrFace1,Standard_True, DisOnP);
311 }
312 else if ( typ1 == GeomAbs_Cone && typ2 == GeomAbs_Plane ){
313 surfok = ChFiKPart_MakeChAsym(DStr,Data,S2->Plane(),S1->Cone(),
314 S1->FirstUParameter(),S1->LastUParameter(),
315 Or2,Or1, dis, Angle, CSpine->Circle(),
316 Wref,OrFace2,Standard_False, DisOnP);
317 }
318 else{
81bba717 319 Standard_NotImplemented::Raise("particular case not written");
7fd59977 320 }
321 }
322 }
323 return surfok;
324}
325
326//=======================================================================
327//function : ComputeCorner
328//purpose :
329//=======================================================================
330
331Standard_Boolean ChFiKPart_ComputeData::ComputeCorner
332 (TopOpeBRepDS_DataStructure& DStr,
333 const Handle(ChFiDS_SurfData)& Data,
334 const Handle(Adaptor3d_HSurface)& S1,
335 const Handle(Adaptor3d_HSurface)& S2,
336 const TopAbs_Orientation OrFace1,
337 const TopAbs_Orientation,
338 const TopAbs_Orientation Or1,
339 const TopAbs_Orientation Or2,
340 const Standard_Real minRad,
341 const Standard_Real majRad,
342 const gp_Pnt2d& P1S1,
343 const gp_Pnt2d& P2S1,
344 const gp_Pnt2d& P1S2,
345 const gp_Pnt2d& P2S2)
346{
347 Standard_Boolean surfok;
348 GeomAbs_SurfaceType typ1 = S1->GetType();
349 GeomAbs_SurfaceType typ2 = S2->GetType();
350 if ( typ1 != GeomAbs_Plane ){
351 Standard_ConstructionError::Raise
352 ("la face du conge torique doit etre plane");
353 }
81bba717 354 // The guideline is the circle corresponding
355 // to the section of S2, and other construction elements.
7fd59977 356
357 gp_Cylinder cyl;
358 gp_Circ circ;
359 Standard_Real First,Last,fu,lu;
360 ChFiKPart_CornerSpine(S1,S2,P1S1,P2S1,P1S2,P2S2,majRad,cyl,circ,First,Last);
361 if ( typ2 == GeomAbs_Cylinder ){
362 cyl = S2->Cylinder();
363 fu = P1S2.X();
364 lu = P2S2.X();
365 }
366 else{
367 fu = First;
368 lu = Last;
369 }
370 surfok = ChFiKPart_MakeFillet(DStr,Data,S1->Plane(),cyl,
371 fu,lu,Or1,Or2,minRad,circ,
372 First,OrFace1,Standard_True);
373 if(surfok){
374 if ( typ2 != GeomAbs_Cylinder ){
375 Data->ChangeInterferenceOnS2().ChangePCurveOnFace() =
376 ChFiKPart_PCurve(P1S2,P2S2,First,Last);
377 }
378 Data->ChangeVertexFirstOnS1().SetPoint(S1->Value(P1S1.X(),P1S1.Y()));
379 Data->ChangeVertexLastOnS1().SetPoint(S1->Value(P2S1.X(),P2S1.Y()));
380 Data->ChangeVertexFirstOnS2().SetPoint(S2->Value(P1S2.X(),P1S2.Y()));
381 Data->ChangeVertexLastOnS2().SetPoint(S2->Value(P2S2.X(),P2S2.Y()));
382 Data->ChangeInterferenceOnS1().SetFirstParameter(First);
383 Data->ChangeInterferenceOnS1().SetLastParameter(Last);
384 Data->ChangeInterferenceOnS2().SetFirstParameter(First);
385 Data->ChangeInterferenceOnS2().SetLastParameter(Last);
386 return Standard_True;
387 }
388 return Standard_False;
389}
390
391
392//=======================================================================
393//function : ComputeCorner
394//purpose :
395//=======================================================================
396
397Standard_Boolean ChFiKPart_ComputeData::ComputeCorner
398 (TopOpeBRepDS_DataStructure& DStr,
399 const Handle(ChFiDS_SurfData)& Data,
400 const Handle(Adaptor3d_HSurface)& S1,
401 const Handle(Adaptor3d_HSurface)& S2,
402 const TopAbs_Orientation OrFace1,
403 const TopAbs_Orientation OrFace2,
404 const TopAbs_Orientation Or1,
405 const TopAbs_Orientation Or2,
406 const Standard_Real Rad,
407 const gp_Pnt2d& PS1,
408 const gp_Pnt2d& P1S2,
409 const gp_Pnt2d& P2S2)
410{
411 return ChFiKPart_Sphere(DStr,Data,S1,S2,OrFace1,OrFace2,Or1,Or2,Rad,PS1,P1S2,P2S2);
412}
413
414//=======================================================================
415//function : ComputeCorner
416//purpose :
417//=======================================================================
418
419Standard_Boolean ChFiKPart_ComputeData::ComputeCorner
420 (TopOpeBRepDS_DataStructure& DStr,
421 const Handle(ChFiDS_SurfData)& Data,
422 const Handle(Adaptor3d_HSurface)& S,
423 const Handle(Adaptor3d_HSurface)& S1,
424 const Handle(Adaptor3d_HSurface)& S2,
425 const TopAbs_Orientation OfS,
426 const TopAbs_Orientation OS,
427 const TopAbs_Orientation OS1,
428 const TopAbs_Orientation OS2,
429 const Standard_Real Radius)
430{
431 GeomAbs_SurfaceType typ = S->GetType();
432 GeomAbs_SurfaceType typ1 = S1->GetType();
433 GeomAbs_SurfaceType typ2 = S2->GetType();
434 if (typ != GeomAbs_Plane ||
435 typ1 != GeomAbs_Plane ||
436 typ2 != GeomAbs_Plane){
437 Standard_ConstructionError::Raise
81bba717 438 ("torus joint only between the planes");
7fd59977 439 }
440 return ChFiKPart_MakeRotule(DStr,Data,S->Plane(),S1->Plane(),
441 S2->Plane(),OS,OS1,OS2,Radius,OfS);
442}