src/GRAPHGEN/conact_code_generator.cpp
// Generate string to access a pixel value using pointers
Generate string to access a pixel value using pointers
Generate string to access a pixel value using pointers
string GenerateAccessPixelCode(const string& img_name, const pixel& p) {
    string slice_id = "";
    if (p.coords_.size() > 2) {
        slice_id = "slice" + string(p.coords_[2] < 0 ? "1" : "0") + to_string(abs(p.coords_[2])) + "_";
    }
    string row_id = "row" + string(p.coords_[1] < 0 ? "1" : "0") + to_string(abs(p.coords_[1]));
    string col = "";
    if (p.coords_[0] > 0) {
        col += " + " + to_string(abs(p.coords_[0]));
    }
    else if (p.coords_[0] < 0) {
        col += " - " + to_string(abs(p.coords_[0]));
    }
    return img_name + slice_id + row_id + "[c" + col + "]";
}
string GenerateAccessPixelCode ( const string & img_name , const pixel & p ) { string slice_id = " " ; if ( p . coords_ . size ( ) > 2 ) { slice_id = " " + string ( p . coords_ [ 2 ] < 0 ? " " : " " ) + to_string ( abs ( p . coords_ [ 2 ] ) ) + " " ; } string row_id = " " + string ( p . coords_ [ 1 ] < 0 ? " " : " " ) + to_string ( abs ( p . coords_ [ 1 ] ) ) ; string col = " " ; if ( p . coords_ [ 0 ] > 0 ) { col += " " + to_string ( abs ( p . coords_ [ 0 ] ) ) ; } else if ( p . coords_ [ 0 ] < 0 ) { col += " " + to_string ( abs ( p . coords_ [ 0 ] ) ) ; } return img_name + slice_id + row_id + " " + col + " " ; }
Generate string to access a pixel value using pointers
Generate string to access a pixel value using pointers