• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NREL / SolTrace / 14868779160

06 May 2025 08:10PM UTC coverage: 44.154% (+0.5%) from 43.617%
14868779160

Pull #65

github

web-flow
Merge 8d1b66799 into 96166e291
Pull Request #65: Refactor the Trace function (and related functions)

363 of 670 new or added lines in 6 files covered. (54.18%)

135 existing lines in 4 files now uncovered.

1941 of 4396 relevant lines covered (44.15%)

10000057.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

43.6
/coretrace/determineelementintersectionnew.cpp
1

2
/*******************************************************************************************************
3
*  Copyright 2018 Alliance for Sustainable Energy, LLC
4
*
5
*  NOTICE: This software was developed at least in part by Alliance for Sustainable Energy, LLC
6
*  ("Alliance") under Contract No. DE-AC36-08GO28308 with the U.S. Department of Energy and the U.S.
7
*  The Government retains for itself and others acting on its behalf a nonexclusive, paid-up,
8
*  irrevocable worldwide license in the software to reproduce, prepare derivative works, distribute
9
*  copies to the public, perform publicly and display publicly, and to permit others to do so.
10
*
11
*  Redistribution and use in source and binary forms, with or without modification, are permitted
12
*  provided that the following conditions are met:
13
*
14
*  1. Redistributions of source code must retain the above copyright notice, the above government
15
*  rights notice, this list of conditions and the following disclaimer.
16
*
17
*  2. Redistributions in binary form must reproduce the above copyright notice, the above government
18
*  rights notice, this list of conditions and the following disclaimer in the documentation and/or
19
*  other materials provided with the distribution.
20
*
21
*  3. The entire corresponding source code of any redistribution, with or without modification, by a
22
*  research entity, including but not limited to any contracting manager/operator of a United States
23
*  National Laboratory, any institution of higher learning, and any non-profit organization, must be
24
*  made publicly available under this license for as long as the redistribution is made available by
25
*  the research entity.
26
*
27
*  4. Redistribution of this software, without modification, must refer to the software by the same
28
*  designation. Redistribution of a modified version of this software (i) may not refer to the modified
29
*  version by the same designation, or by any confusingly similar designation, and (ii) must refer to
30
*  the underlying software originally provided by Alliance as "SolTrace". Except to comply with the 
31
*  foregoing, the term "SolTrace", or any confusingly similar designation may not be used to refer to 
32
*  any modified version of this software or any modified version of the underlying software originally 
33
*  provided by Alliance without the prior written consent of Alliance.
34
*
35
*  5. The name of the copyright holder, contributors, the United States Government, the United States
36
*  Department of Energy, or any of their employees may not be used to endorse or promote products
37
*  derived from this software without specific prior written permission.
38
*
39
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
40
*  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
41
*  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER,
42
*  CONTRIBUTORS, UNITED STATES GOVERNMENT OR UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR
43
*  EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44
*  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
46
*  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
47
*  THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48
*******************************************************************************************************/
49

50

51

52
#include <stdio.h>
53
#include <stdlib.h>
54
#include <math.h>
55
#include "types.h"
56
#include "procs.h"
57

58
void DetermineElementIntersectionNew(
280,729,521✔
59
                        TElement *Element,
60
                        double PosRayIn[3],
61
                        double CosRayIn[3],
62
                        double PosRayOut[3],
63
                        double CosRayOut[3],
64
                        double DFXYZ[3],
65
                        double *PathLength,
66
                        int *ErrorFlag,
67
                        int *Intercept,
68
                        int *BacksideFlag )
