Hi, I want to how can we convert the contour geometry to stl file?

46 visualizaciones (últimos 30 días)
ArxIv
ArxIv el 26 de Oct. de 2024 a las 12:14
Comentada: Star Strider el 29 de Oct. de 2024 a las 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]);

Respuesta aceptada

Star Strider
Star Strider el 26 de Oct. de 2024 a las 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
Warning: Duplicate data points have been detected and removed.
Some point indices will not be referenced by the triangulation.
DT = 198×3
74 71 65 26 24 37 15 46 24 65 62 61 196 96 15 115 108 107 78 76 83 96 196 115 165 196 174 15 21 18
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
figure
triplot(DT, x, y) % Plot Result
axis('equal','padded')
TR = triangulation(DT,x,y); % Create ‘triangulation’ Object
Warning: Some input points are not referenced by the triangulation.
TR =
triangulation with properties: Points: [201x2 double] ConnectivityList: [198x3 double]
stlwrite(TR, 'STL_Test.stl', 'text') % Write Triangulation Object To STL File
TRr = stlread('STL_Test.stl') % Check: Read Triangulation Object From STL File
TRr =
triangulation with properties: Points: [200x3 double] ConnectivityList: [198x3 double]
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 comentarios
ArxIv
ArxIv el 29 de Oct. de 2024 a las 13:04
Thank you for your help.
I really appreciate it!
Star Strider
Star Strider el 29 de Oct. de 2024 a las 13:49
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Triangulation Representation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by