Hi, I want to how can we convert the contour geometry to stl file?
46 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
ArxIv
il 26 Ott 2024 alle 12:14
Commentato: Star Strider
il 29 Ott 2024 alle 13:49
Hello,
I would like to know how can we convert 2D-geometry I obtained from isocontour of the signed distance function to stl.file.
This is because I want to generate triangular mesh for the inside of the isocontour using "generateMesh" function.
For example, I need to mesh the inside of the circular domain shown in contour.png. The isocontour is plottted using the code below.
Plus, I would be happy if you could inform me how to conduct this meshing without stl.file.
clc; clear; close all;
% Generating simple SDF
[x, y] = meshgrid(linspace(-2, 2, 100), linspace(-2, 2, 100));
sdf = sqrt(x.^2 + y.^2) - 1;
% Extracting 0-level isocontour of the SDF.
isoValue = 0;
contour(x(1,:), y(:,1), sdf, [isoValue isoValue]);
0 Commenti
Risposta accettata
Star Strider
il 26 Ott 2024 alle 14:27
Try something like this —
% clc; clear; close all;
% Generating simple SDF
[x, y] = meshgrid(linspace(-2, 2, 100), linspace(-2, 2, 100));
sdf = sqrt(x.^2 + y.^2) - 1;
% Extracting 0-level isocontour of the SDF.
isoValue = 0;
c = contour(x(1,:), y(:,1), sdf, [isoValue isoValue]);
axis('equal')
x = c(1,2:end).'; % First Row Of ‘c’ Are The ‘X’ Coordinates, Delete The First Element From Each
y = c(2,2:end).'; % Second Row Of ‘c’ Are The ‘Y’ Coordinates, Delete The First Element From Each
DT = delaunay(x,y); % Delaunay Triangulation
figure
triplot(DT, x, y) % Plot Result
axis('equal','padded')
TR = triangulation(DT,x,y); % Create ‘triangulation’ Object
stlwrite(TR, 'STL_Test.stl', 'text') % Write Triangulation Object To STL File
TRr = stlread('STL_Test.stl') % Check: Read Triangulation Object From STL File
boundaryEdges = freeBoundary(TRr).'; % Get Boundary Edges
figure
triplot(TRr) % Plot ‘triangulation’ Objeect
hold on
plot(TRr.Points(boundaryEdges,1), TRr.Points(boundaryEdges,2), '-r', 'LineWidth',2) % Plot Boundary
hold off
axis('equal','padded')
.
4 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Triangulation Representation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!