syntax = "proto3";

package biopb.image;

option java_package = "biopb.image";
option java_multiple_files = true;


import "biopb/image/bindata.proto";

/////////////
// ROI classes are desgined roughly after OME-XML's related datatypes, but with
// a emphasis on 3D data
//
message Point {
    float x = 1;
    float y = 2;
    optional float z = 3;
}


// A simple rectangle object. 
//
message Rectangle {

    Point top_left = 1;

    Point bottom_right = 2;

}


// The Mask ROI shape is a link to a BinData object that is a BIT mask drawn on
// top of the image as an ROI. It is applied at the same scale, pixel to pixel,
// as the Image the ROI is applied to. The dimension order of the mask is the
// same as the that of the image data the Roi is applied to.
//
message Mask {

    Rectangle rectangle = 1;

    BinData bin_data = 2;
}

// A simple ellipse object.
//
message Ellipse {

    Point center = 1;

    // If the `center`` has no z field, neither should `radius`
    Point radius = 2;

}

// The Polygon defines closed shapes formed of straight lines. Note: Polygon
// uses counterclockwise winding (this is the default OpenGL behavior)
//
message Polygon {

    repeated Point points = 1;

}


// A closed 3D shape repesented by triangular meshes. 
//
message Mesh {

    // All vertices of the mesh
    repeated Point verts = 1;

    // A trangle defined three indices of the verts array
    message Face {
        uint32 p1 = 1;
        uint32 p2 = 2;
        uint32 p3 = 3;

        // Optionally one can cache the computed normal vectors here
        repeated Point normals = 4;
    
        // Optionally one can cache the associated face values here
        repeated float values = 5;

    }
    repeated Face faces = 2;

}


// A three dimensional 'Region of Interest'.  
//
message ROI {

    oneof shape {

        Point point = 1;

        Rectangle rectangle = 2;

        Ellipse ellipse = 3;

        Polygon polygon = 4;

        Mesh mesh = 5;

        Mask mask = 6;

    }

}
