BRL-CAD
surfacetree.h
Go to the documentation of this file.
1/* S U R F A C E T R E E . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2004-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20
21/** @addtogroup brep_surfacetree
22 *
23 * @brief
24 * Curve Tree.
25 *
26 */
27#ifndef BREP_SURFACETREE_H
28#define BREP_SURFACETREE_H
29
30#include "common.h"
31#ifdef __cplusplus
32extern "C++" {
33/* @cond */
34#include <list>
35#include <queue>
36/* @endcond */
37}
38#endif
39#include "brep/defines.h"
40#include "brep/curvetree.h"
41#include "brep/bbnode.h"
42
43/** @{ */
44/** @file brep/surfacetree.h */
45
46#ifdef __cplusplus
47
48__BEGIN_DECLS
49
50extern "C++" {
51namespace brlcad {
52
53 /**
54 * SurfaceTree declaration
55 */
56 class BREP_EXPORT SurfaceTree {
57 public:
58 explicit SurfaceTree(const ON_BrepFace *face, bool removeTrimmed = true, int depthLimit = BREP_MAX_FT_DEPTH, double within_distance_tol = BREP_EDGE_MISS_TOLERANCE);
60
61 /* Report whether the tree is in a usable state */
62 bool Valid() const {
63 if (!m_root)
64 return false;
65 return true;
66 };
67
69
70 /**
71 * Calculate, using the surface bounding volume hierarchy, a uv
72 * estimate for the closest point on the surface to the point in
73 * 3-space.
74 */
75 ON_2dPoint getClosestPointEstimate(const ON_3dPoint &pt) const;
76 ON_2dPoint getClosestPointEstimate(const ON_3dPoint &pt, ON_Interval &u, ON_Interval &v) const;
77
78 /**
79 * Return surface
80 */
81 const ON_Surface *getSurface() const;
82 int getSurfacePoint(const ON_3dPoint &pt, ON_2dPoint &uv, const ON_3dPoint &from, double tolerance = BREP_SAME_POINT_TOLERANCE) const;
83
84 /**
85 * Return just the leaves of the surface tree
86 */
87 void getLeaves(std::list<const BBNode *> &out_leaves) const;
88
90
91 private:
92 SurfaceTree(const SurfaceTree &source);
93 SurfaceTree &operator=(const SurfaceTree &source);
94
95 int depth() const;
96 bool isFlat(const ON_Plane frames[9]) const;
97 bool isStraight(const ON_Plane frames[9]) const;
98 bool isFlatU(const ON_Plane frames[9]) const;
99 bool isFlatV(const ON_Plane frames[9]) const;
100 BBNode *subdivideSurface(const ON_Surface *localsurf, const ON_Interval &u, const ON_Interval &v, ON_Plane frames[9], int depth, int depthLimit, int prev_knot, double within_distance_tol) const;
101 BBNode *surfaceBBox(const ON_Surface *localsurf, bool leaf, const ON_Plane frames[9], const ON_Interval &u, const ON_Interval &v, double within_distance_tol) const;
102
103 const bool m_removeTrimmed;
104 const ON_BrepFace * const m_face;
105 BBNode *m_root;
106 std::queue<ON_Plane *> * const m_f_queue;
107 };
108
109} /* namespace brlcad */
110} /* extern C++ */
111
112__END_DECLS
113
114#endif
115
116/** @} */
117
118#endif /* BREP_SURFACETREE_H */
119
120/*
121 * Local Variables:
122 * mode: C
123 * tab-width: 8
124 * indent-tabs-mode: t
125 * c-file-style: "stroustrup"
126 * End:
127 * ex: shiftwidth=4 tabstop=8
128 */
SurfaceTree(const ON_BrepFace *face, bool removeTrimmed=true, int depthLimit=BREP_MAX_FT_DEPTH, double within_distance_tol=BREP_EDGE_MISS_TOLERANCE)
const ON_Surface * getSurface() const
bool Valid() const
Definition: surfacetree.h:62
ON_2dPoint getClosestPointEstimate(const ON_3dPoint &pt, ON_Interval &u, ON_Interval &v) const
BBNode * getRootNode() const
const CurveTree * m_ctree
Definition: surfacetree.h:89
void getLeaves(std::list< const BBNode * > &out_leaves) const
int getSurfacePoint(const ON_3dPoint &pt, ON_2dPoint &uv, const ON_3dPoint &from, double tolerance=BREP_SAME_POINT_TOLERANCE) const
ON_2dPoint getClosestPointEstimate(const ON_3dPoint &pt) const
Header file for the BRL-CAD common definitions.
#define BREP_SAME_POINT_TOLERANCE
Definition: defines.h:155
#define BREP_MAX_FT_DEPTH
Definition: defines.h:118
#define BREP_EDGE_MISS_TOLERANCE
Definition: defines.h:153
Definition: bbnode.h:42
NMG topological face.
Definition: topology.h:210