How to merge 2 different 3-D surface patch objects (Faces & Vertices) in 1 patch object with ONLY the outside surface (inside points removed)

7 Ansichten (letzte 30 Tage)
Hello,
Considering two patch objects fv1 & fv2 that are closed and intersect partially, is there a way to create a fv3 that is the merging results of fv1+fv2 ? I do not want to do it only graphically (patch(fv1);patch(fv2)) but really get the new fv3.faces & fv3.vertices of the external envelope, removing vertices that would be "inside the solid" and creating new that would be at the intersection of external faces.
Please find here below the code to illustrate the problem. Thank you in advance, André
fv1.vertices = [0,0,0;1,0,0;1,1,0;0,1,0;0,0,1;1,0,1;1,1,1;0,1,1];
fv1.faces = [1,2,6;1,6,5;2,3,7;2,7,6;3,4,8;3,8,7;4,1,5;4,5,8;1,2,3;1,3,4;5,6,7;5,7,8];
fv2.vertices = [0,0,0;0.7,0.5,-0.5;0.2,1.3,-0.3;-0.5,0.85,0.15;0.5,0.15,0.85;1.2,0.65,0.35;0.7,1.5,0.5;0,1,1];
fv2.faces = [1,2,6;1,6,5;2,3,7;2,7,6;3,4,8;3,8,7;4,1,5;4,5,8;1,2,3;1,3,4;5,6,7;5,7,8];
figure(1)
h1 = patch(fv1,'FaceVertexCData',hsv(12),'FaceColor','flat');
h2 = patch(fv2,'FaceVertexCData',hsv(12),'FaceColor','flat');
figure(2)
fv3.vertices = [fv1.vertices;fv2.vertices];
fv3.faces = [fv1.faces;fv2.faces+length(fv1.vertices)]
h3 = patch(fv3,'FaceVertexCData',hsv(24),'FaceColor','flat');
% Comment: here I still have the internal vertices, not really the envelope
figure(3)
fv4=reducepatch(fv3);
patch(fv4,'FaceVertexCData',hsv(8),'FaceColor','flat')
% Comment: reduce patch doesn't solve the problem correctly.

Antworten (1)

Johannes Korsawe
Johannes Korsawe am 19 Sep. 2013
Not an answer, but a comment.
I also tried to solve this problem with several steps:
1. Determine the inside/outside points of the two volumes wrt each other (use intriangulation from the FEX.)
2. Determine if null, one, two or three indices of a triangle of set A is inside set B and vice versa.
3. The one/two-index triangles can be used to form a free boundary of the two volumes which now has to be connected in some way.
4. I tried to connect the two boundaries directly in a way that no additional points were produced. This is only an approximate solution, as no intersections between triangles would be calculated. But i failed in a clear algorithm to so either.
5. If you want to be clear, you need to determine out of the respective sets, which triangel has some intersection with the next and calculate the intersecting points, combine them with the free boundary and voila.
This problem shows very many special cases in connecting the free boundaries in either way if you take a closer look. No easy solution to be expected.
Just my two cents.
Johannes

Community Treasure Hunt

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

Start Hunting!

Translated by