1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkHyperTreeGridEntry.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkHyperTreeGridEntry.h"
#include "vtkBitArray.h"
#include "vtkHyperTree.h"
#include "vtkHyperTreeGrid.h"
#include <cassert>
//-----------------------------------------------------------------------------
void vtkHyperTreeGridEntry::PrintSelf(ostream& os, vtkIndent indent)
{
os << indent << "--vtkHyperTreeGridEntry--" << endl;
os << indent << "Index:" << this->Index << endl;
}
//-----------------------------------------------------------------------------
void vtkHyperTreeGridEntry::Dump(ostream& os)
{
os << "Index:" << this->Index << endl;
}
//-----------------------------------------------------------------------------
vtkHyperTree* vtkHyperTreeGridEntry::Initialize(
vtkHyperTreeGrid* grid, vtkIdType treeIndex, bool create)
{
assert(grid != nullptr);
this->Index = 0;
return grid->GetTree(treeIndex, create);
}
//-----------------------------------------------------------------------------
vtkIdType vtkHyperTreeGridEntry::GetGlobalNodeIndex(const vtkHyperTree* tree) const
{
assert("pre: not_tree" && tree);
return tree->GetGlobalIndexFromLocal(this->Index);
}
//-----------------------------------------------------------------------------
void vtkHyperTreeGridEntry::SetGlobalIndexStart(vtkHyperTree* tree, vtkIdType index)
{
assert("pre: not_tree" && tree);
tree->SetGlobalIndexStart(index);
}
//-----------------------------------------------------------------------------
void vtkHyperTreeGridEntry::SetGlobalIndexFromLocal(vtkHyperTree* tree, vtkIdType index)
{
assert("pre: not_tree" && tree);
tree->SetGlobalIndexFromLocal(this->Index, index);
}
//-----------------------------------------------------------------------------
void vtkHyperTreeGridEntry::SetMask(
const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, bool value)
{
assert("pre: not_tree" && tree);
const_cast<vtkHyperTreeGrid*>(grid)->GetMask()->InsertTuple1(
this->GetGlobalNodeIndex(tree), value);
}
//-----------------------------------------------------------------------------
bool vtkHyperTreeGridEntry::IsMasked(const vtkHyperTreeGrid* grid, const vtkHyperTree* tree) const
{
if (tree && const_cast<vtkHyperTreeGrid*>(grid)->HasMask())
{
return const_cast<vtkHyperTreeGrid*>(grid)->GetMask()->GetValue(
this->GetGlobalNodeIndex(tree)) != 0;
}
return false;
}
//-----------------------------------------------------------------------------
bool vtkHyperTreeGridEntry::IsLeaf(
const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level) const
{
assert("pre: not_tree" && tree);
if (level == const_cast<vtkHyperTreeGrid*>(grid)->GetDepthLimiter())
{
return true;
}
return tree->IsLeaf(this->Index);
}
//---------------------------------------------------------------------------
void vtkHyperTreeGridEntry::SubdivideLeaf(
const vtkHyperTreeGrid* grid, vtkHyperTree* tree, unsigned int level)
{
assert("pre: not_tree" && tree);
// JB Comment faire pour definir un accesseur a DepthLimiter qui est const
assert("pre: depth_limiter" && level <= const_cast<vtkHyperTreeGrid*>(grid)->GetDepthLimiter());
assert("pre: is_masked" && !this->IsMasked(grid, tree));
if (this->IsLeaf(grid, tree, level))
{
tree->SubdivideLeaf(this->Index, level);
}
}
//---------------------------------------------------------------------------
bool vtkHyperTreeGridEntry::IsTerminalNode(
const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level) const
{
(void)level; // remove warning for release build
assert("pre: not_tree" && tree);
bool result = !this->IsLeaf(grid, tree, level);
if (result)
{
result = tree->IsTerminalNode(this->Index);
}
assert("post: compatible" && (!result || !this->IsLeaf(grid, tree, level)));
return result;
}
//-----------------------------------------------------------------------------
void vtkHyperTreeGridEntry::ToChild(
const vtkHyperTreeGrid* grid, const vtkHyperTree* tree, unsigned int level, unsigned char ichild)
{
(void)grid; // only used in assert
(void)level; // only used in assert
assert("pre: not_tree" && tree);
assert("pre: not_leaf" && !this->IsLeaf(grid, tree, level));
assert("pre: not_valid_child" && ichild < tree->GetNumberOfChildren());
// JB Comment faire pour definir un accesseur a DepthLimiter qui est const
assert("pre: depth_limiter" && level <= const_cast<vtkHyperTreeGrid*>(grid)->GetDepthLimiter());
assert("pre: is_masked" && !IsMasked(grid, tree));
this->Index = tree->GetElderChildIndex(this->Index) + ichild;
}
|