00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <UT/UT_CPIO.h>
00032
00033 #include <UT/UT_DSOVersion.h>
00034 #include <GU/GU_Detail.h>
00035 #include <PRM/PRM_Include.h>
00036 #include <OP/OP_Operator.h>
00037 #include <OP/OP_OperatorTable.h>
00038 #include <OP/OP_SaveFlags.h>
00039 #include "SOP_BlindData.h"
00040
00041 using namespace HDK_Sample;
00042
00043 void
00044 newSopOperator(OP_OperatorTable *table)
00045 {
00046 table->addOperator(new OP_Operator("hdk_blinddata",
00047 "BlindData",
00048 SOP_BlindData::myConstructor,
00049 SOP_BlindData::myTemplateList,
00050 1,
00051 1,
00052 0));
00053 }
00054
00055 PRM_Template
00056 SOP_BlindData::myTemplateList[] = {
00057 PRM_Template(),
00058 };
00059
00060
00061 OP_Node *
00062 SOP_BlindData::myConstructor(OP_Network *net, const char *name, OP_Operator *op)
00063 {
00064 return new SOP_BlindData(net, name, op);
00065 }
00066
00067 SOP_BlindData::SOP_BlindData(OP_Network *net, const char *name, OP_Operator *op)
00068 : SOP_Node(net, name, op)
00069 {
00070 }
00071
00072 SOP_BlindData::~SOP_BlindData() {}
00073
00074 OP_ERROR
00075 SOP_BlindData::cookMySop(OP_Context &context)
00076 {
00077
00078
00079 if (lockInputs(context) >= UT_ERROR_ABORT)
00080 return error();
00081
00082 duplicateSource(0, context);
00083
00084 unlockInputs();
00085 return error();
00086 }
00087
00088 const char *
00089 SOP_BlindData::inputLabel(unsigned) const
00090 {
00091 return "Source Geometry";
00092 }
00093
00094 static const char *theExtension = "mydata";
00095
00096 OP_ERROR
00097 SOP_BlindData::save(ostream &os, const OP_SaveFlags &flags,
00098 const char *path_prefix)
00099 {
00100 UT_CPIO packet;
00101 char path[UT_SMALLBUF];
00102
00103 clearErrors();
00104
00105
00106 if (SOP_Node::save(os, flags, path_prefix) >= UT_ERROR_ABORT)
00107 return error();
00108
00109 ostrstream ts(path, UT_SMALLBUF); ts << path_prefix << getName() << "."
00110 << theExtension << ends;
00111 packet.open(os, path);
00112 savePrivateData(os, flags.getBinary());
00113 packet.close(os);
00114
00115 return error();
00116 }
00117
00118 bool
00119 SOP_BlindData::load(UT_IStream &is, const char *extension, const char *path)
00120 {
00121 if (!strcmp(extension, theExtension))
00122 {
00123
00124 loadPrivateData(is);
00125 return error();
00126 }
00127 return SOP_Node::load(is, extension, path);
00128 }
00129
00130 int
00131 SOP_BlindData::loadPrivateData(UT_IStream &is)
00132 {
00133 UT_String data;
00134 bool result;
00135
00136 result = data.load(is);
00137 return !result ? 0 : 1;
00138 }
00139
00140 int
00141 SOP_BlindData::savePrivateData(ostream &os, int binary)
00142 {
00143 UT_String data;
00144
00145 data = "This is my private data";
00146 data.save(os, binary);
00147 return !os ? 0 : 1;
00148 }