0024830: Remove redundant keyword 'mutable' in CDL declarations
[occt.git] / src / BRepApprox / BRepApprox_ApproxLine.cxx
1 // Created on: 1995-07-20
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <BRepApprox_ApproxLine.ixx>
18
19 #include <gp_Pnt2d.hxx>
20
21 //=======================================================================
22 //function : BRepApprox_ApproxLine
23 //purpose  : 
24 //=======================================================================
25
26 BRepApprox_ApproxLine::BRepApprox_ApproxLine
27    (const Handle(Geom_BSplineCurve)&    CurveXYZ,
28     const Handle(Geom2d_BSplineCurve)&  CurveUV1,
29     const Handle(Geom2d_BSplineCurve)&  CurveUV2) 
30
31   myCurveXYZ = CurveXYZ;
32   myCurveUV1 = CurveUV1;
33   myCurveUV2 = CurveUV2;
34 }
35
36
37 //=======================================================================
38 //function : BRepApprox_ApproxLine
39 //purpose  : 
40 //=======================================================================
41
42 BRepApprox_ApproxLine::BRepApprox_ApproxLine
43     (const Handle(IntSurf_LineOn2S)& lin,
44      const Standard_Boolean ) 
45      :myLineOn2S(lin) 
46
47 }
48
49 //=======================================================================
50 //function : NbPnts
51 //purpose  : 
52 //=======================================================================
53
54 Standard_Integer BRepApprox_ApproxLine::NbPnts() const 
55 {
56   if(!myCurveXYZ.IsNull())
57     return(myCurveXYZ->NbPoles());
58   if(!myCurveUV1.IsNull())
59     return(myCurveUV1->NbPoles());
60   if(!myCurveUV2.IsNull())
61     return(myCurveUV2->NbPoles());
62   return(myLineOn2S->NbPoints());
63 }
64
65 //=======================================================================
66 //function : Point
67 //purpose  : 
68 //=======================================================================
69
70 IntSurf_PntOn2S BRepApprox_ApproxLine::Point(const Standard_Integer Index)
71 {
72   if(!myLineOn2S.IsNull()) { 
73     if(myLineOn2S->NbPoints()) { 
74       return(myLineOn2S->Value(Index));
75     }
76   }
77   gp_Pnt2d P1,P2;
78   gp_Pnt   P;
79   if(!myCurveXYZ.IsNull()) 
80     P = myCurveXYZ->Pole(Index);
81   if(!myCurveUV1.IsNull())
82     P1 = myCurveUV1->Pole(Index);
83   if(!myCurveUV2.IsNull())
84     P2 = myCurveUV2->Pole(Index);
85
86   IntSurf_PntOn2S aPntOn2S;
87   aPntOn2S.SetValue(P, P1.X(), P1.Y(), P2.X(), P2.Y());
88
89   return aPntOn2S;
90 }