← Back to team overview

yade-dev team mailing list archive

Re: acces to sphere/wall information

 

What is the equivalent command with python?

O.bodies.shape=sphere/wall/facet ?





2009/12/15 Václav Šmilauer <eudoxos@xxxxxxxx>

>
> > I usually use classIndexes, but it needs a bit more than one line. Do we
> > have a simpler way now (checking class names takes too much time)?
> You should try 1. dynamic_cast and 2. class indices. I am not sure which
> one will be the winner:
>
> FOREACH(const shared_ptr<Body>& b, *scene->bodies){
>        if(!b) continue; // deleted bodies
>
>        // first possibility
>        // (not tested, but I think static indices should work just fine)
>        if(b->shape->getClassIndexStatic()==Sphere::getClassIndexStatic()){
> /* ... */ }
>        else if(b->shape->getClassIndexStatic()==Wall::getClassIndexState())
> { /* ... */ }
>
>        // second possibility
>        if(dynamic_cast<Sphere>(b->shape->get())){ /* ... */ }
>        else if(dynamic_cast<Wall>(b->shape->get())){ /* ... */ }
> }
>
> v
>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~yade-dev<https://launchpad.net/%7Eyade-dev>
> Post to     : yade-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~yade-dev<https://launchpad.net/%7Eyade-dev>
> More help   : https://help.launchpad.net/ListHelp
>

Follow ups

References