0024166: Unable to create file with "Save" menu of voxeldemo Qt sample
[occt.git] / src / Geom2dInt / Geom2dInt_CurveTool.gxx
CommitLineData
b311480e 1// Created on: 1992-10-22
2// Created by: Laurent BUCHARD
3// Copyright (c) 1992-1999 Matra Datavision
4// Copyright (c) 1999-2012 OPEN CASCADE SAS
5//
6// The content of this file is subject to the Open CASCADE Technology Public
7// License Version 6.5 (the "License"). You may not use the content of this file
8// except in compliance with the License. Please obtain a copy of the License
9// at http://www.opencascade.org and read it completely before using this file.
10//
11// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13//
14// The Original Code and all software distributed under the License is
15// distributed on an "AS IS" basis, without warranty of any kind, and the
16// Initial Developer hereby disclaims all such warranties, including without
17// limitation, any warranties of merchantability, fitness for a particular
18// purpose or non-infringement. Please see the License for the specific terms
19// and conditions governing the rights and limitations under the License.
20
7fd59977 21
7fd59977 22
23
24#include <GeomAbs_CurveType.hxx>
25#include <Handle_Geom2d_BezierCurve.hxx>
26#include <Handle_Geom2d_BSplineCurve.hxx>
27#include <Geom2d_BezierCurve.hxx>
28#include <Geom2d_BSplineCurve.hxx>
29
30//============================================================
31Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C,
32 const Standard_Real U0,
33 const Standard_Real U1) {
34 GeomAbs_CurveType typC = C.GetType();
35 static Standard_Real nbsOther = 10.0;
36 Standard_Real nbs = nbsOther;
37
38 if(typC == GeomAbs_Line)
39 nbs = 2;
40 else if(typC == GeomAbs_BezierCurve)
41 nbs = 3 + C.NbPoles();
42 else if(typC == GeomAbs_BSplineCurve) {
43 Standard_Real t=C.LastParameter()-C.FirstParameter();
44 Standard_Real t1=U1-U0;
45 if(t1<0.0) t1=-t1;
46 nbs = C.NbKnots();
47 nbs*= C.Degree();
48 nbs*= (t1/t);
49 if(nbs < 4.0) nbs=4;
50 }
51 //// modified by jgv, 20.02.02 for bug OCC165 ////
52 else if (typC == GeomAbs_OtherCurve)
53 nbs = 20;
54 //////////////////////////////////////////////////
55
56 if(nbs>300)
57 nbs = 300;
58 return((Standard_Integer)nbs);
59}
60//============================================================
61Standard_Integer Geom2dInt_CurveTool::NbSamples (const IntCurveCurve& C) {
62 GeomAbs_CurveType typC = C.GetType();
63 static Standard_Real nbsOther = 10.0;
64 Standard_Real nbs = nbsOther;
65
66 if(typC == GeomAbs_Line)
67 nbs = 2;
68 else if(typC == GeomAbs_BezierCurve)
69 nbs = 3 + C.NbPoles();
70 else if(typC == GeomAbs_BSplineCurve) {
71 nbs = C.NbKnots();
72 nbs*= C.Degree();
73 if(nbs < 2.0) nbs=2;
74 }
75 //// modified by jgv, 20.02.02 for bug OCC165 ////
76 else if (typC == GeomAbs_OtherCurve)
77 nbs = 20;
78 //////////////////////////////////////////////////
79
80 if(nbs>300)
81 nbs = 300;
82 return((Standard_Integer)nbs);
83}
84
85
86
87