1 // Created on: 1995-10-19
2 // Created by: Laurent BOURESCHE
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Adaptor2d_HCurve2d.hxx>
19 #include <Adaptor3d_CurveOnSurface.hxx>
20 #include <Adaptor3d_HSurface.hxx>
21 #include <GeomFill_BoundWithSurf.hxx>
23 #include <gp_Pnt2d.hxx>
25 #include <gp_Vec2d.hxx>
27 #include <Law_BSpFunc.hxx>
28 #include <Law_Function.hxx>
29 #include <Standard_Type.hxx>
31 IMPLEMENT_STANDARD_RTTIEXT(GeomFill_BoundWithSurf,GeomFill_Boundary)
33 //=======================================================================
34 //function : GeomFill_BoundWithSurf
36 //=======================================================================
37 GeomFill_BoundWithSurf::GeomFill_BoundWithSurf
38 (const Adaptor3d_CurveOnSurface& CurveOnSurf,
39 const Standard_Real Tol3d,
40 const Standard_Real Tolang) :
41 GeomFill_Boundary(Tol3d,Tolang), myConS(CurveOnSurf)
46 //=======================================================================
49 //=======================================================================
51 gp_Pnt GeomFill_BoundWithSurf::Value(const Standard_Real U) const
54 if(!myPar.IsNull()) x = myPar->Value(U);
55 return myConS.Value(x);
59 //=======================================================================
62 //=======================================================================
64 void GeomFill_BoundWithSurf::D1(const Standard_Real U,
68 Standard_Real x = U, dx = 1.;
69 if(!myPar.IsNull()) myPar->D1(U,x,dx);
75 //=======================================================================
76 //function : HasNormals
78 //=======================================================================
80 Standard_Boolean GeomFill_BoundWithSurf::HasNormals() const
86 //=======================================================================
89 //=======================================================================
91 gp_Vec GeomFill_BoundWithSurf::Norm(const Standard_Real U) const
93 // voir s il ne faudrait pas utiliser LProp ou autre.
95 Standard_Failure::Raise("BoundWithSurf Norm : pas de contrainte");
97 // Handle(Adaptor3d_HSurface)& S = myConS.GetSurface();
98 // Handle(Adaptor2d_HCurve2d)& C2d = myConS.GetCurve();
101 if(!myPar.IsNull()) w = myPar->Value(U);
102 myConS.GetCurve()->Value(w).Coord(x,y);
105 myConS.GetSurface()->D1(x,y,P,Su,Sv);
112 //=======================================================================
115 //=======================================================================
117 void GeomFill_BoundWithSurf::D1Norm(const Standard_Real U,
122 Standard_Failure::Raise("BoundWithSurf Norm : pas de contrainte");
123 // Handle(Adaptor3d_HSurface)& S = myConS.GetSurface();
124 // Handle(Adaptor2d_HCurve2d)& C2d = myConS.GetCurve();
127 Standard_Real x,y,dx,dy;
128 Standard_Real w = U, dw = 1.;
129 if(!myPar.IsNull()) myPar->D1(U,w,dw);
130 myConS.GetCurve()->D1(w,P2d,V2d);
135 gp_Vec Su, Sv, Suu, Suv, Svv;
136 myConS.GetSurface()->D2(x,y,P,Su,Sv, Suu, Svv, Suv);
139 Standard_Real nsuu = N.Dot(Suu), nsuv = N.Dot(Suv), nsvv = N.Dot(Svv);
140 Standard_Real susu = Su.Dot(Su), susv = Su.Dot(Sv), svsv = Sv.Dot(Sv);
141 Standard_Real deno = (susu*svsv) - (susv*susv);
142 if(Abs(deno) < 1.e-16) {
143 // on embraye sur un calcul approche, c est mieux que rien!?!
144 gp_Vec temp = Norm(U + 1.e-12);
145 DN = N.Multiplied(-1.);
150 Standard_Real a = (-nsuu*svsv + nsuv*susv)/deno;
151 Standard_Real b = ( nsuu*susv - nsuv*susu)/deno;
152 Standard_Real c = (-nsuv*svsv + nsvv*susv)/deno;
153 Standard_Real d = ( nsuv*susv - nsvv*susu)/deno;
155 gp_Vec temp1 = Su.Multiplied(a);
156 gp_Vec temp2 = Sv.Multiplied(b);
158 temp2 = Su.Multiplied(c);
159 gp_Vec temp3 = Sv.Multiplied(d);
163 DN = temp1.Added(temp2);
168 //=======================================================================
169 //function : Reparametrize
171 //=======================================================================
173 void GeomFill_BoundWithSurf::Reparametrize(const Standard_Real First,
174 const Standard_Real Last,
175 const Standard_Boolean HasDF,
176 const Standard_Boolean HasDL,
177 const Standard_Real DF,
178 const Standard_Real DL,
179 const Standard_Boolean Rev)
181 Handle(Law_BSpline) curve = Law::Reparametrize(myConS,
185 myPar = new Law_BSpFunc();
186 Handle(Law_BSpFunc)::DownCast (myPar)->SetCurve(curve);
189 //=======================================================================
192 //=======================================================================
194 void GeomFill_BoundWithSurf::Bounds(Standard_Real& First,
195 Standard_Real& Last) const
197 if(!myPar.IsNull()) myPar->Bounds(First,Last);
199 First = myConS.FirstParameter();
200 Last = myConS.LastParameter();
205 //=======================================================================
206 //function : IsDegenerated
208 //=======================================================================
210 Standard_Boolean GeomFill_BoundWithSurf::IsDegenerated() const
212 return Standard_False;