b311480e |
1 | // Created on: 1995-07-20 |
2 | // Created by: Modelistation |
3 | // Copyright (c) 1995-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 | |
04f7bd75 |
17 | #include <BRepApprox_ApproxLine.ixx> |
18 | |
7fd59977 |
19 | #include <gp_Pnt2d.hxx> |
20 | |
21 | //======================================================================= |
04f7bd75 |
22 | //function : BRepApprox_ApproxLine |
7fd59977 |
23 | //purpose : |
24 | //======================================================================= |
25 | |
04f7bd75 |
26 | BRepApprox_ApproxLine::BRepApprox_ApproxLine |
27 | (const Handle(Geom_BSplineCurve)& CurveXYZ, |
28 | const Handle(Geom2d_BSplineCurve)& CurveUV1, |
29 | const Handle(Geom2d_BSplineCurve)& CurveUV2) |
7fd59977 |
30 | { |
04f7bd75 |
31 | myCurveXYZ = CurveXYZ; |
32 | myCurveUV1 = CurveUV1; |
33 | myCurveUV2 = CurveUV2; |
7fd59977 |
34 | } |
35 | |
36 | |
37 | //======================================================================= |
04f7bd75 |
38 | //function : BRepApprox_ApproxLine |
7fd59977 |
39 | //purpose : |
40 | //======================================================================= |
41 | |
04f7bd75 |
42 | BRepApprox_ApproxLine::BRepApprox_ApproxLine |
7fd59977 |
43 | (const Handle(IntSurf_LineOn2S)& lin, |
44 | const Standard_Boolean ) |
04f7bd75 |
45 | :myLineOn2S(lin) |
7fd59977 |
46 | { |
47 | } |
48 | |
49 | //======================================================================= |
50 | //function : NbPnts |
51 | //purpose : |
52 | //======================================================================= |
53 | |
04f7bd75 |
54 | Standard_Integer BRepApprox_ApproxLine::NbPnts() const |
7fd59977 |
55 | { |
04f7bd75 |
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()); |
7fd59977 |
63 | } |
64 | |
65 | //======================================================================= |
66 | //function : Point |
67 | //purpose : |
68 | //======================================================================= |
69 | |
04f7bd75 |
70 | IntSurf_PntOn2S BRepApprox_ApproxLine::Point(const Standard_Integer Index) |
7fd59977 |
71 | { |
04f7bd75 |
72 | if(!myLineOn2S.IsNull()) { |
73 | if(myLineOn2S->NbPoints()) { |
74 | return(myLineOn2S->Value(Index)); |
7fd59977 |
75 | } |
76 | } |
77 | gp_Pnt2d P1,P2; |
78 | gp_Pnt P; |
04f7bd75 |
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()); |
7fd59977 |
88 | |
04f7bd75 |
89 | return aPntOn2S; |
7fd59977 |
90 | } |