HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROP/ROP_Dumper.C
/*
* Copyright (c) 2018
* Side Effects Software Inc. All rights reserved.
*
* Redistribution and use of Houdini Development Kit samples in source and
* binary forms, with or without modification, are permitted provided that the
* following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. The name of Side Effects Software may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "ROP_Dumper.h"
#include <ROP/ROP_Error.h>
#include <SOP/SOP_Node.h>
#include <OP/OP_Director.h>
#include <UT/UT_OFStream.h>
using namespace HDK_Sample;
int *ROP_Dumper::ifdIndirect = 0;
static PRM_Name theFileName("file", "Save to file");
static PRM_Default theFileDefault(0, "junk.out");
static PRM_Template *
getTemplates()
{
static PRM_Template *theTemplate = 0;
if (theTemplate)
return theTemplate;
theTemplate = new PRM_Template[14];
theTemplate[0] = PRM_Template(PRM_FILE, 1, &theFileName, &theFileDefault);
theTemplate[13] = PRM_Template();
return theTemplate;
}
{
static OP_TemplatePair *ropPair = 0;
if (!ropPair)
{
base = new OP_TemplatePair(getTemplates());
}
return ropPair;
}
{
static OP_VariablePair *pair = 0;
if (!pair)
return pair;
}
{
return new ROP_Dumper(net, name, op);
}
: ROP_Node(net, name, entry)
{
if (!ifdIndirect)
ifdIndirect = allocIndirect(16);
}
ROP_Dumper::~ROP_Dumper()
{
}
//------------------------------------------------------------------------------
// The startRender(), renderFrame(), and endRender() render methods are
// invoked by Houdini when the ROP runs.
int
ROP_Dumper::startRender(int /*nframes*/, fpreal tstart, fpreal tend)
{
myEndTime = tend;
return 1;
}
static void
printNode(std::ostream &os, OP_Node *node, int indent)
{
wbuf.sprintf("%*s", indent, "");
os << wbuf.buffer() << node->getName() << "\n";
for (int i=0; i<node->getNchildren(); ++i)
printNode(os, node->getChild(i), indent+2);
}
{
// Execute the pre-render script.
// Evaluate the parameter for the file name and write something to the
// file.
UT_String file_name;
OUTPUT(file_name, time);
UT_OFStream os(file_name);
printNode(os, OPgetDirector(), 0);
os.close();
// Execute the post-render script.
}
{
}
void
{
table->addOperator(new OP_Operator("hdk_dumper",
"Dump Tree",
0,
0,
}