Professional Documents
Culture Documents
ECE5322
21st CenturyElectromagnetics
Instructor:
Office:
Phone:
EMail:
Dr.Raymond C.Rumpf
A337
(915)7476958
rcrumpf@utep.edu
Lecture #19
Lecture Outline
STL Files
File format description
Problems and repairing
MATLAB Topics
CAD Topics
Lecture19
3/17/2016
Slide4
3/17/2016
Surface Mesh
Despitethisspherereallybeingasolidobject,itisrepresentedinan
STLfilebyjustitssurface.
SolidObject
STLRepresentation
Lecture19
Thissetoftextisrepeatedforeverytriangleonthe
surfaceoftheobject.
v v v3 v1
n 2 1
v2 v1 v3 v1
v2
v1
v3
Bold face indicates a keyword; these must appear in lower case. Note that there is a space in facet normal and in
outer loop, while there is no space in any of the keywords beginning with end. Indentation must be with spaces;
tabs are not allowed. The notation, {}+, means that the contents of the brace brackets can be repeated one or
more times. Symbols in italics are variables which are to be replaced with user-specified values. The numerical data
in the facet normal and vertex lines are single precision floats, for example, 1.23456E+789. A facet normal
coordinate may have a leading minus sign; a vertex coordinate may not.
Lecture19
3/17/2016
AnSTLfileisessentiallyjusta
listofallthetrianglesonthe
surfaceofanobject.
Eachtriangleisdefinedwitha
surfacenormalandthe
positionofthethreevertices.
Lecture19
Slide7
A Single Triangle
facet normal -8.281842e-001 2.923717e-001 -4.781524e-001
outer loop
vertex 4.323172e-018 1.632799e-017 6.495190e-001
vertex 3.750000e-001 7.081604e-001 4.330127e-001
vertex 3.750000e-001 0.000000e+000 0.000000e+000
endloop
endfacet
1. Facetnormalmustfollowrighthand
ruleandpointoutwardfromobject.
a) Someprogramssetthisto[0;0;0]
orconveyshadinginformation.
b) Dontdependonit!
2. Adjacenttrianglesmusthavetwo
commonvertices.
3. STLfilesappeartobesetuptohandle
arbitrarypolygons.Dontdothis.
Lecture19
Vertex3
FacetNormal
Vertex1
Vertex2
Slide8
3/17/2016
Lecture19
STL File
Problems and
Repairing
3/17/2016
Inverted Normals
Allsurfacenormals shouldpointoutwards.
Good
Bad
http://admproductdesign.com/workshop/3dprinting/definitionofstlerrors.html
Lecture19
11
Intersecting Triangles
Nofacesshouldcutthrougheachother.Intersectionsshouldbe
removed.
http://admproductdesign.com/workshop/3dprinting/definitionofstlerrors.html
Lecture19
12
3/17/2016
Noise Shells
Ashellisacollectionoftrianglesthatformasingleindependent
object.SomeSTLfilesmaycontainsmallshellsthatarejustnoise.
Theseshouldbeeliminated.
Mainshell
NoiseShell
Lecture19
13
Nonmanifold Meshes
Amanifold(i.e.watertight)meshhasnoholesandisdescribedbya
singlecontinuoussurface.
http://http://www.autodesk.com/
Lecture19
14
3/17/2016
Slide15
Importing and
Exporting STL
Files in MATLAB
3/17/2016
Lecture19
17
Lecture19
18
3/17/2016
vx , M
v y ,1
v y ,2
vy ,M
vz ,1
vz ,2
vz , M
V isanarray
containingthe
positionofallthe
verticesinCartesian
coordinates.
5
8
2
M isthetotal
numberof
1
vertices.
7
11
3
12
10
Lecture19
19
2,5,8
SolidWorks exportsalazyarrayofvertices.
vx ,1
v
x ,2
V
vx , M
Lecture19
v y ,1
v y ,2
vy,M
vz ,1
vz ,2
vz , M
4,9,11
1,6,12
3,7,10
20
10
3/17/2016
vx ,4
vz ,1
vz ,2
vz ,3
vz ,4
v y ,1
v y ,2
v y ,3
v y ,4
2
2
2
2
ArrayofVertices,V
4
4
3
3
4
3
1
Lecture19
21
Array of Faces
n1,1
n
2,1
F
nN ,1
n1,2
n2,2
nN ,2
n1,3
n2,3
nN ,3
F isanarray
indicatingthearray
indicesofthe
verticesdefining
thefacet.
5
allintegers
8
2
9
4
N isthetotal
numberof
faces.
Lecture19
3
11
3
12
10
22
11
3/17/2016
2,5,8
4,9,11
1,6,12
3,7,10
Lecture19
23
4
1
3
Thiscanmakeaverylargedifferenceforlargeandcomplexobjects.
Lecture19
24
12
3/17/2016
OrientationinSolidWorks
ImportedOrientation
AdjustedOrientation
Lecture19
25
Visualizing
Surface Meshes
in MATLAB
13
3/17/2016
Lecture19
27
Generating
Faces and
Vertices Using
MATLAB
14
3/17/2016
MATLAB Surfaces
SurfacescomposedofsquarefacetsarestoredinX,Y,andZ arrays.
Thesurfaceshownisconstructed
ofarraysthatareall55.
Lecture19
29
Surfacescanbeconvertedtotriangularpatches(facetsandvertices)
usingthesurf2patch() function.
% CONVERT TO PATCH
[F,V] = surf2patch(X,Y,Z,triangles);
Thefacesandverticescanbedirectlyvisualizedusingthepatch()
function.
% VISUALIZE FACES AND VERTICES
h = patch('faces',F,'vertices',V);
set(h,'FaceColor',[0.5 0.5 0.8],'EdgeColor','k');
Lecture19
30
15
3/17/2016
Objecton3DGrid
SurfaceMesh
Lecture19
31
isocaps()
isosurface()
+ isocaps()
32
16
3/17/2016
F2 andV2
Correctly
Combined
Incorrectly
Combined
% WRONG WAY TO
% COMBINE FACES AND VERTICES
F3 = [ F1 ; F2 ]
V3 = [ V1 ; V2 ]
Lecture19
33
Converting
Surface Meshes
to Objects on a
3D Grid
17
3/17/2016
Example Pyramid
ER(nx,ny,nz)
SolidWorks Model
Lecture19
ImportSTLintoMATLAB
ConverttoVolumeObject
35
Example Dinosaur
ER(nx,ny,nz)
ImportSTLintoMATLAB
Lecture19
ConverttoVolumeObject
36
18
3/17/2016
Lecture19
37
Converting
Images and 2D
Objects to STL
19
3/17/2016
% RESIZE IMAGE
B = imresize(B,0.2);
[Nx,Ny,Nc] = size(B);
Thiswillgiveusacoarsermeshinorder
tobefasterandmorememoryefficient.
Lecture19
39
%
B
B
B
Lecture19
40
20
3/17/2016
% STACK IMAGE
B(:,:,2) = B;
Lecture19
41
Weonlywishtomeshasinglesurfacesowegive
isocaps(),theadditionalinputargument
zmintodothis.
% CREATE 2D MESH
[F,V] = isocaps(ya,xa,[0 1],B,0.5,'zmin');
Lecture19
42
21
3/17/2016
Lecture19
43
Lecture19
44
22
3/17/2016
Lecture19
45
Point Clouds
23
3/17/2016
PointCloudDescriptionofaKleinBottle
PointcloudsrepresenttheoutsidesurfaceofobjectasasetofverticesdefinedbyX,Y,andZ
coordinates.Theyaretypicallygeneratedby3Dscanners,butcanalsobeusedtoexport3D
objectsfromMATLABintoSolidWorks orotherCADprograms.
Lecture19
47
Lecture19
48
24
3/17/2016
xN
PC =
0.1200
0.1159
0.0311
0.0000
-0.0311
-0.0600
y1
y2
y3
yN
0.0000
-0.0311
-0.1159
-0.1200
-0.1159
-0.1039
z1
z2
z3
z N
0.7071
0.7071
0.7071
0.7071
0.7071
0.7071
Lecture19
49
PC = [ X Y Z ];
Lecture19
PC = [ X Z Y ];
50
25
3/17/2016
Lecture19
51
Lecture19
52
26
3/17/2016
Lecture19
53
Lecture19
1.
2.
3.
4.
RuntheMeshPrepWizard.
Selectthepointcloud.
Clicktherightarraybutton.
Orientationmethod,selectNone
becausewedidthisinMATLAB.
5. Noiseremoval,zeroassuming
geometrycamefromMATLAB.
6. Workthroughalloptions.
7. Clickthegreencheckmarktofinish.
54
27
3/17/2016
Lecture19
55
Lecture19
56
28
3/17/2016
Importing
Custom
Polygons into
SolidWorks
The Problem
Supposewecalculatetheverticesofapolygonfromanoptimization
inMATLAB.
Howdoweimportantthe
verticessothatthepolygon
canbeimportedexactlyinto
Solidworks sothatitcanbe
extruded,cut,modified,etc.?
Thereisnofeaturein
SolidWorks todothis!!
Lecture19
58
29
3/17/2016
Example Application
PlacingaGMRfilteronto
acurvedsurface.
Gratingperiodisspatially
variedtocompensate.
sin x R
x
tan 1
R
1 d R cos x R
K x K 0 k0 ninc sin inc x
inc x
x K x dx
0
r x
r
cos x cos f
cos x cos f
R.C.Rumpf,M.Gates,C.L.Kozikowski,W.A.Davis,
"GuidedModeResonanceFilterCompensatedtoOperate
onaCurvedSurface,"PIERC,Vol.40,pp.93103,2013.
Lecture19
59
Thisshouldbeasquare!
Lecture19
Thefourpointsarefittoaspline!
60
30
3/17/2016
0
0.3758
1.0452
0.5573
1.8765
0.7853
1.1984
0.5240
0.4822
0.1664
-0.1517
-0.5774
-1.2777
-1.2314
-1.6931
-1.5074
-1.1927
-0.6455
-0.3766
-0.0000
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
Lecture19
61
Thiscreatesafilecalledpoly.igsinyourworkingdirectory.
Lecture19
62
31
3/17/2016
Lecture19
63
Openthefile.
Lecture19
64
32
3/17/2016
Lecture19
65
Lecture19
66
33
3/17/2016
Lecture19
67
STL to CAD
Conversion
34
3/17/2016
Lecture19
69
Openmeshlab.exe.
File ExportMeshAs
SelectDXFfiletype.
Savemesh.
LaunchSolidWorks.
File Open
SelectDXFfile.
SelectImporttoanewpartas:
then3Dcurvesormodel
thenNext>.
9. SelectAllLayers
Lecture19
70
35