#pragma once #include <math.h> #include "DS_1b_cube.h" class DS_2b_cube { public: DS_2b_cube(unsigned short int nwZ, unsigned short int nwY, unsigned short int nwX); DS_2b_cube(DS_1b_cube* DS_1bit_cube); ~DS_2b_cube(void); //inlined functions unsigned char get_spot(unsigned short int zL, unsigned short int yL, unsigned short int xL) { return (data[zL][yL][xL/4] >> (6 - 2*(unsigned char)(xL%4))) & 0x03; } void set_spot(unsigned char val, unsigned short int zL, unsigned short int yL, unsigned short int xL) { /* this is used multiple times, so do calc only once */ unsigned char invcharLoc = 6 - 2*(unsigned char)(xL%4); /* get the byte that contains the desired location */ unsigned char * cur_byte = &data[zL][yL][xL/4]; /* might need to shift to bring the desired location to the most significant spot */ val = (val << invcharLoc); unsigned char mask = (unsigned char)(~(0x03 << invcharLoc)); //first AND with new value to clear an '0's, then OR to set any highs *cur_byte = (*cur_byte & mask) | val; } //other functions DS_2b_cube* rotate_XY_to_YZ(); DS_2b_cube* rotate_XY_to_ZX(); int to_DS_cube(DS_cube * result_cube, unsigned short int first_slice, unsigned short int last_slice); int to_DS_1b_cube(DS_1b_cube * result_cube, unsigned short int first_slice, unsigned short int last_slice); bool write_to_RAW_STACK(char * out_file); void clear(); //public variables public: unsigned short int wZ; unsigned short int wY; unsigned short int wX; unsigned short int cwX; unsigned char *** data; //this is a 3d array unsigned char ** rows; //this is memory for each slice pointers unsigned char * memory; //this is memory for actual data };