Fixed uninitialized normal
This commit is contained in:
@@ -37,144 +37,144 @@
|
|||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
|
||||||
* *
|
* *
|
||||||
* ========================================================================= */
|
* ========================================================================= */
|
||||||
|
|
||||||
/*===========================================================================*\
|
/*===========================================================================*\
|
||||||
* *
|
* *
|
||||||
* $Revision$ *
|
* $Revision$ *
|
||||||
* $Date$ *
|
* $Date$ *
|
||||||
* *
|
* *
|
||||||
\*===========================================================================*/
|
\*===========================================================================*/
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
//
|
//
|
||||||
// CLASS newClass - IMPLEMENTATION
|
// CLASS newClass - IMPLEMENTATION
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
|
|
||||||
//== INCLUDES =================================================================
|
//== INCLUDES =================================================================
|
||||||
|
|
||||||
#include <OpenMesh/Tools/VDPM/VHierarchy.hh>
|
#include <OpenMesh/Tools/VDPM/VHierarchy.hh>
|
||||||
|
|
||||||
|
|
||||||
//== NAMESPACES ===============================================================
|
//== NAMESPACES ===============================================================
|
||||||
|
|
||||||
namespace OpenMesh {
|
namespace OpenMesh {
|
||||||
namespace VDPM {
|
namespace VDPM {
|
||||||
|
|
||||||
//== IMPLEMENTATION ==========================================================
|
//== IMPLEMENTATION ==========================================================
|
||||||
|
|
||||||
|
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
VHierarchy() :
|
VHierarchy() :
|
||||||
n_roots_(0), tree_id_bits_(0)
|
n_roots_(0), tree_id_bits_(0)
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
set_num_roots(unsigned int _n_roots)
|
set_num_roots(unsigned int _n_roots)
|
||||||
{
|
{
|
||||||
n_roots_ = _n_roots;
|
n_roots_ = _n_roots;
|
||||||
|
|
||||||
tree_id_bits_ = 0;
|
tree_id_bits_ = 0;
|
||||||
while (n_roots_ > ((unsigned int) 0x00000001 << tree_id_bits_))
|
while (n_roots_ > ((unsigned int) 0x00000001 << tree_id_bits_))
|
||||||
++tree_id_bits_;
|
++tree_id_bits_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VHierarchyNodeHandle
|
VHierarchyNodeHandle
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
add_node()
|
add_node()
|
||||||
{
|
{
|
||||||
return add_node(VHierarchyNode());
|
return add_node(VHierarchyNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
VHierarchyNodeHandle
|
VHierarchyNodeHandle
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
add_node(const VHierarchyNode &_node)
|
add_node(const VHierarchyNode &_node)
|
||||||
{
|
{
|
||||||
nodes_.push_back(_node);
|
nodes_.push_back(_node);
|
||||||
|
|
||||||
return VHierarchyNodeHandle(int(nodes_.size() - 1));
|
return VHierarchyNodeHandle(int(nodes_.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
make_children(VHierarchyNodeHandle &_parent_handle)
|
make_children(VHierarchyNodeHandle &_parent_handle)
|
||||||
{
|
{
|
||||||
VHierarchyNodeHandle lchild_handle = add_node();
|
VHierarchyNodeHandle lchild_handle = add_node();
|
||||||
VHierarchyNodeHandle rchild_handle = add_node();
|
VHierarchyNodeHandle rchild_handle = add_node();
|
||||||
|
|
||||||
VHierarchyNode &parent = node(_parent_handle);
|
VHierarchyNode &parent = node(_parent_handle);
|
||||||
VHierarchyNode &lchild = node(lchild_handle);
|
VHierarchyNode &lchild = node(lchild_handle);
|
||||||
VHierarchyNode &rchild = node(rchild_handle);
|
VHierarchyNode &rchild = node(rchild_handle);
|
||||||
|
|
||||||
parent.set_children_handle(lchild_handle);
|
parent.set_children_handle(lchild_handle);
|
||||||
lchild.set_parent_handle(_parent_handle);
|
lchild.set_parent_handle(_parent_handle);
|
||||||
rchild.set_parent_handle(_parent_handle);
|
rchild.set_parent_handle(_parent_handle);
|
||||||
|
|
||||||
lchild.set_index(VHierarchyNodeIndex(parent.node_index().tree_id(tree_id_bits_), 2*parent.node_index().node_id(tree_id_bits_), tree_id_bits_));
|
lchild.set_index(VHierarchyNodeIndex(parent.node_index().tree_id(tree_id_bits_), 2*parent.node_index().node_id(tree_id_bits_), tree_id_bits_));
|
||||||
rchild.set_index(VHierarchyNodeIndex(parent.node_index().tree_id(tree_id_bits_), 2*parent.node_index().node_id(tree_id_bits_)+1, tree_id_bits_));
|
rchild.set_index(VHierarchyNodeIndex(parent.node_index().tree_id(tree_id_bits_), 2*parent.node_index().node_id(tree_id_bits_)+1, tree_id_bits_));
|
||||||
}
|
}
|
||||||
|
|
||||||
VHierarchyNodeHandle
|
VHierarchyNodeHandle
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
node_handle(VHierarchyNodeIndex _node_index)
|
node_handle(VHierarchyNodeIndex _node_index)
|
||||||
{
|
{
|
||||||
if (_node_index.is_valid(tree_id_bits_) != true)
|
if (_node_index.is_valid(tree_id_bits_) != true)
|
||||||
return InvalidVHierarchyNodeHandle;
|
return InvalidVHierarchyNodeHandle;
|
||||||
|
|
||||||
VHierarchyNodeHandle node_handle = root_handle(_node_index.tree_id(tree_id_bits_));
|
VHierarchyNodeHandle node_handle = root_handle(_node_index.tree_id(tree_id_bits_));
|
||||||
unsigned int node_id = _node_index.node_id(tree_id_bits_);
|
unsigned int node_id = _node_index.node_id(tree_id_bits_);
|
||||||
unsigned int flag = 0x80000000;
|
unsigned int flag = 0x80000000;
|
||||||
|
|
||||||
while (!(node_id & flag)) flag >>= 1;
|
while (!(node_id & flag)) flag >>= 1;
|
||||||
flag >>= 1;
|
flag >>= 1;
|
||||||
|
|
||||||
while (flag > 0 && is_leaf_node(node_handle) != true)
|
while (flag > 0 && is_leaf_node(node_handle) != true)
|
||||||
{
|
{
|
||||||
if (node_id & flag) // 1: rchild
|
if (node_id & flag) // 1: rchild
|
||||||
{
|
{
|
||||||
node_handle = rchild_handle(node_handle);
|
node_handle = rchild_handle(node_handle);
|
||||||
}
|
}
|
||||||
else // 0: lchild
|
else // 0: lchild
|
||||||
{
|
{
|
||||||
node_handle = lchild_handle(node_handle);
|
node_handle = lchild_handle(node_handle);
|
||||||
}
|
}
|
||||||
flag >>= 1;
|
flag >>= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return node_handle;
|
return node_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
VHierarchy::
|
VHierarchy::
|
||||||
is_ancestor(VHierarchyNodeIndex _ancestor_index, VHierarchyNodeIndex _descendent_index)
|
is_ancestor(VHierarchyNodeIndex _ancestor_index, VHierarchyNodeIndex _descendent_index)
|
||||||
{
|
{
|
||||||
if (_ancestor_index.tree_id(tree_id_bits_) != _descendent_index.tree_id(tree_id_bits_))
|
if (_ancestor_index.tree_id(tree_id_bits_) != _descendent_index.tree_id(tree_id_bits_))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
unsigned int ancestor_node_id = _ancestor_index.node_id(tree_id_bits_);
|
unsigned int ancestor_node_id = _ancestor_index.node_id(tree_id_bits_);
|
||||||
unsigned int descendent_node_id = _descendent_index.node_id(tree_id_bits_);
|
unsigned int descendent_node_id = _descendent_index.node_id(tree_id_bits_);
|
||||||
|
|
||||||
if (ancestor_node_id > descendent_node_id)
|
if (ancestor_node_id > descendent_node_id)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while (descendent_node_id > 0)
|
while (descendent_node_id > 0)
|
||||||
{
|
{
|
||||||
if (ancestor_node_id == descendent_node_id)
|
if (ancestor_node_id == descendent_node_id)
|
||||||
return true;
|
return true;
|
||||||
descendent_node_id >>= 1; // descendent_node_id /= 2
|
descendent_node_id >>= 1; // descendent_node_id /= 2
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
} // namespace VDPM
|
} // namespace VDPM
|
||||||
} // namespace OpenMesh
|
} // namespace OpenMesh
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class VHierarchyNode
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
VHierarchyNode() :radius_(0.0f), sin_square_(0.0f),mue_square_(0.0f), sigma_square_(0.0f) { }
|
VHierarchyNode() :radius_(0.0f), normal_(0.0f), sin_square_(0.0f),mue_square_(0.0f), sigma_square_(0.0f) { }
|
||||||
|
|
||||||
/// Returns true, if node is root else false.
|
/// Returns true, if node is root else false.
|
||||||
bool is_root() const
|
bool is_root() const
|
||||||
|
|||||||
Reference in New Issue
Block a user