59 #define TRIANGLEBSPCORET_C 64 #include "TriangleBSPCoreT.hh" 69 template <
class BSPTraits>
72 build(
unsigned int _max_handles,
unsigned int _max_depth)
76 root_ =
new Node(handles_, 0);
82 traits_.calculateBoundingBoxRoot (root_);
84 _build(root_, _max_handles, _max_depth);
92 template <
class BSPTraits>
96 unsigned int _max_handles,
100 if ((_depth == 0) || ((_node->end()-_node->begin()) <= (
int)_max_handles))
106 traits_.calculateBoundingBox (_node, median, axis);
109 const Point XYZ[3] = { Point(1,0,0), Point(0,1,0), Point(0,0,1) };
110 _node->plane_ =
Plane(median, XYZ[axis]);
113 Handles lhandles, rhandles;
114 lhandles.reserve(_node->handles_.size()/2);
115 rhandles.reserve(_node->handles_.size()/2);
119 for (it=_node->begin(); it!=_node->end(); ++it)
121 traits_.points(*it, p0, p1, p2);
136 if ( _node->plane_(p0) || _node->plane_(p1) || _node->plane_(p2) ) lhandles.push_back(*it);
137 if ( !_node->plane_(p0) || !_node->plane_(p1) || !_node->plane_(p2) ) rhandles.push_back(*it);
142 if (lhandles.size() == _node->handles_.size() ||
143 rhandles.size() == _node->handles_.size())
146 _node->handles_ = Handles();
150 _node->left_child_ =
new Node(lhandles, _node); lhandles = Handles();
151 _node->right_child_ =
new Node(rhandles, _node); rhandles = Handles();
164 _node->right_child_->bb_min = _node->bb_min;
165 _node->right_child_->bb_max = _node->bb_max;
166 _node->right_child_->bb_max[axis] = median [axis];
168 _node->left_child_->bb_min = _node->bb_min;
169 _node->left_child_->bb_min[axis] = median [axis];
170 _node->left_child_->bb_max = _node->bb_max;
173 _build(_node->left_child_, _max_handles, _depth-1);
174 _build(_node->right_child_, _max_handles, _depth-1);
void build(unsigned int _max_handles, unsigned int _max_depth)