From 49657ee99e7af0ac6c592f69c688219f42211b00 Mon Sep 17 00:00:00 2001 From: Cyrille Henry Date: Tue, 15 Jan 2013 19:24:15 +0000 Subject: add messages to get list of masses or links accepting various conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -Cette ligne, et les suivantes ci-dessous, seront ignorées-- M pmpd3d.c M pmpd3d_various.c svn path=/trunk/externals/pmpd/; revision=16873 --- pmpd3d.c | 10 ++++- pmpd3d_various.c | 130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+), 1 deletion(-) diff --git a/pmpd3d.c b/pmpd3d.c index 140a6f6..5d4be64 100644 --- a/pmpd3d.c +++ b/pmpd3d.c @@ -689,7 +689,15 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_adaptLength, gensym("adaptLength"), A_GIMME, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesDistances, gensym("massesDistances"), A_GIMME, 0); + class_addmethod(pmpd3d_class, (t_method)pmpd3d_enumMasses, gensym("enumMasses"), A_GIMME, 0); + class_addmethod(pmpd3d_class, (t_method)pmpd3d_enumLinks, gensym("enumLinks"), A_GIMME, 0); +// class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesTab, gensym("forcesXT"), A_GIMME, 0); +// class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesTab, gensym("forcesYT"), A_GIMME, 0); +// class_addmethod(pmpd3d_class, (t_method)pmpd3d_forcesTab, gensym("forcesZT"), A_GIMME, 0); + + + // pmpd3d_stat class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosMean, gensym("massesPosMean"), A_GIMME, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_massesPosStd, gensym("massesPosStd"),A_GIMME, 0); @@ -706,6 +714,6 @@ void pmpd3d_setup(void) class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksPosSpeedStd, gensym("linksPosSpeedStd"), A_GIMME, 0); class_addmethod(pmpd3d_class, (t_method)pmpd3d_linksLengthSpeedStd0, gensym("linksLengthSpeedStd"), A_GIMME, 0); */ - + } diff --git a/pmpd3d_various.c b/pmpd3d_various.c index e671e86..55eeeb9 100644 --- a/pmpd3d_various.c +++ b/pmpd3d_various.c @@ -565,3 +565,133 @@ void pmpd3d_massesDistances(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) } } +void pmpd3d_enumMasses(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int i, j, test, tmp; + t_atom std_out[1]; + + j = 0; + test = 1; + + for (i=0; i < x->nb_mass; i++) + { + while ( (j < argc-1) && (test) ) + { + if ( (argv[j].a_type == A_SYMBOL) && (argv[j+1].a_type == A_FLOAT) ) + { + if (atom_getsymbolarg(j,argc,argv) == gensym("posXSup") ) + { + if ( x->mass[i].posX < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("posXInf") ) + { + if ( x->mass[i].posX > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("posYSup") ) + { + if ( x->mass[i].posY < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("posYInf") ) + { + if ( x->mass[i].posY > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("posZSup") ) + { + if ( x->mass[i].posZ < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("posZInf") ) + { + if ( x->mass[i].posZ > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedXSup") ) + { + if ( x->mass[i].speedX < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedXInf") ) + { + if ( x->mass[i].speedX > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedYSup") ) + { + if ( x->mass[i].speedY < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedYInf") ) + { + if ( x->mass[i].speedY > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedZSup") ) + { + if ( x->mass[i].speedZ < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedZInf") ) + { + if ( x->mass[i].speedZ > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedSup") ) + { + tmp = x->mass[i].speedX * x->mass[i].speedX; + tmp += x->mass[i].speedY * x->mass[i].speedY; + tmp += x->mass[i].speedZ * x->mass[i].speedZ; + + if ( ( tmp < atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("speedInf") ) + { + tmp = x->mass[i].speedX * x->mass[i].speedX; + tmp += x->mass[i].speedY * x->mass[i].speedY; + tmp += x->mass[i].speedZ * x->mass[i].speedZ; + + if ( ( tmp > atom_getfloatarg(j+1,argc,argv)) * atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + j += 2; + } + } + if (test) + { + SETFLOAT(&(std_out[0]),i); + outlet_anything(x->main_outlet, gensym("listMasses"),1,std_out); + } + } +} + +void pmpd3d_enumLinks(t_pmpd3d *x, t_symbol *s, int argc, t_atom *argv) +{ + t_int i, j, test; + t_atom std_out[1]; + + j = 0; + test = 1; + + for (i=0; i < x->nb_link; i++) + { + while ( (j < argc-1) && (test) ) + { + if ( (argv[j].a_type == A_SYMBOL) && (argv[j+1].a_type == A_FLOAT) ) + { + if (atom_getsymbolarg(j,argc,argv) == gensym("forcesSup") ) + { + if ( x->mass[i].posX < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("forcesInf") ) + { + if ( x->mass[i].posX > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if (atom_getsymbolarg(j,argc,argv) == gensym("lengthSup") ) + { + if ( x->mass[i].posY < atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + else if ( atom_getsymbolarg(j,argc,argv) == gensym("lengthInf") ) + { + if ( x->mass[i].posY > atom_getfloatarg(j+1,argc,argv) ) test = 0; + } + j += 2; + } + } + if (test) + { + SETFLOAT(&(std_out[0]),i); + outlet_anything(x->main_outlet, gensym("listLinks"),1,std_out); + } + } +} + -- cgit v1.2.1