Consider the following answer by the writer of pgfplots, Christian Feuersänger, for drawing a 3d object in LaTeX.
The problem I am facing now is how to convert a STL
file to such a collection of dat
files.
I am positive Mathematica can do that. But I need some help.
I imported a sample STL part and looked at its FullForm
:
Import["ExampleData/seashell.stl"]//FullForm
It is actually a MeshRegion
:
MeshRegion[
{
{-0.4408000111579895`, -0.010666999965906143`,
0.01866699941456318`}, {-0.2808000147342682`, 0.02133299969136715`,
0.01866699941456318`}, etc.
},
{Polygon[{
{1,2,3},{1,3,4},{2,5,6},{2,6,3},{5,7,8}, etc.
}]
]
If I understand correctly, the dat
file should be composed of 3 different files:
- facetIdx.dat (facet index file?)
- patches.dat (each row is one vertex; three (or four) consecutive vertices make one facet (patch))
- vertices.dat (every row is a xyz coordinate of a vertix?)
Sample files, specifically the one used in the answer linked above, can be found here.
(You can get a meaningful plot by working with only one file)
I am not 100% understand what is the syntax of the dat
files.
Does anyone have any experience with such files?
How can Mathematica generate such dat files?