0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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
7fd59977 18#include <Geom2d_BezierCurve.hxx>
42cf5bc1 19#include <Geom2dInt_Geom2dCurveTool.hxx>
20#include <GeomAbs_CurveType.hxx>
f4dee9bb 21#include <Precision.hxx>
47cbf134 22
7fd59977 23//============================================================
47cbf134 24Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C,
f4dee9bb 25 const Standard_Real U0,
26 const Standard_Real U1)
a874a4a0 27{
7fd59977 28 GeomAbs_CurveType typC = C.GetType();
a874a4a0 29 Standard_Integer nbs = C.NbSamples();
7fd59977 30
5ae6e53d 31 if(typC == GeomAbs_BSplineCurve)
32 {
f4dee9bb 33 Standard_Real t=C.LastParameter()-C.FirstParameter();
34 if(t > Precision::PConfusion())
35 {
36 Standard_Real t1 = U1 - U0;
37 if(t1 < 0.0) t1 = -t1;
38 nbs = C.NbKnots();
39 nbs*= C.Degree();
40 Standard_Real anb = t1 / t * nbs;
41 nbs = (Standard_Integer)anb;
5ae6e53d 42
f4dee9bb 43 Standard_Integer aMinPntNb = Max(C.Degree() + 1, 4);
44 if(nbs < aMinPntNb)
45 nbs = aMinPntNb;
46 }
cdf4594a 47 }
48 else if (typC == GeomAbs_Circle)
49 {
50 //Try to reach deflection = eps*R, eps = 0.01
51 const Standard_Real minR = 1.; //eps = 0.01
52 Standard_Real R = C.Circle().Radius();
53 if(R > minR)
54 {
55 Standard_Real angl = 0.283079; //2.*ACos(1. - eps);
56 Standard_Integer n = RealToInt(Abs(U1 - U0) / angl);
57 nbs = Max(n, nbs);
58 }
7fd59977 59 }
7fd59977 60
61 if(nbs>300)
62 nbs = 300;
a874a4a0 63 return nbs;
64
7fd59977 65}
66//============================================================
47cbf134 67Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C) {
cdf4594a 68 Standard_Integer nbs = C.NbSamples();
69 GeomAbs_CurveType typC = C.GetType();
70 if (typC == GeomAbs_Circle)
71 {
72 //Try to reach deflection = eps*R, eps = 0.01
73 const Standard_Real minR = 1.; //eps = 0.01
74 Standard_Real R = C.Circle().Radius();
75 if(R > minR)
76 {
77 Standard_Real angl = 0.283079; //2.*ACos(1. - eps);
78 Standard_Integer n = RealToInt((C.LastParameter()-C.FirstParameter()) / angl);
79 nbs = Max(n, nbs);
80 }
81 }
82
83 return nbs;
a874a4a0 84 }
7fd59977 85
86
87
88