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.
80 lines
2.3 KiB
80 lines
2.3 KiB
%--------------------------
|
|
% @Author: Jingqiao Hu
|
|
% @Date: 2021-12-28 21:34:40
|
|
% @LastEditTime: 2022-05-09 21:13:55
|
|
|
|
% the mesh and MMCs are independent,
|
|
% which means the MMCs is moving and the mesh remains unchanged
|
|
% c_interPolySeed: the intersected polytope for each seed
|
|
%--------------------------
|
|
function [c_rho, c_phi] = projection_independent(c_nodes, c_tets, ...
|
|
MMCs, epsilon, c_nnbEdgeIDX, c_interPolySeed, microx)
|
|
|
|
ncvt = size(c_nodes, 1);
|
|
npnts = size(c_interPolySeed, 1);
|
|
|
|
c_phi = init_phi(ncvt, c_nodes);
|
|
c_rho = cell(ncvt, 1);
|
|
|
|
for i = 1 : npnts
|
|
pid = c_interPolySeed{i};
|
|
mid = c_nnbEdgeIDX{i};
|
|
|
|
for j = 1 : length(mid)
|
|
mmc = MMCs(mid(j), :);
|
|
t = mmc(1);
|
|
sp = mmc(2:4);
|
|
ep = mmc(5:7);
|
|
|
|
for k = 1 : length(pid)
|
|
ele = pid(k);
|
|
nodes = c_nodes{ele};
|
|
|
|
phi = signed_distance(nodes, sp, ep, t);
|
|
c_phi{ele} = max(phi, c_phi{ele});
|
|
end
|
|
end
|
|
end
|
|
|
|
% figure; camlight;lighting gouraud
|
|
|
|
% Heaviside
|
|
parfor ele = 1 : ncvt
|
|
H = Heaviside_simply(c_phi{ele}, epsilon);
|
|
|
|
% FF = reshape(c_phi{ele}, microx+1, microx+1, microx+1);
|
|
% x = c_nodes{ele}(:,1);
|
|
% y = c_nodes{ele}(:,2);
|
|
% z = c_nodes{ele}(:,3);
|
|
% x = reshape(x, microx+1,microx+1, microx+1);
|
|
% y = reshape(y, microx+1,microx+1, microx+1);
|
|
% z = reshape(z, microx+1,microx+1, microx+1);
|
|
% % [faces,verts] = isosurface(x,y,z,phi,0);
|
|
%
|
|
% p=patch(isosurface(x,y,z,FF,0));
|
|
% set(p,'facecolor','[0.8 0.4 0.4]','edgecolor','none');
|
|
% p=patch(isocaps(x,y,z,FF,0,'FaceColor','red'));
|
|
% set(p,'facecolor','[0.8 0.4 0.4]','edgecolor','none');
|
|
% view([10 25])
|
|
% axis equal; axis tight;
|
|
% xlabel('x axis');
|
|
% ylabel('y axis');
|
|
% zlabel('z axis');
|
|
% hold on;
|
|
|
|
|
|
% sum(c_rho{ele} > 0.1)
|
|
|
|
faces = c_tets{ele};
|
|
c_rho{ele} = sum(H(faces), 2) / size(faces,2);
|
|
|
|
% sum(c_rho{ele} > 0.5)
|
|
end
|
|
end
|
|
|
|
function phi_cell = init_phi(ncvt, c_nodes)
|
|
phi_cell = cell(ncvt, 1);
|
|
parfor ele = 1:ncvt
|
|
phi_cell{ele} = repmat(-1e5, size(c_nodes{ele}, 1), 1);
|
|
end
|
|
end
|