b311480e |
1 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
2 | // |
3 | // The content of this file is subject to the Open CASCADE Technology Public |
4 | // License Version 6.5 (the "License"). You may not use the content of this file |
5 | // except in compliance with the License. Please obtain a copy of the License |
6 | // at http://www.opencascade.org and read it completely before using this file. |
7 | // |
8 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
9 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
10 | // |
11 | // The Original Code and all software distributed under the License is |
12 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
13 | // Initial Developer hereby disclaims all such warranties, including without |
14 | // limitation, any warranties of merchantability, fitness for a particular |
15 | // purpose or non-infringement. Please see the License for the specific terms |
16 | // and conditions governing the rights and limitations under the License. |
17 | |
7fd59977 |
18 | #include <IntTools_Curve.ixx> |
19 | #include <Geom_BoundedCurve.hxx> |
20 | #include <GeomAdaptor_Curve.hxx> |
21 | |
22 | //======================================================================= |
23 | //function : IntTools_Curve::IntTools_Curve |
24 | //purpose : |
25 | //======================================================================= |
b311480e |
26 | IntTools_Curve::IntTools_Curve() |
7fd59977 |
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 | } |