Patch: Problem using FaceVertexAlphaData to control face visibility

조회 수: 6 (최근 30일)
Eva
Eva 2024년 1월 23일
답변: Eva 2024년 1월 25일
Hello!
As part of a larger topology optimization algotihm i have written a plot function. This plot function visualizes a 3D matrix containing values between 0-1. Where each value represent the 'artificial density' of a cube.
I have been using the patch function to draw the faces of the cubes. Previously i was able to use the FaceVertexAlphaData option to just plot the faces of the cubes with a density higher then 0.3.
I did not touch my code for two months, and now using it again my plotting function is not plotting the right transparency for the faces and edges anymore.
This is an example of a result i was getting previously:
And this is the result i am currently getting:
I am using r2022b and did not make any changes to my code. What could be the reason I am not getting the same result anymore? And does anyone have any suggestions how i could achieve the same result i was previously getting without the use of a loop?
Thank you very much in advance!
This is the relevant snippet of my code:
%setup face matrix
A = (0:8:(nele_L-1)*8);
B = repmat(reshape(repmat(A, 6, 1), [nele_L*6, 1]), 1, 4);
face_mat = [1 2 3 4; 2 6 7 3; 6 5 8 7; 5 1 4 8; 1 2 6 5; 4 3 7 8]; %connection table
face_full = B + repmat(face_mat, nele_L, 1);
%setup vert matrix
vert_mat = [0 0 0; d_FE_L 0 0; d_FE_L 0 -d_FE_L; 0 0 -d_FE_L;...
0 -d_FE_L 0;d_FE_L -d_FE_L 0; d_FE_L -d_FE_L -d_FE_L;0 -d_FE_L -d_FE_L];
x_mat = repmat(reshape(repmat((0:(nelx_L - 1))*d_FE_L, nelz_L*8, 1), [], 1), nely_L, 1);
y_mat = reshape(repmat((0:(nely_L-1))*d_FE_L*-1, (nelz_L*nelx_L*8), 1), [], 1);
z_mat = repmat(reshape(repmat(reshape(repmat((0:(nelz_L-1))*d_FE_L*-1, 8, 1), [], 1), 1, nelx_L), [], 1), nely_L, 1);
coords_mat = cat(2, x_mat, y_mat, z_mat);
vert_tot = coords_mat + repmat(vert_mat, nele_L, 1);
colour = repmat(reshape(repmat(reshape((1-xPhys), 1, []), 6,1), [], 1), 1, 3);
face_alpha = zeros(size(colour(:,1)));
face_alpha(colour(:,1)<=0.7) =1;
figure
view(-30, 30);
axis equal;
axis padded;
axis off;
patch('Faces',face_full,'Vertices',vert_tot, 'FaceVertexCData', colour, 'FaceVertexAlphaData', face_alpha,'FaceAlpha', 'flat', 'EdgeAlpha', 'flat', 'FaceColor','flat');
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2024년 1월 23일
"Previously i was able to use the FaceVertexAlphaData option to just plot the faces of the cubes with a density higher then 0.3."
Could you elaborate on this? Did you use a singular value as the value for the FaceVertexAlphaData argument, as opposed to using different values for each face that is done in the code above?
Eva
Eva 2024년 1월 23일
No, previously i also used a vector containing information for each face if it should be shown yes or no, as done in the code above.

댓글을 달려면 로그인하십시오.

채택된 답변

Eva
Eva 2024년 1월 25일
Update:
Saw a suggestion on a different post that suggested trying a different renderer, or that it could be a graphic driver issue. Updating the drivers solved the issue.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by