Commit | Line | Data |
---|---|---|
b311480e | 1 | // Copyright (c) 1995-1999 Matra Datavision |
973c2be1 | 2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 3 | // |
973c2be1 | 4 | // This file is part of Open CASCADE Technology software library. |
b311480e | 5 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 11 | // |
973c2be1 | 12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. | |
b311480e | 14 | |
7fd59977 | 15 | /*********************************************************************** |
16 | ||
17 | FONCTION : | |
18 | ---------- | |
19 | File OpenGl_telem_util : | |
20 | ||
21 | ||
22 | REMARQUES: | |
23 | ---------- | |
24 | ||
25 | ||
26 | HISTORIQUE DES MODIFICATIONS : | |
27 | -------------------------------- | |
28 | xx-xx-xx : xxx ; Creation. | |
29 | 07-02-96 : FMN ; - Ajout trace | |
30 | - Suppression code inutile | |
31 | 08-03-96 : FMN ; - Ajout include manquant | |
32 | 01-04-96 : CAL ; Integration MINSK portage WNT | |
33 | 15-04-96 : CAL ; Integration travail PIXMAP de Jim ROTH | |
34 | 22-04-96 : FMN ; Ajout TelReadImage TelDrawImage | |
35 | 10-05-96 : CAL ; Ajout d'un nouveau delta dans les copies | |
36 | de pixels (voir CALL_DEF_DELTA) | |
37 | 25-06-96 : FMN ; Suppression utilisation de glScissor. | |
38 | 02-07-96 : FMN ; Suppression WSWSHeight et WSWSWidth | |
39 | Suppression glViewport inutile. | |
40 | 18-07-96 : FMN ; Suppression TelFlush inutile. | |
41 | 08-07-96 : FMN ; Suppression de OPENGL_DEBUG inutile avec la nouvelle | |
42 | version de ogldebug. | |
43 | 24-10-96 : CAL ; Portage WNT | |
44 | 23-01-97 : CAL ; Suppression de TelClearViews dans TelCopyBuffers | |
45 | 30-01-97 : FMN ; Ajout commentaires + WNT. | |
46 | 12-02-97 : FMN ; Suppression TelEnquireFacilities() | |
47 | 22-04-97 : FMN ; Ajout affichage du cadre pour la copie de buffer | |
48 | 30-06-97 : FMN ; Suppression OpenGl_telem_light.h | |
49 | 18-07-97 : FMN ; Utilisation de la toolkit sur les lights | |
50 | 07-10-97 : FMN ; Simplification WNT + correction Transient | |
51 | 05-12-97 : FMN ; PRO11168: Suppression TglActiveWs pour project/unproject | |
52 | 23-12-97 : FMN ; Suppression TelSetFrontFaceAttri et TelSetBackFaceAttri | |
53 | 30-12-97 : FMN ; CTS18312: Correction back material | |
54 | 04-05-98 : CAL ; Contournement bug SGI octane bavure de pixels (PRO12899) | |
55 | 30-09-98 : CAL ; Optimisation pour eviter de charger inutilement | |
56 | les matrices de la vue. | |
57 | 19-10-98 : FMN ; Suppression de glPixelTransferi dans TelEnable() car cela | |
58 | rentre en conflit avec l'utilisation d'une image de fond. | |
59 | 02.14.100 : JR : Warnings on WNT truncations from double to float | |
60 | 08-03-01 : GG ; BUC60823 Avoid crash in the normal computation method | |
61 | when a face has confused or aligned points. | |
62 | ||
63 | ************************************************************************/ | |
64 | ||
d64e6d05 | 65 | #include <stdio.h> |
66 | ||
5f8b738e | 67 | #include <OpenGl_GlCore11.hxx> |
7fd59977 | 68 | |
7fd59977 | 69 | #include <OpenGl_telem_util.hxx> |
2166f0fa SK |
70 | #include <InterfaceGraphic_Graphic3d.hxx> |
71 | #include <InterfaceGraphic_Visual3d.hxx> | |
7fd59977 | 72 | |
7fd59977 | 73 | #define GPRECIS 0.000001 |
74 | Tint TelGetPolygonNormal(tel_point pnts, Tint* indexs, Tint npnt, Tfloat *norm ) { | |
75 | Tint status=0; | |
76 | ||
77 | norm[0] = norm[1] = norm[2] = 0.; | |
78 | if( npnt > 2 ) { | |
79 | Tfloat a[3], b[3], c[3]; | |
80 | Tint i,j,i0,ii=0,jj; | |
81 | ||
82 | i0 = 0; if( indexs ) i0 = indexs[0]; | |
83 | for( i=1 ; i<npnt ; i++ ) { | |
84 | ii = i; if( indexs ) ii = indexs[i]; | |
85 | vecsub( a, pnts[ii].xyz, pnts[i0].xyz ); | |
86 | if( vecmg2(a) > GPRECIS ) break; | |
87 | } | |
88 | if( i < npnt-1 ) { | |
89 | for( j=i+1 ; j<npnt ; j++ ) { | |
90 | jj = j; if( indexs ) jj = indexs[j]; | |
91 | vecsub( b, pnts[jj].xyz, pnts[i0].xyz ); | |
92 | vecsub( c, pnts[jj].xyz, pnts[ii].xyz ); | |
93 | if( (vecmg2(b) > GPRECIS) && (vecmg2(c) > GPRECIS) ) break; | |
94 | } | |
95 | if( j < npnt ) { | |
96 | Tfloat d; | |
97 | veccrs( norm, a, b ); | |
98 | d = vecnrmd( norm, d ); | |
99 | status = (d > 0.) ? 1 : 0; | |
100 | } | |
101 | } | |
102 | } | |
0797d9d3 | 103 | #ifdef OCCT_DEBUG |
7fd59977 | 104 | if( !status ) |
105 | printf(" *** OpenGl_TelGetPolygonNormal.has found confused or aligned points\n"); | |
106 | #endif | |
107 | ||
108 | return status; | |
109 | } | |
110 | ||
111 | Tint TelGetNormal(Tfloat *data1, Tfloat *data2, Tfloat *data3, Tfloat *norm ) { | |
112 | Tfloat a[3], b[3]; | |
113 | Tint status=0; | |
114 | ||
115 | norm[0] = norm[1] = norm[2] = 0.; | |
116 | vecsub( a, data2, data1 ); | |
117 | vecsub( b, data3, data2 ); | |
118 | if( (vecmg2(a) > GPRECIS) && (vecmg2(b) > GPRECIS) ) { | |
119 | Tfloat d; | |
120 | veccrs( norm, a, b ); | |
121 | d = vecnrmd( norm, d ); | |
122 | status = (d > 0.) ? 1 : 0; | |
123 | } | |
0797d9d3 | 124 | #ifdef OCCT_DEBUG |
7fd59977 | 125 | if( !status ) |
126 | printf(" *** OpenGl_TelGetNormal.has found confused or aligned points\n"); | |
127 | #endif | |
128 | ||
129 | return status; | |
130 | } | |
7fd59977 | 131 | |
2166f0fa | 132 | void TelMultiplymat3 (Tmatrix3 c, Tmatrix3 a, Tmatrix3 b) |
7fd59977 | 133 | { |
134 | Tint row, col, i; | |
135 | Tmatrix3 res; | |
136 | Tint dim = 4; | |
137 | ||
138 | /* on multiplie d'abord les 2 matrices dim x dim */ | |
139 | for (row = 0; row < dim; row++) { | |
140 | for (col = 0; col < dim; col++) { | |
141 | Tfloat sum = ( float )0.0; | |
142 | for (i = 0; i < dim; i++) | |
143 | sum += a[row][i] * b[i][col]; | |
144 | res[row][col] = sum; | |
145 | } | |
146 | } | |
147 | ||
148 | /* on copie ensuite le resultat */ | |
149 | matcpy (c, res); | |
150 | ||
151 | return; | |
152 | } |