0024510: Remove unused local variables
[occt.git] / src / Primitives / Primitives_Wedge.gxx
CommitLineData
b311480e 1// Created on: 1991-09-27
2// Created by: Christophe MARION
3// Copyright (c) 1991-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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <Precision.hxx>
18#include <gp_Vec.hxx>
19#include <gp_Pln.hxx>
20#include <gp_Lin.hxx>
21#include <ElSLib.hxx>
22#include <ElCLib.hxx>
23
24#include <Standard_DomainError.hxx>
25#include <Standard_OutOfRange.hxx>
26
27#undef Standard_True
28#undef Standard_False
29
30#define Standard_True ((Standard_Boolean) 1)
31#define Standard_False ((Standard_Boolean) 0)
32
33#define NBFACES 6
34#define NBWIRES 6
35#define NBEDGES 12
36#define NBVERTICES 8
37
38static const Standard_Integer num[6] = {0,1,2,3,4,5};
39static const Standard_Integer val[6] = {0,4,0,2,0,1};
40static const Standard_Integer tab[6][6] = {{-1,-1, 0, 1, 8, 9},
41 {-1,-1, 2, 3,10,11},
42 { 0, 2,-1,-1, 4, 5},
43 { 1, 3,-1,-1, 6, 7},
44 { 8,10, 4, 6,-1,-1},
45 { 9,11, 5, 7,-1,-1}};
46
47//=======================================================================
48//function : Primitives_Wedge_NumDir1
49//purpose : when giving a direction return the range of the face
50//=======================================================================
51
52static Standard_Integer Primitives_Wedge_NumDir1
53 (const Primitives_Direction d1) { return num[d1]; }
54
55//=======================================================================
56//function : Primitives_Wedge_NumDir2
57//purpose : when giving two directions return the range of the edge
58//=======================================================================
59
60static Standard_Integer Primitives_Wedge_NumDir2
61 (const Primitives_Direction d1,
62 const Primitives_Direction d2)
63{
64 Standard_Integer i1 = Primitives_Wedge_NumDir1(d1);
65 Standard_Integer i2 = Primitives_Wedge_NumDir1(d2);
66 if ( i1/2 == i2/2 ) Standard_DomainError::Raise();
67 return tab[i1][i2];
68}
69
70//=======================================================================
71//function : Primitives_Wedge_NumDir3
72//purpose : when giving three directions return the range of the vertex
73//=======================================================================
74
75static Standard_Integer Primitives_Wedge_NumDir3
76 (const Primitives_Direction d1,
77 const Primitives_Direction d2,
78 const Primitives_Direction d3)
79{
80 Standard_Integer i1 = Primitives_Wedge_NumDir1(d1);
81 Standard_Integer i2 = Primitives_Wedge_NumDir1(d2);
82 Standard_Integer i3 = Primitives_Wedge_NumDir1(d3);
83 if (( i1/2 == i2/2 ) ||
84 ( i2/2 == i3/2 ) ||
85 ( i3/2 == i1/2 )) Standard_DomainError::Raise();
86 return val[i1]+val[i2]+val[i3];
87}
88
89//=======================================================================
90//function : Primitives_Wedge_Check
91//purpose : raise Standard_DomainError if something was built
92//=======================================================================
93
94static void Primitives_Wedge_Check(const Standard_Boolean V[],
95 const Standard_Boolean E[],
96 const Standard_Boolean W[],
97 const Standard_Boolean F[])
98{
99 Standard_Integer i;
100 for (i = 0; i < NBVERTICES; i++)
101 if (V[i]) Standard_DomainError::Raise();
102 for (i = 0; i < NBEDGES; i++)
103 if (E[i]) Standard_DomainError::Raise();
104 for (i = 0; i < NBWIRES; i++)
105 if (W[i]) Standard_DomainError::Raise();
106 for (i = 0; i < NBFACES; i++)
107 if (F[i]) Standard_DomainError::Raise();
108}
109
110//=======================================================================
111//function : Primitives_Wedge_Init
112//purpose : Set arrays to Standard_False
113//=======================================================================
114
115static void Primitives_Wedge_Init(Standard_Boolean& S,
116 Standard_Boolean V[],
117 Standard_Boolean E[],
118 Standard_Boolean W[],
119 Standard_Boolean F[])
120{
121 Standard_Integer i;
122 S = Standard_False;
123 for (i = 0; i < NBVERTICES; i++)
124 V[i] = Standard_False;
125 for (i = 0; i < NBEDGES; i++)
126 E[i] = Standard_False;
127 for (i = 0; i < NBWIRES; i++)
128 W[i] = Standard_False;
129 for (i = 0; i < NBFACES; i++)
130 F[i] = Standard_False;
131}
132
133//=======================================================================
134//function : Primitives_Wedge
135//purpose : build a box
136//=======================================================================
137
138Primitives_Wedge::Primitives_Wedge (const TheBuilder& B,
139 const gp_Ax2& Axes,
140 const Standard_Real dx,
141 const Standard_Real dy,
142 const Standard_Real dz) :
143 myBuilder(B),
144 myAxes(Axes),
145 XMin(0),
146 XMax(dx),
147 YMin(0),
148 YMax(dy),
149 ZMin(0),
150 ZMax(dz),
151 Z2Min(0),
152 Z2Max(dz),
153 X2Min(0),
154 X2Max(dx)
155{
156 for (Standard_Integer i = 0; i < NBFACES; i++) { myInfinite[i]=Standard_False; }
157 if ( ( dx <= Precision::Confusion() ) ||
158 ( dy <= Precision::Confusion() ) ||
159 ( dz <= Precision::Confusion() ) )
160 Standard_DomainError::Raise();
161 Primitives_Wedge_Init(ShellBuilt,VerticesBuilt,EdgesBuilt,
162 WiresBuilt,FacesBuilt);
163}
164
165//=======================================================================
166//function : Primitives_Wedge
167//purpose : build a STEP wedge
168//=======================================================================
169
170Primitives_Wedge::Primitives_Wedge (const TheBuilder& B,
171 const gp_Ax2& Axes,
172 const Standard_Real dx,
173 const Standard_Real dy,
174 const Standard_Real dz,
175 const Standard_Real ltx) :
176 myBuilder(B),
177 myAxes(Axes),
178 XMin(0),
179 XMax(dx),
180 YMin(0),
181 YMax(dy),
182 ZMin(0),
183 ZMax(dz),
184 Z2Min(0),
185 Z2Max(dz),
186 X2Min(0),
187 X2Max(ltx)
188{
189 for (Standard_Integer i = 0; i < NBFACES; i++) { myInfinite[i]=Standard_False; }
190 if ( ( dx <= Precision::Confusion() ) ||
191 ( dy <= Precision::Confusion() ) ||
192 ( dz <= Precision::Confusion() ) ||
193 ( ltx < 0 ) )
194 Standard_DomainError::Raise();
195 Primitives_Wedge_Init(ShellBuilt,VerticesBuilt,EdgesBuilt,
196 WiresBuilt,FacesBuilt);
197}
198
199//=======================================================================
200//function : Primitives_Wedge
201//purpose : build a wedge by giving all the fields
202//=======================================================================
203
204Primitives_Wedge::Primitives_Wedge (const TheBuilder& B,
205 const gp_Ax2& Axes,
206 const Standard_Real xmin,
207 const Standard_Real ymin,
208 const Standard_Real zmin,
209 const Standard_Real z2min,
210 const Standard_Real x2min,
211 const Standard_Real xmax,
212 const Standard_Real ymax,
213 const Standard_Real zmax,
214 const Standard_Real z2max,
215 const Standard_Real x2max) :
216 myBuilder(B),
217 myAxes(Axes),
218 XMin(xmin),
219 XMax(xmax),
220 YMin(ymin),
221 YMax(ymax),
222 ZMin(zmin),
223 ZMax(zmax),
224 Z2Min(z2min),
225 Z2Max(z2max),
226 X2Min(x2min),
227 X2Max(x2max)
228{
229 for (Standard_Integer i = 0; i < NBFACES; i++) { myInfinite[i]=Standard_False; }
230 if ( ( XMax-XMin <= Precision::Confusion() ) ||
231 ( YMax-YMin <= Precision::Confusion() ) ||
232 ( ZMax-ZMin <= Precision::Confusion() ) ||
233 ( Z2Max-Z2Min < 0 ) ||
234 ( X2Max-X2Min < 0 ) )
235 Standard_DomainError::Raise();
236 Primitives_Wedge_Init(ShellBuilt,VerticesBuilt,EdgesBuilt,
237 WiresBuilt,FacesBuilt);
238}
239
240//=======================================================================
241//function : Axes,
242// GetXMin, GetYMin, GetZMin, GetZ2Min, GetX2Min
243// GetXMax, GetYMax, GetZMax, GetZ2Max, GetX2Max
244//purpose : trivial
245//=======================================================================
246
247gp_Ax2 Primitives_Wedge::Axes () const { return myAxes; }
248Standard_Real Primitives_Wedge::GetXMin () const { return XMin; }
249Standard_Real Primitives_Wedge::GetYMin () const { return YMin; }
250Standard_Real Primitives_Wedge::GetZMin () const { return ZMin; }
251Standard_Real Primitives_Wedge::GetZ2Min () const { return Z2Min; }
252Standard_Real Primitives_Wedge::GetX2Min () const { return X2Min; }
253Standard_Real Primitives_Wedge::GetXMax () const { return XMax; }
254Standard_Real Primitives_Wedge::GetYMax () const { return YMax; }
255Standard_Real Primitives_Wedge::GetZMax () const { return ZMax; }
256Standard_Real Primitives_Wedge::GetZ2Max () const { return Z2Max; }
257Standard_Real Primitives_Wedge::GetX2Max () const { return X2Max; }
258
259//=======================================================================
260//function : Open
261//purpose : trivial
262//=======================================================================
263
264void Primitives_Wedge::Open (const Primitives_Direction d1)
265{
266 Primitives_Wedge_Check(VerticesBuilt,EdgesBuilt,WiresBuilt,FacesBuilt);
267 myInfinite[Primitives_Wedge_NumDir1(d1)] = Standard_True;
268}
269
270//=======================================================================
271//function : Close
272//purpose : trivial
273//=======================================================================
274
275void Primitives_Wedge::Close (const Primitives_Direction d1)
276{
277 Primitives_Wedge_Check(VerticesBuilt,EdgesBuilt,WiresBuilt,FacesBuilt);
278 myInfinite[Primitives_Wedge_NumDir1(d1)] = Standard_False;
279}
280
281//=======================================================================
282//function : IsInfinite
283//purpose : true if it is open in the given direction
284//=======================================================================
285
286Standard_Boolean Primitives_Wedge::IsInfinite (const Primitives_Direction d1) const
287{ return myInfinite[Primitives_Wedge_NumDir1(d1)]; }
288
289//=======================================================================
290//function : Shell
291//purpose :
292//=======================================================================
293
294const TheShell& Primitives_Wedge::Shell() {
295 if (!ShellBuilt) {
296 myBuilder.MakeShell(myShell);
297
298 if (HasFace(Primitives_XMin))
299 myBuilder.AddShellFace(myShell,Face(Primitives_XMin));
300 if (HasFace(Primitives_XMax))
301 myBuilder.AddShellFace(myShell,Face(Primitives_XMax));
302 if (HasFace(Primitives_YMin))
303 myBuilder.AddShellFace(myShell,Face(Primitives_YMin));
304 if (HasFace(Primitives_YMax))
305 myBuilder.AddShellFace(myShell,Face(Primitives_YMax));
306 if (HasFace(Primitives_ZMin))
307 myBuilder.AddShellFace(myShell,Face(Primitives_ZMin));
308 if (HasFace(Primitives_ZMax))
309 myBuilder.AddShellFace(myShell,Face(Primitives_ZMax));
310
311 myBuilder.CompleteShell(myShell);
312 ShellBuilt = Standard_True;
313 }
314 return myShell;
315}
316
317//=======================================================================
318//function : HasFace
319//purpose : true if the face exist in one direction
320//=======================================================================
321
322Standard_Boolean Primitives_Wedge::HasFace (const Primitives_Direction d1) const
323{
324 Standard_Boolean state = !myInfinite[Primitives_Wedge_NumDir1(d1)];
325 if ( d1 == Primitives_YMax ) state = state && ( Z2Max != Z2Min )
326 && ( X2Max != X2Min );
327 return state;
328}
329
330//=======================================================================
331//function : Plane
332//purpose :
333//=======================================================================
334
335gp_Pln Primitives_Wedge::Plane(const Primitives_Direction d1)
336{
337
338 Standard_Integer i = Primitives_Wedge_NumDir1(d1);
339
340 gp_Dir D;
341 gp_Vec VX = myAxes.XDirection();
342 gp_Vec VY = myAxes.YDirection();
343 gp_Vec VZ = myAxes.Direction();
344
345 switch (i/2) {
346
347 case 0 :
348 D = myAxes.XDirection();
349 break;
350
351 case 1 :
352 D = myAxes.YDirection();
353 break;
354
355 case 2 :
356 D = myAxes.Direction();
357 break;
358
359 };
1d47d8d0 360 Standard_Real X = 0., Y = 0., Z = 0.;
7fd59977 361
362 switch (i) {
363
364 case 0 :
365 // XMin
366 X = XMin;
367 Y = YMin;
368 Z = ZMin;
369 if ( X2Min != XMin ) D = gp_Dir((YMax-YMin)*VX+(XMin-X2Min)*VY);
370 break;
371
372 case 1 :
373 // XMax
374 X = XMax;
375 Y = YMin;
376 Z = ZMin;
377 if ( X2Max != XMax ) D = gp_Dir((YMax-YMin)*VX+(XMax-X2Max)*VY);
378 break;
379
380 case 2 :
381 // YMin
382 X = XMin;
383 Y = YMin;
384 Z = ZMin;
385 break;
386
387 case 3 :
388 // YMax
389 X = XMin;
390 Y = YMax;
391 Z = ZMin;
392 break;
393
394 case 4 :
395 // ZMin
396 X = XMin;
397 Y = YMin;
398 Z = ZMin;
399 if ( Z2Min != ZMin ) D = gp_Dir((YMax-YMin)*VZ+(ZMin-Z2Min)*VY);
400 break;
401
402 case 5 :
403 // ZMax
404 X = XMin;
405 Y = YMin;
406 Z = ZMax;
407 if ( Z2Max != ZMax ) D = gp_Dir((YMax-YMin)*VZ+(ZMax-Z2Max)*VY);
408 break;
409
410 };
411
412 gp_Pnt P = myAxes.Location();
413 P.Translate(X*gp_Vec(myAxes.XDirection()));
414 P.Translate(Y*gp_Vec(myAxes.YDirection()));
415 P.Translate(Z*gp_Vec(myAxes.Direction ()));
416 gp_Pln plane(P,D);
417 return plane;
418}
419
420//=======================================================================
421//function : Face
422//purpose : the face in one direction
423//=======================================================================
424
425const TheFace& Primitives_Wedge::Face
426 (const Primitives_Direction d1)
427{
428
429 Standard_Integer i = Primitives_Wedge_NumDir1(d1);
430
431 if (!FacesBuilt[i]) {
432 gp_Pln P = Plane(d1);
433 myBuilder.MakeFace(myFaces[i],P);
434 if (HasWire(d1)) myBuilder.AddFaceWire(myFaces[i],Wire(d1));
435 if ( i%2 == 0 ) myBuilder.ReverseFace(myFaces[i]);
436
437 // pcurves
1d47d8d0 438
7fd59977 439 Primitives_Direction dd1 = Primitives_ZMin, dd2 = Primitives_YMax,
440 dd3 = Primitives_ZMax,dd4 = Primitives_YMin;
1d47d8d0 441
7fd59977 442 switch (i/2) {
443
444 case 0 :
445 // XMin XMax
446 dd1 = Primitives_ZMin;
447 dd2 = Primitives_YMax;
448 dd3 = Primitives_ZMax;
449 dd4 = Primitives_YMin;
450 break;
451
452 case 1 :
453 // YMin YMax
454 dd1 = Primitives_XMin;
455 dd2 = Primitives_ZMax;
456 dd3 = Primitives_XMax;
457 dd4 = Primitives_ZMin;
458 break;
459
460 case 2 :
461 // ZMin ZMax
462 dd1 = Primitives_YMin;
463 dd2 = Primitives_XMax;
464 dd3 = Primitives_YMax;
465 dd4 = Primitives_XMin;
466 break;
467
468 };
469
470 gp_Lin L;
471 gp_Dir DX = P.XAxis().Direction();
472 gp_Dir DY = P.YAxis().Direction();
473 Standard_Real U,V,DU,DV;
474 if (HasEdge(d1,dd4)) {
475 L = Line(d1,dd4);
476 ElSLib::Parameters(P,L.Location(),U,V);
477 DU = L.Direction() * DX;
478 DV = L.Direction() * DY;
479 myBuilder.SetPCurve(myEdges[Primitives_Wedge_NumDir2(d1,dd4)],
480 myFaces[i],
481 gp_Lin2d(gp_Pnt2d(U,V),gp_Dir2d(DU,DV)));
482 }
483 if (HasEdge(d1,dd3)) {
484 L = Line(d1,dd3);
485 ElSLib::Parameters(P,L.Location(),U,V);
486 DU = L.Direction() * DX;
487 DV = L.Direction() * DY;
488 myBuilder.SetPCurve(myEdges[Primitives_Wedge_NumDir2(d1,dd3)],
489 myFaces[i],
490 gp_Lin2d(gp_Pnt2d(U,V),gp_Dir2d(DU,DV)));
491 }
492
493 if (HasEdge(d1,dd2)) {
494 L = Line(d1,dd2);
495 ElSLib::Parameters(P,L.Location(),U,V);
496 DU = L.Direction() * DX;
497 DV = L.Direction() * DY;
498 myBuilder.SetPCurve(myEdges[Primitives_Wedge_NumDir2(d1,dd2)],
499 myFaces[i],
500 gp_Lin2d(gp_Pnt2d(U,V),gp_Dir2d(DU,DV)));
501 }
502
503 if (HasEdge(d1,dd1)) {
504 L = Line(d1,dd1);
505 ElSLib::Parameters(P,L.Location(),U,V);
506 DU = L.Direction() * DX;
507 DV = L.Direction() * DY;
508 myBuilder.SetPCurve(myEdges[Primitives_Wedge_NumDir2(d1,dd1)],
509 myFaces[i],
510 gp_Lin2d(gp_Pnt2d(U,V),gp_Dir2d(DU,DV)));
511 }
512
513
514 myBuilder.CompleteFace(myFaces[i]);
515 FacesBuilt[i] = Standard_True;
516 }
517
518 return myFaces[i];
519
520}
521
522//=======================================================================
523//function : HasWire
524//purpose : trivial
525//=======================================================================
526
527Standard_Boolean Primitives_Wedge::HasWire (const Primitives_Direction d1) const
528{
529 Standard_Integer i = Primitives_Wedge_NumDir1(d1);
530
531 if (myInfinite[i]) return Standard_False;
7fd59977 532 Primitives_Direction dd1 = Primitives_XMin,dd2 = Primitives_YMax,dd3 = Primitives_XMax ,dd4 = Primitives_ZMin;
1d47d8d0 533
7fd59977 534 switch (i/2) {
535
536 case 0 :
537 // XMin XMax
538 dd1 = Primitives_ZMin;
539 dd2 = Primitives_YMax;
540 dd3 = Primitives_ZMax;
541 dd4 = Primitives_YMin;
542 break;
543
544 case 1 :
545 // YMin YMax
546 dd1 = Primitives_XMin;
547 dd2 = Primitives_ZMax;
548 dd3 = Primitives_XMax;
549 dd4 = Primitives_ZMin;
550 break;
551
552 case 2 :
553 // ZMin ZMax
554 dd1 = Primitives_YMin;
555 dd2 = Primitives_XMax;
556 dd3 = Primitives_YMax;
557 dd4 = Primitives_XMin;
558 break;
559#ifndef DEB
560 default:
561 break;
562#endif
563 };
564
565 return HasEdge(d1,dd1)||HasEdge(d1,dd2)||HasEdge(d1,dd3)||HasEdge(d1,dd4);
566
567}
568
569//=======================================================================
570//function : Wire
571//purpose : trivial
572//=======================================================================
573
574const TheWire& Primitives_Wedge::Wire
575 (const Primitives_Direction d1)
576{
577 Standard_Integer i = Primitives_Wedge_NumDir1(d1);
578
7fd59977 579 Primitives_Direction dd1 = Primitives_XMin,dd2 = Primitives_YMax,dd3 = Primitives_XMax ,dd4 = Primitives_ZMin;
1d47d8d0 580
7fd59977 581 if (!WiresBuilt[i]) {
582
583 switch (i/2) {
584
585 case 0 :
586 // XMin XMax
587 dd1 = Primitives_ZMin;
588 dd2 = Primitives_YMax;
589 dd3 = Primitives_ZMax;
590 dd4 = Primitives_YMin;
591 break;
592
593 case 1 :
594 // YMin YMax
595 dd1 = Primitives_XMin;
596 dd2 = Primitives_ZMax;
597 dd3 = Primitives_XMax;
598 dd4 = Primitives_ZMin;
599 break;
600
601 case 2 :
602 // ZMin ZMax
603 dd1 = Primitives_YMin;
604 dd2 = Primitives_XMax;
605 dd3 = Primitives_YMax;
606 dd4 = Primitives_XMin;
607 break;
7fd59977 608 default:
609 break;
7fd59977 610 };
611
612 myBuilder.MakeWire(myWires[i]);
613
614 if (HasEdge(d1,dd4))
615 myBuilder.AddWireEdge(myWires[i],Edge(d1,dd4),Standard_False);
616 if (HasEdge(d1,dd3))
617 myBuilder.AddWireEdge(myWires[i],Edge(d1,dd3),Standard_False);
618 if (HasEdge(d1,dd2))
619 myBuilder.AddWireEdge(myWires[i],Edge(d1,dd2),Standard_True );
620 if (HasEdge(d1,dd1))
621 myBuilder.AddWireEdge(myWires[i],Edge(d1,dd1),Standard_True );
622
623 myBuilder.CompleteWire(myWires[i]);
624 WiresBuilt[i] = Standard_True;
625 }
626
627 return myWires[i];
628
629}
630
631//=======================================================================
632//function : HasEdge
633//purpose : trivial
634//=======================================================================
635
636Standard_Boolean Primitives_Wedge::HasEdge (const Primitives_Direction d1,
637 const Primitives_Direction d2) const
638{
639 Standard_Boolean state = !(myInfinite[Primitives_Wedge_NumDir1(d1)] ||
640 myInfinite[Primitives_Wedge_NumDir1(d2)]);
641 Standard_Integer i = Primitives_Wedge_NumDir2(d1,d2);
642 if ( i == 6 || i == 7 ) state = state && ( X2Max != X2Min );
643 else if ( i == 1 || i == 3 ) state = state && ( Z2Max != Z2Min );
644 return state;
645}
646
647//=======================================================================
648//function : Line
649//purpose : trivial
650//=======================================================================
651
652gp_Lin Primitives_Wedge::Line
653 (const Primitives_Direction d1,
654 const Primitives_Direction d2)
655{
656 if (!HasEdge(d1,d2)) Standard_DomainError::Raise();
657
658 Standard_Integer i = Primitives_Wedge_NumDir2(d1,d2);
1d47d8d0 659
7fd59977 660 Standard_Real X =0., Y =0., Z =0.;
1d47d8d0 661
7fd59977 662 gp_Dir D;
663 gp_Vec VX = myAxes.XDirection();
664 gp_Vec VY = myAxes.YDirection();
665 gp_Vec VZ = myAxes.Direction();
7fd59977 666
667 switch (i/4) {
668
669 case 0 :
670 D = myAxes.Direction();
7fd59977 671 break;
672
673 case 1 :
674 D = myAxes.XDirection();
7fd59977 675 break;
676
677 case 2 :
678 D = myAxes.YDirection();
7fd59977 679 break;
680
681 };
682
683 switch (i) {
684
685 case 0 :
686 // XMin YMin
687 X = XMin;
688 Y = YMin;
689 Z = ZMin;
690 break;
691
692 case 1 :
693 // XMin YMax
694 X = X2Min;
695 Y = YMax;
696 Z = Z2Min;
697 break;
698
699 case 2 :
700 // XMax YMin
701 X = XMax;
702 Y = YMin;
703 Z = ZMin;
704 break;
705
706 case 3 :
707 // XMax YMax
708 X = X2Max;
709 Y = YMax;
710 Z = Z2Min;
711 break;
712
713 case 4 :
714 // YMin ZMin
715 X = XMin;
716 Y = YMin;
717 Z = ZMin;
718 break;
719
720 case 5 :
721 // YMin ZMax
722 X = XMin;
723 Y = YMin;
724 Z = ZMax;
725 break;
726
727 case 6 :
728 // YMax ZMin
729 X = X2Min;
730 Y = YMax;
731 Z = Z2Min;
732 break;
733
734 case 7 :
735 // YMax ZMax
736 X = X2Min;
737 Y = YMax;
738 Z = Z2Max;
739 break;
740
741 case 8 :
742 // ZMin XMin
743 X = XMin;
744 Y = YMin;
745 Z = ZMin;
746 if ( (XMin != X2Min) || (ZMin != Z2Min) )
b70bbe58 747 D = gp_Vec( (X2Min-XMin)*VX + (YMax-YMin)*VY + (Z2Min-ZMin)*VZ);
7fd59977 748 break;
749
750 case 9 :
751 // ZMax XMin
752 X = XMin;
753 Y = YMin;
754 Z = ZMax;
755 if ( (XMin != X2Min) || (ZMax != Z2Max) )
756 D = gp_Vec( (X2Min-XMin)*VX + (YMax-YMin)*VY + (Z2Max-ZMax)*VZ);
757 break;
758
759 case 10 :
760 // ZMin XMax
761 X = XMax;
762 Y = YMin;
763 Z = ZMin;
764 if ( (XMax != X2Max) || (ZMin != Z2Min) )
765 D = gp_Vec( (X2Max-XMax)*VX + (YMax-YMin)*VY + (Z2Min-ZMin)*VZ);
766 break;
767
768 case 11 :
769 // ZMax XMax
770 X = XMax;
771 Y = YMin;
772 Z = ZMax;
773 if ( (XMax != X2Max) || (ZMax != Z2Max) )
774 D = gp_Vec(gp_Pnt(XMax,YMin,ZMax),gp_Pnt(X2Max,YMax,Z2Max));
775 D = gp_Vec( (X2Max-XMax)*VX + (YMax-YMin)*VY + (Z2Max-ZMax)*VZ);
776 break;
777
778 }
779
780 gp_Pnt P = myAxes.Location();
781 P.Translate(X*gp_Vec(myAxes.XDirection()));
782 P.Translate(Y*gp_Vec(myAxes.YDirection()));
783 P.Translate(Z*gp_Vec(myAxes.Direction ()));
784 return gp_Lin(gp_Ax1(P,D));
785
786}
787
788//=======================================================================
789//function : Edge
790//purpose : trivial
791//=======================================================================
792
793const TheEdge& Primitives_Wedge::Edge
794 (const Primitives_Direction d1,
795 const Primitives_Direction d2)
796{
797 if (!HasEdge(d1,d2)) Standard_DomainError::Raise();
798
799 Standard_Integer i = Primitives_Wedge_NumDir2(d1,d2);
800
801 if (!EdgesBuilt[i]) {
1d47d8d0 802
7fd59977 803 Primitives_Direction dd1 = Primitives_XMin ,dd2 = Primitives_XMax;
1d47d8d0 804
7fd59977 805 switch (i/4) {
806
807 case 0 :
808 dd1 = Primitives_ZMin;
809 dd2 = Primitives_ZMax;
810 break;
811
812 case 1 :
813 dd1 = Primitives_XMin;
814 dd2 = Primitives_XMax;
815 break;
816
817 case 2 :
818 dd1 = Primitives_YMin;
819 dd2 = Primitives_YMax;
820 break;
96a95605 821
7fd59977 822 default:
823 break;
7fd59977 824 };
825
826 gp_Lin L = Line(d1,d2);
827 myBuilder.MakeEdge(myEdges[i],L);
828
829 if (HasVertex(d1,d2,dd2)) {
830 myBuilder.AddEdgeVertex(myEdges[i],Vertex(d1,d2,dd2),
831 ElCLib::Parameter(L,Point(d1,d2,dd2)),
832 Standard_False);
833 }
834 if (HasVertex(d1,d2,dd1)) {
835 myBuilder.AddEdgeVertex(myEdges[i],Vertex(d1,d2,dd1),
836 ElCLib::Parameter(L,Point(d1,d2,dd1)),
837 Standard_True );
838 }
839
840 if ( Z2Max == Z2Min ) {
841 if ( i == 6 ) {
842 myEdges[7] = myEdges[6];
843 EdgesBuilt[7] = Standard_True;
844 }
845 else if ( i == 7 ) {
846 myEdges[6] = myEdges[7];
847 EdgesBuilt[6] = Standard_True;
848 }
849 }
850 if ( X2Max == X2Min ) {
851 if ( i == 1 ) {
852 myEdges[3] = myEdges[1];
853 EdgesBuilt[3] = Standard_True;
854 }
855 else if ( i == 3 ) {
856 myEdges[1] = myEdges[3];
857 EdgesBuilt[1] = Standard_True;
858 }
859 }
860
861 myBuilder.CompleteEdge(myEdges[i]);
862 EdgesBuilt[i] = Standard_True;
863 }
864
865 return myEdges[i];
866
867}
868
869//=======================================================================
870//function : HasVertex
871//purpose : trivial
872//=======================================================================
873
874Standard_Boolean Primitives_Wedge::HasVertex
875 (const Primitives_Direction d1,
876 const Primitives_Direction d2,
877 const Primitives_Direction d3) const
878{ return !(myInfinite[Primitives_Wedge_NumDir1(d1)] ||
879 myInfinite[Primitives_Wedge_NumDir1(d2)] ||
880 myInfinite[Primitives_Wedge_NumDir1(d3)]); }
881
882//=======================================================================
883//function : Point
884//purpose : trivial
885//=======================================================================
886
887gp_Pnt Primitives_Wedge::Point
888 (const Primitives_Direction d1,
889 const Primitives_Direction d2,
890 const Primitives_Direction d3)
891{
892 if (!HasVertex(d1,d2,d3)) Standard_DomainError::Raise();
893
894 Standard_Integer i = Primitives_Wedge_NumDir3(d1,d2,d3);
1d47d8d0 895
7fd59977 896 Standard_Real X =0., Y =0., Z =0.;
1d47d8d0 897
7fd59977 898 switch (i) {
899
900 case 0 :
901 X = XMin;
902 Y = YMin;
903 Z = ZMin;
904 break;
905
906 case 1 :
907 X = XMin;
908 Y = YMin;
909 Z = ZMax;
910 break;
911
912 case 2 :
913 X = X2Min;
914 Y = YMax;
915 Z = Z2Min;
916 break;
917
918 case 3 :
919 X = X2Min;
920 Y = YMax;
921 Z = Z2Max;
922 break;
923
924 case 4 :
925 X = XMax;
926 Y = YMin;
927 Z = ZMin;
928 break;
929
930 case 5 :
931 X = XMax;
932 Y = YMin;
933 Z = ZMax;
934 break;
935
936 case 6 :
937 X = X2Max;
938 Y = YMax;
939 Z = Z2Min;
940 break;
941
942 case 7 :
943 X = X2Max;
944 Y = YMax;
945 Z = Z2Max;
946 break;
947
948 };
949
950 gp_Pnt P = myAxes.Location();
951 P.Translate(X*gp_Vec(myAxes.XDirection()));
952 P.Translate(Y*gp_Vec(myAxes.YDirection()));
953 P.Translate(Z*gp_Vec(myAxes.Direction ()));
954 return P;
955}
956
957//=======================================================================
958//function : Vertex
959//purpose : trivial
960//=======================================================================
961
962const TheVertex& Primitives_Wedge::Vertex
963 (const Primitives_Direction d1,
964 const Primitives_Direction d2,
965 const Primitives_Direction d3)
966{
967 if (!HasVertex(d1,d2,d3)) Standard_DomainError::Raise();
968
969 Standard_Integer i = Primitives_Wedge_NumDir3(d1,d2,d3);
970
971 if (!VerticesBuilt[i]) {
972
973 myBuilder.MakeVertex(myVertices[i],Point(d1,d2,d3));
974
975 if ( Z2Max == Z2Min ) {
976 if ( i == 2 || i == 6 ) {
977 myVertices[3] = myVertices[2];
978 myVertices[7] = myVertices[6];
979 VerticesBuilt[3] = Standard_True;
980 VerticesBuilt[7] = Standard_True;
981 }
982 else if ( i == 3 || i == 7 ) {
983 myVertices[2] = myVertices[3];
984 myVertices[6] = myVertices[7];
985 VerticesBuilt[2] = Standard_True;
986 VerticesBuilt[6] = Standard_True;
987 }
988 }
989 if ( X2Max == X2Min ) {
990 if ( i == 2 || i == 3 ) {
991 myVertices[6] = myVertices[2];
992 myVertices[7] = myVertices[3];
993 VerticesBuilt[6] = Standard_True;
994 VerticesBuilt[7] = Standard_True;
995 }
996 else if ( i == 6 || i == 7 ) {
997 myVertices[2] = myVertices[6];
998 myVertices[3] = myVertices[7];
999 VerticesBuilt[2] = Standard_True;
1000 VerticesBuilt[3] = Standard_True;
1001 }
1002 }
1003
1004 VerticesBuilt[i] = Standard_True;
1005 }
1006
1007 return myVertices[i];
1008
1009}
1010