How could I generate several ellipsoids in a single stl file

11 views (last 30 days)
I try to generate stl file of single ellipsoid mainly by following steps:
  1. Input ellipsoid parameters via ''ellipsoid'' function.
  2. Create surface and convert to patch sturcture via ''surf2patch''
  3. Extract faces and vertices in patch sturcture.
  4. Build triangulation and correspond alphaShape
  5. Extract boundary faces of alphaShape and establish an new set of sriangulation.
  6. Export stl file via ''stlwrite'' function.
Hwoever, now I would like to export a stl file which contains several ellipsoids without overlapping.
The first step for me is to generate two ellipsoids in one stl file.
The second ellipsoid is generated and plotted with the first ellipsoid in the same figure.
But I do not know how to export them in the same stl file.
Would anyone gives me some hints or suggestions?
Thanks a lot.
Attached is the code.
clear
clc
close all
%input the properties of ellipsoid by ''ellipsoid'' function
[x, y, z] = ellipsoid(1,1,1,5,3,3);
%Convert the ellipsoid to surface via ''surf''
s=surf(x,y,z)
%from surface to patch: generate the faces and vertices
p=surf2patch(s)
%Extract faces and vertices from structure p
pf=p.faces
pv=p.vertices
tr=triangulation(pf,pv)
sha=alphaShape(tr.Points)
%Using larger sha.Alpha to imprive the quality of mesh
sha.Alpha=5
%Extract boundary face of alphaShape
[F,P]=boundaryFacets(sha)
%New set of triangulation
Newtr=triangulation(F,P)
%Second ellipsoid
%input the properties of ellipsoid by ''ellipsoid'' function
[x1, y1, z1] = ellipsoid(7,7,7,5,3,3);
%Convert the ellipsoid to surface via ''surf''
s1=surf(x1,y1,z1)
%from surface to patch: generate the faces and vertices
p1=surf2patch(s1)
%Extract faces and vertices from structure p
pf1=p1.faces
pv1=p1.vertices
tr1=triangulation(pf1,pv1)
sha1=alphaShape(tr1.Points)
%Using larger sha.Alpha to imprive the quality of mesh
sha1.Alpha=5
%Extract boundary face of alphaShape
[F1,P1]=boundaryFacets(sha1)
%New set of triangulation
Newtr1=triangulation(F1,P1)
%Plotting both ellipsoids in one figure
hold on
plot(sha)
plot(sha1)
%export stl
%stlwrite(tr_c,'two_ell.stl')
I think I sould probably focus on ''How to merge two sets of triangulation in single set'' or ''How to creat an alphaShape contains several objects'', but I don't know how could I do so.
Sincerely and merry christmas.
  5 Comments
Daniel Chou
Daniel Chou on 15 Jun 2022
@Ju Lia have you solved your problem?
In case you want me to help you more
My email: dchou9@gatech.edu
Sincerely

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by