1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
|
// File: Voxel_FastConverter.cxx
// Created: Mon May 30 17:55:14 2008
// Author: Vladislav ROMASHKO
// <vladislav.romashko@opencascade.com>
#include <Voxel_FastConverter.ixx>
#include <Bnd_Box.hxx>
#include <BRep_Tool.hxx>
#include <BRepBndLib.hxx>
#include <BRepMesh.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopExp_Explorer.hxx>
#include <gp_Lin2d.hxx>
#include <gce_MakePln.hxx>
#include <ElSLib.hxx>
#include <Poly_Triangulation.hxx>
#include <IntAna2d_AnaIntersection.hxx>
// Printing the progress in stdout.
//#define CONV_DUMP
Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape,
Voxel_ROctBoolDS& voxels,
const Standard_Real deflection,
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
const Standard_Integer nbthreads)
:myShape(shape),myVoxels(&voxels),
myDeflection(deflection),myIsBool(2),
myNbX(nbx),myNbY(nby),myNbZ(nbz),
myNbThreads(nbthreads),
myNbTriangles(0)
{
Init();
}
Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape,
Voxel_BoolDS& voxels,
const Standard_Real deflection,
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
const Standard_Integer nbthreads)
:myShape(shape),myVoxels(&voxels),
myDeflection(deflection),myIsBool(1),
myNbX(nbx),myNbY(nby),myNbZ(nbz),
myNbThreads(nbthreads),
myNbTriangles(0)
{
Init();
}
Voxel_FastConverter::Voxel_FastConverter(const TopoDS_Shape& shape,
Voxel_ColorDS& voxels,
const Standard_Real deflection,
const Standard_Integer nbx,
const Standard_Integer nby,
const Standard_Integer nbz,
const Standard_Integer nbthreads)
:myShape(shape),myVoxels(&voxels),
myDeflection(deflection),myIsBool(0),
myNbX(nbx),myNbY(nby),myNbZ(nbz),
myNbThreads(nbthreads),
myNbTriangles(0)
{
Init();
}
void Voxel_FastConverter::Init()
{
if (myShape.IsNull())
return;
if (myNbThreads < 1)
return;
// Check number of splits.
Voxel_DS* voxels = (Voxel_DS*) myVoxels;
if (voxels->GetNbX() != myNbX || voxels->GetNbY() != myNbY || voxels->GetNbZ() != myNbZ)
{
// Compute boundary box of the shape
Bnd_Box box;
BRepBndLib::Add(myShape, box);
// Define the voxel model by means of the boundary box of shape
Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
box.Get(xmin, ymin, zmin, xmax, ymax, zmax);
// Initialize the voxels.
if (myIsBool == 2)
((Voxel_ROctBoolDS*) voxels)->Init(xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin, myNbX, myNbY, myNbZ);
else if (myIsBool == 1)
((Voxel_BoolDS*) voxels)->Init(xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin, myNbX, myNbY, myNbZ);
else if (myIsBool == 0)
((Voxel_ColorDS*) voxels)->Init(xmin, ymin, zmin, xmax - xmin, ymax - ymin, zmax - zmin, myNbX, myNbY, myNbZ);
}
// Check presence of triangulation.
TopLoc_Location L;
Standard_Boolean triangulate = Standard_False;
TopExp_Explorer expl(myShape, TopAbs_FACE);
for (; expl.More(); expl.Next())
{
TopoDS_Face F = TopoDS::Face(expl.Current());
Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
if (T.IsNull() || fabs(T->Deflection() - myDeflection) > Precision::Confusion())
{
triangulate = Standard_True;
break;
}
}
// Re-create the triangulation.
if (triangulate)
{
BRepMesh::Mesh(myShape, myDeflection);
}
// Compute the number of triangles.
myNbTriangles = 0;
expl.Init(myShape, TopAbs_FACE);
for (; expl.More(); expl.Next())
{
TopoDS_Face F = TopoDS::Face(expl.Current());
Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
myNbTriangles += T->NbTriangles();
}
}
// Destructor
void Voxel_FastConverter::Destroy()
{
}
Standard_Boolean Voxel_FastConverter::Convert(Standard_Integer& progress,
const Standard_Integer ithread)
{
if (ithread == 1)
progress = 0;
#ifdef CONV_DUMP
if (ithread == 1)
printf("Progress = %d \r", progress);
#endif
if (myNbX <= 0 || myNbY <= 0 || myNbZ <= 0)
return Standard_False;
// Half of diagonal of a voxel
Voxel_DS* ds = (Voxel_DS*) myVoxels;
Standard_Real dx = ds->GetXLen() / (Standard_Real) ds->GetNbX(),
dy = ds->GetYLen() / (Standard_Real) ds->GetNbY(),
dz = ds->GetZLen() / (Standard_Real) ds->GetNbZ();
Standard_Real hdiagonal = sqrt(dx * dx + dy * dy + dz * dz);
hdiagonal /= 2.0;
// Compute the scope of triangles for current thread
Standard_Integer start_thread_triangle = 1, end_thread_triangle = myNbTriangles, ithread_triangle = 0;
start_thread_triangle = (ithread - 1) * (myNbTriangles / myNbThreads) + 1;
end_thread_triangle = (ithread - 0) * (myNbTriangles / myNbThreads);
// Convert
TopLoc_Location L;
Standard_Integer iprogress = 0;
Standard_Integer n1, n2, n3;
Standard_Integer ixmin, iymin, izmin, ixmax, iymax, izmax;
Standard_Real xmin, ymin, zmin, xmax, ymax, zmax;
TopExp_Explorer expl(myShape, TopAbs_FACE);
for (; expl.More(); expl.Next())
{
TopoDS_Face F = TopoDS::Face(expl.Current());
Handle(Poly_Triangulation) T = BRep_Tool::Triangulation(F, L);
gp_Trsf trsf;
Standard_Boolean transform = !L.IsIdentity();
if (transform)
trsf = L.Transformation();
const TColgp_Array1OfPnt& nodes = T->Nodes();
const Poly_Array1OfTriangle& triangles = T->Triangles();
Standard_Integer itriangle = triangles.Lower(), nb_triangles = triangles.Upper();
for (; itriangle <= nb_triangles; itriangle++)
{
ithread_triangle++;
if (ithread_triangle < start_thread_triangle || ithread_triangle > end_thread_triangle)
continue;
const Poly_Triangle& t = triangles.Value(itriangle);
t.Get(n1, n2, n3);
gp_Pnt p1 = nodes.Value(n1);
gp_Pnt p2 = nodes.Value(n2);
gp_Pnt p3 = nodes.Value(n3);
if (transform)
{
p1.Transform(trsf);
p2.Transform(trsf);
p3.Transform(trsf);
}
// Get boundary box of the triangle
GetBndBox(p1, p2, p3, xmin, ymin, zmin, xmax, ymax, zmax);
// Find the range of voxels inside the boudary box of the triangle.
if (!ds->GetVoxel(xmin, ymin, zmin, ixmin, iymin, izmin))
continue;
if (!ds->GetVoxel(xmax, ymax, zmax, ixmax, iymax, izmax))
continue;
// Refuse voxels for whom distance from their center to plane of triangle is greater than half of diagonal.
// Make a line from center of each voxel to the center of triangle and
// compute intersection of the line with sides of triangle.
// Refuse the voxel in case of intersection.
gce_MakePln mkPlane(p1, p2, p3);
if (!mkPlane.IsDone())
continue;
gp_Pln plane = mkPlane.Value();
ComputeVoxelsNearTriangle(plane, p1, p2, p3, hdiagonal, ixmin, iymin, izmin, ixmax, iymax, izmax);
// Progress
if (ithread == 1)
{
iprogress++;
progress = (Standard_Integer) ( (Standard_Real) iprogress / (Standard_Real) myNbTriangles * 100.0 );
}
#ifdef CONV_DUMP
if (ithread == 1 && prev_progress != progress)
{
printf("Progress = %d \r", progress);
prev_progress = progress;
}
#endif
} // iteration of triangles
} // iteration of faces
if (ithread == 1)
progress = 100;
#ifdef CONV_DUMP
if (ithread == 1)
printf("Progress = %d \r", progress);
#endif
return Standard_True;
}
Standard_Boolean Voxel_FastConverter::FillInVolume(const Standard_Byte inner,
const Standard_Integer ithread)
{
Voxel_DS* ds = (Voxel_DS*) myVoxels;
Standard_Integer ix, iy, iz, nbx = ds->GetNbX(), nby = ds->GetNbY(), nbz = ds->GetNbZ();
Standard_Boolean prev_surface, surface, volume;
if (inner)
{
// Fill-in internal voxels by the value "inner"
for (ix = 0; ix < nbx; ix++)
{
for (iy = 0; iy < nby; iy++)
{
// Check existence of volume.
volume = Standard_False;
surface = Standard_False;
prev_surface = Standard_False;
for (iz = 0; iz < nbz; iz++)
{
surface = (myIsBool == 1) ?
((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True :
((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0;
if (prev_surface && !surface)
{
volume = !volume;
}
prev_surface = surface;
}
if (volume)
continue;
// Fill-in the volume.
volume = Standard_False;
surface = Standard_False;
prev_surface = Standard_False;
for (iz = 0; iz < nbz; iz++)
{
surface = (myIsBool == 1) ?
((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True :
((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0;
if (prev_surface && !surface)
{
volume = !volume;
}
if (volume && !surface)
{
(myIsBool == 1) ? ((Voxel_BoolDS*)myVoxels)->Set(ix, iy, iz, inner) :
((Voxel_ColorDS*)myVoxels)->Set(ix, iy, iz, inner);
}
prev_surface = surface;
}
}
}
}
else
{
// Set value of interbal voxels to 0 ("inner" = 0)
Standard_Boolean next_surface;
for (ix = 0; ix < nbx; ix++)
{
for (iy = 0; iy < nby; iy++)
{
volume = Standard_False;
surface = Standard_False;
prev_surface = Standard_False;
next_surface = Standard_False;
for (iz = 0; iz < nbz; iz++)
{
surface = (myIsBool == 1) ?
((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz) == Standard_True :
((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz) > 0;
if (prev_surface != surface)
{
volume = !volume;
}
if (volume && iz + 1 < nbz)
{
next_surface = (myIsBool == 1) ?
((Voxel_BoolDS*)myVoxels)->Get(ix, iy, iz + 1) == Standard_True :
((Voxel_ColorDS*)myVoxels)->Get(ix, iy, iz + 1) > 0;
}
if (volume && prev_surface == surface && next_surface)
{
(myIsBool == 1) ? ((Voxel_BoolDS*)myVoxels)->Set(ix, iy, iz, inner) :
((Voxel_ColorDS*)myVoxels)->Set(ix, iy, iz, inner);
}
prev_surface = surface;
}
}
}
}
return Standard_True;
}
void Voxel_FastConverter::GetBndBox(const gp_Pnt& p1,
const gp_Pnt& p2,
const gp_Pnt& p3,
Standard_Real& xmin,
Standard_Real& ymin,
Standard_Real& zmin,
Standard_Real& xmax,
Standard_Real& ymax,
Standard_Real& zmax) const
{
// P1:
xmin = p1.X();
ymin = p1.Y();
zmin = p1.Z();
xmax = p1.X();
ymax = p1.Y();
zmax = p1.Z();
// P2:
if (xmin > p2.X())
xmin = p2.X();
if (ymin > p2.Y())
ymin = p2.Y();
if (zmin > p2.Z())
zmin = p2.Z();
if (xmax < p2.X())
xmax = p2.X();
if (ymax < p2.Y())
ymax = p2.Y();
if (zmax < p2.Z())
zmax = p2.Z();
// P3:
if (xmin > p3.X())
xmin = p3.X();
if (ymin > p3.Y())
ymin = p3.Y();
if (zmin > p3.Z())
zmin = p3.Z();
if (xmax < p3.X())
xmax = p3.X();
if (ymax < p3.Y())
ymax = p3.Y();
if (zmax < p3.Z())
zmax = p3.Z();
}
// This method is copied from Voxel_ShapeIntersector.cxx
static Standard_Boolean mayIntersect(const gp_Pnt2d& p11, const gp_Pnt2d& p12,
const gp_Pnt2d& p21, const gp_Pnt2d& p22)
{
if (p11.X() > p21.X() && p11.X() > p22.X() && p12.X() > p21.X() && p12.X() > p22.X())
return Standard_False;
if (p11.X() < p21.X() && p11.X() < p22.X() && p12.X() < p21.X() && p12.X() < p22.X())
return Standard_False;
if (p11.Y() > p21.Y() && p11.Y() > p22.Y() && p12.Y() > p21.Y() && p12.Y() > p22.Y())
return Standard_False;
if (p11.Y() < p21.Y() && p11.Y() < p22.Y() && p12.Y() < p21.Y() && p12.Y() < p22.Y())
return Standard_False;
return Standard_True;
}
void Voxel_FastConverter::ComputeVoxelsNearTriangle(const gp_Pln& plane,
const gp_Pnt& p1,
const gp_Pnt& p2,
const gp_Pnt& p3,
const Standard_Real hdiagonal,
const Standard_Integer ixmin,
const Standard_Integer iymin,
const Standard_Integer izmin,
const Standard_Integer ixmax,
const Standard_Integer iymax,
const Standard_Integer izmax) const
{
gp_Pnt pc;
Standard_Real xc, yc, zc, uc, vc, u1, v1, u2, v2, u3, v3;
Standard_Integer ix, iy, iz;
IntAna2d_AnaIntersection intersector2d;
// Project points of triangle onto the plane
ElSLib::Parameters(plane, p1, u1, v1);
ElSLib::Parameters(plane, p2, u2, v2);
ElSLib::Parameters(plane, p3, u3, v3);
// Make lines of triangle
gp_Pnt2d p2d1(u1, v1), p2d2(u2, v2), p2d3(u3, v3), p2dt((u1+u2+u3)/3.0,(v1+v2+v3)/3.0), p2dc;
gp_Vec2d v2d12(p2d1, p2d2), v2d23(p2d2, p2d3), v2d31(p2d3, p2d1);
gp_Lin2d L1(p2d1, v2d12), L2(p2d2, v2d23), L3(p2d3, v2d31), Lv;
Standard_Real d1 = p2d1.Distance(p2d2) - Precision::Confusion(),
d2 = p2d2.Distance(p2d3) - Precision::Confusion(),
d3 = p2d3.Distance(p2d1) - Precision::Confusion(), dv;
Voxel_DS* ds = (Voxel_DS*) myVoxels;
for (ix = ixmin; ix <= ixmax; ix++)
{
for (iy = iymin; iy <= iymax; iy++)
{
for (iz = izmin; iz <= izmax; iz++)
{
ds->GetCenter(ix, iy, iz, xc, yc, zc);
pc.SetCoord(xc, yc, zc);
if (plane.Distance(pc) < hdiagonal)
{
ElSLib::Parameters(plane, pc, uc, vc);
p2dc.SetCoord(uc, vc);
gp_Vec2d v2dct(p2dc, p2dt);
dv = v2dct.Magnitude() - Precision::Confusion();
Lv.SetLocation(p2dc);
Lv.SetDirection(v2dct);
// Side 1:
if (mayIntersect(p2d1, p2d2, p2dc, p2dt))
{
intersector2d.Perform(Lv, L1);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d1)
{
continue;
}
}
}
// Side 2:
if (mayIntersect(p2d2, p2d3, p2dc, p2dt))
{
intersector2d.Perform(Lv, L2);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d2)
{
continue;
}
}
}
// Side 3:
if (mayIntersect(p2d3, p2d1, p2dc, p2dt))
{
intersector2d.Perform(Lv, L3);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d3)
{
continue;
}
}
}
// Set positive value to this voxel:
switch (myIsBool)
{
case 0:
((Voxel_ColorDS*) myVoxels)->Set(ix, iy, iz, 15);
break;
case 1:
((Voxel_BoolDS*) myVoxels)->Set(ix, iy, iz, Standard_True);
break;
case 2:
{
//((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, Standard_True);
// Check intersection between the triangle & sub-voxels of the voxel.
Standard_Real hdiagonal2 = hdiagonal / 2.0, hdiagonal4 = hdiagonal / 4.0;
for (Standard_Integer i = 0; i < 8; i++)
{
((Voxel_ROctBoolDS*) myVoxels)->GetCenter(ix, iy, iz, i, xc, yc, zc);
pc.SetCoord(xc, yc, zc);
if (plane.Distance(pc) < hdiagonal2)
{
ElSLib::Parameters(plane, pc, uc, vc);
p2dc.SetCoord(uc, vc);
gp_Vec2d v2dct(p2dc, p2dt);
dv = v2dct.Magnitude() - Precision::Confusion();
Lv.SetLocation(p2dc);
Lv.SetDirection(v2dct);
// Side 1:
if (mayIntersect(p2d1, p2d2, p2dc, p2dt))
{
intersector2d.Perform(Lv, L1);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d1)
{
continue;
}
}
}
// Side 2:
if (mayIntersect(p2d2, p2d3, p2dc, p2dt))
{
intersector2d.Perform(Lv, L2);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d2)
{
continue;
}
}
}
// Side 3:
if (mayIntersect(p2d3, p2d1, p2dc, p2dt))
{
intersector2d.Perform(Lv, L3);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d3)
{
continue;
}
}
}
//((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, i, Standard_True);
// Check intersection between the triangle & sub-voxels of the sub-voxel.
for (Standard_Integer j = 0; j < 8; j++)
{
((Voxel_ROctBoolDS*) myVoxels)->GetCenter(ix, iy, iz, i, j, xc, yc, zc);
pc.SetCoord(xc, yc, zc);
if (plane.Distance(pc) < hdiagonal4)
{
ElSLib::Parameters(plane, pc, uc, vc);
p2dc.SetCoord(uc, vc);
gp_Vec2d v2dct(p2dc, p2dt);
dv = v2dct.Magnitude() - Precision::Confusion();
Lv.SetLocation(p2dc);
Lv.SetDirection(v2dct);
// Side 1:
if (mayIntersect(p2d1, p2d2, p2dc, p2dt))
{
intersector2d.Perform(Lv, L1);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d1)
{
continue;
}
}
}
// Side 2:
if (mayIntersect(p2d2, p2d3, p2dc, p2dt))
{
intersector2d.Perform(Lv, L2);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d2)
{
continue;
}
}
}
// Side 3:
if (mayIntersect(p2d3, p2d1, p2dc, p2dt))
{
intersector2d.Perform(Lv, L3);
if (intersector2d.IsDone() && !intersector2d.ParallelElements() && intersector2d.NbPoints())
{
const IntAna2d_IntPoint& i2d = intersector2d.Point(1);
Standard_Real param1 = i2d.ParamOnFirst();
Standard_Real param2 = i2d.ParamOnSecond();
if (param1 > Precision::Confusion() && param1 < dv &&
param2 > Precision::Confusion() && param2 < d3)
{
continue;
}
}
}
((Voxel_ROctBoolDS*) myVoxels)->Set(ix, iy, iz, i, j, Standard_True);
}
} // End of "Check level 2".
}
} // End of "Check level 1".
break;
}
}
}
}
}
}
}
|