BRL-CAD
curvetree.h
Go to the documentation of this file.
1 /* C U R V E T R E E . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2004-2024 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 /** @file brep/curvetree.h */
22 /** @addtogroup brep_curvetree
23  *
24  * @brief
25  * Curve Tree.
26  *
27  */
28 
29 #ifndef BREP_CURVETREE_H
30 #define BREP_CURVETREE_H
31 
32 #include "common.h"
33 
34 #ifdef __cplusplus
35 // @cond SKIP_C++_INCLUDE
36 extern "C++" {
37 # include <map>
38 }
39 // @endcond
40 #endif
41 
42 #include "brep/defines.h"
43 #include "brep/brnode.h"
44 #include "brep/util.h"
45 
46 
47 __BEGIN_DECLS
48 
49 #ifdef __cplusplus
50 extern "C++" {
51 
52 namespace brlcad {
53 
54  /**
55  * CurveTree declaration
56  */
57  class BREP_EXPORT CurveTree : public PooledObject<CurveTree> {
58  public:
59  explicit CurveTree(const ON_BrepFace *face);
61 
62  CurveTree(Deserializer &deserializer, const ON_BrepFace &face);
63  void serialize(Serializer &serializer) const;
64  std::vector<std::size_t> serialize_get_leaves_keys(const std::list<const BRNode *> &leaves) const;
65  std::list<const BRNode *> serialize_get_leaves(const std::size_t *keys, std::size_t num_keys) const;
66  void serialize_cleanup() const;
67 
68  /**
69  * Return just the leaves of the surface tree
70  */
71  void getLeaves(std::list<const BRNode *> &out_leaves) const;
72  void getLeavesAbove(std::list<const BRNode *> &out_leaves, const ON_Interval &u, const ON_Interval &v) const;
73  void getLeavesAbove(std::list<const BRNode *> &out_leaves, const ON_2dPoint &pt, fastf_t tol) const;
74  void getLeavesRight(std::list<const BRNode *> &out_leaves, const ON_2dPoint &pt, fastf_t tol) const;
75 
76  private:
77  friend class BBNode;
78 
79  CurveTree(const CurveTree &source);
80  CurveTree &operator=(const CurveTree &source);
81 
82  const BRNode *getRootNode() const;
83 
84  /**
85  * Calculate, using the surface bounding volume hierarchy, a uv
86  * estimate for the closest point on the surface to the point in
87  * 3-space.
88  */
89  ON_2dPoint getClosestPointEstimate(const ON_3dPoint &pt) const;
90  ON_2dPoint getClosestPointEstimate(const ON_3dPoint &pt, ON_Interval &u, ON_Interval &v) const;
91 
92  void getLeavesRight(std::list<const BRNode *> &out_leaves, const ON_Interval &u, const ON_Interval &v) const;
93 
94  int depth() const;
95 
96  bool getHVTangents(const ON_Curve *curve, const ON_Interval &t, std::list<fastf_t> &list) const;
97  bool isLinear(const ON_Curve *curve, double min, double max) const;
98  BRNode *subdivideCurve(const ON_Curve *curve, int trim_index, int adj_face_index, double min, double max, bool innerTrim, int depth) const;
99  BRNode *curveBBox(const ON_Curve *curve, int trim_index, int adj_face_index, const ON_Interval &t, bool isLeaf, bool innerTrim, const ON_BoundingBox &bb) const;
100  static ON_BoundingBox initialLoopBBox(const ON_BrepFace &face);
101 
102  const ON_BrepFace * const m_face;
103  BRNode *m_root;
104 
105 
106  struct Stl : public PooledObject<Stl> {
107  Stl() : m_sortedX() {}
108 
109  std::vector<const BRNode *> m_sortedX;
110  } * const m_stl;
111 
112  mutable std::map<const BRNode *, std::size_t> *m_sortedX_indices;
113  };
114 
115 } /* namespace brlcad */
116 
117 } /* extern C++ */
118 
119 __END_DECLS
120 
121 #endif /* __cplusplus */
122 
123 /** @} */
124 
125 #endif /* BREP_CURVETREE_H */
126 
127 /*
128  * Local Variables:
129  * mode: C
130  * tab-width: 8
131  * indent-tabs-mode: t
132  * c-file-style: "stroustrup"
133  * End:
134  * ex: shiftwidth=4 tabstop=8
135  */
void getLeaves(std::list< const BRNode * > &out_leaves) const
void getLeavesRight(std::list< const BRNode * > &out_leaves, const ON_2dPoint &pt, fastf_t tol) const
void serialize(Serializer &serializer) const
void getLeavesAbove(std::list< const BRNode * > &out_leaves, const ON_2dPoint &pt, fastf_t tol) const
std::list< const BRNode * > serialize_get_leaves(const std::size_t *keys, std::size_t num_keys) const
CurveTree(const ON_BrepFace *face)
void serialize_cleanup() const
CurveTree(Deserializer &deserializer, const ON_BrepFace &face)
void getLeavesAbove(std::list< const BRNode * > &out_leaves, const ON_Interval &u, const ON_Interval &v) const
std::vector< std::size_t > serialize_get_leaves_keys(const std::list< const BRNode * > &leaves) const
Header file for the BRL-CAD common definitions.
void int char int int double * min
Definition: tig.h:182
double fastf_t
fastest 64-bit (or larger) floating point type
Definition: vmath.h:334
Definition: bbnode.h:42
NMG topological face.
Definition: topology.h:210