Plugin Build incomplete type is not allowed

Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
POST REPLY
User avatar
Chaofei Zhang
Posts: 26
Joined: Tue Oct 03, 2017 11:03 am

Plugin Build incomplete type is not allowed

Post by Chaofei Zhang » Mon Apr 23, 2018 2:24 pm

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

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Plugin Build incomplete type is not allowed

Post by Dimitar Stanev » Mon Apr 23, 2018 9:59 pm

Hi,

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

User avatar
Chaofei Zhang
Posts: 26
Joined: Tue Oct 03, 2017 11:03 am

Re: Plugin Build incomplete type is not allowed

Post by Chaofei Zhang » Wed Apr 25, 2018 6:27 am

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

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Plugin Build incomplete type is not allowed

Post by Dimitar Stanev » Wed Apr 25, 2018 8:14 am

Code: Select all

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

User avatar
Chaofei Zhang
Posts: 26
Joined: Tue Oct 03, 2017 11:03 am

Re: Plugin Build incomplete type is not allowed

Post by Chaofei Zhang » Wed Apr 25, 2018 12:08 pm

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

User avatar
Dimitar Stanev
Posts: 1096
Joined: Fri Jan 31, 2014 5:14 am

Re: Plugin Build incomplete type is not allowed

Post by Dimitar Stanev » Thu Apr 26, 2018 3:37 am

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.

User avatar
Chaofei Zhang
Posts: 26
Joined: Tue Oct 03, 2017 11:03 am

Re: Plugin Build incomplete type is not allowed

Post by Chaofei Zhang » Thu Apr 26, 2018 10:43 am

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

User avatar
Chaofei Zhang
Posts: 26
Joined: Tue Oct 03, 2017 11:03 am

Re: Plugin Build incomplete type is not allowed

Post by Chaofei Zhang » Wed May 02, 2018 10:14 am

Any suggestions?

POST REPLY