59 #ifndef MB_BSPTREENODE_HH
60 #define MB_BSPTREENODE_HH
64 #include <ACG/Geometry/Types/PlaneT.hh>
65 #include <ACG/Geometry/Algorithms.hh>
74 typedef typename Mesh::FaceHandle Handle;
77 typedef std::vector<Handle> Handles;
78 typedef typename Handles::iterator HandleIter;
79 typedef typename Point::value_type Scalar;
84 parent_(_parent), left_child_(0), right_child_(0) {}
92 if (
this == parent_->left_child_)
93 parent_->left_child_ = 0;
95 parent_->right_child_ = 0;
100 return handles_.begin();
103 return handles_.end();
106 size_t size()
const {
107 return handles_.size();
111 TreeNode *parent_, *left_child_, *right_child_;
113 Point bb_min, bb_max;
116 template<
typename MeshT >
119 if (_max_depth > 0 && (left_child_ || right_child_) )
128 Point size_ = bb_max - bb_min;
130 std::vector<VertexHandle> vhandle(8);
131 vhandle[0] = _object->add_vertex(bb_min+Point(0.0,0.0,size_[2]));
132 vhandle[1] = _object->add_vertex(bb_min+Point(size_[0],0.0,size_[2]));
133 vhandle[2] = _object->add_vertex(bb_min+Point(size_[0],size_[1],size_[2]));
134 vhandle[3] = _object->add_vertex(bb_min+Point(0.0,size_[1],size_[2]));
135 vhandle[4] = _object->add_vertex(bb_min+Point(0.0,0.0,0.0));
136 vhandle[5] = _object->add_vertex(bb_min+Point(size_[0],0.0,0.0));
137 vhandle[6] = _object->add_vertex(bb_min+Point(size_[0],size_[1],0.0));
138 vhandle[7] = _object->add_vertex(bb_min+Point(0.0,size_[1],0.0));
142 std::vector<VertexHandle> face_vhandles;
144 face_vhandles.clear();
145 face_vhandles.push_back(vhandle[0]);
146 face_vhandles.push_back(vhandle[1]);
147 face_vhandles.push_back(vhandle[2]);
148 face_vhandles.push_back(vhandle[3]);
149 _object->add_face(face_vhandles);
151 face_vhandles.clear();
152 face_vhandles.push_back(vhandle[7]);
153 face_vhandles.push_back(vhandle[6]);
154 face_vhandles.push_back(vhandle[5]);
155 face_vhandles.push_back(vhandle[4]);
156 _object->add_face(face_vhandles);
158 face_vhandles.clear();
159 face_vhandles.push_back(vhandle[1]);
160 face_vhandles.push_back(vhandle[0]);
161 face_vhandles.push_back(vhandle[4]);
162 face_vhandles.push_back(vhandle[5]);
163 _object->add_face(face_vhandles);
165 face_vhandles.clear();
166 face_vhandles.push_back(vhandle[2]);
167 face_vhandles.push_back(vhandle[1]);
168 face_vhandles.push_back(vhandle[5]);
169 face_vhandles.push_back(vhandle[6]);
170 _object->add_face(face_vhandles);
172 face_vhandles.clear();
173 face_vhandles.push_back(vhandle[3]);
174 face_vhandles.push_back(vhandle[2]);
175 face_vhandles.push_back(vhandle[6]);
176 face_vhandles.push_back(vhandle[7]);
177 _object->add_face(face_vhandles);
179 face_vhandles.clear();
180 face_vhandles.push_back(vhandle[0]);
181 face_vhandles.push_back(vhandle[3]);
182 face_vhandles.push_back(vhandle[7]);
183 face_vhandles.push_back(vhandle[4]);
184 _object->add_face(face_vhandles);
198 std::ostream &operator<< (std::ostream &stream, const TreeNode<Mesh> &node) {
199 stream <<
"[TreeNode instance. Handles: ";
200 for (
typename std::vector<
typename TreeNode<Mesh>::Handle>::const_iterator it = node.handles_.begin(), it_end = node.handles_.end();
201 it != it_end; ++it) {
203 if (it < it_end-1) stream <<
", ";
205 stream <<
", parent: " << node.parent_ <<
", left_child_: " << node.left_child_
206 <<
", right_child_: " << node.right_child_ <<
", plane_: <not implemented>, bb_min: "
207 << node.bb_min <<
", bb_max: " << node.bb_max <<
", size(): " << node.size() <<
"]";
212 #endif // MB_BSPTREENODE_HH defined
Kernel::Point Point
Coordinate type.
void visualizeTree(MeshT *_object, int _max_depth)
This visualizes the bounding boxes.
Kernel::VertexHandle VertexHandle
Handle for referencing the corresponding item.