Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-24 09:15:12

0001 // Created on: 1993-07-22
0002 // Created by: Isabelle GRIGNON
0003 // Copyright (c) 1993-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _BRepBndLib_HeaderFile
0018 #define _BRepBndLib_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 
0023 class TopoDS_Shape;
0024 class Bnd_Box;
0025 class Bnd_OBB;
0026 
0027 //! This package provides the bounding boxes for curves
0028 //! and surfaces from BRepAdaptor.
0029 //! Functions to add a topological shape to a bounding box
0030 class BRepBndLib
0031 {
0032 public:
0033   DEFINE_STANDARD_ALLOC
0034 
0035   //! Adds the shape S to the bounding box B.
0036   //! More precisely are successively added to B:
0037   //! -   each face of S; the triangulation of the face is used if it exists,
0038   //! -   then each edge of S which does not belong to a face,
0039   //! the polygon of the edge is used if it exists
0040   //! -   and last each vertex of S which does not belong to an edge.
0041   //! After each elementary operation, the bounding box B is
0042   //! enlarged by the tolerance value of the relative sub-shape.
0043   //! When working with the triangulation of a face this value of
0044   //! enlargement is the sum of the triangulation deflection and
0045   //! the face tolerance. When working with the
0046   //! polygon of an edge this value of enlargement is
0047   //! the sum of the polygon deflection and the edge tolerance.
0048   //! Warning
0049   //! -   This algorithm is time consuming if triangulation has not
0050   //! been inserted inside the data structure of the shape S.
0051   //! -   The resulting bounding box may be somewhat larger than the object.
0052   Standard_EXPORT static void Add(const TopoDS_Shape& S,
0053                                   Bnd_Box&            B,
0054                                   const bool          useTriangulation = true);
0055 
0056   //! Adds the shape S to the bounding box B.
0057   //! This is a quick algorithm but only works if the shape S is
0058   //! composed of polygonal planar faces, as is the case if S is
0059   //! an approached polyhedral representation of an exact
0060   //! shape. Pay particular attention to this because this
0061   //! condition is not checked and, if it not respected, an error
0062   //! may occur in the algorithm for which the bounding box is built.
0063   //! Note that the resulting bounding box is not enlarged by the
0064   //! tolerance value of the sub-shapes as is the case with the
0065   //! Add function. So the added part of the resulting bounding
0066   //! box is closer to the shape S.
0067   Standard_EXPORT static void AddClose(const TopoDS_Shape& S, Bnd_Box& B);
0068 
0069   //! Adds the shape S to the bounding box B.
0070   //! This algorithm builds precise bounding box,
0071   //! which differs from exact geometry boundaries of shape only on shape entities tolerances
0072   //! Algorithm is the same as for method Add(..), but uses more precise methods for building boxes
0073   //! for geometry objects.
0074   //! If useShapeTolerance = True, bounding box is enlardged by shape tolerances and
0075   //! these tolerances are used for numerical methods of bounding box size calculations,
0076   //! otherwise bounding box is built according to sizes of uderlined geometrical entities,
0077   //! numerical calculation use tolerance Precision::Confusion().
0078   Standard_EXPORT static void AddOptimal(const TopoDS_Shape& S,
0079                                          Bnd_Box&            B,
0080                                          const bool          useTriangulation  = true,
0081                                          const bool          useShapeTolerance = false);
0082 
0083   //! Computes the Oriented Bounding box for the shape <theS>.
0084   //! Two independent methods of computation are implemented:
0085   //! first method based on set of points (so, it demands the
0086   //! triangulated shape or shape with planar faces and linear edges).
0087   //! The second method is based on use of inertia axes and is called
0088   //! if use of the first method is impossible.
0089   //! If theIsTriangulationUsed == FALSE then the triangulation will
0090   //! be ignored at all.
0091   //! If theIsShapeToleranceUsed == TRUE then resulting box will be
0092   //! extended on the tolerance of the shape.
0093   //! theIsOptimal flag defines whether to look for the more tight
0094   //! OBB for the cost of performance or not.
0095   Standard_EXPORT static void AddOBB(const TopoDS_Shape& theS,
0096                                      Bnd_OBB&            theOBB,
0097                                      const bool          theIsTriangulationUsed  = true,
0098                                      const bool          theIsOptimal            = false,
0099                                      const bool          theIsShapeToleranceUsed = true);
0100 };
0101 
0102 #endif // _BRepBndLib_HeaderFile