[Gridflow-cvs] [svn] commit: r6180 - in /trunk: doc/flow_classes/#pack-help.pd src/classes3.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Tue Aug 17 16:09:13 EDT 2010


Author: matju
Date: Tue Aug 17 16:09:12 2010
New Revision: 6180

Log:
[#pack]: add attr 'cast'

Modified:
    trunk/doc/flow_classes/#pack-help.pd
    trunk/src/classes3.cxx

Modified: trunk/doc/flow_classes/#pack-help.pd
==============================================================================
--- trunk/doc/flow_classes/#pack-help.pd (original)
+++ trunk/doc/flow_classes/#pack-help.pd Tue Aug 17 16:09:12 2010
@@ -4,61 +4,69 @@
 #X floatatom 110 119 5 0 0 0 - - -;
 #X floatatom 136 137 5 0 0 0 - - -;
 #X text 165 113 <--click and drag to place numbers in the grid.;
-#X text 232 567 Outputs values from each individual inlet into a grid.
-;
 #X obj 0 0 doc_h;
 #X obj 3 359 doc_i n;
 #X obj 3 262 doc_c 0..2;
 #X text 14 28 Creates a one-dimensional grid (a Dim(N) vector) from
 individual integers.;
-#X text 232 439 every inlet is hot.;
-#X text 232 461 inlet order corresponds to value order in the grid.
+#X text 232 534 every inlet is hot.;
+#X text 232 556 inlet order corresponds to value order in the grid.
 ;
-#X obj 3 537 doc_o 1;
-#X obj 14 567 doc_oo 0;
+#X obj 3 632 doc_o 1;
+#X obj 14 662 doc_oo 0;
 #X obj 14 292 doc_cc 0;
 #X obj 14 327 doc_cc 1;
-#X obj 97 292 doc_m c0 float/int;
 #X obj 97 327 doc_m c1 numtype;
-#X obj 97 567 doc_m o0 grid[n];
-#X obj 0 619 doc_f;
+#X obj 97 662 doc_m o0 grid[n];
+#X obj 0 727 doc_f;
 #X text 232 327 number type (default: int32);
 #X obj 85 155 #pack 3 f;
-#X obj 3 599 doc_also;
-#X obj 103 599 pack;
-#X obj 139 599 #unpack;
+#X obj 3 707 doc_also;
+#X obj 103 707 pack;
+#X obj 139 707 #unpack;
 #X obj 85 176 display;
 #X text 232 292 number of elements in the vector to be built (aka number
 of dimensions in the vector space) (default: 2);
-#X text 232 483 float \$1 is like set \$1 then bang.;
-#X text 232 505 only set value \, don't send.;
+#X text 232 578 float \$1 is like set \$1 then bang.;
+#X text 232 600 only set value \, don't send.;
 #X obj 14 389 doc_ii 0;
-#X obj 97 389 doc_m i0 bang;
-#X text 232 389 output existing contents;
-#X obj 97 411 doc_m i0 list;
-#X obj 97 439 doc_m iany float;
-#X obj 97 505 doc_m iany set;
-#X obj 14 439 doc_ii any;
-#X text 232 411 set several inlets at once and output only once. if
+#X obj 97 391 doc_m i0 bang;
+#X text 232 391 output existing contents;
+#X obj 97 429 doc_m i0 list;
+#X obj 97 534 doc_m iany float;
+#X obj 97 600 doc_m iany set;
+#X obj 14 534 doc_ii any;
+#X text 232 429 set several inlets at once and output only once. if
 the list is too short \, some inlets will be left untouched. if the
 list is too long \, excess arguments will be ignored.;
 #X msg 70 68 60 120 180 240;
 #X text 164 67 <--set several values at once;
 #X text 165 78 (\$4 gets ignored in this example);
-#X connect 1 0 21 0;
-#X connect 2 0 21 1;
-#X connect 3 0 21 2;
-#X connect 16 1 26 0;
-#X connect 17 1 20 0;
-#X connect 18 1 5 0;
-#X connect 21 0 25 0;
-#X connect 21 0 0 0;
-#X connect 22 1 23 0;
-#X connect 22 1 24 0;
-#X connect 30 1 31 0;
-#X connect 32 1 36 0;
-#X connect 33 1 10 0;
-#X connect 33 1 11 0;
-#X connect 33 1 27 0;
-#X connect 34 1 28 0;
-#X connect 37 0 21 0;
+#X obj 97 477 doc_m i0 cast;
+#X obj 232 512 doc_link numtype 1;
+#X text 232 477 choose number type conversion. this is the numtype
+of the output grid.;
+#X msg 30 110 cast s;
+#X obj 97 292 doc_m c0 float;
+#X text 232 662 Puts together the values stored in each inlet \, and
+outputs the grid made from them.;
+#X connect 1 0 19 0;
+#X connect 2 0 19 1;
+#X connect 3 0 19 2;
+#X connect 15 1 18 0;
+#X connect 16 1 43 0;
+#X connect 19 0 23 0;
+#X connect 19 0 0 0;
+#X connect 20 1 21 0;
+#X connect 20 1 22 0;
+#X connect 28 1 29 0;
+#X connect 30 1 34 0;
+#X connect 31 1 9 0;
+#X connect 31 1 10 0;
+#X connect 31 1 25 0;
+#X connect 32 1 26 0;
+#X connect 35 0 19 0;
+#X connect 38 1 39 0;
+#X connect 38 1 40 0;
+#X connect 41 0 19 0;
+#X connect 42 1 24 0;

Modified: trunk/src/classes3.cxx
==============================================================================
--- trunk/src/classes3.cxx (original)
+++ trunk/src/classes3.cxx Tue Aug 17 16:09:12 2010
@@ -1224,26 +1224,24 @@
 \class GridPack : FObject {
 	int n;
 	PtrGrid a;
+	\attr NumberTypeE cast;
 	\constructor (int n=2, NumberTypeE nt=int32_e) {
 		if (n<1) RAISE("n=%d must be at least 1",n);
 		if (n>32) RAISE("n=%d is too many?",n);
-		a = new Grid(Dim(n),nt,true);
+		a = new Grid(Dim(n),float32_e,true);
 		this->n=n;
 		ninlets_set(this->n);
+		cast = int32_e;
 	}
 	//\decl 0 cast (NumberTypeE nt) {a = new Grid(a->dim,nt);}
 	\decl n set   (int inlet, float f) {
 		if (inlet>=n) RAISE("what???");
-		#define FOO(T) ((T *)*a)[inlet] = T(f);
-		TYPESWITCH(a->nt,FOO,);
-		#undef FOO
+		((float *)*a)[inlet] = f;
 	}
 	\decl n float (int inlet, float f) {_n_set(inlet,f); _0_bang();}
 	\decl 0 bang () {
-		go=new GridOut(this,0,a->dim,a->nt);
-		#define FOO(T) go->send(n,(T *)*a);
-		TYPESWITCH(a->nt,FOO,);
-		#undef FOO
+		go=new GridOut(this,0,a->dim,cast);
+		go->send(n,(float *)*a);
 	}
 };
 \end class {install("#pack",1,1); add_creator("@pack");}



More information about the Gridflow-cvs mailing list