90896def57bad6c5185ef2ed13f31a3e9ec15592
[occt.git] / src / StdPrs / StdPrs_WFDeflectionRestrictedFace.cxx
1 // Created on: 1995-08-07
2 // Created by: Modelistation
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <StdPrs_WFDeflectionRestrictedFace.ixx>
18
19 #include <Hatch_Hatcher.hxx>
20 #include <Graphic3d_ArrayOfPolylines.hxx>
21 #include <Graphic3d_AspectLine3d.hxx>
22 #include <Graphic3d_Group.hxx>
23 #include <gp_Pnt.hxx>
24 #include <gp_Pnt2d.hxx>
25 #include <Prs3d_IsoAspect.hxx>
26 #include <Adaptor2d_Curve2d.hxx>
27 #include <GCPnts_QuasiUniformDeflection.hxx>
28 #include <Adaptor3d_IsoCurve.hxx>
29 #include <StdPrs_DeflectionCurve.hxx>
30 #include <StdPrs_ToolRFace.hxx>
31 #include <Bnd_Box2d.hxx>
32 #include <BndLib_Add2dCurve.hxx>
33 #include <Precision.hxx>
34 #include <GeomAdaptor_Curve.hxx>
35 #include <Geom_Curve.hxx>
36 #include <GeomAbs_SurfaceType.hxx>
37 #include <Geom_Surface.hxx>
38 #include <TColgp_SequenceOfPnt2d.hxx>
39
40
41
42
43 #ifdef DEB_MESH
44 #include <OSD_Chronometer.hxx>
45 extern OSD_Chronometer FFaceTimer1,FFaceTimer2,FFaceTimer3,FFaceTimer4;
46 #endif
47
48
49 //==================================================================
50 // function: FindLimits
51 // purpose:
52 //==================================================================
53 static void FindLimits(const Adaptor3d_Curve& aCurve,
54                        const Standard_Real  aLimit,
55                        Standard_Real&       First,
56                        Standard_Real&       Last)
57 {
58   First = Max(aCurve.FirstParameter(), First);
59   Last  = Min(aCurve.LastParameter(), Last);
60   Standard_Boolean firstInf = Precision::IsNegativeInfinite(First);
61   Standard_Boolean lastInf  = Precision::IsPositiveInfinite(Last);
62
63   if (firstInf || lastInf) {
64     gp_Pnt P1,P2;
65     Standard_Real delta = 1;
66     if (firstInf && lastInf) {
67       do {
68         delta *= 2;
69         First = - delta;
70         Last  =   delta;
71         aCurve.D0(First,P1);
72         aCurve.D0(Last,P2);
73       } while (P1.Distance(P2) < aLimit);
74     }
75     else if (firstInf) {
76       aCurve.D0(Last,P2);
77       do {
78         delta *= 2;
79         First = Last - delta;
80         aCurve.D0(First,P1);
81       } while (P1.Distance(P2) < aLimit);
82     }
83     else if (lastInf) {
84       aCurve.D0(First,P1);
85       do {
86         delta *= 2;
87         Last = First + delta;
88         aCurve.D0(Last,P2);
89       } while (P1.Distance(P2) < aLimit);
90     }
91   }    
92
93 }
94
95
96 //=========================================================================
97 // function: Add
98 // purpose
99 //=========================================================================
100 void StdPrs_WFDeflectionRestrictedFace::Add
101   (const Handle (Prs3d_Presentation)& aPresentation,
102    const Handle(BRepAdaptor_HSurface)& aFace,
103    const Standard_Boolean DrawUIso,
104    const Standard_Boolean DrawVIso,
105    const Quantity_Length Deflection,
106    const Standard_Integer NBUiso,
107    const Standard_Integer NBViso,
108    const Handle(Prs3d_Drawer)& aDrawer,
109    Prs3d_NListOfSequenceOfPnt& Curves) {
110
111 #ifdef DEB_MESH
112   FFaceTimer1.Start();
113 #endif
114
115   StdPrs_ToolRFace ToolRst (aFace);
116   Standard_Real UF, UL, VF, VL;
117   UF = aFace->FirstUParameter();
118   UL = aFace->LastUParameter();
119   VF = aFace->FirstVParameter();
120   VL = aFace->LastVParameter();
121
122   Standard_Real aLimit = aDrawer->MaximalParameterValue();
123
124   // compute bounds of the restriction
125   Standard_Real UMin,UMax,VMin,VMax;
126   //Standard_Real u,v,step;
127   Standard_Integer i;//,nbPoints = 10;
128
129   UMin = Max(UF, -aLimit);
130   UMax = Min(UL, aLimit);
131   VMin = Max(VF, -aLimit);
132   VMax = Min(VL, aLimit);
133
134
135   // update min max for the hatcher.
136   gp_Pnt2d P1,P2;
137   Standard_Real U1, U2;
138   gp_Pnt dummypnt;
139   Standard_Real ddefle= Max(UMax-UMin, VMax-VMin) * aDrawer->DeviationCoefficient();
140   TColgp_SequenceOfPnt2d tabP;
141   Standard_Real aHatchingTol = 1.e100;
142
143   UMin = VMin = 1.e100;
144   UMax = VMax = -1.e100;
145   
146   for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
147     TopAbs_Orientation Orient = ToolRst.Orientation();
148     if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
149       Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
150       if (TheRCurve->GetType() != GeomAbs_Line) {
151         GCPnts_QuasiUniformDeflection UDP(*TheRCurve, ddefle);
152         if (UDP.IsDone()) {
153           Standard_Integer NumberOfPoints = UDP.NbPoints();
154           if ( NumberOfPoints >= 2 ) {
155             dummypnt = UDP.Value(1);
156             P2.SetCoord(dummypnt.X(), dummypnt.Y());
157             UMin = Min(P2.X(), UMin);
158             UMax = Max(P2.X(), UMax);
159             VMin = Min(P2.Y(), VMin);
160             VMax = Max(P2.Y(), VMax);
161             for (i = 2; i <= NumberOfPoints; i++) {
162               P1 = P2;
163               dummypnt = UDP.Value(i);
164               P2.SetCoord(dummypnt.X(), dummypnt.Y());
165               UMin = Min(P2.X(), UMin);
166               UMax = Max(P2.X(), UMax);
167               VMin = Min(P2.Y(), VMin);
168               VMax = Max(P2.Y(), VMax);
169               aHatchingTol = Min(P1.SquareDistance(P2), aHatchingTol);
170
171               if(Orient == TopAbs_FORWARD ) {
172                 //isobuild.Trim(P1,P2);
173                 tabP.Append(P1);
174                 tabP.Append(P2);
175               }
176               else {
177                 //isobuild.Trim(P2,P1);
178                 tabP.Append(P2);
179                 tabP.Append(P1);
180               }
181             }
182           }
183         }
184         else {
185           cout << "Cannot evaluate curve on surface"<<endl;
186         }
187       }
188       else {
189         U1 = TheRCurve->FirstParameter();
190         U2 = TheRCurve->LastParameter();
191         // MSV 17.08.06 OCC13144: U2 occured less than U1, to overcome it
192         // ensure that distance U2-U1 is not greater than aLimit*2,
193         // if greater then choose an origin and use aLimit to define
194         // U1 and U2 anew
195         Standard_Real aOrigin = 0.;
196         if (!Precision::IsNegativeInfinite(U1) || !Precision::IsPositiveInfinite(U2)) {
197           if (Precision::IsNegativeInfinite(U1))
198             aOrigin = U2 - aLimit;
199           else if (Precision::IsPositiveInfinite(U2))
200             aOrigin = U1 + aLimit;
201           else
202             aOrigin = (U1 + U2) * 0.5;
203         }
204         U1 = Max(aOrigin - aLimit, U1);
205         U2 = Min(aOrigin + aLimit, U2);
206         P1 = TheRCurve->Value(U1);
207         P2 = TheRCurve->Value(U2);
208         UMin = Min(P1.X(), UMin);
209         UMax = Max(P1.X(), UMax);
210         VMin = Min(P1.Y(), VMin);
211         VMax = Max(P1.Y(), VMax);
212         UMin = Min(P2.X(), UMin);
213         UMax = Max(P2.X(), UMax);
214         VMin = Min(P2.Y(), VMin);
215         VMax = Max(P2.Y(), VMax);
216         aHatchingTol = Min(P1.SquareDistance(P2), aHatchingTol);
217
218         if(Orient == TopAbs_FORWARD ) {
219          // isobuild.Trim(P1,P2);
220           tabP.Append(P1);
221           tabP.Append(P2);
222         }
223         else {
224           //isobuild.Trim(P2,P1);
225           tabP.Append(P2);
226           tabP.Append(P1);
227         }
228       }
229     }
230   }
231
232
233 #ifdef DEB_MESH
234   FFaceTimer1.Stop();
235
236   FFaceTimer2.Start();
237 #endif
238
239   // Compute the hatching tolerance.
240   aHatchingTol *= 0.1;
241   aHatchingTol = Max(Precision::Confusion(), aHatchingTol);
242   aHatchingTol = Min(1.e-5, aHatchingTol);
243
244   // load the isos
245   Hatch_Hatcher isobuild(aHatchingTol, ToolRst.IsOriented());
246   Standard_Boolean UClosed = aFace->IsUClosed();
247   Standard_Boolean VClosed = aFace->IsVClosed();
248
249   if ( ! UClosed ) {
250     UMin = UMin + ( UMax - UMin) /1000.;
251     UMax = UMax - ( UMax - UMin) /1000.; 
252   }
253
254   if ( ! VClosed ) {
255     VMin = VMin + ( VMax - VMin) /1000.;
256     VMax = VMax - ( VMax - VMin) /1000.; 
257   }
258
259   if (DrawUIso){
260     if (NBUiso > 0) {
261       UClosed = Standard_False; // En attendant un hatcher de course.
262       Standard_Real du= UClosed ? (UMax-UMin)/NBUiso : (UMax-UMin)/(1+NBUiso);
263       for (i=1; i<=NBUiso;i++){
264         isobuild.AddXLine(UMin+du*i);
265       }
266     }
267   }
268   if (DrawVIso){
269     if ( NBViso > 0) {
270       VClosed = Standard_False;
271       Standard_Real dv= VClosed ?(VMax-VMin)/NBViso : (VMax-VMin)/(1+NBViso);
272       for (i=1; i<=NBViso;i++){
273         isobuild.AddYLine(VMin+dv*i);
274       }
275     }
276   }
277
278 #ifdef DEB_MESH
279   FFaceTimer2.Stop();
280   FFaceTimer3.Start();
281 #endif
282
283   
284   Standard_Integer ll = tabP.Length();
285   for (i = 1; i <= ll; i+=2) {
286     isobuild.Trim(tabP(i),tabP(i+1));
287   }
288
289
290 #ifdef DEB_MESH  
291   FFaceTimer3.Stop();
292   FFaceTimer4.Start();
293 #endif
294
295   // draw the isos
296
297   Adaptor3d_IsoCurve anIso;
298   anIso.Load(aFace);
299   Handle(Geom_Curve) BC;
300   const BRepAdaptor_Surface& BS = *(BRepAdaptor_Surface*)&(aFace->Surface());
301   GeomAbs_SurfaceType thetype = aFace->GetType();
302
303   Standard_Integer NumberOfLines = isobuild.NbLines();
304   Handle(Geom_Surface) GB;
305   if (thetype == GeomAbs_BezierSurface) {
306     GB = BS.Bezier();
307   }
308   else if (thetype == GeomAbs_BSplineSurface){
309     GB = BS.BSpline();
310   }
311
312   Standard_Real anAngle = aDrawer->DeviationAngle();
313
314   for (i = 1; i <= NumberOfLines; i++) {
315     Standard_Integer NumberOfIntervals = isobuild.NbIntervals(i);
316     Standard_Real Coord = isobuild.Coordinate(i);
317     for (Standard_Integer j = 1; j <= NumberOfIntervals; j++) {
318       Standard_Real b1=isobuild.Start(i,j),b2=isobuild.End(i,j);
319
320
321       if (!GB.IsNull()) {
322         if (isobuild.IsXLine(i))
323           BC = GB->UIso(Coord);
324         else 
325           BC = GB->VIso(Coord);
326         GeomAdaptor_Curve GC(BC);
327         FindLimits(GC, aLimit,b1, b2);
328         if (b2-b1>Precision::Confusion()) {
329           Handle(TColgp_HSequenceOfPnt) Points = new TColgp_HSequenceOfPnt;
330           StdPrs_DeflectionCurve::Add (aPresentation, GC, b1, b2, Deflection, 
331                                        Points->ChangeSequence(), anAngle, Standard_False);
332           Curves.Append(Points);
333         }
334       }
335       else {
336         if (isobuild.IsXLine(i))
337           anIso.Load(GeomAbs_IsoU,Coord,b1,b2);
338         else
339           anIso.Load(GeomAbs_IsoV,Coord,b1,b2);
340         FindLimits(anIso, aLimit,b1, b2);
341         if (b2-b1>Precision::Confusion()) {
342           Handle(TColgp_HSequenceOfPnt) Points = new TColgp_HSequenceOfPnt;
343           StdPrs_DeflectionCurve::Add (aPresentation, anIso, b1, b2, Deflection, 
344                                        Points->ChangeSequence(), anAngle, Standard_False);
345           Curves.Append(Points);
346         }
347       }
348     }
349   }
350 #ifdef DEB_MESH
351   FFaceTimer4.Stop();
352 #endif
353 }
354
355
356 //=========================================================================
357 // function: Match
358 // purpose
359 //=========================================================================
360 Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match
361   (const Quantity_Length X,
362    const Quantity_Length Y,
363    const Quantity_Length Z,
364    const Quantity_Length aDistance,
365    const Handle(BRepAdaptor_HSurface)& aFace,
366    const Handle(Prs3d_Drawer)& aDrawer,
367    const Standard_Boolean DrawUIso,
368    const Standard_Boolean DrawVIso,
369    const Quantity_Length Deflection,
370    const Standard_Integer NBUiso,
371    const Standard_Integer NBViso)
372 {
373
374    StdPrs_ToolRFace ToolRst (aFace);
375    const Standard_Real aLimit = aDrawer->MaximalParameterValue();
376
377   // compute bounds of the restriction
378   Standard_Real UMin,UMax,VMin,VMax;
379   Standard_Real u,v,step;
380   Standard_Integer i,nbPoints = 10;
381   UMin = VMin = RealLast();
382   UMax = VMax = RealFirst();
383   
384   for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
385     Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
386     u = TheRCurve->FirstParameter();
387     v = TheRCurve->LastParameter();
388     step = ( v - u) / nbPoints;
389     for (i = 0; i <= nbPoints; i++) {
390       gp_Pnt2d P = TheRCurve->Value(u);
391       if (P.X() < UMin) UMin = P.X();
392       if (P.X() > UMax) UMax = P.X();
393       if (P.Y() < VMin) VMin = P.Y();
394       if (P.Y() > VMax) VMax = P.Y();
395       u += step;
396     }
397   }
398   
399   // load the isos
400   Hatch_Hatcher isobuild(1.e-5,ToolRst.IsOriented());
401   Standard_Boolean UClosed = aFace->IsUClosed();
402   Standard_Boolean VClosed = aFace->IsVClosed();
403
404   if ( ! UClosed ) {
405     UMin = UMin + ( UMax - UMin) /1000.;
406     UMax = UMax - ( UMax - UMin) /1000.; 
407   }
408
409   if ( ! VClosed ) {
410     VMin = VMin + ( VMax - VMin) /1000.;
411     VMax = VMax - ( VMax - VMin) /1000.; 
412   }
413
414   if (DrawUIso){
415     if (NBUiso > 0) {
416       UClosed = Standard_False; // En attendant un hatcher de course.
417       Standard_Real du= UClosed ? (UMax-UMin)/NBUiso : (UMax-UMin)/(1+NBUiso);
418       for (i=1; i<=NBUiso;i++){
419         isobuild.AddXLine(UMin+du*i);
420       }
421     }
422   }
423   if (DrawVIso){
424     if ( NBViso > 0) {
425       VClosed = Standard_False;
426       Standard_Real dv= VClosed ?(VMax-VMin)/NBViso : (VMax-VMin)/(1+NBViso);
427       for (i=1; i<=NBViso;i++){
428         isobuild.AddYLine(VMin+dv*i);
429       }
430     }
431   }
432
433   // trim the isos
434   gp_Pnt2d P1,P2;
435   gp_Pnt dummypnt;
436   for (ToolRst.Init(); ToolRst.More(); ToolRst.Next()) {
437     TopAbs_Orientation Orient = ToolRst.Orientation();
438     if ( Orient == TopAbs_FORWARD || Orient == TopAbs_REVERSED ) {
439       Adaptor2d_Curve2dPtr TheRCurve = ToolRst.Value();
440       GCPnts_QuasiUniformDeflection UDP(*TheRCurve, Deflection);
441       if (UDP.IsDone()) {
442         Standard_Integer NumberOfPoints = UDP.NbPoints();
443         if ( NumberOfPoints >= 2 ) {
444           dummypnt = UDP.Value(1);
445           P2.SetCoord(dummypnt.X(), dummypnt.Y());
446           for (i = 2; i <= NumberOfPoints; i++) {
447             P1 = P2;
448             dummypnt = UDP.Value(i);
449             P2.SetCoord(dummypnt.X(), dummypnt.Y());
450             if(Orient == TopAbs_FORWARD )
451               isobuild.Trim(P1,P2);
452             else
453               isobuild.Trim(P2,P1);
454           }
455         }
456       }
457       else {
458         cout << "Cannot evaluate curve on surface"<<endl;
459       }
460     }
461   }
462   
463   // draw the isos
464
465   Adaptor3d_IsoCurve anIso;
466   anIso.Load(aFace);
467   Standard_Integer NumberOfLines = isobuild.NbLines();
468   Standard_Real anAngle = aDrawer->DeviationAngle();
469
470   for (i = 1; i <= NumberOfLines; i++) {
471     Standard_Integer NumberOfIntervals = isobuild.NbIntervals(i);
472     Standard_Real Coord = isobuild.Coordinate(i);
473     for (Standard_Integer j = 1; j <= NumberOfIntervals; j++) {
474       Standard_Real b1=isobuild.Start(i,j),b2=isobuild.End(i,j);
475
476       b1 = b1 == RealFirst() ? - aLimit : b1;
477       b2 = b2 == RealLast()  ?   aLimit : b2;
478
479       if (isobuild.IsXLine(i))
480         anIso.Load(GeomAbs_IsoU,Coord,b1,b2);
481       else
482         anIso.Load(GeomAbs_IsoV,Coord,b1,b2);
483     
484       if (StdPrs_DeflectionCurve::Match(X,Y,Z,aDistance,anIso, b1, b2, Deflection, anAngle))
485           return Standard_True;
486     }
487   }
488   return Standard_False;
489 }
490
491
492 //=========================================================================
493 // function: Add
494 // purpose
495 //=========================================================================
496 void StdPrs_WFDeflectionRestrictedFace::Add
497   (const Handle (Prs3d_Presentation)& aPresentation,
498    const Handle(BRepAdaptor_HSurface)& aFace,
499    const Handle (Prs3d_Drawer)& aDrawer)
500 {
501   Prs3d_NListOfSequenceOfPnt Curves;
502   StdPrs_WFDeflectionRestrictedFace::Add (aPresentation,
503                                           aFace,
504                                           Standard_True,
505                                           Standard_True,
506                                           aDrawer->MaximalChordialDeviation(),
507                                           aDrawer->UIsoAspect()->Number(),
508                                           aDrawer->VIsoAspect()->Number(),
509                                           aDrawer,
510                                           Curves);
511 }
512
513
514 //=========================================================================
515 // function: AddUIso
516 // purpose
517 //=========================================================================
518 void StdPrs_WFDeflectionRestrictedFace::AddUIso
519   (const Handle (Prs3d_Presentation)& aPresentation,
520    const Handle(BRepAdaptor_HSurface)& aFace,
521    const Handle (Prs3d_Drawer)& aDrawer)
522 {
523   Prs3d_NListOfSequenceOfPnt Curves;
524   StdPrs_WFDeflectionRestrictedFace::Add ( 
525                       aPresentation,
526                       aFace,
527                       Standard_True,
528                       Standard_False,
529                       aDrawer->MaximalChordialDeviation(),
530                       aDrawer->UIsoAspect()->Number(),
531                       aDrawer->VIsoAspect()->Number(),
532                       aDrawer,
533                       Curves);
534 }
535
536
537 //=========================================================================
538 // function: AddVIso
539 // purpose
540 //=========================================================================
541 void StdPrs_WFDeflectionRestrictedFace::AddVIso
542   (const Handle (Prs3d_Presentation)& aPresentation,
543    const Handle(BRepAdaptor_HSurface)& aFace,
544    const Handle (Prs3d_Drawer)& aDrawer)
545 {
546   Prs3d_NListOfSequenceOfPnt Curves;
547   StdPrs_WFDeflectionRestrictedFace::Add ( 
548                       aPresentation,
549                       aFace,
550                       Standard_False,
551                       Standard_True,
552                       aDrawer->MaximalChordialDeviation(),
553                       aDrawer->UIsoAspect()->Number(),
554                       aDrawer->VIsoAspect()->Number(),
555                       aDrawer,
556                       Curves);
557 }
558
559
560 //=========================================================================
561 // function: Match
562 // purpose
563 //=========================================================================
564 Standard_Boolean StdPrs_WFDeflectionRestrictedFace::Match
565   (const Quantity_Length X,
566    const Quantity_Length Y,
567    const Quantity_Length Z,
568    const Quantity_Length aDistance,
569    const Handle(BRepAdaptor_HSurface)& aFace,
570    const Handle (Prs3d_Drawer)& aDrawer)
571 {
572   return StdPrs_WFDeflectionRestrictedFace::Match (  
573                       X,Y,Z,aDistance,
574                       aFace,
575                       aDrawer,
576                       Standard_True,
577                       Standard_True,
578                       aDrawer->MaximalChordialDeviation(),
579                       aDrawer->UIsoAspect()->Number(),
580                       aDrawer->VIsoAspect()->Number());
581 }
582
583
584 //=========================================================================
585 // function: MatchUIso
586 // purpose
587 //=========================================================================
588 Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchUIso
589   (const Quantity_Length X,
590    const Quantity_Length Y,
591    const Quantity_Length Z,
592    const Quantity_Length aDistance,
593    const Handle(BRepAdaptor_HSurface)& aFace,
594    const Handle (Prs3d_Drawer)& aDrawer)
595 {
596   return StdPrs_WFDeflectionRestrictedFace::Match ( 
597                       X,Y,Z,aDistance,
598                       aFace,
599                       aDrawer,
600                       Standard_True,
601                       Standard_False,
602                       aDrawer->MaximalChordialDeviation(),
603                       aDrawer->UIsoAspect()->Number(),
604                       aDrawer->VIsoAspect()->Number());
605 }
606
607
608 //=========================================================================
609 // function: MatchVIso
610 // purpose
611 //=========================================================================
612 Standard_Boolean StdPrs_WFDeflectionRestrictedFace::MatchVIso
613   (const Quantity_Length X,
614    const Quantity_Length Y,
615    const Quantity_Length Z,
616    const Quantity_Length aDistance,
617    const Handle(BRepAdaptor_HSurface)& aFace,
618    const Handle (Prs3d_Drawer)& aDrawer)
619 {
620   return StdPrs_WFDeflectionRestrictedFace::Match ( 
621                       X,Y,Z,aDistance,
622                       aFace,
623                       aDrawer,
624                       Standard_False,
625                       Standard_True,
626                       aDrawer->MaximalChordialDeviation(),
627                       aDrawer->UIsoAspect()->Number(),
628                       aDrawer->VIsoAspect()->Number());
629 }
630
631 namespace
632 {
633   static const Standard_Integer THE_INDICES[][3] =
634   { { 0, 0, 0 }, { 1, 0, 0 }, { 1, 0, 1 }, { 0, 0, 1 },
635     { 0, 1, 1 }, { 1, 1, 1 }, { 1, 1, 0 }, { 0, 1, 0 },
636     { 0, 0, 0 }, { 0, 0, 1 }, { 1, 0, 1 }, { 1, 1, 1 },
637     { 0, 1, 1 }, { 0, 1, 0 }, { 1, 1, 0 }, { 1, 0, 0 } };
638 }
639
640 //=======================================================================
641 //function : AddBox
642 //purpose  :
643 //=======================================================================
644 void StdPrs_WFDeflectionRestrictedFace::AddBox (const Handle(Prs3d_Presentation)& thePrs,
645                                                 const Bnd_Box&                    theBndBox,
646                                                 const Handle(Prs3d_Drawer)&       theDrawer)
647 {
648   if (theBndBox.IsVoid())
649   {
650     return;
651   }
652
653   Standard_Real X[2], Y[2], Z[2];
654   theBndBox.Get (X[0], Y[0], Z[0], X[1], Y[1], Z[1]);
655
656   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
657   Quantity_Color    aColor;
658   Aspect_TypeOfLine aDummyLineType;
659   Standard_Real     aWidth = 1.0;
660   theDrawer->LineAspect()->Aspect()->Values (aColor, aDummyLineType, aWidth);
661
662   aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (aColor, Aspect_TOL_DOTDASH, aWidth));
663
664   Handle(Graphic3d_ArrayOfPolylines) aPolyline = new Graphic3d_ArrayOfPolylines(16);
665   for(Standard_Integer aVertIter = 0; aVertIter < 16; ++aVertIter)
666   {
667     aPolyline->AddVertex (X[THE_INDICES[aVertIter][0]],
668                           Y[THE_INDICES[aVertIter][1]],
669                           Z[THE_INDICES[aVertIter][2]]);
670   }
671   aGroup->AddPrimitiveArray (aPolyline);
672 }