Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/opencascade/Prs3d_BndBox.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Created on: 2014-10-14
0002 // Created by: Anton POLETAEV
0003 // Copyright (c) 2013-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
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 //! Tool for computing bounding box presentation.
0027 class Prs3d_BndBox : public Prs3d_Root
0028 {
0029 public:
0030   //! Computes presentation of a bounding box.
0031   //! @param[in] thePresentation  the presentation.
0032   //! @param[in] theBndBox  the bounding box.
0033   //! @param[in] theDrawer  the drawer.
0034   Standard_EXPORT static void Add(const occ::handle<Prs3d_Presentation>& thePresentation,
0035                                   const Bnd_Box&                         theBndBox,
0036                                   const occ::handle<Prs3d_Drawer>&       theDrawer);
0037 
0038   //! Computes presentation of a bounding box.
0039   //! @param[in] thePresentation  the presentation.
0040   //! @param[in] theBndBox  the bounding box.
0041   //! @param[in] theDrawer  the drawer.
0042   Standard_EXPORT static void Add(const occ::handle<Prs3d_Presentation>& thePresentation,
0043                                   const Bnd_OBB&                         theBndBox,
0044                                   const occ::handle<Prs3d_Drawer>&       theDrawer);
0045 
0046 public:
0047   //! Create primitive array with line segments for displaying a box.
0048   //! @param[in] theBox  the box to add
0049   static occ::handle<Graphic3d_ArrayOfSegments> FillSegments(const Bnd_OBB& theBox)
0050   {
0051     if (theBox.IsVoid())
0052     {
0053       return occ::handle<Graphic3d_ArrayOfSegments>();
0054     }
0055 
0056     occ::handle<Graphic3d_ArrayOfSegments> aSegs = new Graphic3d_ArrayOfSegments(8, 12 * 2);
0057     FillSegments(aSegs, theBox);
0058     return aSegs;
0059   }
0060 
0061   //! Create primitive array with line segments for displaying a box.
0062   //! @param[in] theBox  the box to add
0063   static occ::handle<Graphic3d_ArrayOfSegments> FillSegments(const Bnd_Box& theBox)
0064   {
0065     if (theBox.IsVoid())
0066     {
0067       return occ::handle<Graphic3d_ArrayOfSegments>();
0068     }
0069 
0070     occ::handle<Graphic3d_ArrayOfSegments> aSegs = new Graphic3d_ArrayOfSegments(8, 12 * 2);
0071     FillSegments(aSegs, theBox);
0072     return aSegs;
0073   }
0074 
0075   //! Create primitive array with line segments for displaying a box.
0076   //! @param[in][out] theSegments   primitive array to be filled;
0077   //!                               should be at least 8 nodes and 24 edges in size
0078   //! @param[in] theBox  the box to add
0079   static void FillSegments(const occ::handle<Graphic3d_ArrayOfSegments>& theSegments,
0080                            const Bnd_OBB&                                theBox)
0081   {
0082     if (!theBox.IsVoid())
0083     {
0084       gp_Pnt aXYZ[8];
0085       theBox.GetVertex(aXYZ);
0086       fillSegments(theSegments, aXYZ);
0087     }
0088   }
0089 
0090   //! Create primitive array with line segments for displaying a box.
0091   //! @param[in][out] theSegments   primitive array to be filled;
0092   //!                               should be at least 8 nodes and 24 edges in size
0093   //! @param[in] theBox  the box to add
0094   static void FillSegments(const occ::handle<Graphic3d_ArrayOfSegments>& theSegments,
0095                            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         gp_Pnt(aMin.X(), aMin.Y(), aMin.Z()),
0103         gp_Pnt(aMax.X(), aMin.Y(), aMin.Z()),
0104         gp_Pnt(aMin.X(), aMax.Y(), aMin.Z()),
0105         gp_Pnt(aMax.X(), aMax.Y(), aMin.Z()),
0106         gp_Pnt(aMin.X(), aMin.Y(), aMax.Z()),
0107         gp_Pnt(aMax.X(), aMin.Y(), aMax.Z()),
0108         gp_Pnt(aMin.X(), aMax.Y(), aMax.Z()),
0109         gp_Pnt(aMax.X(), aMax.Y(), aMax.Z()),
0110       };
0111       fillSegments(theSegments, aXYZ);
0112     }
0113   }
0114 
0115 public:
0116   //! Create primitive array with line segments for displaying a box.
0117   //! @param[in][out] theSegments   primitive array to be filled;
0118   //!                               should be at least 8 nodes and 24 edges in size
0119   //! @param[in] theBox  the box to add
0120   static void fillSegments(const occ::handle<Graphic3d_ArrayOfSegments>& theSegments,
0121                            const gp_Pnt*                                 theBox)
0122   {
0123     const int aFrom = theSegments->VertexNumber();
0124     for (int aVertIter = 0; aVertIter < 8; ++aVertIter)
0125     {
0126       theSegments->AddVertex(theBox[aVertIter]);
0127     }
0128 
0129     theSegments->AddEdges(aFrom + 1, aFrom + 2);
0130     theSegments->AddEdges(aFrom + 3, aFrom + 4);
0131     theSegments->AddEdges(aFrom + 5, aFrom + 6);
0132     theSegments->AddEdges(aFrom + 7, aFrom + 8);
0133     //
0134     theSegments->AddEdges(aFrom + 1, aFrom + 3);
0135     theSegments->AddEdges(aFrom + 2, aFrom + 4);
0136     theSegments->AddEdges(aFrom + 5, aFrom + 7);
0137     theSegments->AddEdges(aFrom + 6, aFrom + 8);
0138     //
0139     theSegments->AddEdges(aFrom + 1, aFrom + 5);
0140     theSegments->AddEdges(aFrom + 2, aFrom + 6);
0141     theSegments->AddEdges(aFrom + 3, aFrom + 7);
0142     theSegments->AddEdges(aFrom + 4, aFrom + 8);
0143   }
0144 };
0145 
0146 #endif // _Prs3d_BndBox_H__