58 #include <OpenMesh/Tools/VDPM/VHierarchyWindow.hh>
64 #if defined(__MINGW32__)
81 vhierarchy_(NULL), buffer_(NULL),buffer_min_ (0), buffer_max_(0), current_pos_(0) , window_min_(0), window_max_(0), n_shift_(0)
88 VHierarchyWindow(VHierarchy &_vhierarchy) :
89 vhierarchy_(&_vhierarchy),buffer_(NULL),buffer_min_ (0), buffer_max_(0), current_pos_(0) , window_min_(0), window_max_(0) ,n_shift_(0)
95 ~VHierarchyWindow(
void)
104 update_buffer(VHierarchyNodeHandle _node_handle)
106 if (underflow(_node_handle) !=
true && overflow(_node_handle) !=
true)
111 for (none_zero_pos=
int(buffer_size()-1); none_zero_pos >= 0; --none_zero_pos)
113 if (buffer_[none_zero_pos] != 0)
break;
115 window_max_ = buffer_min_ + none_zero_pos + 1;
116 for(none_zero_pos=0; none_zero_pos < int(buffer_size()); ++none_zero_pos)
118 if (buffer_[none_zero_pos] != 0)
break;
120 window_min_ = buffer_min_ + none_zero_pos;
122 assert(window_min_ < window_max_);
124 while (underflow(_node_handle) ==
true) buffer_min_ /= 2;
125 while (overflow(_node_handle) ==
true)
128 if (buffer_max_ > vhierarchy_->num_nodes() / 8)
129 buffer_max_ = 1 + vhierarchy_->num_nodes() / 8;
132 unsigned char *new_buffer = (
unsigned char *) malloc(buffer_size());
133 memset(new_buffer, 0, buffer_size());
134 memcpy(&(new_buffer[window_min_-buffer_min_]),
135 &(buffer_[none_zero_pos]),
138 buffer_ = new_buffer;
144 VHierarchyWindow::init(VHierarchyNodeHandleContainer &_roots)
150 buffer_max_ = _roots.size() / 8;
151 if (_roots.size() % 8 > 0)
154 buffer_ = (
unsigned char *) malloc(buffer_size());
155 memset(buffer_, 0, buffer_size());
162 for (
unsigned int i=0; i<_roots.size(); i++)
164 activate(VHierarchyNodeHandle((
int) i));
171 update_with_vsplit(VHierarchyNodeHandle _parent_handle)
174 lchild_handle = vhierarchy_->lchild_handle(_parent_handle),
175 rchild_handle = vhierarchy_->rchild_handle(_parent_handle);
177 assert(is_active(_parent_handle) ==
true);
178 assert(is_active(lchild_handle) !=
true);
179 assert(is_active(rchild_handle) !=
true);
181 inactivate(_parent_handle);
182 activate(rchild_handle);
183 activate(lchild_handle);
188 update_with_ecol(VHierarchyNodeHandle _parent_handle)
191 lchild_handle = vhierarchy_->lchild_handle(_parent_handle),
192 rchild_handle = vhierarchy_->rchild_handle(_parent_handle);
194 assert(is_active(_parent_handle) !=
true);
195 assert(is_active(lchild_handle) ==
true);
196 assert(is_active(rchild_handle) ==
true);
198 activate(_parent_handle);
199 inactivate(rchild_handle);
200 inactivate(lchild_handle);