%-------------------------- % @Author: Jingqiao Hu % @Date: 2022-01-08 22:27:37 % @LastEditTime: 2022-01-08 22:28:52 % c_interPolyMMC: the intersected polygon for each mmc % c_interPolySeed: the intersected polygon for each seed %-------------------------- function [c_interPolyMMC, c_interPolySeed] = do_intersection(MMCs_poly, c_poly, c_nnbEdgeIDX) ncvt = size(c_nnbEdgeIDX, 1); % computer the intersected-idx of each polygon-cell for each MMC c_interPolyMMC = mexInterPoly(MMCs_poly, c_poly); % compute the intersected-idx of each polygon-cell for each seed c_interPolySeed = cell(ncvt, 1); parfor i = 1 : ncvt MMCs_id = c_nnbEdgeIDX{i}; % the corresponding idx in MMCs_poly for each seed interP = []; for j = 1 : numel(MMCs_id) mj = MMCs_id(j); % this MMCs_poly id pgonID = c_interPolyMMC{mj}; % the intersected mesh-polygon with this MMC for k = 1 : length(pgonID) interP = [interP; pgonID]; end end c_interPolySeed{i} = unique(interP); end % % test % for i = 1 : ncvt % figure(4); clf % voronoi(seeds(:,1), seeds(:,2)); hold on; % scatter(seeds(i,1), seeds(i,2), 'filled'); hold on; % % pid = c_interPolySeed{i}; % for j = 1:length(pid) % pgon = c_poly{pid(j)}; % plot(polyshape(pgon)); hold on; % end % end end