Integration of OCCT 6.5.0 from SVN
[occt.git] / src / IntWalk / IntWalk_PWalking_4.gxx
CommitLineData
7fd59977 1//-- File : IntWalk_PWalking_4.gxx
2//--
3//-- Modif du 5 Octobre 94 (LBR)
4//-- if(Trouve) ...
5//-- On deborde sur une frontiere, Duv[.] = -1 -1 -1 -1
6//-- donc on garde la meme iso bloquee (voir if(k!=1) )
7//--
8
9//-- Modif du 8 juillet 96 (LBR)
10//-- simplifaication du traitement des auto-intersections.
11//-- Idee :
12//-- Tester la boucle fermee en 3d et en 2d.
13//--
14
15#include <gp_Pnt2d.hxx>
16
17
18Standard_Boolean IntWalk_PWalking::
19 TestArret(const Standard_Boolean DejaReparti,
20 TColStd_Array1OfReal& Param,
21 IntImp_ConstIsoparametric& ChoixIso)
22
23//
24// tester si le point d intersection donne par ces parametres reste dans le
25// domaine naturelle de chaque carreau.
26// si le point deborde cadrer de facon a trouver la meilleure iso (frontiere)
27// qui intersecte le plus franchement l autre carreau
28// sinon tester si presence de ligne fermee
29//
30{
31 Standard_Real Uvd[4],Uvf[4],Epsuv[4],Duv[4],Uvp[4],dv,dv2,ParC[4];
32 Standard_Real DPc,DPb;
33#ifndef DEB
34 Standard_Integer i = 0, k = 0;
35#else
36 Standard_Integer i,k;
37#endif
38 Epsuv[0] = ResoU1;
39 Epsuv[1] = ResoV1;
40 Epsuv[2] = ResoU2;
41 Epsuv[3] = ResoV2;
42 previousPoint.Parameters(Uvp[0],Uvp[1],Uvp[2],Uvp[3]);
43 Standard_Boolean Trouve = Standard_False;
44
45 Uvd[0]=Um1; Uvf[0]=UM1; Uvd[1]=Vm1; Uvf[1]=VM1;
46 Uvd[2]=Um2; Uvf[2]=UM2; Uvd[3]=Vm2; Uvf[3]=VM2;
47
48 Standard_Integer im1;
49 for ( i = 1,im1 = 0;i<=4;i++,im1++) {
50 switch(i) {
51 case 1: k=2; break;
52 case 2: k=1; break;
53 case 3: k=4; break;
54 case 4: k=3; break;
55 }
56 if (Param(i) < (Uvd[im1]-Epsuv[im1])) { //-- Current ----- Bound Inf ----- Previous
57 Trouve = Standard_True; //--
58 DPc = Uvp[im1]-Param(i); //-- Previous - Current
59 DPb = Uvp[im1]-Uvd[im1]; //-- Previous - Bound Inf
60 ParC[im1] = Uvd[im1]; //-- ParamCorrige
61 dv = Param(k)-Uvp[k-1]; //-- Current - Previous (Sur Autre Direction)
62 dv2 = dv*dv;
63 if(dv2>RealEpsilon()) { //-- Progression sur l autre Direction ?
64 Duv[im1] = DPc*DPb + dv2;
65 Duv[im1] = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
66 }
67 else {
68 Duv[im1]=-1.0; //-- Si Pas de prgogression, on ne change pas
69 } //-- le choix de l iso
70 }
71 else if (Param(i) > (Uvf[im1] + Epsuv[im1])) { //-- Previous ----- Bound Sup ----- Current
72 Trouve = Standard_True; //--
73 DPc = Param(i)-Uvp[im1]; //-- Current - Previous
74 DPb = Uvf[im1]-Uvp[im1]; //-- Bound Sup - Previous
75 ParC[im1] = Uvf[im1]; //-- Param Corrige
76 dv = Param(k)-Uvp[k-1]; //-- Current - Previous (Sur autre Direction)
77 dv2 = dv*dv;
78 if(dv2>RealEpsilon()) { //-- Progression sur l autre Direction ?
79 Duv[im1] = DPc*DPb + dv2;
80 Duv[im1] = Duv[im1]*Duv[im1]/(DPc*DPc+dv2)/(DPb*DPb+dv2);
81 }
82 else {
83 Duv[im1]=-1.0; //-- Si Pas de prgogression, on ne change pas
84 } //-- le choix de l iso
85 }
86 else {
87 Duv[im1]= -1.;
88 ParC[im1]=Param(i);
89 }
90 }
91
92 if (Trouve) {
93 //--------------------------------------------------
94 //-- Un des Parametres u1,v1,u2,v2 est en dehors --
95 //-- des bornes naturelles. --
96 //-- On cherche la meilleure direction de --
97 //-- progression et on recadre les params. --
98 //--------------------------------------------------
99 Standard_Real ddv = -1.0;
100 k=-1;
101 for (i=0;i<=3;i++) {
102 Param(i+1) = ParC[i];
103 if(Duv[i]>ddv) {
104 ddv = Duv[i];
105 k=i;
106 }
107 }
108 if(k!=-1) {
109 ChoixIso = ChoixRef[k];
110 }
111 else {
112 if((ParC[0]<=Uvd[0]+Epsuv[0]) || (ParC[0]>=Uvf[0]-Epsuv[0])) {
113 ChoixIso = IntImp_UIsoparametricOnCaro1;
114 }
115 else if((ParC[1]<=Uvd[1]+Epsuv[1]) || (ParC[1]>=Uvf[1]-Epsuv[1])) {
116 ChoixIso = IntImp_VIsoparametricOnCaro1;
117 }
118 else if((ParC[2]<=Uvd[2]+Epsuv[2]) || (ParC[2]>=Uvf[2]-Epsuv[2])) {
119 ChoixIso = IntImp_UIsoparametricOnCaro2;
120 }
121 else if((ParC[3]<=Uvd[3]+Epsuv[3]) || (ParC[3]>=Uvf[3]-Epsuv[3])) {
122 ChoixIso = IntImp_VIsoparametricOnCaro2;
123 }
124 }
125 close = Standard_False;
126 return Standard_True;
127 }
128 else
129 {
130 if (!DejaReparti) { // recherche si ligne fermee
131
132 Standard_Real u,v,up,vp;
133 const IntSurf_PntOn2S& POn2S1=line->Value(1);
134 POn2S1.ParametersOnS1(u,v);
135 gp_Pnt2d P1uv(u,v);
136 previousPoint.ParametersOnS1(u,v);
137 up=u; vp=v;
138 gp_Pnt2d Prevuv(u,v);
139 myIntersectionOn2S.Point().ParametersOnS1(u,v);
140 gp_Pnt2d myIntersuv(u,v);
141 Standard_Boolean close2d = (P1uv.XY()-Prevuv.XY())*
142 (P1uv.XY()-myIntersuv.XY()) <0.0;
143
144 const gp_Pnt &P1 = line->Value(1).Value();
145 close = (P1.XYZ() - previousPoint.Value().XYZ())*
146 (P1.XYZ() - myIntersectionOn2S.Point().Value().XYZ()) < 0;
147 if(close != close2d) {
148#ifdef DEB
149 cout<<"\n PWalking_4 TestArret - close2d"<<close2d<<endl;
150#endif
151 }
152 Standard_Boolean autoclose = Standard_False;
153 previousPoint.ParametersOnS2(u,v);
154 if( myIntersectionOn2S.Function().AuxillarSurface1()
155 == myIntersectionOn2S.Function().AuxillarSurface2()) {
156 if(Abs(u-up)<=1e-7 && Abs(v-vp)<=1e-7) {
157 autoclose=Standard_True;
158 }
159 }
160
161
162
163 return (autoclose || (close&&close2d));
164 }
165 else return Standard_False;
166 }
167}
168
169