THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/09/2009 at 06:33, xxxxxxxx wrote:
Ok, I tried to confirm this. I am not sure if the problem is really in the node. Here is the code of a simple node that writes out geometry of a polygon object. It seems to work fine without any crashes. Maybe this helps.
> \> #include "c4d.h" \> #include "c4d_operatordata.h" \> \> #include "print_node.h" \> \> \> class PrintNode : public GvOperatorData \> { \> INSTANCEOF(PrintNode,GvOperatorData) \> \> private: \> BaseList2D \*result; \> GvValue \*v1; \> \> public: \> virtual Bool Init(GeListNode \*node); \> \> virtual const String GetDetailedText(GvNode \*bn); \> virtual const String GetText(GvNode \*bn); \> \> virtual Bool iCreateOperator(GvNode \*bn); \> \> virtual Bool AddToCalculationTable(GvNode \*bn, GvRun \*r); \> \> virtual Bool InitCalculation(GvNode \*bn, GvCalc \*c, GvRun \*r); \> virtual void FreeCalculation(GvNode \*bn, GvCalc \*c); \> virtual Bool Calculate(GvNode \*bn, GvPort \*port, GvRun \*r, GvCalc \*c); \> \> static NodeData\* Alloc(void) { return gNew PrintNode; } \> }; \> \> Bool PrintNode::Init(GeListNode \*node) \> { \> result = NULL; \> return TRUE; \> } \> \> Bool PrintNode::iCreateOperator(GvNode \*bn) \> { \> bn->SetShowPortNamesState(FALSE); \> BaseContainer \*bc = bn->GetOpContainerInstance(); if (!bc) return FALSE; \> return SUPER::iCreateOperator(bn); \> } \> \> const String PrintNode::GetDetailedText(GvNode \*bn) \> { \> return GvGetOperatorDetailedText(this,bn); \> } \> \> const String PrintNode::GetText(GvNode \*bn) \> { \> if (result) \> return result->GetName(); \> \> return "NULL"; \> } \> \> Bool PrintNode::AddToCalculationTable(GvNode \*bn, GvRun \*r) \> { \> return r->AddNodeToCalculationTable(bn); \> } \> \> Bool PrintNode::InitCalculation(GvNode \*bn, GvCalc \*c, GvRun \*r) \> { \> v1 = bn->AllocCalculationHandler(PRINT_NODE_INPUT,c,r,0); if (!v1) return FALSE; \> return TRUE; \> } \> \> void PrintNode::FreeCalculation(GvNode \*bn, GvCalc \*c) \> { \> bn->FreeCalculationHandler(v1); \> } \> \> Bool PrintNode::Calculate(GvNode \*bn, GvPort \*port, GvRun \*r, GvCalc \*c) \> { \> if (!v1->Calculate(bn,GV_PORT_INPUT,r,c)) return FALSE; \> \> LONG index; \> if (!v1->GetPort()->GetInstance(result, r, &index;)) return FALSE; \> \> if (result && c->document && result->GetType() == Opolygon) \> { \> AutoAlloc<BaseFile> file; \> if (!file) return FALSE; \> \> BaseTime time = c->document->GetTime(); \> Real fps = c->document->GetFps(); \> String frame = "c:\ est"+LongToString(time.GetFrame(fps)); \> Filename fn(frame); \> \> if (!file->Open(fn, GE_WRITE, FILE_IGNOREOPEN, GE_INTEL)) return FALSE; \> \> const Vector \*points = ToPoly(result)->GetPointR(); \> LONG pcnt = ToPoly(result)->GetPointCount(); \> \> for (LONG i=0; i<pcnt; i++) \> { \> if (!file->WriteVector(points[i])) return FALSE; \> } \> } \> \> return TRUE; \> } \> \> //////////////////////////////// \> \> #define GVPRINTNODE_ID 1010815 \> \> Bool RegisterPrintNode() \> { \> return GvRegisterOperatorPlugin(GVPRINTNODE_ID, "Print Node", 0, PrintNode::Alloc, "print_node", 0, ID_GV_OPCLASS_TYPE_GENERAL, ID_GV_OPGROUP_TYPE_GENERAL, 0, NULL); \> } \>
cheers,
Matthias