0022792: Globally defined symbol PI conflicts with VTK definition (Intel compiler)
[occt.git] / src / HLRBRep / HLRBRep.cxx
CommitLineData
733a0e55
S
1// File: HLRBRep.cxx
2// Created: Thu Aug 27 12:33:14 1992
3// Author: Christophe MARION
4// Copyright: OPEN CASCADE 2000
7fd59977 5
6#include <HLRBRep.ixx>
7#include <BRepLib_MakeEdge2d.hxx>
8#include <Geom2d_BezierCurve.hxx>
9#include <Geom2d_BSplineCurve.hxx>
10#include <TColStd_Array1OfInteger.hxx>
11#include <TColStd_Array1OfReal.hxx>
12#include <TColgp_Array1OfPnt2d.hxx>
13
14//=======================================================================
15//function : MakeEdge
16//purpose :
17//=======================================================================
18
19TopoDS_Edge HLRBRep::MakeEdge (const HLRBRep_Curve& ec,
20 const Standard_Real U1,
21 const Standard_Real U2)
22{
23 TopoDS_Edge Edg;
24 //gp_Pnt2d P,P1,P2;
25 Standard_Real sta3d = U1;
26 Standard_Real end3d = U2;
27 Standard_Real sta = ec.Parameter2d(U1);
28 Standard_Real end = ec.Parameter2d(U2);
29
30 if (ec.GetType() == GeomAbs_Line) {
31 Edg = BRepLib_MakeEdge2d(ec.Line(),sta,end);
32 }
33 else if (ec.GetType() == GeomAbs_Circle) {
34 Edg = BRepLib_MakeEdge2d(ec.Circle(),sta,end);
35 }
36 else if (ec.GetType() == GeomAbs_Ellipse) {
37 Edg = BRepLib_MakeEdge2d(ec.Ellipse(),sta,end);
38 }
39 else if (ec.GetType() == GeomAbs_Hyperbola) {
40 Edg = BRepLib_MakeEdge2d(ec.Hyperbola(),sta,end);
41 }
42 else if (ec.GetType() == GeomAbs_Parabola) {
43 Edg = BRepLib_MakeEdge2d(ec.Parabola(),sta,end);
44 }
45 else if (ec.GetType() == GeomAbs_BezierCurve) {
46 TColgp_Array1OfPnt2d Poles(1,ec.NbPoles());
47 if (ec.IsRational()) {
48 TColStd_Array1OfReal Weights(1,ec.NbPoles());
49 ec.PolesAndWeights(Poles,Weights);
50 Edg = BRepLib_MakeEdge2d(new Geom2d_BezierCurve(Poles,Weights),sta,end);
51 }
52 else {
53 ec.Poles(Poles);
54 Edg = BRepLib_MakeEdge2d(new Geom2d_BezierCurve(Poles),sta,end);
55 }
56 }
57 else if (ec.GetType() == GeomAbs_BSplineCurve) {
58 TColgp_Array1OfPnt2d Poles(1,ec.NbPoles());
59 TColStd_Array1OfReal knots(1,ec.NbKnots());
60 TColStd_Array1OfInteger mults(1,ec.NbKnots());
61 //-- ec.KnotsAndMultiplicities(knots,mults);
62 ec.Knots(knots);
63 ec.Multiplicities(mults);
64 if (ec.IsRational()) {
65 TColStd_Array1OfReal Weights(1,ec.NbPoles());
66 ec.PolesAndWeights(Poles,Weights);
67 Edg = BRepLib_MakeEdge2d
68 (new Geom2d_BSplineCurve
69 (Poles,Weights,knots,mults,ec.Degree()),sta,end);
70 }
71 else {
72 ec.Poles(Poles);
73 Edg = BRepLib_MakeEdge2d
74 (new Geom2d_BSplineCurve(Poles,knots,mults,ec.Degree()),sta,end);
75 }
76 }
77 else {
78 Standard_Integer nbPnt = 15;
79 TColgp_Array1OfPnt2d Poles(1,nbPnt);
80 TColStd_Array1OfReal knots(1,nbPnt);
81 TColStd_Array1OfInteger mults(1,nbPnt);
82 mults.Init(1);
83 mults(1 ) = 2;
84 mults(nbPnt) = 2;
85 Standard_Real step = (end3d-sta3d)/(nbPnt-1);
86
87 for (Standard_Integer i = 1; i <= nbPnt; i++) {
88 Poles(i) = ec.Value(sta3d);
89 knots(i) = sta3d;
90 sta3d += step;
91 }
92 Edg = BRepLib_MakeEdge2d
93 (new Geom2d_BSplineCurve(Poles,knots,mults,1),sta,end);
94 }
95 return Edg;
96}
97
98//=======================================================================
99//function : PolyHLRAngleAndDeflection
100//purpose :
101//=======================================================================
102
103void
104HLRBRep::PolyHLRAngleAndDeflection (const Standard_Real InAngl,
105 Standard_Real& OutAngl,
106 Standard_Real& OutDefl)
107{
c6541a0c
D
108 static Standard_Real HAngMin = 1*M_PI/180;
109 static Standard_Real HAngLim = 5*M_PI/180;
110 static Standard_Real HAngMax = 35*M_PI/180;
7fd59977 111
112 OutAngl = InAngl;
113 if (OutAngl < HAngMin) OutAngl = HAngMin;
114 if (OutAngl > HAngMax) OutAngl = HAngMax;
115 OutAngl = HAngLim + sqrt((OutAngl - HAngMin) * (HAngMax - HAngLim) *
116 (HAngMax - HAngLim) / (HAngMax - HAngMin));
117 OutDefl = OutAngl * OutAngl * 0.5;
118}