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