0026419: [Regression?] Export of a reversed face leads to crash in 6.9.0 although...
[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
42cf5bc1 18#include <Adaptor2d_Curve2d.hxx>
7fd59977 19#include <Geom2d_BezierCurve.hxx>
20#include <Geom2d_BSplineCurve.hxx>
42cf5bc1 21#include <Geom2dInt_Geom2dCurveTool.hxx>
22#include <GeomAbs_CurveType.hxx>
23#include <gp_Pnt2d.hxx>
24#include <gp_Vec2d.hxx>
47cbf134 25
7fd59977 26//============================================================
47cbf134 27Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C,
a874a4a0 28 const Standard_Real U0,
29 const Standard_Real U1)
30{
7fd59977 31 GeomAbs_CurveType typC = C.GetType();
a874a4a0 32 Standard_Integer nbs = C.NbSamples();
7fd59977 33
a874a4a0 34 if(typC == GeomAbs_BSplineCurve) {
7fd59977 35 Standard_Real t=C.LastParameter()-C.FirstParameter();
36 Standard_Real t1=U1-U0;
37 if(t1<0.0) t1=-t1;
38 nbs = C.NbKnots();
39 nbs*= C.Degree();
a874a4a0 40 Standard_Real anb = t1/t * nbs;
41 nbs = (Standard_Integer)anb;
7fd59977 42 if(nbs < 4.0) nbs=4;
43 }
7fd59977 44
45 if(nbs>300)
46 nbs = 300;
a874a4a0 47 return nbs;
48
7fd59977 49}
50//============================================================
47cbf134 51Standard_Integer Geom2dInt_Geom2dCurveTool::NbSamples (const Adaptor2d_Curve2d& C) {
a874a4a0 52 return C.NbSamples();
53 }
7fd59977 54
55
56
57