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