summaryrefslogtreecommitdiff
path: root/inc/Geom2dInt_CurveTool.gxx
blob: 8f0e752ef3eb940cbdfc7035149e3fcb8c17ea5e (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

// File:	Geom2dInt_CurveTool.gxx
// Created:	Thu Oct 22 12:09:58 1992
// Author:	Laurent BUCHARD
//		<lbr@sdsun2>
//-Copyright:	 Matra Datavision 1992


#include <GeomAbs_CurveType.hxx>
#include <Handle_Geom2d_BezierCurve.hxx>
#include <Handle_Geom2d_BSplineCurve.hxx>
#include <Geom2d_BezierCurve.hxx>
#include <Geom2d_BSplineCurve.hxx>

//============================================================
Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& 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) { 
    Standard_Real t=C.LastParameter()-C.FirstParameter();
    Standard_Real t1=U1-U0;
    if(t1<0.0) t1=-t1;
    nbs = C.NbKnots();
    nbs*= C.Degree();
    nbs*= (t1/t);
    if(nbs < 4.0) nbs=4;
  }
  //// modified by jgv, 20.02.02 for bug OCC165 ////
  else if (typC == GeomAbs_OtherCurve)
    nbs = 20;
  //////////////////////////////////////////////////

  if(nbs>300)
    nbs = 300;
  return((Standard_Integer)nbs);
}
//============================================================
Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C) { 
  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();
    if(nbs < 2.0) nbs=2;
  }
  //// modified by jgv, 20.02.02 for bug OCC165 ////
  else if (typC == GeomAbs_OtherCurve)
    nbs = 20;
  //////////////////////////////////////////////////

  if(nbs>300)
    nbs = 300;
  return((Standard_Integer)nbs);
}