1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
20 //-- Modif du 5 Octobre 94 (LBR)
22 //-- On deborde sur une frontiere, Duv[.] = -1 -1 -1 -1
23 //-- donc on garde la meme iso bloquee (voir if(k!=1) )
26 //-- Modif du 8 juillet 96 (LBR)
27 //-- simplifaication du traitement des auto-intersections.
29 //-- Tester la boucle fermee en 3d et en 2d.
32 #include <gp_Pnt2d.hxx>
35 Standard_Boolean IntWalk_PWalking::
36 TestArret(const Standard_Boolean DejaReparti,
37 TColStd_Array1OfReal& Param,
38 IntImp_ConstIsoparametric& ChoixIso)
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
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;
55 previousPoint.Parameters(Uvp[0],Uvp[1],Uvp[2],Uvp[3]);
56 Standard_Boolean Trouve = Standard_False;
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;
62 for ( i = 1,im1 = 0;i<=4;i++,im1++) {
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)
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);
81 Duv[im1]=-1.0; //-- Si Pas de prgogression, on ne change pas
82 } //-- le choix de l iso
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)
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);
96 Duv[im1]=-1.0; //-- Si Pas de prgogression, on ne change pas
97 } //-- le choix de l iso
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;
115 Param(i+1) = ParC[i];
122 ChoixIso = ChoixRef[k];
125 if((ParC[0]<=Uvd[0]+Epsuv[0]) || (ParC[0]>=Uvf[0]-Epsuv[0])) {
126 ChoixIso = IntImp_UIsoparametricOnCaro1;
128 else if((ParC[1]<=Uvd[1]+Epsuv[1]) || (ParC[1]>=Uvf[1]-Epsuv[1])) {
129 ChoixIso = IntImp_VIsoparametricOnCaro1;
131 else if((ParC[2]<=Uvd[2]+Epsuv[2]) || (ParC[2]>=Uvf[2]-Epsuv[2])) {
132 ChoixIso = IntImp_UIsoparametricOnCaro2;
134 else if((ParC[3]<=Uvd[3]+Epsuv[3]) || (ParC[3]>=Uvf[3]-Epsuv[3])) {
135 ChoixIso = IntImp_VIsoparametricOnCaro2;
138 close = Standard_False;
139 return Standard_True;
143 if (!DejaReparti) { // recherche si ligne fermee
146 const IntSurf_PntOn2S& POn2S1=line->Value(1);
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;
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;
166 close = close2dS1 && close2dS2;
169 else return Standard_False;