#include "code_runner_ext.h" /* RANKS:*/ /*0 --> [1]*/ /*1 --> [1, 1]*/ /*2 --> [1, 1, 1]*/ /*3 --> [1, 1, 2]*/ /*4 --> [2, 2, 2]*/ /*5 --> [2, 2, 2, 2]*/ /*6 --> [1, 1, 1, 1]*/ /*7 --> [1, 1, 2, 2]*/ /*8 --> [1, 1, 1, 3]*/ /*9 --> [3, 3, 3, 3]*/ inline int rank_switch(VALUE data_kit){ return FIX2INT(RFCALL_10_ON( data_kit, "rank_c_switch")); } void get_data_pointer(VALUE data_kit, VALUE * dp){ /*VALUE * dp;*/ VALUE * axes; int i, nranks; nranks = FIX2INT(RFCALL_10_ON( RFCALL_10_ON(data_kit,"ranks"), "size")); /*dp = ALLOC_N(VALUE, nranks);*/ axes = RARRAY_PTR(RFCALL_10_ON(data_kit, "axes_array")); for (i=0;i1) cell_size*=2; if (nj>1) cell_size*=2; for(i=0;i1) cell_size*=2; if (nj>1) cell_size*=2; if (nk>1) cell_size*=2; for(i=0;i1?(nj>1?4:2):1);*/ cell_size=1; if (ni>1) cell_size*=2; if (nj>1) cell_size*=2; nc = *number_count; for(i=0;i1){ if (nj>1) fprintf(file, "4 %d %d %d %d\n", i*nj+j+nc, i*(nj)+j+1+nc, (i+1)*nj+j+1+nc, (i+1)*nj+j+nc); else fprintf(file, "2 %d %d\n", i*nj+j+nc, (i+1)*nj+j+nc); } else{ if (nj>1) fprintf(file, "2 %d %d\n", i*nj+j+nc, i*(nj)+j+1+nc); else fprintf(file, "1 %d\n", i*nj+j+nc); } } break; case 8: /*[1,1,1,3]*/ case 9: /*[3,3,3,3]*/ /*CR_PSTR("HERE!2");*/ cell_size=1; if (ni>1) cell_size*=2; if (nj>1) cell_size*=2; if (nk>1) cell_size*=2; nc = *number_count; /*CR_PINT2("nc", nc);*/ /*nc = 0;*/ for(i=0;i1){ if(nj>1){ if(nk>1) fprintf(file, "8 %d %d %d %d %d %d %d %d\n", i*(nj*nk)+j*nk+k+nc, i*(nj*nk)+j*nk+k+1+nc, i*(nj*nk)+(j+1)*nk+k+nc, i*(nj*nk)+(j+1)*nk+k+1+nc, (i+1)*(nj*nk)+j*nk+k+nc, (i+1)*(nj*nk)+j*nk+k+1+nc, (i+1)*(nj*nk)+(j+1)*nk+k+nc, (i+1)*(nj*nk)+(j+1)*nk+k+1+nc ); else fprintf(file, "4 %d %d %d %d\n", i*(nj*nk)+j*nk+k+nc, i*(nj*nk)+(j+1)*nk+k+nc, (i+1)*(nj*nk)+(j+1)*nk+k+nc, (i+1)*(nj*nk)+j*nk+k+nc ); } else{ if(nk>1) fprintf(file, "4 %d %d %d %d\n", i*(nj*nk)+j*nk+k+nc, i*(nj*nk)+j*nk+k+1+nc, (i+1)*(nj*nk)+j*nk+k+1+nc, (i+1)*(nj*nk)+j*nk+k+nc ); else fprintf(file, "2 %d %d\n", i*(nj*nk)+j*nk+k+nc, (i+1)*(nj*nk)+j*nk+k+nc ); } } else{ if(nj>1){ if(nk>1) fprintf(file, "4 %d %d %d %d\n", i*(nj*nk)+j*nk+k+nc, i*(nj*nk)+j*nk+k+1+nc, i*(nj*nk)+(j+1)*nk+k+1+nc, i*(nj*nk)+(j+1)*nk+k+nc ); else fprintf(file, "2 %d %d\n", i*(nj*nk)+j*nk+k+nc, i*(nj*nk)+(j+1)*nk+k+nc ); } else{ if(nk>1) fprintf(file, "2 %d %d\n", i*(nj*nk)+j*nk+k+nc, i*(nj*nk)+j*nk+k+1+nc ); else fprintf(file, "1 %d\n", i*(nj*nk)+j*nk+k+nc ); } } } break; } /* end switch(rank_switch))*/ break; case PRINT_CELL_TYPES: switch (rank_switch(data_kit)){ case 0: /*[1]*/ case 1: /*[1,1]*/ case 2: /*[1,1,1]*/ case 6: /*[1,1,1,1]*/ for (i=0;i1?(nj>1?4:2):1);*/ cell_size=1; if (ni>1) cell_size*=2; if (nj>1) cell_size*=2; switch(cell_size){ case 4: cell_type = 7; break; case 2: cell_type = 3; break; case 1: cell_type = 1; break; } for(i=0;i1) cell_size*=2; if (nj>1) cell_size*=2; if (nk>1) cell_size*=2; switch(cell_size){ case 8: cell_type = 11; break; /*3D cells, see www.vtk.org/VTK/img/file-formats.pdf*/ case 4: cell_type = 7; break; /*Polygons*/ case 2: cell_type = 3; break; /*Lines*/ case 1: cell_type = 1; break; /*Points*/ } for(i=0;i