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