function valid = check_validity(cuboidhyp, vp)
% check if all left-right relations are satisfied among junctions

valid = true(length(cuboidhyp),1);
for i = 1:length(cuboidhyp)
    if  determinepointlr(1, cuboidhyp(i).junc3(1).pt, cuboidhyp(i).junc3(3).pt, vp) == 1 || ...
        determinepointlr(1, cuboidhyp(i).junc3(2).pt, cuboidhyp(i).junc3(4).pt, vp) == 1 || ...
        determinepointlr(1, cuboidhyp(i).junc3(5).pt, cuboidhyp(i).junc3(7).pt, vp) == 1 || ...
        determinepointlr(1, cuboidhyp(i).junc3(6).pt, cuboidhyp(i).junc3(8).pt, vp) == 1 || ...
        determinepointlr(2, cuboidhyp(i).junc3(1).pt, cuboidhyp(i).junc3(2).pt, vp) == 1 || ...
        determinepointlr(2, cuboidhyp(i).junc3(3).pt, cuboidhyp(i).junc3(4).pt, vp) == 1 || ...
        determinepointlr(2, cuboidhyp(i).junc3(5).pt, cuboidhyp(i).junc3(6).pt, vp) == 1 || ...
        determinepointlr(2, cuboidhyp(i).junc3(7).pt, cuboidhyp(i).junc3(8).pt, vp) == 1 || ...
        determinepointlr(3, cuboidhyp(i).junc3(1).pt, cuboidhyp(i).junc3(5).pt, vp) == 1 || ...
        determinepointlr(3, cuboidhyp(i).junc3(2).pt, cuboidhyp(i).junc3(6).pt, vp) == 1 || ...
        determinepointlr(3, cuboidhyp(i).junc3(3).pt, cuboidhyp(i).junc3(7).pt, vp) == 1 || ...
        determinepointlr(3, cuboidhyp(i).junc3(4).pt, cuboidhyp(i).junc3(8).pt, vp) == 1
        
        valid(i) = false;
    end
end

