50 #define TRIANGLEBSPCORET_C 55 #include "TriangleBSPCoreT.hh" 60 template <
class BSPTraits>
63 build(
unsigned int _max_handles,
unsigned int _max_depth)
67 root_ =
new Node(handles_, 0);
73 traits_.calculateBoundingBoxRoot (root_);
75 _build(root_, _max_handles, _max_depth);
83 template <
class BSPTraits>
87 unsigned int _max_handles,
91 if ((_depth == 0) || ((_node->end()-_node->begin()) <= (
int)_max_handles))
97 traits_.calculateBoundingBox (_node, median, axis);
100 const Point XYZ[3] = { Point(1,0,0), Point(0,1,0), Point(0,0,1) };
101 _node->plane_ =
Plane(median, XYZ[axis]);
104 Handles lhandles, rhandles;
105 lhandles.reserve(_node->handles_.size()/2);
106 rhandles.reserve(_node->handles_.size()/2);
110 for (it=_node->begin(); it!=_node->end(); ++it)
112 traits_.points(*it, p0, p1, p2);
127 if ( _node->plane_(p0) || _node->plane_(p1) || _node->plane_(p2) ) lhandles.push_back(*it);
128 if ( !_node->plane_(p0) || !_node->plane_(p1) || !_node->plane_(p2) ) rhandles.push_back(*it);
133 if (lhandles.size() == _node->handles_.size() ||
134 rhandles.size() == _node->handles_.size())
137 _node->handles_ = Handles();
141 _node->left_child_ =
new Node(lhandles, _node); lhandles = Handles();
142 _node->right_child_ =
new Node(rhandles, _node); rhandles = Handles();
155 _node->right_child_->bb_min = _node->bb_min;
156 _node->right_child_->bb_max = _node->bb_max;
157 _node->right_child_->bb_max[axis] = median [axis];
159 _node->left_child_->bb_min = _node->bb_min;
160 _node->left_child_->bb_min[axis] = median [axis];
161 _node->left_child_->bb_max = _node->bb_max;
164 _build(_node->left_child_, _max_handles, _depth-1);
165 _build(_node->right_child_, _max_handles, _depth-1);
void build(unsigned int _max_handles, unsigned int _max_depth)