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>
17 #include <Standard_OutOfRange.hxx>
19 static const IntImp_ConstIsoparametric staticChoixRef [4] = {
20 IntImp_UIsoparametricOnCaro1,
21 IntImp_VIsoparametricOnCaro1,
22 IntImp_UIsoparametricOnCaro2,
23 IntImp_VIsoparametricOnCaro2,
26 IntImp_ConstIsoparametric ChoixRef (Standard_Integer theIndex)
28 Standard_OutOfRange_Raise_if (theIndex < 0 || theIndex > 3, "ChoixRef() in " __FILE__)
29 return staticChoixRef[theIndex];
32 //=======================================================================
33 //function : IntImp_ComputeTangence
35 //=======================================================================
36 Standard_Boolean IntImp_ComputeTangence(const gp_Vec DPuv[],
37 const Standard_Real EpsUV[],
38 Standard_Real Tgduv[],
39 IntImp_ConstIsoparametric TabIso[])
40 // arguments d entree:
41 // DPuv [0] =derivee en u sur caro 1
42 // DPuv [1] =derivee en v sur caro 1
43 // DPuv [2] =derivee en u sur caro 2
44 // DPuv [3] =derivee en v sur caro 2
45 // EpsUV[0] tolerance en u sur caro1
46 // EpsUV[1] tolerance en v sur caro1
47 // EpsUV[2] tolerance en u sur caro2
48 // EpsUV[3] tolerance en v sur caro2
49 // arguments de sortie:
50 // Tgduv[0] composante sup dp/du de caro1 de la tangente a l intersection
51 // Tgduv[1] composante sup dp/dv de caro1 de la tangente a l intersection
52 // Tgduv[2] composante sup dp/du de caro2 de la tangente a l intersection
53 // Tgduv[3] composante sup dp/dv de caro2 de la tangente a l intersection
54 // TabIso[0...3] meilleure iso range par ordre decroissant candidate
57 // calculer la tangente a l 'intersection ;en utilisant la propriete suivante
58 // du produit scalaire a^(b^c)=b(ac)-c(ab) on obtient les composantes de la
59 // tangente a l intersection dans les 2 plans tangents (t=n1^n2 ou n1 normale
60 // au premier carreau n2 au 2ieme)
61 // on s assurera que les plans tangents des 2 carreaux ne sont pas //
62 // les composantes de l intersection dans les plans tangents permettent de
63 //determiner l angle entre les isoparametriques d un carreau avec le carreau
65 //on triera par ordre croissant les cosinus :le plus petit cosinus determine le
66 // meilleure angle donc la meilleure iso a choisir pour trouver
70 Standard_Real NormDuv[4], aM2, aTol2;
76 NormDuv[i] = DPuv[i].SquareMagnitude();
77 if(NormDuv[i]<=aTol2) {
82 //-------------------------------------------------
86 //modified by NIZNHY-PKV Tue Nov 01 08:37:32 2011f
87 aM2=N1.SquareMagnitude();
91 //modified by NIZNHY-PKV Tue Nov 01 08:37:34 2011t
93 //-------------------------------------------------
96 //modified by NIZNHY-PKV Tue Nov 01 08:37:32 2011f
97 aM2=N2.SquareMagnitude();
101 //modified by NIZNHY-PKV Tue Nov 01 08:37:34 2011t
104 //modified by NIZNHY-PKV Tue Nov 01 08:31:25 2011f
105 for (i=0; i<4; ++i) {
106 NormDuv[i]=sqrt(NormDuv[i]);
108 //modified by NIZNHY-PKV Tue Nov 01 08:31:29 2011t
109 Tgduv[0] = -DPuv[1].Dot(N2);
110 Tgduv[1] = DPuv[0].Dot(N2);
111 Tgduv[2] = DPuv[3].Dot(N1);
112 Tgduv[3] = -DPuv[2].Dot(N1);
115 Standard_Boolean tangent = (Abs(Tgduv[0]) <= EpsUV[0]*NormDuv[1] &&
116 Abs(Tgduv[1]) <= EpsUV[1]*NormDuv[0] &&
117 Abs(Tgduv[2]) <= EpsUV[2]*NormDuv[3] &&
118 Abs(Tgduv[3]) <= EpsUV[3]*NormDuv[2] );
120 Standard_Real t=N1.Dot(N2);
123 tangent=Standard_True;
128 NormDuv[0] = Abs(Tgduv[1]) /NormDuv[0]; //iso u sur caro1
129 NormDuv[1] = Abs(Tgduv[0]) /NormDuv[1]; //iso v sur caro1
130 NormDuv[2] = Abs(Tgduv[3]) /NormDuv[2]; // iso u sur caro2
131 NormDuv[3] = Abs(Tgduv[2]) /NormDuv[3]; //iso v sur caro2
135 //-- Tri sur NormDuv ( en para. avec ChoixRef )
136 Standard_Boolean triOk = Standard_False;
138 IntImp_ConstIsoparametric ti;
141 TabIso[i] = staticChoixRef[i];
144 triOk = Standard_True;
146 if(NormDuv[i-1]>NormDuv[i]) {
147 triOk=Standard_False;
149 NormDuv[i]=NormDuv[i-1];
153 TabIso[i] = TabIso[i-1];
162 // trier par ordre croissant le tableau NormDuv
164 for (j =0;j<=3;j++) Irang[j]=j;
165 for (j =0;j<=3;j++) {
168 for (i =j+1;i<=3;i++) {
169 if (NormDuv[i] < Tampon) {
174 Irang[j] = Irang[II];
176 NormDuv[II] = NormDuv[j];
181 TabIso[j] = staticChoixRef[Irang[j]];