0025456: BOPAlgo_CheckerSI reports an error on the given shape
[occt.git] / src / IntTools / IntTools_Curve.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #include <IntTools_Curve.ixx>
15 #include <Geom_BoundedCurve.hxx>
16 #include <GeomAdaptor_Curve.hxx>
17
18 //=======================================================================
19 //function : IntTools_Curve::IntTools_Curve
20 //purpose  : 
21 //=======================================================================
22 IntTools_Curve::IntTools_Curve()
23 {
24 }
25 //=======================================================================
26 //function : IntTools_Curve::IntTools_Curve
27 //purpose  : 
28 //=======================================================================
29   IntTools_Curve::IntTools_Curve(const Handle(Geom_Curve)& Curve3d,
30                                  const Handle(Geom2d_Curve)& FirstCurve2d,
31                                  const Handle(Geom2d_Curve)& SecondCurve2d)
32 {
33   SetCurves(Curve3d, FirstCurve2d, SecondCurve2d);
34 }
35 //=======================================================================
36 //function : SetCurves
37 //purpose  : 
38 //=======================================================================
39   void IntTools_Curve::SetCurves(const Handle(Geom_Curve)& Curve3d,
40                                  const Handle(Geom2d_Curve)& FirstCurve2d,
41                                  const Handle(Geom2d_Curve)& SecondCurve2d) 
42 {
43   SetCurve(Curve3d);
44   SetFirstCurve2d(FirstCurve2d);
45   SetSecondCurve2d(SecondCurve2d);
46 }
47
48 //=======================================================================
49 //function : HasBounds
50 //purpose  : 
51 //=======================================================================
52   Standard_Boolean IntTools_Curve::HasBounds() const 
53 {
54   Standard_Boolean bBounded;
55
56   Handle(Geom_BoundedCurve) aC3DBounded =
57     Handle(Geom_BoundedCurve)::DownCast(my3dCurve);
58   
59   bBounded=!aC3DBounded.IsNull();
60   
61   return bBounded ;
62 }
63
64 //=======================================================================
65 //function : Bounds
66 //purpose  : 
67 //=======================================================================
68   void IntTools_Curve::Bounds(Standard_Real& aT1,
69                               Standard_Real& aT2,
70                               gp_Pnt& aP1,
71                               gp_Pnt& aP2) const 
72 {
73   aT1=0.;
74   aT2=0.;
75   aP1.SetCoord(0.,0.,0.);
76   aP2.SetCoord(0.,0.,0.);
77   if (HasBounds()) {
78     aT1=my3dCurve->FirstParameter();
79     aT2=my3dCurve->LastParameter();
80     my3dCurve->D0(aT1, aP1);
81     my3dCurve->D0(aT2, aP2);
82   }
83 }
84
85 //=======================================================================
86 //function : D0
87 //purpose  : 
88 //=======================================================================
89   Standard_Boolean IntTools_Curve::D0(Standard_Real& aT,
90                                       gp_Pnt& aP) const 
91 {
92   Standard_Real aF, aL;
93
94   aF=my3dCurve->FirstParameter();
95   aL=my3dCurve->LastParameter();
96   if (aT<aF || aT>aL) {
97     return Standard_False;
98   }
99   my3dCurve->D0(aT, aP);
100   return Standard_True;
101 }
102
103 //=======================================================================
104 //function : D0
105 //purpose  : 
106 //=======================================================================
107    GeomAbs_CurveType IntTools_Curve::Type() const 
108 {
109   GeomAdaptor_Curve aGAC(my3dCurve);
110   GeomAbs_CurveType aType=aGAC.GetType();
111   return aType;
112 }