← Back to team overview

yade-users team mailing list archive

Re: [Question #153589]: Adding an IGeomFunctor subclass

 

Question #153589 on Yade changed:
https://answers.launchpad.net/yade/+question/153589

    Status: Open => Answered

Chareyre proposed the following answer:

> I created the Law2_CylScGeom6D_CohFrictPhys_CohesionMoment class, child of LawFunctor. I have done that in the CohesiveFrictionalContactLaw.hpp/cpp files to avoid adding things at the big Cylinder.cpp file.
> The new class is the same as Law2_CylScGeom_FrictPhys_CundallStrack, I just changed the names and the beginning by that : 
>
> CylScGeom6D* geom = static_cast<CylScGeom6D*>(ig.get());
> CohFrictPhys* phys = static_cast<CohFrictPhys*>(ip.get());
All right.
> And the hpp declaration is like the CohesiveFrictionalContactLaw one
> (just changing the names).
>
>
> Unfortunately scons gave this error :
>
> /usr/include/boost/smart_ptr/shared_ptr.hpp: In constructor 'boost::shared_ptr< <template-parameter-1-1> >::shared_ptr(const boost::shared_ptr<Y>&, boost::detail::dynamic_cast_tag) [with Y = IGeom, T = CylScGeom6D]':
> /usr/include/boost/smart_ptr/shared_ptr.hpp:522:   instantiated from 'boost::shared_ptr<X> boost::dynamic_pointer_cast(const boost::shared_ptr<U>&) [with T = CylScGeom6D, U = IGeom]'
> /home/francoisk/build-trunk/include/yade/pkg/dem/CohesiveFrictionalContactLaw.hpp:81:   instantiated from here
> /usr/include/boost/smart_ptr/shared_ptr.hpp:259: error: cannot dynamic_cast 'r->boost::shared_ptr<IGeom>::px' (of type 'class IGeom* const') to type 'struct CylScGeom6D*' (target is not pointer or reference to complete type)
Is this the full output?

Random ideas:
- Did you forget to define a virtual by any chance? Like this in
Cylinder.cpp :  CylScGeom::~CylScGeom(){}
- Why IGeom is seen as a "class" while CylScGeom6D is seen as "struct"?
- Ho wait... aren't you just trying to cast a const to not-const?

It is difficult to guess without seeing the code.

B

-- 
You received this question notification because you are a member of
yade-users, which is an answer contact for Yade.