0024827: Incorrect result of projection of an edge on a face
[occt.git] / src / Geom2dInt / Geom2dInt_Geom2dCurveTool.cxx
CommitLineData
b311480e 1// Created on: 1992-10-22
2// Created by: Laurent BUCHARD
3// Copyright (c) 1992-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
47cbf134 17#include <Geom2dInt_Geom2dCurveTool.ixx>
18
7fd59977 19#include <GeomAbs_CurveType.hxx>
cb389a77 20#include <Geom2d_BezierCurve.hxx>
21#include <Geom2d_BSplineCurve.hxx>
7fd59977 22#include <Geom2d_BezierCurve.hxx>
23#include <Geom2d_BSplineCurve.hxx>
24
47cbf134 25#include <Adaptor2d_Curve2d.hxx>
26
7fd59977 27//============================================================
47cbf134 28Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C,
7fd59977 29 const Standard_Real U0,
30 const Standard_Real U1) {
31 GeomAbs_CurveType typC = C.GetType();
32 static Standard_Real nbsOther = 10.0;
33 Standard_Real nbs = nbsOther;
34
35 if(typC == GeomAbs_Line)
36 nbs = 2;
37 else if(typC == GeomAbs_BezierCurve)
38 nbs = 3 + C.NbPoles();
39 else if(typC == GeomAbs_BSplineCurve) {
40 Standard_Real t=C.LastParameter()-C.FirstParameter();
41 Standard_Real t1=U1-U0;
42 if(t1<0.0) t1=-t1;
43 nbs = C.NbKnots();
44 nbs*= C.Degree();
45 nbs*= (t1/t);
46 if(nbs < 4.0) nbs=4;
47 }
48 //// modified by jgv, 20.02.02 for bug OCC165 ////
49 else if (typC == GeomAbs_OtherCurve)
50 nbs = 20;
51 //////////////////////////////////////////////////
52
53 if(nbs>300)
54 nbs = 300;
55 return((Standard_Integer)nbs);
56}
57//============================================================
47cbf134 58Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C) {
7fd59977 59 GeomAbs_CurveType typC = C.GetType();
60 static Standard_Real nbsOther = 10.0;
61 Standard_Real nbs = nbsOther;
62
63 if(typC == GeomAbs_Line)
64 nbs = 2;
65 else if(typC == GeomAbs_BezierCurve)
66 nbs = 3 + C.NbPoles();
67 else if(typC == GeomAbs_BSplineCurve) {
68 nbs = C.NbKnots();
69 nbs*= C.Degree();
70 if(nbs < 2.0) nbs=2;
71 }
72 //// modified by jgv, 20.02.02 for bug OCC165 ////
73 else if (typC == GeomAbs_OtherCurve)
74 nbs = 20;
75 //////////////////////////////////////////////////
76
77 if(nbs>300)
78 nbs = 300;
79 return((Standard_Integer)nbs);
80}
81
82
83
84