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