summaryrefslogtreecommitdiff
path: root/src/HLRBRep/HLRBRep_BCurveTool.cxx
blob: d0d0684ac90227224ffbf461dacc7884bdd9d97c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// File:	HLRBRep_BCurveTool.cxx
// Created:	Mon Jul 17 17:39:39 1995
// Author:	Modelistation
//		<model@mastox>

#include <HLRBRep_BCurveTool.ixx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_Shape.hxx>
#include <Handle_Geom_BezierCurve.hxx>
#include <Handle_Geom_BSplineCurve.hxx>
#include <TColStd_Array1OfReal.hxx>
#include <TColgp_Array1OfPnt.hxx>


//=======================================================================
//function : NbSamples
//purpose  : 
//=======================================================================

Standard_Integer
HLRBRep_BCurveTool::NbSamples (const BRepAdaptor_Curve& C,
			       const Standard_Real U0,
			       const Standard_Real U1)
{
  GeomAbs_CurveType typC = C.GetType();
  static Standard_Real nbsOther = 10.0;
  Standard_Real nbs = nbsOther;
  
  if(typC == GeomAbs_Line) 
    nbs = 2;
  else if(typC == GeomAbs_BezierCurve) 
    nbs = 3 + C.NbPoles();
  else if(typC == GeomAbs_BSplineCurve) { 
    nbs = C.NbKnots();
    nbs*= C.Degree();
    nbs*= C.LastParameter()- C.FirstParameter();
    nbs/= U1-U0;
    if(nbs < 2.0) nbs=2;
  }
  if(nbs>50)
    nbs = 50;
  return((Standard_Integer)nbs);
}

//=======================================================================
//function : Poles
//purpose  : 
//=======================================================================

void HLRBRep_BCurveTool::Poles(const BRepAdaptor_Curve& C,
			       TColgp_Array1OfPnt& T)
{ 
  if(C.GetType() == GeomAbs_BezierCurve) 
    C.Bezier()->Poles(T);
  else if(C.GetType() == GeomAbs_BSplineCurve) 
    C.BSpline()->Poles(T);
}

//=======================================================================
//function : PolesAndWeights
//purpose  : 
//=======================================================================

void HLRBRep_BCurveTool::PolesAndWeights(const BRepAdaptor_Curve& C, 
					 TColgp_Array1OfPnt& T,
					 TColStd_Array1OfReal& W)
{ 
  if(C.GetType() == GeomAbs_BezierCurve) {
    const Handle(Geom_BezierCurve) HB = C.Bezier();
    HB->Poles(T);
    HB->Weights(W);
  }
  else if(C.GetType() == GeomAbs_BSplineCurve) {
    const Handle(Geom_BSplineCurve) HB = C.BSpline();
    HB->Poles(T);
    HB->Weights(W);
  }
}

//=======================================================================
//function : Bezier
//purpose  : 
//=======================================================================

Handle(Geom_BezierCurve)
     HLRBRep_BCurveTool::Bezier (const BRepAdaptor_Curve& C)
{ return(C.Bezier()); }

//=======================================================================
//function : BSpline
//purpose  : 
//=======================================================================

Handle(Geom_BSplineCurve)
     HLRBRep_BCurveTool::BSpline (const BRepAdaptor_Curve& C)
{ return(C.BSpline()); }