0031939: Coding - correction of spelling errors in comments
[occt.git] / src / GeomFill / GeomFill_SnglrFunc.cxx
CommitLineData
b311480e 1// Created on: 1998-02-26
2// Created by: Roman BORISOV
3// Copyright (c) 1998-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
42cf5bc1 17
18#include <Adaptor3d_HCurve.hxx>
19#include <GeomFill_SnglrFunc.hxx>
20#include <gp_Pnt.hxx>
21#include <gp_Vec.hxx>
7fd59977 22#include <Precision.hxx>
42cf5bc1 23#include <Standard_DomainError.hxx>
24#include <Standard_NotImplemented.hxx>
25#include <Standard_OutOfRange.hxx>
7fd59977 26
27GeomFill_SnglrFunc::GeomFill_SnglrFunc(const Handle(Adaptor3d_HCurve)& HC) :
28 myHCurve(HC), ratio(1)
29{
30}
31
32void GeomFill_SnglrFunc::SetRatio(const Standard_Real Ratio)
33{
34 ratio = Ratio;
35}
36
37 Standard_Real GeomFill_SnglrFunc::FirstParameter() const
38{
39 return myHCurve->FirstParameter();
40}
41
42 Standard_Real GeomFill_SnglrFunc::LastParameter() const
43{
44 return myHCurve->LastParameter();
45}
46
31b1749c 47 Standard_Integer GeomFill_SnglrFunc::NbIntervals(const GeomAbs_Shape S) const
7fd59977 48{
7fd59977 49 GeomAbs_Shape HCS=GeomAbs_C0;
f6b08ecf 50 if (S == GeomAbs_C0)
51 {
52 HCS = GeomAbs_C2;
53 }
54 else if (S == GeomAbs_C1)
55 {
56 HCS = GeomAbs_C3;
57 }
58 else if (S >= GeomAbs_C2)
59 {
60 HCS = GeomAbs_CN;
7fd59977 61 }
62 return myHCurve->NbIntervals(HCS);
63}
64
31b1749c 65 void GeomFill_SnglrFunc::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) const
7fd59977 66{
7fd59977 67 GeomAbs_Shape HCS=GeomAbs_C0;
f6b08ecf 68 if (S == GeomAbs_C0)
69 {
70 HCS = GeomAbs_C2;
71 }
72 else if (S == GeomAbs_C1)
73 {
74 HCS = GeomAbs_C3;
75 }
76 else if (S >= GeomAbs_C2)
77 {
78 HCS = GeomAbs_CN;
7fd59977 79 }
80 myHCurve->Intervals(T, HCS);
81}
82
83 Standard_Boolean GeomFill_SnglrFunc::IsPeriodic() const
84{
85 return myHCurve->IsPeriodic();
86}
87
88 Standard_Real GeomFill_SnglrFunc::Period() const
89{
90 return myHCurve->Period();
91}
92
93
94 gp_Pnt GeomFill_SnglrFunc::Value(const Standard_Real U) const
95{
96 gp_Pnt C;
97 gp_Vec DC, D2C;
98 myHCurve->D2(U, C, DC, D2C);
99 DC *= ratio;
100 return gp_Pnt(DC.Crossed(D2C).XYZ());
101}
102
103 void GeomFill_SnglrFunc::D0(const Standard_Real U,gp_Pnt& P) const
104{
105 gp_Pnt C;
106 gp_Vec DC, D2C;
107 myHCurve->D2(U, C, DC, D2C);
108 DC *= ratio;
109 P = gp_Pnt(DC.Crossed(D2C).XYZ());
110}
111
112 void GeomFill_SnglrFunc::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V) const
113{
114 gp_Pnt C;
115 gp_Vec DC, D2C, D3C;
116 myHCurve->D3(U, C, DC, D2C, D3C);
117 DC *= ratio;
118 P = gp_Pnt(DC.Crossed(D2C).XYZ());
119 V = DC.Crossed(D3C);
120}
121
122 void GeomFill_SnglrFunc::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
123{
124 gp_Pnt C;
125 gp_Vec DC, D2C, D3C, D4C;
126 myHCurve->D3(U, C, DC, D2C, D3C);
127 P = gp_Pnt(DC.Crossed(D2C).XYZ());
128 V1 = DC.Crossed(D3C);
129 D4C = myHCurve->DN(U, 4);
130 V2 = D2C.Crossed(D3C) + DC.Crossed(D4C);
131
132 P.ChangeCoord() *= ratio;
133 V1 *= ratio;
134 V2 *= ratio;
135}
136
32ca7a51 137void GeomFill_SnglrFunc::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const
138 {
139 gp_Vec DC, D2C, D3C, D4C, D5C;
140 myHCurve->D3(U, P, DC, D2C, D3C);
141 D4C = myHCurve->DN(U, 4);
142 D5C = myHCurve->DN(U, 5);
143 P = gp_Pnt(DC.Crossed(D2C).XYZ()).ChangeCoord()*ratio;
144 V1 = DC.Crossed(D3C)*ratio;
145 V2 = (D2C.Crossed(D3C) + DC.Crossed(D4C))*ratio;
146 V3 = (DC.Crossed(D5C) + D2C.Crossed(D4C)*2)*ratio;
147 }
148
149gp_Vec GeomFill_SnglrFunc::DN(const Standard_Real U,const Standard_Integer N) const
150 {
151 Standard_RangeError_Raise_if (N < 1, "Exception: Geom2d_OffsetCurve::DN(). N<1.");
152
153 gp_Vec D1C, D2C, D3C;
154 gp_Pnt C;
155
156 switch(N)
157 {
158 case 1:
159 D1(U,C,D1C);
160 return D1C;
161 case 2:
162 D2(U,C,D1C,D2C);
163 return D2C;
164 case 3:
165 D3(U,C,D1C,D2C,D3C);
166 return D3C;
167 default:
9775fa61 168 throw Standard_NotImplemented("Exception: Derivative order is greater than 3. "
32ca7a51 169 "Cannot compute of derivative.");
170 }
32ca7a51 171 }
172
7fd59977 173 Standard_Real GeomFill_SnglrFunc::Resolution(const Standard_Real R3D) const
174{
175 return Precision::Parametric(R3D);
176}
177
178 GeomAbs_CurveType GeomFill_SnglrFunc::GetType() const
179{
180 return GeomAbs_OtherCurve;
181}
182
183