I understand that you are trying to combine two STL geometries into a single geometry by merging their nodes and faces in MATLAB, you can follow these steps:
- Read the STL files to get the nodes and faces.
- Merge the nodes and faces from both geometries.
- Write the combined geometry to a new STL file.
Below is a MATLAB script that demonstrates how to do this:
% Read the STL files
fv1 = stlread('../sol/sol_1.stl');
fv2 = stlread('../sol/sol_2.stl');
% Extract nodes (vertices) and faces from the first geometry
nodes1 = fv1.Points;
faces1 = fv1.ConnectivityList;
% Extract nodes (vertices) and faces from the second geometry
nodes2 = fv2.Points;
faces2 = fv2.ConnectivityList;
% Merge nodes
% Note: We need to adjust the face indices of the second geometry
% by adding the number of nodes in the first geometry
% Combine nodes
combinedNodes = [nodes1; nodes2];
% Adjust face indices for the second geometry
adjustedFaces2 = faces2 + size(nodes1, 1);
% Combine faces
combinedFaces = [faces1; adjustedFaces2];
% Create a new triangulation object for the combined geometry
combinedGeometry = triangulation(combinedFaces, combinedNodes);
% Write the combined geometry to a new STL file
stlwrite(combinedGeometry, 'combined_geometry.stl');
I hope this helps.