Start a new topic

How to access the cable positions from C++?

Hi everyone,


I am testing the movement of the cable.

I know that I can get the size of a point's position with VortexStudio.

But I would like to get detailed positions of each point from C++.

Could you tell me the specific access procedure?

I am using Vortex Studio Editor 2018c.


Thank you.


The details about cable point locations are output by the Dynamics Generic Cable extension in the output field:

Outputs -> Cables -> Point Infos -> [cable number]. 


You can see this field in the Editor, but it can't actually display all the data. But if you access this field from C++, it is an array of data structures containing every point location and orientation. 


I don't have any sample code for this, but this should at least show you where to start. If that is not enough to get it to work, maybe another CM Labs support agent can provide sample code. 

Hi,


This is some code to access the PointInfo. This was working in an old version of Vortex. It could help you


C++ code to access the PointInfo

==================================

CableSystemDynamicPlugin* csdp = this;

VxSim::VxExtension* cableDynamics = csdp->getProxy();

VxData::Container& containerOutput = cableDynamics->getOutputContainer();

// Here you have to use the generic access on the container with the help of the DynamicssICD.h

VxData::FieldBase& fbCable = containerOutput[CableSystems::DynamicsICD::kCablesID];

 

VxData::Container& cables = dynamic_cast<VxData::Container&>(fbCable);

if ( cables.isValid() )

{

    int numCables = (*mCables)[CableSystems::DynamicsICD::CablesContainerID::kNumCablesID].toInteger();

    VxData::Container& ptInfos = dynamic_cast<VxData::Container&>((*mCables)[CableSystems::DynamicsICD::CablesContainerID::kPointInfosID]);

    if ( ptInfos.isValid() )

    {

        for(int i=0; i<numCables; ++i)

        {

            std::stringstream ss;

            ss << i;

            printf("Cable: %d\n", i);

            printf("-----------------------\n");

            VxData::Container& ptInfo = dynamic_cast<VxData::Container&>(ptInfos[ss.str().c_str()]);

            if ( ptInfo.isValid() )

            {

                unsigned int nbPts = ptInfo[CableSystems:: DynamicsICD::PointInfoContainerID::kNumPointsID].toInteger();

                // If you have the header PointInfoContainer.h

                // unsigned int nbPts2 = dynamic_cast<PointInfoContainer&>(ptInfo).mNumberOfdPoints.getValue().toInteger();

                VxData::FieldBase& fieldPts = ptInfo[CableSystems:: DynamicsICD::PointInfoContainerID::kPositionsID];

                VxData::Vector<VxVector3>& pts = dynamic_cast<VxData::Vector<VxVector3>&>(fieldPts);

                if ( pts.isValid() )

                {

                    for (auto it = pts.begin(), itE = pts.end(); it != itE; ++it)

                    {

                        const VxVector3& p = *it;

                        printf("Position: [%f, %f, %f]\n", p[0], p[1], p[2]);

                    }

                }

            }

        }

    }

}



Remi

Hi Martin, Remi,


Thank you for your comment and sample code.

I could get cable's positions!

Thank you.

Login to post a comment