0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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
25e59720 26IMPLEMENT_STANDARD_RTTIEXT(BRepApprox_ApproxLine,Standard_Transient)
92efcf78 27
7fd59977 28//=======================================================================
04f7bd75 29//function : BRepApprox_ApproxLine
7fd59977 30//purpose :
31//=======================================================================
04f7bd75 32BRepApprox_ApproxLine::BRepApprox_ApproxLine
33 (const Handle(Geom_BSplineCurve)& CurveXYZ,
34 const Handle(Geom2d_BSplineCurve)& CurveUV1,
35 const Handle(Geom2d_BSplineCurve)& CurveUV2)
7fd59977 36{
04f7bd75 37 myCurveXYZ = CurveXYZ;
38 myCurveUV1 = CurveUV1;
39 myCurveUV2 = CurveUV2;
7fd59977 40}
41
42
43//=======================================================================
04f7bd75 44//function : BRepApprox_ApproxLine
7fd59977 45//purpose :
46//=======================================================================
47
04f7bd75 48BRepApprox_ApproxLine::BRepApprox_ApproxLine
7fd59977 49 (const Handle(IntSurf_LineOn2S)& lin,
50 const Standard_Boolean )
04f7bd75 51 :myLineOn2S(lin)
7fd59977 52{
53}
54
55//=======================================================================
56//function : NbPnts
57//purpose :
58//=======================================================================
59
04f7bd75 60Standard_Integer BRepApprox_ApproxLine::NbPnts() const
7fd59977 61{
04f7bd75 62 if(!myCurveXYZ.IsNull())
63 return(myCurveXYZ->NbPoles());
64 if(!myCurveUV1.IsNull())
65 return(myCurveUV1->NbPoles());
66 if(!myCurveUV2.IsNull())
67 return(myCurveUV2->NbPoles());
68 return(myLineOn2S->NbPoints());
7fd59977 69}
70
71//=======================================================================
72//function : Point
73//purpose :
74//=======================================================================
75
04f7bd75 76IntSurf_PntOn2S BRepApprox_ApproxLine::Point(const Standard_Integer Index)
7fd59977 77{
04f7bd75 78 if(!myLineOn2S.IsNull()) {
79 if(myLineOn2S->NbPoints()) {
80 return(myLineOn2S->Value(Index));
7fd59977 81 }
82 }
83 gp_Pnt2d P1,P2;
84 gp_Pnt P;
04f7bd75 85 if(!myCurveXYZ.IsNull())
86 P = myCurveXYZ->Pole(Index);
87 if(!myCurveUV1.IsNull())
88 P1 = myCurveUV1->Pole(Index);
89 if(!myCurveUV2.IsNull())
90 P2 = myCurveUV2->Pole(Index);
91
92 IntSurf_PntOn2S aPntOn2S;
93 aPntOn2S.SetValue(P, P1.X(), P1.Y(), P2.X(), P2.Y());
7fd59977 94
04f7bd75 95 return aPntOn2S;
7fd59977 96}