You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
3.1 KiB
91 lines
3.1 KiB
3 years ago
|
%--------------------------
|
||
|
% @Author: Jingqiao Hu
|
||
|
% @Date: 2022-01-08 22:27:37
|
||
|
% @LastEditTime: 2022-01-29 15:30:40
|
||
|
|
||
|
% c_interPolyMMC: the intersected polygon for each mmc
|
||
|
% c_interPolySeed: the intersected polygon for each seed
|
||
|
% each mmc is simplified as a segment
|
||
|
%--------------------------
|
||
|
function [c_interPolySeed] = do_intersection(vedges, c_polyMesh, c_nnbEdgeIDX, seeds)
|
||
|
|
||
|
ncvt = size(c_polyMesh, 1);
|
||
|
npnts = size(seeds, 1);
|
||
|
|
||
|
% computer the intersected-idx of each polytope-cell for each MMC
|
||
|
c_interPolyMMC = cell(ncvt, 1);
|
||
|
for i = 1 : size(vedges, 1)
|
||
|
|
||
|
p1 = vedges(i,1:3);
|
||
|
p2 = vedges(i,4:6);
|
||
|
|
||
|
interP = zeros(ncvt, 2);
|
||
|
interP(:,2) = 1:ncvt;
|
||
|
|
||
|
parfor j = 1 : ncvt
|
||
|
pnts = c_polyMesh{j};
|
||
|
intersect = TriangleRayIntersection(p1, p2, pnts(:, 1:3), pnts(:,4:6), pnts(:,7:9), ...
|
||
|
'lineType' , 'segment', 'border', 'inclusive' );
|
||
|
|
||
|
if sum(intersect) > 0
|
||
|
interP(j, 1) = 1;
|
||
|
end
|
||
|
end
|
||
|
c_interPolyMMC{i} = interP(interP(:,1) > 0, 2);
|
||
|
|
||
|
% % test
|
||
|
% figure(1); clf
|
||
|
% x = vedges(:,[1,4]);
|
||
|
% y = vedges(:,[2,5]);
|
||
|
% z = vedges(:,[3,6]);
|
||
|
% plot3(x',y',z','LineWidth',1, 'Color','k'); hold on;
|
||
|
% segs = vedges(i, :);
|
||
|
% x = segs(:,[1,4]);
|
||
|
% y = segs(:,[2,5]);
|
||
|
% z = segs(:,[3,6]);
|
||
|
% plot3(x',y',z','LineWidth',2); hold on; axis equal;
|
||
|
% idx = c_interPolyMMC{i};
|
||
|
% for j = 1:length(idx)
|
||
|
% verts = c_polyMesh{idx(j)};
|
||
|
% scatter3( verts(:,1), verts(:,2), verts(:,3), 'filled'); hold on;
|
||
|
% scatter3( verts(:,4), verts(:,5), verts(:,6), 'filled'); hold on;
|
||
|
% scatter3( verts(:,7), verts(:,8), verts(:,9), 'filled'); hold on;
|
||
|
% end
|
||
|
|
||
|
end
|
||
|
|
||
|
% compute the intersected-idx of each polygon-cell for each seed
|
||
|
c_interPolySeed = cell(npnts, 1);
|
||
|
parfor i = 1 : npnts
|
||
|
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(1); clf
|
||
|
% x = vedges(:,[1,4]);
|
||
|
% y = vedges(:,[2,5]);
|
||
|
% z = vedges(:,[3,6]);
|
||
|
% plot3(x',y',z','LineWidth',1, 'Color','k'); hold on;
|
||
|
%
|
||
|
% pid = c_interPolySeed{i};
|
||
|
% for j = 1:length(pid)
|
||
|
% verts = c_polyMesh{pid(j)};
|
||
|
% scatter3( verts(:,1), verts(:,2), verts(:,3), 'filled', 'k'); hold on;
|
||
|
% scatter3( verts(:,4), verts(:,5), verts(:,6), 'filled', 'k'); hold on;
|
||
|
% scatter3( verts(:,7), verts(:,8), verts(:,9), 'filled', 'k'); hold on;
|
||
|
% end
|
||
|
% scatter3(seeds(i,1), seeds(i,2),seeds(i,3), 'filled', 'r'); hold on;
|
||
|
% end
|
||
|
end
|