0024002: Overall code and build procedure refactoring -- automatic
[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
15 #include <Geom2d_Curve.hxx>
16 #include <Geom_BoundedCurve.hxx>
17 #include <Geom_Curve.hxx>
18 #include <GeomAdaptor_Curve.hxx>
19 #include <gp_Pnt.hxx>
20 #include <IntTools_Curve.hxx>
21
22 //=======================================================================
23 //function : IntTools_Curve::IntTools_Curve
24 //purpose  : 
25 //=======================================================================
26 IntTools_Curve::IntTools_Curve()
27 {
28 }
29 //=======================================================================
30 //function : IntTools_Curve::IntTools_Curve
31 //purpose  : 
32 //=======================================================================
33   IntTools_Curve::IntTools_Curve(const Handle(Geom_Curve)& Curve3d,
34                                  const Handle(Geom2d_Curve)& FirstCurve2d,
35                                  const Handle(Geom2d_Curve)& SecondCurve2d)
36 {
37   SetCurves(Curve3d, FirstCurve2d, SecondCurve2d);
38 }
39 //=======================================================================
40 //function : SetCurves
41 //purpose  : 
42 //=======================================================================
43   void IntTools_Curve::SetCurves(const Handle(Geom_Curve)& Curve3d,
44                                  const Handle(Geom2d_Curve)& FirstCurve2d,
45                                  const Handle(Geom2d_Curve)& SecondCurve2d) 
46 {
47   SetCurve(Curve3d);
48   SetFirstCurve2d(FirstCurve2d);
49   SetSecondCurve2d(SecondCurve2d);
50 }
51
52 //=======================================================================
53 //function : HasBounds
54 //purpose  : 
55 //=======================================================================
56   Standard_Boolean IntTools_Curve::HasBounds() const 
57 {
58   Standard_Boolean bBounded;
59
60   Handle(Geom_BoundedCurve) aC3DBounded =
61     Handle(Geom_BoundedCurve)::DownCast(my3dCurve);
62   
63   bBounded=!aC3DBounded.IsNull();
64   
65   return bBounded ;
66 }
67
68 //=======================================================================
69 //function : Bounds
70 //purpose  : 
71 //=======================================================================
72   void IntTools_Curve::Bounds(Standard_Real& aT1,
73                               Standard_Real& aT2,
74                               gp_Pnt& aP1,
75                               gp_Pnt& aP2) const 
76 {
77   aT1=0.;
78   aT2=0.;
79   aP1.SetCoord(0.,0.,0.);
80   aP2.SetCoord(0.,0.,0.);
81   if (HasBounds()) {
82     aT1=my3dCurve->FirstParameter();
83     aT2=my3dCurve->LastParameter();
84     my3dCurve->D0(aT1, aP1);
85     my3dCurve->D0(aT2, aP2);
86   }
87 }
88
89 //=======================================================================
90 //function : D0
91 //purpose  : 
92 //=======================================================================
93   Standard_Boolean IntTools_Curve::D0(Standard_Real& aT,
94                                       gp_Pnt& aP) const 
95 {
96   Standard_Real aF, aL;
97
98   aF=my3dCurve->FirstParameter();
99   aL=my3dCurve->LastParameter();
100   if (aT<aF || aT>aL) {
101     return Standard_False;
102   }
103   my3dCurve->D0(aT, aP);
104   return Standard_True;
105 }
106
107 //=======================================================================
108 //function : D0
109 //purpose  : 
110 //=======================================================================
111    GeomAbs_CurveType IntTools_Curve::Type() const 
112 {
113   GeomAdaptor_Curve aGAC(my3dCurve);
114   GeomAbs_CurveType aType=aGAC.GetType();
115   return aType;
116 }