b311480e |
1 | // Created on: 1998-02-26 |
2 | // Created by: Roman BORISOV |
3 | // Copyright (c) 1998-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <GeomFill_SnglrFunc.ixx> |
32ca7a51 |
24 | #include <Standard_NotImplemented.hxx> |
7fd59977 |
25 | #include <Precision.hxx> |
26 | |
27 | GeomFill_SnglrFunc::GeomFill_SnglrFunc(const Handle(Adaptor3d_HCurve)& HC) : |
28 | myHCurve(HC), ratio(1) |
29 | { |
30 | } |
31 | |
32 | void 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 | |
47 | Standard_Integer GeomFill_SnglrFunc::NbIntervals(const GeomAbs_Shape S) |
48 | { |
7fd59977 |
49 | GeomAbs_Shape HCS=GeomAbs_C0; |
7fd59977 |
50 | switch(S) { |
51 | case GeomAbs_C0: HCS = GeomAbs_C2; break; |
52 | case GeomAbs_C1: HCS = GeomAbs_C3; break; |
53 | case GeomAbs_C2: HCS = GeomAbs_CN; break; |
54 | default: Standard_DomainError::Raise(); |
55 | } |
56 | return myHCurve->NbIntervals(HCS); |
57 | } |
58 | |
59 | void GeomFill_SnglrFunc::Intervals(TColStd_Array1OfReal& T,const GeomAbs_Shape S) |
60 | { |
7fd59977 |
61 | GeomAbs_Shape HCS=GeomAbs_C0; |
7fd59977 |
62 | switch(S) { |
63 | case GeomAbs_C0: HCS = GeomAbs_C2; break; |
64 | case GeomAbs_C1: HCS = GeomAbs_C3; break; |
65 | case GeomAbs_C2: HCS = GeomAbs_CN; break; |
66 | default: Standard_DomainError::Raise(); |
67 | } |
68 | myHCurve->Intervals(T, HCS); |
69 | } |
70 | |
71 | Standard_Boolean GeomFill_SnglrFunc::IsPeriodic() const |
72 | { |
73 | return myHCurve->IsPeriodic(); |
74 | } |
75 | |
76 | Standard_Real GeomFill_SnglrFunc::Period() const |
77 | { |
78 | return myHCurve->Period(); |
79 | } |
80 | |
81 | |
82 | gp_Pnt GeomFill_SnglrFunc::Value(const Standard_Real U) const |
83 | { |
84 | gp_Pnt C; |
85 | gp_Vec DC, D2C; |
86 | myHCurve->D2(U, C, DC, D2C); |
87 | DC *= ratio; |
88 | return gp_Pnt(DC.Crossed(D2C).XYZ()); |
89 | } |
90 | |
91 | void GeomFill_SnglrFunc::D0(const Standard_Real U,gp_Pnt& P) const |
92 | { |
93 | gp_Pnt C; |
94 | gp_Vec DC, D2C; |
95 | myHCurve->D2(U, C, DC, D2C); |
96 | DC *= ratio; |
97 | P = gp_Pnt(DC.Crossed(D2C).XYZ()); |
98 | } |
99 | |
100 | void GeomFill_SnglrFunc::D1(const Standard_Real U,gp_Pnt& P,gp_Vec& V) const |
101 | { |
102 | gp_Pnt C; |
103 | gp_Vec DC, D2C, D3C; |
104 | myHCurve->D3(U, C, DC, D2C, D3C); |
105 | DC *= ratio; |
106 | P = gp_Pnt(DC.Crossed(D2C).XYZ()); |
107 | V = DC.Crossed(D3C); |
108 | } |
109 | |
110 | void GeomFill_SnglrFunc::D2(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const |
111 | { |
112 | gp_Pnt C; |
113 | gp_Vec DC, D2C, D3C, D4C; |
114 | myHCurve->D3(U, C, DC, D2C, D3C); |
115 | P = gp_Pnt(DC.Crossed(D2C).XYZ()); |
116 | V1 = DC.Crossed(D3C); |
117 | D4C = myHCurve->DN(U, 4); |
118 | V2 = D2C.Crossed(D3C) + DC.Crossed(D4C); |
119 | |
120 | P.ChangeCoord() *= ratio; |
121 | V1 *= ratio; |
122 | V2 *= ratio; |
123 | } |
124 | |
32ca7a51 |
125 | void GeomFill_SnglrFunc::D3(const Standard_Real U,gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3) const |
126 | { |
127 | gp_Vec DC, D2C, D3C, D4C, D5C; |
128 | myHCurve->D3(U, P, DC, D2C, D3C); |
129 | D4C = myHCurve->DN(U, 4); |
130 | D5C = myHCurve->DN(U, 5); |
131 | P = gp_Pnt(DC.Crossed(D2C).XYZ()).ChangeCoord()*ratio; |
132 | V1 = DC.Crossed(D3C)*ratio; |
133 | V2 = (D2C.Crossed(D3C) + DC.Crossed(D4C))*ratio; |
134 | V3 = (DC.Crossed(D5C) + D2C.Crossed(D4C)*2)*ratio; |
135 | } |
136 | |
137 | gp_Vec GeomFill_SnglrFunc::DN(const Standard_Real U,const Standard_Integer N) const |
138 | { |
139 | Standard_RangeError_Raise_if (N < 1, "Exception: Geom2d_OffsetCurve::DN(). N<1."); |
140 | |
141 | gp_Vec D1C, D2C, D3C; |
142 | gp_Pnt C; |
143 | |
144 | switch(N) |
145 | { |
146 | case 1: |
147 | D1(U,C,D1C); |
148 | return D1C; |
149 | case 2: |
150 | D2(U,C,D1C,D2C); |
151 | return D2C; |
152 | case 3: |
153 | D3(U,C,D1C,D2C,D3C); |
154 | return D3C; |
155 | default: |
156 | Standard_NotImplemented::Raise("Exception: Derivative order is greater than 3. " |
157 | "Cannot compute of derivative."); |
158 | } |
159 | |
160 | return gp_Vec(); |
161 | |
162 | } |
163 | |
7fd59977 |
164 | Standard_Real GeomFill_SnglrFunc::Resolution(const Standard_Real R3D) const |
165 | { |
166 | return Precision::Parametric(R3D); |
167 | } |
168 | |
169 | GeomAbs_CurveType GeomFill_SnglrFunc::GetType() const |
170 | { |
171 | return GeomAbs_OtherCurve; |
172 | } |
173 | |
174 | |