% function reuseStaleTag()

% First build model, geo, containing overlapping blocks: B1 and B2
geo = struct;
gobj = gobj_block( [0], [1], [0], [1], [0], [1], 'B1' );
geo = geom_add_gobj( geo, gobj );
gobj = gobj_block( [0.5], [1.5], [0], [1], [0], [1], 'B2' );
geo = geom_add_gobj( geo, gobj );
%print_tags_and_objs_tag

% then combine B1 and B2 by subtraction:
geo = geom_apply_formula( geo, 'B1-B2' );

% Now create another block and check to see that its tag is unique
gobj = gobj_block( [0], [1], [0], [1], [0], [1], 'B1' );

all_tags = cellfun( @(o)o.tag, geo.objects, 'UniformOutput', false );
is_tag_unique = ~ismember( gobj.tag, all_tags );

%print_tags_and_objs_tag
if is_tag_unique
    disp ("gobj.tag, "+gobj.tag+", is unique, adding gobj to geo ...");
    geo = geom_add_gobj( geo, gobj );
else
    disp ("gobj.tag: "+gobj.tag+" is not unique");
end
disp ("The tag of object added (geo.objects{2}) is "+geo.objects{2}.tag);
%print_tags_and_objs_tag;

% function print_tags_and_objs_tag
%     
% disp ("content of geo.tags:");
% for i=1:1:length(geo.tags)
%     disp (i+": "+geo.tags{i});
% end
% 
% disp ("content of geo.objects{}.tag:");
% for i=1:1:length(geo.objects)
%     disp (i+": "+geo.objects{i}.tag);
% end
%     end
% end



