1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <IntImp_ComputeTangence.hxx>
16 #include <IntImp_ConstIsoparametric.hxx>
18 static const IntImp_ConstIsoparametric staticChoixRef [4] = {
19 IntImp_UIsoparametricOnCaro1,
20 IntImp_VIsoparametricOnCaro1,
21 IntImp_UIsoparametricOnCaro2,
22 IntImp_VIsoparametricOnCaro2,
25 Standard_EXPORT const IntImp_ConstIsoparametric *ChoixRef = staticChoixRef ;
27 //=======================================================================
28 //function : IntImp_ComputeTangence
30 //=======================================================================
31 Standard_Boolean IntImp_ComputeTangence(const gp_Vec DPuv[],
32 const Standard_Real EpsUV[],
33 Standard_Real Tgduv[],
34 IntImp_ConstIsoparametric TabIso[])
35 // arguments d entree:
36 // DPuv [0] =derivee en u sur caro 1
37 // DPuv [1] =derivee en v sur caro 1
38 // DPuv [2] =derivee en u sur caro 2
39 // DPuv [3] =derivee en v sur caro 2
40 // EpsUV[0] tolerance en u sur caro1
41 // EpsUV[1] tolerance en v sur caro1
42 // EpsUV[2] tolerance en u sur caro2
43 // EpsUV[3] tolerance en v sur caro2
44 // arguments de sortie:
45 // Tgduv[0] composante sup dp/du de caro1 de la tangente a l intersection
46 // Tgduv[1] composante sup dp/dv de caro1 de la tangente a l intersection
47 // Tgduv[2] composante sup dp/du de caro2 de la tangente a l intersection
48 // Tgduv[3] composante sup dp/dv de caro2 de la tangente a l intersection
49 // TabIso[0...3] meilleure iso range par ordre decroissant candidate
52 // calculer la tangente a l 'intersection ;en utilisant la propriete suivante
53 // du produit scalaire a^(b^c)=b(ac)-c(ab) on obtient les composantes de la
54 // tangente a l intersection dans les 2 plans tangents (t=n1^n2 ou n1 normale
55 // au premier carreau n2 au 2ieme)
56 // on s assurera que les plans tangents des 2 carreaux ne sont pas //
57 // les composantes de l intersection dans les plans tangents permettent de
58 //determiner l angle entre les isoparametriques d un carreau avec le carreau
60 //on triera par ordre croissant les cosinus :le plus petit cosinus determine le
61 // meilleure angle donc la meilleure iso a choisir pour trouver
65 Standard_Real NormDuv[4], aM2, aTol2;
71 NormDuv[i] = DPuv[i].SquareMagnitude();
72 if(NormDuv[i]<=aTol2) {
77 //-------------------------------------------------
81 //modified by NIZNHY-PKV Tue Nov 01 08:37:32 2011f
82 aM2=N1.SquareMagnitude();
86 //modified by NIZNHY-PKV Tue Nov 01 08:37:34 2011t
88 //-------------------------------------------------
91 //modified by NIZNHY-PKV Tue Nov 01 08:37:32 2011f
92 aM2=N2.SquareMagnitude();
96 //modified by NIZNHY-PKV Tue Nov 01 08:37:34 2011t
99 //modified by NIZNHY-PKV Tue Nov 01 08:31:25 2011f
100 for (i=0; i<4; ++i) {
101 NormDuv[i]=sqrt(NormDuv[i]);
103 //modified by NIZNHY-PKV Tue Nov 01 08:31:29 2011t
104 Tgduv[0] = -DPuv[1].Dot(N2);
105 Tgduv[1] = DPuv[0].Dot(N2);
106 Tgduv[2] = DPuv[3].Dot(N1);
107 Tgduv[3] = -DPuv[2].Dot(N1);
110 Standard_Boolean tangent = (Abs(Tgduv[0]) <= EpsUV[0]*NormDuv[1] &&
111 Abs(Tgduv[1]) <= EpsUV[1]*NormDuv[0] &&
112 Abs(Tgduv[2]) <= EpsUV[2]*NormDuv[3] &&
113 Abs(Tgduv[3]) <= EpsUV[3]*NormDuv[2] );
115 Standard_Real t=N1.Dot(N2);
118 tangent=Standard_True;
123 NormDuv[0] = Abs(Tgduv[1]) /NormDuv[0]; //iso u sur caro1
124 NormDuv[1] = Abs(Tgduv[0]) /NormDuv[1]; //iso v sur caro1
125 NormDuv[2] = Abs(Tgduv[3]) /NormDuv[2]; // iso u sur caro2
126 NormDuv[3] = Abs(Tgduv[2]) /NormDuv[3]; //iso v sur caro2
130 //-- Tri sur NormDuv ( en para. avec ChoixRef )
131 Standard_Boolean triOk = Standard_False;
133 IntImp_ConstIsoparametric ti;
134 for ( i=0;i<=3;i++) TabIso[i] = ChoixRef[i];
136 triOk = Standard_True;
138 if(NormDuv[i-1]>NormDuv[i]) {
139 triOk=Standard_False;
141 NormDuv[i]=NormDuv[i-1];
145 TabIso[i] = TabIso[i-1];
154 // trier par ordre croissant le tableau NormDuv
156 for (j =0;j<=3;j++) Irang[j]=j;
157 for (j =0;j<=3;j++) {
160 for (i =j+1;i<=3;i++) {
161 if (NormDuv[i] < Tampon) {
166 Irang[j] = Irang[II];
168 NormDuv[II] = NormDuv[j];
171 for (j=0; j<=3;j++) TabIso[j]=ChoixRef[Irang[j]];