1 // Created on: 1997-05-05
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1997-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.
17 // Modified: Mon Nov 3 10:24:07 1997
18 // ne traite que les GeomAdaptor_Surface;
19 // plus de reference a BRepAdaptor
22 #include <GeomPlate_CurveConstraint.ixx>
23 #include <GCPnts_AbscissaPoint.hxx>
24 #include <Adaptor2d_HCurve2d.hxx>
25 #include <Adaptor3d_HSurface.hxx>
26 #include <GeomAdaptor.hxx>
27 #include <Precision.hxx>
28 #include <GeomAdaptor_HSurface.hxx>
29 #include <GeomAdaptor_HCurve.hxx>
30 #include <ProjLib_ProjectedCurve.hxx>
31 #include <Approx_Curve2d.hxx>
32 #include <GeomAbs_Shape.hxx>
33 #include <BRepAdaptor_HSurface.hxx>
34 #include <Geom2d_BSplineCurve.hxx>
36 //---------------------------------------------------------
38 //---------------------------------------------------------
39 GeomPlate_CurveConstraint :: GeomPlate_CurveConstraint () :
44 //---------------------------------------------------------
45 // Constructeurs avec courbe sur surface
46 //---------------------------------------------------------
47 GeomPlate_CurveConstraint :: GeomPlate_CurveConstraint (const Handle(Adaptor3d_HCurveOnSurface)& Boundary,
48 const Standard_Integer Tang,
49 const Standard_Integer NPt,
50 const Standard_Real TolDist,
51 const Standard_Real TolAng,
52 const Standard_Real TolCurv
54 myFrontiere(Boundary),
60 if ((Tang<-1)||(Tang>2))
61 Standard_Failure::Raise("GeomPlate : The continuity is not G0 G1 or G2");
63 myConstG0=Standard_True;
64 myConstG1=Standard_True;
65 myConstG2=Standard_True;
66 if (myFrontiere.IsNull())
67 Standard_Failure::Raise("GeomPlate_CurveConstraint : Curve must be on a Surface");
68 Handle(Geom_Surface) Surf;
69 Handle(GeomAdaptor_HSurface) GS1;
70 GS1 = Handle(GeomAdaptor_HSurface)::DownCast(myFrontiere->ChangeCurve().GetSurface());
72 Surf=GS1->ChangeSurface().Surface();
75 // Handle(BRepAdaptor_HSurface) BS1;
76 // BS1=Handle(BRepAdaptor_HSurface)::DownCast(myFrontiere->ChangeCurve().GetSurface());
77 // Surf = BRep_Tool::Surface(BS1->ChangeSurface().Face());
78 Standard_Failure::Raise("GeomPlate_CurveConstraint : Surface must be GeomAdaptor_Surface");
80 myLProp.SetSurface(Surf);
91 //---------------------------------------------------------
92 // Constructeurs avec courbe 3d (pour continuite G0 G-1)
93 //---------------------------------------------------------
94 GeomPlate_CurveConstraint :: GeomPlate_CurveConstraint (const Handle(Adaptor3d_HCurve)& Boundary,
95 const Standard_Integer Tang,
96 const Standard_Integer NPt,
97 const Standard_Real TolDist) :
102 if ((Tang!=-1)&&(Tang!=0))
103 Standard_Failure::Raise("GeomPlate : The continuity is not G0 or G-1");
105 myConstG0=Standard_True;
106 myConstG1=Standard_True;
107 myConstG2=Standard_True;
109 myHCurve2d.Nullify();
116 //---------------------------------------------------------
117 // Fonction : FirstParameter
118 //---------------------------------------------------------
119 Standard_Real GeomPlate_CurveConstraint :: FirstParameter() const
121 if (!myHCurve2d.IsNull())
122 return myHCurve2d->FirstParameter();
123 else if (my3dCurve.IsNull())
124 return myFrontiere->FirstParameter();
126 return my3dCurve->FirstParameter();
128 //---------------------------------------------------------
129 // Fonction : LastParameter
130 //---------------------------------------------------------
131 Standard_Real GeomPlate_CurveConstraint :: LastParameter() const
133 if (!myHCurve2d.IsNull())
134 return myHCurve2d->LastParameter();
135 else if (my3dCurve.IsNull())
136 return myFrontiere->LastParameter();
138 return my3dCurve->LastParameter();
140 //---------------------------------------------------------
142 //---------------------------------------------------------
143 Standard_Real GeomPlate_CurveConstraint :: Length() const
144 { GCPnts_AbscissaPoint AP;
145 if (my3dCurve.IsNull())
146 {// GCPnts_AbscissaPoint A(myFrontiere->Curve(),AP.Length(myFrontiere->Curve())/2,myFrontiere->FirstParameter());
147 // Standard_Real toto=A.Parameter();
149 return AP.Length(myFrontiere->GetCurve());
153 { // GCPnts_AbscissaPoint A(my3dCurve->Curve(),AP.Length(my3dCurve->Curve())/2,my3dCurve->FirstParameter());
154 // Standard_Real toto=A.Parameter();
157 return AP.Length(my3dCurve->GetCurve());
164 //---------------------------------------------------------
166 //---------------------------------------------------------
167 void GeomPlate_CurveConstraint :: D0(const Standard_Real U,gp_Pnt& P) const
170 if (my3dCurve.IsNull())
171 { P2d = myFrontiere->ChangeCurve().GetCurve()->Value(U);
172 myFrontiere->ChangeCurve().GetSurface()->D0(P2d.Coord(1),P2d.Coord(2),P);
177 //---------------------------------------------------------
179 //---------------------------------------------------------
180 void GeomPlate_CurveConstraint :: D1(const Standard_Real U,
181 gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
183 if (!my3dCurve.IsNull())
184 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
186 P2d = myFrontiere->ChangeCurve().GetCurve()->Value(U);
187 myFrontiere->ChangeCurve().GetSurface()->D1(P2d.Coord(1),P2d.Coord(2),P,V1,V2);
191 //---------------------------------------------------------
193 //---------------------------------------------------------
194 void GeomPlate_CurveConstraint :: D2(const Standard_Real U,
195 gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,
196 gp_Vec& V3,gp_Vec& V4,gp_Vec& V5) const
198 if (!my3dCurve.IsNull())
199 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
201 P2d = myFrontiere->ChangeCurve().GetCurve()->Value(U);
202 myFrontiere->ChangeCurve().GetSurface()->D2(P2d.Coord(1),P2d.Coord(2),P,V1,V2,V3,V4,V5);
205 //---------------------------------------------------------
206 // Fonction : SetG0Criterion
207 //---------------------------------------------------------
208 void GeomPlate_CurveConstraint :: SetG0Criterion(const Handle(Law_Function) &G0Crit)
210 myConstG0=Standard_False;
212 //---------------------------------------------------------
213 // Fonction : SetG1Criterion
214 //---------------------------------------------------------
215 void GeomPlate_CurveConstraint :: SetG1Criterion(const Handle(Law_Function) &G1Crit)
216 { if (!my3dCurve.IsNull())
217 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
219 myConstG1=Standard_False;
221 //---------------------------------------------------------
222 // Fonction : SetG2Criterion
223 //---------------------------------------------------------
224 void GeomPlate_CurveConstraint :: SetG2Criterion(const Handle(Law_Function) &G2Crit)
225 { if (!my3dCurve.IsNull())
226 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
228 myConstG2=Standard_False;
230 //---------------------------------------------------------
231 // Fonction : G0Criterion
232 //---------------------------------------------------------
233 Standard_Real GeomPlate_CurveConstraint :: G0Criterion(const Standard_Real U) const
237 return myG0Crit->Value(U);
239 //---------------------------------------------------------
240 // Fonction : G1Criterion
241 //---------------------------------------------------------
242 Standard_Real GeomPlate_CurveConstraint :: G1Criterion(const Standard_Real U) const
243 { if (!my3dCurve.IsNull())
244 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
248 return myG1Crit->Value(U);
250 //---------------------------------------------------------
251 // Fonction : G2Criterion
252 //---------------------------------------------------------
253 Standard_Real GeomPlate_CurveConstraint :: G2Criterion(const Standard_Real U) const
254 { if (!my3dCurve.IsNull())
255 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
259 return myG2Crit->Value(U);
261 //---------------------------------------------------------
262 // Fonction : Curve2dOnSurf
263 //---------------------------------------------------------
264 Handle(Geom2d_Curve) GeomPlate_CurveConstraint :: Curve2dOnSurf () const
266 if(my2dCurve.IsNull() && !myHCurve2d.IsNull())
268 Handle(Geom2d_Curve) C2d;
269 GeomAbs_Shape Continuity = GeomAbs_C1;
270 Standard_Integer MaxDegree = 10;
271 Standard_Integer MaxSeg=20+myHCurve2d->NbIntervals(GeomAbs_C3);
272 Approx_Curve2d appr(myHCurve2d,myHCurve2d->FirstParameter(),myHCurve2d->LastParameter(),
273 myTolU,myTolV,Continuity,MaxDegree,MaxSeg);
277 else return my2dCurve;
279 //---------------------------------------------------------
280 // Fonction : SetCurve2dOnSurf
281 //---------------------------------------------------------
282 void GeomPlate_CurveConstraint :: SetCurve2dOnSurf (const Handle(Geom2d_Curve) &Curve)
285 //---------------------------------------------------------
286 // Fonction : ProjectedCurve
287 //---------------------------------------------------------
288 Handle(Adaptor2d_HCurve2d) GeomPlate_CurveConstraint :: ProjectedCurve () const
292 //---------------------------------------------------------
293 // Fonction : SetProjectedCurve
294 //---------------------------------------------------------
295 void GeomPlate_CurveConstraint :: SetProjectedCurve (const Handle(Adaptor2d_HCurve2d) &Curve,
296 const Standard_Real TolU,const Standard_Real TolV)
302 //---------------------------------------------------------
303 // Fonction : Curve3d
304 //---------------------------------------------------------
305 Handle(Adaptor3d_HCurve) GeomPlate_CurveConstraint :: Curve3d () const
306 { if (my3dCurve.IsNull())
311 //------------------------------------------------------------
312 //Fonction : NbPoints
313 //------------------------------------------------------------
314 Standard_Integer GeomPlate_CurveConstraint::NbPoints() const
318 //------------------------------------------------------------
320 //------------------------------------------------------------
321 Standard_Integer GeomPlate_CurveConstraint::Order() const
325 //------------------------------------------------------------
326 //Fonction : SetNbPoints
327 //------------------------------------------------------------
328 void GeomPlate_CurveConstraint::SetNbPoints(const Standard_Integer NewNb)
332 //------------------------------------------------------------
333 //Fonction : SetOrder
334 //------------------------------------------------------------
335 void GeomPlate_CurveConstraint::SetOrder(const Standard_Integer Order)
339 //------------------------------------------------------------
340 //Fonction : LPropSurf
341 //------------------------------------------------------------
342 GeomLProp_SLProps &GeomPlate_CurveConstraint::LPropSurf(const Standard_Real U)
343 { if (myFrontiere.IsNull())
344 Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface");
345 gp_Pnt2d P2d= myFrontiere->ChangeCurve().GetCurve()->Value(U);
346 myLProp.SetParameters(P2d.X(),P2d.Y());