Skip to content

Instantly share code, notes, and snippets.

@hb3p8
Created Aug 27, 2014
Embed
What would you like to do?
// =======================================================================
// function : PrintPretty
// purpose :
// =======================================================================
void RayTraceGPU_Node::PrintPretty (std::string thePrefix, bool isLeft, int theLevel) const
{
if (IsLeaf())
{
thePrefix.erase(thePrefix.size() - 2, 2);
thePrefix += isLeft ? "|-" : "\xC0-";
std::cout << thePrefix;
const RayTraceGPU_PrimitiveNode* aNode =
static_cast<const RayTraceGPU_PrimitiveNode*> (this);
char buf[32];
_itoa((int)aNode, buf, 16);
std::cout << (aNode->IsComplement() ? "!" : " ") << aNode->TypeID() << std::endl;
}
else
{
const RayTraceGPU_OperationNode* aNode =
static_cast<const RayTraceGPU_OperationNode*> (this);
thePrefix.erase(thePrefix.size() - 2, 2);
thePrefix += isLeft ? "|-" : "\xC0-";
std::cout
<< thePrefix
<< (aNode->Operation() == RT_OP_INTER ? (aNode->IsComplement() ? " ~." : " . ") : (aNode->Operation() == RT_OP_UNION ? (aNode->IsComplement() ? " ~+" : " + ") : (aNode->IsComplement() ? " ~-" : " - ")))
<< "(" << aNode->Height() << ")"
<< std::endl;
thePrefix.erase(thePrefix.size() - 2, 2);
if (!isLeft)
{
thePrefix += " ";
}
else
{
thePrefix += "| ";
}
thePrefix += " | ";
{
aNode->Child<0>()->PrintPretty (thePrefix, true, theLevel + 1);
aNode->Child<1>()->PrintPretty (thePrefix, false, theLevel + 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment