0026377: Passing Handle objects as arguments to functions as non-const reference...
[occt.git] / src / DrawFairCurve / DrawFairCurve_Batten.cxx
CommitLineData
b311480e 1// Created on: 1996-02-16
2// Created by: Philippe MANGIN
3// Copyright (c) 1996-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
7fd59977 17
42cf5bc1 18#include <DrawFairCurve_Batten.hxx>
7fd59977 19#include <FairCurve_AnalysisCode.hxx>
42cf5bc1 20#include <FairCurve_Batten.hxx>
c04c30b3 21#include <Geom2d_BSplineCurve.hxx>
42cf5bc1 22#include <GeomTools_Curve2dSet.hxx>
23#include <gp_Pnt2d.hxx>
24#include <Standard_Type.hxx>
7fd59977 25
92efcf78 26IMPLEMENT_STANDARD_RTTIEXT(DrawFairCurve_Batten,DrawTrSurf_BSplineCurve2d)
27
7fd59977 28DrawFairCurve_Batten::DrawFairCurve_Batten(const Standard_Address TheBatten)
29 : DrawTrSurf_BSplineCurve2d( ((FairCurve_Batten*)TheBatten)->Curve()),
30 MyBatten( TheBatten)
31
32{
33 Compute();
34 ShowCurvature();
35}
36
37void DrawFairCurve_Batten::Compute()
38{
39 FairCurve_AnalysisCode Iana;
6e6cd5d9 40 ((FairCurve_Batten*)MyBatten)->Compute(Iana, 50, 1.0e-2);
7fd59977 41 curv = ((FairCurve_Batten*)MyBatten)->Curve();
42}
43void DrawFairCurve_Batten::SetPoint(const Standard_Integer Side, const gp_Pnt2d& Point)
44{
45 if (Side == 1) {
46 ((FairCurve_Batten*)MyBatten)->SetP1(Point);
47 }
48 else {
49 ((FairCurve_Batten*)MyBatten)-> SetP2(Point);
50 }
51 Compute();
52}
53
54void DrawFairCurve_Batten::SetAngle(const Standard_Integer Side, const Standard_Real Angle)
55{
56 if (Side == 1) {
c6541a0c 57 ((FairCurve_Batten*)MyBatten)->SetAngle1(Angle*M_PI/180);
7fd59977 58 if ( ((FairCurve_Batten*)MyBatten)->GetConstraintOrder1() == 0 )
59 {
60 ((FairCurve_Batten*)MyBatten)->SetConstraintOrder1(1);
61 }
62 }
63 else {
c6541a0c 64 ((FairCurve_Batten*)MyBatten)->SetAngle2(Angle*M_PI/180);
7fd59977 65 if ( ((FairCurve_Batten*)MyBatten)->GetConstraintOrder2() == 0 )
66 {
67 ((FairCurve_Batten*)MyBatten)->SetConstraintOrder2(1);
68 }
69 }
70 Compute();
71}
72
73void DrawFairCurve_Batten::SetSliding(const Standard_Real Length)
74{
75 ((FairCurve_Batten*)MyBatten)-> SetFreeSliding(Standard_False);
76 ((FairCurve_Batten*)MyBatten)->SetSlidingFactor(Length);
77 Compute();
78}
79
80void DrawFairCurve_Batten::SetHeight(const Standard_Real Height)
81{
82 ((FairCurve_Batten*)MyBatten)->SetHeight(Height);
83 Compute();
84}
85
86void DrawFairCurve_Batten::SetSlope(const Standard_Real Slope)
87{
88 ((FairCurve_Batten*)MyBatten)->SetSlope(Slope);
89 Compute();
90}
91
92Standard_Real DrawFairCurve_Batten::GetAngle(const Standard_Integer Side) const
93{
94 if (Side == 1) return ((FairCurve_Batten*)MyBatten)->GetAngle1();
95 else return ((FairCurve_Batten*)MyBatten)->GetAngle2();
96}
97
98Standard_Real DrawFairCurve_Batten::GetSliding() const
99{
100 return ((FairCurve_Batten*)MyBatten)->GetSlidingFactor();
101}
102
103
104void DrawFairCurve_Batten::FreeSliding()
105{
106 ((FairCurve_Batten*)MyBatten)->SetFreeSliding(Standard_True);
107 Compute();
108}
109
110void DrawFairCurve_Batten::FreeAngle(const Standard_Integer Side)
111{
112 if (Side == 1) ((FairCurve_Batten*)MyBatten)->SetConstraintOrder1(0);
113 else ((FairCurve_Batten*)MyBatten)->SetConstraintOrder2(0);
114
115 Compute();
116}
117
118void DrawFairCurve_Batten::Dump(Standard_OStream& S)const
119{
120 GeomTools_Curve2dSet::PrintCurve2d(curv,S);
121 ((FairCurve_Batten*)MyBatten)->Dump(S);
122}