1 // Created on: 1995-02-24
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
24 //=======================================================================
27 //=======================================================================
29 void Contap_SurfProps::Normale(const TheSurface& S,
30 const Standard_Real U,
31 const Standard_Real V,
36 GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
40 gp_Pln pl(TheSurfaceTool::Plane(S));
41 Norm = pl.Axis().Direction();
42 P = ElSLib::Value(U,V,pl);
52 gp_Sphere sp(TheSurfaceTool::Sphere(S));
53 P = ElSLib::Value(U,V,sp);
54 Norm = gp_Vec(sp.Location(),P);
56 Norm.Divide(sp.Radius());
59 Norm.Divide(-sp.Radius());
64 case GeomAbs_Cylinder:
66 gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
67 P = ElSLib::Value(U,V,cy);
68 Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
69 Sin(U),cy.YAxis().Direction());
79 gp_Cone co(TheSurfaceTool::Cone(S));
80 P = ElSLib::Value(U,V,co);
81 Standard_Real Angle = co.SemiAngle();
82 Standard_Real Sina = sin(Angle);
83 Standard_Real Cosa = cos(Angle);
84 Standard_Real Rad = co.RefRadius();
86 Standard_Real Vcalc = V;
87 if (Abs(V*Sina + Rad) <= 1e-12) { // on est a l`apex
89 Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
90 if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
101 if (Rad + Vcalc*Sina < 0.) {
102 Norm.SetLinearForm(Sina, co.Axis().Direction(),
103 Cosa*cos(U),co.XAxis().Direction(),
104 Cosa*sin(U),co.YAxis().Direction());
107 Norm.SetLinearForm(-Sina, co.Axis().Direction(),
108 Cosa*cos(U),co.XAxis().Direction(),
109 Cosa*sin(U),co.YAxis().Direction());
119 TheSurfaceTool::D1(S,U,V,P,d1u,d1v);
120 Norm = d1u.Crossed(d1v);
129 //=======================================================================
130 //function : DerivAndNorm
132 //=======================================================================
134 void Contap_SurfProps::DerivAndNorm(const TheSurface& S,
135 const Standard_Real U,
136 const Standard_Real V,
143 GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
147 gp_Pln pl(TheSurfaceTool::Plane(S));
148 Norm = pl.Axis().Direction();
149 ElSLib::D1(U,V,pl,P,d1u,d1v);
159 gp_Sphere sp(TheSurfaceTool::Sphere(S));
160 ElSLib::D1(U,V,sp,P,d1u,d1v);
161 Norm = gp_Vec(sp.Location(),P);
163 Norm.Divide(sp.Radius());
166 Norm.Divide(-sp.Radius());
171 case GeomAbs_Cylinder:
173 gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
174 ElSLib::D1(U,V,cy,P,d1u,d1v);
175 Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
176 Sin(U),cy.YAxis().Direction());
186 gp_Cone co(TheSurfaceTool::Cone(S));
187 ElSLib::D1(U,V,co,P,d1u,d1v);
188 Standard_Real Angle = co.SemiAngle();
189 Standard_Real Sina = Sin(Angle);
190 Standard_Real Cosa = Cos(Angle);
191 Standard_Real Rad = co.RefRadius();
193 Standard_Real Vcalc = V;
194 if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
195 Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
196 if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
204 if (Rad + Vcalc*Sina < 0.) {
205 Norm.SetLinearForm(Sina, co.Axis().Direction(),
206 Cosa*Cos(U),co.XAxis().Direction(),
207 Cosa*Sin(U),co.YAxis().Direction());
210 Norm.SetLinearForm(-Sina, co.Axis().Direction(),
211 Cosa*Cos(U),co.XAxis().Direction(),
212 Cosa*Sin(U),co.YAxis().Direction());
221 TheSurfaceTool::D1(S,U,V,P,d1u,d1v);
222 Norm = d1u.Crossed(d1v);
229 //=======================================================================
230 //function : NormAndDn
232 //=======================================================================
234 void Contap_SurfProps::NormAndDn(const TheSurface& S,
235 const Standard_Real U,
236 const Standard_Real V,
243 GeomAbs_SurfaceType typS = TheSurfaceTool::GetType(S);
247 gp_Pln pl(TheSurfaceTool::Plane(S));
248 P = ElSLib::Value(U,V,pl);
249 Norm = pl.Axis().Direction();
253 Dnu = Dnv = gp_Vec(0.,0.,0.);
259 gp_Sphere sp(TheSurfaceTool::Sphere(S));
260 ElSLib::D1(U,V,sp,P,Dnu,Dnv);
261 Norm = gp_Vec(sp.Location(),P);
262 Standard_Real Rad = sp.Radius();
272 case GeomAbs_Cylinder:
274 gp_Cylinder cy(TheSurfaceTool::Cylinder(S));
275 P = ElSLib::Value(U,V,cy);
276 Norm.SetLinearForm(Cos(U),cy.XAxis().Direction(),
277 Sin(U),cy.YAxis().Direction());
278 Dnu.SetLinearForm(-Sin(U),cy.XAxis().Direction(),
279 Cos(U),cy.YAxis().Direction());
284 Dnv = gp_Vec(0.,0.,0.);
291 gp_Cone co(TheSurfaceTool::Cone(S));
292 P = ElSLib::Value(U,V,co);
293 Standard_Real Angle = co.SemiAngle();
294 Standard_Real Sina = Sin(Angle);
295 Standard_Real Cosa = Cos(Angle);
296 Standard_Real Rad = co.RefRadius();
297 Standard_Real Vcalc = V;
298 if (Abs(V*Sina + Rad) <= RealEpsilon()) { // on est a l`apex
299 Standard_Real Vfi = TheSurfaceTool::FirstVParameter(S);
300 if (Vfi < -Rad/Sina) { // partie valide pour V < Vapex
308 if (Rad + Vcalc*Sina < 0.) {
309 Norm.SetLinearForm(Sina, co.Axis().Direction(),
310 Cosa*Cos(U),co.XAxis().Direction(),
311 Cosa*Sin(U),co.YAxis().Direction());
314 Norm.SetLinearForm(-Sina, co.Axis().Direction(),
315 Cosa*Cos(U),co.XAxis().Direction(),
316 Cosa*Sin(U),co.YAxis().Direction());
318 Dnu.SetLinearForm(-Cosa*Sin(U),co.XAxis().Direction(),
319 Cosa*Cos(U),co.YAxis().Direction());
324 Dnv = gp_Vec(0.,0.,0.);
330 gp_Vec d1u,d1v,d2u,d2v,d2uv;
331 TheSurfaceTool::D2(S,U,V,P,d1u,d1v,d2u,d2v,d2uv);
332 Norm = d1u.Crossed(d1v);
333 Dnu = d2u.Crossed(d1v) + d1u.Crossed(d2uv);
334 Dnv = d2uv.Crossed(d1v) + d1u.Crossed(d2v);