0024059: Eliminate compiler warning C4701 in MSVC++ with warning level 4
[occt.git] / src / IntWalk / IntWalk_PWalking_4.gxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
8 //
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 //
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
18
19 //-- 
20 //-- Modif du 5 Octobre 94 (LBR) 
21 //--   if(Trouve) ...
22 //-- On deborde sur une frontiere, Duv[.] = -1 -1 -1 -1 
23 //-- donc on garde la meme iso bloquee (voir if(k!=1) )
24 //-- 
25
26 //-- Modif du 8 juillet 96 (LBR)
27 //-- simplifaication du traitement des auto-intersections.
28 //-- Idee : 
29 //--          Tester la boucle fermee en 3d et en 2d. 
30 //-- 
31
32 #include <gp_Pnt2d.hxx>
33
34
35 Standard_Boolean IntWalk_PWalking::
36         TestArret(const Standard_Boolean DejaReparti,
37                   TColStd_Array1OfReal& Param,
38                   IntImp_ConstIsoparametric&  ChoixIso)
39
40 //
41 // tester si le point d intersection donne par ces parametres reste dans le
42 // domaine naturelle de chaque carreau.
43 // si le point deborde cadrer de facon a trouver la meilleure iso (frontiere)
44 // qui intersecte le plus franchement l autre carreau
45 // sinon tester si presence de ligne fermee  
46 // 
47 {
48   Standard_Real Uvd[4],Uvf[4],Epsuv[4],Duv[4],Uvp[4],dv,dv2,ParC[4];
49   Standard_Real DPc,DPb;
50   Standard_Integer i = 0, k = 0;
51   Epsuv[0] = ResoU1;
52   Epsuv[1] = ResoV1;
53   Epsuv[2] = ResoU2;
54   Epsuv[3] = ResoV2;
55   previousPoint.Parameters(Uvp[0],Uvp[1],Uvp[2],Uvp[3]);
56   Standard_Boolean Trouve = Standard_False;
57
58   Uvd[0]=Um1;   Uvf[0]=UM1;   Uvd[1]=Vm1;   Uvf[1]=VM1;
59   Uvd[2]=Um2;   Uvf[2]=UM2;   Uvd[3]=Vm2;   Uvf[3]=VM2;
60
61   Standard_Integer im1;
62   for ( i = 1,im1 = 0;i<=4;i++,im1++) {
63     switch(i) { 
64     case 1: k=2; break;
65     case 2: k=1; break;
66     case 3: k=4; break;
67     case 4: k=3; break;
68     }
69     if (Param(i) < (Uvd[im1]-Epsuv[im1])) {        //--     Current -----  Bound Inf -----  Previous
70       Trouve    = Standard_True;                   //-- 
71       DPc       = Uvp[im1]-Param(i);               //--     Previous  - Current
72       DPb       = Uvp[im1]-Uvd[im1];               //--     Previous  - Bound Inf
73       ParC[im1] = Uvd[im1];                        //--     ParamCorrige
74       dv        = Param(k)-Uvp[k-1];               //--     Current   - Previous (Sur Autre Direction)
75       dv2       = dv*dv;         
76       if(dv2>RealEpsilon()) {                       //--     Progression sur l autre Direction ?
77         Duv[im1]  = DPc*DPb + dv2;
78         Duv[im1]  = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
79       }
80       else {
81         Duv[im1]=-1.0;                              //--    Si Pas de prgogression, on ne change pas 
82       }                                             //--    le choix de l iso 
83     }   
84     else if (Param(i) > (Uvf[im1] + Epsuv[im1])) {  //--     Previous -----  Bound Sup -----  Current
85       Trouve    = Standard_True;                    //-- 
86       DPc       = Param(i)-Uvp[im1];                //--     Current   - Previous
87       DPb       = Uvf[im1]-Uvp[im1];                //--     Bound Sup - Previous 
88       ParC[im1] = Uvf[im1];                         //--     Param Corrige
89       dv        = Param(k)-Uvp[k-1];                //--     Current   - Previous (Sur autre Direction)
90       dv2       = dv*dv;
91       if(dv2>RealEpsilon()) {                       //--     Progression sur l autre Direction ?
92         Duv[im1]  =  DPc*DPb + dv2;
93         Duv[im1]  = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
94       }
95       else {
96         Duv[im1]=-1.0;                              //--    Si Pas de prgogression, on ne change pas 
97       }                                             //--    le choix de l iso 
98     }
99     else { 
100       Duv[im1]= -1.;
101       ParC[im1]=Param(i);
102     }
103   }
104
105   if (Trouve) {
106     //--------------------------------------------------
107     //-- Un des Parametres u1,v1,u2,v2 est en dehors  --
108     //-- des bornes naturelles.                       -- 
109     //-- On cherche la meilleure direction de         -- 
110     //-- progression et on recadre les params.        --
111     //--------------------------------------------------
112     Standard_Real ddv = -1.0;
113     k=-1;
114     for (i=0;i<=3;i++) {
115       Param(i+1) = ParC[i];
116       if(Duv[i]>ddv) { 
117         ddv = Duv[i];
118         k=i;
119       }
120     }
121     if(k!=-1) { 
122       ChoixIso   = ChoixRef[k];
123     }
124     else { 
125       if((ParC[0]<=Uvd[0]+Epsuv[0]) || (ParC[0]>=Uvf[0]-Epsuv[0])) {
126         ChoixIso = IntImp_UIsoparametricOnCaro1;
127       }
128       else if((ParC[1]<=Uvd[1]+Epsuv[1]) || (ParC[1]>=Uvf[1]-Epsuv[1])) {
129         ChoixIso = IntImp_VIsoparametricOnCaro1;
130       }
131       else if((ParC[2]<=Uvd[2]+Epsuv[2]) || (ParC[2]>=Uvf[2]-Epsuv[2])) {
132         ChoixIso = IntImp_UIsoparametricOnCaro2;
133       }
134       else if((ParC[3]<=Uvd[3]+Epsuv[3]) || (ParC[3]>=Uvf[3]-Epsuv[3])) {
135         ChoixIso = IntImp_VIsoparametricOnCaro2;
136       }
137     }
138     close = Standard_False;
139     return Standard_True;
140   }
141   else 
142     {  
143       if (!DejaReparti) { // recherche si ligne fermee
144
145         Standard_Real u,v;
146         const IntSurf_PntOn2S& POn2S1=line->Value(1);
147         //On S1
148         POn2S1.ParametersOnS1(u,v);
149         gp_Pnt2d P1uvS1(u,v);
150         previousPoint.ParametersOnS1(u,v);
151         gp_Pnt2d PrevuvS1(u,v);
152         myIntersectionOn2S.Point().ParametersOnS1(u,v);
153         gp_Pnt2d myIntersuvS1(u,v);
154         Standard_Boolean close2dS1 = (P1uvS1.XY()-PrevuvS1.XY())*
155           (P1uvS1.XY()-myIntersuvS1.XY()) < 0.0;
156         //On S2
157         POn2S1.ParametersOnS2(u,v);
158         gp_Pnt2d P1uvS2(u,v);
159         previousPoint.ParametersOnS2(u,v);
160         gp_Pnt2d PrevuvS2(u,v);
161         myIntersectionOn2S.Point().ParametersOnS2(u,v);
162         gp_Pnt2d myIntersuvS2(u,v);
163         Standard_Boolean close2dS2 = (P1uvS2.XY()-PrevuvS2.XY())*
164           (P1uvS2.XY()-myIntersuvS2.XY()) < 0.0;
165
166         close = close2dS1 && close2dS2;
167         return close;
168       }
169       else return Standard_False;
170     }
171 }
172
173