summaryrefslogtreecommitdiff
path: root/src/HLRBRep/HLRBRep_CurveTool.cxx
blob: 2917fe75b67cf4e89214071f1ef71c21c123a80e (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
// File:	HLRBRep_CurveTool.cxx
// Created:	Mon Jul 17 17:39:39 1995
// Author:	Modelistation
//		<model@mastox>

#include <HLRBRep_CurveTool.ixx>
#include <HLRBRep_Curve.hxx>
#include <GeomAbs_CurveType.hxx>
#include <GeomAbs_Shape.hxx>
#include <Handle_Geom2d_BezierCurve.hxx>
#include <Handle_Geom2d_BSplineCurve.hxx>
#include <TColStd_Array1OfReal.hxx>

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

Standard_Integer
HLRBRep_CurveTool::NbSamples (const Standard_Address C)
{ 
  GeomAbs_CurveType typC = ((HLRBRep_Curve *)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 + ((HLRBRep_Curve *)C)->NbPoles();
  else if(typC == GeomAbs_BSplineCurve) { 
    nbs = ((HLRBRep_Curve *)C)->NbKnots();
    nbs*= ((HLRBRep_Curve *)C)->Degree();
    if(nbs < 2.0) nbs=2;
  }
  if(nbs>50)
    nbs = 50;
  return((Standard_Integer)nbs);
}

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

Standard_Integer
HLRBRep_CurveTool::NbSamples (const Standard_Address C,
			      const Standard_Real u1,
			      const Standard_Real u2) 
{ 
  GeomAbs_CurveType typC = ((HLRBRep_Curve *)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 + ((HLRBRep_Curve *)C)->NbPoles();
  else if(typC == GeomAbs_BSplineCurve) { 
    nbs = ((HLRBRep_Curve *)C)->NbKnots();
    nbs*= ((HLRBRep_Curve *)C)->Degree();
    if(nbs < 2.0) nbs=2;
  }
  if(nbs>50)
    nbs = 50;
  return((Standard_Integer)nbs);
}