0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepApprox / BRepApprox_ApproxLine.cxx
CommitLineData
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
42cf5bc1 18#include <BRepApprox_ApproxLine.hxx>
19#include <Geom2d_BSplineCurve.hxx>
20#include <Geom_BSplineCurve.hxx>
7fd59977 21#include <gp_Pnt2d.hxx>
42cf5bc1 22#include <IntSurf_LineOn2S.hxx>
23#include <IntSurf_PntOn2S.hxx>
24#include <Standard_Type.hxx>
7fd59977 25
26//=======================================================================
04f7bd75 27//function : BRepApprox_ApproxLine
7fd59977 28//purpose :
29//=======================================================================
04f7bd75 30BRepApprox_ApproxLine::BRepApprox_ApproxLine
31 (const Handle(Geom_BSplineCurve)& CurveXYZ,
32 const Handle(Geom2d_BSplineCurve)& CurveUV1,
33 const Handle(Geom2d_BSplineCurve)& CurveUV2)
7fd59977 34{
04f7bd75 35 myCurveXYZ = CurveXYZ;
36 myCurveUV1 = CurveUV1;
37 myCurveUV2 = CurveUV2;
7fd59977 38}
39
40
41//=======================================================================
04f7bd75 42//function : BRepApprox_ApproxLine
7fd59977 43//purpose :
44//=======================================================================
45
04f7bd75 46BRepApprox_ApproxLine::BRepApprox_ApproxLine
7fd59977 47 (const Handle(IntSurf_LineOn2S)& lin,
48 const Standard_Boolean )
04f7bd75 49 :myLineOn2S(lin)
7fd59977 50{
51}
52
53//=======================================================================
54//function : NbPnts
55//purpose :
56//=======================================================================
57
04f7bd75 58Standard_Integer BRepApprox_ApproxLine::NbPnts() const
7fd59977 59{
04f7bd75 60 if(!myCurveXYZ.IsNull())
61 return(myCurveXYZ->NbPoles());
62 if(!myCurveUV1.IsNull())
63 return(myCurveUV1->NbPoles());
64 if(!myCurveUV2.IsNull())
65 return(myCurveUV2->NbPoles());
66 return(myLineOn2S->NbPoints());
7fd59977 67}
68
69//=======================================================================
70//function : Point
71//purpose :
72//=======================================================================
73
04f7bd75 74IntSurf_PntOn2S BRepApprox_ApproxLine::Point(const Standard_Integer Index)
7fd59977 75{
04f7bd75 76 if(!myLineOn2S.IsNull()) {
77 if(myLineOn2S->NbPoints()) {
78 return(myLineOn2S->Value(Index));
7fd59977 79 }
80 }
81 gp_Pnt2d P1,P2;
82 gp_Pnt P;
04f7bd75 83 if(!myCurveXYZ.IsNull())
84 P = myCurveXYZ->Pole(Index);
85 if(!myCurveUV1.IsNull())
86 P1 = myCurveUV1->Pole(Index);
87 if(!myCurveUV2.IsNull())
88 P2 = myCurveUV2->Pole(Index);
89
90 IntSurf_PntOn2S aPntOn2S;
91 aPntOn2S.SetValue(P, P1.X(), P1.Y(), P2.X(), P2.Y());
7fd59977 92
04f7bd75 93 return aPntOn2S;
7fd59977 94}