How to create volume out of surfaces?

I got these two surfaces from isosurface plot, thus I have all the coordinates of these surfaces. I would like to fill in between the two surface to create a 3d solid part. How can I do that?

답변 (2개)

darova
darova 2021년 6월 7일

0 개 추천

Your object looks symmetrical. Try manually to create surface
p1 = isosurface(...);
p2 = isosurface(...);
v1 = p1.vertices;
v2 = p2.vertices;
ix1 = v1(:,3) > (max(v1(:,3))-0.05); % find z coord of boundary
ix2 = v2(:,3) > (max(v2(:,3))-0.05); % find z coord of boundary
[t1,r1] = cart2pol(v1(:,1),v1(:,2)); % extract data first contour
[t2,r2] = cart2pol(v2(:,1),v2(:,2)); % extract data second contour
ind1 = sort(t1); % order points counter clockwise
ind2 = sort(t2); % order points counter clockwise
% data can be of different size. Interpolate data to make the same size
r22 = interp1(t2,r2,t1); % make two contours same size as second one
x1 = v1(:,1);
y1 = v1(:,2);
z1 = v1(:,3);
[x2,y2] = pol2cart(t1,r22); % second contour
z2 = z1;
% create data for surface
X = [x1(:) x2(:)];
Y = [y1(:) y2(:)];
Z = [z1(:) z2(:)];
surf(X,Y,Z)

댓글 수: 6

Teerapong Poltue
Teerapong Poltue 2021년 6월 8일
well, I've tried this code but it turns out pretty weird. Since I would like to export this as an .stl file as a solid for futher CAD. Similar to surf2solid, but solid between the 2 surfaces.
darova
darova 2021년 6월 8일
Please upload the data for experiments
What about this?
s = load('data.mat');
p1 = s.co{1};
p2 = s.co{2};
v1 = p1.vertices;
v2 = p2.vertices;
ix1 = v1(:,3) > (max(v1(:,3))-0.1); % find z coord of boundary
ix2 = v2(:,3) > (max(v2(:,3))-0.1); % find z coord of boundary
v11 = v1(ix1,:);
v22 = v2(ix2,:);
[t1,r1] = cart2pol(v11(:,1),v11(:,2)); % extract data first contour
[t2,r2] = cart2pol(v22(:,1),v22(:,2)); % extract data second contour
% order points counter clockwise
[t1s,ind1] = sort(t1);
[t2s,ind2] = sort(t2);
r1s = r1(ind1);
r2s = r2(ind2);
% there are repeated values. Select unique only
[t1u,i1] = unique(t1s);
[t2u,i2] = unique(t2s);
r1u = r1s(i1);
r2u = r2s(i2);
% make closed contour
t1u(end+1) = t1u(1)+2*pi;
t2u(end+1) = t2u(1)+2*pi;
r1u(end+1) = r1u(1);
r2u(end+1) = r2u(1);
% Interpolate data to make the same size
t11 = linspace(min(t1u),max(t1u),30);
t22 = linspace(min(t2u),max(t2u),30);
r11 = interp1(t1u,r1u,t11);
r22 = interp1(t2u,r2u,t22);
% get cartesian coordinates
[x1,y1] = pol2cart(t11,r11);
[x2,y2] = pol2cart(t11,r22);
z1 = max(v1(:,3)) + x1*0;
z2 = z1;
% create data for surface
X = [x1(:) x2(:)];
Y = [y1(:) y2(:)];
Z = [z1(:) z2(:)];
surface(X,Y,Z)
patch(p1,'facecolor','red')
patch(p2,'facecolor','green')
view(45,45)
Teerapong Poltue
Teerapong Poltue 2021년 6월 9일
Well the space between two surfaces still being a void space, I would like to fill that with solid.
darova
darova 2021년 6월 9일
Maybe look into alphaShape

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

DGM
DGM 2025년 7월 11일

0 개 추천

Here are two examples of using isosurface() and isocaps() to assemble a closed triangulated surface describing a solid.
If the expectation is that the representation is somehow supposed to be a solid, then one needs to ask what's meant by "fill with solid", and why that's necessary. The given examples are sufficient to establish a solid model for the PDE toolbox tools. At that point, you can mesh it however you want. If all you need to do is feed it to CAD/CAM software, then all you need is a closed surface.

질문:

2021년 6월 7일

답변:

DGM
2025년 7월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by