Debian Codegraph @

manual/manual.html

raw
1 <html>
2
3 <head>
4 <meta name="description" content="The RPly Homepage">
5 <meta name="keywords" content="open source, C, Library, PLY, file format,
6 input, output, tools">
7 <title>
8 RPly: ANSI C library for PLY file format input and output
9 </title>
10 <link rel="stylesheet" href="reference.css" type="text/css">
11 </head>
12
13 <body>
14
15 <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
16
17 <div class=header>
18 <hr>
19 <center>
20 <table summary="RPly logo">
21 <tr><td align=center>
22 <img border=0 alt="RPly" src="rply.png">
23 </td></tr>
24 <tr><td align=center valign=top>ANSI C Library for PLY file format input and output
25 </td></tr>
26 </table>
27 </center>
28 <hr>
29 </div>
30
31
32 <!-- Introduction +++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
33
34 <h1>Introduction</h1>
35
36 <p>RPly is a library that lets applications read and write PLY files. The
37 PLY file format is widely used to store geometric information, such as 3D
38 models, but is general enough to be useful for other purposes.
39 </p>
40
41 <p>There are other libraries out there, of course. I tried using them and
42 finally decided to write my own. The result is RPly, and I
43 hope you are as happy with it as I am. </p>
44
45 <p>RPly is easy to use, well documented, small, free,
46 open-source, ANSI C, efficient, and well tested. I will keep supporting it
47 for a while because all my tools use the library for input/output. The highlights are: </p>
48 <ul>
49 <li> A callback mechanism that makes PLY file input straightforward;
50 <li> Support for the full range of numeric formats though the user only
51 deals with doubles;
52 <li> Binary (big and little endian) and text modes are fully supported;
53 <li> Input and output are buffered for efficiency;
54 <li> Available under the
55 <a href=http://www.opensource.org/licenses/mit-license.html>MIT license</a>
56 for added freedom.
57 </ul>
58
59 <p>
60 The format was developed at <a
61 href=http://graphics.stanford.edu/data/3Dscanrep/>Stanford University</a>
62 for use with their 3D scanning projects. Greg Turk's PLY library, available
63 from <a href=http://www.cc.gatech.edu/projects/large_models>
64 Georgia Institute of Technology</a>, seems to be the standard reference
65 to the PLY file format, although there are some variations out there.
66 </p>
67
68 <p> Whatever documentation and examples were found, were taken into
69 consideration to create RPly. In theory, since RPly doesn't try to interpret
70 the meaning of the data in a PLY file, it should be able to read any PLY file.
71 In practice, the library works with all PLY files that I could find. </p>
72
73 <h2>Download</h2>
74
75 <p>
76 Version 1.1.4 of RPly is available for download in source
77 code from <a href=rply-1.1.4.tar.gz>this link</a>. Examples and documentation
78 are packed inside the tarball. Have fun!
79 </p>
80
81 <p>
82 Copyright &copy; 2003-2015 Diego Nehab. All rights reserved. <br>
83 Author: <A href="http://www.impa.br/~diego">Diego Nehab</a>
84 </p>
85
86 <h2>What's new?</h2>
87
88 <ul>
89 <li> Fixed bug that prevented reading of ASCII files that
90 are not terminated by a whitespace;
91 <li> Added <tt>ply_open_from_file</tt> and
92 <tt>ply_create_to_file</tt> variants to <tt>ply_open</tt>
93 and <tt>ply_create</tt>, respectively, that receive file
94 pointers instead of file names.
95 </ul>
96
97 <h2> RPly's idea of what a PLY file is </h2>
98
99 <p> A PLY file contains the description of one object. This object is
100 composed by <em>elements</em>, each element type
101 being defined by a group of <em>properties</em>. The PLY file
102 format specifies a syntax for the description of element types and the
103 properties that compose them, as well as comments and meta-information.
104 </p>
105
106 <p> The element type descriptions come in a header, which is followed by
107 element instances. Element instances come grouped by their type, in the
108 order of declaration. Each element instance is defined by the value
109 of its properties. Properties values also appear in the order of their
110 declaration. Here is a sample PLY file describing a triangle: </p>
111
112 <pre class=example>
113 ply
114 format ascii 1.0
115 comment this is a simple file
116 obj_info any data, in one line of free form text
117 element vertex 3
118 property float x
119 property float y
120 property float z
121 element face 1
122 property list uchar int vertex_indices
123 end_header
124 -1 0 0
125 0 1 0
126 1 0 0
127 3 0 1 2
128 </pre>
129
130 <p> The header goes from the first line to the line marked by
131 <tt>end_header</tt>. The first line contains only <tt>ply\n</tt> and is
132 used to detect whether a file is in PLY format or not (RPly
133 also accepts files that start with <tt>ply\r\n</tt>, in
134 which case the end-of-line terminator is assumed to be
135 <tt>\r\n</tt> throughout.) The second line
136 specifies the <tt>format</tt> number (which is always <tt>1.0</tt>) and the
137 storage mode (<tt>ascii</tt>, <tt>binary_big_endian</tt> or
138 <tt>binary_little_endian</tt>). </p>
139
140 <p> Lines that start with <tt>comment</tt> are just comments, of course.
141 Lines that start with <tt>obj_info</tt> contain meta-information about the
142 object. <tt>Comment</tt>s and <tt>obj_info</tt>s are optional and their
143 relative order in the header is irrelevant. </p>
144
145 <p> In the sample PLY file, the first element type is declared with name
146 <tt>vertex</tt>, and on the same line we learn that there will be 3
147 instances of this element type. The properties following describe what a
148 <tt>vertex</tt> element looks like. Each <tt>vertex</tt> is declared to
149 consist of 3 scalar properties, named <tt>x</tt>, <tt>y</tt> and
150 <tt>z</tt>. Each scalar property is declared to be of type <tt>float</tt>.
151 </p>
152
153 <p> Scalar types can be any of the following: <tt>int8</tt>,
154 <tt>uint8</tt>, <tt>int16</tt>, <tt>uint16</tt>, <tt>int32</tt>,
155 <tt>uint32</tt>, <tt>float32</tt>, <tt>float64</tt>, <tt>char</tt>,
156 <tt>uchar</tt>, <tt>short</tt>, <tt>ushort</tt>, <tt>int</tt>,
157 <tt>uint</tt>, <tt>float</tt>, <tt>double</tt>. They consist of signed
158 and unsigned integer types of sizes 8, 16 and 32 bits, as well as floating
159 point types of 32 and 64bits.
160
161 <p> Next, the <tt>face</tt> element type is declared, of which only 1
162 instance will be given. This element consists of a <tt>list</tt> property,
163 named <tt>vertex_indices</tt>. Lists are sequences on which the
164 first value, the <em>length</em>, gives the number of remaining values. List properties are described by the scalar
165 type of their length field and the scalar type of the remaining fields.
166 In the case of <tt>vertex_indices</tt>, the length field
167 is of type <tt>uchar</tt> and the remaining values are of type
168 <tt>int</tt>. </p>
169
170 <p> Following the header, come the elements, in the order they were
171 declared in the header. First come the 3 elements of type <tt>vertex</tt>,
172 each represented by the value of their properties <tt>x</tt>, <tt>y</tt>
173 and <tt>z</tt>. Then comes the single <tt>face</tt> element, composed by a
174 single list of type <tt>vertex_indices</tt> containing 3 values
175 (0 1 2).</p>
176
177 <h2> How to read a file with RPly </h2>
178
179 <p> Most users that want to read a PLY file already know which elements and
180 properties they are interested in. In the following example, we will
181 implement a simple program that dumps the contents of a PLY file to the
182 terminal, in a different, simpler format that only works for triangles.
183 </p>
184
185 <p> This simple format has a header that gives the number of vertices in the
186 first line and the number of triangles in the second line. Following the
187 header come the vertices, and finally the triangles. Here is the sample
188 code for the program:</p>
189
190 <pre class=example>
191 #include &lt;stdio.h&gt;
192 #include "rply.h"
193
194 static int vertex_cb(p_ply_argument argument) {
195 long eol;
196 ply_get_argument_user_data(argument, NULL, &amp;eol);
197 printf("%g", ply_get_argument_value(argument));
198 if (eol) printf("\n");
199 else printf(" ");
200 return 1;
201 }
202
203 static int face_cb(p_ply_argument argument) {
204 long length, value_index;
205 ply_get_argument_property(argument, NULL, &amp;length, &amp;value_index);
206 switch (value_index) {
207 case 0:
208 case 1:
209 printf("%g ", ply_get_argument_value(argument));
210 break;
211 case 2:
212 printf("%g\n", ply_get_argument_value(argument));
213 break;
214 default:
215 break;
216 }
217 return 1;
218 }
219
220 int main(void) {
221 long nvertices, ntriangles;
222 p_ply ply = ply_open("input.ply", NULL, 0, NULL);
223 if (!ply) return 1;
224 if (!ply_read_header(ply)) return 1;
225 nvertices = ply_set_read_cb(ply, "vertex", "x", vertex_cb, NULL, 0);
226 ply_set_read_cb(ply, "vertex", "y", vertex_cb, NULL, 0);
227 ply_set_read_cb(ply, "vertex", "z", vertex_cb, NULL, 1);
228 ntriangles = ply_set_read_cb(ply, "face", "vertex_indices", face_cb, NULL, 0);
229 printf("%ld\n%ld\n", nvertices, ntriangles);
230 if (!ply_read(ply)) return 1;
231 ply_close(ply);
232 return 0;
233 }
234 </pre>
235
236 <p> RPly uses callbacks to pass data to an application. Independent callbacks
237 can be associated with each property of each element. For scalar
238 properties, the callback is invoked once for each instance. For list
239 properties, the callback is invoked first with the number of
240 entries in the instance, and then once for each of the data entries.
241 <em>This is exactly the order in which the data items appear in the
242 file.</em></p>
243
244 <p> To keep things simple, values are always passed as <tt>double</tt>,
245 regardless of how they are stored in the file. From its parameters,
246 callbacks can find out exactly which part of the file is being processed
247 (including the actual type of the value), plus access custom information
248 provided by the user in the form of a pointer and an integer constant. </p>
249
250 <p> In our example, we start with a call to <tt>ply_open</tt> to open a
251 file for reading. Then we get RPly to parse it's header, with a call to
252 <tt>ply_read_header</tt>. After the header is parsed, RPly knows which
253 element types and properties are available. We then set callbacks for each
254 of the <tt>vertex</tt> element properties and the <tt>face</tt> property
255 (using <tt>ply_set_read_cb</tt>). Finally, we invoke the main RPly reading
256 function, <tt>ply_read</tt>. This function reads all data in the file,
257 passing the data to the appropriate callbacks. After all reading is done,
258 we call <tt>ply_close</tt> to release any resources used by RPly.</p>
259
260 <p>There are some details, of course. <tt>Ply_set_read_cb</tt> returns the
261 number of instances of the target property (which is the same as the number
262 of element instances). This is how the program obtains the number of
263 vertices and faces in the file. </p>
264
265 <p>RPly lets us associate one pointer <em>and</em> one integer to each
266 callback. We are free to use either or both to link some context to our
267 callbacks. Our example uses the integer placeholder to tell
268 <tt>vertex_cb</tt> that it has to break the line after the <tt>z</tt>
269 property (notice the last argument of <tt>ply_set_read_cb</tt>).</p>
270
271 <p><tt>Vertex_cb</tt> gets the user data and the property value from it's
272 argument and prints accordingly. The <tt>face_cb</tt> callback is a bit
273 more complicated because lists are more complicated. Since the
274 simple file format only supports triangles, it only prints the first
275 3 list values, after which it breaks the line. </p>
276
277 <p> The output of the program, as expected, is: </p>
278
279 <pre class=example>
280 3
281 1
282 -1 0 0
283 0 1 0
284 1 0 0
285 0 1 2
286 </pre>
287
288 <h2> Writing files with RPly </h2>
289
290 <p> The next example is somewhat more involved. We will create a program
291 that converts our simple PLY file to binary mode. Besides showing how to
292 write a PLY file, this example also illustrates the query functions. We
293 do not know a priori which elements and properties, comments and obj_infos
294 will be in the input file, so we need a way to find out. Although our simple
295 program would work on any PLY file, a better version of this program is
296 available from the RPly distribution. For simplicity, the simple version
297 omits error messages and command line parameter processing. </p>
298
299 <p> In practice, writing a file is even easier than reading one. First we
300 create a file in binary mode, with a call to <tt>ply_create</tt> (notice
301 the argument <tt>PLY_LITTLE_ENDIAN</tt> that gives the storage mode). Then,
302 we define the elements using <tt>ply_add_element</tt>. After each element, we
303 define its properties using <tt>ply_add_scalar_property</tt> or
304 <tt>ply_add_list_property</tt>. When we are done with elements and
305 properties, we add comments and obj_infos. We then write the header with
306 <tt>ply_write_header</tt> and send all data items. The data items are sent
307 one by one, with calls to <tt>ply_write</tt>, <em>in the same order they
308 are to appear in the file</em>. Again, to simplify things, this function
309 receives data as <tt>double</tt> and performs the needed conversion. Here
310 is the code for the example: </p>
311
312 <pre class=example>
313 #include &lt;stdio.h&gt;
314 #include "rply.h"
315
316 static int callback(p_ply_argument argument) {
317 void *pdata;
318 /* just pass the value from the input file to the output file */
319 ply_get_argument_user_data(argument, &amp;pdata, NULL);
320 ply_write((p_ply) pdata, ply_get_argument_value(argument));
321 return 1;
322 }
323
324 static int setup_callbacks(p_ply iply, p_ply oply) {
325 p_ply_element element = NULL;
326 /* iterate over all elements in input file */
327 while ((element = ply_get_next_element(iply, element))) {
328 p_ply_property property = NULL;
329 long ninstances = 0;
330 const char *element_name;
331 ply_get_element_info(element, &amp;element_name, &amp;ninstances);
332 /* add this element to output file */
333 if (!ply_add_element(oply, element_name, ninstances)) return 0;
334 /* iterate over all properties of current element */
335 while ((property = ply_get_next_property(element, property))) {
336 const char *property_name;
337 e_ply_type type, length_type, value_type;
338 ply_get_property_info(property, &amp;property_name, &amp;type,
339 &amp;length_type, &amp;value_type);
340 /* setup input callback for this property */
341 if (!ply_set_read_cb(iply, element_name, property_name, callback,
342 oply, 0)) return 0;
343 /* add this property to output file */
344 if (!ply_add_property(oply, property_name, type, length_type,
345 value_type)) return 0;
346 }
347 }
348 return 1;
349 }
350
351 int main(int argc, char *argv[]) {
352 const char *value;
353 p_ply iply, oply;
354 iply = ply_open("input.ply", NULL, 0, NULL);
355 if (!iply) return 1;
356 if (!ply_read_header(iply)) return 1;
357 oply = ply_create("output.ply", PLY_LITTLE_ENDIAN, NULL, 0, NULL);
358 if (!oply) return 1;
359 if (!setup_callbacks(iply, oply)) return 1;
360 /* pass comments and obj_infos from input to output */
361 value = NULL;
362 while ((value = ply_get_next_comment(iply, value)))
363 if (!ply_add_comment(oply, value)) return 1;
364 value = NULL;
365 while ((value = ply_get_next_obj_info(iply, value)))
366 if (!ply_add_obj_info(oply, value)) return 1;;
367 /* write output header */
368 if (!ply_write_header(oply)) return 1;
369 /* read input file generating callbacks that pass data to output file */
370 if (!ply_read(iply)) return 1;
371 /* close up, we are done */
372 if (!ply_close(iply)) return 1;
373 if (!ply_close(oply)) return 1;
374 return 0;
375 }
376 </pre>
377
378 <p> RPly uses iterators to let the user loop over a PLY file header. A
379 function is used to get the first item of a given class (element, property
380 etc). Passing the last returned item to the same function produces the next
381 item, until there are no more items. Examples of iterator use can be seen
382 in the <tt>main</tt> function, which uses them to loop over comments and
383 obj_infos, and in the <tt>setup_callbacks</tt> function, which loops over
384 elements and properties. </p>
385
386 <p> In the <tt>setup_callbacks</tt> function, for each element in the
387 input, an equivalent element is defined in the output. For each property in
388 each element, an equivalent property is defined in the output. Notice that
389 the same callback is specified for all properties. It is given the output
390 PLY handle as the context pointer. Each time it is called, it passes the
391 received value to <tt>ply_write</tt> on the output handle. It is as simple
392 as that. </p>
393
394 <h2> A note on locale </h2>
395
396 <p> ASCII PLY files are supposed to use the <tt>C</tt>
397 locale for numeric formatting. RPly relies on library
398 functions (such as <tt>fprintf</tt> and <tt>strtod</tt>)
399 that are affected by the current locale. If your software
400 modifies the locale (or if it uses another library/toolkit that
401 does) and you use RPly under the modified locale, you may be
402 unable to read or write properly formatted ASCII PLY files.
403 </p>
404
405 <p> Modifying RPly internally to hedge against different
406 locales would be complicated, particularly in multi-threaded
407 applications. Therefore, RPly leaves this as your
408 responsibility. To protect against locale problems in the
409 simplest scenario, you should bracket RPly I/O as follows: </p>
410
411 <pre class="example">
412 #include &lt;locale.h&gt;
413 /* Save application locale */
414 const char *old_locale = setlocale(LC_NUMERIC, NULL);
415 /* Change to PLY standard */
416 setlocale(LC_NUMERIC, "C");
417 /* Use the RPly library */
418 ...
419
420 /* Restore application locale when done */
421 setlocale(LC_NUMERIC, old_locale);
422 </pre>
423
424 <h1>Reference Manual</h1>
425
426 <!-- ply_open ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
427
428 <p class=name id=ply_open>
429 p_ply <b>ply_open</b>(const char *name, p_ply_error_cb error_cb, long idata, void *pdata)
430 </p>
431
432 <p class=description>
433 Opens a PLY file for reading, checks if it is a valid PLY file
434 and returns a handle to it.
435 </p>
436
437 <p class=arguments>
438 <tt>Name</tt> is the file name, and <tt>error_cb</tt> is a function to
439 be called when an error is found.
440 Arguments <tt>idata</tt>
441 and <tt>pdata</tt> are available to the error callback via the
442 <a href=#ply_get_ply_user_data><tt>ply_get_ply_user_data</tt></a>
443 function.
444 If <tt>error_cb</tt> is NULL, the default
445 error callback is used. It prints a message to the standard error stream.
446 </p>
447
448 <p class=return>
449 Returns a handle to the file or NULL on error.
450 </p>
451
452 <p class=note>
453 Note: <tt>Error_cb</tt> is of type <tt>void
454 (*p_ply_error_cb)(p_ply ply, const char *message)</tt>.
455 </p>
456
457 <!-- ply_open_from_file ++++++++++++++++++++++++++++++++++++++++++++++++ -->
458
459 <p class=name id=ply_open_from_file>
460 p_ply <b>ply_open_from_file</b>(FILE *file_pointer, p_ply_error_cb error_cb, long idata, void *pdata)
461 </p>
462
463 <p class=description>
464 Checks if the FILE pointer points to a valid PLY file and returns a
465 handle to it. The handle can be used wherever a handle returned by <a
466 href=#ply_open><tt>ply_open</tt></a> is accepted.
467 </p>
468
469 <p class=arguments>
470 <tt>File_pointer</tt> is the FILE pointer open for reading, and <tt>error_cb</tt> is a function to be called when an error is found.
471 Arguments <tt>idata</tt>
472 and <tt>pdata</tt> are available to the error callback via the
473 <a href=#ply_get_ply_user_data><tt>ply_get_ply_user_data</tt></a>
474 function.
475 If <tt>error_cb</tt> is NULL, the default
476 error callback is used. It prints a message to the standard error stream.
477 </p>
478
479 <p class=return>
480 Returns a handle to the file or NULL on error.
481 </p>
482
483 <p class=note>
484 Note: <tt>Error_cb</tt> is of type <tt>void
485 (*p_ply_error_cb)(p_ply ply, const char *message)</tt>.
486 </p>
487
488 <p class=note>
489 Note: This function is declared in header <tt>rplyfile.h</tt>.
490 </p>
491
492 <!-- ply_get_ply_user_data ++++++++++++++++++++++++++++++++++++++++ -->
493
494 <p class=name id=ply_get_ply_user_data>
495 int <b>ply_get_ply_user_data</b>(p_ply_ply ply, void *pdata, long *idata)
496 </p>
497
498 <p class=description>
499 Retrieves user data from the ply handle.
500 </p>
501
502 <p class=arguments>
503 <tt>Ply</tt> is the handle passed to the error callback.
504 <tt>Pdata</tt> receives the user data pointer.
505 <tt>Idata</tt> receives the user data integer.
506 <tt>Pdata</tt> and <tt>idata</tt> can be NULL.
507 </p>
508
509 <p class=return>
510 Returns 1 in case of success, 0 otherwise.
511 </p>
512
513
514 <!-- ply_read_header +++++++++++++++++++++++++++++++++++++++++++++++++ -->
515
516 <p class=name id=ply_read_header>
517 int <b>ply_read_header</b>(p_ply ply)
518 </p>
519
520 <p class=description>
521 Reads and parses the header of a PLY file.
522 After a call to this function, the query functions
523 <a href=#ply_get_next_element><tt>ply_get_next_element</tt></a>,
524 <a href=#ply_get_next_property><tt>ply_get_next_property</tt></a>,
525 <a href=#ply_get_next_comment><tt>ply_get_next_comment</tt></a>, and
526 <a href=#ply_get_next_obj_info><tt>ply_get_next_obj_info</tt></a> can be
527 called. Callbacks can also be set with the
528 <a href=#ply_set_read_cb><tt>ply_set_read_cb</tt></a> function.
529 </p>
530
531 <p class=arguments>
532 <tt>Ply</tt> is a handle returned by <a
533 href=#ply_open><tt>ply_open</tt></a>.
534 </p>
535
536 <p class=return>
537 Returns 1 in case of success, 0 otherwise.
538 </p>
539
540 <!-- ply_set_read_cb +++++++++++++++++++++++++++++++++++++++++++++++++ -->
541
542 <p class=name id=ply_set_read_cb>
543 long <b>ply_set_read_cb</b>(<br>
544 &nbsp;&nbsp; p_ply ply,<br>
545 &nbsp;&nbsp; const char *element_name,<br>
546 &nbsp;&nbsp; const char *property_name,<br>
547 &nbsp;&nbsp; p_ply_read_cb read_cb,<br>
548 &nbsp;&nbsp; void *pdata,<br>
549 &nbsp;&nbsp; long idata<br>
550 )
551 </p>
552
553 <p class=description>
554 Sets up the callback to be invoked when the value of a property is read.
555 </p>
556
557 <p class=arguments>
558 <tt>Ply</tt> is a handle returned by <a href=#ply_open><tt>ply_open</tt></a>.
559 <tt>Element_name</tt> and <tt>property_name</tt> are the names of the
560 element and property of interest. <tt>Read_cb</tt> is the callback
561 function. <tt>Pdata</tt> and <tt>idata</tt> are user data to be passed to
562 the callback function.
563 </p>
564
565 <p class=return>
566 Returns the number of instances of the element of interest.
567 </p>
568
569 <p class=note>
570 Note: <tt>Read_cb</tt> is of type
571 <tt>int (*p_ply_read_cb)(p_ply_argument argument)</tt>.
572 The callback should return 1 to continue the reading process,
573 or return 0 to abort.
574
575 <!-- ply_get_argument_element ++++++++++++++++++++++++++++++++++++++++ -->
576
577 <p class=name id=ply_get_argument_element>
578 int <b>ply_get_argument_element</b>(<br>
579 &nbsp;&nbsp; p_ply_argument argument,<br>
580 &nbsp;&nbsp; p_ply_element *element,<br>
581 &nbsp;&nbsp; long *instance_index<br>
582 )
583 </p>
584
585 <p class=description>
586 Retrieves element information from the callback argument.
587 </p>
588
589 <p class=arguments>
590 <tt>Argument</tt> is the handle passed to the callback.
591 <tt>Element</tt> receives a handle to the element
592 originating the callback. <tt>Instance_index</tt> receives
593 the index of the instance of the element
594 being read. <tt>Element</tt> and <tt>instance_index</tt> can be NULL.
595 </p>
596
597 <p class=return>
598 Returns 1 in case of success, 0 otherwise.
599 </p>
600
601 <p class=note>
602 Note: further information can be obtained from <tt>element</tt> with a
603 call to <a href=#ply_get_element_info>ply_get_element_info</a>.
604 </p>
605
606 <!-- ply_get_argument_property +++++++++++++++++++++++++++++++++++++++ -->
607
608 <p class=name id=ply_get_argument_property>
609 int <b>ply_get_argument_property</b>(<br>
610 &nbsp;&nbsp; p_ply_argument argument,<br>
611 &nbsp;&nbsp; p_ply_property *property,<br>
612 &nbsp;&nbsp; long *length,<br>
613 &nbsp;&nbsp; long *value_index<br>
614 )
615 </p>
616
617 <p class=description>
618 Retrieves property information from the callback argument.
619 </p>
620
621 <p class=arguments>
622 <tt>Argument</tt> is the handle passed to the callback.
623 <tt>Property</tt> receives a handle to the property
624 originating the callback. <tt>Length</tt> receives the number
625 of values in the list property (1 for scalar properties).
626 <tt>Value_index</tt> receives the index of the current property entry (0 for
627 scalar properties, -1 for the first value of a list property, the one that
628 gives the number of entries). <tt>Property</tt>, <tt>length</tt> and
629 <tt>value_index</tt> can be NULL.
630 </p>
631
632 <p class=return>
633 Returns 1 in case of success, 0 otherwise.
634 </p>
635
636 <p class=note>
637 Note: further information can be obtained from <tt>property</tt> with a
638 call to <a href=#ply_get_property_info>ply_get_property_info</a>.
639 </p>
640
641 <!-- ply_get_argument_user_data +++++++++++++++++++++++++++++++++++++++ -->
642
643 <p class=name id=ply_get_argument_user_data>
644 int <b>ply_get_argument_user_data</b>(p_ply_argument argument, void *pdata,
645 long *idata)
646 </p>
647
648 <p class=description>
649 Retrieves the user data from the callback argument.
650 </p>
651
652 <p class=arguments>
653 <tt>Argument</tt> is the handle passed to the callback.
654 <tt>Pdata</tt> receives the user data pointer.
655 <tt>Idata</tt> receives the user data integer.
656 <tt>Pdata</tt> and <tt>idata</tt> can be NULL.
657 </p>
658
659 <p class=return>
660 Returns 1 in case of success, 0 otherwise.
661 </p>
662
663 <!-- ply_get_argument_value +++++++++++++++++++++++++++++++++++++++++++ -->
664
665 <p class=name id=ply_get_argument_value>
666 double <b>ply_get_argument_value</b>(p_ply_argument argument)
667 </p>
668
669 <p class=description>
670 Retrieves the property value from the callback argument.
671 </p>
672
673 <p class=arguments>
674 <tt>Argument</tt> is the handle passed to the callback.
675 </p>
676
677 <p class=return>
678 Returns the property value.
679 </p>
680
681 <!-- ply_read +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
682
683 <p class=name id=ply_read>
684 int <b>ply_read</b>(p_ply ply)
685 </p>
686
687 <p class=description>
688 Reads all data in file, calling appropriate callbacks.
689 </p>
690
691 <p class=arguments>
692 <tt>Ply</tt> is a handle returned by <a href=#ply_open><tt>ply_open</tt></a>.
693 </p>
694
695 <p class=return>
696 Returns 1 in case of success, 0 otherwise.
697 </p>
698
699 <!-- ply_get_next_element ++++++++++++++++++++++++++++++++++++++++++++ -->
700
701 <p class=name id=ply_get_next_element>
702 p_ply_element <b>ply_get_next_element</b>(p_ply ply, p_ply_element last)
703 </p>
704
705 <p class=description>
706 Iterates over all elements on the header of a PLY file.
707 </p>
708
709 <p class=arguments>
710 <tt>Ply</tt> is a handle returned by <a href=#ply_open><tt>ply_open</tt></a>.
711 <a href=#ply_read_header><tt>Ply_read_header</tt></a> must have been called
712 on the handle otherwise no elements will be found.
713 <tt>Last</tt> is NULL to retrieve the first element, and an element to
714 retrieve the next element.
715 </p>
716
717 <p class=return>
718 Returns the next element, or NULL if no more elements.
719 </p>
720
721 <p class=note>
722 Note: further information can be obtained from an element with a
723 call to <a href=#ply_get_element_info>ply_get_element_info</a>.
724 </p>
725
726 <!-- ply_get_next_property +++++++++++++++++++++++++++++++++++++++++++ -->
727
728 <p class=name id=ply_get_next_property>
729 p_ply_property <b>ply_get_next_property</b>(p_ply_element element, p_ply_property last)
730 </p>
731
732 <p class=description>
733 Iterates over all properties of an element.
734 </p>
735
736 <p class=arguments>
737 <tt>Element</tt> is an element handle.
738 <tt>Last</tt> is NULL to retrieve the first property, and a property to
739 retrieve the next property.
740 </p>
741
742 <p class=return>
743 Returns the next property, or NULL if no more properties.
744 </p>
745
746 <p class=note>
747 Note: further information can be obtained from a property with a
748 call to <a href=#ply_get_property_info>ply_get_property_info</a>.
749 </p>
750
751 <!-- ply_get_next_comment ++++++++++++++++++++++++++++++++++++++++++++ -->
752
753 <p class=name id=ply_get_next_comment>
754 const char *<b>ply_get_next_comment</b>(p_ply ply, const char *last)
755 </p>
756
757 <p class=description>
758 Iterates over all comments on the header of a PLY file.
759 </p>
760
761 <p class=arguments>
762 <tt>Ply</tt> is a handle returned by <a href=#ply_open><tt>ply_open</tt></a>.
763 <a href=#ply_read_header><tt>Ply_read_header</tt></a> must have been called
764 on the handle otherwise no comments will be found.
765 <tt>Last</tt> is NULL to retrieve the first comment, and a comment to
766 retrieve the next comment.
767 </p>
768
769 <p class=return>
770 Returns the next comment, or NULL if no more comments.
771 </p>
772
773 <!-- ply_get_next_obj_info +++++++++++++++++++++++++++++++++++++++++++ -->
774
775 <p class=name id=ply_get_next_obj_info>
776 const char *<b>ply_get_next_obj_info</b>(p_ply ply, const char *last)
777 </p>
778
779 <p class=description>
780 Iterates over all obj_infos on the header of a PLY file.
781 </p>
782
783 <p class=arguments>
784 <tt>Ply</tt> is a handle returned by <a href=#ply_open><tt>ply_open</tt></a>.
785 <a href=#ply_read_header><tt>Ply_read_header</tt></a> must have been called
786 on the handle otherwise no obj_infos will be found.
787 <tt>Last</tt> is NULL to retrieve the first obj_info, and a obj_info to
788 retrieve the next obj_info.
789 </p>
790
791 <p class=return>
792 Returns the next obj_info, or NULL if no more obj_infos.
793 </p>
794
795 <!-- ply_get_element_info ++++++++++++++++++++++++++++++++++++++++++++ -->
796
797 <p class=name id=ply_get_element_info>
798 int <b>ply_get_element_info</b>(p_ply_element element, const char** name,
799 long *ninstances)
800 </p>
801
802 <p class=description>
803 Retrieves information from an element handle.
804 </p>
805
806 <p class=arguments>
807 <tt>Element</tt> is the handle of the element of interest.
808 <tt>Name</tt> receives the internal copy of the element name.
809 <tt>Ninstances</tt> receives the number of instances of this element
810 in the file. Both <tt>name</tt> and <tt>ninstances</tt> can be NULL.
811 </p>
812
813 <p class=return>
814 Returns 1 in case of success, 0 otherwise.
815 </p>
816
817 <!-- ply_get_property_info +++++++++++++++++++++++++++++++++++++++++++ -->
818
819 <p class=name id=ply_get_property_info>
820 int <b>ply_get_property_info</b>(<br>
821 &nbsp;&nbsp; p_ply_property property,<br>
822 &nbsp;&nbsp; const char** name,<br>
823 &nbsp;&nbsp; e_ply_type *type,<br>
824 &nbsp;&nbsp; e_ply_type *length_type,<br>
825 &nbsp;&nbsp; e_ply_type *value_type<br>
826 )
827 </p>
828
829 <p class=description>
830 Retrieves information from a property handle.
831 </p>
832
833 <p class=arguments>
834 <tt>Property</tt> is the handle of the property of interest.
835 <tt>Name</tt> receives the internal copy of the property name.
836 <tt>Type</tt> receives the property type.
837 <tt>Length_type</tt> receives the scalar type of the first entry
838 in a list property (the one that gives the number of entries).
839 <tt>Value_type</tt> receives the scalar type of the remaining list entries.
840 <tt>Name</tt>, <tt>type</tt>, <tt>length_type</tt>, and
841 <tt>value_type</tt> can be NULL.
842 </p>
843
844 <p class=return>
845 Returns 1 in case of success, 0 otherwise.
846 </p>
847
848 <p class=note>
849 Note: <tt>Length_type</tt> and <tt>value_type</tt> can
850 receive any of the constants for scalar types defined in
851 <tt>e_ply_type</tt>. <tt>Type</tt> can, in addition, be <tt>PLY_LIST</tt>,
852 in which case the property is a list property and the fields
853 <tt>length_type</tt> and <tt>value_type</tt> become meaningful.
854 </p>
855
856 <!-- ply_create ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
857
858 <p class=name id=ply_create>
859 p_ply <b>ply_create</b>(const char *name, e_ply_storage_mode storage_mode,
860 p_ply_error_cb error_cb)
861 </p>
862
863 <p class=description>
864 Creates a PLY file for writing.
865 </p>
866
867 <p class=arguments>
868 <tt>Name</tt> is the file name, <tt>storage_mode</tt> is the file storage mode
869 (<tt>PLY_ASCII</tt>, <tt>PLY_LITTLE_ENDIAN</tt>,
870 <tt>PLY_BIG_ENDIAN</tt>, or <tt>PLY_DEFAULT</tt> to
871 automatically detect host endianess).
872 <tt>Error_cb</tt> is a function to be called when an error is found.
873 Arguments <tt>idata</tt>
874 and <tt>pdata</tt> are available to the error callback via the
875 <a href=#ply_get_ply_user_data><tt>ply_get_ply_user_data</tt></a>
876 function.
877 If <tt>error_cb</tt> is NULL, the default
878 error callback is used. It prints a message to the standard error stream.
879 </p>
880
881 <p class=return>
882 Returns a handle to the file or NULL on error.
883 </p>
884
885 <p class=note>
886 Note: <tt>Error_cb</tt> is of type <tt>void
887 (*p_ply_error_cb)(const char *message)</tt>
888 </p>
889
890 <!-- ply_create_to_file ++++++++++++++++++++++++++++++++++++++++++++++++++ -->
891
892 <p class=name id=ply_create_to_file>
893 p_ply <b>ply_create_to_file</b>(FILE *file_pointer, e_ply_storage_mode storage_mode, p_ply_error_cb error_cb)
894 </p>
895
896 <p class=description>
897 Creates a PLY file to be written to a FILE pointer and
898 returns a handle to it.
899 The handle can be used wherever a handle returned by <a
900 href=#ply_create><tt>ply_create</tt></a> is accepted.
901 </p>
902
903 <p class=arguments>
904 <tt>File_pointer</tt> a pointer to a file open for writing, <tt>storage_mode</tt> is the file storage mode
905 (<tt>PLY_ASCII</tt>, <tt>PLY_LITTLE_ENDIAN</tt>,
906 <tt>PLY_BIG_ENDIAN</tt>, or <tt>PLY_DEFAULT</tt> to
907 automatically detect host endianess).
908 <tt>Error_cb</tt> is a function to be called when an error is found.
909 Arguments <tt>idata</tt>
910 and <tt>pdata</tt> are available to the error callback via the
911 <a href=#ply_get_ply_user_data><tt>ply_get_ply_user_data</tt></a>
912 function.
913 If <tt>error_cb</tt> is NULL, the default
914 error callback is used. It prints a message to the standard error stream.
915 </p>
916
917 <p class=return>
918 Returns a handle to the file or NULL on error.
919 </p>
920
921 <p class=note>
922 Note: <tt>Error_cb</tt> is of type <tt>void
923 (*p_ply_error_cb)(const char *message)</tt>
924 </p>
925
926 <p class=note>
927 Note: This function is declared in header <tt>rplyfile.h</tt>.
928 </p>
929
930 <!-- ply_add_element +++++++++++++++++++++++++++++++++++++++++++++++++ -->
931
932 <p class=name id=ply_add_element>
933 int <b>ply_add_element</b>(p_ply ply, const char *name, long ninstances)
934 </p>
935
936 <p class=description>
937 Adds a new element to the ply file.
938 </p>
939
940 <p class=arguments>
941 <tt>Ply</tt> is a handle returned by
942 <a href=#ply_create><tt>ply_create</tt></a>, <tt>name</tt> is the element
943 name and <tt>ninstances</tt> is the number of instances of this element that
944 will be written to the file.
945 </p>
946
947 <p class=return>
948 Returns 1 in case of success, 0 otherwise.
949 </p>
950
951 <!-- ply_add_property ++++++++++++++++++++++++++++++++++++++++++++++++ -->
952
953 <p class=name id=ply_add_property>
954 int <b>ply_add_property</b>(<br>
955 &nbsp;&nbsp; p_ply ply,<br>
956 &nbsp;&nbsp; const char *name,<br>
957 &nbsp;&nbsp; e_ply_type type,<br>
958 &nbsp;&nbsp; e_ply_type length_type,<br>
959 &nbsp;&nbsp; e_ply_type value_type<br>
960 )
961 </p>
962
963 <p class=description>
964 Adds a new property to the last element added to the ply file.
965 </p>
966
967 <p class=arguments>
968 <tt>Ply</tt> is a handle returned by
969 <a href=#ply_create><tt>ply_create</tt></a> and <tt>name</tt> is the
970 property name.
971 <tt>Type</tt> is the property type.
972 <tt>Length_type</tt> is the scalar type of the first entry
973 in a list property (the one that gives the number of entries).
974 <tt>Value_type</tt> is the scalar type of the remaining list entries.
975 If <tt>type</tt> is not <tt>PLY_LIST</tt>, <tt>length_type</tt> and
976 <tt>value_type</tt> are ignored.
977 </p>
978
979 <p class=return>
980 Returns 1 in case of success, 0 otherwise.
981 </p>
982
983 <p class=note>
984 Note: <tt>Length_type</tt> and <tt>value_type</tt> can
985 be any of the constants for scalar types defined in
986 <tt>e_ply_type</tt>. <tt>Type</tt> can, in addition, be <tt>PLY_LIST</tt>,
987 in which case the property is a list property and the fields
988 <tt>length_type</tt> and <tt>value_type</tt> become meaningful.
989 </p>
990
991 <!-- ply_add_list_property ++++++++++++++++++++++++++++++++++++++++++ -->
992
993 <p class=name id=ply_add_list_property>
994 int <b>ply_add_list_property</b>(<br>
995 &nbsp;&nbsp; p_ply ply,<br>
996 &nbsp;&nbsp; const char *name,<br>
997 &nbsp;&nbsp; e_ply_type length_type,<br>
998 &nbsp;&nbsp; e_ply_type value_type<br>
999 )
1000 </p>
1001
1002 <p class=description>
1003 Same as <a href=#ply_add_property><tt>ply_add_property</tt></a> if
1004 <tt>type</tt> is <tt>PLY_LIST</tt>.
1005 </p>
1006
1007 <!-- ply_add_scalar_property +++++++++++++++++++++++++++++++++++++++++ -->
1008
1009 <p class=name id=ply_add_scalar_property>
1010 int <b>ply_add_scalar_property</b>(p_ply ply, const char *name, e_ply_type type)
1011 </p>
1012
1013 <p class=description>
1014 Same as <a href=#ply_add_property><tt>ply_add_property</tt></a> if
1015 <tt>type</tt> is <em>not</em> <tt>PLY_LIST</tt>.
1016 </p>
1017
1018 <!-- ply_add_comment +++++++++++++++++++++++++++++++++++++++++++++++++ -->
1019
1020 <p class=name id=ply_add_comment>
1021 int <b>ply_add_comment</b>(p_ply ply, const char *comment);
1022 </p>
1023
1024 <p class=description>
1025 Adds a comment to a PLY file.
1026 </p>
1027
1028 <p class=arguments>
1029 <tt>Ply</tt> is a handle returned by
1030 <a href=#ply_create><tt>ply_create</tt></a> and <tt>comment</tt> is the
1031 comment text.
1032 </p>
1033
1034 <p class=return>
1035 Returns 1 in case of success, 0 otherwise.
1036 </p>
1037
1038 <!-- ply_add_obj_info ++++++++++++++++++++++++++++++++++++++++++++++++ -->
1039
1040 <p class=name id=ply_add_obj_info>
1041 int <b>ply_add_obj_info</b>(p_ply ply, const char *obj_info);
1042 </p>
1043
1044 <p class=description>
1045 Adds a obj_info to a PLY file.
1046 </p>
1047
1048 <p class=arguments>
1049 <tt>Ply</tt> is a handle returned by
1050 <a href=#ply_create><tt>ply_create</tt></a> and <tt>obj_info</tt> is the
1051 obj_info text.
1052 </p>
1053
1054 <p class=return>
1055 Returns 1 in case of success, 0 otherwise.
1056 </p>
1057
1058 <!-- ply_write_header ++++++++++++++++++++++++++++++++++++++++++++++++ -->
1059
1060 <p class=name id=ply_write_header>
1061 int <b>ply_write_header</b>(p_ply ply);
1062 </p>
1063
1064 <p class=description>
1065 Writes the PLY file header to disk, after all elements, properties,
1066 comments and obj_infos have been added to the handle.
1067 </p>
1068
1069 <p class=arguments>
1070 <tt>Ply</tt> is a handle returned by
1071 <a href=#ply_create><tt>ply_create</tt></a> and <tt>comment</tt> is the
1072 comment text.
1073 </p>
1074
1075 <p class=return>
1076 Returns 1 in case of success, 0 otherwise.
1077 </p>
1078
1079 <!-- ply_write +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
1080
1081 <p class=name id=ply_write>
1082 int <b>ply_write</b>(p_ply ply, double value);
1083 </p>
1084
1085 <p class=description>
1086 Passes a value to be stored in the PLY file.
1087 Values must be passed in the order they will appear in the file.
1088 </p>
1089
1090 <p class=arguments>
1091 <tt>Ply</tt> is a handle returned by
1092 <a href=#ply_create><tt>ply_create</tt></a> and <tt>value</tt> is the
1093 value to be stored. For simplicity, values are always passed as
1094 <tt>double</tt> and conversion is performed as needed.
1095 </p>
1096
1097 <p class=return>
1098 Returns 1 in case of success, 0 otherwise.
1099 </p>
1100
1101 <!-- ply_close +++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
1102
1103 <p class=name id=ply_close>
1104 int <b>ply_close</b>(p_ply ply);
1105 </p>
1106
1107 <p class=description>
1108 Closes the handle and ensures that all resources have been freed and data
1109 have been written.
1110 </p>
1111
1112 <p class=arguments>
1113 <tt>Ply</tt> is a handle returned by
1114 <a href=#ply_create><tt>ply_create</tt></a> or by
1115 <a href=#ply_open><tt>ply_open</tt></a>.
1116 </p>
1117
1118 <p class=return>
1119 Returns 1 in case of success, 0 otherwise.
1120 </p>
1121
1122 <!-- footer ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
1123
1124 <div class=footer>
1125 <hr>
1126 <center>
1127 <p>
1128 <small>
1129 Last modified by Diego Nehab on <br>
1130 Fri Aug 21 17:11:09 BRT 2015
1131 </small>
1132 </p>
1133 </center>
1134 </div>
1135
1136 </body>
1137 </html>