@@ -6,6 +6,8 @@ the Stanford triangle format.
6
6
7
7
## Quick start
8
8
9
+ ### Writing ply
10
+
9
11
Here's an example of how to write a basic ply file containing random triangles
10
12
and edges:
11
13
42
44
push! (ply, PlyElement (" edge" , vertex_index))
43
45
44
46
# For the sake of the example, ascii format is used, the default binary mode is faster.
45
- save_ply (ply, " test .ply" , ascii= true )
47
+ save_ply (ply, " example1 .ply" , ascii= true )
46
48
```
47
49
48
50
Opening this file using a program like
49
- [ displaz] ( https://github.com/c42f/displaz ) , for example using ` displaz test .ply ` ,
51
+ [ displaz] ( https://github.com/c42f/displaz ) , for example using ` displaz example1 .ply ` ,
50
52
you should see something like
51
53
52
54
![ Example one] ( doc/example1.png )
53
55
54
- ## The file format
55
56
56
- In the abstract, the ply format is a container for a set of named tables of
57
- numeric data. Each table, or ** element** , has several named columns or
58
- ** properties** . Properties can be either simple numeric values (floating point
59
- or signed/unsigned integers), or variable length lists of such numeric values.
57
+ ### Reading ply
58
+
59
+ Reading the ply file generated above is quite simple:
60
+
61
+ ``` julia
62
+ julia> using PlyIO
63
+
64
+ julia> ply = load_ply (" example1.ply" )
65
+ PlyIO. Ply with header:
66
+ ply
67
+ format ascii 1.0
68
+ comment An example ply file
69
+ element vertex 1000
70
+ property float64 x
71
+ property float64 y
72
+ property float64 z
73
+ property float64 r
74
+ property float64 g
75
+ property float64 b
76
+ element face 1000
77
+ property list int32 int32 vertex_index
78
+ element edge 1000
79
+ property list int32 int32 vertex_index
80
+ end_header
81
+
82
+ julia> ply[" vertex" ]
83
+ PlyElement " vertex" of length 1000 with properties [" x" , " y" , " z" , " r" , " g" , " b" ]
84
+
85
+ julia> ply[" vertex" ][" x" ]
86
+ 1000 - element PlyIO. ArrayProperty{Float64,String} " x" :
87
+ - 0.472592
88
+ 1.04326
89
+ - 0.982202
90
+ ⋮
91
+ - 2.55605
92
+ 0.773923
93
+ - 2.10675
94
+ ```
95
+
96
+ ## API
97
+
98
+ ### The file format
99
+
100
+ Conceptually, the ply format is a container for a set of named tables of numeric
101
+ data. Each table, or ** element** , has several named columns or ** properties** .
102
+ Properties can be either simple numeric arrays (floating point or
103
+ signed/unsigned integers), or arrays of variable length lists of such numeric
104
+ values.
105
+
106
+ As described, ply is quite a generic format but it's primarily used for
107
+ geometric data. For this use there are some loose
108
+ [ naming conventions] ( http://paulbourke.net/dataformats/ply/ ) which attach
109
+ geometric meaning to certian combinations of element and property names.
110
+ Unfortunately there's no official standard.
111
+
112
+ ### Document object model
113
+
114
+ Ply elements are represented with the ` PlyElement ` type which is a list of
115
+ properties which may be looked up by name.
116
+
117
+ Properties may be represented by an ` AbstractArray ` type which has the the
118
+ ` plyname ` function defined, which should return a name for the property. The
119
+ builtin types ` ArrayProperty ` and ` ListProperty ` are used as containers for data
120
+ when reading a ply file.
121
+
122
+ The ` Ply ` type is a container for several interleaved ` PlyElement ` and
123
+ ` PlyComment ` fields, in the order which would be observed in a standard ply
124
+ header.
125
+
126
+ ### Reading and writing
60
127
61
- For geometric data, there are some loose
62
- [ naming conventions] ( http://paulbourke.net/dataformats/ply/ ) . Unfortunately
63
- there's no official standard.
128
+ To read and write ` Ply ` objects from files or ` IO ` streams, use the functions
129
+ ` load_ply() ` and ` save_ply() ` .
0 commit comments