Page 1 of 1

Plugin Build incomplete type is not allowed

Posted: Mon Apr 23, 2018 2:24 pm
by czhang9
Hi everyone,

I am a new in C++, and trying to build a plugin in Visual Studio 2017.
In my code, the joint information is needed (see the below code), but errors occurred: incomplete type is not allowed.

const Joint& joint = _model->getJointSet().get(_jointReferences.getName());//this line is correct
simbodyIndex = joint.getBody().getIndex();// this line is wrong, incomplete type is not allowed.

I think my header has already included joint class:
#include <OpenSim/Simulation/Model/Model.h>
#include <OpenSim/Simulation/Model/ActivationFiberLengthMuscle.h>
#include <OpenSim/Simulation/Model/ForceSet.h>
#include <OpenSim/Simulation/SimbodyEngine/Coordinate.h>
#include <OpenSim/Simulation/SimbodyEngine/SimbodyEngine.h>

Does anyone can help figure it out?

Thanks,
Chaofei

Re: Plugin Build incomplete type is not allowed

Posted: Mon Apr 23, 2018 9:59 pm
by mitkof6
Hi,

Joint is an abstract class and can't be used. Change this to whatever type the joint is (e.g. CustomJoint).

Re: Plugin Build incomplete type is not allowed

Posted: Wed Apr 25, 2018 6:27 am
by czhang9
Hi Dimitar,

Thanks for your reply. CustomJoint is not defined.

#include <OpenSim/Simulation/Model/JointSet.h>
const CustomJoint& joint = _model->getJointSet().get(_jointReferences.getName());


Chaofei

Re: Plugin Build incomplete type is not allowed

Posted: Wed Apr 25, 2018 8:14 am
by mitkof6

Code: Select all

#include <OpenSim/Simulation/SimbodyEngine/CustomJoint.h>

Re: Plugin Build incomplete type is not allowed

Posted: Wed Apr 25, 2018 12:08 pm
by czhang9
Hi Dimitar,

Thanks for your help.
But I still get errors: no suitable user-defined conversion from "const OpenSim::Joint" to "const OpenSim::CustomJoint" exists.

#include <OpenSim/Simulation/SimbodyEngine/CustomJoint.h>
const CustomJoint& joint = _model->getJointSet().get(_jointReferences.getName());

And the following code has the same problem (incomplete type is not allowed)
_model->getGroundBody().getIndex()

Thanks,
Chaofei

Re: Plugin Build incomplete type is not allowed

Posted: Thu Apr 26, 2018 3:37 am
by mitkof6
You can leave it as Joint or cast it

Code: Select all

const auto& joint = dynamic_cast<const CustomJoint&>( _model->getJointSet().get(_jointReferences[i].getName()));

#include <OpenSim/OpenSim.h>
depending on the context you may need to include some headers from simbody. Check what is returned by getIndex() and include it.

Re: Plugin Build incomplete type is not allowed

Posted: Thu Apr 26, 2018 10:43 am
by czhang9
Hi Dimitar,

Thanks! My problem of incomplete type has been solved.
The joint and customjoint are both ok. Just need to include header for getindex().
#include <OpenSim/Simulation/SimbodyEngine/Body.h>

But when I try to build, an error occurs in 'Property.h': use of undefined type 'OpenSim::SpatialTransform'.
I tried to include header 'SpatialTransorm.h', more errors appeared.

Do you have any ideas?

Much appreciated!

Chaofei

Re: Plugin Build incomplete type is not allowed

Posted: Wed May 02, 2018 10:14 am
by czhang9
Any suggestions?