50 #ifndef MB_BSPTREENODE_HH 51 #define MB_BSPTREENODE_HH 55 #include <ACG/Geometry/Types/PlaneT.hh> 56 #include <ACG/Geometry/Algorithms.hh> 62 template <
class BSPTraits>
65 typedef typename BSPTraits::Handle Handle;
66 typedef typename BSPTraits::Point Point;
67 typedef typename BSPTraits::VertexHandle VertexHandle;
68 typedef std::vector<Handle> Handles;
69 typedef typename Handles::iterator HandleIter;
70 typedef typename Handles::const_iterator HandleConstIter;
71 typedef typename Point::value_type Scalar;
76 parent_(_parent), left_child_(0), right_child_(0) {}
84 if (
this == parent_->left_child_)
85 parent_->left_child_ = 0;
87 parent_->right_child_ = 0;
92 return handles_.begin();
96 return handles_.end();
99 HandleConstIter begin()
const {
100 return handles_.begin();
103 HandleConstIter end()
const {
104 return handles_.end();
107 size_t size()
const {
108 return handles_.size();
112 TreeNode *parent_, *left_child_, *right_child_;
114 Point bb_min, bb_max;
117 template<
typename MeshT >
120 if (_max_depth > 0 && (left_child_ || right_child_) )
129 Point size_ = bb_max - bb_min;
131 std::vector<VertexHandle> vhandle(8);
132 vhandle[0] = _object->add_vertex(bb_min+Point(0.0,0.0,size_[2]));
133 vhandle[1] = _object->add_vertex(bb_min+Point(size_[0],0.0,size_[2]));
134 vhandle[2] = _object->add_vertex(bb_min+Point(size_[0],size_[1],size_[2]));
135 vhandle[3] = _object->add_vertex(bb_min+Point(0.0,size_[1],size_[2]));
136 vhandle[4] = _object->add_vertex(bb_min+Point(0.0,0.0,0.0));
137 vhandle[5] = _object->add_vertex(bb_min+Point(size_[0],0.0,0.0));
138 vhandle[6] = _object->add_vertex(bb_min+Point(size_[0],size_[1],0.0));
139 vhandle[7] = _object->add_vertex(bb_min+Point(0.0,size_[1],0.0));
143 std::vector<VertexHandle> face_vhandles;
145 face_vhandles.clear();
146 face_vhandles.push_back(vhandle[0]);
147 face_vhandles.push_back(vhandle[1]);
148 face_vhandles.push_back(vhandle[2]);
149 face_vhandles.push_back(vhandle[3]);
150 _object->add_face(face_vhandles);
152 face_vhandles.clear();
153 face_vhandles.push_back(vhandle[7]);
154 face_vhandles.push_back(vhandle[6]);
155 face_vhandles.push_back(vhandle[5]);
156 face_vhandles.push_back(vhandle[4]);
157 _object->add_face(face_vhandles);
159 face_vhandles.clear();
160 face_vhandles.push_back(vhandle[1]);
161 face_vhandles.push_back(vhandle[0]);
162 face_vhandles.push_back(vhandle[4]);
163 face_vhandles.push_back(vhandle[5]);
164 _object->add_face(face_vhandles);
166 face_vhandles.clear();
167 face_vhandles.push_back(vhandle[2]);
168 face_vhandles.push_back(vhandle[1]);
169 face_vhandles.push_back(vhandle[5]);
170 face_vhandles.push_back(vhandle[6]);
171 _object->add_face(face_vhandles);
173 face_vhandles.clear();
174 face_vhandles.push_back(vhandle[3]);
175 face_vhandles.push_back(vhandle[2]);
176 face_vhandles.push_back(vhandle[6]);
177 face_vhandles.push_back(vhandle[7]);
178 _object->add_face(face_vhandles);
180 face_vhandles.clear();
181 face_vhandles.push_back(vhandle[0]);
182 face_vhandles.push_back(vhandle[3]);
183 face_vhandles.push_back(vhandle[7]);
184 face_vhandles.push_back(vhandle[4]);
185 _object->add_face(face_vhandles);
198 template<
class BSPTraits>
199 std::ostream &operator<< (std::ostream &stream, const TreeNode<BSPTraits> &node) {
200 stream <<
"[TreeNode instance. Handles: ";
202 it != it_end; ++it) {
204 if (it < it_end-1) stream <<
", ";
206 stream <<
", parent: " << node.parent_ <<
", left_child_: " << node.left_child_
207 <<
", right_child_: " << node.right_child_ <<
", plane_: <not implemented>, bb_min: " 208 << node.bb_min <<
", bb_max: " << node.bb_max <<
", size(): " << node.size() <<
"]";
213 #endif // MB_BSPTREENODE_HH defined
void visualizeTree(MeshT *_object, int _max_depth)
This visualizes the bounding boxes.