Jump to content

POP_BlindData proper useage


Guest xionmark

Recommended Posts

Guest xionmark

And now without the blind data member var in the POP declaration; I think this is the way it's intended to be used. Just have to figure out the duplicate() method.

See attached.

Link to comment
Share on other sites

Guest xionmark

Hi Mike,

Can't seem to get the duplicate() method to get called. I've attached the current code and a hip file that has 3 pop networks. The subsampling, preroll, etc. does what's expected, but I never seem to see the duplicate() method.

Anyway, here's the salient parts of the code that does work well (so far):

class MyBlindData : public POP_BlindData
{
    public:
    int     anInt;
    float   aFloat;
    float   aFloatArray[5];

    MyBlindData(POP_Node *node) : POP_BlindData(node) {
        cout << "MyBlindData constructor called" << endl;
        anInt = 0;
        aFloat = 0.0f;
        aFloatArray[0] = 0.0;
        aFloatArray[1] = 0.0;
        aFloatArray[2] = 0.0;
        aFloatArray[3] = 0.0;
        aFloatArray[4] = 0.0;
    }
    virtual ~MyBlindData() {}

    POP_BlindData *duplicate(const POP_ContextData *src);
    int resetSimulation();
};

int MyBlindData::resetSimulation(){

    cout << "MyBlindData::resetSimulation() called" << endl;
    anInt = 0;
    aFloat = 0.0f;
    aFloatArray[0] = 0.0;
    aFloatArray[1] = 0.0;
    aFloatArray[2] = 0.0;
    aFloatArray[3] = 0.0;
    aFloatArray[4] = 0.0;

 return 0;
}


POP_BlindData * MyBlindData::duplicate(const POP_ContextData *src) {
    cout << "MyBlindData::duplicate() called " << endl;

//     POP_ContextData *_tmpPopContext;
//     _tmpPopContext->copyFrom(*src);

    MyBlindData *myTmpBlindData;
    myTmpBlindData = (MyBlindData*)src->getBlindData(this->getOwner());

    if (!myTmpBlindData)  {
        myTmpBlindData = new MyBlindData(this->getOwner());
        myTmpBlindData->anInt = 200;
        myTmpBlindData->aFloat = 200.23f;
        myTmpBlindData->aFloatArray[0] = 200.1;
        myTmpBlindData->aFloatArray[1] = 200.2;
        myTmpBlindData->aFloatArray[2] = 200.3;
        myTmpBlindData->aFloatArray[3] = 200.4;
        myTmpBlindData->aFloatArray[4] = 200.5;
/*        if(!src->addBlindData((POP_BlindData *)myTmpBlindData))
            cout << "MyBlindData::duplicate() - adding blind data FAILED" << endl;
        else
            cout << "MyBlindData::duplicate() - added blind data " << endl;*/
    }

    return (POP_BlindData *)this;
};

   MyBlindData *myTmpBlindData;
    myTmpBlindData = (MyBlindData*)data->getBlindData(this);

    if (!myTmpBlindData)  {
        myTmpBlindData = new MyBlindData(this);
        myTmpBlindData->anInt = 1;
        myTmpBlindData->aFloat = radius;
        myTmpBlindData->aFloatArray[0] = radius;
        myTmpBlindData->aFloatArray[1] = radius;
        myTmpBlindData->aFloatArray[2] = radius;
        myTmpBlindData->aFloatArray[3] = radius;
        myTmpBlindData->aFloatArray[4] = radius;
        if(!data->addBlindData((POP_BlindData *)myTmpBlindData))
            cout << "Adding blind data FAILED" << endl;
        else
            cout << "Added blind data " << endl;
    }
    else {
        myTmpBlindData->anInt += 1;
        myTmpBlindData->aFloat += radius;
        cout << "Blind data: anInt " << myTmpBlindData->anInt << endl;
        cout << "Blind data: aFloat " << myTmpBlindData->aFloat << endl;
        for(int i =0; i < 5; ++i){
            myTmpBlindData->aFloatArray[i] += radius;
            cout << "Blind data: aFloatArray[" << i << "] = " << myTmpBlindData->aFloatArray[i] << endl;
        }
    }
    cout << endl;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...