Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1993-06-24 |
2 | // Created by: Jean Yves LEBEY | |
3 | // Copyright (c) 1993-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 | #include <TopOpeBRepTool_CurveTool.ixx> | |
23 | ||
24 | #include <ProjLib_ProjectedCurve.hxx> | |
25 | #include <BRepApprox_Approx.hxx> | |
26 | #include <BRepApprox_ApproxLine.hxx> | |
27 | #include <TopoDS.hxx> | |
28 | #include <TopoDS_Face.hxx> | |
29 | #include <Geom_BSplineCurve.hxx> | |
30 | #include <Geom2d_Line.hxx> | |
31 | #include <Geom2d_Circle.hxx> | |
32 | #include <Geom2d_Ellipse.hxx> | |
33 | #include <Geom2d_Parabola.hxx> | |
34 | #include <Geom2d_Hyperbola.hxx> | |
35 | #include <Geom2d_BSplineCurve.hxx> | |
36 | #include <TColStd_Array1OfReal.hxx> | |
37 | #include <GeomLib_CheckBSplineCurve.hxx> | |
38 | #include <GeomLib_Check2dBSplineCurve.hxx> | |
39 | #include <TColStd_Array1OfInteger.hxx> | |
40 | #include <BRepAdaptor_Surface.hxx> | |
41 | #include <GeomAdaptor_Curve.hxx> | |
42 | #include <BRepAdaptor_HSurface.hxx> | |
43 | #include <GeomAdaptor_HCurve.hxx> | |
44 | #include <GeomAbs_SurfaceType.hxx> | |
45 | #include <gp_Pln.hxx> | |
46 | #include <gp_Pnt2d.hxx> | |
47 | #include <ElSLib.hxx> | |
48 | #include <Standard_NotImplemented.hxx> | |
49 | #include <Standard_ProgramError.hxx> | |
50 | #include <OSD_Chronometer.hxx> | |
51 | ||
52 | #include <GeomTools_Curve2dSet.hxx> | |
53 | #include <TColStd_Array1OfBoolean.hxx> | |
54 | #include <gp_Lin.hxx> | |
55 | #include <gce_MakeLin.hxx> | |
56 | #include <gp_Lin2d.hxx> | |
57 | #include <gce_MakeLin2d.hxx> | |
58 | #include <BRepTools.hxx> | |
59 | #include <Precision.hxx> | |
60 | #include <gce_MakeCirc.hxx> | |
61 | #include <gp_Vec.hxx> | |
62 | //#include <Approx.hxx> | |
63 | #include <Geom_Surface.hxx> | |
64 | #include <TopLoc_Location.hxx> | |
65 | #include <Geom_RectangularTrimmedSurface.hxx> | |
66 | #include <BRep_Tool.hxx> | |
67 | ||
7fd59977 | 68 | #ifdef DEB |
69 | #include <TopOpeBRepTool_KRO.hxx> | |
70 | TOPKRO KRO_CURVETOOL_APPRO("approximation"); | |
1d0a9d4d | 71 | extern Standard_Boolean TopOpeBRepTool_GettraceKRO(); |
72 | extern Standard_Boolean TopOpeBRepTool_GettracePCURV(); | |
73 | extern Standard_Boolean TopOpeBRepTool_GettraceCHKBSPL(); | |
7fd59977 | 74 | #endif |
75 | //#define DRAW | |
76 | //#define IFV | |
77 | #define CurveImprovement | |
78 | #ifdef DRAW | |
79 | #include <DrawTrSurf.hxx> | |
80 | static Standard_Integer NbCalls = 0; | |
81 | #endif | |
82 | //======================================================================= | |
83 | //function : CurveTool | |
84 | //purpose : | |
85 | //======================================================================= | |
86 | ||
87 | TopOpeBRepTool_CurveTool::TopOpeBRepTool_CurveTool() | |
88 | {} | |
89 | ||
90 | //======================================================================= | |
91 | //function : CurveTool | |
92 | //purpose : | |
93 | //======================================================================= | |
94 | ||
95 | TopOpeBRepTool_CurveTool::TopOpeBRepTool_CurveTool | |
96 | (const TopOpeBRepTool_OutCurveType O) | |
97 | { | |
98 | TopOpeBRepTool_GeomTool GT(O); | |
99 | SetGeomTool(GT); | |
100 | } | |
101 | ||
102 | //======================================================================= | |
103 | //function : CurveTool | |
104 | //purpose : | |
105 | //======================================================================= | |
106 | ||
107 | TopOpeBRepTool_CurveTool::TopOpeBRepTool_CurveTool | |
108 | (const TopOpeBRepTool_GeomTool& GT) | |
109 | { | |
110 | SetGeomTool(GT); | |
111 | } | |
112 | ||
113 | //======================================================================= | |
114 | //function : ChangeGeomTool | |
115 | //purpose : | |
116 | //======================================================================= | |
117 | ||
118 | TopOpeBRepTool_GeomTool& TopOpeBRepTool_CurveTool::ChangeGeomTool() | |
119 | { | |
120 | return myGeomTool; | |
121 | } | |
122 | ||
123 | //======================================================================= | |
124 | //function : GetGeomTool | |
125 | //purpose : | |
126 | //======================================================================= | |
127 | ||
128 | const TopOpeBRepTool_GeomTool& TopOpeBRepTool_CurveTool::GetGeomTool()const | |
129 | { | |
130 | return myGeomTool; | |
131 | } | |
132 | ||
133 | //======================================================================= | |
134 | //function : SetGeomTool | |
135 | //purpose : | |
136 | //======================================================================= | |
137 | ||
138 | void TopOpeBRepTool_CurveTool::SetGeomTool | |
139 | (const TopOpeBRepTool_GeomTool& GT) | |
140 | { | |
141 | myGeomTool.Define(GT); | |
142 | } | |
143 | ||
144 | //----------------------------------------------------------------------- | |
145 | //function : MakePCurve | |
146 | //purpose : | |
147 | //----------------------------------------------------------------------- | |
148 | Standard_EXPORT Handle(Geom2d_Curve) MakePCurve(const ProjLib_ProjectedCurve& PC) | |
149 | { | |
150 | Handle(Geom2d_Curve) C2D; | |
151 | switch (PC.GetType()) { | |
152 | case GeomAbs_Line : C2D = new Geom2d_Line(PC.Line()); break; | |
153 | case GeomAbs_Circle : C2D = new Geom2d_Circle(PC.Circle()); break; | |
154 | case GeomAbs_Ellipse : C2D = new Geom2d_Ellipse(PC.Ellipse()); break; | |
155 | case GeomAbs_Parabola : C2D = new Geom2d_Parabola(PC.Parabola()); break; | |
156 | case GeomAbs_Hyperbola : C2D = new Geom2d_Hyperbola(PC.Hyperbola()); break; | |
157 | case GeomAbs_BSplineCurve : C2D = PC.BSpline(); break; | |
158 | case GeomAbs_BezierCurve : case GeomAbs_OtherCurve : default : | |
159 | Standard_NotImplemented::Raise("CurveTool::MakePCurve"); | |
160 | break; | |
161 | } | |
162 | return C2D; | |
163 | } | |
164 | ||
165 | //------------------------------------------------------------------ | |
166 | static Standard_Boolean CheckApproxResults | |
167 | (const BRepApprox_Approx& Approx) | |
168 | //------------------------------------------------------------------ | |
169 | { | |
170 | const AppParCurves_MultiBSpCurve& amc = Approx.Value(1); | |
171 | Standard_Integer np = amc.NbPoles(); | |
172 | Standard_Integer nc = amc.NbCurves(); | |
173 | if (np < 2 || nc < 1) return Standard_False; | |
174 | ||
175 | // check the knots for coincidence | |
176 | const TColStd_Array1OfReal& knots = amc.Knots(); | |
177 | for (Standard_Integer i = knots.Lower(); i < knots.Upper(); i++) { | |
178 | if (knots(i+1) - knots(i) <= Epsilon(knots(i))) { | |
179 | return Standard_False; | |
180 | } | |
181 | } | |
182 | return Standard_True; | |
183 | } | |
184 | ||
185 | //------------------------------------------------------------------ | |
186 | static Standard_Boolean CheckPCurve | |
187 | (const Handle(Geom2d_Curve)& aPC, const TopoDS_Face& aFace) | |
188 | //------------------------------------------------------------------ | |
189 | // check if points of the pcurve are out of the face bounds | |
190 | { | |
191 | const Standard_Integer NPoints = 23; | |
192 | Standard_Real umin,umax,vmin,vmax; | |
193 | ||
194 | BRepTools::UVBounds(aFace, umin, umax, vmin, vmax); | |
195 | Standard_Real tolU = Max ((umax-umin)*0.01, Precision::Confusion()); | |
196 | Standard_Real tolV = Max ((vmax-vmin)*0.01, Precision::Confusion()); | |
197 | Standard_Real fp = aPC->FirstParameter(); | |
198 | Standard_Real lp = aPC->LastParameter(); | |
199 | Standard_Real step = (lp-fp)/(NPoints+1); | |
200 | ||
201 | // adjust domain for periodic surfaces | |
202 | TopLoc_Location aLoc; | |
203 | Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace, aLoc); | |
204 | if (aSurf->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) | |
205 | aSurf = (Handle(Geom_RectangularTrimmedSurface)::DownCast(aSurf))->BasisSurface(); | |
206 | ||
207 | gp_Pnt2d pnt = aPC->Value((fp+lp)/2); | |
208 | Standard_Real u,v; | |
209 | pnt.Coord(u,v); | |
210 | ||
211 | if (aSurf->IsUPeriodic()) { | |
212 | Standard_Real aPer = aSurf->UPeriod(); | |
213 | Standard_Integer nshift = (Standard_Integer) ((u-umin)/aPer); | |
214 | if (u < umin+aPer*nshift) nshift--; | |
215 | umin += aPer*nshift; | |
216 | umax += aPer*nshift; | |
217 | } | |
218 | if (aSurf->IsVPeriodic()) { | |
219 | Standard_Real aPer = aSurf->VPeriod(); | |
220 | Standard_Integer nshift = (Standard_Integer) ((v-vmin)/aPer); | |
221 | if (v < vmin+aPer*nshift) nshift--; | |
222 | vmin += aPer*nshift; | |
223 | vmax += aPer*nshift; | |
224 | } | |
225 | ||
226 | Standard_Integer i; | |
227 | for (i=1; i <= NPoints; i++) { | |
228 | Standard_Real p = fp + i * step; | |
229 | pnt = aPC->Value(p); | |
230 | pnt.Coord(u,v); | |
231 | if (umin-u > tolU || u-umax > tolU || | |
232 | vmin-v > tolV || v-vmax > tolV) | |
233 | return Standard_False; | |
234 | } | |
235 | return Standard_True; | |
236 | } | |
237 | ||
238 | //------------------------------------------------------------------ | |
239 | static Handle(Geom_Curve) MakeCurve3DfromWLineApprox | |
240 | (const BRepApprox_Approx& Approx,const Standard_Integer ) | |
241 | //------------------------------------------------------------------ | |
242 | { | |
243 | const AppParCurves_MultiBSpCurve& amc = Approx.Value(1); | |
244 | Standard_Integer np = amc.NbPoles(); | |
245 | //Standard_Integer nc = amc.NbCurves(); | |
246 | TColgp_Array1OfPnt poles3d(1,np); | |
247 | Standard_Integer ic = 1; | |
248 | //for (ic=1; ic<=nc; ic++) { | |
249 | //if (ic == CI) { | |
250 | amc.Curve(ic,poles3d); | |
251 | //} | |
252 | //} | |
253 | ||
254 | const TColStd_Array1OfReal& knots = amc.Knots(); | |
255 | const TColStd_Array1OfInteger& mults = amc.Multiplicities(); | |
256 | Standard_Integer degree = amc.Degree(); | |
257 | Handle(Geom_Curve) C3D = new Geom_BSplineCurve(poles3d,knots,mults,degree); | |
258 | return C3D; | |
259 | } | |
260 | ||
261 | //------------------------------------------------------------------ | |
262 | static Handle(Geom2d_Curve) MakeCurve2DfromWLineApproxAndPlane | |
263 | (const BRepApprox_Approx& Approx,const gp_Pln& Pl) | |
264 | //------------------------------------------------------------------ | |
265 | { | |
266 | const AppParCurves_MultiBSpCurve& amc = Approx.Value(1); | |
267 | Standard_Integer np = amc.NbPoles(); | |
268 | TColgp_Array1OfPnt2d poles2d(1,np); | |
269 | TColgp_Array1OfPnt poles3d(1,np); | |
270 | amc.Curve(1,poles3d); | |
271 | for(Standard_Integer i=1; i<=np; i++) { | |
272 | Standard_Real U,V; ElSLib::Parameters(Pl,poles3d.Value(i),U,V); | |
273 | poles2d.SetValue(i,gp_Pnt2d(U,V)); | |
274 | } | |
275 | const TColStd_Array1OfReal& knots = amc.Knots(); | |
276 | const TColStd_Array1OfInteger& mults = amc.Multiplicities(); | |
277 | Standard_Integer degree = amc.Degree(); | |
278 | Handle(Geom2d_Curve) C2D = new Geom2d_BSplineCurve(poles2d,knots,mults,degree); | |
279 | return C2D; | |
280 | } | |
281 | ||
282 | //------------------------------------------------------------------ | |
283 | static Handle(Geom2d_Curve) MakeCurve2DfromWLineApprox | |
284 | (const BRepApprox_Approx& Approx,const Standard_Integer CI) | |
285 | //------------------------------------------------------------------ | |
286 | { | |
287 | const AppParCurves_MultiBSpCurve& amc = Approx.Value(1); | |
288 | Standard_Integer np = amc.NbPoles(); | |
289 | TColgp_Array1OfPnt2d poles2d(1,np); | |
290 | Standard_Integer nc = amc.NbCurves(); | |
291 | for (Standard_Integer ic=1; ic<=nc; ic++) if (ic == CI) amc.Curve(ic,poles2d); | |
292 | const TColStd_Array1OfReal& knots = amc.Knots(); | |
293 | const TColStd_Array1OfInteger& mults = amc.Multiplicities(); | |
294 | Standard_Integer degree = amc.Degree(); | |
295 | Handle(Geom2d_Curve) C2D = new Geom2d_BSplineCurve(poles2d,knots,mults,degree); | |
296 | return C2D; | |
297 | } | |
298 | ||
299 | ||
300 | //======================================================================= | |
301 | //function : MakeCurves | |
302 | //purpose : | |
303 | //======================================================================= | |
304 | ||
305 | Standard_Boolean TopOpeBRepTool_CurveTool::MakeCurves | |
306 | (const Standard_Real parmin, const Standard_Real parmax, | |
307 | const Handle(Geom_Curve)& C3D, | |
308 | const Handle(Geom2d_Curve)& PC1, const Handle(Geom2d_Curve)& PC2, | |
309 | const TopoDS_Shape& S1, const TopoDS_Shape& S2, | |
310 | Handle(Geom_Curve)& C3Dnew, | |
311 | Handle(Geom2d_Curve)& PC1new, Handle(Geom2d_Curve)& PC2new, | |
312 | Standard_Real& TolReached3d, Standard_Real& TolReached2d) const | |
313 | { | |
314 | Standard_Boolean CompC3D = myGeomTool.CompC3D(); | |
315 | ||
316 | //cout << "MakeCurves begin" << endl; | |
317 | if (!CompC3D) return Standard_False; | |
318 | ||
319 | Standard_Boolean CompPC1 = myGeomTool.CompPC1(); | |
320 | Standard_Boolean CompPC2 = myGeomTool.CompPC2(); | |
321 | Standard_Real tol3d,tol2d; | |
322 | Standard_Boolean RelativeTol; | |
323 | myGeomTool.GetTolerances(tol3d,tol2d,RelativeTol); | |
324 | Standard_Integer NbPntMax = myGeomTool.NbPntMax(); | |
325 | ||
326 | #ifdef DEB | |
327 | if (TopOpeBRepTool_GettraceKRO()) KRO_CURVETOOL_APPRO.Start(); | |
328 | #endif | |
329 | ||
330 | //---------------------------------- | |
331 | ///* | |
332 | #ifdef IFV | |
333 | char name[16]; | |
334 | char *nm = &name[0]; | |
335 | sprintf(name,"C3D_%d",++NbCalls); | |
336 | DrawTrSurf::Set(nm, C3D); | |
337 | sprintf(name,"PC1_%d",NbCalls); | |
338 | DrawTrSurf::Set(nm, PC1); | |
339 | sprintf(name,"PC2_%d",NbCalls); | |
340 | DrawTrSurf::Set(nm, PC2); | |
341 | #endif | |
342 | //*/ | |
343 | //--------------------------------------------- | |
344 | ||
345 | Standard_Integer iparmin = (Standard_Integer)parmin; | |
346 | Standard_Integer iparmax = (Standard_Integer)parmax; | |
347 | ||
348 | Handle(Geom_BSplineCurve)& HC3D = *((Handle(Geom_BSplineCurve)*)&C3D); | |
349 | Handle(Geom2d_BSplineCurve)& HPC1 = *((Handle(Geom2d_BSplineCurve)*)&PC1); | |
350 | Handle(Geom2d_BSplineCurve)& HPC2 = *((Handle(Geom2d_BSplineCurve)*)&PC2); | |
351 | ||
352 | //--------------------- IFV - "improving" initial curves | |
353 | #ifdef CurveImprovement | |
354 | Standard_Integer nbpol = HC3D->NbPoles(); | |
355 | //cout <<"nbpol = " << nbpol << endl; | |
356 | if(nbpol > 100) { | |
357 | TColgp_Array1OfPnt PolC3D(1, nbpol); | |
358 | TColgp_Array1OfPnt2d PolPC1(1, nbpol); | |
359 | TColgp_Array1OfPnt2d PolPC2(1, nbpol); | |
360 | TColStd_Array1OfBoolean IsValid(1, nbpol); | |
361 | IsValid.Init(Standard_True); | |
362 | Standard_Real tol = Max(1.e-10, 100.*tol3d*tol3d); //tol *= tol; - square distance | |
363 | Standard_Real tl2d = tol*(tol2d*tol2d)/(tol3d*tol3d); | |
364 | Standard_Real def = tol; | |
365 | Standard_Real def2d = tol2d; | |
366 | HC3D->Poles(PolC3D); | |
367 | if(CompPC1) HPC1->Poles(PolPC1); | |
368 | if(CompPC2) HPC2->Poles(PolPC2); | |
369 | ||
370 | Standard_Integer ip = 1, NbPol = 1; | |
371 | Standard_Real d, d1, d2; | |
372 | gp_Pnt P = PolC3D(ip); | |
373 | gp_Pnt2d P1, P2; | |
374 | if(CompPC1) P1 = PolPC1(ip); | |
375 | if(CompPC2) P2 = PolPC2(ip); | |
376 | ||
377 | for(ip = 2; ip <= nbpol; ip++) { | |
378 | if( IsValid(ip) ) { | |
379 | d = P.SquareDistance(PolC3D(ip)); | |
380 | if(CompPC1) {d1 = P1.SquareDistance(PolPC1(ip));} else {d1 = 0.;} | |
381 | if(CompPC2) {d2 = P2.SquareDistance(PolPC2(ip));} else {d2 = 0.;} | |
382 | if(d > tol || d1 > tl2d || d2 > tl2d ) { | |
383 | Standard_Real dd=0.; | |
384 | if(ip < nbpol ) dd = P.Distance(PolC3D(ip+1)); | |
385 | if(ip < nbpol && dd < 10.*tol) { | |
386 | gce_MakeLin mkL(P, PolC3D(ip+1)); | |
387 | if(mkL.IsDone()) { | |
388 | gp_Lin L = mkL.Value(); | |
389 | d = L.SquareDistance(PolC3D(ip)); | |
390 | if(CompPC1) { | |
391 | gp_Lin2d L1 = gce_MakeLin2d(P1, PolPC1(ip+1)); | |
392 | d1 = L1.SquareDistance(PolPC1(ip)); | |
393 | } | |
394 | else d1 = 0.; | |
395 | if(CompPC2) { | |
396 | gp_Lin2d L2 = gce_MakeLin2d(P2, PolPC2(ip+1)); | |
397 | d2 = L2.SquareDistance(PolPC2(ip)); | |
398 | } | |
399 | else d2 = 0.; | |
400 | ||
401 | if(d > def || d1 > def2d || d2 > def2d ) { | |
402 | NbPol++; | |
403 | P = PolC3D(ip); | |
404 | if(CompPC1) P1 = PolPC1(ip); | |
405 | if(CompPC2) P2 = PolPC2(ip); | |
406 | } | |
407 | else { | |
408 | IsValid(ip) = Standard_False; | |
409 | } | |
410 | } | |
411 | else { | |
412 | IsValid(ip+1) = Standard_False; | |
413 | NbPol++; | |
414 | P = PolC3D(ip); | |
415 | if(CompPC1) P1 = PolPC1(ip); | |
416 | if(CompPC2) P2 = PolPC2(ip); | |
417 | } | |
418 | } | |
419 | else { | |
420 | NbPol++; | |
421 | P = PolC3D(ip); | |
422 | if(CompPC1) P1 = PolPC1(ip); | |
423 | if(CompPC2) P2 = PolPC2(ip); | |
424 | } | |
425 | } | |
426 | else { | |
427 | IsValid(ip) = Standard_False; | |
428 | } | |
429 | } | |
430 | } | |
431 | ||
432 | if(NbPol < 2) {IsValid(nbpol) = Standard_True; NbPol++;} | |
433 | ||
434 | if(NbPol < nbpol) { | |
435 | #ifdef IFV | |
436 | cout << "NbPol < nbpol : " << NbPol << " " << nbpol << endl; | |
437 | #endif | |
438 | TColgp_Array1OfPnt Polc3d(1, NbPol); | |
439 | TColgp_Array1OfPnt2d Polpc1(1, NbPol); | |
440 | TColgp_Array1OfPnt2d Polpc2(1, NbPol); | |
441 | TColStd_Array1OfReal knots(1,NbPol); | |
442 | TColStd_Array1OfInteger mults(1,NbPol); | |
443 | mults.Init(1); mults(1) = 2; mults(NbPol) = 2; | |
444 | Standard_Integer count = 0; | |
445 | for(ip = 1; ip <= nbpol; ip++) { | |
446 | if(IsValid(ip)) { | |
447 | count++; | |
448 | Polc3d(count) = PolC3D(ip); | |
449 | if(CompPC1) Polpc1(count) = PolPC1(ip); | |
450 | if(CompPC2) Polpc2(count) = PolPC2(ip); | |
451 | knots(count) = count; | |
452 | } | |
453 | } | |
454 | ||
455 | Polc3d(NbPol) = PolC3D(nbpol); | |
456 | if(CompPC1) Polpc1(NbPol) = PolPC1(nbpol); | |
457 | if(CompPC2) Polpc2(NbPol) = PolPC2(nbpol); | |
458 | ||
459 | HC3D = new Geom_BSplineCurve(Polc3d, knots, mults, 1); | |
460 | if(CompPC1) HPC1 = new Geom2d_BSplineCurve(Polpc1, knots, mults, 1); | |
461 | if(CompPC2) HPC2 = new Geom2d_BSplineCurve(Polpc2, knots, mults, 1); | |
462 | iparmax = NbPol; | |
463 | ||
464 | #ifdef IFV | |
465 | sprintf(name,"C3Dmod_%d",NbCalls); | |
466 | nm = &name[0]; | |
467 | DrawTrSurf::Set(nm, HC3D); | |
468 | sprintf(name,"PC1mod_%d",NbCalls); | |
469 | nm = &name[0]; | |
470 | DrawTrSurf::Set(nm, HPC1); | |
471 | sprintf(name,"PC2mod_%d",NbCalls); | |
472 | nm = &name[0]; | |
473 | DrawTrSurf::Set(nm, HPC2); | |
474 | #endif | |
475 | ||
476 | } | |
477 | } | |
478 | //--------------- IFV - end "improving" | |
479 | #endif | |
480 | ||
481 | ||
482 | BRepApprox_Approx Approx; | |
483 | ||
484 | Standard_Integer degmin = 4; | |
485 | Standard_Integer degmax = 8; | |
486 | Approx_ParametrizationType parametrization = Approx_ChordLength; | |
487 | ||
488 | Standard_Integer npol = HC3D->NbPoles(); | |
489 | TColgp_Array1OfPnt Polc3d(1, npol); | |
490 | TColStd_Array1OfReal par(1, npol); | |
491 | HC3D->Poles(Polc3d); | |
492 | gp_Pnt P = Polc3d(1); | |
493 | ||
494 | Standard_Boolean IsBad = Standard_False; | |
495 | Standard_Integer ip; | |
496 | Standard_Real ksi = 0., kc, kcprev = 0.; | |
497 | Standard_Real dist; | |
498 | par(1) = 0.; | |
499 | for(ip = 2; ip <= npol; ip++) { | |
500 | dist = P.Distance(Polc3d(ip)); | |
501 | ||
502 | if(dist < Precision::Confusion()) { | |
503 | IsBad = Standard_True; | |
504 | break; | |
505 | } | |
506 | ||
507 | par(ip) = par(ip-1) + dist; | |
508 | P = Polc3d(ip); | |
509 | } | |
510 | ||
511 | if(!IsBad) { | |
512 | ||
513 | TColStd_Array1OfReal Curvature(1, npol); | |
514 | ||
515 | if(npol > 3) { | |
516 | Standard_Integer ic = 1; | |
517 | for(ip = 2; ip <= npol-1; ip += npol-3) { | |
518 | gp_Vec v1(Polc3d(ip-1),Polc3d(ip)); | |
519 | gp_Vec v2(Polc3d(ip),Polc3d(ip+1)); | |
520 | if(!v1.IsParallel(v2, 1.e-4)) { | |
521 | gce_MakeCirc mc(Polc3d(ip-1),Polc3d(ip),Polc3d(ip+1)); | |
522 | gp_Circ cir = mc.Value(); | |
523 | kc = 1./cir.Radius(); | |
524 | } | |
525 | else kc = 0.; | |
526 | ||
527 | Curvature(ic) = kc; | |
528 | ic = npol; | |
529 | } | |
530 | } | |
531 | else if(npol == 3) { | |
532 | ip = 2; | |
533 | gp_Vec v1(Polc3d(ip-1),Polc3d(ip)); | |
534 | gp_Vec v2(Polc3d(ip),Polc3d(ip+1)); | |
535 | if(!v1.IsParallel(v2, 1.e-4)) { | |
536 | gce_MakeCirc mc(Polc3d(ip-1),Polc3d(ip),Polc3d(ip+1)); | |
537 | gp_Circ cir = mc.Value(); | |
538 | kc = 1./cir.Radius(); | |
539 | } | |
540 | else kc = 0.; | |
541 | Curvature(1) = Curvature(npol) = kc; | |
542 | } | |
543 | else { | |
544 | Curvature(1) = Curvature(npol) = 0.; | |
545 | } | |
546 | ||
547 | ip = 1; | |
548 | Standard_Real dt = par(ip+1) - par(ip); | |
549 | Standard_Real dx = (Polc3d(ip+1).X() - Polc3d(ip).X())/dt, | |
550 | dy = (Polc3d(ip+1).Y() - Polc3d(ip).Y())/dt, | |
551 | dz = (Polc3d(ip+1).Z() - Polc3d(ip).Z())/dt; | |
552 | Standard_Real dx1, dy1, dz1, d2x, d2y, d2z, d2t; | |
553 | ||
554 | for(ip = 2; ip <= npol-1; ip++) { | |
555 | dt = par(ip+1) - par(ip); | |
556 | dx1 = (Polc3d(ip+1).X() - Polc3d(ip).X())/dt; | |
557 | dy1 = (Polc3d(ip+1).Y() - Polc3d(ip).Y())/dt, | |
558 | dz1 = (Polc3d(ip+1).Z() - Polc3d(ip).Z())/dt; | |
559 | d2t = 2./(par(ip+1) - par(ip-1)); | |
560 | d2x = d2t*(dx1 - dx); | |
561 | d2y = d2t*(dy1 - dy); | |
562 | d2z = d2t*(dz1 - dz); | |
563 | Curvature(ip) = Sqrt(d2x*d2x + d2y*d2y + d2z*d2z); | |
564 | dx = dx1; dy = dy1; dz = dz1; | |
565 | } | |
566 | ||
567 | Standard_Real crit = 1000.; // empirical criterion !!! | |
568 | ||
569 | dt = par(2) - par(1); | |
570 | kcprev = (Curvature(2) - Curvature(1))/dt; | |
571 | for(ip = 2; ip <= npol-1; ip++) { | |
572 | dt = par(ip+1) - par(ip); | |
573 | kc = (Curvature(ip+1) - Curvature(ip))/dt; | |
574 | ksi = ksi + Abs(kc - kcprev); | |
575 | if(ksi > crit) {IsBad = Standard_True;break;} | |
576 | kc = kcprev; | |
577 | } | |
578 | ||
579 | } | |
580 | //cout << NbCalls << " ksi = " << ksi << endl; | |
581 | //cout << "IsBad = " << IsBad << endl; | |
582 | ||
583 | if(IsBad){ | |
584 | Standard_Real tt = Min(10.*tol3d,Precision::Approximation()); | |
585 | tol2d = tt * tol2d / tol3d; | |
586 | tol3d = tt; | |
587 | NbPntMax = 40; | |
588 | degmax = 4; | |
589 | parametrization = Approx_Centripetal; | |
590 | } | |
591 | ||
592 | Standard_Integer nitmax = 0; // use projection only | |
593 | Standard_Boolean withtangency = Standard_True; | |
594 | ||
595 | Standard_Boolean compminmaxUV = Standard_True; | |
596 | BRepAdaptor_Surface BAS1(TopoDS::Face(S1),compminmaxUV); | |
597 | BRepAdaptor_Surface BAS2(TopoDS::Face(S2),compminmaxUV); | |
598 | ||
599 | ||
600 | Handle(BRepApprox_ApproxLine) AL; | |
601 | AL = new BRepApprox_ApproxLine(HC3D,HPC1,HPC2); | |
602 | ||
603 | Approx.SetParameters(tol3d,tol2d,RelativeTol,degmin,degmax,nitmax,NbPntMax,withtangency, | |
604 | parametrization); | |
605 | ||
606 | if (CompC3D && CompPC1 && BAS1.GetType() == GeomAbs_Plane) { | |
607 | //-- The curve X,Y,Z and U2,V2 is approximated | |
608 | Approx.Perform(BAS1,BAS2,AL,CompC3D,Standard_False,CompPC2,iparmin,iparmax); | |
609 | } | |
610 | ||
611 | else if(CompC3D && CompPC2 && BAS2.GetType() == GeomAbs_Plane) { | |
612 | //-- The curve X,Y,Z and U1,V1 is approximated | |
613 | Approx.Perform(BAS1,BAS2,AL,CompC3D,CompPC1,Standard_False,iparmin,iparmax); | |
614 | } | |
615 | ||
616 | else { | |
617 | Approx.Perform(BAS1,BAS2,AL,CompC3D,CompPC1,CompPC2,iparmin,iparmax); | |
618 | } | |
619 | ||
620 | // MSV Nov 9, 2001: do not raise exception in the case of failure, | |
621 | // but return status | |
622 | ||
623 | Standard_Boolean done = Approx.IsDone(); | |
624 | done = done && CheckApproxResults(Approx); | |
625 | ||
626 | if (done) { | |
627 | if (CompC3D && CompPC1 && BAS1.GetType() == GeomAbs_Plane) { | |
628 | C3Dnew = ::MakeCurve3DfromWLineApprox(Approx,1); | |
629 | PC1new = ::MakeCurve2DfromWLineApproxAndPlane(Approx,BAS1.Plane()); | |
630 | if (CompPC2) PC2new = ::MakeCurve2DfromWLineApprox(Approx,2); | |
631 | } | |
632 | else if(CompC3D && CompPC2 && BAS2.GetType() == GeomAbs_Plane) { | |
633 | C3Dnew = ::MakeCurve3DfromWLineApprox(Approx,1); | |
634 | if (CompPC1) PC1new = ::MakeCurve2DfromWLineApprox(Approx,2); | |
635 | PC2new = ::MakeCurve2DfromWLineApproxAndPlane(Approx,BAS2.Plane()); | |
636 | } | |
637 | else { | |
638 | if (CompC3D) C3Dnew = ::MakeCurve3DfromWLineApprox(Approx,1); | |
639 | if (CompPC1) PC1new = ::MakeCurve2DfromWLineApprox(Approx,2); | |
640 | if (CompPC2) { | |
641 | Standard_Integer i32 = (CompPC1) ? 3 : 2; | |
642 | PC2new = ::MakeCurve2DfromWLineApprox(Approx,i32); | |
643 | } | |
644 | } | |
645 | ||
646 | // check the pcurves relatively the faces bounds | |
647 | if (CompPC1) | |
648 | done = done && CheckPCurve(PC1new,TopoDS::Face(S1)); | |
649 | if (CompPC2) | |
650 | done = done && CheckPCurve(PC2new,TopoDS::Face(S2)); | |
651 | } | |
652 | ||
653 | if (!done) { | |
654 | if (CompC3D) C3Dnew.Nullify(); | |
655 | if (CompPC1) PC1new.Nullify(); | |
656 | if (CompPC2) PC2new.Nullify(); | |
657 | return Standard_False; | |
658 | } | |
659 | ||
660 | #ifdef IFV | |
661 | sprintf(name,"C3Dnew_%d", NbCalls); | |
662 | nm = &name[0]; | |
663 | DrawTrSurf::Set(nm, C3Dnew); | |
664 | if (CompPC1) { | |
665 | sprintf(name,"PC1new_%d", NbCalls); | |
666 | nm = &name[0]; | |
667 | DrawTrSurf::Set(nm, PC1new); | |
668 | } | |
669 | if (CompPC2) { | |
670 | sprintf(name,"PC2new_%d", NbCalls); | |
671 | nm = &name[0]; | |
672 | DrawTrSurf::Set(nm, PC2new); | |
673 | } | |
674 | ||
675 | #endif | |
676 | ||
677 | TolReached3d = Approx.TolReached3d(); | |
678 | TolReached2d = Approx.TolReached2d(); | |
679 | #ifdef IFV | |
680 | cout << NbCalls << " : Tol = " << TolReached3d << " " << TolReached2d << endl; | |
681 | #endif | |
682 | ||
683 | Standard_Boolean bf, bl; | |
684 | ||
685 | const Handle(Geom_BSplineCurve)& Curve = Handle(Geom_BSplineCurve)::DownCast(C3Dnew); | |
686 | if(!Curve.IsNull()) { | |
687 | GeomLib_CheckBSplineCurve cbsc(Curve, 1.e-7, 0.1); | |
688 | cbsc.NeedTangentFix(bf, bl); | |
689 | ||
690 | #ifdef DEB | |
691 | if (TopOpeBRepTool_GettraceCHKBSPL()) { | |
692 | if(bf || bl) { | |
693 | cout<<"Problem orientation GeomLib_CheckBSplineCurve : First = "<<bf; | |
694 | cout<<" Last = "<<bl<<endl; | |
695 | } | |
696 | } | |
697 | #endif | |
698 | cbsc.FixTangent(bf, bl); | |
699 | } | |
700 | ||
701 | const Handle(Geom2d_BSplineCurve)& Curve2df = Handle(Geom2d_BSplineCurve)::DownCast(PC1new); | |
702 | if(!Curve2df.IsNull()) { | |
703 | GeomLib_Check2dBSplineCurve cbsc2df(Curve2df, 1.e-7, 0.1); | |
704 | cbsc2df.NeedTangentFix(bf, bl); | |
705 | #ifdef DEB | |
706 | if (TopOpeBRepTool_GettraceCHKBSPL()) { | |
707 | if(bf || bl) { | |
708 | cout<<"Problem orientation GeomLib_CheckBSplineCurve : First = "<<bf; | |
709 | cout<<" Last = "<<bl<<endl; | |
710 | } | |
711 | } | |
712 | #endif | |
713 | cbsc2df.FixTangent(bf, bl); | |
714 | } | |
715 | ||
716 | const Handle(Geom2d_BSplineCurve)& Curve2ds = Handle(Geom2d_BSplineCurve)::DownCast(PC2new); | |
717 | if(!Curve2ds.IsNull()) { | |
718 | GeomLib_Check2dBSplineCurve cbsc2ds(Curve2ds, 1.e-7, 0.1); | |
719 | cbsc2ds.NeedTangentFix(bf, bl); | |
720 | #ifdef DEB | |
721 | if (TopOpeBRepTool_GettraceCHKBSPL()) { | |
722 | if(bf || bl) { | |
723 | cout<<"Problem orientation GeomLib_CheckBSplineCurve : First = "<<bf; | |
724 | cout<<" Last = "<<bl<<endl; | |
725 | } | |
726 | } | |
727 | #endif | |
728 | cbsc2ds.FixTangent(bf, bl); | |
729 | } | |
730 | ||
731 | #ifdef DEB | |
732 | if (TopOpeBRepTool_GettraceKRO()) KRO_CURVETOOL_APPRO.Stop(); | |
733 | #endif | |
734 | // cout << "MakeCurves end" << endl; | |
735 | ||
736 | return Standard_True; | |
737 | } | |
738 | ||
739 | ||
740 | //======================================================================= | |
741 | //function : MakeBSpline1fromPnt | |
742 | //purpose : | |
743 | //======================================================================= | |
744 | ||
745 | Handle(Geom_Curve) TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt | |
746 | (const TColgp_Array1OfPnt& Points) | |
747 | { | |
748 | Standard_Integer Degree = 1; | |
749 | ||
750 | Standard_Integer i,nbpoints = Points.Length(); | |
751 | Standard_Integer nbknots = nbpoints - Degree +1; | |
752 | ||
753 | // First compute the parameters | |
754 | // Standard_Real length = 0.; | |
755 | // TColStd_Array1OfReal parameters(1,nbpoints); | |
756 | // for (i = 1; i < nbpoints; i++) { | |
757 | // parameters(i) = length; | |
758 | // Standard_Real dist = Points(i).Distance(Points(i+1)); | |
759 | // length += dist; | |
760 | // } | |
761 | // parameters(nbpoints) = length; | |
762 | ||
763 | // knots and multiplicities | |
764 | TColStd_Array1OfReal knots(1,nbknots); | |
765 | TColStd_Array1OfInteger mults(1,nbknots); | |
766 | mults.Init(1); | |
767 | mults(1) = mults(nbknots) = Degree + 1; | |
768 | ||
769 | // knots(1) = 0; | |
770 | // for (i=2;i<nbknots;i++) knots(i) = (parameters(i) + parameters(i+1)) /2.; | |
771 | // knots(nbknots) = length; | |
772 | ||
773 | // take point index as parameter : JYL 01/AUG/94 | |
774 | for (i = 1; i <= nbknots; i++) knots(i) = (Standard_Real)i; | |
775 | Handle(Geom_Curve) C = new Geom_BSplineCurve(Points,knots,mults,Degree); | |
776 | return C; | |
777 | } | |
778 | ||
779 | ||
780 | //======================================================================= | |
781 | //function : MakeBSpline1fromPnt2d | |
782 | //purpose : | |
783 | //======================================================================= | |
784 | ||
785 | Handle(Geom2d_Curve) TopOpeBRepTool_CurveTool::MakeBSpline1fromPnt2d | |
786 | (const TColgp_Array1OfPnt2d& Points) | |
787 | { | |
788 | Standard_Integer Degree = 1; | |
789 | ||
790 | Standard_Integer i,nbpoints = Points.Length(); | |
791 | Standard_Integer nbknots = nbpoints - Degree +1; | |
792 | ||
793 | // First compute the parameters | |
794 | // Standard_Real length = 0; | |
795 | // TColStd_Array1OfReal parameters(1,nbpoints); | |
796 | // for (i = 1; i < nbpoints; i++) { | |
797 | // parameters(i) = length; | |
798 | // Standard_Real dist = Points(i).Distance(Points(i+1)); | |
799 | // length += dist; | |
800 | // } | |
801 | // parameters(nbpoints) = length; | |
802 | ||
803 | // knots and multiplicities | |
804 | TColStd_Array1OfReal knots(1,nbknots); | |
805 | TColStd_Array1OfInteger mults(1,nbknots); | |
806 | mults.Init(1); | |
807 | mults(1) = mults(nbknots) = Degree + 1; | |
808 | ||
809 | // knots(1) = 0; | |
810 | // for (i=2;i<nbknots;i++) knots(i) = (parameters(i) + parameters(i+1)) /2.; | |
811 | // knots(nbknots) = length; | |
812 | ||
813 | // take point index as parameter : JYL 01/AUG/94 | |
814 | for (i = 1; i <= nbknots; i++) knots(i) = (Standard_Real)i; | |
815 | Handle(Geom2d_Curve) C = new Geom2d_BSplineCurve(Points,knots,mults,Degree); | |
816 | return C; | |
817 | } | |
818 | ||
819 | //======================================================================= | |
820 | //function : IsProjectable | |
821 | //purpose : | |
822 | //======================================================================= | |
823 | ||
824 | Standard_Boolean TopOpeBRepTool_CurveTool::IsProjectable | |
825 | (const TopoDS_Shape& S, const Handle(Geom_Curve)& C3D) | |
826 | { | |
827 | const TopoDS_Face& F = TopoDS::Face(S); | |
828 | Standard_Boolean compminmaxUV = Standard_False; | |
829 | BRepAdaptor_Surface BAS(F,compminmaxUV); | |
830 | GeomAbs_SurfaceType suty = BAS.GetType(); | |
831 | GeomAdaptor_Curve GAC(C3D); | |
832 | GeomAbs_CurveType cuty = GAC.GetType(); | |
833 | ||
834 | // -------- | |
835 | // avoid projection of 3d curve on surface in case | |
836 | // of a quadric (ellipse,hyperbola,parabola) on a cone. | |
837 | // Projection fails when the curve in not fully inside the UV domain | |
838 | // of the cone : only part of 2d curve is built. | |
839 | // NYI : projection of quadric on cone (crossing cone domain) | |
840 | // -------- | |
841 | ||
842 | Standard_Boolean projectable = Standard_True; | |
843 | if ( suty == GeomAbs_Cone ) { | |
844 | if( (cuty == GeomAbs_Ellipse) || | |
845 | ( cuty == GeomAbs_Hyperbola) || | |
846 | ( cuty == GeomAbs_Parabola) ) { | |
847 | projectable = Standard_False; | |
848 | } | |
849 | } | |
850 | else if ( suty == GeomAbs_Cylinder ) { | |
851 | if (cuty == GeomAbs_Ellipse) { | |
852 | projectable = Standard_False; | |
853 | } | |
854 | } | |
855 | else if ( suty == GeomAbs_Sphere ) { | |
856 | if (cuty == GeomAbs_Circle) { | |
857 | projectable = Standard_False; | |
858 | } | |
859 | } | |
860 | else if ( suty == GeomAbs_Torus ) { | |
861 | if (cuty == GeomAbs_Circle) { | |
862 | projectable = Standard_False; | |
863 | } | |
864 | } | |
865 | ||
866 | #ifdef DEB | |
867 | if (TopOpeBRepTool_GettracePCURV()) { | |
868 | cout<<"--- IsProjectable : "; | |
869 | if (projectable) cout<<"projectable"<<endl; | |
870 | else cout<<"NOT projectable"<<endl; | |
871 | } | |
872 | #endif | |
873 | ||
874 | return projectable; | |
875 | } | |
876 | ||
877 | ||
878 | //======================================================================= | |
879 | //function : MakePCurveOnFace | |
880 | //purpose : | |
881 | //======================================================================= | |
882 | ||
883 | Handle(Geom2d_Curve) TopOpeBRepTool_CurveTool::MakePCurveOnFace | |
884 | (const TopoDS_Shape& S, | |
885 | const Handle(Geom_Curve)& C3D, | |
886 | Standard_Real& TolReached2d, | |
887 | const Standard_Real first, const Standard_Real last) | |
888 | ||
889 | { | |
890 | Standard_Boolean trim = Standard_False; | |
891 | if (first < last) | |
892 | trim = Standard_True; | |
893 | ||
894 | const TopoDS_Face& F = TopoDS::Face(S); | |
895 | Standard_Boolean compminmaxUV = Standard_False; | |
896 | BRepAdaptor_Surface BAS(F,compminmaxUV); | |
897 | GeomAdaptor_Curve GAC; | |
898 | if (trim) GAC.Load(C3D,first,last); | |
899 | else GAC.Load(C3D); | |
900 | Handle(BRepAdaptor_HSurface) BAHS = new BRepAdaptor_HSurface(BAS); | |
901 | Handle(GeomAdaptor_HCurve) BAHC = new GeomAdaptor_HCurve(GAC); | |
902 | ProjLib_ProjectedCurve projcurv(BAHS,BAHC); | |
903 | Handle(Geom2d_Curve) C2D = ::MakePCurve(projcurv); | |
904 | TolReached2d = projcurv.GetTolerance(); | |
905 | ||
906 | Standard_Real UMin, UMax, VMin, VMax; | |
907 | BRepTools::UVBounds(F,UMin, UMax, VMin, VMax); | |
908 | ||
909 | Standard_Real f = GAC.FirstParameter(); | |
910 | Standard_Real l = GAC.LastParameter(); | |
911 | Standard_Real t =(f+l)*.5; | |
912 | gp_Pnt2d pC2D; C2D->D0(t,pC2D); | |
913 | Standard_Real u2 = pC2D.X(); | |
914 | Standard_Real v2 = pC2D.Y(); | |
915 | ||
916 | if (BAS.GetType() == GeomAbs_Sphere) { | |
917 | // MSV: consider quasiperiodic shift of pcurve | |
918 | Standard_Real VFirst = BAS.FirstVParameter(); | |
919 | Standard_Real VLast = BAS.LastVParameter(); | |
920 | Standard_Boolean mincond = v2 < VFirst; | |
921 | Standard_Boolean maxcond = v2 > VLast; | |
922 | if (mincond || maxcond) { | |
923 | Handle(Geom2d_Curve) PCT = Handle(Geom2d_Curve)::DownCast(C2D->Copy()); | |
924 | // make mirror relative to the isoline of apex -PI/2 or PI/2 | |
925 | gp_Trsf2d aTrsf; | |
c6541a0c D |
926 | gp_Pnt2d po(0,-M_PI/2); |
927 | if (maxcond) po.SetY(M_PI/2); | |
7fd59977 | 928 | aTrsf.SetMirror(gp_Ax2d(po, gp_Dir2d(1,0))); |
929 | PCT->Transform(aTrsf); | |
930 | // add translation along U direction on PI | |
c6541a0c | 931 | gp_Vec2d vec(M_PI,0); |
7fd59977 | 932 | Standard_Real UFirst = BAS.FirstUParameter(); |
c6541a0c | 933 | if (u2-UFirst-M_PI > -1e-7) vec.Reverse(); |
7fd59977 | 934 | PCT->Translate(vec); |
935 | C2D = PCT; | |
936 | // recompute the test point | |
937 | C2D->D0(t,pC2D); | |
938 | u2 = pC2D.X(); | |
939 | v2 = pC2D.Y(); | |
940 | } | |
941 | } | |
942 | ||
943 | Standard_Real du = 0.; | |
944 | if (BAHS->IsUPeriodic()) { | |
945 | //modified by NIZHNY-MZV Thu Mar 30 10:03:15 2000 | |
946 | Standard_Boolean mincond = (UMin - u2 > 1e-7) ? Standard_True : Standard_False; | |
947 | Standard_Boolean maxcond = (u2 - UMax > 1e-7) ? Standard_True : Standard_False; | |
948 | Standard_Boolean decalu = mincond || maxcond; | |
949 | if (decalu) du = ( mincond ) ? BAHS->UPeriod() : -BAHS->UPeriod(); | |
950 | //Standard_Boolean decalu = ( u2 < UMin || u2 > UMax); | |
951 | //if (decalu) du = ( u2 < UMin ) ? BAHS->UPeriod() : -BAHS->UPeriod(); | |
952 | } | |
953 | Standard_Real dv = 0.; | |
954 | if (BAHS->IsVPeriodic()) { | |
955 | //modified by NIZHNY-MZV Thu Mar 30 10:06:24 2000 | |
956 | Standard_Boolean mincond = (VMin - v2 > 1e-7) ? Standard_True : Standard_False; | |
957 | Standard_Boolean maxcond = (v2 - VMax > 1e-7) ? Standard_True : Standard_False; | |
958 | Standard_Boolean decalv = mincond || maxcond; | |
959 | if (decalv) dv = ( mincond ) ? BAHS->VPeriod() : -BAHS->VPeriod(); | |
960 | //Standard_Boolean decalv = ( v2 < VMin || v2 > VMax); | |
961 | //if (decalv) dv = ( v2 < VMin ) ? BAHS->VPeriod() : -BAHS->VPeriod(); | |
962 | } | |
963 | ||
964 | if ( du != 0. || dv != 0.) { | |
965 | Handle(Geom2d_Curve) PCT = Handle(Geom2d_Curve)::DownCast(C2D->Copy()); | |
966 | PCT->Translate(gp_Vec2d(du,dv)); | |
967 | C2D = PCT; | |
968 | } | |
969 | ||
970 | return C2D; | |
971 | } |