Maya XGen API

How to get control vertex positions in Maya XGen Interactive

#include <XGen/XgSplineAPI.h>

XGenSplineAPI::XgFnSpline splines;
{
    MDagPath dagPath = NodeNameToDagPath(fromNodeName); // custom function
    MFnDagNode nodeFn(dagPath);

    MPlug outRenderDataPlg = nodeFn.findPlug("outRender Data");
    MObject outRenderDataObj = outRenderDataPlg.asMObject();
    MPxData* outRenderDataPtr = MFnPluginDaga(outRenderDataObj).data();

    std::stringstream bs;
    outRenderDataPtr->writeBinary(bs);
    std::string bd = bs.str();

    const unsigned int tail = bd.size() % sizeof(unsigned int);
    const unsigned int padding = (tail>0) ? sizeof(unsigned int) - tail : 0;
    const unsigned int nElements = bd.size() / sizeof(unsigned int) + (tail>0 ? 1 : 0);

   splines.load(bs, nElements, 0);
}

MPointArray cvs:
{
    XGenSplineAPI::XgItSpline itr = splines.iterator();
    for(; !itr.isDone(); itr.next())
    {
        const unsigned int nCurves = itr.primitiveCount();

        const unsigned int stride = itr.primitiveInfoStride();
        const unsigned int* primitiveInfos = itr.primitiveInfos();

        const SgVec3f* positions = itr.positions(0);

        for(unsigned int i=0; i<nCurves; ++i)
        {
            const unsigned int& offset = primitiveInfos[i * stride];
            const unsigned int& length = primitiveInfos[i * stride + 1];

            const unsigned int& nCVs = length;

            for(unsigned int j=0; j<nCVs; ++j)
            {
                const unsigned int index = offset + j;

                const float& x = positions[index][0];
                const float& y = positions[index][1];
                const float& z = positions[index][2];

                cvs.append(MPoint(x, y, z));
            }
        }
    }
}