53 #include <OpenMesh/Tools/VDPM/VHierarchyWindow.hh> 59 #if defined(__MINGW32__) 76 vhierarchy_(nullptr), buffer_(nullptr),buffer_min_ (0), buffer_max_(0), current_pos_(0) , window_min_(0), window_max_(0), n_shift_(0)
83 VHierarchyWindow(VHierarchy &_vhierarchy) :
84 vhierarchy_(&_vhierarchy),buffer_(nullptr),buffer_min_ (0), buffer_max_(0), current_pos_(0) , window_min_(0), window_max_(0) ,n_shift_(0)
90 ~VHierarchyWindow(
void)
92 if (buffer_ !=
nullptr)
99 update_buffer(VHierarchyNodeHandle _node_handle)
101 if (underflow(_node_handle) !=
true && overflow(_node_handle) !=
true)
106 for (none_zero_pos=
int(buffer_size()-1); none_zero_pos >= 0; --none_zero_pos)
108 if (buffer_[none_zero_pos] != 0)
break;
110 window_max_ = buffer_min_ + none_zero_pos + 1;
111 for(none_zero_pos=0; none_zero_pos < int(buffer_size()); ++none_zero_pos)
113 if (buffer_[none_zero_pos] != 0)
break;
115 window_min_ = buffer_min_ + none_zero_pos;
117 assert(window_min_ < window_max_);
119 while (underflow(_node_handle) ==
true) buffer_min_ /= 2;
120 while (overflow(_node_handle) ==
true)
123 if (buffer_max_ > vhierarchy_->num_nodes() / 8)
124 buffer_max_ = 1 + vhierarchy_->num_nodes() / 8;
127 unsigned char *new_buffer = (
unsigned char *) malloc(buffer_size());
128 memset(new_buffer, 0, buffer_size());
129 memcpy(&(new_buffer[window_min_-buffer_min_]),
130 &(buffer_[none_zero_pos]),
133 buffer_ = new_buffer;
141 if (buffer_ !=
nullptr)
145 buffer_max_ = _roots.size() / 8;
146 if (_roots.size() % 8 > 0)
149 buffer_ = (
unsigned char *) malloc(buffer_size());
150 memset(buffer_, 0, buffer_size());
157 for (
unsigned int i=0; i<_roots.size(); i++)
159 activate(VHierarchyNodeHandle((
int) i));
166 update_with_vsplit(VHierarchyNodeHandle _parent_handle)
169 lchild_handle = vhierarchy_->lchild_handle(_parent_handle),
170 rchild_handle = vhierarchy_->rchild_handle(_parent_handle);
172 assert(is_active(_parent_handle) ==
true);
173 assert(is_active(lchild_handle) !=
true);
174 assert(is_active(rchild_handle) !=
true);
176 inactivate(_parent_handle);
177 activate(rchild_handle);
178 activate(lchild_handle);
183 update_with_ecol(VHierarchyNodeHandle _parent_handle)
186 lchild_handle = vhierarchy_->lchild_handle(_parent_handle),
187 rchild_handle = vhierarchy_->rchild_handle(_parent_handle);
189 assert(is_active(_parent_handle) !=
true);
190 assert(is_active(lchild_handle) ==
true);
191 assert(is_active(rchild_handle) ==
true);
193 activate(_parent_handle);
194 inactivate(rchild_handle);
195 inactivate(lchild_handle);
std::vector< VHierarchyNodeHandle > VHierarchyNodeHandleContainer
Container for vertex hierarchy node handles.