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
Plugin Build incomplete type is not allowed
- Chaofei Zhang
- Posts: 26
- Joined: Tue Oct 03, 2017 11:03 am
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: Plugin Build incomplete type is not allowed
Hi,
Joint is an abstract class and can't be used. Change this to whatever type the joint is (e.g. CustomJoint).
Joint is an abstract class and can't be used. Change this to whatever type the joint is (e.g. CustomJoint).
- Chaofei Zhang
- Posts: 26
- Joined: Tue Oct 03, 2017 11:03 am
Re: Plugin Build incomplete type is not allowed
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
Thanks for your reply. CustomJoint is not defined.
#include <OpenSim/Simulation/Model/JointSet.h>
const CustomJoint& joint = _model->getJointSet().get(_jointReferences.getName());
Chaofei
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: Plugin Build incomplete type is not allowed
Code: Select all
#include <OpenSim/Simulation/SimbodyEngine/CustomJoint.h>
- Chaofei Zhang
- Posts: 26
- Joined: Tue Oct 03, 2017 11:03 am
Re: Plugin Build incomplete type is not allowed
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
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
- Dimitar Stanev
- Posts: 1096
- Joined: Fri Jan 31, 2014 5:14 am
Re: Plugin Build incomplete type is not allowed
You can leave it as Joint or cast it
depending on the context you may need to include some headers from simbody. Check what is returned by getIndex() and include it.
Code: Select all
const auto& joint = dynamic_cast<const CustomJoint&>( _model->getJointSet().get(_jointReferences[i].getName()));
#include <OpenSim/OpenSim.h>
- Chaofei Zhang
- Posts: 26
- Joined: Tue Oct 03, 2017 11:03 am
Re: Plugin Build incomplete type is not allowed
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
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
- Chaofei Zhang
- Posts: 26
- Joined: Tue Oct 03, 2017 11:03 am
Re: Plugin Build incomplete type is not allowed
Any suggestions?