69
{
70
        double r = 0.0, Ro = 0.0, Ri = 0.0, XL = 0.0, x = 0.0, y = 0.0;
280,729,521✔
71
        double /*SLOP30 = 0.0, SLOP60 = 0.0,*/ Y1 = 0.0, Y2 = 0.0, Y3 = 0.0, Y4 = 0.0;
280,729,521✔
72
        double P1x = 0.0, P1y = 0.0, P2x = 0.0, P2y = 0.0, P3x = 0.0, P3y = 0.0, P4x = 0.0, P4y = 0.0;
280,729,521✔
73
        //double Tn;
74
        int in_quad = 0;
280,729,521✔
75
   //ZAperPlane: real;
76

77
        *ErrorFlag = 0;
280,729,521✔
78
        double SLOP30 = 0.57735026918962573; //tan(30.0*(acos(-1.0)/180.0));
280,729,521✔
79
        double SLOP60 = 1.7320508075688767; //tan(60.0*(acos(-1.0)/180.0));
280,729,521✔
80

81
        //AperturePlane(Element);           <------- calculated now in ODConcentrator
82
        //ZAperPlane = Element->ZAperture;
83

84
        //find intersection with surface first
85
        Intersect(PosRayIn, CosRayIn, Element, PosRayOut, CosRayOut, DFXYZ, PathLength, ErrorFlag);
280,729,521✔
86
        if (*ErrorFlag > 0 || *PathLength < 0)
280,729,521✔
87
        {
88
                *Intercept = 0;
45,358✔
89
                PosRayOut[0] = 0.0;
45,358✔
90
                PosRayOut[1] = 0.0;
45,358✔
91
                PosRayOut[2] = 0.0;
45,358✔
92
                CosRayOut[0] = 0.0;
45,358✔
93
                CosRayOut[1] = 0.0;
45,358✔
94
                CosRayOut[2] = 0.0;
45,358✔
95
                DFXYZ[0] = 0.0;
45,358✔
96
                DFXYZ[1] = 0.0;
45,358✔
97
                DFXYZ[2] = 0.0;
45,358✔
98
                *BacksideFlag = 0;
45,358✔
99
                *PathLength = 0.0;
45,358✔
100
                //goto Label_100;
101
                return;
45,358✔
102
        }
103

104
        x = PosRayOut[0];
280,684,163✔
105
        y = PosRayOut[1];
280,684,163✔
106
        r = sqrt(x*x + y*y);
280,684,163✔
107

108

109

110
        switch (Element->ShapeIndex)
280,684,163✔
111
        {
112
        case 'c':
12,726✔
113
        case 'C': //circular aperture
114
                        Ro = Element->ParameterA/2.0;
12,726✔
115

116
                        if (r > Ro) //ray falls outsideside circular aperture
12,726✔
117
                        {
118
                           *Intercept = 0;
2,726✔
119
                           PosRayOut[0] = 0.0;
2,726✔
120
                           PosRayOut[1] = 0.0;
2,726✔
121
                           PosRayOut[2] = 0.0;
2,726✔
122
                           CosRayOut[0] = 0.0;
2,726✔
123
                           CosRayOut[1] = 0.0;
2,726✔
124
                           CosRayOut[2] = 0.0;
2,726✔
125
                           DFXYZ[0] = 0.0;
2,726✔
126
                           DFXYZ[1] = 0.0;
2,726✔
127
                           DFXYZ[2] = 0.0;
2,726✔
128
                           *PathLength = 0.0;
2,726✔
129
                           *ErrorFlag = 0;
2,726✔
130
                           *BacksideFlag = 0;
2,726✔
131
                           //goto Label_100;
132
                           break;
2,726✔
133
                        }
134
                        else
135
                        {
136
                                if (DOT(CosRayIn, DFXYZ) < 0)
10,000✔
137
                                        *BacksideFlag = 0;
10,000✔
138
                                else
139
                                        *BacksideFlag = 1;
×
140
                                *Intercept = 1;
10,000✔
141
                                //goto Label_100;
142
                                break;
10,000✔
143
                        }
144
                break;
145
        
146
        case 'h':
237,826✔
147
        case 'H': //hexagonal aperture
148
                        Ro = Element->ParameterA/2.0;
237,826✔
149

150
                        if (r > Ro) //ray falls outside circular circumference aperture
237,826✔
151
                        {
152
                           *Intercept = 0;
234,037✔
153
                           PosRayOut[0] = 0.0;
234,037✔
154
                           PosRayOut[1] = 0.0;
234,037✔
155
                           PosRayOut[2] = 0.0;
234,037✔
156
                           CosRayOut[0] = 0.0;
234,037✔
157
                           CosRayOut[1] = 0.0;
234,037✔
158
                           CosRayOut[2] = 0.0;
234,037✔
159
                           DFXYZ[0] = 0.0;
234,037✔
160
                           DFXYZ[1] = 0.0;
234,037✔
161
                           DFXYZ[2] = 0.0;
234,037✔
162
                           *PathLength = 0.0;
234,037✔
163
                           *ErrorFlag = 0;
234,037✔
164
                           *BacksideFlag = 0;
234,037✔
165
                           //goto Label_100;
166
                           break;
234,037✔
167
                        }
168
                        Ri = Ro*cos(30.0*(ACOSM1O180));
3,789✔
169

170
                        if ( r <= Ri ) //ray falls inside inscribed circle
3,789✔
171
                        {
172
                                if ( DOT(CosRayIn, DFXYZ) < 0 )
2,880✔
173
                                        *BacksideFlag = 0;
2,879✔
174
                                else
175
                                        *BacksideFlag = 1;
1✔
176
                                *Intercept = 1;
2,880✔
177
                                //goto Label_100;
178
                                break;
2,880✔
179
                        }
180

181
                        XL = sqrt(Ro*Ro - Ri*Ri); //otherwise break hexagon into 3 sections
909✔
182
                        if ( (x <= Ro) && (x > XL) )  //1st section
909✔
183
                        {
184
                                Y1 = SLOP60*(x-Ro);
276✔
185
                                Y2 = -Y1;
276✔
186
                                if ( (y >= Y1) && (y <= Y2) )
276✔
187
                                {
188
                                        if ( DOT(CosRayIn, DFXYZ) < 0 )
70✔
189
                                                *BacksideFlag = 0;
70✔
190
                                        else
191
                                                *BacksideFlag = 1;
×
192
                                                
193
                                        *Intercept = 1;
70✔
194
                                        //goto Label_100;
195
                                        break;
70✔
196
                                }
197
                                *Intercept = 0;
206✔
198
                                PosRayOut[0] = 0.0;
206✔
199
                                PosRayOut[1] = 0.0;
206✔
200
                                PosRayOut[2] = 0.0;
206✔
201
                                CosRayOut[0] = 0.0;
206✔
202
                                CosRayOut[1] = 0.0;
206✔
203
                                CosRayOut[2] = 0.0;
206✔
204
                                DFXYZ[0] = 0.0;
206✔
205
                                DFXYZ[1] = 0.0;
206✔
206
                                DFXYZ[2] = 0.0;
206✔
207
                                *PathLength = 0.0;
206✔
208
                                *BacksideFlag = 0;
206✔
209
                                *ErrorFlag = 0;
206✔
210
                                //goto Label_100;
211
                                break;
206✔
212
                        }
213
                        
214
                        if ( (x <= XL) && (x >= -XL) )    //2nd section
633✔
215
                        {
216
                                if ( (y >= -Ri) && (y <= Ri) )
322✔
217
                                {
218
                                        if ( DOT(CosRayIn, DFXYZ) < 0 )
117✔
219
                                                *BacksideFlag = 0;
117✔
220
                                        else
221
                                                *BacksideFlag = 1;
×
222
                                        *Intercept = 1;
117✔
223
                                        //goto Label_100;
224
                                        break;
117✔
225
                                }
226
                                *Intercept = 0;
205✔
227
                                PosRayOut[0] = 0.0;
205✔
228
                                PosRayOut[1] = 0.0;
205✔
229
                                PosRayOut[2] = 0.0;
205✔
230
                                CosRayOut[0] = 0.0;
205✔
231
                                CosRayOut[1] = 0.0;
205✔
232
                                CosRayOut[2] = 0.0;
205✔
233
                                DFXYZ[0] = 0.0;
205✔
234
                                DFXYZ[1] = 0.0;
205✔
235
                                DFXYZ[2] = 0.0;
205✔
236
                                *PathLength = 0.0;
205✔
237
                                *BacksideFlag = 0;
205✔
238
                                *ErrorFlag = 0;
205✔
239
                                //goto Label_100;
240
                                break;
205✔
241
                        }
242
                        
243
                        if ( (x < -XL) && (x >= -Ro) )    //3rd section
311✔
244
                        {
245
                                Y3 = SLOP60*(x+Ro);
311✔
246
                                Y4 = -Y3;
311✔
247
                                if ( (y >= Y4) && (y <= Y3) )
311✔
248
                                {
249
                                        if ( DOT(CosRayIn, DFXYZ) < 0 )
91✔
250
                                                *BacksideFlag = 0;
91✔
251
                                        else
252
                                                *BacksideFlag = 1;
×
253
                                        *Intercept = 1;
91✔
254
                                        //goto Label_100;
255
                                        break;
91✔
256
                                }
257
                                *Intercept = 0;
220✔
258
                                PosRayOut[0] = 0.0;
220✔
259
                                PosRayOut[1] = 0.0;
220✔
260
                                PosRayOut[2] = 0.0;
220✔
261
                                CosRayOut[0] = 0.0;
220✔
262
                                CosRayOut[1] = 0.0;
220✔
263
                                CosRayOut[2] = 0.0;
220✔
264
                                DFXYZ[0] = 0.0;
220✔
265
                                DFXYZ[1] = 0.0;
220✔
266
                                DFXYZ[2] = 0.0;
220✔
267
                                *PathLength = 0.0;
220✔
268
                                *BacksideFlag = 0;
220✔
269
                                *ErrorFlag = 0;
220✔
270
                                //goto Label_100;
271
                                break;
220✔
272
                        }
273
                break;
×
274

275
        case 't':
×
276
        case 'T': //Triangular aperture
277
                        Ro = Element->ParameterA/2.0;
×
278

279
                        if ( r > Ro ) //ray falls outside circular circumference aperture
×
280
                        {
281
                                *Intercept = 0;
×
282
                                PosRayOut[0] = 0.0;
×
283
                                PosRayOut[1] = 0.0;
×
284
                                PosRayOut[2] = 0.0;
×
285
                                CosRayOut[0] = 0.0;
×
286
                                CosRayOut[1] = 0.0;
×
287
                                CosRayOut[2] = 0.0;
×
288
                                DFXYZ[0] = 0.0;
×
289
                                DFXYZ[1] = 0.0;
×
290
                                DFXYZ[2] = 0.0;
×
291
                                *PathLength = 0.0;
×
292
                                *BacksideFlag = 0;
×
293
                                *ErrorFlag = 0;
×
294
                                //goto Label_100;
NEW
295
                                break;
×
296
                        }
297
                        Ri = Ro*sin(30.0*(ACOSM1O180));
×
298

299
                        if ( r <= Ri )  //ray falls inside inscribed circle
×
300
                        {
301
                                if ( DOT(CosRayIn, DFXYZ) < 0 )
×
302
                                        *BacksideFlag = 0;
×
303
                                else
304
                                        *BacksideFlag = 1;
×
305
                                *Intercept = 1;
×
306
                                //goto Label_100;
NEW
307
                                break;
×
308
                        }
309

310
                        if ( (x <= Ro) && (x > 0.0) )  //1st section
×
311
                        {
312
                                Y1 = -SLOP60*(x-Ri/cos(30.0*(ACOSM1O180)));
×
313
                                Y2 = -Ri;
×
314
                                if ( (y <= Y1) && (y >= Y2) )
×
315
                                {
316
                                        if ( DOT(CosRayIn, DFXYZ) < 0 )
×
317
                                                *BacksideFlag = 0;
×
318
                                        else
319
                                                *BacksideFlag = 1;
×
320
                                        *Intercept = 1;
×
321
                                        //goto Label_100;
NEW
322
                                        break;
×
323
                                }
324
                                *Intercept = 0;
×
325
                                PosRayOut[0] = 0.0;
×
326
                                PosRayOut[1] = 0.0;
×
327
                                PosRayOut[2] = 0.0;
×
328
                                CosRayOut[0] = 0.0;
×
329
                                CosRayOut[1] = 0.0;
×
330
                                CosRayOut[2] = 0.0;
×
331
                                DFXYZ[0] = 0.0;
×
332
                                DFXYZ[1] = 0.0;
×
333
                                DFXYZ[2] = 0.0;
×
334
                                *PathLength = 0.0;
×
335
                                *BacksideFlag = 0;
×
336
                                *ErrorFlag = 0;
×
337
                                //goto Label_100;
NEW
338
                                break;
×
339
                        }
340
                        if ( (x >= -Ro) && (x <= 0.0) )  //2nd section
×
341
                        {
342
                                Y3 = SLOP60*(x+Ri/cos(30.0*(ACOSM1O180)));
×
343
                                Y4 = -Ri;
×
344
                                if ( (y >= Y4) && (y <= Y3) )
×
345
                                {
346
                                        if ( DOT(CosRayIn, DFXYZ) < 0 )
×
347
                                                *BacksideFlag = 0;
×
348
                                        else
349
                                                *BacksideFlag = 1;
×
350
                                        *Intercept = 1;
×
351
                                        //goto Label_100;
NEW
352
                                        break;
×
353
                                }
354
                                *Intercept = 0;
×
355
                                PosRayOut[0] = 0.0;
×
356
                                PosRayOut[1] = 0.0;
×
357
                                PosRayOut[2] = 0.0;
×
358
                                CosRayOut[0] = 0.0;
×
359
                                CosRayOut[1] = 0.0;
×
360
                                CosRayOut[2] = 0.0;
×
361
                                DFXYZ[0] = 0.0;
×
362
                                DFXYZ[1] = 0.0;
×
363
                                DFXYZ[2] = 0.0;
×
364
                                *PathLength = 0.0;
×
365
                                *BacksideFlag = 0;
×
366
                                *ErrorFlag = 0;
×
367
                                //goto Label_100;
NEW
368
                                break;
×
369
                        }
370
                break;
×
371

372
        case 'r':
280,347,174✔
373
        case 'R': //Rectangular aperture
374
               
375
                        if ( (x > Element->ParameterA/2.0) || (x < -Element->ParameterA/2.0) )
280,347,174✔
376
                        {
377
                                *Intercept = 0;
278,888,101✔
378
                                PosRayOut[0] = 0.0;
278,888,101✔
379
                                PosRayOut[1] = 0.0;
278,888,101✔
380
                                PosRayOut[2] = 0.0;
278,888,101✔
381
                                CosRayOut[0] = 0.0;
278,888,101✔
382
                                CosRayOut[1] = 0.0;
278,888,101✔
383
                                CosRayOut[2] = 0.0;
278,888,101✔
384
                                DFXYZ[0] = 0.0;
278,888,101✔
385
                                DFXYZ[1] = 0.0;
278,888,101✔
386
                                DFXYZ[2] = 0.0;
278,888,101✔
387
                                *PathLength = 0.0;
278,888,101✔
388
                                *BacksideFlag = 0;
278,888,101✔
389
                                *ErrorFlag = 0;
278,888,101✔
390
                                //goto Label_100;
391
                                break;
278,888,101✔
392
                        }
393
                        
394
                        if ( (y > Element->ParameterB/2.0) || (y < -Element->ParameterB/2.0) )
1,459,073✔
395
                        {
396
                                *Intercept = 0;
1,315,484✔
397
                                PosRayOut[0] = 0.0;
1,315,484✔
398
                                PosRayOut[1] = 0.0;
1,315,484✔
399
                                PosRayOut[2] = 0.0;
1,315,484✔
400
                                CosRayOut[0] = 0.0;
1,315,484✔
401
                                CosRayOut[1] = 0.0;
1,315,484✔
402
                                CosRayOut[2] = 0.0;
1,315,484✔
403
                                DFXYZ[0] = 0.0;
1,315,484✔
404
                                DFXYZ[1] = 0.0;
1,315,484✔
405
                                DFXYZ[2] = 0.0;
1,315,484✔
406
                                *PathLength = 0.0;
1,315,484✔
407
                                *BacksideFlag = 0;
1,315,484✔
408
                                *ErrorFlag = 0;
1,315,484✔
409
                                //goto Label_100;
410
                                break;
1,315,484✔
411
                        }
412

413
                        if ( DOT(CosRayIn, DFXYZ) < 0 ) //successfully falls on rectangle
143,589✔
414
                                *BacksideFlag = 0;
142,716✔
415
                        else
416
                                *BacksideFlag = 1;
873✔
417
                                
418
                        *Intercept = 1;
143,589✔
419
                        //goto Label_100;
420

421
                break;
143,589✔
422

423
        case 'a':
×
424
        case 'A': //Annulus or torus contour
425
        
NEW
426
                        if ((Element->ParameterA == 0.0) && (Element->ParameterB == 0.0))
×
427
                        {
428
                                // Naturally goes to Label_5
429
                                //goto Label_5; //torus
430
                        }
NEW
431
                        else if ( (r < Element->ParameterA) || (r > Element->ParameterB) )
×
432
                        {
433
                                *Intercept = 0;
×
434
                                PosRayOut[0] = 0.0;
×
435
                                PosRayOut[1] = 0.0;
×
436
                                PosRayOut[2] = 0.0;
×
437
                                CosRayOut[0] = 0.0;
×
438
                                CosRayOut[1] = 0.0;
×
439
                                CosRayOut[2] = 0.0;
×
440
                                DFXYZ[0] = 0.0;
×
441
                                DFXYZ[1] = 0.0;
×
442
                                DFXYZ[2] = 0.0;
×
443
                                *PathLength = 0.0;
×
444
                                *BacksideFlag = 0;
×
445
                                *ErrorFlag = 0;
×
446
                                //goto Label_100;
NEW
447
                                break;
×
448
                        }
449
                        //Label_5:
450
                        if ( x >= 0.0 )
×
451
                        {
452
                                if ( (asin(y/r) > Element->ParameterC*(ACOSM1O180)/2.0) || (asin(y/r) < -Element->ParameterC*(ACOSM1O180)/2.0) )
×
453
                                {
454
                                        *Intercept = 0;
×
455
                                        PosRayOut[0] = 0.0;
×
456
                                        PosRayOut[1] = 0.0;
×
457
                                        PosRayOut[2] = 0.0;
×
458
                                        CosRayOut[0] = 0.0;
×
459
                                        CosRayOut[1] = 0.0;
×
460
                                        CosRayOut[2] = 0.0;
×
461
                                        DFXYZ[0] = 0.0;
×
462
                                        DFXYZ[1] = 0.0;
×
463
                                        DFXYZ[2] = 0.0;
×
464
                                        *PathLength = 0.0;
×
465
                                        *BacksideFlag = 0;
×
466
                                        *ErrorFlag = 0;
×
467
                                        //goto Label_100;
NEW
468
                                        break;
×
469
                                }
470

471
                                if ( DOT(CosRayIn, DFXYZ) < 0 ) //successfully falls on annular section
×
472
                                        *BacksideFlag = 0;
×
473
                                else
474
                                        *BacksideFlag = 1;
×
475
                                *Intercept = 1;
×
476
                                //goto Label_100;
NEW
477
                                break;
×
478
                        }
479
                        
480
                        if ( x < 0.0 )
×
481
                        {
482
                                if ( (y >= 0) && ((acos(y/r)+M_PI/2.0) > Element->ParameterC*(ACOSM1O180)/2.0) )
×
483
                                {
484
                                        *Intercept = 0;
×
485
                                        PosRayOut[0] = 0.0;
×
486
                                        PosRayOut[1] = 0.0;
×
487
                                        PosRayOut[2] = 0.0;
×
488
                                        CosRayOut[0] = 0.0;
×
489
                                        CosRayOut[1] = 0.0;
×
490
                                        CosRayOut[2] = 0.0;
×
491
                                        DFXYZ[0] = 0.0;
×
492
                                        DFXYZ[1] = 0.0;
×
493
                                        DFXYZ[2] = 0.0;
×
494
                                        *PathLength = 0.0;
×
495
                                        *BacksideFlag = 0;
×
496
                                        *ErrorFlag = 0;
×
497
                                        //goto Label_100;
NEW
498
                                        break;
×
499
                                }
500
                                else if ( (y < 0) && ((-acos(-y/r)-M_PI/2.0) < -Element->ParameterC*(ACOSM1O180)/2.0) )
×
501
                                {
502
                                        *Intercept = 0;
×
503
                                        PosRayOut[0] = 0.0;
×
504
                                        PosRayOut[1] = 0.0;
×
505
                                        PosRayOut[2] = 0.0;
×
506
                                        CosRayOut[0] = 0.0;
×
507
                                        CosRayOut[1] = 0.0;
×
508
                                        CosRayOut[2] = 0.0;
×
509
                                        DFXYZ[0] = 0.0;
×
510
                                        DFXYZ[1] = 0.0;
×
511
                                        DFXYZ[2] = 0.0;
×
512
                                        *PathLength = 0.0;
×
513
                                        *BacksideFlag = 0;
×
514
                                        *ErrorFlag = 0;
×
515
                                        //goto Label_100;
NEW
516
                                        break;
×
517
                                }
518

519
                                if ( DOT(CosRayIn, DFXYZ) < 0 ) //successfully falls on annular section
×
520
                                        *BacksideFlag = 0;
×
521
                                else
522
                                        *BacksideFlag = 1;
×
523
                                *Intercept = 1;
×
524
                                //goto Label_100;
NEW
525
                                break;
×
526
                        }
527
                break;
×
528

529
        case 'l':
86,437✔
530
        case 'L': //off axis aperture section of line focus trough  or cylinder
531
                        if ((Element->ParameterA == 0.0) && (Element->ParameterB == 0.0))
86,437✔
532
                        {
533
                                // Skipping goto (now goes to label 10 automatically)
534
                                //goto Label_10; //for cylinder, only need to check for limits on y
535
                        }
NEW
536
                        else if ( (x < Element->ParameterA) || (x > Element->ParameterB) )
×
537
                        {
538
                                *Intercept = 0;
×
539
                                PosRayOut[0] = 0.0;
×
540
                                PosRayOut[1] = 0.0;
×
541
                                PosRayOut[2] = 0.0;
×
542
                                CosRayOut[0] = 0.0;
×
543
                                CosRayOut[1] = 0.0;
×
544
                                CosRayOut[2] = 0.0;
×
545
                                DFXYZ[0] = 0.0;
×
546
                                DFXYZ[1] = 0.0;
×
547
                                DFXYZ[2] = 0.0;
×
548
                                *PathLength = 0.0;
×
549
                                *BacksideFlag = 0;
×
550
                                *ErrorFlag = 0;
×
551
                                //goto Label_100;
NEW
552
                                break;
×
553
                        }
554

555
                        //Label_10:
556
                        if ( (y < -Element->ParameterC/2.0) || (y > Element->ParameterC/2.0) )
86,437✔
557
                        {
558
                                *Intercept = 0;
×
559
                                PosRayOut[0] = 0.0;
×
560
                                PosRayOut[1] = 0.0;
×
561
                                PosRayOut[2] = 0.0;
×
562
                                CosRayOut[0] = 0.0;
×
563
                                CosRayOut[1] = 0.0;
×
564
                                CosRayOut[2] = 0.0;
×
565
                                DFXYZ[0] = 0.0;
×
566
                                DFXYZ[1] = 0.0;
×
567
                                DFXYZ[2] = 0.0;
×
568
                                *PathLength = 0.0;
×
569
                                *BacksideFlag = 0;
×
570
                                *ErrorFlag = 0;
×
571
                                //goto Label_100;
NEW
572
                                break;
×
573
                        }
574

575
                        if ( DOT(CosRayIn, DFXYZ) < 0 ) //successfully falls on line focus or cylindrical section
86,437✔
576
                                *BacksideFlag = 0;
×
577
                        else
578
                                *BacksideFlag = 1;
86,437✔
579
                                
580
                        *Intercept = 1;
86,437✔
581
                        //goto Label_100;
582
                break;
86,437✔
583

584
        case 'i':
×
585
        case 'I': //irregular triangle
586
                        P1x = Element->ParameterA;
×
587
                        P1y = Element->ParameterB;
×
588
                        P2x = Element->ParameterC;
×
589
                        P2y = Element->ParameterD;
×
590
                        P3x = Element->ParameterE;
×
591
                        P3y = Element->ParameterF;
×
592

593
                        if (!intri( P1x, P1y, P2x, P2y, P3x, P3y, x, y ))
×
594
                        {
595
                                *Intercept = 0;
×
596
                                PosRayOut[0] = 0.0;
×
597
                                PosRayOut[1] = 0.0;
×
598
                                PosRayOut[2] = 0.0;
×
599
                                CosRayOut[0] = 0.0;
×
600
                                CosRayOut[1] = 0.0;
×
601
                                CosRayOut[2] = 0.0;
×
602
                                DFXYZ[0] = 0.0;
×
603
                                DFXYZ[1] = 0.0;
×
604
                                DFXYZ[2] = 0.0;
×
605
                                *PathLength = 0.0;
×
606
                                *ErrorFlag = 0;
×
607
                                *BacksideFlag = 0;
×
608
                                //goto Label_100;
NEW
609
                                break;
×
610
                        }
611

612
                        if ( DOT(CosRayIn, DFXYZ) < 0 )
×
613
                                *BacksideFlag = 0;
×
614
                        else
615
                                *BacksideFlag = 1;
×
616
                        *Intercept = 1;
×
617
                        //goto Label_100;
UNCOV
618
                break;
×
619

620
        case 'q':
×
621
        case 'Q': //irregular quadrilateral
622
                        P1x = Element->ParameterA;
×
623
                        P1y = Element->ParameterB;
×
624
                        P2x = Element->ParameterC;
×
625
                        P2y = Element->ParameterD;
×
626
                        P3x = Element->ParameterE;
×
627
                        P3y = Element->ParameterF;
×
628
                        P4x = Element->ParameterG;
×
629
                        P4y = Element->ParameterH;
×
630

631
                        in_quad = inquad(P1x, P1y, P2x, P2y, P3x, P3y, P4x, P4y, x, y);
×
632

633
                        if (!in_quad)
×
634
                        {
635
                                *Intercept = 0;
×
636
                                PosRayOut[0] = 0.0;
×
637
                                PosRayOut[1] = 0.0;
×
638
                                PosRayOut[2] = 0.0;
×
639
                                CosRayOut[0] = 0.0;
×
640
                                CosRayOut[1] = 0.0;
×
641
                                CosRayOut[2] = 0.0;
×
642
                                DFXYZ[0] = 0.0;
×
643
                                DFXYZ[1] = 0.0;
×
644
                                DFXYZ[2] = 0.0;
×
645
                                *PathLength = 0.0;
×
646
                                *ErrorFlag = 0;
×
647
                                *BacksideFlag = 0;
×
648
                                //goto Label_100;
NEW
649
                                break;
×
650
                        }
651

652
                        if ( DOT(CosRayIn, DFXYZ) < 0 )
×
653
                                *BacksideFlag = 0;
×
654
                        else
655
                                *BacksideFlag = 1;
×
656
                        *Intercept = 1;
×
657
                        //goto Label_100;
UNCOV
658
                break;
×
659
        } //end select case
660
        
661
        //Label_100:
662
        if ( *BacksideFlag )   //if hit on backside of element then slope of surface is reversed
280,684,163✔
663
        {
664
                DFXYZ[0] = -DFXYZ[0];
87,311✔
665
                DFXYZ[1] = -DFXYZ[1];
87,311✔
666
                DFXYZ[2] = -DFXYZ[2];
87,311✔
667
        }
668
}
669
//End of Procedure--------------------------------------------------------------
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc