1 // Created on: 1995-09-12
2 // Created by: Christophe MARION
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <HLRAlgo.hxx>
20 static const Standard_Real cosu0 = cos(0.*M_PI/14.);
21 static const Standard_Real sinu0 = sin(0.*M_PI/14.);
22 static const Standard_Real cosu1 = cos(1.*M_PI/14.);
23 static const Standard_Real sinu1 = sin(1.*M_PI/14.);
24 static const Standard_Real cosu2 = cos(2.*M_PI/14.);
25 static const Standard_Real sinu2 = sin(2.*M_PI/14.);
26 static const Standard_Real cosu3 = cos(3.*M_PI/14.);
27 static const Standard_Real sinu3 = sin(3.*M_PI/14.);
28 static const Standard_Real cosu4 = cos(4.*M_PI/14.);
29 static const Standard_Real sinu4 = sin(4.*M_PI/14.);
30 static const Standard_Real cosu5 = cos(5.*M_PI/14.);
31 static const Standard_Real sinu5 = sin(5.*M_PI/14.);
32 static const Standard_Real cosu6 = cos(6.*M_PI/14.);
33 static const Standard_Real sinu6 = sin(6.*M_PI/14.);
35 //=======================================================================
36 //function : UpdateMinMax
38 //=======================================================================
40 void HLRAlgo::UpdateMinMax (const Standard_Real x,
41 const Standard_Real y,
42 const Standard_Real z,
43 const Standard_Address Min,
44 const Standard_Address Max)
47 d[ 0] = cosu0 * x + sinu0 * y;
48 d[ 1] = sinu0 * x - cosu0 * y;
49 d[ 2] = cosu1 * x + sinu1 * y;
50 d[ 3] = sinu1 * x - cosu1 * y;
51 d[ 4] = cosu2 * x + sinu2 * y;
52 d[ 5] = sinu2 * x - cosu2 * y;
53 d[ 6] = cosu3 * x + sinu3 * y;
54 d[ 7] = sinu3 * x - cosu3 * y;
55 d[ 8] = cosu4 * x + sinu4 * y;
56 d[ 9] = sinu4 * x - cosu4 * y;
57 d[10] = cosu5 * x + sinu5 * y;
58 d[11] = sinu5 * x - cosu5 * y;
59 d[12] = cosu6 * x + sinu6 * y;
60 d[13] = sinu6 * x - cosu6 * y;
64 Standard_Integer i = 0;
67 if (((Standard_Real*)Min)[i] > d[i]) ((Standard_Real*)Min)[i] = d[i];
68 if (((Standard_Real*)Max)[i] < d[i]) ((Standard_Real*)Max)[i] = d[i];
73 //=======================================================================
74 //function : EnlargeMinMax
76 //=======================================================================
78 void HLRAlgo::EnlargeMinMax (const Standard_Real tol,
79 const Standard_Address Min,
80 const Standard_Address Max)
82 Standard_Integer i = 0;
85 ((Standard_Real*)Min)[i] -= tol;
86 ((Standard_Real*)Max)[i] += tol;
91 //=======================================================================
92 //function :InitMinMax
94 //=======================================================================
96 void HLRAlgo::InitMinMax (const Standard_Real Big,
97 const Standard_Address Min,
98 const Standard_Address Max)
100 Standard_Integer i = 0;
103 ((Standard_Real*)Min)[i] = Big;
104 ((Standard_Real*)Max)[i] = -Big;
109 //=======================================================================
110 //function : EncodeMinMax
112 //=======================================================================
114 void HLRAlgo::EncodeMinMax (const Standard_Address Min,
115 const Standard_Address Max,
116 const Standard_Address MM)
118 ((Standard_Integer*)MM)[ 0] = ((Standard_Integer*)Min)[ 1]&0x00007fff;
119 ((Standard_Integer*)MM)[ 8] = ((Standard_Integer*)Max)[ 1]&0x00007fff;
120 ((Standard_Integer*)MM)[ 0]+=(((Standard_Integer*)Min)[ 0]&0x00007fff)<<16;
121 ((Standard_Integer*)MM)[ 8]+=(((Standard_Integer*)Max)[ 0]&0x00007fff)<<16;
122 ((Standard_Integer*)MM)[ 1] = ((Standard_Integer*)Min)[ 3]&0x00007fff;
123 ((Standard_Integer*)MM)[ 9] = ((Standard_Integer*)Max)[ 3]&0x00007fff;
124 ((Standard_Integer*)MM)[ 1]+=(((Standard_Integer*)Min)[ 2]&0x00007fff)<<16;
125 ((Standard_Integer*)MM)[ 9]+=(((Standard_Integer*)Max)[ 2]&0x00007fff)<<16;
126 ((Standard_Integer*)MM)[ 2] = ((Standard_Integer*)Min)[ 5]&0x00007fff;
127 ((Standard_Integer*)MM)[10] = ((Standard_Integer*)Max)[ 5]&0x00007fff;
128 ((Standard_Integer*)MM)[ 2]+=(((Standard_Integer*)Min)[ 4]&0x00007fff)<<16;
129 ((Standard_Integer*)MM)[10]+=(((Standard_Integer*)Max)[ 4]&0x00007fff)<<16;
130 ((Standard_Integer*)MM)[ 3] = ((Standard_Integer*)Min)[ 7]&0x00007fff;
131 ((Standard_Integer*)MM)[11] = ((Standard_Integer*)Max)[ 7]&0x00007fff;
132 ((Standard_Integer*)MM)[ 3]+=(((Standard_Integer*)Min)[ 6]&0x00007fff)<<16;
133 ((Standard_Integer*)MM)[11]+=(((Standard_Integer*)Max)[ 6]&0x00007fff)<<16;
134 ((Standard_Integer*)MM)[ 4] = ((Standard_Integer*)Min)[ 9]&0x00007fff;
135 ((Standard_Integer*)MM)[12] = ((Standard_Integer*)Max)[ 9]&0x00007fff;
136 ((Standard_Integer*)MM)[ 4]+=(((Standard_Integer*)Min)[ 8]&0x00007fff)<<16;
137 ((Standard_Integer*)MM)[12]+=(((Standard_Integer*)Max)[ 8]&0x00007fff)<<16;
138 ((Standard_Integer*)MM)[ 5] = ((Standard_Integer*)Min)[11]&0x00007fff;
139 ((Standard_Integer*)MM)[13] = ((Standard_Integer*)Max)[11]&0x00007fff;
140 ((Standard_Integer*)MM)[ 5]+=(((Standard_Integer*)Min)[10]&0x00007fff)<<16;
141 ((Standard_Integer*)MM)[13]+=(((Standard_Integer*)Max)[10]&0x00007fff)<<16;
142 ((Standard_Integer*)MM)[ 6] = ((Standard_Integer*)Min)[13]&0x00007fff;
143 ((Standard_Integer*)MM)[14] = ((Standard_Integer*)Max)[13]&0x00007fff;
144 ((Standard_Integer*)MM)[ 6]+=(((Standard_Integer*)Min)[12]&0x00007fff)<<16;
145 ((Standard_Integer*)MM)[14]+=(((Standard_Integer*)Max)[12]&0x00007fff)<<16;
146 ((Standard_Integer*)MM)[ 7] = ((Standard_Integer*)Min)[15]&0x00007fff;
147 ((Standard_Integer*)MM)[15] = ((Standard_Integer*)Max)[15]&0x00007fff;
148 ((Standard_Integer*)MM)[ 7]+=(((Standard_Integer*)Min)[14]&0x00007fff)<<16;
149 ((Standard_Integer*)MM)[15]+=(((Standard_Integer*)Max)[14]&0x00007fff)<<16;
152 //=======================================================================
155 //=======================================================================
157 Standard_Real HLRAlgo::SizeBox(const Standard_Address Min,
158 const Standard_Address Max)
160 Standard_Real s = ((Standard_Integer *)Max)[0] - ((Standard_Integer *)Min)[0];
161 Standard_Integer i = 1;
164 s *= ((Standard_Integer *)Max)[i] - ((Standard_Integer *)Min)[i];
170 //=======================================================================
171 //function : DecodeMinMax
173 //=======================================================================
175 void HLRAlgo::DecodeMinMax (const Standard_Address MM,
176 const Standard_Address Min,
177 const Standard_Address Max)
179 ((Standard_Integer*)Min)[ 0]=(((Standard_Integer*)MM)[ 0]&0x7fff0000)>>16;
180 ((Standard_Integer*)Max)[ 0]=(((Standard_Integer*)MM)[ 8]&0x7fff0000)>>16;
181 ((Standard_Integer*)Min)[ 1]= ((Standard_Integer*)MM)[ 0]&0x00007fff;
182 ((Standard_Integer*)Max)[ 1]= ((Standard_Integer*)MM)[ 8]&0x00007fff;
183 ((Standard_Integer*)Min)[ 2]=(((Standard_Integer*)MM)[ 1]&0x7fff0000)>>16;
184 ((Standard_Integer*)Max)[ 2]=(((Standard_Integer*)MM)[ 9]&0x7fff0000)>>16;
185 ((Standard_Integer*)Min)[ 3]= ((Standard_Integer*)MM)[ 1]&0x00007fff;
186 ((Standard_Integer*)Max)[ 3]= ((Standard_Integer*)MM)[ 9]&0x00007fff;
187 ((Standard_Integer*)Min)[ 4]=(((Standard_Integer*)MM)[ 2]&0x7fff0000)>>16;
188 ((Standard_Integer*)Max)[ 4]=(((Standard_Integer*)MM)[10]&0x7fff0000)>>16;
189 ((Standard_Integer*)Min)[ 5]= ((Standard_Integer*)MM)[ 2]&0x00007fff;
190 ((Standard_Integer*)Max)[ 5]= ((Standard_Integer*)MM)[10]&0x00007fff;
191 ((Standard_Integer*)Min)[ 6]=(((Standard_Integer*)MM)[ 3]&0x7fff0000)>>16;
192 ((Standard_Integer*)Max)[ 6]=(((Standard_Integer*)MM)[11]&0x7fff0000)>>16;
193 ((Standard_Integer*)Min)[ 7]= ((Standard_Integer*)MM)[ 3]&0x00007fff;
194 ((Standard_Integer*)Max)[ 7]= ((Standard_Integer*)MM)[11]&0x00007fff;
195 ((Standard_Integer*)Min)[ 8]=(((Standard_Integer*)MM)[ 4]&0x7fff0000)>>16;
196 ((Standard_Integer*)Max)[ 8]=(((Standard_Integer*)MM)[12]&0x7fff0000)>>16;
197 ((Standard_Integer*)Min)[ 9]= ((Standard_Integer*)MM)[ 4]&0x00007fff;
198 ((Standard_Integer*)Max)[ 9]= ((Standard_Integer*)MM)[12]&0x00007fff;
199 ((Standard_Integer*)Min)[10]=(((Standard_Integer*)MM)[ 5]&0x7fff0000)>>16;
200 ((Standard_Integer*)Max)[10]=(((Standard_Integer*)MM)[13]&0x7fff0000)>>16;
201 ((Standard_Integer*)Min)[11]= ((Standard_Integer*)MM)[ 5]&0x00007fff;
202 ((Standard_Integer*)Max)[11]= ((Standard_Integer*)MM)[13]&0x00007fff;
203 ((Standard_Integer*)Min)[12]=(((Standard_Integer*)MM)[ 6]&0x7fff0000)>>16;
204 ((Standard_Integer*)Max)[12]=(((Standard_Integer*)MM)[14]&0x7fff0000)>>16;
205 ((Standard_Integer*)Min)[13]= ((Standard_Integer*)MM)[ 6]&0x00007fff;
206 ((Standard_Integer*)Max)[13]= ((Standard_Integer*)MM)[14]&0x00007fff;
207 ((Standard_Integer*)Min)[14]=(((Standard_Integer*)MM)[ 7]&0x7fff0000)>>16;
208 ((Standard_Integer*)Max)[14]=(((Standard_Integer*)MM)[15]&0x7fff0000)>>16;
209 ((Standard_Integer*)Min)[15]= ((Standard_Integer*)MM)[ 7]&0x00007fff;
210 ((Standard_Integer*)Max)[15]= ((Standard_Integer*)MM)[15]&0x00007fff;
213 //=======================================================================
214 //function :CopyMinMax
216 //=======================================================================
218 void HLRAlgo::CopyMinMax (const Standard_Address IMin,
219 const Standard_Address IMax,
220 const Standard_Address OMin,
221 const Standard_Address OMax)
223 Standard_Integer i = 0;
226 ((Standard_Integer*)OMin)[i]=((Standard_Integer*)IMin)[i];
227 ((Standard_Integer*)OMax)[i]=((Standard_Integer*)IMax)[i];
232 //=======================================================================
233 //function :AddMinMax
235 //=======================================================================
237 void HLRAlgo::AddMinMax (const Standard_Address IMin,
238 const Standard_Address IMax,
239 const Standard_Address OMin,
240 const Standard_Address OMax)
242 Standard_Integer i = 0;
245 if (((Standard_Integer*)OMin)[i] > ((Standard_Integer*)IMin)[i])
246 ((Standard_Integer*)OMin)[i]=((Standard_Integer*)IMin)[i];
247 if (((Standard_Integer*)OMax)[i] < ((Standard_Integer*)IMax)[i])
248 ((Standard_Integer*)OMax)[i]=((Standard_Integer*)IMax)[i];