From 11b24421d96755d508b15563fccaeb45329506f6 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Mon, 9 May 2005 14:12:25 +0000 Subject: bugs fixed and lists methods ordered svn path=/trunk/externals/nusmuk/; revision=2925 --- msd.h | 106 ++++++++++++++++++++++++++++++++-------------------- msd/01_msdtest.pd | 30 +++++++-------- msd/help-msd.pd | 22 ++++++----- msd2D/help-msd2D.pd | 36 +++++++++--------- msd3D/help-msd3D.pd | 54 +++++++++++++------------- 5 files changed, 139 insertions(+), 109 deletions(-) diff --git a/msd.h b/msd.h index 402b539..c52ac3f 100644 --- a/msd.h +++ b/msd.h @@ -335,7 +335,7 @@ protected: IDMap massids; // masses by name t_float limit[N][2]; // Limit values - unsigned int id_mass, id_link, mouse_grab, nearest_mass; + unsigned int id_mass, id_link, mouse_grab, nearest_mass, link_deleted, mass_deleted; // --------------------------------------------------------------- RESET // ---------------------------------------------------------------------- @@ -472,15 +472,16 @@ protected: return; } - t_mass *m = mass.remove(GetAInt(argv[0])); + t_mass *m = mass.find(GetAInt(argv[0])); if(m) { // Delete all associated links - for(typename std::vector::iterator it = m->links.begin(); it != m->links.end(); ++it) + for(typename std::vector::iterator it = m->links.begin(); it < m->links.end(); ++it) deletelink(*it); outmass(S_Mass_deleted,m); massids.erase(m); mass.remove(m->nbr); delete m; + mass_deleted = 1; } else error("%s - %s : Index not found",thisName(),GetString(thisTag())); @@ -677,8 +678,10 @@ protected: } t_link *l = link.find(GetAInt(argv[0])); - if(l) + if(l) { deletelink(l); + link_deleted = 1; + } else { error("%s - %s : Index not found",thisName(),GetString(thisTag())); return; @@ -837,61 +840,82 @@ protected: // List of masses positions on first outlet void m_mass_dumpl() - { - int sz = mass.size(); - NEWARR(t_atom,sortie,sz*N); - t_atom *s = sortie; - for(typename IndexMap::iterator mit(mass); mit; ++mit) - for(int i = 0; i < N; ++i) SetFloat(*(s++),mit.data()->pos[i]); - ToOutAnything(0, S_massesPosL, sz*N, sortie); - DELARR(sortie); + { + if (mass_deleted ==0) { + int sz = mass.size(); + NEWARR(t_atom,sortie,sz*N); + t_atom *s = sortie; + for(typename IndexMap::iterator mit(mass); mit; ++mit) + for(int i = 0; i < N; ++i) SetFloat(s[mit.data()->nbr*N+i],mit.data()->pos[i]); + ToOutAnything(0, S_massesPosL, sz*N, sortie); + DELARR(sortie); + } + else + error("%s - %s : Message Forbidden when deletion is used",thisName(),GetString(thisTag())); } + // List of masses x positions on first outlet void m_mass_dump_xl() { - int sz = mass.size(); - NEWARR(t_atom,sortie,sz); - t_atom *s = sortie; - for(typename IndexMap::iterator mit(mass); mit; ++mit) - SetFloat(*(s++),mit.data()->pos[0]); - ToOutAnything(0, S_massesPosXL, sz, sortie); - DELARR(sortie); + if (mass_deleted ==0) { + int sz = mass.size(); + NEWARR(t_atom,sortie,sz); + t_atom *s = sortie; + for(typename IndexMap::iterator mit(mass); mit; ++mit) + SetFloat(s[mit.data()->nbr],mit.data()->pos[0]); + ToOutAnything(0, S_massesPosXL, sz, sortie); + DELARR(sortie); + } + else + error("%s - %s : Message Forbidden when deletion is used",thisName(),GetString(thisTag())); } // List of masses y positions on first outlet void m_mass_dump_yl() { - int sz = mass.size(); - NEWARR(t_atom,sortie,sz); - t_atom *s = sortie; - for(typename IndexMap::iterator mit(mass); mit; ++mit) - SetFloat(*(s++),mit.data()->pos[1]); - ToOutAnything(0, S_massesPosYL, sz, sortie); - DELARR(sortie); + if (mass_deleted ==0) { + int sz = mass.size(); + NEWARR(t_atom,sortie,sz); + t_atom *s = sortie; + for(typename IndexMap::iterator mit(mass); mit; ++mit) + SetFloat(s[mit.data()->nbr],mit.data()->pos[1]); + ToOutAnything(0, S_massesPosYL, sz, sortie); + DELARR(sortie); + } + else + error("%s - %s : Message Forbidden when deletion is used",thisName(),GetString(thisTag())); } // List of masses z positions on first outlet void m_mass_dump_zl() { - int sz = mass.size(); - NEWARR(t_atom,sortie,sz); - t_atom *s = sortie; - for(typename IndexMap::iterator mit(mass); mit; ++mit) - SetFloat(*(s++),mit.data()->pos[2]); - ToOutAnything(0, S_massesPosZL, sz, sortie); - DELARR(sortie); + if (mass_deleted ==0) { + int sz = mass.size(); + NEWARR(t_atom,sortie,sz); + t_atom *s = sortie; + for(typename IndexMap::iterator mit(mass); mit; ++mit) + SetFloat(s[mit.data()->nbr],mit.data()->pos[2]); + ToOutAnything(0, S_massesPosZL, sz, sortie); + DELARR(sortie); + } + else + error("%s - %s : Message Forbidden when deletion is used",thisName(),GetString(thisTag())); } // List of masses forces on first outlet void m_force_dumpl() { - int sz = mass.size(); - NEWARR(t_atom,sortie,sz*N); - t_atom *s = sortie; - for(typename IndexMap::iterator mit(mass); mit; ++mit) - for(int i = 0; i < N; ++i) SetFloat(*(s++),mit.data()->out_force[i]); - ToOutAnything(0, S_massesForcesL, sz*N, sortie); - DELARR(sortie); + if (mass_deleted ==0) { + int sz = mass.size(); + NEWARR(t_atom,sortie,sz*N); + t_atom *s = sortie; + for(typename IndexMap::iterator mit(mass); mit; ++mit) + for(int i = 0; i < N; ++i) SetFloat(s[mit.data()->nbr*N+i],mit.data()->out_force[i]); + ToOutAnything(0, S_massesForcesL, sz*N, sortie); + DELARR(sortie); + } + else + error("%s - %s : Message Forbidden when deletion is used",thisName(),GetString(thisTag())); } // List of masses and links infos on second outlet @@ -918,7 +942,7 @@ private: massids.reset(); mass.reset(); - id_mass = id_link = mouse_grab = 0; + id_mass = id_link = mouse_grab = mass_deleted = link_deleted = 0; } void deletelink(t_link *l) diff --git a/msd/01_msdtest.pd b/msd/01_msdtest.pd index dbacaa3..9f13180 100644 --- a/msd/01_msdtest.pd +++ b/msd/01_msdtest.pd @@ -32,16 +32,16 @@ #X obj 45 576 cnv 15 300 200 empty empty empty 20 12 0 14 -261689 -66577 0; #X obj 88 590 vsl 15 128 0 100 0 0 empty empty empty 0 -8 0 8 -261689 --1 -1 8218 1; +-1 -1 8396 1; #X obj 111 590 vsl 15 128 0 100 0 0 empty empty empty 0 -8 0 8 -261689 --1 -1 6270 1; +-1 -1 6393 1; #X obj 66 590 vsl 15 128 0 100 0 0 empty empty empty 0 -8 0 8 -261689 -1 -1 10160 1; #X msg 52 736 posX fix \$1; #X obj 156 590 vsl 15 128 0 100 0 0 empty empty empty 0 -8 0 8 -261689 --1 -1 2445 1; +-1 -1 2427 1; #X obj 134 590 vsl 15 128 0 100 0 0 empty empty empty 0 -8 0 8 -261689 --1 -1 4345 1; +-1 -1 4369 1; #X text 199 638 MOVE FIRST SLIDER; #X text 182 662 TO MOVE THE FIXED MASS; #X msg 184 248 link souple \$1 \$2 10 0.5 0.5; @@ -50,14 +50,14 @@ #X msg 180 438 forceX mob -300; #X obj 167 55 t b b b b b b; #X text 205 34 RESET; -#X msg 52 335 bang \, massesPosL; #X obj 52 545 unpack f f f f f; #X obj 52 523 route massesPosL; +#X msg 52 335 bang \, massesPosL; #X connect 0 0 38 0; -#X connect 2 0 42 0; +#X connect 2 0 41 0; #X connect 2 1 1 0; #X connect 3 0 6 0; -#X connect 6 0 40 0; +#X connect 6 0 42 0; #X connect 9 0 2 0; #X connect 10 0 38 0; #X connect 11 0 9 0; @@ -84,11 +84,11 @@ #X connect 38 3 15 0; #X connect 38 4 14 0; #X connect 38 5 11 0; -#X connect 40 0 2 0; -#X connect 41 0 28 0; -#X connect 41 1 26 0; -#X connect 41 2 27 0; -#X connect 41 3 31 0; -#X connect 41 4 30 0; -#X connect 42 0 41 0; -#X connect 42 1 1 0; +#X connect 40 0 28 0; +#X connect 40 1 26 0; +#X connect 40 2 27 0; +#X connect 40 3 31 0; +#X connect 40 4 30 0; +#X connect 41 0 40 0; +#X connect 41 1 1 0; +#X connect 42 0 2 0; diff --git a/msd/help-msd.pd b/msd/help-msd.pd index 22d551f..b113a1f 100644 --- a/msd/help-msd.pd +++ b/msd/help-msd.pd @@ -23,8 +23,6 @@ #X msg 85 485 forceX \$1 \$2; #X obj 61 617 cnv 15 610 198 empty empty GET_ATTRIBUTES 20 12 0 14 -261689 -66577 0; -#X msg 147 644 massePosL; -#X msg 147 672 masseForcesL; #X text 248 644 output all masses positions in a list on outlet No 1; #X text 247 673 output all masses forces in a list on outlet No 1; @@ -47,7 +45,7 @@ their; #X text 67 83 mass. They can be mobile or fixed \, in this case forces ; -#X text 67 54 The msd masses are the principals objects of the model. +#X text 66 54 The msd masses are the principals objects of the model. ; #X text 66 97 applied on them automatically \, by links \, or manually \, by; @@ -58,18 +56,22 @@ their; #X text 334 271 \$4 : initial position; #X text 350 449 \$1 : Id (symbol) or No; #X text 348 503 \$1 : Id (symbol) or No; +#X msg 147 644 massesPosL; +#X msg 147 672 massesForcesL; +#X text 66 128 Be careful : if masses are deleted \, lists messages +won't work; #X connect 2 0 0 0; #X connect 9 0 0 0; #X connect 14 0 0 0; #X connect 17 0 0 0; -#X connect 19 0 0 0; -#X connect 20 0 0 0; -#X connect 23 0 0 0; -#X connect 27 0 0 0; -#X connect 28 0 0 0; +#X connect 21 0 0 0; +#X connect 25 0 0 0; +#X connect 26 0 0 0; +#X connect 29 0 0 0; #X connect 31 0 0 0; -#X connect 33 0 0 0; -#X connect 42 0 0 0; +#X connect 40 0 0 0; +#X connect 46 0 0 0; +#X connect 47 0 0 0; #X restore 282 323 pd masses; #N canvas 222 83 808 841 links 0; #X obj 33 821 msd; diff --git a/msd2D/help-msd2D.pd b/msd2D/help-msd2D.pd index f4b3208..b8cba2f 100644 --- a/msd2D/help-msd2D.pd +++ b/msd2D/help-msd2D.pd @@ -22,8 +22,6 @@ #X msg 85 485 forceX \$1 \$2; #X obj 61 617 cnv 15 610 260 empty empty GET_ATTRIBUTES 20 12 0 14 -261689 -66577 0; -#X msg 147 644 massePosL; -#X msg 147 694 masseForcesL; #X text 248 644 output all masses positions in a list on outlet No 1; #X text 247 695 output all masses forces in a list on outlet No 1; @@ -60,27 +58,31 @@ their; #X text 334 271 \$4 \, \$5 : initial position; #X text 350 449 \$1 : Id (symbol) or No; #X text 348 503 \$1 : Id (symbol) or No; -#X msg 68 668 massePosXL; -#X msg 147 669 massePosYL; #X text 248 669 output all masses x/y position in a list on outlet No 1; #X msg 112 838 grabMass \$1 \$2 \$3; #X text 247 838 Get nearest mass and grab it; #X text 112 857 \$1 \, \$2 : X \, Y position of mouse; #X text 357 857 \$3 : grab or not (left click); -#X connect 1 0 44 0; -#X connect 8 0 44 0; -#X connect 13 0 44 0; -#X connect 16 0 44 0; -#X connect 18 0 44 0; -#X connect 19 0 44 0; -#X connect 22 0 44 0; -#X connect 26 0 44 0; -#X connect 29 0 44 0; -#X connect 38 0 44 0; -#X connect 41 0 44 0; -#X connect 46 0 44 0; -#X connect 50 0 44 0; +#X msg 147 644 massesPosL; +#X msg 147 669 massesPosYL; +#X msg 147 694 massesForcesL; +#X msg 68 669 massesPosXL; +#X text 66 131 Be careful: if masses are deleted \, lists messages +won't work; +#X connect 1 0 42 0; +#X connect 8 0 42 0; +#X connect 13 0 42 0; +#X connect 16 0 42 0; +#X connect 20 0 42 0; +#X connect 24 0 42 0; +#X connect 27 0 42 0; +#X connect 36 0 42 0; +#X connect 39 0 42 0; +#X connect 44 0 42 0; +#X connect 53 0 42 0; +#X connect 55 0 42 0; +#X connect 56 0 42 0; #X restore 221 312 pd masses; #X text 75 312 HELP on masses --->; #X text 74 343 HELP on links --->; diff --git a/msd3D/help-msd3D.pd b/msd3D/help-msd3D.pd index 21f6a71..725b9e1 100644 --- a/msd3D/help-msd3D.pd +++ b/msd3D/help-msd3D.pd @@ -22,8 +22,6 @@ #X msg 82 458 forceX \$1 \$2; #X obj 61 595 cnv 15 610 245 empty empty GET_ATTRIBUTES 20 12 0 14 -261689 -66577 0; -#X msg 147 622 massePosL; -#X msg 146 696 masseForcesL; #X text 248 622 output all masses positions in a list on outlet No 1; #X text 246 697 output all masses forces in a list on outlet No 1; @@ -38,16 +36,16 @@ #X msg 143 817 infosL; #X text 246 817 Get infos on all masses and links on outlet No 2; #X text 347 533 \$1 : Value; -#X text 73 22 MASSES :; -#X text 66 69 They got only one physical parameter \, the value of +#X text 73 9 MASSES :; +#X text 64 45 They got only one physical parameter \, the value of their; -#X text 67 83 mass. They can be mobile or fixed \, in this case forces +#X text 65 59 mass. They can be mobile or fixed \, in this case forces ; -#X text 67 54 The msd masses are the principals objects of the model. +#X text 64 30 The msd masses are the principals objects of the model. ; -#X text 66 97 applied on them automatically \, by links \, or manually +#X text 64 73 applied on them automatically \, by links \, or manually \, by; -#X text 67 112 messages \, don't do anything.; +#X text 65 88 messages \, don't do anything.; #X msg 81 556 setMobile \$1 \, setFixed \$1; #X text 345 556 Change mobile parameter; #X text 345 572 \$1 : Creation No of mass; @@ -65,24 +63,28 @@ their; #X text 348 481 \$1 : Id (symbol) or No; #X text 247 648 output all masses x/y/z positions in a list on outlet No 1; -#X msg 146 648 massePosYL; -#X msg 147 670 massePosZL; -#X msg 67 648 massePosXL; -#X connect 1 0 50 0; -#X connect 8 0 50 0; -#X connect 13 0 50 0; -#X connect 16 0 50 0; -#X connect 18 0 50 0; -#X connect 19 0 50 0; -#X connect 22 0 50 0; -#X connect 26 0 50 0; -#X connect 29 0 50 0; -#X connect 38 0 50 0; -#X connect 44 0 50 0; -#X connect 45 0 50 0; -#X connect 54 0 50 0; -#X connect 55 0 50 0; -#X connect 56 0 50 0; +#X msg 147 622 massesPosL; +#X msg 146 648 massesPosYL; +#X msg 147 670 massesPosZL; +#X msg 146 696 massesForcesL; +#X msg 67 648 massesPosXL; +#X text 64 103 Be careful : if masses are deleted \, lists messages +won't work; +#X connect 1 0 48 0; +#X connect 8 0 48 0; +#X connect 13 0 48 0; +#X connect 16 0 48 0; +#X connect 20 0 48 0; +#X connect 24 0 48 0; +#X connect 27 0 48 0; +#X connect 36 0 48 0; +#X connect 42 0 48 0; +#X connect 43 0 48 0; +#X connect 52 0 48 0; +#X connect 53 0 48 0; +#X connect 54 0 48 0; +#X connect 55 0 48 0; +#X connect 56 0 48 0; #X restore 159 305 pd masses; #X text 12 305 HELP on masses --->; #X text 11 336 HELP on links --->; -- cgit v1.2.1