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

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Tue Aug 17 23:44:34 EDT 2010


Author: matju
Date: Tue Aug 17 23:44:34 2010
New Revision: 6190

Log:
[#border]: allow 2-dimensional grids

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

Modified: trunk/doc/flow_classes/#border-help.pd
==============================================================================
--- trunk/doc/flow_classes/#border-help.pd (original)
+++ trunk/doc/flow_classes/#border-help.pd Tue Aug 17 23:44:34 2010
@@ -1,44 +1,55 @@
-#N canvas 597 51 632 499 10;
+#N canvas 596 51 632 565 10;
 #X obj 20 84 #in;
 #X obj 20 127 #out window;
 #X text 15 28 Creates a black border around an image.;
 #X msg 20 62 load working.jpg;
-#X text 232 206 top padding and left padding. defaults to (1 1 0).
-;
-#X text 232 228 bottom and right padding. defaults to (1 1 0).;
 #X obj 20 105 #border (5 10 0) (15 20 0);
-#X text 209 98 5 at the top;
-#X text 208 112 10 at the left;
-#X text 208 126 15 at the bottom;
-#X text 208 139 20 at the right;
-#X text 114 255 both arguments must have 3 elements. The third element
-is reserved for future use.;
-#X text 232 425 The original image surrounded by zero padding \, which
+#X text 126 46 5 at the top;
+#X text 125 60 10 at the left;
+#X text 125 74 15 at the bottom;
+#X text 125 87 20 at the right;
+#X text 232 466 The original image surrounded by zero padding \, which
 usually means black pixels.;
-#X obj 14 425 doc_oo 0;
-#X obj 14 321 doc_ii 0;
-#X obj 14 341 doc_ii 1;
-#X obj 14 363 doc_ii 2;
+#X obj 14 466 doc_oo 0;
+#X obj 14 360 doc_ii 0;
+#X obj 14 382 doc_ii 1;
+#X obj 14 404 doc_ii 2;
 #X obj 14 206 doc_cc 0;
-#X obj 14 228 doc_cc 1;
-#X obj 232 341 doc_same 0;
-#X obj 232 363 doc_same 1;
+#X obj 14 276 doc_cc 1;
+#X obj 232 382 doc_same 0;
+#X obj 232 404 doc_same 1;
 #X obj 0 0 doc_h;
-#X obj 0 470 doc_f;
+#X obj 0 531 doc_f;
 #X obj 3 176 doc_c 2;
-#X obj 3 291 doc_i 3;
-#X obj 3 395 doc_o 1;
+#X obj 3 330 doc_i 3;
+#X obj 3 436 doc_o 1;
 #X obj 97 206 doc_m c0 grid[3];
-#X obj 97 228 doc_m c1 grid[3];
-#X obj 97 321 doc_m i0 grid;
-#X obj 97 341 doc_m i1 list;
-#X obj 97 363 doc_m i2 list;
-#X obj 97 425 doc_m o0 grid;
-#X connect 0 0 6 0;
+#X obj 97 276 doc_m c1 grid[3];
+#X obj 97 360 doc_m i0 grid;
+#X obj 97 382 doc_m i1 list;
+#X obj 97 404 doc_m i2 list;
+#X obj 97 466 doc_m o0 grid;
+#X obj 3 511 doc_also;
+#X obj 344 50 #border (1 2) (3 4);
+#X msg 344 29 2 2 # 866 500 -500 866;
+#X obj 344 70 display;
+#X text 232 206 top padding and left padding. defaults to (1 1).;
+#X text 232 276 bottom and right padding. defaults to (1 1).;
+#X text 232 298 there may be a third element in the list but...;
+#X obj 103 511 #slice;
+#X text 232 228 there may be a third element in the list but it must
+be 0 and it's only allowed when there are three dimensions in the input
+grid. it is reserved for future use.;
+#X connect 0 0 4 0;
 #X connect 3 0 0 0;
-#X connect 6 0 1 0;
-#X connect 26 1 4 0;
-#X connect 27 1 5 0;
-#X connect 29 1 19 0;
-#X connect 30 1 20 0;
-#X connect 31 1 12 0;
+#X connect 4 0 1 0;
+#X connect 23 1 33 0;
+#X connect 23 1 37 0;
+#X connect 24 1 34 0;
+#X connect 24 1 35 0;
+#X connect 26 1 16 0;
+#X connect 27 1 17 0;
+#X connect 28 1 9 0;
+#X connect 29 1 36 0;
+#X connect 30 0 32 0;
+#X connect 31 0 30 0;

Modified: trunk/src/classes3.cxx
==============================================================================
--- trunk/src/classes3.cxx (original)
+++ trunk/src/classes3.cxx Tue Aug 17 23:44:34 2010
@@ -540,7 +540,7 @@
 	\grin 1 int
 	\grin 2 int
 	\constructor (Grid *dl=0, Grid *dr=0) {
-		t_atom2 a[3] = {1,1,0};
+		t_atom2 a[3] = {1,1};
 		diml_grid=dl?dl:new Grid(3,a,int32_e);
 		dimr_grid=dr?dr:new Grid(3,a,int32_e);
 		diml = diml_grid->to_dim();
@@ -550,18 +550,18 @@
 
 GRID_INLET(0) {
 	int n = in.dim.n;
-	if (n!=3) RAISE("only 3 dims supported for now");
-	if (diml.n != n) RAISE("diml mismatch");
-	if (dimr.n != n) RAISE("dimr mismatch");
-	if (diml[2] || dimr[2]) RAISE("can't augment channels (todo)");
+	if (n<2 || n>3) RAISE("only 2 or 3 dims supported for now");
+	if (diml.n<2 || diml.n>n) RAISE("diml mismatch");
+	if (dimr.n<2 || dimr.n>n) RAISE("dimr mismatch");
+	if ((diml.n>2 && diml[2]) || (diml.n>2 && dimr[2])) RAISE("can't augment channels (todo)");
 	int32 v[n];
-	for (int i=0; i<n; i++) v[i]=in.dim[i]+diml[i]+dimr[i];
+	for (int i=0; i<n; i++) v[i]=in.dim[i] + (i<diml.n?diml[i]:0) + (i<dimr.n?dimr[i]:0);
 	in.set_chunk(0);
 	go=new GridOut(this,0,Dim(n,v),in.nt);
 } GRID_FLOW {
 	int sy = in.dim[0];
-	int sx = in.dim[1]; int zx = sx+diml[1]+dimr[1];
-	int sc = in.dim[2]; int zc = sc+diml[2]+dimr[2];
+	int sx = in.dim[1];      int zx = sx+diml[1]     +dimr[1];
+	int sc = in.dim.prod(2); int zc = sc+(2<diml.n?diml[2]:0) + (2<dimr.n?dimr[2]:0);
 	int sxc = sx*sc; int zxc = zx*zc;
 	int32 duh[zxc];
 	for (int x=0; x<zxc; x++) duh[x]=0;



More information about the Gridflow-cvs mailing list