File indexing completed on 2025-01-18 10:04:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _Prs3d_BndBox_H__
0017 #define _Prs3d_BndBox_H__
0018
0019 #include <Bnd_OBB.hxx>
0020 #include <Graphic3d_ArrayOfSegments.hxx>
0021 #include <Graphic3d_ArrayOfTriangles.hxx>
0022 #include <Prs3d_Drawer.hxx>
0023 #include <Prs3d_Presentation.hxx>
0024 #include <Prs3d_Root.hxx>
0025
0026
0027 class Prs3d_BndBox : public Prs3d_Root
0028 {
0029 public:
0030
0031
0032
0033
0034
0035 Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
0036 const Bnd_Box& theBndBox,
0037 const Handle(Prs3d_Drawer)& theDrawer);
0038
0039
0040
0041
0042
0043 Standard_EXPORT static void Add (const Handle(Prs3d_Presentation)& thePresentation,
0044 const Bnd_OBB& theBndBox,
0045 const Handle(Prs3d_Drawer)& theDrawer);
0046
0047 public:
0048
0049
0050
0051 static Handle(Graphic3d_ArrayOfSegments) FillSegments (const Bnd_OBB& theBox)
0052 {
0053 if (theBox.IsVoid())
0054 {
0055 return Handle(Graphic3d_ArrayOfSegments)();
0056 }
0057
0058 Handle(Graphic3d_ArrayOfSegments) aSegs = new Graphic3d_ArrayOfSegments (8, 12 * 2);
0059 FillSegments (aSegs, theBox);
0060 return aSegs;
0061 }
0062
0063
0064
0065 static Handle(Graphic3d_ArrayOfSegments) FillSegments (const Bnd_Box& theBox)
0066 {
0067 if (theBox.IsVoid())
0068 {
0069 return Handle(Graphic3d_ArrayOfSegments)();
0070 }
0071
0072 Handle(Graphic3d_ArrayOfSegments) aSegs = new Graphic3d_ArrayOfSegments (8, 12 * 2);
0073 FillSegments (aSegs, theBox);
0074 return aSegs;
0075 }
0076
0077
0078
0079
0080
0081 static void FillSegments (const Handle(Graphic3d_ArrayOfSegments)& theSegments, const Bnd_OBB& theBox)
0082 {
0083 if (!theBox.IsVoid())
0084 {
0085 gp_Pnt aXYZ[8];
0086 theBox.GetVertex (aXYZ);
0087 fillSegments (theSegments, aXYZ);
0088 }
0089 }
0090
0091
0092
0093
0094
0095 static void FillSegments (const Handle(Graphic3d_ArrayOfSegments)& theSegments, const Bnd_Box& theBox)
0096 {
0097 if (!theBox.IsVoid())
0098 {
0099 const gp_Pnt aMin = theBox.CornerMin();
0100 const gp_Pnt aMax = theBox.CornerMax();
0101 const gp_Pnt aXYZ[8] =
0102 {
0103 gp_Pnt (aMin.X(), aMin.Y(), aMin.Z()),
0104 gp_Pnt (aMax.X(), aMin.Y(), aMin.Z()),
0105 gp_Pnt (aMin.X(), aMax.Y(), aMin.Z()),
0106 gp_Pnt (aMax.X(), aMax.Y(), aMin.Z()),
0107 gp_Pnt (aMin.X(), aMin.Y(), aMax.Z()),
0108 gp_Pnt (aMax.X(), aMin.Y(), aMax.Z()),
0109 gp_Pnt (aMin.X(), aMax.Y(), aMax.Z()),
0110 gp_Pnt (aMax.X(), aMax.Y(), aMax.Z()),
0111 };
0112 fillSegments (theSegments, aXYZ);
0113 }
0114 }
0115
0116 public:
0117
0118
0119
0120
0121
0122 static void fillSegments (const Handle(Graphic3d_ArrayOfSegments)& theSegments, const gp_Pnt* theBox)
0123 {
0124 const Standard_Integer aFrom = theSegments->VertexNumber();
0125 for (int aVertIter = 0; aVertIter < 8; ++aVertIter)
0126 {
0127 theSegments->AddVertex (theBox[aVertIter]);
0128 }
0129
0130 theSegments->AddEdges (aFrom + 1, aFrom + 2);
0131 theSegments->AddEdges (aFrom + 3, aFrom + 4);
0132 theSegments->AddEdges (aFrom + 5, aFrom + 6);
0133 theSegments->AddEdges (aFrom + 7, aFrom + 8);
0134
0135 theSegments->AddEdges (aFrom + 1, aFrom + 3);
0136 theSegments->AddEdges (aFrom + 2, aFrom + 4);
0137 theSegments->AddEdges (aFrom + 5, aFrom + 7);
0138 theSegments->AddEdges (aFrom + 6, aFrom + 8);
0139
0140 theSegments->AddEdges (aFrom + 1, aFrom + 5);
0141 theSegments->AddEdges (aFrom + 2, aFrom + 6);
0142 theSegments->AddEdges (aFrom + 3, aFrom + 7);
0143 theSegments->AddEdges (aFrom + 4, aFrom + 8);
0144 }
0145
0146 };
0147
0148 #endif