0029311: Implementation of the Oriented Bounding Boxes (OBB) functionality
[occt.git] / src / BRepBndLib / BRepBndLib.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-07-22
2// Created by: Isabelle GRIGNON
3// Copyright (c) 1993-1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
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
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.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _BRepBndLib_HeaderFile
18#define _BRepBndLib_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <Standard_Boolean.hxx>
25class TopoDS_Shape;
26class Bnd_Box;
1a0339b4 27class Bnd_OBB;
42cf5bc1 28
29
30//! This package provides the bounding boxes for curves
31//! and surfaces from BRepAdaptor.
32//! Functions to add a topological shape to a bounding box
33class BRepBndLib
34{
35public:
36
37 DEFINE_STANDARD_ALLOC
38
39
40 //! Adds the shape S to the bounding box B.
41 //! More precisely are successively added to B:
42 //! - each face of S; the triangulation of the face is used if it exists,
43 //! - then each edge of S which does not belong to a face,
44 //! the polygon of the edge is used if it exists
45 //! - and last each vertex of S which does not belong to an edge.
46 //! After each elementary operation, the bounding box B is
47 //! enlarged by the tolerance value of the relative sub-shape.
48 //! When working with the triangulation of a face this value of
49 //! enlargement is the sum of the triangulation deflection and
50 //! the face tolerance. When working with the
51 //! polygon of an edge this value of enlargement is
52 //! the sum of the polygon deflection and the edge tolerance.
53 //! Warning
54 //! - This algorithm is time consuming if triangulation has not
55 //! been inserted inside the data structure of the shape S.
56 //! - The resulting bounding box may be somewhat larger than the object.
57 Standard_EXPORT static void Add (const TopoDS_Shape& S, Bnd_Box& B, const Standard_Boolean useTriangulation = Standard_True);
58
59 //! Adds the shape S to the bounding box B.
60 //! This is a quick algorithm but only works if the shape S is
61 //! composed of polygonal planar faces, as is the case if S is
62 //! an approached polyhedral representation of an exact
63 //! shape. Pay particular attention to this because this
64 //! condition is not checked and, if it not respected, an error
65 //! may occur in the algorithm for which the bounding box is built.
66 //! Note that the resulting bounding box is not enlarged by the
67 //! tolerance value of the sub-shapes as is the case with the
68 //! Add function. So the added part of the resulting bounding
69 //! box is closer to the shape S.
70 Standard_EXPORT static void AddClose (const TopoDS_Shape& S, Bnd_Box& B);
71
3ba87fdb 72 //! Adds the shape S to the bounding box B.
73 //! This algorith builds precise bounding box,
74 //! which differs from exact geometry boundaries of shape only on shape entities tolerances
75 //! Algorithm is the same as for method Add(..), but uses more precise methods for building boxes
76 //! for geometry objects.
77 //! If useShapeTolerance = True, bounding box is enlardged by shape tolerances and
78 //! these tolerances are used for numerical methods of bounding box size calculations,
79 //! otherwise bounding box is built according to sizes of uderlined geometrical entities,
80 //! numerical calculation use tolerance Precision::Confusion().
81 Standard_EXPORT static void AddOptimal (const TopoDS_Shape& S, Bnd_Box& B,
82 const Standard_Boolean useTriangulation = Standard_True,
83 const Standard_Boolean useShapeTolerance = Standard_False);
42cf5bc1 84
85
1a0339b4 86 //! Computes the Oriented Bounding box for the shape <theS>.
87 //! Two independent methods of computation are implemented:
88 //! first method based on set of points (so, it demands the
89 //! triangulated shape or shape with planar faces and linear edges).
90 //! The second method is based on use of inertia axes and is called
91 //! if use of the first method is impossible.
92 //! If theIsTriangulationUsed == FALSE then the triangulation will
93 //! be ignored at all.
94 //! If theIsShapeToleranceUsed == TRUE then resulting box will be
95 //! extended on the tolerance of the shape.
96 //! theIsOptimal flag defines the algorithm for construction of initial
97 //! Bnd_Box for the second method (if theIsOptimal == TRUE then
98 //! this box will be created by AddOptimal(...) method).
99 Standard_EXPORT static
100 void AddOBB(const TopoDS_Shape& theS,
101 Bnd_OBB& theOBB,
102 const Standard_Boolean theIsTriangulationUsed = Standard_True,
103 const Standard_Boolean theIsOptimal = Standard_False,
104 const Standard_Boolean theIsShapeToleranceUsed = Standard_True);
42cf5bc1 105
106protected:
107
108
109
110
111
112private:
113
114
115
116
117
118};
119
120
121
122
123
124
125
126#endif // _BRepBndLib_HeaderFile