0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / Convert / Convert_ParabolaToBSplineCurve.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
7fd59977 15//JCV 16/10/91
16
42cf5bc1 17#include <Convert_ParabolaToBSplineCurve.hxx>
7fd59977 18#include <gp.hxx>
19#include <gp_Ax2d.hxx>
20#include <gp_Dir2d.hxx>
42cf5bc1 21#include <gp_Parab2d.hxx>
7fd59977 22#include <gp_Trsf2d.hxx>
42cf5bc1 23#include <TColgp_Array1OfPnt2d.hxx>
7fd59977 24#include <TColgp_HArray1OfPnt2d.hxx>
7fd59977 25#include <TColStd_Array1OfReal.hxx>
42cf5bc1 26#include <TColStd_HArray1OfInteger.hxx>
27#include <TColStd_HArray1OfReal.hxx>
7fd59977 28
29static Standard_Integer TheDegree = 2;
30static Standard_Integer MaxNbKnots = 2;
31static Standard_Integer MaxNbPoles = 3;
32
33//=======================================================================
34//function : Convert_ParabolaToBSplineCurve
35//purpose :
36//=======================================================================
37
38Convert_ParabolaToBSplineCurve::Convert_ParabolaToBSplineCurve
39 (const gp_Parab2d& Prb,
40 const Standard_Real U1 ,
41 const Standard_Real U2 )
42: Convert_ConicToBSplineCurve (MaxNbPoles, MaxNbKnots, TheDegree)
43{
44 Standard_DomainError_Raise_if( Abs(U2 - U1) < Epsilon(0.),
45 "Convert_ParabolaToBSplineCurve");
46
47 Standard_Real UF = Min (U1, U2);
48 Standard_Real UL = Max( U1, U2);
49
50 Standard_Real p = Prb.Parameter();
51
52 nbPoles = 3;
53 nbKnots = 2;
54 isperiodic = Standard_False;
55 knots->ChangeArray1()(1) = UF; mults->ChangeArray1()(1) = 3;
56 knots->ChangeArray1()(2) = UL; mults->ChangeArray1()(2) = 3;
57
58 weights->ChangeArray1()(1) = 1.;
59 weights->ChangeArray1()(2) = 1.;
60 weights->ChangeArray1()(3) = 1.;
61
62 gp_Dir2d Ox = Prb.Axis().XDirection();
63 gp_Dir2d Oy = Prb.Axis().YDirection();
64 Standard_Real S = ( Ox.X() * Oy.Y() - Ox.Y() * Oy.X() > 0.) ? 1 : -1;
65
66
0d969553 67 // poles expressed in the reference mark
7fd59977 68 poles->ChangeArray1()(1) =
69 gp_Pnt2d( ( UF * UF) / ( 2. * p), S * UF );
70 poles->ChangeArray1()(2) =
71 gp_Pnt2d( ( UF * UL) / ( 2. * p), S * ( UF + UL) / 2. );
72 poles->ChangeArray1()(3) =
73 gp_Pnt2d( ( UL * UL) / ( 2. * p), S * UL );
74
0d969553 75 // replace the bspline in the mark of the parabola
7fd59977 76 gp_Trsf2d Trsf;
77 Trsf.SetTransformation( Prb.Axis().XAxis(), gp::OX2d());
78 poles->ChangeArray1()(1).Transform( Trsf);
79 poles->ChangeArray1()(2).Transform( Trsf);
80 poles->ChangeArray1()(3).Transform( Trsf);
81}
82
83