0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / Adaptor3d / Adaptor3d_TopolTool.cxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14
15 #include <Adaptor2d_HCurve2d.hxx>
16 #include <Adaptor2d_HLine2d.hxx>
17 #include <Adaptor3d_HSurface.hxx>
18 #include <Adaptor3d_HVertex.hxx>
19 #include <Adaptor3d_TopolTool.hxx>
20 #include <GeomAdaptor_Surface.hxx>
21 #include <gp_Cone.hxx>
22 #include <gp_Pnt.hxx>
23 #include <gp_Pnt2d.hxx>
24 #include <gp_Trsf.hxx>
25 #include <Precision.hxx>
26 #include <Standard_DomainError.hxx>
27 #include <Standard_NotImplemented.hxx>
28 #include <Standard_Type.hxx>
29
30 IMPLEMENT_STANDARD_RTTIEXT(Adaptor3d_TopolTool,Standard_Transient)
31
32 #define myInfinite Precision::Infinite()
33
34 static void GetConeApexParam(const gp_Cone& C, Standard_Real& U, Standard_Real& V)
35 {
36   const gp_Ax3& Pos = C.Position();
37   Standard_Real Radius = C.RefRadius();
38   Standard_Real SAngle = C.SemiAngle();
39   const gp_Pnt& P = C.Apex();
40  
41   gp_Trsf T;
42   T.SetTransformation (Pos);
43   gp_Pnt Ploc = P.Transformed (T);
44
45   if(Ploc.X() ==0.0  &&  Ploc.Y()==0.0 ) {
46     U = 0.0;
47   }
48   else if ( -Radius > Ploc.Z()* Tan(SAngle) ) {
49     // the point is at the `wrong` side of the apex
50     U = atan2(-Ploc.Y(), -Ploc.X());
51   }
52   else {
53     U = atan2(Ploc.Y(),Ploc.X());
54   }
55   if      (U < -1.e-16)  U += (M_PI+M_PI);
56   else if (U < 0)        U = 0;
57
58   V =  sin(SAngle) * ( Ploc.X() * cos(U) + Ploc.Y() * sin(U) - Radius)
59     + cos(SAngle) * Ploc.Z();
60 }
61
62
63 Adaptor3d_TopolTool::Adaptor3d_TopolTool () : myNbSamplesU(-1),nbRestr(0),idRestr(0)
64                                               
65 {
66 }
67
68 Adaptor3d_TopolTool::Adaptor3d_TopolTool (const Handle(Adaptor3d_HSurface)& S)
69 {
70   Initialize(S);
71 }
72
73
74 void Adaptor3d_TopolTool::Initialize ()
75 {
76  throw Standard_NotImplemented("Adaptor3d_TopolTool::Initialize ()");
77 }
78
79 void Adaptor3d_TopolTool::Initialize (const Handle(Adaptor3d_HSurface)& S)
80 {
81   Standard_Real pinf,psup,deltap;
82   //Adaptor2d_Line2d  * Line2dPtr ;
83
84   myNbSamplesU=-1;
85   Uinf = S->FirstUParameter(); // where UIntervalFirst ??
86   Vinf = S->FirstVParameter();
87   Usup = S->LastUParameter();
88   Vsup = S->LastVParameter();
89   nbRestr = 0;
90   idRestr = 0;
91
92   Standard_Boolean Uinfinfinite = Precision::IsNegativeInfinite(Uinf);
93   Standard_Boolean Usupinfinite = Precision::IsPositiveInfinite(Usup);
94   Standard_Boolean Vinfinfinite = Precision::IsNegativeInfinite(Vinf);
95   Standard_Boolean Vsupinfinite = Precision::IsPositiveInfinite(Vsup);
96
97   if (! Vinfinfinite) {
98     deltap = Min(Usup-Uinf,2.*myInfinite);
99     if (Uinf >= -myInfinite){
100       pinf = Uinf;
101       psup = pinf + deltap;
102     }
103     else if (Usup <= myInfinite) {
104       psup = Usup;
105       pinf = psup - deltap;
106     }
107     else {
108       pinf = -myInfinite;
109       psup = myInfinite;
110     }
111
112     // Line2dPtr = new Adaptor2d_Line2d(gp_Pnt2d(0.,Vinf),gp_Dir2d(1.,0.),pinf,psup);
113     //myRestr[nbRestr] = new Adaptor2d_HLine2d(*Line2dPtr);
114     myRestr[nbRestr] = new Adaptor2d_HLine2d(Adaptor2d_Line2d(gp_Pnt2d(0.,Vinf),gp_Dir2d(1.,0.),pinf,psup));
115     nbRestr++;
116   }
117
118   if (!Usupinfinite) {
119     deltap = Min(Vsup-Vinf,2.*myInfinite);
120     if (Vinf >= -myInfinite){
121       pinf = Vinf;
122       psup = pinf + deltap;
123     }
124     else if (Vsup <= myInfinite) {
125       psup = Vsup;
126       pinf = psup - deltap;
127     }
128     else {
129       pinf = -myInfinite;
130       psup = myInfinite;
131     }
132
133
134     
135     //Line2dPtr = new Adaptor2d_Line2d(gp_Pnt2d(Usup,0.),gp_Dir2d(0.,1.),pinf,psup);
136     //myRestr[nbRestr] = new Adaptor2d_HLine2d(*Line2dPtr);
137     myRestr[nbRestr] = new Adaptor2d_HLine2d(Adaptor2d_Line2d(gp_Pnt2d(Usup,0.),gp_Dir2d(0.,1.),pinf,psup));
138     nbRestr++;
139   }
140
141   if (!Vsupinfinite) {
142     deltap = Min(Usup-Uinf,2.*myInfinite);
143     if (-Usup >= -myInfinite){
144       pinf = -Usup;
145       psup = pinf + deltap;
146     }
147     else if (-Uinf <= myInfinite) {
148       psup = -Uinf;
149       pinf = psup - deltap;
150     }
151     else {
152       pinf = -myInfinite;
153       psup = myInfinite;
154     }
155
156     
157     //Line2dPtr = new Adaptor2d_Line2d(gp_Pnt2d(0.,Vsup),gp_Dir2d(-1.,0.),pinf,psup);
158     //myRestr[nbRestr] = new Adaptor2d_HLine2d(*Line2dPtr);
159     myRestr[nbRestr] = new Adaptor2d_HLine2d(Adaptor2d_Line2d(gp_Pnt2d(0.,Vsup),gp_Dir2d(-1.,0.),pinf,psup));
160     nbRestr++;
161   }
162
163   if (!Uinfinfinite) {
164     deltap = Min(Vsup-Vinf,2.*myInfinite);
165     if (-Vsup >= -myInfinite){
166       pinf = -Vsup;
167       psup = pinf + deltap;
168     }
169     else if (-Vinf <= myInfinite) {
170       psup = -Vinf;
171       pinf = psup - deltap;
172     }
173     else {
174       pinf = -myInfinite;
175       psup = myInfinite;
176     }
177
178     //Line2dPtr = new Adaptor2d_Line2d(gp_Pnt2d(Uinf,0.),gp_Dir2d(0.,-1),pinf,psup);
179     //myRestr[nbRestr] = new Adaptor2d_HLine2d(*Line2dPtr);
180     myRestr[nbRestr] = new Adaptor2d_HLine2d(Adaptor2d_Line2d(gp_Pnt2d(Uinf,0.),gp_Dir2d(0.,-1),pinf,psup));
181     nbRestr++;
182   }
183
184   myS = S;
185
186   if(nbRestr == 2 && S->GetType() == GeomAbs_Cone ) {
187     Standard_Real U = 0., V = 0.;
188     GetConeApexParam(S->Cone(),U,V);
189
190     deltap = Min(Usup-Uinf,2.*myInfinite);
191     if (Uinf >= -myInfinite){
192       pinf = Uinf;
193       psup = pinf + deltap;
194     }
195     else if (Usup <= myInfinite) {
196       psup = Usup;
197       pinf = psup - deltap;
198     }
199     else {
200       pinf = -myInfinite;
201       psup = myInfinite;
202     }
203
204     //Line2dPtr = new Adaptor2d_Line2d(gp_Pnt2d(U,V),gp_Dir2d(1.,0.),pinf,psup);
205     //myRestr[nbRestr] = new Adaptor2d_HLine2d(*Line2dPtr);
206     myRestr[nbRestr] = new Adaptor2d_HLine2d(Adaptor2d_Line2d(gp_Pnt2d(U,V),gp_Dir2d(1.,0.),pinf,psup));
207     nbRestr++;
208   }
209 }
210
211
212 void Adaptor3d_TopolTool::Init ()
213 {
214   idRestr = 0;
215 }
216
217
218 Standard_Boolean Adaptor3d_TopolTool::More ()
219 {
220   return (idRestr < nbRestr);
221 }
222
223 Handle(Adaptor2d_HCurve2d) Adaptor3d_TopolTool::Value ()
224 {
225   if (idRestr >= nbRestr) {throw Standard_DomainError();}
226   return myRestr[idRestr];
227 }
228
229 void Adaptor3d_TopolTool::Next ()
230 {
231   idRestr++;
232 }
233
234
235 void Adaptor3d_TopolTool::Initialize(const Handle(Adaptor2d_HCurve2d)& C)
236 {
237   nbVtx = 0;
238   idVtx = 0;
239   Standard_Real theUinf,theUsup;
240   theUinf = C->FirstParameter();
241   theUsup = C->LastParameter();
242 //  if (!Precision::IsNegativeInfinite(theUinf)) {
243   if (theUinf > -myInfinite) {
244     myVtx[nbVtx] = new Adaptor3d_HVertex(C->Value(theUinf),TopAbs_FORWARD,1.e-8);
245     nbVtx++;
246   }
247 //  if (!Precision::IsPositiveInfinite(theUsup)) {
248   if (theUsup < myInfinite) {
249     myVtx[nbVtx] = new Adaptor3d_HVertex(C->Value(theUsup),TopAbs_REVERSED,1.e-8);
250     nbVtx++;
251   }
252 }
253
254
255 void Adaptor3d_TopolTool::InitVertexIterator ()
256 {
257   idVtx =  0;
258 }
259
260
261 Standard_Boolean Adaptor3d_TopolTool::MoreVertex ()
262 {
263   return (idVtx < nbVtx);
264 }
265
266
267 Handle(Adaptor3d_HVertex) Adaptor3d_TopolTool::Vertex ()
268 {
269   if (idVtx >= nbVtx) {throw Standard_DomainError();}
270   return myVtx[idVtx];
271 }
272
273 void Adaptor3d_TopolTool::NextVertex ()
274 {
275   idVtx++;
276 }
277
278
279 TopAbs_State Adaptor3d_TopolTool::Classify(const gp_Pnt2d& P,
280                                          const Standard_Real Tol,
281                                          const Standard_Boolean )
282 //                                       const Standard_Boolean RecadreOnPeriodic)
283 {
284
285   Standard_Real U = P.X();
286   Standard_Real V = P.Y();
287
288   if (nbRestr == 4) {
289     if ((U < Uinf - Tol) || (U > Usup + Tol) ||
290       (V < Vinf - Tol) || (V > Vsup + Tol)) {
291         return TopAbs_OUT;
292     }
293     if ((Abs(U - Uinf) <= Tol) || (Abs(U - Usup) <= Tol) ||
294       (Abs(V - Vinf) <= Tol) || (Abs(V - Vsup) <= Tol)) {
295         return TopAbs_ON;
296     }
297     return TopAbs_IN;
298   }
299   else if (nbRestr == 0) {
300     return TopAbs_IN;
301   }
302   else {
303     Standard_Boolean dansu,dansv,surumin,surumax,survmin,survmax;
304     if (Precision::IsNegativeInfinite(Uinf) && 
305             Precision::IsPositiveInfinite(Usup)) {
306       dansu = Standard_True;
307       surumin = surumax = Standard_False;
308     }
309     else if (Precision::IsNegativeInfinite(Uinf)) {
310       surumin = Standard_False;
311       if (U >= Usup+Tol) {
312               dansu = Standard_False;
313               surumax = Standard_False;
314       }
315       else {
316               dansu = Standard_True;
317               surumax = Standard_False;
318               if (Abs(U-Usup)<=Tol) {
319                 surumax = Standard_True;
320               }
321       }
322     }
323     else if (Precision::IsPositiveInfinite(Usup)) {
324       surumax = Standard_False;
325       if (U < Uinf-Tol) {
326         dansu = Standard_False;
327         surumin = Standard_False;
328       }
329       else {
330         dansu = Standard_True;
331         surumin = Standard_False;
332         if (Abs(U-Uinf)<=Tol) {
333           surumin = Standard_True;
334         }
335       }
336     }
337     else {
338       if ((U < Uinf - Tol) || (U > Usup + Tol)) {
339         surumin = surumax = dansu = Standard_False;
340       }
341       else {
342         dansu = Standard_True;
343         surumin = surumax = Standard_False;
344         if (Abs(U-Uinf)<=Tol) {
345           surumin = Standard_True;
346         }
347         else if (Abs(U-Usup)<=Tol) {
348           surumax = Standard_True;
349         }
350       }
351     }
352
353     if (Precision::IsNegativeInfinite(Vinf) &&
354             Precision::IsPositiveInfinite(Vsup)) {
355       dansv = Standard_True;
356       survmin = survmax = Standard_False;
357     }
358     else if (Precision::IsNegativeInfinite(Vinf)) {
359       survmin = Standard_False;
360       if (V > Vsup+Tol) {
361         dansv = Standard_False;
362         survmax = Standard_False;
363       }
364       else {
365         dansv = Standard_True;
366         survmax = Standard_False;
367         if (Abs(V-Vsup)<=Tol) {
368           survmax = Standard_True;
369         }
370       }
371     }
372     else if (Precision::IsPositiveInfinite(Vsup)) {
373       survmax = Standard_False;
374       if (V < Vinf-Tol) {
375         dansv = Standard_False;
376         survmin = Standard_False;
377       }
378       else {
379         dansv = Standard_True;
380         survmin = Standard_False;
381         if (Abs(V-Vinf)<=Tol) {
382           survmin = Standard_True;
383         }
384       }
385     }
386     else {
387       if ((V < Vinf - Tol) || (V > Vsup + Tol)) {
388         survmin = survmax = dansv = Standard_False;
389       }
390       else {
391         dansv = Standard_True;
392         survmin = survmax = Standard_False;
393         if (Abs(V-Vinf)<=Tol) {
394           survmin = Standard_True;
395         }
396         else if (Abs(V-Vsup)<=Tol) {
397           survmax = Standard_True;
398         }
399       }
400     }
401
402     if (!dansu || !dansv) {
403       return TopAbs_OUT;
404     }
405     if (surumin || survmin || surumax || survmax) {
406       return TopAbs_ON;
407     }
408     return TopAbs_IN;
409   }
410 }
411
412
413
414 Standard_Boolean  Adaptor3d_TopolTool::IsThePointOn(const gp_Pnt2d& P,
415                                              const Standard_Real Tol,
416                                              const Standard_Boolean )
417 //                                           const Standard_Boolean RecadreOnPeriodic)
418 {
419
420   Standard_Real U = P.X();
421   Standard_Real V = P.Y();
422
423   if (nbRestr == 4) {
424     if ((U < Uinf - Tol) || (U > Usup + Tol) ||
425         (V < Vinf - Tol) || (V > Vsup + Tol)) {
426       return(Standard_False);
427     }
428     if ((Abs(U - Uinf) <= Tol) || (Abs(U - Usup) <= Tol) ||
429         (Abs(V - Vinf) <= Tol) || (Abs(V - Vsup) <= Tol)) {
430       return(Standard_True);
431     }
432     return(Standard_False);
433   }
434   else if (nbRestr == 0) {
435     return(Standard_False);
436   }
437   else {
438     Standard_Boolean dansu,dansv,surumin,surumax,survmin,survmax;
439     if (Precision::IsNegativeInfinite(Uinf) && 
440         Precision::IsPositiveInfinite(Usup)) {
441       dansu = Standard_True;
442       surumin = surumax = Standard_False;
443     }
444     else if (Precision::IsNegativeInfinite(Uinf)) {
445       surumin = Standard_False;
446       if (U >= Usup+Tol) {
447         dansu = Standard_False;
448         surumax = Standard_False;
449       }
450       else {
451         dansu = Standard_True;
452         surumax = Standard_False;
453         if (Abs(U-Usup)<=Tol) {
454           surumax = Standard_True;
455         }
456       }
457     }
458     else if (Precision::IsPositiveInfinite(Usup)) {
459       surumax = Standard_False;
460       if (U < Uinf-Tol) {
461         dansu = Standard_False;
462         surumin = Standard_False;
463       }
464       else {
465         dansu = Standard_True;
466         surumin = Standard_False;
467         if (Abs(U-Uinf)<=Tol) {
468           surumin = Standard_True;
469         }
470       }
471     }
472     else {
473       if ((U < Uinf - Tol) || (U > Usup + Tol)) {
474         surumin = surumax = dansu = Standard_False;
475       }
476       else {
477         dansu = Standard_True;
478         surumin = surumax = Standard_False;
479         if (Abs(U-Uinf)<=Tol) {
480           surumin = Standard_True;
481         }
482         else if (Abs(U-Usup)<=Tol) {
483           surumax = Standard_True;
484         }
485       }
486     }
487
488     if (Precision::IsNegativeInfinite(Vinf) &&
489         Precision::IsPositiveInfinite(Vsup)) {
490       dansv = Standard_True;
491       survmin = survmax = Standard_False;
492     }
493     else if (Precision::IsNegativeInfinite(Vinf)) {
494       survmin = Standard_False;
495       if (V > Vsup+Tol) {
496         dansv = Standard_False;
497         survmax = Standard_False;
498       }
499       else {
500         dansv = Standard_True;
501         survmax = Standard_False;
502         if (Abs(V-Vsup)<=Tol) {
503           survmax = Standard_True;
504         }
505       }
506     }
507     else if (Precision::IsPositiveInfinite(Vsup)) {
508       survmax = Standard_False;
509       if (V < Vinf-Tol) {
510         dansv = Standard_False;
511         survmin = Standard_False;
512       }
513       else {
514         dansv = Standard_True;
515         survmin = Standard_False;
516         if (Abs(V-Vinf)<=Tol) {
517           survmin = Standard_True;
518         }
519       }
520     }
521     else {
522       if ((V < Vinf - Tol) || (V > Vsup + Tol)) {
523         survmin = survmax = dansv = Standard_False;
524       }
525       else {
526         dansv = Standard_True;
527         survmin = survmax = Standard_False;
528         if (Abs(V-Vinf)<=Tol) {
529           survmin = Standard_True;
530         }
531         else if (Abs(V-Vsup)<=Tol) {
532           survmax = Standard_True;
533         }
534       }
535     }
536
537     if (!dansu || !dansv) {
538       return(Standard_False);
539     }
540     if (surumin || survmin || surumax || survmax) {
541       return(Standard_True);
542     }
543     return(Standard_False);;
544   }
545 }
546
547
548 TopAbs_Orientation Adaptor3d_TopolTool::Orientation
549   (const Handle(Adaptor2d_HCurve2d)&)
550 {
551   return TopAbs_FORWARD;
552 }
553
554 TopAbs_Orientation Adaptor3d_TopolTool::Orientation
555   (const Handle(Adaptor3d_HVertex)& V)
556 {
557   return V->Orientation();
558 }
559
560 Standard_Boolean Adaptor3d_TopolTool::Identical
561   (const Handle(Adaptor3d_HVertex)& V1,
562    const Handle(Adaptor3d_HVertex)& V2)
563 {
564   return V1->IsSame(V2);
565 }
566
567
568 //-- ============================================================
569 //-- m e t h o d e s   u t i l i s e e s   p o u r   l e s  
570 //--  s a m p l e s
571 //-- ============================================================ 
572 #include <TColgp_Array2OfPnt.hxx>
573 #include <Geom_BezierSurface.hxx>
574 #include <Geom_BSplineSurface.hxx>
575 #include <TColStd_Array1OfReal.hxx>
576 #include <TColStd_Array1OfBoolean.hxx>
577 //#include <gce_MakeLin.hxx>
578 #include <gp_Lin.hxx>
579 #include <gp_Dir.hxx>
580 #include <gp_Vec.hxx>
581
582 #define myMinPnts 4 //Absolut possible minimum of sample points
583                     //Restriction of IntPolyh
584
585
586 static void Analyse(const TColgp_Array2OfPnt& array2,
587                     const Standard_Integer nbup,
588                     const Standard_Integer nbvp,
589                     Standard_Integer& myNbSamplesU,
590                     Standard_Integer& myNbSamplesV) { 
591   gp_Vec Vi,Vip1;
592   Standard_Integer sh,nbch,i,j;
593   
594   sh = 1;
595   nbch = 0;
596   if(nbvp>2) { 
597     for(i=2;i<nbup;i++) { 
598       const gp_Pnt& A=array2.Value(i,1);
599       const gp_Pnt& B=array2.Value(i,2);
600       const gp_Pnt& C=array2.Value(i,3);
601       Vi.SetCoord(C.X()-B.X()-B.X()+A.X(),
602                   C.Y()-B.Y()-B.Y()+A.Y(),
603                   C.Z()-B.Z()-B.Z()+A.Z());
604       Standard_Integer locnbch=0;
605       for(j=3; j<nbvp;j++) {  //-- try
606         const gp_Pnt& A1=array2.Value(i,j-1);
607         const gp_Pnt& B1=array2.Value(i,j);
608         const gp_Pnt& C1=array2.Value(i,j+1);
609         Vip1.SetCoord(C1.X()-B1.X()-B1.X()+A1.X(),
610                       C1.Y()-B1.Y()-B1.Y()+A1.Y(),
611                       C1.Z()-B1.Z()-B1.Z()+A1.Z());
612         Standard_Real pd = Vi.Dot(Vip1);
613         Vi=Vip1;
614         if(pd>1.0e-7 || pd<-1.0e-7) { 
615           if(pd>0) {  if(sh==-1) {   sh=1; locnbch++;   }  }
616           else {        if(sh==1) {  sh=-1; locnbch++;  }  }
617         }
618       }
619       if(locnbch>nbch) { 
620         nbch=locnbch; 
621       }
622     }
623   }
624   myNbSamplesV = nbch+5;
625   
626   nbch=0;
627   if(nbup>2) { 
628     for(j=2;j<nbvp;j++) { 
629       const gp_Pnt& A=array2.Value(1,j);
630       const gp_Pnt& B=array2.Value(2,j);
631       const gp_Pnt& C=array2.Value(3,j);
632       Vi.SetCoord(C.X()-B.X()-B.X()+A.X(),
633                   C.Y()-B.Y()-B.Y()+A.Y(),
634                   C.Z()-B.Z()-B.Z()+A.Z());
635       Standard_Integer locnbch=0;
636       for(i=3; i<nbup;i++) {  //-- try
637         const gp_Pnt& A1=array2.Value(i-1,j);
638         const gp_Pnt& B1=array2.Value(i,j);
639         const gp_Pnt& C1=array2.Value(i+1,j);
640         Vip1.SetCoord(C1.X()-B1.X()-B1.X()+A1.X(),
641                       C1.Y()-B1.Y()-B1.Y()+A1.Y(),
642                       C1.Z()-B1.Z()-B1.Z()+A1.Z());
643         Standard_Real pd = Vi.Dot(Vip1);
644         Vi=Vip1;
645         if(pd>1.0e-7 || pd<-1.0e-7) { 
646           if(pd>0) {  if(sh==-1) {   sh=1; locnbch++;   }  }
647           else {        if(sh==1) {  sh=-1; locnbch++;  }  }
648         }
649       }
650       if(locnbch>nbch) nbch=locnbch;
651     }  
652   }
653   myNbSamplesU = nbch+5;
654 }  
655
656
657 void Adaptor3d_TopolTool::ComputeSamplePoints() { 
658   Standard_Real uinf,usup,vinf,vsup;
659   uinf = myS->FirstUParameter();  usup = myS->LastUParameter();
660   vinf = myS->FirstVParameter();  vsup = myS->LastVParameter();
661   if (usup < uinf) { Standard_Real temp=uinf; uinf=usup; usup=temp; }
662   if (vsup < vinf) { Standard_Real temp=vinf; vinf=vsup; vsup=temp; }
663   if (uinf == RealFirst() && usup == RealLast()) { uinf=-1.e5; usup=1.e5; }
664   else if (uinf == RealFirst()) { uinf=usup-2.e5; }
665   else if (usup == RealLast()) {  usup=uinf+2.e5; }
666   
667   if (vinf == RealFirst() && vsup == RealLast()) { vinf=-1.e5; vsup=1.e5; }
668   else if (vinf == RealFirst()) { vinf=vsup-2.e5;  }
669   else if (vsup == RealLast()) {  vsup=vinf+2.e5;  }
670   
671   Standard_Integer nbsu,nbsv;
672   GeomAbs_SurfaceType typS = myS->GetType();
673   switch(typS) { 
674   case GeomAbs_Plane:          { nbsv=2; nbsu=2; } break;
675   case GeomAbs_BezierSurface:  { nbsv=3+myS->NbVPoles(); nbsu=3+myS->NbUPoles();  } break;
676   case GeomAbs_BSplineSurface: {
677     nbsv = myS->NbVKnots();     nbsv*= myS->VDegree();     if(nbsv < 4) nbsv=4;    
678     nbsu = myS->NbUKnots();     nbsu*= myS->UDegree();     if(nbsu < 4) nbsu=4;
679   }
680     break;
681   case GeomAbs_Cylinder:
682   case GeomAbs_Cone:
683   case GeomAbs_Sphere:
684   case GeomAbs_Torus:
685   case GeomAbs_SurfaceOfRevolution:
686   case GeomAbs_SurfaceOfExtrusion:    { nbsv = 15; nbsu=15; }     break;
687   default:                            { nbsu = 10; nbsv=10; }    break;
688   }
689   
690   //-- If the number of points is too great... analyze 
691   //-- 
692   //-- 
693   
694   if(nbsu<6) nbsu=6;
695   if(nbsv<6) nbsv=6;
696   
697   myNbSamplesU = nbsu;
698   myNbSamplesV = nbsv;
699
700   if(nbsu>8 || nbsv>8) {
701     if(typS == GeomAbs_BSplineSurface) { 
702       const Handle(Geom_BSplineSurface)& Bspl = myS->BSpline();
703       Standard_Integer nbup = Bspl->NbUPoles();
704       Standard_Integer nbvp = Bspl->NbVPoles();
705       TColgp_Array2OfPnt array2(1,nbup,1,nbvp);
706       Bspl->Poles(array2);
707       Analyse(array2,nbup,nbvp,myNbSamplesU,myNbSamplesV);
708     }
709     else if(typS == GeomAbs_BezierSurface) { 
710       const Handle(Geom_BezierSurface)& Bez = myS->Bezier();
711       Standard_Integer nbup = Bez->NbUPoles();
712       Standard_Integer nbvp = Bez->NbVPoles();
713       TColgp_Array2OfPnt array2(1,nbup,1,nbvp);
714       Bez->Poles(array2);
715       Analyse(array2,nbup,nbvp,myNbSamplesU,myNbSamplesV);
716     }
717   }
718 }
719
720 Standard_Integer Adaptor3d_TopolTool::NbSamplesU()
721
722   if(myNbSamplesU <0) {
723     ComputeSamplePoints();
724   }
725   return(myNbSamplesU);
726 }
727
728 Standard_Integer Adaptor3d_TopolTool::NbSamplesV()
729
730   if(myNbSamplesU <0) { 
731     ComputeSamplePoints();    
732   }
733   return(myNbSamplesV);
734 }
735
736 Standard_Integer Adaptor3d_TopolTool::NbSamples()
737
738   if(myNbSamplesU <0) { 
739     ComputeSamplePoints();    
740   }
741   return(myNbSamplesU*myNbSamplesV);
742 }
743
744 void Adaptor3d_TopolTool::UParameters(TColStd_Array1OfReal& theArray) const
745 {
746   theArray = myUPars->Array1();
747 }
748
749 void Adaptor3d_TopolTool::VParameters(TColStd_Array1OfReal& theArray) const
750 {
751   theArray = myVPars->Array1();
752 }
753
754 void Adaptor3d_TopolTool::SamplePoint(const Standard_Integer i,
755                                       gp_Pnt2d& P2d,
756                                       gp_Pnt& P3d)
757 {
758   Standard_Integer iu, iv;
759   Standard_Real u, v;
760   if (myUPars.IsNull())
761     {
762       Standard_Real myDU=(Usup-Uinf)/(myNbSamplesU+1);
763       Standard_Real myDV=(Vsup-Vinf)/(myNbSamplesV+1);
764       iv = 1 + i/myNbSamplesU;
765       iu = 1+ i-(iv-1)*myNbSamplesU;
766       u=Uinf+iu*myDU;
767       v=Vinf+iv*myDV;
768     }
769   else
770     {
771       iv = (i-1)/myNbSamplesU + 1;
772       iu = (i-1)%myNbSamplesU + 1;
773       u = myUPars->Value(iu);
774       v = myVPars->Value(iv);
775     }
776
777   P2d.SetCoord(u,v);
778   P3d = myS->Value(u,v);
779 }
780
781
782
783 Standard_Boolean Adaptor3d_TopolTool::DomainIsInfinite() { 
784   if(Precision::IsNegativeInfinite(Uinf)) return(Standard_True);
785   if(Precision::IsPositiveInfinite(Usup)) return(Standard_True);
786   if(Precision::IsNegativeInfinite(Vinf)) return(Standard_True);
787   if(Precision::IsPositiveInfinite(Vsup)) return(Standard_True);
788   return(Standard_False);
789 }
790 //=======================================================================
791 //function : Edge
792 //purpose  : 
793 //=======================================================================
794   Standard_Address Adaptor3d_TopolTool::Edge() const 
795 {
796   return NULL;
797
798 //=======================================================================
799 //function : Has3d
800 //purpose  : 
801 //=======================================================================
802
803 Standard_Boolean Adaptor3d_TopolTool::Has3d() const
804 {
805   return Standard_False;
806 }
807
808 //=======================================================================
809 //function : Tol3d
810 //purpose  : 
811 //=======================================================================
812
813 Standard_Real Adaptor3d_TopolTool::Tol3d(const Handle(Adaptor2d_HCurve2d)&) const
814 {
815   throw Standard_DomainError("Adaptor3d_TopolTool: has no 3d representation");
816 }
817
818 //=======================================================================
819 //function : Tol3d
820 //purpose  : 
821 //=======================================================================
822
823 Standard_Real Adaptor3d_TopolTool::Tol3d(const Handle(Adaptor3d_HVertex)&) const
824 {
825   throw Standard_DomainError("Adaptor3d_TopolTool: has no 3d representation");
826 }
827
828 //=======================================================================
829 //function : Pnt
830 //purpose  : 
831 //=======================================================================
832
833 gp_Pnt Adaptor3d_TopolTool::Pnt(const Handle(Adaptor3d_HVertex)&) const
834 {
835   throw Standard_DomainError("Adaptor3d_TopolTool: has no 3d representation");
836 }
837
838
839 //=======================================================================
840 //function : SamplePnts
841 //purpose  : 
842 //=======================================================================
843
844 void Adaptor3d_TopolTool::SamplePnts(const Standard_Real theDefl, 
845                                      const Standard_Integer theNUmin,
846                                      const Standard_Integer theNVmin)
847
848   Standard_Real uinf,usup,vinf,vsup;
849   uinf = myS->FirstUParameter();  usup = myS->LastUParameter();
850   vinf = myS->FirstVParameter();  vsup = myS->LastVParameter();
851   if (usup < uinf) { Standard_Real temp=uinf; uinf=usup; usup=temp; }
852   if (vsup < vinf) { Standard_Real temp=vinf; vinf=vsup; vsup=temp; }
853   if (uinf == RealFirst() && usup == RealLast()) { uinf=-1.e5; usup=1.e5; }
854   else if (uinf == RealFirst()) { uinf=usup-2.e5; }
855   else if (usup == RealLast()) {  usup=uinf+2.e5; }
856   
857   if (vinf == RealFirst() && vsup == RealLast()) { vinf=-1.e5; vsup=1.e5; }
858   else if (vinf == RealFirst()) { vinf=vsup-2.e5;  }
859   else if (vsup == RealLast()) {  vsup=vinf+2.e5;  }
860   
861 //   Standard_Integer nbsu,nbsv;
862   GeomAbs_SurfaceType typS = myS->GetType();
863 //   switch(typS) { 
864 //   case GeomAbs_Plane:          { nbsv=2; nbsu=2; } break;
865 //   case GeomAbs_BezierSurface:  { 
866 //     nbsv=myS->NbVPoles(); 
867 //     nbsu=myS->NbUPoles();
868 //     nbsu = Max(nbsu, theNUmin);
869 //     nbsv = Max(nbsv, theNVmin);
870 //     if(nbsu>8 || nbsv>8) {
871 //       const Handle(Geom_BezierSurface)& Bez = myS->Bezier();
872 //       Standard_Integer nbup = Bez->NbUPoles();
873 //       Standard_Integer nbvp = Bez->NbVPoles();
874 //       TColgp_Array2OfPnt array2(1,nbup,1,nbvp);
875 //       Bez->Poles(array2);
876 //       Analyse(array2,nbup,nbvp,myNbSamplesU,myNbSamplesV);
877 //     }  
878 //   } 
879 //     break;
880 //   case GeomAbs_BSplineSurface: {
881   if(typS == GeomAbs_BSplineSurface) {
882     // Processing BSpline surface 
883     BSplSamplePnts(theDefl, theNUmin, theNVmin);
884     return;
885   }
886   else {
887     ComputeSamplePoints();
888   }
889 //   case GeomAbs_Cylinder:
890 //   case GeomAbs_Cone:
891 //   case GeomAbs_Sphere:
892 //   case GeomAbs_Torus:
893 //   case GeomAbs_SurfaceOfRevolution:
894 //   case GeomAbs_SurfaceOfExtrusion:    { nbsv = Max(15,theNVmin); nbsu=Max(15,theNUmin); } break;
895 //   default:                            { nbsu = Max(10,theNUmin); nbsv=Max(10,theNVmin); } break;
896 //   }
897   
898   
899 //   if(nbsu<6) nbsu=6;
900 //   if(nbsv<6) nbsv=6;
901   
902 //   myNbSamplesU = nbsu;
903 //   myNbSamplesV = nbsv;
904
905
906   myUPars = new TColStd_HArray1OfReal(1, myNbSamplesU);
907   myVPars = new TColStd_HArray1OfReal(1, myNbSamplesV);
908   Standard_Integer i;
909   Standard_Real t, dt = (usup - uinf)/(myNbSamplesU - 1);
910   myUPars->SetValue(1, uinf);
911   myUPars->SetValue(myNbSamplesU, usup);
912   for(i = 2, t = uinf+dt; i < myNbSamplesU; ++i, t += dt) {
913     myUPars->SetValue(i, t);
914   }
915
916   dt = (vsup - vinf)/(myNbSamplesV - 1);
917   myVPars->SetValue(1, vinf);
918   myVPars->SetValue(myNbSamplesV, vsup);
919   for(i = 2, t = vinf+dt; i < myNbSamplesV; ++i, t += dt) {
920     myVPars->SetValue(i, t);
921   }
922
923   return;
924
925 }
926
927 //=======================================================================
928 //function : BSplSamplePnts
929 //purpose  : 
930 //=======================================================================
931
932 void Adaptor3d_TopolTool::BSplSamplePnts(const Standard_Real theDefl, 
933                                          const Standard_Integer theNUmin,
934                                          const Standard_Integer theNVmin)
935
936   const Handle(Geom_BSplineSurface)& aBS = myS->BSpline();
937   Standard_Real uinf,usup,vinf,vsup;
938   uinf = myS->FirstUParameter();  usup = myS->LastUParameter();
939   vinf = myS->FirstVParameter();  vsup = myS->LastVParameter();
940
941   Standard_Integer i, k, j = 1;
942   Standard_Real t1, t2, dt;
943   Standard_Integer ui1 = aBS->FirstUKnotIndex();
944   Standard_Integer ui2 = aBS->LastUKnotIndex();
945   Standard_Integer vi1 = aBS->FirstVKnotIndex();
946   Standard_Integer vi2 = aBS->LastVKnotIndex();
947
948   for(i = ui1; i < ui2; ++i) {
949     if(uinf >= aBS->UKnot(i) && uinf < aBS->UKnot(i+1)) {
950       ui1 = i;
951       break;
952     }
953   }
954
955   for(i = ui2; i > ui1; --i) {
956     if(usup <= aBS->UKnot(i) && usup > aBS->UKnot(i-1)) {
957       ui2 = i;
958       break;
959     }
960   }
961
962   for(i = vi1; i < vi2; ++i) {
963     if(vinf >= aBS->VKnot(i) && vinf < aBS->VKnot(i+1)) {
964       vi1 = i;
965       break;
966     }
967   }
968
969   for(i = vi2; i > vi1; --i) {
970     if(vsup <= aBS->VKnot(i) && vsup > aBS->VKnot(i-1)) {
971       vi2 = i;
972       break;
973     }
974   }
975
976   Standard_Integer nbsu = ui2-ui1+1; nbsu += (nbsu - 1) * (aBS->UDegree()-1);
977   Standard_Integer nbsv = vi2-vi1+1; nbsv += (nbsv - 1) * (aBS->VDegree()-1);
978   Standard_Boolean bUuniform = Standard_False;
979   Standard_Boolean bVuniform = Standard_False;
980
981   //modified by NIZHNY-EMV Mon Jun 10 14:19:04 2013
982   if (nbsu < theNUmin || nbsv < theNVmin) {
983     Standard_Integer aNb;
984     if (nbsu < nbsv) {
985       aNb = (Standard_Integer)(nbsv * ((Standard_Real)theNUmin)/((Standard_Real)nbsu));
986       aNb = Min(aNb, 30);
987       bVuniform = (aNb > nbsv) ? Standard_True : bVuniform;
988       nbsv = bVuniform ? aNb : nbsv;
989     } else {
990       aNb = (Standard_Integer)(nbsu * ((Standard_Real)theNVmin)/((Standard_Real)nbsv));
991       aNb = Min(aNb, 30);
992       bUuniform = (aNb > nbsu) ? Standard_True : bUuniform;
993       nbsu = bUuniform ? aNb : nbsu;
994     }
995   }
996   //modified by NIZHNY-EMV Mon Jun 10 14:19:05 2013
997
998   if(nbsu < theNUmin) {
999     nbsu = theNUmin;
1000     bUuniform = Standard_True;
1001   }
1002
1003   if(nbsv < theNVmin) {
1004     nbsv = theNVmin;
1005     bVuniform = Standard_True;
1006   }
1007
1008   TColStd_Array1OfReal anUPars(1, nbsu);
1009   TColStd_Array1OfBoolean anUFlg(1, nbsu);
1010   TColStd_Array1OfReal aVPars(1, nbsv);
1011   TColStd_Array1OfBoolean aVFlg(1, nbsv);
1012
1013   //Filling of sample parameters
1014   if(bUuniform) {
1015     t1 = uinf;
1016     t2 = usup;
1017     dt = (t2 - t1)/(nbsu - 1);
1018     anUPars(1) = t1;
1019     anUFlg(1) = Standard_False;
1020     anUPars(nbsu) = t2;
1021     anUFlg(nbsu) = Standard_False;
1022     for(i = 2, t1 += dt; i < nbsu; ++i, t1 += dt) {
1023       anUPars(i) = t1;
1024       anUFlg(i) = Standard_False;
1025     }
1026   }
1027   else {  
1028     Standard_Integer nbi = aBS->UDegree();
1029     k = 0;
1030     t1 = uinf;
1031     for(i = ui1+1; i <= ui2; ++i) {
1032       if(i == ui2) t2 = usup;
1033       else t2 = aBS->UKnot(i);
1034       dt = (t2 - t1)/nbi;
1035       j = 1;
1036       do { 
1037         ++k;
1038         anUPars(k) = t1;
1039         anUFlg(k) = Standard_False;
1040         t1 += dt;       
1041       }
1042       while (++j <= nbi);
1043       t1 = t2;
1044     }
1045     ++k;
1046     anUPars(k) = t1;
1047   }
1048
1049   if(bVuniform) {
1050     t1 = vinf;
1051     t2 = vsup;
1052     dt = (t2 - t1)/(nbsv - 1);
1053     aVPars(1) = t1;
1054     aVFlg(1) = Standard_False;
1055     aVPars(nbsv) = t2;
1056     aVFlg(nbsv) = Standard_False;
1057     for(i = 2, t1 += dt; i < nbsv; ++i, t1 += dt) {
1058       aVPars(i) = t1;
1059       aVFlg(i) = Standard_False;
1060     }
1061   }
1062   else {  
1063     Standard_Integer nbi = aBS->VDegree();
1064     k = 0;
1065     t1 = vinf;
1066     for(i = vi1+1; i <= vi2; ++i) {
1067       if(i == vi2) t2 = vsup;
1068       else t2 = aBS->VKnot(i);
1069       dt = (t2 - t1)/nbi;
1070       j = 1;
1071       do { 
1072         ++k;
1073         aVPars(k) = t1;
1074         aVFlg(k) = Standard_False;
1075         t1 += dt;       
1076       }
1077       while (++j <= nbi);
1078       t1 = t2;
1079     }
1080     ++k;
1081     aVPars(k) = t1;
1082   }
1083  
1084   //Analysis of deflection
1085
1086   Standard_Real aDefl2 = Max(theDefl*theDefl, 1.e-9);
1087   Standard_Real tol = Max(0.01*aDefl2, 1.e-9);
1088   Standard_Integer l;
1089
1090   anUFlg(1) = Standard_True;
1091   anUFlg(nbsu) = Standard_True;
1092   //myNbSamplesU = 2; 
1093   for(i = 1; i <= nbsv; ++i) {
1094     t1 = aVPars(i);
1095     j = 1;
1096     Standard_Boolean bCont = Standard_True;
1097     while (j < nbsu-1 && bCont) {
1098
1099       if(anUFlg(j+1)) {
1100         ++j;
1101         continue;
1102       }
1103
1104       t2 = anUPars(j);
1105       gp_Pnt p1 = myS->Value(t2, t1);
1106       for(k = j+2; k <= nbsu; ++k) {
1107         t2 = anUPars(k);
1108         gp_Pnt p2 = myS->Value(t2, t1);
1109         //gce_MakeLin MkLin(p1, p2);
1110         //const gp_Lin& lin = MkLin.Value();
1111
1112         if(p1.SquareDistance(p2) <= tol) continue;
1113
1114         gp_Lin lin(p1, gp_Dir(gp_Vec(p1, p2)));
1115         Standard_Boolean ok = Standard_True;
1116         for(l = j+1; l < k; ++l) {
1117
1118           if(anUFlg(l)) {
1119             ok = Standard_False;
1120             break;
1121           }
1122
1123           gp_Pnt pp =  myS->Value(anUPars(l), t1);
1124           Standard_Real d = lin.SquareDistance(pp);
1125           
1126           if(d <= aDefl2) continue;
1127
1128           ok = Standard_False;
1129           break;
1130         }
1131
1132         if(!ok) {
1133           j = k - 1;
1134           anUFlg(j) = Standard_True;
1135           //++myNbSamplesU;
1136           break;
1137         }
1138         
1139         if(anUFlg(k)) {
1140           j = k;
1141           break;
1142         }
1143         
1144
1145       }
1146
1147       if(k >= nbsu) bCont = Standard_False;
1148
1149     }
1150   }
1151
1152   myNbSamplesU = 0;
1153   for (i = 1; i <= nbsu; i++)
1154     if (anUFlg(i) == Standard_True)
1155       myNbSamplesU++;
1156   
1157   if(myNbSamplesU < myMinPnts) {
1158     if(myNbSamplesU == 2) {
1159       //"uniform" distribution;
1160       Standard_Integer nn = nbsu/myMinPnts;
1161       anUFlg(1+nn) = Standard_True;
1162       anUFlg(nbsu-nn) = Standard_True;
1163     }
1164     else { //myNbSamplesU == 3
1165       //insert in bigger segment
1166       i = 2;
1167       while(!anUFlg(i++));
1168       if(i < nbsu/2) j = Min(i+(nbsu-i)/2, nbsu-1);
1169       else j = Max(i/2, 2);
1170     }
1171     anUFlg(j) = Standard_True;
1172     myNbSamplesU = myMinPnts;
1173   }
1174       
1175   aVFlg(1) = Standard_True;
1176   aVFlg(nbsv) = Standard_True;
1177   //myNbSamplesV = 2;
1178   for(i = 1; i <= nbsu; ++i) {
1179     t1 = anUPars(i);
1180     j = 1;
1181     Standard_Boolean bCont = Standard_True;
1182     while (j < nbsv-1 && bCont) {
1183
1184       if(aVFlg(j+1)) {
1185         ++j;
1186         continue;
1187       }
1188
1189       t2 = aVPars(j);
1190       gp_Pnt p1 = myS->Value(t1, t2);
1191       for(k = j+2; k <= nbsv; ++k) {
1192         t2 = aVPars(k);
1193         gp_Pnt p2 = myS->Value(t1, t2);
1194
1195         if(p1.SquareDistance(p2) <= tol) continue;
1196         //gce_MakeLin MkLin(p1, p2);
1197         //const gp_Lin& lin = MkLin.Value();
1198         gp_Lin lin(p1, gp_Dir(gp_Vec(p1, p2)));
1199         Standard_Boolean ok = Standard_True;
1200         for(l = j+1; l < k; ++l) {
1201
1202           if(aVFlg(l)) {
1203             ok = Standard_False;
1204             break;
1205           }
1206
1207           gp_Pnt pp =  myS->Value(t1, aVPars(l));
1208           Standard_Real d = lin.SquareDistance(pp);
1209           
1210           if(d <= aDefl2) continue;
1211
1212           ok = Standard_False;
1213           break;
1214         }
1215
1216         if(!ok) {
1217           j = k - 1;
1218           aVFlg(j) = Standard_True;
1219           //++myNbSamplesV;
1220           break;
1221         }
1222         
1223         if(aVFlg(k)) {
1224           j = k;
1225           break;
1226         }
1227         
1228
1229       }
1230
1231       if(k >= nbsv) bCont = Standard_False;
1232
1233     }
1234   }
1235
1236   myNbSamplesV = 0;
1237   for (i = 1; i <= nbsv; i++)
1238     if (aVFlg(i) == Standard_True)
1239       myNbSamplesV++;
1240   
1241   if(myNbSamplesV < myMinPnts) {
1242     if(myNbSamplesV == 2) {
1243       //"uniform" distribution;
1244       Standard_Integer nn = nbsv/myMinPnts;
1245       aVFlg(1+nn) = Standard_True;
1246       aVFlg(nbsv-nn) = Standard_True;
1247       myNbSamplesV = myMinPnts;
1248     }
1249     else { //myNbSamplesU == 3
1250       //insert in bigger segment
1251       i = 2;
1252       while(!aVFlg(i++));
1253       if(i < nbsv/2) j = Min(i+(nbsv-i)/2, nbsv-1);
1254       else j = Max(i/2, 2);
1255     }
1256     myNbSamplesV = myMinPnts;
1257     aVFlg(j) = Standard_True;
1258   }
1259   //
1260   //modified by NIZNHY-PKV Fri Dec 16 10:05:01 2011f
1261   //
1262   Standard_Boolean bFlag;
1263   //
1264   // U 
1265   bFlag=(myNbSamplesU < theNUmin);
1266   if (bFlag) {
1267     myNbSamplesU=nbsu;
1268   }
1269   //
1270   myUPars = new TColStd_HArray1OfReal(1, myNbSamplesU);
1271   //
1272   for(j = 0, i = 1; i <= nbsu; ++i) {
1273     if (bFlag) {
1274       myUPars->SetValue(i,anUPars(i));
1275     }
1276     else {
1277       if(anUFlg(i)) {
1278         ++j;
1279         myUPars->SetValue(j,anUPars(i));
1280       }
1281     }
1282   }
1283   //
1284   // V 
1285   bFlag=(myNbSamplesV < theNVmin);
1286   if (bFlag) {
1287     myNbSamplesV=nbsv;
1288   }
1289   //
1290   myVPars = new TColStd_HArray1OfReal(1, myNbSamplesV);
1291   //
1292   for(j = 0, i = 1; i <= nbsv; ++i) {
1293     if (bFlag) {
1294        myVPars->SetValue(i,aVPars(i));
1295     }
1296     else {
1297       if(aVFlg(i)) {
1298         ++j;
1299         myVPars->SetValue(j,aVPars(i));
1300       }
1301     }
1302   }
1303   //
1304   /*
1305   myUPars = new TColStd_HArray1OfReal(1, myNbSamplesU);
1306   myVPars = new TColStd_HArray1OfReal(1, myNbSamplesV);
1307
1308   j = 0;
1309   for(i = 1; i <= nbsu; ++i) {
1310     if(anUFlg(i)) {
1311       ++j;
1312       myUPars->SetValue(j,anUPars(i));
1313     }
1314   }
1315
1316   j = 0;
1317   for(i = 1; i <= nbsv; ++i) {
1318     if(aVFlg(i)) {
1319       ++j;
1320       myVPars->SetValue(j,aVPars(i));
1321     }
1322   }
1323   */
1324   //modified by NIZNHY-PKV Mon Dec 26 12:25:35 2011t
1325
1326 }
1327
1328 //=======================================================================
1329 //function : IsUniformSampling
1330 //purpose  : 
1331 //=======================================================================
1332 Standard_Boolean Adaptor3d_TopolTool::IsUniformSampling() const
1333 {
1334   GeomAbs_SurfaceType typS = myS->GetType();
1335
1336   if(typS == GeomAbs_BSplineSurface)
1337     return Standard_False;
1338   return Standard_True;
1339 }